Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/MZ/LargePlatform.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Large 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.stood
13
private alias object.value1 : object.drawPos.y
14
private alias object.value2 : object.collisionOffset.y
15
private alias object.value3 : object.spawnedFireballs
16
private alias object.value4 : object.amplitude.y
17
18
private alias 0 : LARGEPLATFORM_TYPE_ARCH
19
private alias 1 : LARGEPLATFORM_TYPE_CURVE
20
private alias 2 : LARGEPLATFORM_TYPE_RECT
21
22
private alias 0 : LARGEPLATFORM_STATIC
23
private alias 1 : LARGEPLATFORM_MOVE_V_SHORTEST
24
private alias 2 : LARGEPLATFORM_MOVE_V_SHORT
25
private alias 3 : LARGEPLATFORM_MOVE_V_LONG
26
private alias 4 : LARGEPLATFORM_MOVE_V_LONGEST
27
private alias 5 : LARGEPLATFORM_HASTENSION
28
29
// GrassFireball Aliases
30
private alias object.value1 : grassFireball.parentSlot
31
private alias object.value2 : grassFireball.platformPos
32
private alias object.value3 : grassFireball.parentType
33
34
// Player Aliases
35
private alias object.xpos : player.xpos
36
private alias object.ypos : player.ypos
37
38
// Debug Mode Aliases
39
private alias object.value17 : debugMode.currentSelection
40
41
42
// ========================
43
// Function Declarations
44
// ========================
45
46
reserve function LargePlatform_SetupTypes
47
reserve function LargePlatform_DebugDraw
48
reserve function LargePlatform_DebugSpawn
49
50
51
// ========================
52
// Static Values
53
// ========================
54
55
private value LargePlatform_startDebugID = 0
56
57
58
// ========================
59
// Tables
60
// ========================
61
62
public table LargePlatform_heightTableArch
63
-32, -32, -32, -32, -32, -32, -32, -32, -33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -46, -47, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -32, -32, -32, -32, -32, -32, -32
64
end table
65
66
public table LargePlatform_heightTableCurved
67
-33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -46, -47, -48, -49, -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49
68
end table
69
70
private table LargePlatform_debugFrameTable
71
0, 0
72
0, 0
73
2, 2
74
2, 2
75
1
76
end table
77
78
private table LargePlatform_debugStateTable
79
1, 2
80
3, 4
81
1, 2
82
3, 4
83
5
84
end table
85
86
87
// ========================
88
// Function Definitions
89
// ========================
90
91
private function LargePlatform_SetupTypes
92
if temp0 == 0
93
switch object[arrayPos0].state
94
case LARGEPLATFORM_MOVE_V_SHORTEST
95
object[arrayPos0].ypos -= 0x100000
96
object[arrayPos0].amplitude.y = 0x800
97
break
98
99
case LARGEPLATFORM_MOVE_V_SHORT
100
object[arrayPos0].ypos -= 0x180000
101
object[arrayPos0].amplitude.y = 0xC00
102
break
103
104
case LARGEPLATFORM_MOVE_V_LONG
105
object[arrayPos0].ypos -= 0x200000
106
object[arrayPos0].amplitude.y = 0x1000
107
break
108
109
case LARGEPLATFORM_MOVE_V_LONGEST
110
object[arrayPos0].ypos -= 0x300000
111
object[arrayPos0].amplitude.y = 0x1800
112
break
113
114
end switch
115
else
116
switch object[arrayPos0].state
117
case LARGEPLATFORM_MOVE_V_SHORTEST
118
object[arrayPos0].ypos -= 0x100000
119
object[arrayPos0].amplitude.y = -0x800
120
break
121
122
case LARGEPLATFORM_MOVE_V_SHORT
123
object[arrayPos0].ypos -= 0x180000
124
object[arrayPos0].amplitude.y = -0xC00
125
break
126
127
case LARGEPLATFORM_MOVE_V_LONG
128
object[arrayPos0].ypos -= 0x200000
129
object[arrayPos0].amplitude.y = -0x1000
130
break
131
132
case LARGEPLATFORM_MOVE_V_LONGEST
133
object[arrayPos0].ypos -= 0x300000
134
object[arrayPos0].amplitude.y = -0x1800
135
break
136
137
end switch
138
end if
139
end function
140
141
142
private function LargePlatform_DebugDraw
143
temp0 = debugMode[0].currentSelection
144
temp0 -= LargePlatform_startDebugID
145
GetTableValue(temp1, temp0, LargePlatform_debugFrameTable)
146
DrawSprite(temp1)
147
end function
148
149
150
private function LargePlatform_DebugSpawn
151
temp0 = debugMode[0].currentSelection
152
temp0 -= LargePlatform_startDebugID
153
154
CreateTempObject(TypeName[Large Platform], 0, object.xpos, object.ypos)
155
GetTableValue(object[tempObjectPos].frame, temp0, LargePlatform_debugFrameTable)
156
GetTableValue(object[tempObjectPos].state, temp0, LargePlatform_debugStateTable)
157
arrayPos0 = object[tempObjectPos].entityPos
158
temp0 = object.direction
159
CallFunction(LargePlatform_SetupTypes)
160
end function
161
162
163
// ========================
164
// Events
165
// ========================
166
167
event ObjectUpdate
168
switch object.state
169
case LARGEPLATFORM_STATIC
170
object.angle = 0
171
object.amplitude.y = 0
172
break
173
174
case LARGEPLATFORM_MOVE_V_SHORTEST
175
object.angle = oscillation
176
object.angle <<= 1
177
object.angle += 0x10
178
break
179
180
case LARGEPLATFORM_MOVE_V_SHORT
181
object.angle = oscillation
182
object.angle <<= 1
183
object.angle += 0x30
184
break
185
186
case LARGEPLATFORM_MOVE_V_LONG
187
object.angle = oscillation
188
object.angle <<= 1
189
object.angle += 0x50
190
break
191
192
case LARGEPLATFORM_MOVE_V_LONGEST
193
object.angle = oscillation
194
object.angle <<= 1
195
object.angle += 0x70
196
break
197
198
case LARGEPLATFORM_HASTENSION
199
if object.stood == true
200
if object.angle < 128
201
object.angle += 8
202
end if
203
else
204
if object.angle > 0
205
object.angle -= 4
206
end if
207
end if
208
209
object.amplitude.y = 0x800
210
if object.angle > 80
211
if object.spawnedFireballs == false
212
object.spawnedFireballs = true
213
CreateTempObject(TypeName[Grass Fireball], 0, object.xpos, object.ypos)
214
if object.frame < LARGEPLATFORM_TYPE_RECT
215
object[tempObjectPos].xpos -= 0x380000
216
else
217
object[tempObjectPos].xpos -= 0x180000
218
end if
219
grassFireball[tempObjectPos].parentSlot = object.entityPos
220
grassFireball[tempObjectPos].platformPos = 8
221
object[tempObjectPos].drawOrder = 5
222
grassFireball[tempObjectPos].parentType = object.frame
223
end if
224
end if
225
break
226
227
end switch
228
229
Sin(object.collisionOffset.y, object.angle)
230
object.collisionOffset.y *= object.amplitude.y
231
object.collisionOffset.y += object.ypos
232
object.collisionOffset.y &= 0xFFFF0000
233
object.collisionOffset.y -= object.drawPos.y
234
235
object.stood = false
236
temp0 = object.ypos
237
object.ypos = object.drawPos.y
238
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
239
switch object.frame
240
case LARGEPLATFORM_TYPE_ARCH
241
temp1 = player[currentPlayer].xpos
242
temp1 -= object.xpos
243
temp1 >>= 17
244
temp1 += 32
245
if temp1 < 0
246
temp1 = 0
247
end if
248
if temp1 > 63
249
temp1 = 63
250
end if
251
GetTableValue(temp2, temp1, LargePlatform_heightTableArch)
252
BoxCollisionTest(C_SOLID, object.entityPos, -64, temp2, 64, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
253
temp2 -= 3
254
255
BoxCollisionTest(C_PLATFORM, object.entityPos, -64, temp2, 64, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
256
if checkResult == true
257
player[currentPlayer].ypos += 0x40000
258
player[currentPlayer].ypos += object.collisionOffset.y
259
object.stood = true
260
end if
261
break
262
263
case LARGEPLATFORM_TYPE_CURVE
264
temp1 = player[currentPlayer].xpos
265
temp1 -= object.xpos
266
temp1 >>= 17
267
temp1 += 32
268
if temp1 < 0
269
temp1 = 0
270
end if
271
if temp1 > 63
272
temp1 = 63
273
end if
274
GetTableValue(temp2, temp1, LargePlatform_heightTableCurved)
275
BoxCollisionTest(C_SOLID, object.entityPos, -64, temp2, 64, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
276
temp2 -= 3
277
278
BoxCollisionTest(C_PLATFORM, object.entityPos, -64, temp2, 64, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
279
if checkResult == true
280
player[currentPlayer].ypos += 0x40000
281
player[currentPlayer].ypos += object.collisionOffset.y
282
object.stood = true
283
end if
284
break
285
286
case LARGEPLATFORM_TYPE_RECT
287
BoxCollisionTest(C_SOLID, object.entityPos, -32, -47, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
288
temp2 -= 3
289
290
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -51, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
291
if checkResult == true
292
player[currentPlayer].ypos += 0x40000
293
player[currentPlayer].ypos += object.collisionOffset.y
294
object.stood = true
295
end if
296
break
297
298
end switch
299
next
300
object.ypos = temp0
301
302
Sin(object.drawPos.y, object.angle)
303
object.drawPos.y *= object.amplitude.y
304
object.drawPos.y += object.ypos
305
object.drawPos.y &= 0xFFFF0000
306
end event
307
308
309
event ObjectDraw
310
DrawSpriteXY(object.frame, object.xpos, object.drawPos.y)
311
end event
312
313
314
event ObjectStartup
315
LoadSpriteSheet("MZ/Objects.gif")
316
SpriteFrame(-64, -48, 128, 80, 1, 324)
317
SpriteFrame(-64, -64, 128, 96, 317, 396)
318
SpriteFrame(-32, -48, 64, 96, 446, 396)
319
320
foreach (TypeName[Large Platform], arrayPos0, ALL_ENTITIES)
321
object[arrayPos0].frame = object[arrayPos0].propertyValue
322
object[arrayPos0].frame >>= 4
323
object[arrayPos0].frame %= 3
324
325
object[arrayPos0].state = object[arrayPos0].propertyValue
326
object[arrayPos0].state &= 7
327
if object[arrayPos0].state > LARGEPLATFORM_HASTENSION
328
object[arrayPos0].state = LARGEPLATFORM_STATIC
329
end if
330
331
temp0 = object[arrayPos0].propertyValue
332
temp0 &= 15
333
temp0 >>= 3
334
CallFunction(LargePlatform_SetupTypes)
335
336
object[arrayPos0].drawOrder = 5
337
next
338
339
temp0 = 0
340
LargePlatform_startDebugID = DebugMode_ObjCount
341
while temp0 < 9
342
SetTableValue(TypeName[Large Platform], DebugMode_ObjCount, DebugMode_TypesTable)
343
SetTableValue(LargePlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
344
SetTableValue(LargePlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
345
DebugMode_ObjCount++
346
temp0++
347
loop
348
end event
349
350
351
// ========================
352
// Editor Events
353
// ========================
354
355
event RSDKEdit
356
if editor.returnVariable == true
357
switch editor.variableID
358
case EDIT_VAR_PROPVAL // property value
359
checkResult = object.propertyValue
360
break
361
362
case 0 // frameID
363
checkResult = object.propertyValue
364
checkResult >>= 4
365
checkResult %= 3
366
break
367
368
case 1 // type
369
checkResult = object.propertyValue
370
checkResult &= 7
371
if checkResult > LARGEPLATFORM_HASTENSION
372
checkResult = LARGEPLATFORM_STATIC
373
end if
374
break
375
376
case 2 // startDir
377
GetBit(checkResult, object.propertyValue, 3)
378
break
379
380
end switch
381
else
382
switch editor.variableID
383
case EDIT_VAR_PROPVAL // property value
384
object.propertyValue = editor.variableValue
385
break
386
387
case 0 // frameID
388
temp1 = 0x70
389
Not(temp1)
390
object.propertyValue &= temp1
391
392
editor.variableValue &= 3
393
editor.variableValue <<= 4
394
object.propertyValue |= editor.variableValue
395
break
396
397
case 1 // type
398
temp1 = 7
399
Not(temp1)
400
object.propertyValue &= temp1
401
402
temp0 = editor.variableValue
403
temp0 &= 7
404
object.propertyValue |= temp0
405
break
406
407
case 3 // startDir
408
CheckNotEqual(editor.variableValue, false)
409
SetBit(object.propertyValue, 3, checkResult)
410
break
411
412
end switch
413
end if
414
end event
415
416
417
event RSDKDraw
418
object.frame = object.propertyValue
419
object.frame >>= 4
420
object.frame %= 3
421
422
DrawSprite(object.frame)
423
end event
424
425
426
event RSDKLoad
427
LoadSpriteSheet("MZ/Objects.gif")
428
SpriteFrame(-64, -48, 128, 80, 1, 324)
429
SpriteFrame(-64, -64, 128, 96, 317, 396)
430
SpriteFrame(-32, -48, 64, 96, 446, 396)
431
432
AddEditorVariable("frameID")
433
SetActiveVariable("frameID")
434
AddEnumVariable("Arch", LARGEPLATFORM_TYPE_ARCH)
435
AddEnumVariable("Curved", LARGEPLATFORM_TYPE_CURVE)
436
AddEnumVariable("Rectangular", LARGEPLATFORM_TYPE_RECT)
437
438
AddEditorVariable("moveType")
439
SetActiveVariable("moveType")
440
AddEnumVariable("Static", LARGEPLATFORM_STATIC)
441
AddEnumVariable("Move Vertically (Shortest)", LARGEPLATFORM_MOVE_V_SHORTEST)
442
AddEnumVariable("Move Vertically (Short)", LARGEPLATFORM_MOVE_V_SHORT)
443
AddEnumVariable("Move Vertically (Long)", LARGEPLATFORM_MOVE_V_LONG)
444
AddEnumVariable("Move Vertically (Longest)", LARGEPLATFORM_MOVE_V_LONGEST)
445
AddEnumVariable("Spawn Fireballs When Stood", LARGEPLATFORM_HASTENSION)
446
447
AddEditorVariable("startDir")
448
SetActiveVariable("startDir")
449
AddEnumVariable("Down", 0)
450
AddEnumVariable("Up", 1)
451
end event
452
453