Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/CPZ/RotatePlatform.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Rotate Platform Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.centerPos.x
13
private alias object.value1 : object.centerPos.y
14
private alias object.value2 : object.drawPos.x
15
private alias object.value3 : object.drawPos.y
16
private alias object.value4 : object.hitboxL
17
private alias object.value5 : object.hitboxR
18
private alias object.value6 : object.stoodPlayers
19
20
// Player Aliases
21
private alias object.xpos : player.xpos
22
private alias object.ypos : player.ypos
23
24
private alias object.value17 : debugMode.currentSelection
25
26
27
// ========================
28
// Function Declarations
29
// ========================
30
31
reserve function RotatePlatform_DebugDraw
32
reserve function RotatePlatform_DebugSpawn
33
34
35
// ========================
36
// Static Values
37
// ========================
38
39
private value RotatePlatform_startDebugID = 0
40
41
42
// ========================
43
// Function Definitions
44
// ========================
45
46
private function RotatePlatform_DebugDraw
47
temp0 = debugMode[0].currentSelection
48
temp0 -= RotatePlatform_startDebugID
49
temp0 >>= 2
50
DrawSprite(temp0)
51
end function
52
53
54
private function RotatePlatform_DebugSpawn
55
temp0 = debugMode[0].currentSelection
56
temp0 -= RotatePlatform_startDebugID
57
temp2 = temp0
58
temp0 &= 3
59
temp2 >>= 2
60
temp0 <<= 4
61
temp1 = object.direction
62
temp1 <<= 6
63
temp0 += temp1
64
CreateTempObject(TypeName[Rotate Platform], temp0, object.xpos, object.ypos)
65
66
object[tempObjectPos].centerPos.x = object.xpos
67
object[tempObjectPos].centerPos.y = object.ypos
68
object[tempObjectPos].frame = temp2
69
if temp2 == 0
70
object[tempObjectPos].hitboxL = -32
71
object[tempObjectPos].hitboxR = 32
72
else
73
object[tempObjectPos].hitboxL = -24
74
object[tempObjectPos].hitboxR = 24
75
end if
76
end function
77
78
79
// ========================
80
// Events
81
// ========================
82
83
event ObjectUpdate
84
temp4 = object.drawPos.x
85
temp5 = object.drawPos.y
86
87
// Fetch MoveX value
88
GetTableValue(temp0, 28, StageSetup_oscillationTable)
89
temp0 <<= 8
90
temp0 &= 0xFFFF0000
91
temp0 -= 0x400000
92
93
// Fetch MoveY value
94
GetTableValue(temp1, 30, StageSetup_oscillationTable)
95
temp1 <<= 8
96
temp1 &= 0xFFFF0000
97
temp1 -= 0x400000
98
99
GetBit(temp2, object.propertyValue, 5) // flipMoveXY bit
100
if temp2 == true
101
FlipSign(temp0)
102
FlipSign(temp1)
103
end if
104
105
GetBit(temp2, object.propertyValue, 6) // flipMoveX bit
106
if temp2 == true
107
FlipSign(temp0)
108
end if
109
110
GetBit(temp2, object.propertyValue, 4) // flipMoveY bit
111
if temp2 == false
112
object.drawPos.x = temp0
113
object.drawPos.y = temp1
114
else
115
FlipSign(temp0)
116
object.drawPos.x = temp1
117
object.drawPos.y = temp0
118
end if
119
120
object.drawPos.x += object.centerPos.x
121
object.drawPos.y += object.centerPos.y
122
123
temp6 = object.drawPos.x
124
temp6 -= temp4
125
temp7 = object.drawPos.y
126
temp7 -= temp5
127
object.xpos = object.drawPos.x
128
object.ypos = object.drawPos.y
129
130
temp2 = 0
131
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
132
GetBit(temp0, object.stoodPlayers, temp2)
133
if temp0 == true
134
player[currentPlayer].xpos += temp6
135
player[currentPlayer].ypos += temp7
136
end if
137
138
SetBit(object.stoodPlayers, temp2, false)
139
BoxCollisionTest(C_PLATFORM, object.entityPos, object.hitboxL, -16, object.hitboxR, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
140
if checkResult == true
141
SetBit(object.stoodPlayers, temp2, true)
142
end if
143
144
temp2++
145
next
146
147
object.xpos = object.centerPos.x
148
object.ypos = object.centerPos.y
149
end event
150
151
152
event ObjectDraw
153
DrawSpriteXY(object.frame, object.drawPos.x, object.drawPos.y)
154
end event
155
156
157
event ObjectStartup
158
LoadSpriteSheet("CPZ/Objects.gif")
159
SpriteFrame(-32, -16, 64, 27, 136, 155)
160
SpriteFrame(-24, -16, 48, 26, 136, 183)
161
162
foreach (TypeName[Rotate Platform], arrayPos0, ALL_ENTITIES)
163
object[arrayPos0].centerPos.x = object[arrayPos0].xpos
164
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
165
object[arrayPos0].frame = object[arrayPos0].propertyValue
166
object[arrayPos0].frame &= 15
167
if object[arrayPos0].frame == 0
168
object[arrayPos0].hitboxL = -32
169
object[arrayPos0].hitboxR = 32
170
else
171
object[arrayPos0].hitboxL = -24
172
object[arrayPos0].hitboxR = 24
173
end if
174
next
175
176
temp0 = 0
177
RotatePlatform_startDebugID = DebugMode_ObjCount
178
while temp0 < 8
179
SetTableValue(TypeName[Rotate Platform], DebugMode_ObjCount, DebugMode_TypesTable)
180
SetTableValue(RotatePlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
181
SetTableValue(RotatePlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
182
DebugMode_ObjCount++
183
temp0++
184
loop
185
end event
186
187
188
// ========================
189
// Editor Events
190
// ========================
191
192
event RSDKEdit
193
if editor.returnVariable == true
194
switch editor.variableID
195
case EDIT_VAR_PROPVAL // property value
196
checkResult = object.propertyValue
197
break
198
199
case 0 // frameID
200
GetBit(checkResult, object.propertyValue, 0)
201
break
202
203
case 1 // flipMoveX
204
GetBit(checkResult, object.propertyValue, 6)
205
break
206
207
case 2 // flipMoveY
208
GetBit(checkResult, object.propertyValue, 4)
209
break
210
211
case 3 // flipMoveXY
212
GetBit(checkResult, object.propertyValue, 5)
213
break
214
215
end switch
216
else
217
switch editor.variableID
218
case EDIT_VAR_PROPVAL // property value
219
object.propertyValue = editor.variableValue
220
break
221
222
case 0 // frameID
223
CheckNotEqual(editor.variableValue, 0)
224
SetBit(object.propertyValue, 0, checkResult)
225
break
226
227
case 1 // flipMoveX
228
CheckNotEqual(editor.variableValue, 0)
229
SetBit(object.propertyValue, 6, checkResult)
230
break
231
232
case 2 // flipMoveY
233
CheckNotEqual(editor.variableValue, 0)
234
SetBit(object.propertyValue, 4, checkResult)
235
break
236
237
case 3 // flipMoveXY
238
CheckNotEqual(editor.variableValue, 0)
239
SetBit(object.propertyValue, 5, checkResult)
240
break
241
242
end switch
243
end if
244
end event
245
246
247
event RSDKDraw
248
temp0 = object.propertyValue
249
temp0 &= 15
250
DrawSprite(temp0)
251
end event
252
253
254
event RSDKLoad
255
LoadSpriteSheet("CPZ/Objects.gif")
256
SpriteFrame(-32, -16, 64, 27, 136, 155)
257
SpriteFrame(-24, -16, 48, 26, 136, 183)
258
259
AddEditorVariable("frameID")
260
SetActiveVariable("frameID")
261
AddEnumVariable("Large", 0)
262
AddEnumVariable("Small", 1)
263
264
AddEditorVariable("flipMoveX")
265
SetActiveVariable("flipMoveX")
266
AddEnumVariable("false", false)
267
AddEnumVariable("true", true)
268
269
AddEditorVariable("flipMoveY")
270
SetActiveVariable("flipMoveY")
271
AddEnumVariable("false", false)
272
AddEnumVariable("true", true)
273
274
AddEditorVariable("flipMoveXY")
275
SetActiveVariable("flipMoveXY")
276
AddEnumVariable("false", false)
277
AddEnumVariable("true", true)
278
end event
279
280