Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R4/Eggman1.txt
1319 views
1
//----------Sonic CD R4 Eggman Chase Sequence Script----------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Unused
7
#alias Object.Value1 : Object.Speed
8
#alias Object.Value2 : Object.Angle
9
#alias Object.Value3 : Object.YOffset
10
#alias Object.Value4 : Object.FlameAnimation
11
#alias Object.Value5 : Object.Hits
12
#alias Object.Value6 : Object.FrameTimer
13
#alias Object.Value7 : Object.ExplosionTimer
14
#alias Object.PropertyValue : SolidBarrier.PropertyValue
15
16
// Player Alias
17
#alias Player.Value4 : Player.InvincibleTimer
18
19
// States
20
#alias 0 : R4_EGG_CHASE_PLAYER_APPROACH
21
#alias 1 : R4_EGG_CHASE_MOVE_DOWN_1
22
#alias 2 : R4_EGG_CHASE_SHIFT_RIGHT_1
23
#alias 3 : R4_EGG_CHASE_SHIFT_DOWN_1
24
#alias 4 : R4_EGG_CHASE_MOVE_RIGHT_1
25
#alias 5 : R4_EGG_CHASE_MOVE_DOWN_2
26
#alias 6 : R4_EGG_CHASE_MOVE_LEFT_1
27
#alias 7 : R4_EGG_CHASE_MOVE_DOWN_3
28
#alias 8 : R4_EGG_CHASE_MOVE_DR_1
29
#alias 9 : R4_EGG_CHASE_VERTICAL_LOOP
30
#alias 10 : R4_EGG_CHASE_MOVE_DOWN_4
31
#alias 11 : R4_EGG_CHASE_MOVE_DR_2
32
#alias 12 : R4_EGG_CHASE_MOVE_RIGHT_2
33
#alias 13 : R4_EGG_CHASE_MOVE_DR_3
34
#alias 14 : R4_EGG_CHASE_MOVE_DOWN_5
35
#alias 15 : R4_EGG_CHASE_MOVE_DR_4
36
#alias 16 : R4_EGG_CHASE_MOVE_DOWN_6
37
#alias 17 : R4_EGG_CHASE_MOVE_DL_1
38
#alias 18 : R4_EGG_CHASE_MOVE_LEFT_2
39
#alias 19 : R4_EGG_FLEE_TOP_DOOR
40
#alias 20 : R4_EGG_FLEE_MOVE_DR
41
#alias 21 : R4_EGG_FLEE_MOVE_RIGHT_1
42
#alias 22 : R4_EGG_FLEE_MOVE_DOWN_1
43
#alias 23 : R4_EGG_FLEE_BOTTOM_DOOR
44
#alias 24 : R4_EGG_FLEE_MOVE_RIGHT_2
45
#alias 25 : R4_EGG_FLEE_MOVE_UR
46
47
// Global SFX
48
#alias 22 : SFX_G_EXPLOSION
49
50
// Stage SFX
51
#alias 5 : SFX_S_BOSSHIT
52
53
// Priority
54
#alias 1 : PRIORITY_ACTIVE
55
56
// Solid Barrier Property Values
57
#alias 3 : OPEN_EGGMAN
58
59
// Function declarations
60
#function ChaseEggman_Oscillation
61
62
function ChaseEggman_Oscillation
63
Sin(Object.YPos, Object.Angle)
64
Object.YPos <<= 10
65
Object.Angle += 4
66
Object.Angle &= 511
67
end function
68
69
70
sub ObjectMain
71
switch Object.State
72
case R4_EGG_CHASE_PLAYER_APPROACH
73
PlayerObjectCollision(C_TOUCH, -64, -256, 64, 256)
74
if CheckResult == true
75
Object.State = R4_EGG_CHASE_MOVE_DOWN_1
76
Object.Priority = PRIORITY_ACTIVE
77
Object.Speed = 0x1C000
78
end if
79
break
80
81
case R4_EGG_CHASE_MOVE_DOWN_1
82
Object.YPos += Object.Speed
83
// Y - 1054 in map coords
84
if Object.YPos > 0x41E0000
85
Object.State++
86
Object.Direction = FACING_RIGHT
87
Object.FlameAnimation = 2
88
end if
89
break
90
91
case R4_EGG_CHASE_SHIFT_RIGHT_1
92
Object.XPos += Object.Speed
93
Object.YPos += Object.Speed
94
// X - 1248 in map coords
95
if Object.XPos > 0x4E00000
96
Object.XPos = 0x4E00000
97
Object.State++
98
Object.FlameAnimation = 0
99
end if
100
break
101
102
case R4_EGG_CHASE_SHIFT_DOWN_1
103
Object.YPos += Object.Speed
104
// Y - 1120 in map coords
105
if Object.YPos > 0x4600000
106
Object.YPos = 0x4600000
107
Object.State++
108
Object.Angle = 0
109
Object.YOffset = Object.YPos
110
Object.FlameAnimation = 1
111
end if
112
break
113
114
case R4_EGG_CHASE_MOVE_RIGHT_1
115
Object.XPos += Object.Speed
116
CallFunction(ChaseEggman_Oscillation)
117
Object.YPos += Object.YOffset
118
// X - 1596 in map coords
119
if Object.XPos > 0x63C0000
120
Object.XPos = 0x63C0000
121
Object.FlameAnimation = 0
122
if Object.Hits < 4
123
Object.State++
124
else
125
Object.State = R4_EGG_FLEE_BOTTOM_DOOR
126
SolidBarrier[+2].PropertyValue = OPEN_EGGMAN
127
end if
128
end if
129
break
130
131
case R4_EGG_CHASE_MOVE_DOWN_2
132
Object.YPos += Object.Speed
133
// Y - 1312 in map coords
134
if Object.YPos > 0x5200000
135
Object.YPos = 0x5200000
136
Object.State++
137
Object.Direction = FACING_LEFT
138
Object.Angle = 0
139
Object.YOffset = Object.YPos
140
Object.FlameAnimation = 1
141
end if
142
break
143
144
case R4_EGG_CHASE_MOVE_LEFT_1
145
Object.XPos -= Object.Speed
146
CallFunction(ChaseEggman_Oscillation)
147
FlipSign(Object.YPos)
148
Object.YPos += Object.YOffset
149
// Y - 1376 in map coords
150
if Object.XPos < 0x5600000
151
Object.XPos = 0x5600000
152
Object.State++
153
Object.FlameAnimation = 0
154
end if
155
break
156
157
case R4_EGG_CHASE_MOVE_DOWN_3
158
Object.YPos += Object.Speed
159
// Y - 1498 in map coords
160
if Object.YPos > 0x5DA0000
161
Object.State++
162
Object.Direction = FACING_RIGHT
163
Object.FlameAnimation = 2
164
end if
165
break
166
167
case R4_EGG_CHASE_MOVE_DR_1
168
Object.XPos += Object.Speed
169
Object.YPos += Object.Speed
170
// X - 1396 in map coords
171
if Object.XPos > 0x5740000
172
Object.XPos = 0x5740000
173
Object.State++
174
Object.FlameAnimation = 0
175
end if
176
break
177
178
case R4_EGG_CHASE_VERTICAL_LOOP
179
Object.YPos += Object.Speed
180
// Y - 2272 in map coords
181
if Object.YPos > 0x8E00000
182
Object.YPos -= 0x8000000 // Y - -2048 in map coords
183
Object.State++
184
else
185
// Y - 320 in map coords
186
if Player.YPos < 0x1400000
187
Object.YPos -= 0x8000000 // Y - -2048 in map coords
188
Object.State++
189
end if
190
end if
191
break
192
193
case R4_EGG_CHASE_MOVE_DOWN_4
194
Object.YPos += Object.Speed
195
// Y - 300 in map coords
196
if Object.YPos > 0x12C0000
197
Object.YPos = 0x12C0000
198
Object.State++
199
Object.FlameAnimation = 2
200
end if
201
break
202
203
case R4_EGG_CHASE_MOVE_DR_2
204
Object.XPos += Object.Speed
205
Object.YPos += Object.Speed
206
// X - 1532 in map coords
207
if Object.XPos > 0x5FC0000
208
Object.XPos = 0x5FC0000
209
Object.State++
210
Object.Angle = 0
211
Object.YOffset = Object.YPos
212
Object.FlameAnimation = 1
213
end if
214
break
215
216
case R4_EGG_CHASE_MOVE_RIGHT_2
217
Object.XPos += Object.Speed
218
CallFunction(ChaseEggman_Oscillation)
219
Object.YPos += Object.YOffset
220
// X - 1654 in map coords
221
if Object.XPos > 0x6760000
222
Object.State++
223
Object.FlameAnimation = 2
224
end if
225
break
226
227
case R4_EGG_CHASE_MOVE_DR_3
228
Object.XPos += Object.Speed
229
Object.YPos += Object.Speed
230
// X - 1732 in map coords
231
if Object.XPos > 0x6C40000
232
Object.XPos = 0x6C40000
233
Object.State++
234
Object.FlameAnimation = 0
235
end if
236
break
237
238
case R4_EGG_CHASE_MOVE_DOWN_5
239
Object.YPos += Object.Speed
240
// Y - 626 in map coords
241
if Object.YPos > 0x2720000
242
Object.State++
243
Object.FlameAnimation = 2
244
end if
245
break
246
247
case R4_EGG_CHASE_MOVE_DR_4
248
Object.XPos += Object.Speed
249
Object.YPos += Object.Speed
250
// X - 1764 in map coords
251
if Object.XPos > 0x6E40000
252
Object.XPos = 0x6E40000
253
Object.State++
254
Object.FlameAnimation = 0
255
end if
256
break
257
258
case R4_EGG_CHASE_MOVE_DOWN_6
259
Object.YPos += Object.Speed
260
if Object.Hits < 4
261
// Y - 626 in map coords
262
if Object.YPos > 0x2EC0000
263
Object.State++
264
Object.Direction = FACING_LEFT
265
Object.FlameAnimation = 2
266
end if
267
else
268
// Y - 688 in map coords
269
if Object.YPos > 0x2B00000
270
Object.State = R4_EGG_FLEE_TOP_DOOR
271
Object.FlameAnimation = 1
272
Object.Angle = 0
273
Object.YOffset = Object.YPos
274
SolidBarrier[+1].PropertyValue = OPEN_EGGMAN
275
end if
276
end if
277
break
278
279
case R4_EGG_CHASE_MOVE_DL_1
280
Object.XPos -= Object.Speed
281
Object.YPos += Object.Speed
282
// Y - 816 in map coords
283
if Object.YPos > 0x3300000
284
Object.YPos = 0x3300000
285
Object.State++
286
Object.Angle = 0
287
Object.YOffset = Object.YPos
288
Object.FlameAnimation = 1
289
end if
290
break
291
292
case R4_EGG_CHASE_MOVE_LEFT_2
293
Object.XPos -= Object.Speed
294
CallFunction(ChaseEggman_Oscillation)
295
FlipSign(Object.YPos)
296
Object.YPos += Object.YOffset
297
// X - 1232 in map coords
298
if Object.XPos < 0x4D00000
299
Object.XPos = 0x4D00000
300
Object.State = R4_EGG_CHASE_MOVE_DOWN_1
301
Object.FlameAnimation = 0
302
end if
303
break
304
305
case R4_EGG_FLEE_TOP_DOOR
306
Object.XPos += Object.Speed
307
CallFunction(ChaseEggman_Oscillation)
308
Object.YPos += Object.YOffset
309
// X - 1956 in map coords
310
if Object.XPos > 0x7A40000
311
Object.State++
312
Object.FlameAnimation = 2
313
end if
314
break
315
316
case R4_EGG_FLEE_MOVE_DR
317
Object.XPos += Object.Speed
318
Object.YPos += Object.Speed
319
// Y - 736 in map coords
320
if Object.YPos > 0x2E00000
321
Object.YPos = 0x2E00000
322
Object.State++
323
Object.FlameAnimation = 1
324
Object.Angle = 0
325
Object.YOffset = Object.YPos
326
end if
327
break
328
329
case R4_EGG_FLEE_MOVE_RIGHT_1
330
Object.XPos += Object.Speed
331
CallFunction(ChaseEggman_Oscillation)
332
Object.YPos += Object.YOffset
333
// X - 2168 in map coords
334
if Object.XPos > 0x8780000
335
Object.XPos = 0x8780000
336
Object.State++
337
Object.FlameAnimation = 0
338
end if
339
break
340
341
case R4_EGG_FLEE_MOVE_DOWN_1
342
if Object.Speed < 0x40000
343
Object.YPos += 0x40000
344
else
345
Object.YPos += Object.Speed
346
end if
347
348
TempValue0 = Screen.YOffset
349
TempValue0 += 288
350
TempValue0 <<= 16
351
352
if Object.YPos > TempValue0
353
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
354
end if
355
break
356
357
case R4_EGG_FLEE_BOTTOM_DOOR
358
Object.YPos -= Object.Speed
359
// Y - 1088 in map coords
360
if Object.YPos < 0x4400000
361
Object.YPos = 0x4400000
362
Object.State++
363
Object.FlameAnimation = 1
364
Object.Angle = 0
365
Object.YOffset = Object.YPos
366
end if
367
break
368
369
case R4_EGG_FLEE_MOVE_RIGHT_2
370
Object.XPos += Object.Speed
371
CallFunction(ChaseEggman_Oscillation)
372
Object.YPos += Object.YOffset
373
// X - 1856 in map coords
374
if Object.XPos > 0x7400000
375
Object.State++
376
Object.FlameAnimation = 2
377
end if
378
break
379
380
case R4_EGG_FLEE_MOVE_UR
381
Object.XPos += Object.Speed
382
Object.YPos -= Object.Speed
383
// Y - 988 in map coords
384
if Object.YPos < 0x3DC0000
385
Object.YPos = 0x3DC0000
386
Object.State = R4_EGG_FLEE_MOVE_RIGHT_1
387
Object.FlameAnimation = 1
388
Object.Angle = 0
389
Object.YOffset = Object.YPos
390
end if
391
break
392
393
end switch
394
395
if Object.ExplosionTimer == 1
396
CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)
397
if Object.Direction == FACING_RIGHT
398
Object[TempObjectPos].XPos -= 0x80000
399
else
400
Object[TempObjectPos].XPos += 0x80000
401
end if
402
PlaySfx(SFX_G_EXPLOSION, false)
403
Object.ExplosionTimer = 34
404
else
405
if Object.ExplosionTimer > 0
406
Object.ExplosionTimer--
407
end if
408
end if
409
end sub
410
411
412
sub ObjectPlayerInteraction
413
if Object.FrameTimer == 0
414
#platform: Use_Standalone
415
PlayerObjectCollision(C_TOUCH, -32, -24, 32, 24)
416
#endplatform
417
#platform: Use_Origins
418
PlayerObjectCollision(C_ENEMY, -32, -24, 32, 24)
419
#endplatform
420
if CheckResult == true
421
CheckEqual(Player.Animation, ANI_JUMPING)
422
TempValue0 = CheckResult
423
CheckEqual(Player.Animation, ANI_SPINDASH)
424
TempValue0 |= CheckResult
425
#platform: Use_Origins
426
// making really sure you're the one character that can glide or the one character that has a hammer
427
if Stage.PlayerListPos == PLAYER_KNUCKLES
428
CheckEqual(Player.Animation, ANI_GLIDING)
429
TempValue0 |= CheckResult
430
CheckEqual(Player.Animation, ANI_GLIDING_STOP)
431
TempValue0 |= CheckResult
432
end if
433
if Stage.PlayerListPos == PLAYER_AMY
434
CheckEqual(Player.Animation, ANI_HAMMER_JUMP)
435
TempValue0 |= CheckResult
436
CheckEqual(Player.Animation, ANI_HAMMER_DASH)
437
TempValue0 |= CheckResult
438
end if
439
#endplatform
440
if Player.Animation == ANI_FLYING
441
CheckGreater(Player.YPos, Object.YPos)
442
TempValue0 |= CheckResult
443
end if
444
445
ArrayPos0 = Player.EntityNo
446
ArrayPos0 += 2
447
if Object[ArrayPos0].Type == TypeName[Invincibility]
448
TempValue0 = true
449
end if
450
451
if TempValue0 == true
452
FlipSign(Player.XVelocity)
453
FlipSign(Player.Speed)
454
Player.XVelocity >>= 1
455
Player.Speed >>= 1
456
457
Player.YVelocity = Player.YPos
458
Player.YVelocity -= Object.YPos
459
Player.YVelocity >>= 3
460
461
#platform: Use_Origins
462
if Stage.PlayerListPos == PLAYER_KNUCKLES
463
if Player.Animation == ANI_GLIDING
464
Player.Animation = ANI_GLIDING_DROP
465
Player.State = Player_State_GlideDrop
466
end if
467
end if
468
#endplatform
469
470
Object.Hits++
471
if Object.Hits == 4
472
Object.FrameTimer = 16
473
Object.ExplosionTimer = 1
474
else
475
Object.FrameTimer = 1
476
PlayStageSfx(SFX_S_BOSSHIT, false)
477
Object.Speed = 0x48000
478
end if
479
else
480
if Player.InvincibleTimer == 0
481
Player.State = Player_State_GotHit
482
if Player.XPos > Object.XPos
483
Player.Speed = 0x20000
484
else
485
Player.Speed = -0x20000
486
end if
487
end if
488
end if
489
end if
490
else
491
if Object.Hits == 4
492
PlayerObjectCollision(C_TOUCH, -64, -80, 64, 80)
493
if CheckResult == true
494
switch Object.FlameAnimation
495
case 0
496
Object.Speed += 0x8000
497
break
498
499
case 1
500
Object.Speed += 0x8000
501
if Object.Speed > 0x60000
502
Object.Speed = 0x60000
503
end if
504
break
505
506
case 2
507
Object.Speed -= 0x2000
508
if Object.Speed > 0x60000
509
Object.Speed = 0x60000
510
end if
511
if Object.Speed < 0x20000
512
Object.Speed = 0x20000
513
end if
514
break
515
516
end switch
517
else
518
Object.Speed -= 0x2000
519
if Object.Speed < 0x1C000
520
Object.Speed = 0x1C000
521
end if
522
end if
523
524
PlayerObjectCollision(C_TOUCH, -320, -240, 320, 240)
525
if CheckResult == false
526
Object.Speed = 0
527
end if
528
end if
529
end if
530
end sub
531
532
533
sub ObjectDraw
534
if Object.FrameTimer == 0
535
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
536
DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)
537
else
538
if Object.FrameTimer < 16
539
TempValue0 = Object.FrameTimer
540
TempValue0 &= 1
541
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
542
543
if TempValue0 == 0
544
DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos)
545
end if
546
547
TempValue0 = Object.FrameTimer
548
TempValue0 &= 15
549
TempValue0 >>= 2
550
TempValue0 += 8
551
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
552
else
553
if Object.Unused < 32
554
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
555
DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos) // Nervous face
556
else
557
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
558
DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos) // Normal face
559
end if
560
TempValue0 = Object.FrameTimer
561
TempValue0 &= 15
562
TempValue0 >>= 2
563
TempValue0 += 8
564
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
565
end if
566
567
Object.FrameTimer++
568
if Object.Hits < 4
569
if Object.FrameTimer == 80
570
Object.FrameTimer = 0
571
Object.Speed = 0x1C000
572
end if
573
else
574
if Object.FrameTimer == 32
575
Object.FrameTimer = 16
576
end if
577
end if
578
end if
579
580
TempValue0 = Object.Frame
581
TempValue0 >>= 2
582
switch Object.FlameAnimation
583
case 0
584
TempValue0 += 4
585
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
586
break
587
588
case 1
589
TempValue0 += 6
590
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
591
break
592
593
case 2
594
TempValue0 += 4
595
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
596
TempValue0 += 2
597
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
598
break
599
end switch
600
601
Object.Frame++
602
Object.Frame &= 7
603
end sub
604
605
606
sub ObjectStartup
607
LoadSpriteSheet("R4/Objects2.gif")
608
609
// Egg Mobile
610
SpriteFrame(-36, -28, 72, 56, 61, 1) // #0 - Egg Bubble Chase
611
SpriteFrame(-36, -28, 72, 56, 134, 1) // #1 - Egg Bubble Chase damage
612
613
// Eggman
614
SpriteFrame(-12, -28, 32, 16, 207, 1) // #2 - Eggman face
615
SpriteFrame(-12, -28, 32, 16, 207, 18) // #3 - Eggman nervous face
616
617
// Thruster
618
SpriteFrame(-36, 28, 72, 16, 116, 58) // #4 - Thruster vertical big flame
619
SpriteFrame(-36, 28, 72, 16, 116, 75) // #5 - Thruster vertical small flame
620
SpriteFrame(-36, 20, 72, 16, 116, 92) // #6 - Thruster angle big flame
621
SpriteFrame(-36, 20, 72, 16, 116, 109) // #7 - Thruster angle small flame
622
623
// Sweat
624
SpriteFrame(-12, -44, 16, 16, 1, 135) // #8 - Sweat drop frame 0
625
SpriteFrame(-12, -44, 1, 1, 1, 135) // #9 - Sweat drop frame 1
626
SpriteFrame(-12, -44, 16, 16, 18, 135) // #10 - Sweat drop frame 2
627
SpriteFrame(-12, -44, 1, 1, 1, 135) // #11 - Sweat drop frame 3
628
629
// Used to be below LoadSpriteSheet, moved here for consistency
630
ArrayPos0 = 32
631
while ArrayPos0 < 1056
632
if Object[ArrayPos0].Type == TypeName[Eggman Part 1]
633
Object[ArrayPos0].Direction = FACING_LEFT
634
end if
635
ArrayPos0++
636
loop
637
end sub
638
639
640
// ========================
641
// Editor Subs
642
// ========================
643
644
sub RSDKDraw
645
DrawSprite(0)
646
DrawSprite(1)
647
end sub
648
649
650
sub RSDKLoad
651
LoadSpriteSheet("R4/Objects2.gif")
652
653
// Egg Mobile
654
SpriteFrame(-36, -28, 72, 56, 61, 1) // #0 - Egg Bubble Chase
655
// Eggman
656
SpriteFrame(-12, -28, 32, 16, 207, 1) // #2 - Eggman face
657
658
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
659
end sub
660
661