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/MPZ/WheelPlatform.txt
1479 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Wheel 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.platformMPos.x
13
private alias object.value1 : object.platformMPos.y
14
private alias object.value2 : object.platformLPos.x
15
private alias object.value3 : object.platformLPos.y
16
private alias object.value4 : object.platformRPos.x
17
private alias object.value5 : object.platformRPos.y
18
private alias object.value6 : object.jointLPos.x
19
private alias object.value7 : object.jointLPos.y
20
private alias object.value8 : object.jointRPos.x
21
private alias object.value9 : object.jointRPos.y
22
private alias object.value10 : object.indentPos.x
23
private alias object.value11 : object.indentPos.y
24
private alias object.value12 : object.stoodPlayers
25
private alias object.value13 : object.prevPlatformMPos.x
26
private alias object.value14 : object.prevPlatformMPos.y
27
private alias object.value15 : object.active
28
29
// Player Aliases
30
private alias object.xpos : player.xpos
31
private alias object.ypos : player.ypos
32
private alias object.gravity : player.gravity
33
34
35
// ========================
36
// Function Declarations
37
// ========================
38
39
reserve function WheelPlatform_DebugDraw
40
reserve function WheelPlatform_DebugSpawn
41
42
private function WheelPlatform_DebugDraw
43
DrawSprite(3)
44
45
temp0 = object.xpos
46
temp0 -= 0x880000
47
temp1 = object.ypos
48
temp1 += 0xC0000
49
DrawSpriteXY(2, temp0, temp1)
50
51
temp0 -= 0x380000
52
DrawSpriteXY(0, temp0, temp1)
53
54
temp0 = object.xpos
55
temp0 += 0x880000
56
DrawSpriteXY(2, temp0, temp1)
57
58
temp0 += 0x380000
59
DrawSpriteXY(1, temp0, temp1)
60
end function
61
62
63
private function WheelPlatform_DebugSpawn
64
CreateTempObject(TypeName[Wheel Platform], 0, object.xpos, object.ypos)
65
end function
66
67
68
// ========================
69
// Events
70
// ========================
71
72
event ObjectUpdate
73
object.active = true
74
75
temp0 = object.xpos
76
temp0 >>= 16
77
temp0 -= camera[0].xpos
78
Abs(temp0)
79
temp0 -= 576
80
temp1 = object.ypos
81
temp1 >>= 16
82
temp1 -= camera[0].ypos
83
Abs(temp1)
84
temp1 -= 128
85
if temp0 >= screen.xcenter
86
object.active = false
87
end if
88
89
if temp1 >= screen.ycenter
90
object.active = false
91
end if
92
93
if object.active == true
94
GetTableValue(object.platformMPos.x, 16, StageSetup_oscillationTable)
95
object.platformMPos.x >>= 8
96
object.indentPos.x = object.platformMPos.x
97
object.indentPos.x >>= 1
98
object.platformMPos.x -= 56
99
object.indentPos.x -= 28
100
101
GetTableValue(object.platformMPos.y, 18, StageSetup_oscillationTable)
102
object.platformMPos.y >>= 8
103
object.indentPos.y = object.platformMPos.y
104
object.indentPos.y >>= 1
105
object.platformMPos.y -= 56
106
object.indentPos.y -= 28
107
108
GetBit(temp0, object.propertyValue, 0)
109
if temp0 == true
110
FlipSign(object.platformMPos.x)
111
FlipSign(object.platformMPos.y)
112
object.rotation += 34
113
else
114
object.rotation -= 34
115
end if
116
117
GetBit(temp0, object.propertyValue, 1)
118
if temp0 == true
119
FlipSign(object.platformMPos.x)
120
temp0 = object.platformMPos.x
121
object.platformMPos.x = object.platformMPos.y
122
object.platformMPos.y = temp0
123
end if
124
object.platformMPos.x <<= 16
125
object.platformMPos.x += object.xpos
126
object.platformMPos.y <<= 16
127
object.platformMPos.y += object.ypos
128
object.indentPos.x <<= 16
129
object.indentPos.y <<= 16
130
FlipSign(object.indentPos.x)
131
FlipSign(object.indentPos.y)
132
object.platformLPos.x = object.platformMPos.x
133
object.platformLPos.x -= 0x880000
134
object.platformLPos.y = object.platformMPos.y
135
object.platformLPos.y += 0xC0000
136
object.platformRPos.x = object.platformMPos.x
137
object.platformRPos.x += 0x880000
138
object.platformRPos.y = object.platformLPos.y
139
object.jointLPos.x = object.platformMPos.x
140
object.jointLPos.x -= 0xC00000
141
object.jointLPos.y = object.platformLPos.y
142
object.jointRPos.x = object.platformMPos.x
143
object.jointRPos.x += 0xC00000
144
object.jointRPos.y = object.platformLPos.y
145
146
temp1 = object.platformMPos.x
147
temp1 -= object.prevPlatformMPos.x
148
temp2 = object.platformMPos.y
149
temp2 -= object.prevPlatformMPos.y
150
151
object.prevPlatformMPos.x = object.platformMPos.x
152
object.prevPlatformMPos.y = object.platformMPos.y
153
154
temp4 = object.xpos
155
temp5 = object.ypos
156
object.xpos = object.platformMPos.x
157
object.ypos = object.platformMPos.y
158
159
temp7 = 0
160
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
161
GetBit(temp6, object.stoodPlayers, temp7)
162
if temp6 == true
163
player[currentPlayer].xpos += temp1
164
player[currentPlayer].ypos += temp2
165
end if
166
SetBit(object.stoodPlayers, temp7, false)
167
temp0 = 0
168
169
BoxCollisionTest(C_SOLID, object.entityPos, -64, -24, 64, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
170
switch checkResult
171
case COL_TOP
172
SetBit(object.stoodPlayers, temp7, true)
173
break
174
175
case COL_BOTTOM
176
if player[currentPlayer].gravity == 0
177
CallFunction(Player_Kill)
178
end if
179
break
180
end switch
181
182
BoxCollisionTest(C_SOLID, object.entityPos, -96, -24, -64, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
183
switch checkResult
184
case COL_TOP
185
SetBit(object.stoodPlayers, temp7, true)
186
break
187
188
case COL_BOTTOM
189
if player[currentPlayer].gravity == 0
190
CallFunction(Player_Kill)
191
end if
192
break
193
end switch
194
195
BoxCollisionTest(C_SOLID, object.entityPos, 64, -24, 96, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
196
switch checkResult
197
case COL_TOP
198
SetBit(object.stoodPlayers, temp7, true)
199
break
200
201
case COL_BOTTOM
202
if player[currentPlayer].gravity == 0
203
CallFunction(Player_Kill)
204
end if
205
break
206
end switch
207
208
BoxCollisionTest(C_SOLID, object.entityPos, -176, 4, -96, 20, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
209
switch checkResult
210
case COL_TOP
211
SetBit(object.stoodPlayers, temp7, true)
212
break
213
214
case COL_BOTTOM
215
if player[currentPlayer].gravity == 0
216
CallFunction(Player_Kill)
217
end if
218
break
219
end switch
220
221
BoxCollisionTest(C_SOLID, object.entityPos, 96, 4, 176, 20, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
222
switch checkResult
223
case COL_TOP
224
SetBit(object.stoodPlayers, temp7, true)
225
break
226
227
case COL_BOTTOM
228
if player[currentPlayer].gravity == 0
229
CallFunction(Player_Kill)
230
end if
231
break
232
end switch
233
234
BoxCollisionTest(C_SOLID, object.entityPos, -208, 0, -176, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
235
switch checkResult
236
case COL_TOP
237
SetBit(object.stoodPlayers, temp7, true)
238
break
239
240
case COL_BOTTOM
241
if player[currentPlayer].gravity == 0
242
CallFunction(Player_Kill)
243
end if
244
break
245
end switch
246
247
BoxCollisionTest(C_SOLID, object.entityPos, 176, 0, 208, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
248
switch checkResult
249
case COL_TOP
250
SetBit(object.stoodPlayers, temp7, true)
251
break
252
253
case COL_BOTTOM
254
if player[currentPlayer].gravity == 0
255
CallFunction(Player_Kill)
256
end if
257
break
258
end switch
259
260
temp7++
261
next
262
object.xpos = temp4
263
object.ypos = temp5
264
end if
265
end event
266
267
268
event ObjectDraw
269
if object.active == true
270
temp6 = object.xpos
271
temp6 -= 0xC00000
272
temp7 = object.ypos
273
temp7 += 0xC0000
274
temp0 = 0
275
temp2 = object.rotation
276
277
object.rotation >>= 5
278
object.rotation &= 0x1FF
279
while temp0 < 8
280
DrawSpriteFX(5, FX_ROTATE, temp6, temp7)
281
object.rotation += 0x40
282
object.rotation &= 0x1FF
283
temp0++
284
loop
285
286
temp5 = object.xpos
287
temp5 += 0xC00000
288
temp0 = 0
289
while temp0 < 8
290
DrawSpriteFX(5, FX_ROTATE, temp5, temp7)
291
object.rotation += 0x40
292
object.rotation &= 0x1FF
293
temp0++
294
loop
295
296
object.rotation = temp2
297
temp6 += object.indentPos.x
298
temp7 += object.indentPos.y
299
DrawSpriteXY(4, temp6, temp7)
300
301
temp5 += object.indentPos.x
302
DrawSpriteXY(4, temp5, temp7)
303
304
DrawSpriteXY(3, object.platformMPos.x, object.platformMPos.y)
305
DrawSpriteXY(2, object.platformLPos.x, object.platformLPos.y)
306
DrawSpriteXY(0, object.jointLPos.x, object.jointLPos.y)
307
DrawSpriteXY(2, object.platformRPos.x, object.platformRPos.y)
308
DrawSpriteXY(1, object.jointRPos.x, object.jointRPos.y)
309
end if
310
end event
311
312
313
event ObjectStartup
314
LoadSpriteSheet("MPZ/Objects.gif")
315
SpriteFrame(-16, -12, 32, 24, 479, 182) // Joint L - #0
316
SpriteFrame(-16, -12, 32, 24, 479, 133) // Joint R - #1
317
SpriteFrame(-40, -8, 80, 16, 349, 165) // Side Platforms - #2
318
SpriteFrame(-96, -24, 192, 48, 319, 207) // Center Platform - #3
319
SpriteFrame(-12, -12, 24, 24, 487, 157) // Indent - #4
320
SpriteFrame(-2, -14, 4, 4, 40, 34) // Blank Circle Thingy - #5
321
322
foreach (TypeName[Wheel Platform], arrayPos0, ALL_ENTITIES)
323
object[arrayPos0].priority = PRIORITY_ACTIVE
324
next
325
326
SetTableValue(TypeName[Wheel Platform], DebugMode_ObjCount, DebugMode_TypesTable)
327
SetTableValue(WheelPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
328
SetTableValue(WheelPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
329
DebugMode_ObjCount++
330
end event
331
332
333
// ========================
334
// Editor Events
335
// ========================
336
337
event RSDKEdit
338
if editor.returnVariable == true
339
switch editor.variableID
340
case EDIT_VAR_PROPVAL // property value
341
checkResult = object.propertyValue
342
break
343
344
case 0 // flipMoveX
345
GetBit(checkResult, object.propertyValue, 0)
346
break
347
348
case 1 // flipMoveY
349
GetBit(checkResult, object.propertyValue, 1)
350
break
351
352
end switch
353
else
354
switch editor.variableID
355
case EDIT_VAR_PROPVAL // property value
356
object.propertyValue = editor.variableValue
357
break
358
359
case 0 // flipMoveX
360
CheckNotEqual(editor.variableValue, false)
361
SetBit(object.propertyValue, 0, checkResult)
362
break
363
364
case 1 // flipMoveY
365
CheckNotEqual(editor.variableValue, false)
366
SetBit(object.propertyValue, 1, checkResult)
367
break
368
369
end switch
370
end if
371
end event
372
373
374
event RSDKDraw
375
DrawSprite(3)
376
temp0 = object.xpos
377
temp0 -= 0x880000
378
temp1 = object.ypos
379
temp1 += 0xC0000
380
DrawSpriteXY(2, temp0, temp1)
381
temp0 -= 0x380000
382
DrawSpriteXY(0, temp0, temp1)
383
temp0 = object.xpos
384
temp0 += 0x880000
385
DrawSpriteXY(2, temp0, temp1)
386
temp0 += 0x380000
387
DrawSpriteXY(1, temp0, temp1)
388
end event
389
390
391
event RSDKLoad
392
LoadSpriteSheet("MPZ/Objects.gif")
393
SpriteFrame(-16, -12, 32, 24, 479, 182)
394
SpriteFrame(-16, -12, 32, 24, 479, 133)
395
SpriteFrame(-40, -8, 80, 16, 349, 165)
396
SpriteFrame(-96, -24, 192, 48, 319, 207)
397
SpriteFrame(-12, -12, 24, 24, 487, 157)
398
SpriteFrame(-2, -14, 4, 4, 40, 34)
399
400
AddEditorVariable("flipMoveX")
401
SetActiveVariable("flipMoveX")
402
AddEnumVariable("false", false)
403
AddEnumVariable("true", true)
404
405
AddEditorVariable("flipMoveY")
406
SetActiveVariable("flipMoveY")
407
AddEnumVariable("false", false)
408
AddEnumVariable("true", true)
409
end event
410
411