Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R4/Eggman2.txt
1319 views
1
//-----------------Sonic CD Egg Bubble 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.BubbleSpawnTimer
8
#alias Object.Value2 : Object.BubbleSelector
9
#alias Object.Value3 : Object.BubbleRadius
10
#alias Object.Value4 : Object.MaxBubble
11
#alias Object.Value5 : Object.Angle
12
#alias Object.Value6 : Object.BubbleOffset
13
#alias Object.Value7 : Object.Animation
14
#alias Object.Frame : Object.FrameTimer
15
16
17
// Boss Bubble 1 Aliases
18
#alias Object.Value2 : Bubble1.XOffSet
19
#alias Object.Value4 : Bubble1.XShift
20
#alias Object.Value5 : Bubble1.BossEntity
21
#alias Object.Value6 : Bubble1.RadiusSize
22
#alias Object.XPos : Bubble1.XPos
23
#alias Object.YPos : Bubble1.YPos
24
25
// Boss Bubble 2 aliases
26
#alias Object.Value0 : Bubble2.Timer
27
#alias Object.Value2 : Bubble2.XOffSet
28
#alias Object.Value3 : Bubble2.YOffSet
29
#alias Object.Value4 : Bubble2.XShift
30
#alias Object.Value5 : Bubble2.BossEntity
31
#alias Object.Value6 : Bubble2.RadiusSize
32
#alias Object.XPos : Bubble2.XPos
33
#alias Object.YPos : Bubble2.YPos
34
#alias Object.State : Bubble2.State
35
#alias Object.DrawOrder : Bubble2.DrawOrder
36
#alias Object.Type : Bubble2.Type
37
38
// Boss Bullet alias
39
#alias Object.DrawOrder : Bullet.DrawOrder
40
#alias Object.Value5 : Bullet.BossEntity
41
42
// Object +17 is a helper object for the boss movement
43
#alias Object[+17].XPos : Helper.XPos
44
#alias Object[+17].YPos : Helper.YPos
45
#alias Object[+17].Value5 : Helper.Angle
46
47
// Player alias
48
#alias Player.Value4 : Player.InvincibleTimer
49
50
// States
51
#alias 0 : R4_EGG_BUBBLE_PLAYER_APPROACH
52
#alias 1 : R4_EGG_BUBBLE_INTRO
53
#alias 2 : R4_EGG_BUBBLE_SPAWN_BUBBLES
54
#alias 3 : R4_EGG_BUBBLE_DELAY
55
#alias 4 : R4_EGG_BUBBLE_EXPAND_SHIELD
56
#alias 5 : R4_EGG_BUBBLE_START_BATTLE
57
#alias 6 : R4_EGG_BUBBLE_ATTACK_R_TO_L
58
#alias 7 : R4_EGG_BUBBLE_TURN_TO_RIGHT
59
#alias 8 : R4_EGG_BUBBLE_ATTACK_L_TO_R
60
#alias 9 : R4_EGG_BUBBLE_TURN_TO_LEFT
61
#alias 10 : R4_EGG_BUBBLE_REBUILD_SHIELD_L
62
#alias 11 : R4_EGG_BUBBLE_MOVE_TO_R
63
#alias 12 : R4_EGG_BUBBLE_REBUILD_SHIELD_R
64
#alias 13 : R4_EGG_BUBBLE_MOVE_TO_L
65
#alias 14 : R4_EGG_BUBBLE_EXPLODE
66
#alias 15 : R4_EGG_BUBBLE_DEFEAT
67
#alias 16 : R4_EGG_BUBBLE_FLEE
68
#alias 17 : R4_EGG_BUBBLE_RESTORE_BOUNDS
69
70
// BossBubble2 States
71
#alias 2 : BOSSBUBBLE2_BREATHABLE
72
#alias 3 : BOSSBUBBLE2_CONSUMED
73
74
// Eggman Animations
75
#alias 0 : EGGANI_IDLE
76
#alias 1 : EGGANI_LAUGH
77
#alias 2 : EGGANI_HURT
78
#alias 3 : EGGANI_DEFEAT
79
#alias 4 : EGGANI_ESCAPE
80
#alias 5 : EGGANI_NONE
81
82
// Fade Music Property Values
83
#alias 0 : FADEMUSIC_TO_BOSS
84
#alias 1 : FADEMUSIC_TO_LEVEL
85
86
// Global SFX
87
#alias 22 : SFX_G_EXPLOSION
88
89
// Stage SFX
90
#alias 7 : SFX_S_DROWNING
91
92
// Priority
93
#alias 0 : PRIORITY_BOUNDS
94
#alias 1 : PRIORITY_ACTIVE
95
96
// Function declarations
97
#function EggBubble_HandleBubbleMovement
98
#function EggBubble_HandleBubbleTurn
99
#function EggBubble_CheckShieldCondition
100
#function EggBubble_CheckBubbleAmount
101
#function EggBubble_DestroyBubbles
102
#function EggBubble_FireBullet
103
104
105
function EggBubble_HandleBubbleMovement
106
ArrayPos0 = 1
107
TempValue0 = Object.Angle
108
while ArrayPos0 <= Object.MaxBubble
109
if Bubble2[+ArrayPos0].State < 3
110
Bubble2[+ArrayPos0].DrawOrder = 3
111
// Orbit-like movement
112
Cos(TempValue1, TempValue0)
113
TempValue1 *= Object.BubbleRadius
114
TempValue1 >>= 1
115
// Horizontal movement
116
Cos(Bubble2[+ArrayPos0].XPos, Object.Rotation)
117
Bubble2[+ArrayPos0].XPos *= TempValue1
118
Bubble2[+ArrayPos0].XPos >>= 9
119
Bubble2[+ArrayPos0].XPos += Object.XPos
120
// Vertical movement
121
Sin(Bubble2[+ArrayPos0].YPos, TempValue0)
122
Bubble2[+ArrayPos0].YPos *= Object.BubbleRadius
123
Bubble2[+ArrayPos0].YPos >>= 1
124
Bubble2[+ArrayPos0].YPos += Object.YPos
125
end if
126
TempValue0 += Object.BubbleOffset
127
ArrayPos0++
128
loop
129
end function
130
131
132
function EggBubble_HandleBubbleTurn
133
ArrayPos0 = 1
134
TempValue0 = Object.Angle
135
while ArrayPos0 <= Object.MaxBubble
136
if Bubble2[+ArrayPos0].State < 3
137
if TempValue0 < 128
138
Bubble2[+ArrayPos0].DrawOrder = 3
139
else
140
if TempValue0 > 383
141
Bubble2[+ArrayPos0].DrawOrder = 3
142
else
143
Bubble2[+ArrayPos0].DrawOrder = 2
144
end if
145
end if
146
// Orbit-like movement
147
Cos(TempValue1, TempValue0)
148
TempValue1 *= Object.BubbleRadius
149
TempValue1 >>= 1
150
// Horizontal movement
151
Cos(Bubble2[+ArrayPos0].XPos, Object.Rotation)
152
Bubble2[+ArrayPos0].XPos *= TempValue1
153
Bubble2[+ArrayPos0].XPos >>= 9
154
Bubble2[+ArrayPos0].XPos += Object.XPos
155
// Vertical movement
156
Sin(Bubble2[+ArrayPos0].YPos, TempValue0)
157
Bubble2[+ArrayPos0].YPos *= Object.BubbleRadius
158
Bubble2[+ArrayPos0].YPos >>= 1
159
Bubble2[+ArrayPos0].YPos += Object.YPos
160
end if
161
TempValue0 += Object.BubbleOffset
162
TempValue0 &= 511
163
ArrayPos0++
164
loop
165
end function
166
167
168
function EggBubble_CheckShieldCondition
169
ArrayPos0 = 1
170
TempValue0 = 0
171
while ArrayPos0 <= Object.MaxBubble
172
if Bubble2[+ArrayPos0].Type == TypeName[Boss Bubble 2]
173
TempValue0++
174
end if
175
ArrayPos0++
176
loop
177
178
CheckResult = false
179
switch TempValue0
180
case 3
181
if Object.MaxBubble > 4
182
CheckResult = true
183
end if
184
break
185
186
case 4
187
case 5
188
case 6
189
case 7
190
if TempValue0 < Object.MaxBubble
191
CheckResult = true
192
end if
193
break
194
195
case 8
196
case 9
197
case 10
198
case 11
199
case 12
200
case 13
201
case 14
202
TempValue1 = Object.MaxBubble
203
TempValue1 -= TempValue0
204
if TempValue1 > 1
205
CheckResult = true
206
end if
207
break
208
209
end switch
210
end function
211
212
213
function EggBubble_CheckBubbleAmount
214
ArrayPos0 = 1
215
TempValue0 = 0
216
while ArrayPos0 <= Object.MaxBubble
217
if Bubble2[+ArrayPos0].Type == TypeName[Boss Bubble 2]
218
TempValue0++
219
end if
220
ArrayPos0++
221
loop
222
223
ArrayPos0 = 1
224
while ArrayPos0 <= Object.MaxBubble
225
if ArrayPos0 <= TempValue0
226
Bubble2[+ArrayPos0].Type = TypeName[Boss Bubble 2]
227
Bubble2[+ArrayPos0].State = BOSSBUBBLE2_BREATHABLE
228
Bubble2[+ArrayPos0].TImer = 0
229
else
230
Bubble2[+ArrayPos0].Type = TypeName[Blank Object]
231
end if
232
ArrayPos0++
233
loop
234
235
Object.MaxBubble = TempValue0
236
Object.BubbleOffset = 512
237
Object.BubbleOffset /= Object.MaxBubble
238
end function
239
240
241
function EggBubble_DestroyBubbles
242
ArrayPos0 = 1
243
while ArrayPos0 <= Object.MaxBubble
244
if Bubble2[+ArrayPos0].Type == TypeName[Boss Bubble 2]
245
Bubble2[+ArrayPos0].State = BOSSBUBBLE2_CONSUMED
246
Bubble2[+ArrayPos0].TImer = 0
247
end if
248
ArrayPos0++
249
loop
250
end function
251
252
253
function EggBubble_FireBullet
254
if Object.Direction == FACING_RIGHT
255
CreateTempObject(TypeName[Boss Bullet], 0, Object.XPos, Object.YPos)
256
Bullet[TempObjectPos].BossEntity = Object.EntityNo
257
Bullet[TempObjectPos].DrawOrder = 2
258
CreateTempObject(TypeName[Boss Bullet], 1, Object.XPos, Object.YPos)
259
Bullet[TempObjectPos].BossEntity = Object.EntityNo
260
Bullet[TempObjectPos].DrawOrder = 2
261
CreateTempObject(TypeName[Boss Bullet], 2, Object.XPos, Object.YPos)
262
Bullet[TempObjectPos].BossEntity = Object.EntityNo
263
Bullet[TempObjectPos].DrawOrder = 2
264
CreateTempObject(TypeName[Boss Bullet], 3, Object.XPos, Object.YPos)
265
Bullet[TempObjectPos].BossEntity = Object.EntityNo
266
Bullet[TempObjectPos].DrawOrder = 2
267
else
268
CreateTempObject(TypeName[Boss Bullet], 4, Object.XPos, Object.YPos)
269
Bullet[TempObjectPos].BossEntity = Object.EntityNo
270
Bullet[TempObjectPos].DrawOrder = 2
271
CreateTempObject(TypeName[Boss Bullet], 5, Object.XPos, Object.YPos)
272
Bullet[TempObjectPos].BossEntity = Object.EntityNo
273
Bullet[TempObjectPos].DrawOrder = 2
274
CreateTempObject(TypeName[Boss Bullet], 6, Object.XPos, Object.YPos)
275
Bullet[TempObjectPos].BossEntity = Object.EntityNo
276
Bullet[TempObjectPos].DrawOrder = 2
277
CreateTempObject(TypeName[Boss Bullet], 7, Object.XPos, Object.YPos)
278
Bullet[TempObjectPos].BossEntity = Object.EntityNo
279
Bullet[TempObjectPos].DrawOrder = 2
280
end if
281
end function
282
283
284
sub ObjectMain
285
switch Object.State
286
case R4_EGG_BUBBLE_PLAYER_APPROACH
287
Stage.NewXBoundary1 = Object.iXPos
288
Stage.NewXBoundary1 -= 96
289
Stage.NewXBoundary1 -= Screen.CenterX
290
291
Stage.NewXBoundary2 = Stage.NewXBoundary1
292
Stage.NewXBoundary2 += Screen.CenterX
293
Stage.NewXBoundary2 += Screen.CenterX
294
295
PlayerObjectCollision(C_TOUCH, -80, -256, 64, 256)
296
if CheckResult == true
297
Object.State = R4_EGG_BUBBLE_INTRO
298
299
Helper.XPos = Object.XPos
300
Helper.XPos -= 0x600000
301
302
Helper.YPos = Object.YPos
303
304
CreateTempObject(TypeName[Fade Music], FADEMUSIC_TO_BOSS, Object.XPos, Object.YPos)
305
end if
306
break
307
308
case R4_EGG_BUBBLE_INTRO
309
if Object.Timer < 60
310
Object.Timer++
311
else
312
Object.Timer = 0
313
Object.BubbleSelector = 0
314
315
Object.State = R4_EGG_BUBBLE_SPAWN_BUBBLES
316
end if
317
break
318
319
case R4_EGG_BUBBLE_SPAWN_BUBBLES
320
if Object.Timer < 320
321
TempValue0 = Object.Timer
322
TempValue0 %= 20
323
if TempValue0 == 0
324
PlayStageSfx(SFX_S_DROWNING, false)
325
end if
326
327
if Object.BubbleSpawnTimer > 0
328
Object.BubbleSpawnTimer--
329
else
330
Object.BubbleSpawnTimer = 10
331
332
CreateTempObject(TypeName[Boss Bubble 1], 0, Object.XPos, Object.YPos)
333
334
Rand(Bubble1[TempObjectPos].XPos, 28)
335
Bubble1[TempObjectPos].XPos -= 14
336
Bubble1[TempObjectPos].XPos <<= 16
337
Bubble1[TempObjectPos].XPos += Object.XPos
338
339
Bubble1[TempObjectPos].XOffSet = Bubble1[TempObjectPos].XPos
340
341
Bubble1[TempObjectPos].YPos += 0x9C0000
342
343
Rand(Bubble1[TempObjectPos].XShift, 4)
344
Bubble1[TempObjectPos].XShift += 9
345
346
Bubble1[TempObjectPos].BossEntity = Object.EntityNo
347
348
if Object.BubbleSelector == 1
349
Rand(Bubble1[TempObjectPos].RadiusSize, 32)
350
Bubble1[TempObjectPos].RadiusSize -= 16
351
Bubble1[TempObjectPos].RadiusSize <<= 16
352
else
353
Bubble1[TempObjectPos].RadiusSize = 0
354
end if
355
Object.BubbleSelector++
356
Object.BubbleSelector &= 1
357
end if
358
359
Object.Timer++
360
else
361
Object.State = R4_EGG_BUBBLE_DELAY
362
Object.Timer = 0
363
end if
364
break
365
366
case R4_EGG_BUBBLE_DELAY
367
if Object.Timer < 180
368
Object.Timer++
369
else
370
Object.Timer = 0
371
Object.Angle = 0
372
Object.Rotation = 256
373
374
Object.MaxBubble = 16
375
Object.BubbleOffset = 32
376
Object.BubbleRadius = 0x1000
377
378
Object.State = R4_EGG_BUBBLE_EXPAND_SHIELD
379
ArrayPos0 = 1
380
while ArrayPos0 < 17
381
Bubble2[+ArrayPos0].Type = TypeName[Boss Bubble 2]
382
ArrayPos0++
383
loop
384
CallFunction(EggBubble_HandleBubbleMovement)
385
end if
386
break
387
388
case R4_EGG_BUBBLE_EXPAND_SHIELD
389
Object.Angle += 8
390
Object.Angle &= 511
391
392
if Object.BubbleRadius < 0x3000
393
Object.BubbleRadius += 0x60
394
else
395
Object.State = R4_EGG_BUBBLE_START_BATTLE
396
end if
397
398
CallFunction(EggBubble_HandleBubbleMovement)
399
break
400
401
case R4_EGG_BUBBLE_START_BATTLE
402
Object.Angle += 2
403
Object.Angle &= 511
404
405
if Object.Timer < 20
406
Object.Timer++
407
else
408
Object.State = R4_EGG_BUBBLE_ATTACK_R_TO_L
409
Helper.Angle = 0
410
end if
411
412
CallFunction(EggBubble_HandleBubbleMovement)
413
break
414
415
case R4_EGG_BUBBLE_ATTACK_R_TO_L
416
Cos(Object.XPos, Helper.Angle)
417
Object.XPos *= 0x3000
418
Object.XPos += Helper.XPos
419
420
Sin(Object.YPos, Helper.Angle)
421
Object.YPos *= 0x2000
422
Object.YPos += Helper.YPos
423
424
if Helper.Angle == 12
425
CallFunction(EggBubble_FireBullet)
426
end if
427
428
if Helper.Angle < 256
429
Helper.Angle += 2
430
else
431
Object.State = R4_EGG_BUBBLE_TURN_TO_RIGHT
432
end if
433
434
Object.Angle += 2
435
Object.Angle &= 511
436
CallFunction(EggBubble_HandleBubbleMovement)
437
break
438
439
case R4_EGG_BUBBLE_TURN_TO_RIGHT
440
Object.Angle += 8
441
Object.Angle &= 511
442
443
CallFunction(EggBubble_HandleBubbleTurn)
444
445
if Object.Rotation == 128
446
Object.Direction = FACING_LEFT
447
end if
448
449
if Object.Rotation > 0
450
Object.Rotation -= 2
451
else
452
CallFunction(EggBubble_CheckShieldCondition)
453
if CheckResult == true
454
Object.State = R4_EGG_BUBBLE_REBUILD_SHIELD_L
455
Object.Timer = 0
456
else
457
Object.State = R4_EGG_BUBBLE_ATTACK_L_TO_R
458
end if
459
end if
460
461
break
462
463
case R4_EGG_BUBBLE_ATTACK_L_TO_R
464
Cos(Object.XPos, Helper.Angle)
465
Object.XPos *= 0x3000
466
Object.XPos += Helper.XPos
467
468
Sin(Object.YPos, Helper.Angle)
469
Object.YPos *= 0x2000
470
Object.YPos += Helper.YPos
471
472
if Helper.Angle == 244
473
CallFunction(EggBubble_FireBullet)
474
end if
475
if Helper.Angle > 0
476
Helper.Angle -= 2
477
else
478
Object.State = R4_EGG_BUBBLE_TURN_TO_LEFT
479
end if
480
481
Object.Angle += 2
482
Object.Angle &= 511
483
CallFunction(EggBubble_HandleBubbleMovement)
484
break
485
486
case R4_EGG_BUBBLE_TURN_TO_LEFT
487
Object.Angle += 8
488
Object.Angle &= 511
489
CallFunction(EggBubble_HandleBubbleTurn)
490
491
if Object.Rotation == 128
492
Object.Direction = FACING_RIGHT
493
end if
494
if Object.Rotation < 256
495
Object.Rotation += 2
496
else
497
CallFunction(EggBubble_CheckShieldCondition)
498
if CheckResult == true
499
Object.State = R4_EGG_BUBBLE_REBUILD_SHIELD_R
500
Object.Timer = 0
501
else
502
Object.State = R4_EGG_BUBBLE_ATTACK_R_TO_L
503
end if
504
end if
505
break
506
507
case R4_EGG_BUBBLE_REBUILD_SHIELD_L
508
Object.XPos += 0x10000
509
510
if Object.Timer < 20
511
Object.Timer++
512
513
Object.Angle += 2
514
Object.Angle &= 511
515
CallFunction(EggBubble_HandleBubbleMovement)
516
517
if Object.Timer == 20
518
Object.Animation = EGGANI_LAUGH
519
end if
520
else
521
if Object.BubbleRadius > 0xC00
522
Object.BubbleRadius -= 0x100
523
else
524
Object.State = R4_EGG_BUBBLE_MOVE_TO_R
525
CallFunction(EggBubble_CheckBubbleAmount)
526
CallFunction(EggBubble_FireBullet)
527
end if
528
529
Object.Angle += 8
530
Object.Angle &= 511
531
CallFunction(EggBubble_HandleBubbleMovement)
532
end if
533
break
534
535
case R4_EGG_BUBBLE_MOVE_TO_R
536
Object.XPos += 0x10000
537
538
if Object.BubbleRadius < 0x3000
539
Object.BubbleRadius += 0x60
540
Object.Angle += 8
541
else
542
Object.Angle += 2
543
end if
544
545
TempValue0 = Helper.XPos
546
TempValue0 += 0x600000
547
548
if Object.XPos > TempValue0
549
Object.XPos = TempValue0
550
Helper.Angle = 0
551
Object.State = R4_EGG_BUBBLE_TURN_TO_LEFT
552
end if
553
554
Object.Angle &= 511
555
CallFunction(EggBubble_HandleBubbleMovement)
556
break
557
558
case R4_EGG_BUBBLE_REBUILD_SHIELD_R
559
Object.XPos -= 0x10000
560
561
if Object.Timer < 20
562
Object.Timer++
563
564
Object.Angle += 2
565
Object.Angle &= 511
566
CallFunction(EggBubble_HandleBubbleMovement)
567
568
if Object.Timer == 20
569
Object.Animation = EGGANI_LAUGH
570
end if
571
else
572
if Object.BubbleRadius > 0xC00
573
Object.BubbleRadius -= 0x100
574
else
575
Object.State = R4_EGG_BUBBLE_MOVE_TO_L
576
CallFunction(EggBubble_CheckBubbleAmount)
577
CallFunction(EggBubble_FireBullet)
578
end if
579
580
Object.Angle += 8
581
Object.Angle &= 511
582
CallFunction(EggBubble_HandleBubbleMovement)
583
end if
584
break
585
586
case R4_EGG_BUBBLE_MOVE_TO_L
587
Object.XPos -= 0x10000
588
589
if Object.BubbleRadius < 0x3000
590
Object.BubbleRadius += 0x60
591
Object.Angle += 8
592
else
593
Object.Angle += 2
594
end if
595
596
TempValue0 = Helper.XPos
597
TempValue0 -= 0x600000
598
599
if Object.XPos < TempValue0
600
Object.XPos = TempValue0
601
Helper.Angle = 256
602
Object.State = R4_EGG_BUBBLE_TURN_TO_RIGHT
603
end if
604
605
Object.Angle &= 511
606
CallFunction(EggBubble_HandleBubbleMovement)
607
break
608
609
case R4_EGG_BUBBLE_EXPLODE
610
if Object.Timer < 70
611
TempValue0 = Object.Timer
612
TempValue0 &= 3
613
if TempValue0 == 0
614
Rand(TempValue0, 80)
615
TempValue0 -= 40
616
TempValue0 <<= 16
617
TempValue0 += Object.XPos
618
619
Rand(TempValue1, 56)
620
TempValue1 -= 28
621
TempValue1 <<= 16
622
TempValue1 += Object.YPos
623
624
CreateTempObject(TypeName[Explosion], 0, TempValue0, TempValue1)
625
PlaySfx(SFX_G_EXPLOSION, false)
626
end if
627
Object.Timer++
628
else
629
Object.State = R4_EGG_BUBBLE_DEFEAT
630
Object.Animation = EGGANI_DEFEAT
631
Object.Timer = 0
632
Object.Direction = FACING_LEFT
633
634
CallFunction(EggBubble_DestroyBubbles)
635
636
Player.Score += 1000
637
end if
638
break
639
640
case R4_EGG_BUBBLE_DEFEAT
641
if Object.Timer < 70
642
Object.Timer++
643
else
644
Object.Timer = 0
645
Object.Priority = PRIORITY_ACTIVE
646
647
Object.State = R4_EGG_BUBBLE_FLEE
648
Object.Animation = EGGANI_ESCAPE
649
Object.FrameTimer = 0
650
651
Stage.NewWaterLevel = 0x8000000 // Y - 2048 in map coords
652
CreateTempObject(TypeName[Fade Music], FADEMUSIC_TO_LEVEL, Object.XPos, Object.YPos)
653
end if
654
break
655
656
case R4_EGG_BUBBLE_FLEE
657
Object.XPos += 0x1C000
658
if Object.OutOfBounds == true
659
Object.State = R4_EGG_BUBBLE_RESTORE_BOUNDS
660
Object.Animation = EGGANI_NONE
661
end if
662
break
663
664
case R4_EGG_BUBBLE_RESTORE_BOUNDS
665
if Object.Timer < 60
666
Stage.XBoundary2 += 4
667
Object.Timer++
668
else
669
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
670
Stage.NewXBoundary2 = 3840
671
end if
672
break
673
674
end switch
675
end sub
676
677
678
sub ObjectPlayerInteraction
679
if Object.State > R4_EGG_BUBBLE_EXPAND_SHIELD
680
if Object.State < R4_EGG_BUBBLE_EXPLODE
681
#platform: Use_Standalone
682
PlayerObjectCollision(C_TOUCH, -24, -16, 24, 16)
683
#endplatform
684
#platform: Use_Origins
685
PlayerObjectCollision(C_ENEMY, -24, -16, 24, 16)
686
#endplatform
687
if CheckResult == true
688
CheckEqual(Player.Animation, ANI_JUMPING)
689
TempValue0 = CheckResult
690
CheckEqual(Player.Animation, ANI_SPINDASH)
691
TempValue0 |= CheckResult
692
#platform: Use_Origins
693
// making really sure you're the one character that can glide or the one character that has a hammer
694
if Stage.PlayerListPos == PLAYER_KNUCKLES
695
CheckEqual(Player.Animation, ANI_GLIDING)
696
TempValue0 |= CheckResult
697
CheckEqual(Player.Animation, ANI_GLIDING_STOP)
698
TempValue0 |= CheckResult
699
end if
700
if Stage.PlayerListPos == PLAYER_AMY
701
CheckEqual(Player.Animation, ANI_HAMMER_JUMP)
702
TempValue0 |= CheckResult
703
CheckEqual(Player.Animation, ANI_HAMMER_DASH)
704
TempValue0 |= CheckResult
705
end if
706
#endplatform
707
708
ArrayPos0 = Player.EntityNo
709
ArrayPos0 += 2
710
if Object[ArrayPos0].Type == TypeName[Invincibility]
711
TempValue0 = true
712
end if
713
714
if TempValue0 == true
715
716
#platform: Use_Origins
717
EngineCallback(NOTIFY_KILL_BOSS)
718
// Tell HE2 that the boss fight ended
719
game.callbackParam0 = true
720
EngineCallback(NOTIFY_BOSS_END)
721
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
722
StopMusic()
723
end if
724
#endplatform
725
FlipSign(Player.XVelocity)
726
FlipSign(Player.Speed)
727
Player.XVelocity >>= 1
728
Player.Speed >>= 1
729
730
Player.YVelocity = Player.YPos
731
Player.YVelocity -= Object.YPos
732
Player.YVelocity >>= 3
733
734
#platform: Use_Origins
735
if Stage.PlayerListPos == PLAYER_KNUCKLES
736
if Player.Animation == ANI_GLIDING
737
Player.Animation = ANI_GLIDING_DROP
738
Player.State = Player_State_GlideDrop
739
end if
740
end if
741
#endplatform
742
743
Object.State = R4_EGG_BUBBLE_EXPLODE
744
Object.Animation = EGGANI_HURT
745
Object.Timer = 0
746
else
747
if Player.InvincibleTimer == 0
748
Player.State = Player_State_GotHit
749
if Player.XPos > Object.XPos
750
Player.Speed = 0x20000
751
else
752
Player.Speed = -0x20000
753
end if
754
end if
755
Object.Animation = EGGANI_LAUGH
756
end if
757
end if
758
end if
759
end if
760
761
if Object.State < R4_EGG_BUBBLE_RESTORE_BOUNDS
762
TempValue0 = Player.CollisionRight
763
TempValue0 <<= 16
764
TempValue0 += Player.XPos
765
766
TempValue1 = Stage.XBoundary2
767
TempValue1 <<= 16
768
769
if TempValue0 > TempValue1
770
Player.XVelocity = 0
771
Player.Speed = 0
772
Player.XPos = TempValue1
773
774
TempValue0 = Player.CollisionRight
775
TempValue0 <<= 16
776
Player.XPos -= TempValue0
777
end if
778
end if
779
end sub
780
781
782
sub ObjectDraw
783
switch Object.Animation
784
case EGGANI_IDLE
785
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
786
DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)
787
break
788
789
case EGGANI_LAUGH
790
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
791
792
TempValue0 = Object.FrameTimer
793
TempValue0 &= 15
794
TempValue0 >>= 3
795
TempValue0 += 3
796
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
797
798
if Object.FrameTimer < 112
799
Object.FrameTimer++
800
else
801
Object.FrameTimer = 0
802
Object.Animation = 0
803
end if
804
break
805
806
case EGGANI_HURT
807
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
808
DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos)
809
break
810
811
case EGGANI_DEFEAT
812
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
813
DrawSpriteFX(6, FX_FLIP, Object.XPos, Object.YPos)
814
break
815
816
case EGGANI_ESCAPE
817
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
818
DrawSpriteFX(6, FX_FLIP, Object.XPos, Object.YPos)
819
820
TempValue0 = Object.FrameTimer
821
TempValue0 >>= 2
822
TempValue0 += 7
823
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
824
825
Object.FrameTimer++
826
Object.FrameTimer &= 15
827
break
828
end switch
829
end sub
830
831
832
sub ObjectStartup
833
LoadSpriteSheet("R4/Objects2.gif")
834
835
// Egg Mobile
836
SpriteFrame(-32, -28, 64, 56, 51, 58) // #0 - Egg Bubble2 Battle
837
SpriteFrame(-32, -28, 64, 56, 189, 58) // #1 - Egg Bubble2 Battle destroyed
838
839
// Eggman
840
SpriteFrame(-32, -28, 48, 16, 1, 67) // #2 - Eggman face
841
SpriteFrame(-32, -28, 48, 16, 1, 84) // #3 - Eggman laugh frame 0
842
SpriteFrame(-32, -28, 48, 16, 1, 101) // #4 - Eggman laugh frame 1
843
SpriteFrame(-32, -28, 48, 16, 1, 118) // #5 - Eggman hurt
844
SpriteFrame(-32, -28, 48, 16, 50, 118) // #6 - Eggman defeat
845
846
// Sweat
847
SpriteFrame(4, -44, 16, 16, 207, 35) // #7 - Sweat drop frame 0
848
SpriteFrame(4, -44, 1, 1, 207, 35) // #8 - Sweat drop frame 1
849
SpriteFrame(4, -44, 16, 16, 224, 35) // #9 - Sweat drop frame 2
850
SpriteFrame(4, -44, 1, 1, 207, 35) // #10 - Sweat drop frame 3
851
852
// Used to be below LoadSpriteSheet, moved here for consistency
853
ArrayPos0 = 32
854
while ArrayPos0 < 1056
855
if Object[ArrayPos0].Type == TypeName[Eggman Part 2]
856
TempValue0 = 160
857
TempValue0 -= Screen.CenterX
858
Object[ArrayPos0].iXPos += TempValue0
859
end if
860
ArrayPos0++
861
loop
862
end sub
863
864
865
// ========================
866
// Editor Subs
867
// ========================
868
869
sub RSDKDraw
870
DrawSprite(0)
871
DrawSprite(1)
872
end sub
873
874
875
sub RSDKLoad
876
LoadSpriteSheet("R4/Objects2.gif")
877
878
// Egg Mobile
879
SpriteFrame(-32, -28, 64, 56, 51, 58) // #0 - Egg Bubble2 Battle
880
// Eggman
881
SpriteFrame(-32, -28, 48, 16, 1, 67) // #2 - Eggman face
882
883
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
884
end sub
885
886