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/WFZ/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.startPos.x
13
private alias object.value1 : object.startPos.y
14
private alias object.value2 : object.drawPos.x
15
private alias object.value3 : object.drawPos.y
16
private alias object.value4 : object.hitbox.left
17
private alias object.value5 : object.hitbox.right
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
58
temp2 = temp0
59
temp0 &= 3
60
temp2 >>= 2
61
temp0 <<= 4
62
temp1 = object.direction
63
temp1 <<= 6
64
temp0 += temp1
65
CreateTempObject(TypeName[Rotate Platform], temp0, object.xpos, object.ypos)
66
67
object[tempObjectPos].startPos.x = object.xpos
68
object[tempObjectPos].startPos.y = object.ypos
69
object[tempObjectPos].frame = temp2
70
if temp2 == 0
71
object[tempObjectPos].hitbox.left = -32
72
object[tempObjectPos].hitbox.right = 32
73
else
74
object[tempObjectPos].hitbox.left = -24
75
object[tempObjectPos].hitbox.right = 24
76
end if
77
end function
78
79
80
// ========================
81
// Events
82
// ========================
83
84
event ObjectUpdate
85
temp4 = object.drawPos.x
86
temp5 = object.drawPos.y
87
88
GetTableValue(temp0, 28, StageSetup_oscillationTable)
89
temp0 <<= 8
90
temp0 &= 0xFFFF0000
91
temp0 -= 0x400000
92
93
GetTableValue(temp1, 30, StageSetup_oscillationTable)
94
temp1 <<= 8
95
temp1 &= 0xFFFF0000
96
temp1 -= 0x400000
97
98
GetBit(temp2, object.propertyValue, 5)
99
if temp2 == true
100
FlipSign(temp0)
101
FlipSign(temp1)
102
end if
103
104
GetBit(temp2, object.propertyValue, 6)
105
if temp2 == true
106
FlipSign(temp0)
107
end if
108
109
GetBit(temp2, object.propertyValue, 4)
110
if temp2 == false
111
object.drawPos.x = temp0
112
object.drawPos.y = temp1
113
else
114
FlipSign(temp0)
115
object.drawPos.x = temp1
116
object.drawPos.y = temp0
117
end if
118
119
object.drawPos.x += object.startPos.x
120
object.drawPos.y += object.startPos.y
121
122
temp6 = object.drawPos.x
123
temp6 -= temp4
124
temp7 = object.drawPos.y
125
temp7 -= temp5
126
object.xpos = object.drawPos.x
127
object.ypos = object.drawPos.y
128
129
temp2 = 0
130
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
131
GetBit(temp0, object.stoodPlayers, temp2)
132
if temp0 == true
133
player[currentPlayer].xpos += temp6
134
player[currentPlayer].ypos += temp7
135
end if
136
137
SetBit(object.stoodPlayers, temp2, false)
138
BoxCollisionTest(C_PLATFORM, object.entityPos, object.hitbox.left, -16, object.hitbox.right, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
139
if checkResult == true
140
SetBit(object.stoodPlayers, temp2, true)
141
end if
142
temp2++
143
next
144
145
object.xpos = object.startPos.x
146
object.ypos = object.startPos.y
147
end event
148
149
150
event ObjectDraw
151
DrawSpriteXY(object.frame, object.drawPos.x, object.drawPos.y)
152
end event
153
154
155
event ObjectStartup
156
CheckCurrentStageFolder("Zone11")
157
if checkResult == true
158
LoadSpriteSheet("SCZ/Objects.gif")
159
SpriteFrame(-24, -16, 48, 24, 381, 178) // Small Platform - #0
160
SpriteFrame(-32, -16, 64, 24, 1, 146) // Wide Platform - #1
161
else
162
LoadSpriteSheet("MBZ/Objects.gif")
163
SpriteFrame(-24, -16, 48, 24, 529, 999) // Small Platform - #0
164
SpriteFrame(-32, -16, 64, 24, 464, 999) // Wide Platform - #1
165
end if
166
167
foreach (TypeName[Rotate Platform], arrayPos0, ALL_ENTITIES)
168
object[arrayPos0].startPos.x = object[arrayPos0].xpos
169
object[arrayPos0].startPos.y = object[arrayPos0].ypos
170
171
object[arrayPos0].frame = object[arrayPos0].propertyValue
172
object[arrayPos0].frame &= 0xF
173
174
if object[arrayPos0].frame == 0
175
object[arrayPos0].hitbox.left = -32
176
object[arrayPos0].hitbox.right = 32
177
else
178
object[arrayPos0].hitbox.left = -24
179
object[arrayPos0].hitbox.right = 24
180
end if
181
next
182
183
temp0 = 0
184
RotatePlatform_startDebugID = DebugMode_ObjCount
185
while temp0 < 8
186
SetTableValue(TypeName[Rotate Platform], DebugMode_ObjCount, DebugMode_TypesTable)
187
SetTableValue(RotatePlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
188
SetTableValue(RotatePlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
189
DebugMode_ObjCount++
190
temp0++
191
loop
192
end event
193
194
195
// ========================
196
// Editor Events
197
// ========================
198
199
event RSDKEdit
200
if editor.returnVariable == true
201
switch editor.variableID
202
case EDIT_VAR_PROPVAL // property value
203
checkResult = object.propertyValue
204
break
205
206
case 0 // type
207
checkResult = object.propertyValue
208
break
209
210
case 1 // flipMoveX
211
GetBit(checkResult, object.propertyValue, 6)
212
break
213
214
case 2 // flipMoveY
215
GetBit(checkResult, object.propertyValue, 5)
216
break
217
218
case 3 // flipMoveXY
219
GetBit(checkResult, object.propertyValue, 4)
220
break
221
222
end switch
223
else
224
switch editor.variableID
225
case EDIT_VAR_PROPVAL // property value
226
object.propertyValue = editor.variableValue
227
break
228
229
case 0 // type
230
object.propertyValue = editor.variableValue
231
break
232
233
case 1 // flipMoveX
234
CheckNotEqual(editor.variableValue, 0)
235
SetBit(object.propertyValue, 6, checkResult)
236
break
237
238
case 2 // flipMoveY
239
CheckNotEqual(editor.variableValue, 0)
240
SetBit(object.propertyValue, 5, checkResult)
241
break
242
243
case 3 // flipMoveXY
244
CheckNotEqual(editor.variableValue, 0)
245
SetBit(object.propertyValue, 4, checkResult)
246
break
247
248
end switch
249
end if
250
end event
251
252
253
event RSDKDraw
254
object.frame = object.propertyValue
255
object.frame &= 0xF
256
257
temp6 = object.xpos
258
temp7 = object.ypos
259
260
temp0 = 0
261
temp0 &= 0xFFFF0000
262
temp0 -= 0x500000
263
264
temp1 = 0
265
temp1 &= 0xFFFF0000
266
temp1 -= 0x500000
267
268
GetBit(temp2, object.propertyValue, 4)
269
if temp2 == true
270
FlipSign(temp0)
271
FlipSign(temp1)
272
end if
273
274
GetBit(temp2, object.propertyValue, 6)
275
if temp2 == true
276
FlipSign(temp0)
277
end if
278
279
GetBit(temp2, object.propertyValue, 5)
280
if temp2 == false
281
object.drawPos.x = temp0
282
object.drawPos.y = temp1
283
else
284
FlipSign(temp0)
285
object.drawPos.x = temp1
286
object.drawPos.y = temp0
287
end if
288
object.drawPos.x += temp6
289
object.drawPos.y += temp7
290
291
// Where the player will see it
292
if editor.showGizmos == true
293
editor.drawingOverlay = true
294
295
object.inkEffect = INK_BLEND
296
DrawSpriteFX(0, FX_INK, object.drawPos.x, object.drawPos.y)
297
298
editor.drawingOverlay = false
299
end if
300
301
// Actual Position
302
object.inkEffect = INK_NONE
303
DrawSprite(object.frame)
304
end event
305
306
307
event RSDKLoad
308
CheckCurrentStageFolder("Zone11")
309
if checkResult == true
310
LoadSpriteSheet("SCZ/Objects.gif")
311
SpriteFrame(-24, -16, 48, 24, 381, 178) // Small Platform - #0
312
SpriteFrame(-32, -16, 64, 24, 1, 146) // Wide Platform - #1
313
else
314
LoadSpriteSheet("MBZ/Objects.gif")
315
SpriteFrame(-24, -16, 48, 24, 529, 999) // Small Platform - #0
316
SpriteFrame(-32, -16, 64, 24, 464, 999) // Wide Platform - #1
317
end if
318
319
AddEditorVariable("type")
320
SetActiveVariable("type")
321
AddEnumVariable("Small Platform", 0)
322
AddEnumVariable("Wide Platform", 1)
323
324
AddEditorVariable("flipMoveX")
325
SetActiveVariable("flipMoveX")
326
AddEnumVariable("false", false)
327
AddEnumVariable("true", true)
328
329
AddEditorVariable("flipMoveY")
330
SetActiveVariable("flipMoveY")
331
AddEnumVariable("false", false)
332
AddEnumVariable("true", true)
333
334
AddEditorVariable("flipMoveXY")
335
SetActiveVariable("flipMoveXY")
336
AddEnumVariable("false", false)
337
AddEnumVariable("true", true)
338
end event
339
340