Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/HPZ/Eggman.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: B08 Eggman Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// Using HPZEggman/B08Eggman as a prefix here because there's like 12 "Eggman" objects in the game so its less confusing this way
9
// ("B08 Eggman" is the object's TypeName in the scene btw, it's not like every other zone where it's just "Eggman" or MBZ where it's the boss's respective zone initials)
10
11
// ========================
12
// Aliases
13
// ========================
14
15
private alias object.value0 : object.timer
16
private alias object.value1 : object.originPos.y
17
private alias object.value2 : object.oscillationAngle
18
private alias object.value3 : object.health
19
private alias object.value4 : object.invincibilityTimer
20
private alias object.value5 : object.exploding
21
private alias object.value6 : object.boundsM
22
private alias object.value7 : object.boundsL // unused
23
private alias object.value8 : object.boundsR // unused
24
private alias object.value9 : object.boundsT
25
private alias object.value10 : object.boundsB
26
private alias object.value11 : object.groundPos
27
// value12 is unused
28
private alias object.value13 : object.flameAnimation
29
private alias object.value14 : object.flameAnimTimer
30
// value15 is unused
31
private alias object.value16 : object.shakeTimer
32
private alias object.value17 : object.trumboneExtendPos
33
private alias object.value18 : object.trumboneExtendMax
34
private alias object.value19 : object.trumboneOffset.y
35
private alias object.value20 : object.showTrumbone
36
private alias object.value21 : object.trumboneExtendSpeed
37
private alias object.value22 : object.trumboneVelocity.y
38
private alias object.value23 : object.mineSlot
39
private alias object.value24 : object.waterLevel
40
private alias object.value25 : object.impactCount
41
42
// Eggman States
43
private alias 0 : HPZEGGMAN_AWAITPLAYER
44
private alias 1 : HPZEGGMAN_ENTERDELAY
45
private alias 2 : HPZEGGMAN_ENTEREGGMAN
46
private alias 3 : HPZEGGMAN_EXTENDTRUMBONE
47
private alias 4 : HPZEGGMAN_DROPSMALLBOMBS
48
private alias 5 : HPZEGGMAN_DROPPEDSMALLBOMBS
49
private alias 6 : HPZEGGMAN_RAISEBOMBS
50
private alias 7 : HPZEGGMAN_PLAYLOUDHORN
51
private alias 8 : HPZEGGMAN_DROPLARGEBOMB
52
private alias 9 : HPZEGGMAN_AWAITBOMBSEXPLODE
53
private alias 10 : HPZEGGMAN_GEYSERHIT
54
private alias 11 : HPZEGGMAN_GEYSERFALL
55
private alias 12 : HPZEGGMAN_GEYSERRISE
56
private alias 13 : HPZEGGMAN_EXPLODE
57
private alias 14 : HPZEGGMAN_DEFEATFALL
58
private alias 15 : HPZEGGMAN_DEFEATRISE
59
private alias 16 : HPZEGGMAN_FLEE
60
private alias 17 : HPZEGGMAN_ESCAPE
61
62
// Eggman Animations
63
private alias 0 : HPZEGGANI_INVISIBLE
64
private alias 1 : HPZEGGANI_IDLE
65
private alias 2 : HPZEGGANI_LAUGH
66
private alias 3 : HPZEGGANI_HIT
67
private alias 4 : HPZEGGANI_DEFEATED
68
private alias 5 : HPZEGGANI_TOASTED
69
private alias 6 : HPZEGGANI_PANIC
70
71
// Flame Animations
72
private alias 0 : FLAMEANI_INVISIBLE
73
private alias 1 : FLAMEANI_FALLING
74
private alias 2 : FLAMEANI_RISE
75
private alias 3 : FLAMEANI_MOVING
76
77
// EggmanHorn Aliases
78
private alias object.value0 : hpzEggmanHorn.timer
79
80
// EggmanHorn States
81
private alias 0 : HPZEGGMANHORN_IDLE
82
private alias 1 : HPZEGGMANHORN_PLAYINGNOISE
83
private alias 2 : HPZEGGMANHORN_FINISHEDNOISE
84
private alias 3 : HPZEGGMANHORN_DEBRIS
85
86
// EggmanValve States
87
private alias 0 : HPZEGGMANVALVE_RESETBOTH
88
private alias 1 : HPZEGGMANVALVE_USEL
89
private alias 2 : HPZEGGMANVALVE_USER
90
private alias 3 : HPZEGGMANVALVE_USEBOTH
91
private alias 4 : HPZEGGMANVALVE_DEBRIS
92
93
// EggmanMine States
94
private alias 0 : HPZEGGMANMINE_SETUP
95
private alias 1 : HPZEGGMANMINE_SMALL_FALL
96
private alias 2 : HPZEGGMANMINE_SMALL_RISE
97
private alias 3 : HPZEGGMANMINE_SMALL_FLOAT
98
private alias 4 : HPZEGGMANMINE_SMALL_EXPLODE
99
private alias 5 : HPZEGGMANMINE_BIG_FALL
100
private alias 6 : HPZEGGMANMINE_BIG_FOLLOW
101
private alias 7 : HPZEGGMANMINE_BIG_EXPLODE
102
private alias 8 : HPZEGGMANMINE_BIG_EXPLODED
103
104
// BreakGem Aliases
105
private alias object.value1 : breakGem.gravityStrength
106
107
// BreakGem States
108
private alias 1 : BREAKGEM_SHARD
109
110
// Music Events
111
private alias 26 : SLOT_MUSICEVENT_BOSS
112
113
private alias 0 : MUSICEVENT_FADETOBOSS
114
private alias 1 : MUSICEVENT_FADETOSTAGE
115
116
// Player Aliases
117
private alias object.xpos : player.xpos
118
private alias object.ypos : player.ypos
119
private alias object.xvel : player.xvel
120
private alias object.yvel : player.yvel
121
private alias object.speed : player.speed
122
private alias object.animation : player.animation
123
private alias object.collisionRight : player.collisionRight
124
125
private alias object.value40 : player.hitboxLeft
126
private alias object.value38 : player.hitboxTop
127
private alias object.value41 : player.hitboxRight
128
private alias object.value39 : player.hitboxBottom
129
130
131
// ========================
132
// Function Declarations
133
// ========================
134
135
reserve function B08Eggman_Oscillate
136
reserve function B08Eggman_HandleChildren
137
reserve function B08Eggman_HandleMovement
138
139
140
// ========================
141
// Tables
142
// ========================
143
144
private table B08Eggman_flameFrames_Falling
145
7, 7, 8, 8
146
end table
147
148
private table B08Eggman_flameFrames_Rise
149
9, 9, 10, 10
150
end table
151
152
private table B08Eggman_flameFrames_Moving
153
11, 11, 12, 12
154
end table
155
156
157
// ========================
158
// Function Definitions
159
// ========================
160
161
private function B08Eggman_Oscillate
162
Sin256(object.ypos, object.oscillationAngle)
163
object.ypos <<= 10
164
object.ypos += object.originPos.y
165
object.oscillationAngle += 2
166
object.oscillationAngle &= 0xFF
167
end function
168
169
170
private function B08Eggman_HandleChildren
171
// Horn
172
object[+1].xpos = object.xpos
173
object[+1].ypos = object.ypos
174
object[+1].direction = object.direction
175
176
// Valve
177
object[+2].xpos = object.xpos
178
object[+2].ypos = object.ypos
179
object[+2].direction = object.direction
180
end function
181
182
183
private function B08Eggman_HandleMovement
184
checkResult = false
185
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
186
if player[currentPlayer].yvel < 0
187
checkResult |= true
188
end if
189
next
190
191
if checkResult == true
192
object.originPos.y -= 0xC000
193
if object.originPos.y < object.boundsB
194
object.originPos.y = object.boundsB
195
end if
196
object.flameAnimation = FLAMEANI_MOVING
197
else
198
object.originPos.y += 0x8000
199
if object.originPos.y > object.boundsT
200
object.originPos.y = object.boundsT
201
end if
202
object.flameAnimation = FLAMEANI_FALLING
203
end if
204
205
temp0 = player[0].xpos
206
temp0 -= 0x80000
207
temp1 = player[0].xpos
208
temp1 += 0x80000
209
if object.xpos < temp0
210
object.xpos += 0x10000
211
object.direction = FLIP_X
212
end if
213
214
if object.xpos > temp1
215
object.xpos -= 0x10000
216
object.direction = FLIP_NONE
217
end if
218
end function
219
220
221
// ========================
222
// Events
223
// ========================
224
225
event ObjectUpdate
226
switch object.state
227
case HPZEGGMAN_AWAITPLAYER
228
if player[0].xpos > object[+1].xpos
229
temp0 = object[+1].ixpos
230
temp0 -= screen.xcenter
231
stage.newXBoundary1 = temp0
232
233
temp0 = object[+1].ixpos
234
temp0 += screen.xcenter
235
stage.newXBoundary2 = temp0
236
237
temp0 = stage.newYBoundary2
238
temp0 -= screen.ysize
239
stage.newYBoundary1 = temp0
240
241
object.boundsM = object[+1].xpos
242
object.boundsL = -112
243
object.boundsL *= screen.xsize
244
object.boundsL /= 320
245
object.boundsL <<= 16
246
object.boundsR = object.boundsL
247
FlipSign(object.boundsR)
248
249
object.boundsL += object[-1].xpos
250
object.boundsR += object[-1].xpos
251
object.boundsT = object[+1].ypos
252
object.boundsB = object.boundsT
253
object.boundsB -= 0x200000
254
object.groundPos = object[+2].ypos
255
256
object.xpos = 72
257
object.xpos *= screen.xsize
258
object.xpos /= 320
259
object.xpos <<= 16
260
object.xpos += object[+1].xpos
261
object.ypos = object.boundsT
262
object.ypos += 0xF00000
263
264
object.animation = HPZEGGANI_IDLE
265
ResetObjectEntity(SLOT_MUSICEVENT_BOSS, TypeName[Music Event], MUSICEVENT_FADETOBOSS, 0, 0)
266
object[SLOT_MUSICEVENT_BOSS].priority = PRIORITY_ACTIVE
267
268
object[+1].type = TypeName[Eggman Horn]
269
object[+2].type = TypeName[Eggman Valve]
270
CallFunction(B08Eggman_HandleChildren)
271
object.trumboneExtendPos = -0x280000
272
object.showTrumbone = true
273
object.flameAnimation = FLAMEANI_RISE
274
HPZSetup_bossFightActive = true
275
object.waterLevel = object[-1].iypos
276
stage.waterLevel = object.waterLevel
277
stage.waterLevel += 192
278
object.priority = PRIORITY_ACTIVE
279
object.state = HPZEGGMAN_ENTERDELAY
280
end if
281
break
282
283
case HPZEGGMAN_ENTERDELAY
284
object.timer++
285
if object.timer == 60
286
object.timer = 0
287
object.yvel = 0
288
object.state = HPZEGGMAN_ENTEREGGMAN
289
end if
290
break
291
292
case HPZEGGMAN_ENTEREGGMAN
293
object.yvel -= 0x1800
294
if object.yvel < -0x20000
295
object.yvel = -0x20000
296
end if
297
298
object.ypos += object.yvel
299
if stage.waterLevel > object.waterLevel
300
stage.waterLevel -= 2
301
end if
302
303
if object.ypos <= object.boundsT
304
object.ypos = object.boundsT
305
object.originPos.y = object.ypos
306
307
#platform: USE_STANDALONE
308
object.health = 8
309
#endplatform
310
#platform: USE_ORIGINS
311
if game.bossOneLife == false
312
object.health = 8
313
else
314
object.health = 1
315
end if
316
#endplatform
317
318
object.state = HPZEGGMAN_EXTENDTRUMBONE
319
end if
320
321
CallFunction(B08Eggman_HandleChildren)
322
break
323
324
case HPZEGGMAN_EXTENDTRUMBONE
325
object.timer++
326
if object.trumboneExtendPos < -0x280000
327
object.trumboneExtendPos += 0x20000
328
end if
329
330
if object.timer == 240
331
object.timer = 0
332
object.mineSlot = object.entityPos
333
object.mineSlot -= 4
334
object.trumboneExtendMax = -0x280000
335
object.state = 4
336
end if
337
338
CallFunction(B08Eggman_HandleMovement)
339
CallFunction(B08Eggman_Oscillate)
340
CallFunction(B08Eggman_HandleChildren)
341
break
342
343
case HPZEGGMAN_DROPSMALLBOMBS
344
temp0 = object.timer
345
temp0 %= 60
346
if temp0 == 0
347
object[+1].state = HPZEGGMANHORN_PLAYINGNOISE
348
hpzEggmanHorn[+1].timer = 30
349
object[+2].state++
350
if object[+2].state == HPZEGGMANVALVE_USEBOTH
351
object[+2].state = HPZEGGMANVALVE_USEL
352
end if
353
354
temp1 = object.timer
355
temp1 /= 60
356
switch temp1
357
case 0
358
PlaySfx(SfxName[Horn 1], false)
359
break
360
361
case 1
362
PlaySfx(SfxName[Horn 2], false)
363
break
364
365
case 2
366
PlaySfx(SfxName[Horn 3], false)
367
break
368
369
case 3
370
PlaySfx(SfxName[Horn 4], false)
371
break
372
end switch
373
end if
374
375
if hpzEggmanHorn[+1].timer == 1
376
temp1 = screen.xsize
377
temp1 *= 224
378
temp1 >>= 8
379
Rand(temp0, temp1)
380
temp0 >>= 6
381
temp0 <<= 6
382
temp1 >>= 1
383
temp0 -= temp1
384
temp0 <<= 16
385
temp0 += object.boundsM
386
foreach (TypeName[Eggman Mine], arrayPos0, ACTIVE_ENTITIES)
387
temp1 = object[arrayPos0].xpos
388
temp1 -= temp0
389
Abs(temp1)
390
if temp1 <= 0x180000
391
if temp0 < object.boundsM
392
temp0 += 0x200000
393
else
394
temp0 -= 0x200000
395
end if
396
end if
397
next
398
399
arrayPos0 = object.mineSlot
400
ResetObjectEntity(object.mineSlot, TypeName[Eggman Mine], 0, temp0, object.boundsB)
401
object[arrayPos0].ypos -= 0x400000
402
object.mineSlot++
403
object.trumboneExtendMax -= 0xA0000
404
end if
405
406
if hpzEggmanHorn[+1].timer == 0
407
if object.trumboneExtendPos > object.trumboneExtendMax
408
object.trumboneExtendPos -= 0x10000
409
end if
410
end if
411
412
object.timer++
413
if object.timer == 240
414
object.timer = 0
415
object.state = HPZEGGMAN_DROPPEDSMALLBOMBS
416
object[+2].state = HPZEGGMANVALVE_RESETBOTH
417
end if
418
419
CallFunction(B08Eggman_HandleMovement)
420
CallFunction(B08Eggman_Oscillate)
421
CallFunction(B08Eggman_HandleChildren)
422
break
423
424
case HPZEGGMAN_DROPPEDSMALLBOMBS
425
object.timer++
426
if object.timer == 160
427
object.timer = 0
428
object.angle = 256
429
object[+1].state = HPZEGGMANHORN_FINISHEDNOISE
430
hpzEggmanHorn[+1].timer = 128
431
object.state = HPZEGGMAN_RAISEBOMBS
432
PlaySfx(SfxName[Horn Sweep], false)
433
end if
434
435
CallFunction(B08Eggman_HandleMovement)
436
CallFunction(B08Eggman_Oscillate)
437
CallFunction(B08Eggman_HandleChildren)
438
break
439
440
case HPZEGGMAN_RAISEBOMBS
441
object.angle += 4
442
Cos(stage.waterLevel, object.angle)
443
stage.waterLevel >>= 4
444
FlipSign(stage.waterLevel)
445
stage.waterLevel -= 32
446
temp0 = stage.waterLevel
447
temp0 *= 3
448
temp0 /= 6
449
object.trumboneExtendPos = -80
450
object.trumboneExtendPos -= temp0
451
object.trumboneExtendPos <<= 16
452
stage.waterLevel += object.waterLevel
453
if object.angle == 0x300
454
object[-1].state = HPZEGGMANMINE_SMALL_EXPLODE
455
object[-2].state = HPZEGGMANMINE_SMALL_EXPLODE
456
object[-3].state = HPZEGGMANMINE_SMALL_EXPLODE
457
object[-4].state = HPZEGGMANMINE_SMALL_EXPLODE
458
object[+2].state = HPZEGGMANVALVE_RESETBOTH
459
object.state = HPZEGGMAN_PLAYLOUDHORN
460
end if
461
462
CallFunction(B08Eggman_HandleMovement)
463
CallFunction(B08Eggman_Oscillate)
464
CallFunction(B08Eggman_HandleChildren)
465
break
466
467
case HPZEGGMAN_PLAYLOUDHORN
468
object.timer++
469
if object.trumboneExtendPos < -0x280000
470
object.trumboneExtendPos += 0x20000
471
end if
472
473
if object.timer == 240
474
object.timer = 0
475
object[+1].state = HPZEGGMANHORN_PLAYINGNOISE
476
hpzEggmanHorn[+1].timer = 240
477
object[+2].state = HPZEGGMANVALVE_USEBOTH
478
object.state = HPZEGGMAN_DROPLARGEBOMB
479
PlaySfx(SfxName[Loud Horn], false)
480
end if
481
482
CallFunction(B08Eggman_HandleMovement)
483
CallFunction(B08Eggman_Oscillate)
484
CallFunction(B08Eggman_HandleChildren)
485
break
486
487
case HPZEGGMAN_DROPLARGEBOMB
488
if object.trumboneExtendPos > -0x500000
489
object.trumboneExtendPos -= 0x40000
490
end if
491
492
if hpzEggmanHorn[+1].timer == 0
493
object.state = HPZEGGMAN_AWAITBOMBSEXPLODE
494
object[+2].state = HPZEGGMANVALVE_RESETBOTH
495
arrayPos0 = object.entityPos
496
arrayPos0--
497
ResetObjectEntity(arrayPos0, TypeName[Eggman Mine], 2, player[0].xpos, object.boundsB)
498
object[arrayPos0].ypos -= 0x400000
499
end if
500
501
temp0 = oscillation
502
temp0 &= 7
503
if temp0 == 0
504
temp0 = oscillation
505
temp0 &= 15
506
if temp0 == 0
507
temp0 = 10
508
else
509
temp0 = 11
510
end if
511
512
Rand(temp1, screen.xsize)
513
temp1 -= screen.xcenter
514
temp1 <<= 16
515
temp1 += object.boundsM
516
temp2 = object.boundsT
517
temp2 -= 0x500000
518
CreateTempObject(TypeName[Break Gem], temp0, temp1, temp2)
519
breakGem[tempObjectPos].gravityStrength = 0x2800
520
object[tempObjectPos].state = BREAKGEM_SHARD
521
end if
522
523
CallFunction(B08Eggman_HandleMovement)
524
CallFunction(B08Eggman_Oscillate)
525
CallFunction(B08Eggman_HandleChildren)
526
break
527
528
case HPZEGGMAN_AWAITBOMBSEXPLODE
529
if object[-1].type == TypeName[Blank Object]
530
if object[-2].type == TypeName[Blank Object]
531
object.state = HPZEGGMAN_EXTENDTRUMBONE
532
end if
533
end if
534
535
CallFunction(B08Eggman_HandleMovement)
536
CallFunction(B08Eggman_Oscillate)
537
CallFunction(B08Eggman_HandleChildren)
538
break
539
540
case HPZEGGMAN_GEYSERHIT
541
// is this supposed to be set...?
542
// update: is this set from water geyser????
543
// why does this use arrayPos0 here lol
544
object[arrayPos0].flameAnimation = 0
545
switch object.shakeTimer
546
case 0
547
object.xpos += 0x20000
548
break
549
550
case 2
551
object.xpos -= 0x20000
552
break
553
554
end switch
555
556
object.animation = HPZEGGANI_HIT
557
object.shakeTimer++
558
object.shakeTimer &= 3
559
CallFunction(B08Eggman_HandleChildren)
560
break
561
562
case HPZEGGMAN_GEYSERFALL
563
object.ypos += object.yvel
564
object.yvel += 0x1800
565
566
if object.impactCount < 3
567
if object.ypos > object.groundPos
568
object.ypos = object.groundPos
569
object.yvel >>= 1
570
FlipSign(object.yvel)
571
object.impactCount++
572
PlaySfx(SfxName[Ground Impact], false)
573
end if
574
else
575
if object.yvel > 0
576
object.impactCount = 0
577
object.flameAnimation = FLAMEANI_FALLING
578
object.state = HPZEGGMAN_GEYSERRISE
579
end if
580
end if
581
582
CallFunction(B08Eggman_HandleChildren)
583
break
584
585
case HPZEGGMAN_GEYSERRISE
586
object.yvel -= 0x1800
587
if object.yvel < -0x20000
588
object.yvel = -0x20000
589
object.flameAnimation = FLAMEANI_RISE
590
end if
591
592
object.ypos += object.yvel
593
if object.ypos <= object.boundsT
594
object.ypos = object.boundsT
595
object.originPos.y = object.ypos
596
object.oscillationAngle = 0
597
object.state = HPZEGGMAN_EXTENDTRUMBONE
598
end if
599
600
CallFunction(B08Eggman_HandleChildren)
601
break
602
603
case HPZEGGMAN_EXPLODE
604
object.timer++
605
if object.timer == 30
606
object.trumboneExtendSpeed = -0x20000
607
object.trumboneVelocity.y = 0
608
end if
609
610
if object.showTrumbone == true
611
object.trumboneExtendPos += object.trumboneExtendSpeed
612
if object.trumboneExtendPos < -0x500000
613
object.trumboneVelocity.y += 0x3800
614
object.trumboneOffset.y += object.trumboneVelocity.y
615
end if
616
end if
617
618
if object.timer == 60
619
if object.direction == FLIP_NONE
620
object[+1].xvel = -0x10000
621
else
622
object[+1].xvel = 0x10000
623
end if
624
object[+1].yvel = -0x20000
625
object[+1].state = HPZEGGMANHORN_DEBRIS
626
end if
627
628
if object.timer == 120
629
object.showTrumbone = false
630
if object.direction == FLIP_NONE
631
object[+2].xvel = 0x10000
632
else
633
object[+2].xvel = -0x10000
634
end if
635
object[+2].yvel = -0x20000
636
object[+2].state = HPZEGGMANVALVE_DEBRIS
637
end if
638
639
if object.timer == 180
640
object.timer = 0
641
object.animation = HPZEGGANI_TOASTED
642
object.exploding = false
643
object.yvel = 0
644
object.flameAnimation = FLAMEANI_INVISIBLE
645
HPZSetup_bossFightActive = false
646
object.state = HPZEGGMAN_DEFEATFALL
647
ResetObjectEntity(SLOT_MUSICEVENT_BOSS, TypeName[Music Event], MUSICEVENT_FADETOSTAGE, 0, 0)
648
object[SLOT_MUSICEVENT_BOSS].priority = PRIORITY_ACTIVE
649
650
// this should prolly be an animal prison or signpost?
651
// in the layout its just a ring
652
// a little speculation here - if it was a signpost this state'd be SIGNPOST_IDLE_VS which is kinda weird, but it'd be SIGNPOST_EXITSTAGERIGHT with the S1 ver of the obj
653
// if it was an animal prison though, it'd be ANIMALPRISON_HANDLEACTCLEAR in both games, nothing too strange
654
object[+3].priority = PRIORITY_ACTIVE
655
object[+3].state = 3
656
657
temp0 = tileLayer[0].xsize
658
temp0 <<= 7
659
stage.newXBoundary2 = temp0
660
end if
661
break
662
663
case HPZEGGMAN_DEFEATFALL
664
object.ypos += object.yvel
665
object.yvel += 0x1800
666
667
object.timer++
668
if object.timer == 16
669
object.yvel = 0
670
object.timer = 0
671
object.animationTimer = 0
672
object.flameAnimation = FLAMEANI_FALLING
673
object.state++
674
end if
675
break
676
677
case HPZEGGMAN_DEFEATRISE
678
if object.timer < 24
679
object.ypos += object.yvel
680
object.yvel -= 0x800
681
object.timer++
682
else
683
object.timer = 0
684
object.yvel = 0
685
object.originPos.y = object.ypos
686
object.state++
687
end if
688
break
689
690
case HPZEGGMAN_FLEE
691
CallFunction(B08Eggman_Oscillate)
692
if object.timer < 8
693
object.timer++
694
else
695
object.timer = 0
696
object.animation = HPZEGGANI_PANIC
697
object.flameAnimation = FLAMEANI_RISE
698
object.animationTimer = 0
699
object.direction = FLIP_X
700
object.priority = PRIORITY_ACTIVE
701
702
#platform: USE_STANDALONE
703
// Stage bounds are already restored in HPZEGGMAN_EXPLODE, Origins removed the unnecesary duplicate code
704
temp0 = tileLayer[0].xsize
705
temp0 <<= 7
706
stage.newXBoundary2 = temp0
707
#endplatform
708
709
object.state++
710
end if
711
break
712
713
case HPZEGGMAN_ESCAPE
714
object.xpos += 0x40000
715
object.originPos.y -= 0x4000
716
CallFunction(B08Eggman_Oscillate)
717
if object.outOfBounds == true
718
ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, 0, 0)
719
end if
720
break
721
722
end switch
723
724
if object.health != 0
725
if object.invincibilityTimer > 0
726
object.invincibilityTimer--
727
GetBit(temp0, object.invincibilityTimer, 0)
728
if temp0 == true
729
SetPaletteEntry(0, 192, 0xE0E0E0)
730
else
731
SetPaletteEntry(0, 192, 0x000000)
732
end if
733
end if
734
735
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
736
if object.invincibilityTimer < 32
737
CheckEqual(player[currentPlayer].animation, ANI_HURT)
738
temp0 = checkResult
739
CheckEqual(player[currentPlayer].animation, ANI_DYING)
740
temp0 |= checkResult
741
CheckEqual(player[currentPlayer].animation, ANI_DROWNING)
742
temp0 |= checkResult
743
if temp0 != false
744
if object.animation != HPZEGGANI_LAUGH
745
object.animation = HPZEGGANI_LAUGH
746
object.animationTimer = 0
747
end if
748
end if
749
750
BoxCollisionTest(C_TOUCH, object.entityPos, -24, -24, 24, 20, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
751
if checkResult == true
752
CallFunction(Player_CheckHit)
753
if checkResult == true
754
object.health--
755
if object.health == 0
756
#platform: USE_ORIGINS
757
CallNativeFunction2(NotifyCallback, NOTIFY_KILL_BOSS, 0)
758
CallNativeFunction2(NotifyCallback, NOTIFY_BOSS_END, 1)
759
#endplatform
760
player.score += 1000
761
object.timer = 0
762
object.animation = HPZEGGANI_DEFEATED
763
object.flameAnimation = FLAMEANI_FALLING
764
object.animationTimer = 0
765
object.exploding = true
766
object.originPos.y = object.ypos
767
object.state = HPZEGGMAN_EXPLODE
768
SetPaletteEntry(0, 192, 0x000000)
769
else
770
object.animation = HPZEGGANI_HIT
771
object.animationTimer = 0
772
object.invincibilityTimer = 64
773
PlaySfx(SfxName[Boss Hit], false)
774
end if
775
end if
776
end if
777
778
if object.flameAnimation == FLAMEANI_MOVING
779
BoxCollisionTest(C_TOUCH, object.entityPos, -8, 0, 8, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
780
if checkResult == true
781
CallFunction(Player_Hit)
782
end if
783
end if
784
end if
785
next
786
end if
787
788
if object.state != HPZEGGMAN_ESCAPE
789
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
790
temp0 = player[currentPlayer].collisionRight
791
temp0 <<= 16
792
temp0 += player[currentPlayer].xpos
793
temp1 = stage.curXBoundary2
794
temp1 <<= 16
795
if temp0 > temp1
796
player[currentPlayer].xvel = 0
797
player[currentPlayer].speed = 0
798
player[currentPlayer].xpos = temp1
799
temp0 = player[currentPlayer].collisionRight
800
temp0 <<= 16
801
player[currentPlayer].xpos -= temp0
802
end if
803
next
804
end if
805
806
if object.exploding == true
807
temp0 = oscillation
808
temp0 &= 7
809
if temp0 == 0
810
Rand(temp0, 48)
811
temp0 -= 24
812
temp0 <<= 16
813
temp0 += object.xpos
814
Rand(temp1, 48)
815
temp1 -= 24
816
temp1 <<= 16
817
temp1 += object.ypos
818
CreateTempObject(TypeName[Explosion], 0, temp0, temp1)
819
object[tempObjectPos].drawOrder = 5
820
PlaySfx(SfxName[Explosion], false)
821
end if
822
end if
823
end event
824
825
826
event ObjectDraw
827
temp2 = object.trumboneExtendPos
828
FlipSign(temp2)
829
temp2 >>= 16
830
if temp2 < 0
831
temp2 = 0
832
end if
833
if temp2 > 80
834
temp2 = 80
835
end if
836
837
temp3 = object.trumboneExtendPos
838
temp3 >>= 16
839
temp3 -= 16
840
temp4 = object.trumboneOffset.y
841
temp4 += object.ypos
842
843
if object.showTrumbone == true
844
EditFrame(13, temp3, 0, temp2, 6, 265, 235)
845
DrawSpriteFX(13, FX_FLIP, object.xpos, temp4)
846
end if
847
848
DrawSpriteFX(6, FX_FLIP, object.xpos, object.ypos)
849
850
switch object.animation
851
default
852
case HPZEGGANI_INVISIBLE
853
break
854
855
case HPZEGGANI_IDLE
856
temp0 = object.animationTimer
857
temp0 >>= 3
858
object.animationTimer++
859
object.animationTimer &= 15
860
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
861
break
862
863
case HPZEGGANI_LAUGH
864
temp0 = object.animationTimer
865
temp0 &= 15
866
temp0 >>= 3
867
temp0 += 2
868
object.animationTimer++
869
if object.animationTimer == 50
870
object.animationTimer = 0
871
if player[0].animation != ANI_DYING
872
object.animation = HPZEGGANI_IDLE
873
end if
874
end if
875
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
876
break
877
878
case HPZEGGANI_HIT
879
temp0 = object.animationTimer // huh? temp0 isn't used here at all, what's this for?
880
temp0 &= 1
881
temp0 += 2 // ..2? that's the frame offset for the laughing animation though..
882
object.animationTimer++
883
if object.animationTimer == 50
884
object.animationTimer = 0
885
object.animation = HPZEGGANI_IDLE
886
end if
887
DrawSpriteFX(4, FX_FLIP, object.xpos, object.ypos)
888
break
889
890
case HPZEGGANI_DEFEATED
891
temp0 = object.animationTimer
892
temp0 >>= 5
893
temp0 += 4
894
temp0 %= 5
895
object.animationTimer++
896
object.animationTimer &= 63
897
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
898
break
899
900
case HPZEGGANI_TOASTED
901
DrawSpriteFX(5, FX_FLIP, object.xpos, object.ypos)
902
break
903
904
case HPZEGGANI_PANIC
905
temp0 = object.animationTimer
906
temp0 >>= 3
907
object.animationTimer++
908
object.animationTimer &= 15
909
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
910
temp0 = object.animationTimer
911
temp0 >>= 2
912
temp0 &= 1
913
if temp0 == 1
914
DrawSpriteFX(15, FX_FLIP, object.xpos, object.ypos)
915
end if
916
break
917
918
end switch
919
920
if object.showTrumbone == true
921
EditFrame(14, temp3, 6, temp2, 6, 265, 241)
922
DrawSpriteFX(14, FX_FLIP, object.xpos, temp4)
923
end if
924
925
switch object.flameAnimation
926
default
927
case FLAMEANI_INVISIBLE
928
break
929
930
case FLAMEANI_FALLING
931
GetTableValue(temp0, object.flameAnimTimer, B08Eggman_flameFrames_Falling)
932
object.flameAnimTimer++
933
object.flameAnimTimer &= 3
934
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
935
break
936
937
case FLAMEANI_RISE
938
GetTableValue(temp0, object.flameAnimTimer, B08Eggman_flameFrames_Rise)
939
object.flameAnimTimer++
940
object.flameAnimTimer &= 3
941
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
942
break
943
944
case FLAMEANI_MOVING
945
GetTableValue(temp0, object.flameAnimTimer, B08Eggman_flameFrames_Moving)
946
object.flameAnimTimer++
947
object.flameAnimTimer &= 3
948
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
949
break
950
951
end switch
952
end event
953
954
955
event ObjectStartup
956
LoadSpriteSheet("HPZ/Objects.gif")
957
SpriteFrame(-28, -28, 60, 20, 265, 139) // eggman idle 1 - #0
958
SpriteFrame(-28, -28, 60, 20, 326, 139) // eggman idle 2 - #1
959
SpriteFrame(-28, -28, 60, 20, 265, 160) // eggman laugh 1 - #2
960
SpriteFrame(-28, -28, 60, 20, 326, 160) // eggman laugh 2 - #3
961
SpriteFrame(-28, -28, 60, 20, 265, 181) // eggman hit - #4
962
SpriteFrame(-28, -28, 60, 20, 326, 181) // eggman destroyed - #5
963
SpriteFrame(-32, -8, 64, 32, 265, 202) // eggmobile - #6
964
SpriteFrame(-4, 24, 16, 8, 432, 178) // flame 1 - #7
965
SpriteFrame(-4, 24, 16, 12, 415, 170) // flame 2 - #8
966
SpriteFrame(-4, 24, 16, 8, 432, 178) // flame 3 - #9
967
SpriteFrame(-4, 24, 16, 24, 432, 153) // flame 4 - #10
968
SpriteFrame(-4, 24, 16, 12, 415, 157) // flame 5 - #11
969
SpriteFrame(-4, 24, 16, 24, 398, 157) // flame 6 - #12
970
SpriteFrame(-96, 0, 80, 6, 265, 235) // trumbone (top) - #13
971
SpriteFrame(-96, 6, 80, 6, 265, 241) // trumbone (bottom) - #14
972
SpriteFrame(3, -28, 11, 8, 437, 187) // panic sweat - #15
973
end event
974
975
976
// ========================
977
// Editor Events
978
// ========================
979
980
event RSDKDraw
981
DrawSprite(6)
982
DrawSprite(0)
983
end event
984
985
986
event RSDKLoad
987
LoadSpriteSheet("HPZ/Objects.gif")
988
SpriteFrame(-28, -28, 60, 20, 265, 139)
989
SpriteFrame(-28, -28, 60, 20, 326, 139)
990
SpriteFrame(-28, -28, 60, 20, 265, 160)
991
SpriteFrame(-28, -28, 60, 20, 326, 160)
992
SpriteFrame(-28, -28, 60, 20, 265, 181)
993
SpriteFrame(-28, -28, 60, 20, 326, 181)
994
SpriteFrame(-32, -8, 64, 32, 265, 202)
995
SpriteFrame(-4, 24, 16, 8, 432, 178)
996
SpriteFrame(-4, 24, 16, 12, 415, 170)
997
SpriteFrame(-4, 24, 16, 8, 432, 178)
998
SpriteFrame(-4, 24, 16, 24, 432, 153)
999
SpriteFrame(-4, 24, 16, 12, 415, 157)
1000
SpriteFrame(-4, 24, 16, 24, 398, 157)
1001
SpriteFrame(-96, 0, 80, 6, 265, 235)
1002
SpriteFrame(-96, 6, 80, 6, 265, 241)
1003
SpriteFrame(3, -28, 11, 8, 437, 187)
1004
1005
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
1006
end event
1007
1008