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/SBZ/Eggmobile.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Eggmobile 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.legAnim
13
private alias object.value1 : object.legAnimTimer
14
private alias object.value2 : object.flameAnim
15
private alias object.value3 : object.flameAnimTimer
16
private alias object.value4 : object.timer
17
private alias object.value5 : object.explosionTimer
18
private alias object.value6 : object.playerStopPos
19
private alias object.value7 : object.fadeTimer
20
21
private alias 0 : EGGMOBILE_WAITING
22
private alias 1 : EGGMOBILE_ACTIVATE
23
private alias 2 : EGGMOBILE_RISE
24
private alias 3 : EGGMOBILE_FLEE
25
private alias 4 : EGGMOBILE_HIT
26
private alias 5 : EGGMOBILE_SEAT
27
private alias 5 : EGGMOBILE_BOSSRUSH
28
29
private alias 0 : EGGMOBILE_ANI_IDLE
30
private alias 1 : EGGMOBILE_ANI_SEAT
31
private alias 2 : EGGMOBILE_ANI_FLYING
32
private alias 3 : EGGMOBILE_ANI_WASHIT
33
34
private alias 0 : LEGS_IDLE
35
private alias 1 : LEGS_RETRACT
36
private alias 2 : LEGS_NONE
37
38
private alias 0 : FLAME_INACTIVE
39
private alias 1 : FLAME_ACTIVE
40
41
// Player Aliases
42
private alias object.state : player.state
43
private alias object.xpos : player.xpos
44
private alias object.xvel : player.xvel
45
private alias object.yvel : player.yvel
46
private alias object.speed : player.speed
47
private alias object.direction : player.direction
48
private alias object.gravity : player.gravity
49
private alias object.animation : player.animation
50
private alias object.controlMode : player.controlMode
51
private alias object.value40 : player.hitboxLeft
52
private alias object.value38 : player.hitboxTop
53
private alias object.value41 : player.hitboxRight
54
private alias object.value39 : player.hitboxBottom
55
56
// Game Modes
57
private alias 0 : MODE_NOSAVE
58
private alias 1 : MODE_SAVEGAME
59
private alias 2 : MODE_TIMEATTACK
60
61
// Tracks
62
private alias 1 : TRACK_ACTFINISH
63
64
// Reserved Object Slot Aliases
65
private alias 30 : SLOT_ACTFINISH
66
67
// Achievement Aliases
68
private alias 10 : ACHIEVEMENT_ONEFORTHEROAD
69
70
71
// ========================
72
// Events
73
// ========================
74
75
event ObjectUpdate
76
switch object.state
77
case EGGMOBILE_WAITING
78
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
79
BoxCollisionTest(C_SOLID, object.entityPos, -24, -96, 24, 96, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
80
next
81
break
82
83
case EGGMOBILE_ACTIVATE
84
object.priority = PRIORITY_ACTIVE
85
object.animation = EGGMOBILE_ANI_FLYING
86
object.legAnim = LEGS_RETRACT
87
object.yvel = -0x18000
88
object.state++
89
break
90
91
case EGGMOBILE_RISE
92
object.ypos += object.yvel
93
object.timer++
94
if object.timer >= 52
95
object.flameAnim = FLAME_ACTIVE
96
object.xvel = 0x18000
97
object.yvel = -0x1800
98
object.state++
99
end if
100
break
101
102
case EGGMOBILE_HIT
103
object.explosionTimer++
104
temp0 = object.explosionTimer
105
temp0 &= 7
106
if temp0 == 4
107
Rand(temp0, 96)
108
temp0 -= 48
109
temp0 <<= 16
110
temp0 += object.xpos
111
Rand(temp1, 48)
112
temp1 -= 24
113
temp1 <<= 16
114
temp1 += object.ypos
115
CreateTempObject(TypeName[Explosion], 0, temp0, temp1)
116
object[tempObjectPos].drawOrder = 4
117
if object.fadeTimer < 256
118
PlaySfx(SfxName[Explosion], false)
119
end if
120
end if
121
122
if object.fadeTimer < 256
123
object.timer++
124
if object.timer >= 30
125
PlaySfx(SfxName[Boss Hit], false)
126
object.yvel = 0x6000
127
object.timer = 0
128
end if
129
end if
130
// [Fall-through]
131
case EGGMOBILE_FLEE
132
object.xpos += object.xvel
133
object.ypos += object.yvel
134
temp0 = stage.newXBoundary2
135
temp0 += 212 // (screen.xcenter with the standard screen width of 424)
136
temp0 <<= 16
137
if object.xpos >= temp0
138
#platform: USE_ORIGINS
139
CheckNotEqual(options.gameMode, MODE_TIMEATTACK)
140
temp0 = checkResult
141
CheckEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)
142
temp0 &= checkResult
143
if temp0 != 0
144
CallNativeFunction2(NotifyCallback, NOTIFY_KILL_BOSS, 0)
145
CallNativeFunction2(NotifyCallback, NOTIFY_BOSS_END, true)
146
StopMusic()
147
object.state = EGGMOBILE_BOSSRUSH
148
object.fadeTimer = 0
149
else
150
#endplatform
151
#platform: USE_STANDALONE
152
if options.gameMode == MODE_TIMEATTACK
153
#endplatform
154
#platform: USE_ORIGINS
155
CheckEqual(options.gameMode, MODE_TIMEATTACK)
156
temp0 = checkResult
157
CheckNotEqual(game.oneStageFlag, false)
158
temp0 |= checkResult
159
if temp0 != false
160
#endplatform
161
object.type = TypeName[Blank Object]
162
ResetObjectEntity(SLOT_ACTFINISH, TypeName[Act Finish], 0, 0, 0)
163
object[SLOT_ACTFINISH].drawOrder = 6
164
object[SLOT_ACTFINISH].priority = PRIORITY_ACTIVE
165
stage.timeEnabled = false
166
PlayMusic(TRACK_ACTFINISH)
167
else
168
object.fadeTimer += 4
169
music.volume -= 2
170
SetScreenFade(0, 0, 0, object.fadeTimer)
171
if object.fadeTimer == 384
172
173
#platform: USE_ORIGINS
174
// This variable isn't used anywhere in Final Zone, perhaps a scrapped achievement?
175
temp0 = StageStatsUsabilityParam5
176
temp0 &= 1
177
temp1 = StageStatsUsabilityParam5
178
temp1 &= 2
179
temp2 = StageStatsUsabilityParam5
180
temp2 &= 4
181
182
CallNativeFunction4(NotifyCallback, NOTIFY_STATS_CHARA_ACTION, temp0, temp1, temp2)
183
CallNativeFunction2(NotifyCallback, NOTIFY_ACT_FINISH, 0)
184
185
StageStatsUsabilityParam1 = 0
186
StageStatsUsabilityParam2 = 0
187
StageStatsUsabilityParam3 = 0
188
StageStatsUsabilityParam4 = 0
189
StageStatsUsabilityParam5 = 0
190
StatsUsabilityParam1 = 0
191
StatsUsabilityParam2 = 0
192
StatsUsabilityParam3 = 0
193
StatsUsabilityParam4 = 0
194
StatsUsabilityParam5 = 0
195
#endplatform
196
197
if stage.debugMode == false
198
if options.stageSelectFlag == false
199
CallNativeFunction2(SetLeaderboard, 19, player.score)
200
end if
201
end if
202
203
if options.gameMode == MODE_SAVEGAME
204
arrayPos1 = options.saveSlot
205
arrayPos1 <<= 3
206
arrayPos1 += 4
207
saveRAM[arrayPos1] = 20
208
WriteSaveRAM()
209
end if
210
211
stage.activeList = PRESENTATION_STAGE
212
stage.listPos = 1
213
LoadStage()
214
end if
215
end if
216
#platform: USE_ORIGINS
217
end if
218
#endplatform
219
end if
220
221
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
222
if player[currentPlayer].xpos >= object.playerStopPos
223
CheckEqual(player[currentPlayer].state, Player_State_Ground)
224
temp0 = checkResult
225
#platform: USE_ORIGINS
226
CheckEqual(player[currentPlayer].state, Player_State_Air_NoDropDash)
227
temp0 |= checkResult
228
#endplatform
229
CheckEqual(player[currentPlayer].state, Player_State_Air)
230
temp0 |= checkResult
231
CheckEqual(player[currentPlayer].state, Player_State_Fly)
232
temp0 |= checkResult
233
CheckEqual(player[currentPlayer].state, Player_State_GlideRight)
234
temp0 |= checkResult
235
CheckEqual(player[currentPlayer].state, Player_State_Roll)
236
temp0 |= checkResult
237
CheckEqual(player[currentPlayer].state, Player_State_RollJump)
238
temp0 |= checkResult
239
CheckEqual(player[currentPlayer].state, Player_State_Static)
240
temp0 |= checkResult
241
CheckEqual(player[currentPlayer].state, Player_State_Spindash)
242
temp0 |= checkResult
243
244
if temp0 == true
245
player[currentPlayer].state = Player_State_Static
246
player[currentPlayer].direction = FACING_RIGHT
247
player[currentPlayer].controlMode = CONTROLMODE_NONE
248
if player[currentPlayer].gravity == 0
249
player[currentPlayer].xvel = 0
250
player[currentPlayer].speed = 0
251
if object.state == EGGMOBILE_FLEE
252
player[currentPlayer].animation = ANI_LOOKINGUP
253
else
254
player[currentPlayer].animation = ANI_STOPPED
255
end if
256
else
257
player[currentPlayer].speed = player[currentPlayer].xvel
258
player[currentPlayer].yvel += 0x3800
259
end if
260
else
261
if player[currentPlayer].state == Player_State_GlideSlide
262
player[currentPlayer].speed = 0
263
end if
264
end if
265
end if
266
next
267
break
268
269
case EGGMOBILE_SEAT
270
// position == eggmobile.position
271
object.xpos = object[+10].xpos
272
object.ypos = object[+10].ypos
273
if object[+1].type == TypeName[Blank Object]
274
object.type = TypeName[Blank Object]
275
end if
276
break
277
278
end switch
279
280
if object.state == EGGMOBILE_FLEE
281
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
282
#platform: USE_STANDALONE
283
BoxCollisionTest(C_TOUCH, object.entityPos, -20, -16, 20, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
284
#endplatform
285
#platform: USE_ORIGINS
286
BoxCollisionTest(C_TOUCH, object.entityPos, -20, -16, 20, 16, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
287
#endplatform
288
289
if checkResult == true
290
CallFunction(Player_CheckHit)
291
if checkResult == true
292
object.state = EGGMOBILE_HIT
293
object.animation = EGGMOBILE_ANI_WASHIT
294
PlaySfx(SfxName[Boss Hit], false)
295
object.timer = 0
296
if stage.debugMode == false
297
if currentPlayer == 0
298
// Grant the "One For the Road" Achievement
299
CallNativeFunction2(SetAchievement, ACHIEVEMENT_ONEFORTHEROAD, 100)
300
end if
301
end if
302
end if
303
end if
304
next
305
end if
306
end event
307
308
309
event ObjectDraw
310
switch object.animation
311
case EGGMOBILE_ANI_IDLE
312
DrawSpriteFX(16, FX_FLIP, object.xpos, object.ypos)
313
DrawSpriteFX(17, FX_FLIP, object.xpos, object.ypos)
314
break
315
316
case EGGMOBILE_ANI_SEAT
317
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
318
break
319
320
case EGGMOBILE_ANI_FLYING
321
temp0 = object.animationTimer
322
temp0 >>= 2
323
temp0 += 1
324
object.animationTimer++
325
object.animationTimer &= 7
326
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
327
break
328
329
case EGGMOBILE_ANI_WASHIT
330
temp0 = object.animationTimer
331
temp0 >>= 2
332
temp0 += 3
333
object.animationTimer++
334
object.animationTimer &= 7
335
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
336
break
337
338
end switch
339
340
switch object.legAnim
341
case LEGS_IDLE
342
DrawSpriteFX(5, FX_FLIP, object.xpos, object.ypos)
343
break
344
345
case LEGS_RETRACT
346
object.legAnimTimer++
347
if object.legAnimTimer >= 60
348
object.legAnim = LEGS_NONE
349
else
350
temp0 = object.legAnimTimer
351
temp0 /= 20
352
temp0 += 5
353
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
354
end if
355
break
356
357
case LEGS_NONE
358
break
359
360
end switch
361
362
if object.flameAnim != FLAME_INACTIVE
363
temp0 = object.flameAnimTimer
364
temp0 /= 3
365
temp0 += 8
366
object.flameAnimTimer++
367
if object.flameAnimTimer > 21
368
object.flameAnimTimer = 18
369
end if
370
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
371
end if
372
end event
373
374
375
event ObjectStartup
376
LoadSpriteSheet("Global/Eggman.gif")
377
SpriteFrame(-28, -32, 64, 21, 131, 172)
378
SpriteFrame(-28, -32, 64, 56, 131, 58)
379
SpriteFrame(-28, -32, 64, 56, 66, 1)
380
SpriteFrame(-28, -32, 64, 56, 1, 172)
381
SpriteFrame(-28, -32, 64, 56, 66, 172)
382
SpriteFrame(-20, 16, 40, 21, 131, 115)
383
SpriteFrame(-20, 8, 48, 19, 172, 115)
384
SpriteFrame(-20, 8, 40, 16, 172, 135)
385
SpriteFrame(34, 1, 10, 9, 196, 2)
386
SpriteFrame(33, 0, 15, 11, 196, 12)
387
SpriteFrame(34, -1, 22, 14, 213, 1)
388
SpriteFrame(34, -8, 32, 26, 213, 16)
389
SpriteFrame(34, -1, 22, 14, 213, 1)
390
SpriteFrame(34, -8, 32, 26, 213, 16)
391
SpriteFrame(34, 1, 10, 9, 196, 2)
392
SpriteFrame(33, 0, 15, 11, 196, 12)
393
SpriteFrame(-28, -32, 27, 21, 131, 172)
394
SpriteFrame(-28, -11, 64, 35, 131, 193)
395
396
foreach (TypeName[Eggmobile], arrayPos0, ALL_ENTITIES)
397
object[arrayPos0].direction = FACING_LEFT
398
if object[arrayPos0].propertyValue == 1
399
object[arrayPos0].state = EGGMOBILE_SEAT
400
object[arrayPos0].animation = EGGMOBILE_ANI_SEAT
401
object[arrayPos0].legAnim = LEGS_NONE
402
end if
403
next
404
end event
405
406
407
// ========================
408
// Editor Events
409
// ========================
410
411
event RSDKEdit
412
if editor.returnVariable == true
413
switch editor.variableID
414
case EDIT_VAR_PROPVAL // property value
415
checkResult = object.propertyValue
416
break
417
418
case 0 // type
419
checkResult = object.propertyValue
420
break
421
422
end switch
423
else
424
switch editor.variableID
425
case EDIT_VAR_PROPVAL // property value
426
object.propertyValue = editor.variableValue
427
break
428
429
case 0 // type
430
object.propertyValue = editor.variableValue
431
break
432
433
end switch
434
end if
435
end event
436
437
438
event RSDKDraw
439
object.direction = FACING_LEFT
440
441
if object.propertyValue == 1
442
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
443
else
444
DrawSpriteFX(16, FX_FLIP, object.xpos, object.ypos)
445
DrawSpriteFX(17, FX_FLIP, object.xpos, object.ypos)
446
end if
447
end event
448
449
450
event RSDKLoad
451
LoadSpriteSheet("Global/Eggman.gif")
452
SpriteFrame(-28, -32, 64, 21, 131, 172)
453
SpriteFrame(-28, -32, 64, 56, 131, 58)
454
SpriteFrame(-28, -32, 64, 56, 66, 1)
455
SpriteFrame(-28, -32, 64, 56, 1, 172)
456
SpriteFrame(-28, -32, 64, 56, 66, 172)
457
SpriteFrame(-20, 16, 40, 21, 131, 115)
458
SpriteFrame(-20, 8, 48, 19, 172, 115)
459
SpriteFrame(-20, 8, 40, 16, 172, 135)
460
SpriteFrame(34, 1, 10, 9, 196, 2)
461
SpriteFrame(33, 0, 15, 11, 196, 12)
462
SpriteFrame(34, -1, 22, 14, 213, 1)
463
SpriteFrame(34, -8, 32, 26, 213, 16)
464
SpriteFrame(34, -1, 22, 14, 213, 1)
465
SpriteFrame(34, -8, 32, 26, 213, 16)
466
SpriteFrame(34, 1, 10, 9, 196, 2)
467
SpriteFrame(33, 0, 15, 11, 196, 12)
468
SpriteFrame(-28, -32, 27, 21, 131, 172)
469
SpriteFrame(-28, -11, 64, 35, 131, 193)
470
471
AddEditorVariable("type")
472
SetActiveVariable("type")
473
AddEnumVariable("EggMobile", 0)
474
AddEnumVariable("Seat", 1)
475
end event
476
477