Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R6/EggmanMobile.txt
1319 views
1
//----------------Sonic CD Eggman Mobile Script---------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
#alias Object.Value1 : Object.TargetYPos
8
#alias Object.Value2 : Object.YVelocity
9
#alias Object.Value3 : Object.ThrusterAnimation
10
#alias Object.Value4 : Object.FrameTimer
11
#alias Object.Value5 : Object.SpikesAnimation
12
#alias Object.Value6 : Object.EggmanAnimation
13
#alias Object.Value7 : Object.FaceFrame // Indirectly atleast
14
#alias Object.PropertyValue : Object.FaceTimer
15
#alias Object.Scale : Object.TriggerElecArc
16
17
// FloorControl aliases
18
#alias Object[+1].State : FloorControl.State
19
#alias Object[+1].Value0 : FloorControl.Timer
20
#alias Object[+1].Type : FloorControl.Type
21
22
// Boss Barrier 2 alias
23
#alias Object[-1].State : BossBarrier2.State
24
25
// Fade Screen aliases
26
#alias Object.Value1 : FadeScreen.EggMobileEntityNo
27
28
// Steam Cloud aliases
29
#alias Object.YPos : SteamCloud.YPos
30
#alias Object.Value1 : SteamCloud.XVelocity
31
#alias Object.Value2 : SteamCloud.YVelocity
32
33
// States
34
#alias 0 : R6_EGG_IDLE
35
#alias 1 : R6_EGG_START
36
#alias 2 : R6_EGG_INTRO
37
#alias 3 : R6_EGG_SET_ROUTE_1
38
#alias 4 : R6_EGG_ASCEND_1
39
#alias 5 : R6_EGG_SET_ROUTE_2
40
#alias 6 : R6_EGG_ASCEND_2
41
#alias 7 : R6_EGG_SET_ROUTE_3
42
#alias 8 : R6_EGG_ASCEND_3
43
#alias 9 : R6_EGG_ROOF_DRILL
44
#alias 10 : R6_EGG_DESTROYED
45
#alias 11 : R6_EGG_PANICKING
46
#alias 12 : R6_EGG_ESCAPE
47
48
// FloorControl States
49
#alias 0 : FLOORCONTROL_INACTIVE
50
#alias 1 : FLOORCONTROL_SETUP_CRUMBLE
51
#alias 3 : FLOORCONTROL_ELEC_ARC
52
#alias 4 : FLOORCONTROL_TILE_SWAP
53
54
// Boss Barrier States
55
#alias 2 : BOSSBARRIER2_OPEN
56
57
// Eggman Animations
58
#alias 0 : EGGANI_IDLE
59
#alias 1 : EGGANI_HURT
60
#alias 2 : EGGANI_DEFEAT
61
#alias 3 : EGGANI_PANIC
62
63
// Global SFX
64
#alias 22 : SFX_G_EXPLOSION
65
66
// Stage SFX
67
#alias 10 : SFX_S_BUZZSAW
68
#alias 11 : SFX_S_BOSSHIT
69
70
// Function declarations
71
#function R6_EGG_DESCEND
72
#function R6_EGG_MOVE
73
#function R6_EGG_ROUTE_1ST_FLOOR
74
#function R6_EGG_ROUTE_2ST_FLOOR
75
#function R6_EGG_STEAM
76
77
78
function R6_EGG_DESCEND
79
Object.YPos += Object.YVelocity
80
Object.YVelocity -= 256
81
if Object.YPos >= Object.TargetYPos
82
Object.YPos = Object.TargetYPos
83
Object.YVelocity = 0
84
85
Object.ThrusterAnimation = 0
86
Object.FrameTimer = 0
87
88
Object.State++
89
end if
90
end function
91
92
93
function R6_EGG_MOVE
94
Object.YPos += Object.YVelocity
95
Object.YVelocity -= 0x1000
96
if Object.YPos <= Object.TargetYPos
97
Object.YPos = Object.TargetYPos
98
Object.YVelocity = 0
99
100
Object.ThrusterAnimation = 0
101
Object.FrameTimer = 0
102
Object.SpikesAnimation = 0
103
104
Object.AnimationTimer = 0
105
Object.AnimationSpeed = 0
106
107
Object.State++
108
end if
109
end function
110
111
112
function R6_EGG_ROUTE_1ST_FLOOR
113
TempValue0 = Object.YPos
114
TempValue0 += 0x780000
115
116
if Player.YPos < TempValue0
117
if FloorControl.State < FLOORCONTROL_TILE_SWAP
118
FloorControl.State = FLOORCONTROL_INACTIVE
119
FloorControl.Timer = 0
120
if Object.FaceTimer > 0
121
Object.Timer = 1200
122
end if
123
else
124
if FloorControl.Timer > 270
125
FloorControl.State = FLOORCONTROL_INACTIVE
126
FloorControl.Timer = 0
127
else
128
Object.Timer &= 511
129
end if
130
end if
131
132
if Object.Timer < 1200
133
if Object.Timer == 0
134
Object.SpikesAnimation = 1
135
PlayStageSfx(SFX_S_BUZZSAW, false)
136
end if
137
138
Object.Timer += 4
139
TempValue0 = Object.Timer
140
TempValue0 &= 511
141
Sin(Object.YPos, TempValue0)
142
Object.YPos <<= 9
143
Object.YPos += Object.TargetYPos
144
else
145
Object.Timer = 0
146
Object.YVelocity = -0x10000
147
148
Object.ThrusterAnimation = 1
149
Object.FrameTimer = 0
150
151
FloorControl.State = FLOORCONTROL_SETUP_CRUMBLE
152
Object.State++
153
end if
154
end if
155
end function
156
157
158
function R6_EGG_ROUTE_2ST_FLOOR
159
TempValue0 = Object.YPos
160
TempValue0 += 0x780000
161
162
if Player.YPos < TempValue0
163
Object.TriggerElecArc = true
164
if FloorControl.State < FLOORCONTROL_TILE_SWAP
165
FloorControl.State = FLOORCONTROL_INACTIVE
166
FloorControl.Timer = 0
167
if Object.FaceTimer > 0
168
Object.Timer = 1200
169
end if
170
else
171
if FloorControl.Timer > 270
172
FloorControl.State = FLOORCONTROL_INACTIVE
173
FloorControl.Timer = 0
174
else
175
Object.Timer &= 511
176
end if
177
end if
178
179
if Object.Timer < 1200
180
if Object.Timer == 0
181
Object.SpikesAnimation = 1
182
PlayStageSfx(SFX_S_BUZZSAW, false)
183
end if
184
185
Object.Timer += 4
186
TempValue0 = Object.Timer
187
TempValue0 &= 511
188
Sin(Object.YPos, TempValue0)
189
Object.YPos <<= 9
190
Object.YPos += Object.TargetYPos
191
else
192
Object.Timer = 0
193
Object.YVelocity = -0x10000
194
195
Object.ThrusterAnimation = 1
196
Object.FrameTimer = 0
197
198
FloorControl.State = FLOORCONTROL_SETUP_CRUMBLE
199
200
Object.TriggerElecArc = false
201
Object.State++
202
end if
203
else
204
205
if Object.OutOfBounds == true
206
Object.SpikesAnimation = 0
207
Object.AnimationTimer = 0
208
Object.AnimationSpeed = 0
209
end if
210
211
if FloorControl.State < FLOORCONTROL_ELEC_ARC
212
if Object.TriggerElecArc == true
213
FloorControl.State = FLOORCONTROL_ELEC_ARC
214
FloorControl.Timer = 0
215
end if
216
end if
217
end if
218
end function
219
220
221
function R6_EGG_STEAM
222
if Object.AnimationTimer == 0
223
PlaySfx(SFX_G_EXPLOSION, false)
224
end if
225
226
if Object.AnimationTimer < 12
227
CreateTempObject(TypeName[Steam Cloud], 0, Object.XPos, Object.YPos)
228
229
SteamCloud[TempObjectPos].YPos -= 0x480000
230
231
Rand(SteamCloud[TempObjectPos].XVelocity, 0x200)
232
SteamCloud[TempObjectPos].XVelocity -= 0x100
233
SteamCloud[TempObjectPos].XVelocity <<= 10
234
235
Rand(SteamCloud[TempObjectPos].YVelocity, 0x100)
236
SteamCloud[TempObjectPos].YVelocity *= -0x400
237
end if
238
end function
239
240
241
sub ObjectMain
242
switch Object.State
243
case R6_EGG_IDLE
244
if Player.XPos > Object.XPos
245
Object.State++
246
Object.TriggerElecArc = false
247
end if
248
break
249
250
case R6_EGG_START
251
Object.Timer++
252
if Object.Timer == 120
253
Object.Timer = 0
254
255
Object.YVelocity = 0x30000
256
Object.TargetYPos = 0x6200000
257
258
Object.ThrusterAnimation = 1
259
Object.FrameTimer = 0
260
261
Object.State++
262
end if
263
break
264
265
case R6_EGG_INTRO
266
CallFunction(R6_EGG_DESCEND)
267
break
268
269
case R6_EGG_SET_ROUTE_1
270
CallFunction(R6_EGG_ROUTE_1ST_FLOOR)
271
if Object.State > R6_EGG_SET_ROUTE_1
272
Object.TargetYPos = 0x4280000
273
end if
274
break
275
276
case R6_EGG_ASCEND_1
277
CallFunction(R6_EGG_MOVE)
278
break
279
280
case R6_EGG_SET_ROUTE_2
281
CallFunction(R6_EGG_ROUTE_2ST_FLOOR)
282
if Object.State > R6_EGG_SET_ROUTE_2
283
Object.TargetYPos = 0x2280000
284
end if
285
break
286
287
case R6_EGG_ASCEND_2
288
CallFunction(R6_EGG_MOVE)
289
break
290
291
case R6_EGG_SET_ROUTE_3
292
CallFunction(R6_EGG_ROUTE_2ST_FLOOR)
293
if Object.State > R6_EGG_SET_ROUTE_3
294
Object.TargetYPos = 0x1300000
295
end if
296
break
297
298
case R6_EGG_ASCEND_3
299
CallFunction(R6_EGG_MOVE)
300
break
301
302
case R6_EGG_ROOF_DRILL
303
if Object.Timer == 0
304
Object.XPos += 0x20000
305
else
306
Object.XPos -= 0x20000
307
end if
308
Object.Timer++
309
Object.Timer &= 1
310
break
311
312
case R6_EGG_DESTROYED
313
Object.YPos += Object.YVelocity
314
Object.YVelocity += 0x1000
315
316
Player.Speed = 0
317
318
if Object.Timer == 0
319
Object.XPos += 0x20000
320
else
321
Object.XPos -= 0x20000
322
end if
323
Object.Timer++
324
Object.Timer &= 1
325
326
if Object.YPos >= 0x2A00000
327
Object.YPos = 0x2A00000
328
Object.Timer = 0
329
Object.YVelocity = 0
330
331
Object.EggmanAnimation = EGGANI_PANIC
332
333
SetTileLayerEntry(500, 0, 20, 5)
334
SetTileLayerEntry(501, 0, 21, 5)
335
SetTileLayerEntry(506, 0, 22, 5)
336
337
Object.State++
338
end if
339
340
if Player.XPos > Object.TargetYPos
341
Player.XPos = Object.TargetYPos
342
Player.XPos += 0x500000
343
else
344
Player.XPos = Object.TargetYPos
345
Player.XPos -= 0x500000
346
end if
347
348
CallFunction(R6_EGG_STEAM)
349
break
350
351
case R6_EGG_PANICKING
352
Player.Speed = 0
353
if Player.XPos > Object.XPos
354
Player.XPos = Object.XPos
355
Player.XPos += 0x500000
356
else
357
Player.XPos = Object.XPos
358
Player.XPos -= 0x500000
359
end if
360
361
CallFunction(R6_EGG_STEAM)
362
Object.Timer++
363
364
if Object.Timer == 180
365
BossBarrier2.State = BOSSBARRIER2_OPEN
366
end if
367
368
if Object.Timer == 240
369
Object.State++
370
Object.SpikesAnimation = 3
371
CreateTempObject(TypeName[Fade Screen], 0, Object.XPos, Object.YPos)
372
FadeScreen[TempObjectPos].EggMobileEntityNo = Object.EntityNo
373
end if
374
break
375
376
case R6_EGG_ESCAPE
377
Player.Speed = 0
378
if Player.XPos > Object.XPos
379
Player.XPos = Object.XPos
380
Player.XPos += 0x500000
381
else
382
Player.XPos = Object.XPos
383
Player.XPos -= 0x500000
384
end if
385
break
386
387
end switch
388
end sub
389
390
391
sub ObjectPlayerInteraction
392
PlayerObjectCollision(C_TOUCH, -22, 40, 22, 64)
393
if CheckResult == true
394
CallFunction(Player_Hit)
395
end if
396
397
if Player.Animation != ANI_HURT
398
if Object.FaceTimer == 0
399
#platform: Use_Standalone
400
PlayerObjectCollision(C_TOUCH, -64, -48, 64, 16)
401
TempValue0 = CheckResult
402
PlayerObjectCollision(C_TOUCH, -32, 16, 32, 32)
403
TempValue0 |= CheckResult
404
#endplatform
405
#platform: Use_Origins
406
PlayerObjectCollision(C_ENEMY, -64, -48, 64, 16)
407
TempValue0 = CheckResult
408
PlayerObjectCollision(C_ENEMY, -32, 16, 32, 32)
409
TempValue0 |= CheckResult
410
#endplatform
411
if TempValue0 == true
412
TempValue0 = false
413
if Player.Animation == ANI_JUMPING
414
TempValue0 = true
415
end if
416
#platform: Use_Origins
417
if Stage.PlayerListPos == PLAYER_AMY
418
if Player.Animation == ANI_HAMMER_JUMP
419
TempValue0 = true
420
end if
421
if Player.Animation == ANI_HAMMER_DASH
422
TempValue0 = true
423
end if
424
end if
425
if Stage.PlayerListPos == PLAYER_KNUCKLES
426
if Player.Animation == ANI_GLIDING
427
TempValue0 = true
428
end if
429
if Player.Animation == ANI_GLIDING_STOP
430
TempValue0 = true
431
end if
432
end if
433
#endplatform
434
435
if TempValue0 == true
436
#platform: Use_Haptics
437
HapticEffect(75, 0, 0, 0)
438
#endplatform
439
Object.FaceTimer = 120
440
441
FlipSign(Player.Speed)
442
Player.Speed >>= 1
443
444
FlipSign(Player.YVelocity)
445
Player.YVelocity >>= 1
446
Player.XVelocity = Player.Speed
447
448
if Object.State < R6_EGG_ROOF_DRILL
449
PlayStageSfx(SFX_S_BOSSHIT, false)
450
Object.EggmanAnimation = EGGANI_HURT
451
Object.Frame = 0
452
else
453
454
#platform: Use_Origins
455
EngineCallback(NOTIFY_KILL_BOSS)
456
// Tell HE2 that the boss fight ended
457
game.callbackParam0 = true
458
EngineCallback(NOTIFY_BOSS_END)
459
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
460
StopMusic()
461
end if
462
#endplatform
463
464
Object.State = R6_EGG_DESTROYED
465
466
Object.SpikesAnimation = 2
467
Object.AnimationTimer = 0
468
Object.EggmanAnimation = EGGANI_DEFEAT
469
Object.FaceFrame = 0
470
Object.Frame = 0
471
472
Object.TargetYPos = Object.XPos
473
474
FloorControl.Type = TypeName[Blank Object]
475
476
Copy16x16Tile(810, 863)
477
478
PlaySfx(SFX_G_EXPLOSION, false)
479
end if
480
else
481
CallFunction(Player_Hit)
482
end if
483
end if
484
end if
485
end if
486
end sub
487
488
489
sub ObjectDraw
490
DrawSprite(0)
491
492
switch Object.EggmanAnimation
493
case EGGANI_IDLE
494
TempValue0 = Object.FaceFrame
495
TempValue0 /= 10
496
TempValue0 += 2
497
498
Object.FaceFrame++
499
Object.FaceFrame %= 20
500
501
Object.Direction = Object.Frame
502
Object.Direction /= 25
503
504
Object.Frame++
505
Object.Frame %= 50
506
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
507
break
508
509
case EGGANI_HURT
510
Object.Direction = Object.Frame
511
Object.Direction /= 10
512
Object.Frame++
513
Object.Frame %= 20
514
DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos)
515
if Object.FaceTimer > 0
516
Object.FaceTimer--
517
else
518
Object.EggmanAnimation = EGGANI_IDLE
519
Object.FaceFrame = 0
520
Object.Frame = 0
521
end if
522
break
523
524
case EGGANI_DEFEAT
525
DrawSprite(5)
526
break
527
528
case EGGANI_PANIC
529
Object.Direction = Object.Frame
530
Object.Direction /= 25
531
532
Object.Frame++
533
Object.Frame %= 50
534
DrawSpriteFX(6, FX_FLIP, Object.XPos, Object.YPos)
535
break
536
537
end switch
538
539
switch Object.SpikesAnimation
540
case 0
541
DrawSprite(7)
542
break
543
544
case 1
545
TempValue0 = Object.AnimationTimer
546
TempValue0 >>= 7
547
TempValue0 += 7
548
DrawSprite(TempValue0)
549
550
Object.AnimationTimer += Object.AnimationSpeed
551
Object.AnimationTimer &= 511
552
553
if Object.AnimationSpeed < 128
554
Object.AnimationSpeed++
555
end if
556
break
557
558
case 2
559
TempValue0 = Object.AnimationTimer
560
TempValue0 /= 3
561
if TempValue0 < 4
562
TempValue0 += 11
563
DrawSprite(TempValue0)
564
end if
565
Object.AnimationTimer++
566
Object.AnimationTimer %= 30
567
break
568
569
end switch
570
571
switch Object.ThrusterAnimation
572
case 0
573
TempValue0 = Object.FrameTimer
574
TempValue0 >>= 1
575
TempValue0 += 19
576
DrawSprite(TempValue0)
577
Object.FrameTimer++
578
Object.FrameTimer &= 3
579
break
580
581
case 1
582
TempValue0 = Object.FrameTimer
583
TempValue0 /= 3
584
TempValue0 += 15
585
DrawSprite(TempValue0)
586
Object.FrameTimer++
587
Object.FrameTimer %= 12
588
break
589
590
end switch
591
end sub
592
593
594
sub ObjectStartup
595
LoadSpriteSheet("R6/Objects2.gif")
596
// Egg Razor
597
SpriteFrame(-64, -48, 128, 96, 66, 1) // #0 - Egg Razor Machine
598
SpriteFrame(-64, -16, 128, 32, 66, 98) // #1 - Egg Razor Destroyed
599
600
// Eggman
601
SpriteFrame(-24, -21, 48, 24, 116, 131) // #2 - Eggman Idle Frame 0
602
SpriteFrame(-24, -21, 48, 24, 116, 156) // #3 - Eggman Idle Frame 1
603
SpriteFrame(-24, -21, 48, 24, 116, 181) // #4 - Eggman Hurt
604
SpriteFrame(-28, -37, 48, 40, 124, 215) // #5 - Eggman Defeat
605
SpriteFrame(-24, -29, 48, 32, 1, 219) // #6 - Eggman Worry
606
607
// Egg Razor Spikes
608
SpriteFrame(-16, -80, 32, 32, 195, 1) // #7 - Spikes Frame 0
609
SpriteFrame(-16, -80, 32, 32, 195, 34) // #8 - Spikes Frame 1
610
SpriteFrame(-16, -80, 32, 32, 195, 67) // #9 - Spikes Frame 2
611
SpriteFrame(-16, -80, 32, 32, 195, 100) // #10 - Spikes Frame 3
612
613
// Egg Razor Steam
614
SpriteFrame(-12, -80, 24, 32, 228, 51) // #11 - Steam Frame 0
615
SpriteFrame(-12, -80, 24, 32, 228, 84) // #12 - Steam Frame 1
616
SpriteFrame(-12, -80, 24, 32, 231, 117) // #13 - Steam Frame 2
617
SpriteFrame(-12, -80, 24, 32, 231, 150) // #14 - Steam Frame 3
618
619
// Egg Razor Thruster
620
SpriteFrame(-16, 48, 32, 32, 198, 133) // #15 - Thruster Frame 0
621
SpriteFrame(-16, 48, 32, 24, 206, 199) // #16 - Thruster Frame 1
622
SpriteFrame(-16, 48, 32, 32, 198, 166) // #17 - Thruster Frame 2
623
SpriteFrame(-16, 48, 32, 24, 206, 224) // #18 - Thruster Frame 3
624
SpriteFrame(-16, 48, 32, 24, 206, 199) // #19 - Thruster Frame 4
625
SpriteFrame(-16, 48, 32, 24, 206, 224) // #20 - Thruster Frame 5
626
end sub
627
628
629
// ========================
630
// Editor Subs
631
// ========================
632
633
sub RSDKDraw
634
DrawSprite(0)
635
DrawSprite(1)
636
DrawSprite(2)
637
end sub
638
639
640
sub RSDKLoad
641
LoadSpriteSheet("R6/Objects2.gif")
642
// Egg Razor
643
SpriteFrame(-64, -48, 128, 96, 66, 1) // #0 - Egg Razor Machine
644
// Eggman
645
SpriteFrame(-24, -21, 48, 24, 116, 131) // #2 - Eggman Idle Frame 0
646
// Egg Razor Spikes
647
SpriteFrame(-16, -80, 32, 32, 195, 1) // #7 - Spikes Frame 0
648
649
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
650
end sub
651
652