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/ARZ/Eggman.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Eggman Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// Using ARZEggman as a prefix here because there's like 12 "Eggman" objects in the game so its less confusing this way
9
10
// ========================
11
// Aliases
12
// ========================
13
14
private alias object.value0 : object.originPos.x
15
private alias object.value1 : object.originPos.y
16
private alias object.value2 : object.oscillationAngle
17
private alias object.value4 : object.timer
18
private alias object.value5 : object.unused1 // Technically, it *is* used... but it's never used anywhere important
19
private alias object.value6 : object.unused2 // Technically, it *is* used... but it's never used anywhere important
20
private alias object.value7 : object.health
21
private alias object.value8 : object.invincibilityTimer
22
private alias object.value9 : object.exploding
23
24
// Eggman States
25
private alias 0 : ARZEGGMAN_AWAITPLAYER
26
private alias 1 : ARZEGGMAN_BOSSFIGHT
27
private alias 2 : ARZEGGMAN_EXPLODE
28
private alias 3 : ARZEGGMAN_DEFEATFALL
29
private alias 4 : ARZEGGMAN_DEFEATRISE
30
private alias 5 : ARZEGGMAN_FLEE
31
private alias 6 : ARZEGGMAN_ESCAPE
32
33
// Eggman Animations
34
private alias 0 : ARZEGGANI_INVISIBLE
35
private alias 1 : ARZEGGANI_IDLE
36
private alias 2 : ARZEGGANI_LAUGH
37
private alias 3 : ARZEGGANI_HIT
38
private alias 4 : ARZEGGANI_DEFEATED
39
private alias 5 : ARZEGGANI_TOASTED
40
private alias 6 : ARZEGGANI_PANIC
41
42
// EggmanHammer Aliases
43
private alias object.value0 : eggmanHammer.originPos.x
44
private alias object.value1 : eggmanHammer.originPos.y
45
private alias object.value2 : eggmanHammer.oscillationAngle
46
private alias object.value3 : eggmanHammer.timer
47
private alias object.value4 : eggmanHammer.boundsR
48
private alias object.value5 : eggmanHammer.boundsL
49
private alias object.value7 : eggmanHammer.boundsOffset
50
private alias object.value8 : eggmanHammer.hideFlames
51
private alias object.value12 : eggmanHammer.arrowVelocity
52
53
// EggmanHammer States
54
private alias 4 : EGGMANHAMMER_DESTROYED
55
private alias 5 : EGGMANHAMMER_DEBRIS
56
57
// EggmanTotemPole Aliases
58
private alias object.value3 : eggmanTotemPole.timer
59
60
// EggmanTotemPole States
61
private alias 3 : EGGMANTOTEMPOLE_LOWERING
62
63
// EggmanArrow States
64
private alias 2 : EGGMANARROW_FALLING
65
66
// Player Aliases
67
private alias object.xpos : player.xpos
68
private alias object.xvel : player.xvel
69
private alias object.speed : player.speed
70
private alias object.animation : player.animation
71
private alias object.collisionRight : player.collisionRight
72
73
private alias object.value40 : player.hitboxLeft
74
private alias object.value38 : player.hitboxTop
75
private alias object.value41 : player.hitboxRight
76
private alias object.value39 : player.hitboxBottom
77
78
// Music Events
79
private alias 26 : SLOT_MUSICEVENT_BOSS
80
81
private alias 0 : MUSICEVENT_FADETOBOSS
82
private alias 1 : MUSICEVENT_FADETOSTAGE
83
84
85
// ========================
86
// Function Declarations
87
// ========================
88
89
reserve function ARZEggman_Oscillate
90
91
92
// ========================
93
// Tables
94
// ========================
95
96
// No flames so this isn't used at all
97
// It's the same table as the one in [CPZ Eggman], likely just here because the entire CPZ script was used as a base
98
private table ARZEggman_flameAnimFrameTable
99
7, 8, 8, 7, 7, 16
100
end table
101
102
103
// ========================
104
// Function Definitions
105
// ========================
106
107
private function ARZEggman_Oscillate
108
object.ypos = object.originPos.y
109
Sin256(temp0, object.oscillationAngle)
110
temp0 <<= 10
111
object.ypos += temp0
112
object.oscillationAngle += 2
113
object.oscillationAngle &= 255
114
115
object[+1].xpos = object.xpos
116
object[+1].ypos = object.ypos
117
object[+1].direction = object.direction
118
end function
119
120
121
// ========================
122
// Events
123
// ========================
124
125
event ObjectUpdate
126
switch object.state
127
case ARZEGGMAN_AWAITPLAYER
128
temp0 = object.ixpos
129
temp0 -= screen.xcenter
130
stage.newXBoundary1 = temp0
131
132
temp0 = object.ixpos
133
temp0 += screen.xcenter
134
stage.newXBoundary2 = temp0
135
136
if player[0].xpos > object.xpos
137
object.animation = ARZEGGANI_IDLE
138
ResetObjectEntity(SLOT_MUSICEVENT_BOSS, TypeName[Music Event], MUSICEVENT_FADETOBOSS, 0, 0)
139
object[SLOT_MUSICEVENT_BOSS].priority = PRIORITY_ACTIVE
140
141
object[+1].type = TypeName[Eggman Hammer]
142
eggmanHammer[+1].timer = 168
143
144
object.ypos -= 0xF80000
145
object.originPos.y = object.ypos
146
147
object[+1].xpos = object.xpos
148
object[+1].ypos = object.ypos
149
eggmanHammer[+1].originPos.x = object.xpos
150
eggmanHammer[+1].originPos.y = object.ypos
151
object[+1].frame = 3
152
object[+1].priority = PRIORITY_ACTIVE
153
154
object[+5].type = TypeName[Eggman Totem]
155
object[+5].xpos = object.ixpos
156
object[+5].xpos -= screen.xcenter
157
object[+5].xpos += 16
158
object[+5].xpos <<= 16
159
160
eggmanHammer[+1].boundsR = object[+5].xpos
161
eggmanHammer[+1].boundsR += 0x5A0000
162
163
eggmanTotemPole[+5].timer = 136
164
object[+5].drawOrder = 2
165
object[+5].priority = PRIORITY_ACTIVE
166
167
eggmanHammer[+1].boundsOffset = 0xC800
168
eggmanHammer[+1].boundsOffset *= screen.xcenter
169
eggmanHammer[+1].boundsOffset /= 160
170
eggmanHammer[+1].arrowVelocity = 0x30000
171
eggmanHammer[+1].arrowVelocity *= screen.xcenter
172
eggmanHammer[+1].arrowVelocity /= 160
173
174
object[+6].type = TypeName[Eggman Totem]
175
object[+6].xpos = object.ixpos
176
object[+6].xpos += screen.xcenter
177
object[+6].xpos -= 16
178
object[+6].xpos <<= 16
179
180
eggmanHammer[+1].boundsL = object[+6].xpos
181
eggmanHammer[+1].boundsL -= 0x5A0000
182
183
eggmanTotemPole[+6].timer = 136
184
object[+6].direction = FLIP_X
185
object[+6].drawOrder = 2
186
object[+6].priority = PRIORITY_ACTIVE
187
188
#platform: USE_STANDALONE
189
object.health = 8
190
#endplatform
191
#platform: USE_ORIGINS
192
if game.bossOneLife == false
193
object.health = 8
194
else
195
object.health = 1
196
end if
197
#endplatform
198
199
object.priority = PRIORITY_ACTIVE
200
object.state++
201
end if
202
break
203
204
case ARZEGGMAN_BOSSFIGHT
205
break
206
207
case ARZEGGMAN_EXPLODE
208
object.timer++
209
if object.timer == 60
210
if object.direction == FLIP_NONE
211
object[+1].xvel = -0x10000
212
else
213
object[+1].xvel = 0x10000
214
end if
215
216
object[+1].yvel = -0x40000
217
object[+1].state++
218
end if
219
220
if object.timer == 180
221
object.timer = 0
222
object.animation = ARZEGGANI_TOASTED
223
object.exploding = false
224
object.state++
225
226
ResetObjectEntity(SLOT_MUSICEVENT_BOSS, TypeName[Music Event], MUSICEVENT_FADETOSTAGE, 0, 0)
227
object[SLOT_MUSICEVENT_BOSS].priority = PRIORITY_ACTIVE
228
229
temp0 = tileLayer[0].xsize
230
temp0 <<= 7
231
stage.newXBoundary2 = temp0
232
eggmanHammer[+1].hideFlames = true
233
end if
234
break
235
236
case ARZEGGMAN_DEFEATFALL
237
object.ypos += object.yvel
238
object.yvel += 0x1800
239
240
object.timer++
241
if object.timer == 38
242
object.yvel = 0
243
object.timer = 0
244
object.animationTimer = 0
245
eggmanHammer[+1].hideFlames = false
246
object.state++
247
end if
248
249
object[+1].xpos = object.xpos
250
object[+1].ypos = object.ypos
251
object[+1].direction = object.direction
252
break
253
254
case ARZEGGMAN_DEFEATRISE
255
if object.timer < 48
256
object.ypos += object.yvel
257
object.yvel -= 0x800
258
object.timer++
259
else
260
object.timer = 0
261
object.yvel = 0
262
object.originPos.y = object.ypos
263
object.state++
264
end if
265
266
object[+1].xpos = object.xpos
267
object[+1].ypos = object.ypos
268
object[+1].direction = object.direction
269
break
270
271
case ARZEGGMAN_FLEE
272
object.ypos = object.originPos.y
273
CallFunction(ARZEggman_Oscillate)
274
275
if object.timer < 8
276
object.timer++
277
else
278
object.timer = 0
279
object.animation = ARZEGGANI_PANIC
280
object.animationTimer = 0
281
object.unused1 = 2
282
object.unused2 = 0
283
object.direction = FLIP_X
284
object.priority = PRIORITY_ACTIVE
285
286
#platform: USE_STANDALONE
287
temp0 = tileLayer[0].xsize
288
temp0 <<= 7
289
stage.newXBoundary2 = temp0
290
#endplatform
291
292
object.state++
293
end if
294
break
295
296
case ARZEGGMAN_ESCAPE
297
object.xpos += 0x40000
298
object.originPos.y -= 0x4000
299
300
CallFunction(ARZEggman_Oscillate)
301
302
if object.outOfBounds == true
303
object.type = TypeName[Blank Object]
304
object[+1].type = TypeName[Blank Object]
305
end if
306
break
307
308
end switch
309
310
if object.health != 0
311
if object.invincibilityTimer > 0
312
object.invincibilityTimer--
313
GetBit(temp0, object.invincibilityTimer, 0)
314
if temp0 == true
315
SetPaletteEntry(0, 192, 0xE0E0E0)
316
else
317
SetPaletteEntry(0, 192, 0x000000)
318
end if
319
end if
320
321
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
322
if object.invincibilityTimer == 0
323
CheckEqual(player[currentPlayer].animation, ANI_HURT)
324
temp0 = checkResult
325
CheckEqual(player[currentPlayer].animation, ANI_DYING)
326
temp0 |= checkResult
327
CheckEqual(player[currentPlayer].animation, ANI_DROWNING)
328
temp0 |= checkResult
329
if temp0 != 0
330
if object.animation != ARZEGGANI_LAUGH
331
object.animation = ARZEGGANI_LAUGH
332
object.animationTimer = 0
333
end if
334
end if
335
336
BoxCollisionTest(C_TOUCH, object.entityPos, -24, -24, 24, 24, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
337
if checkResult == true
338
CallFunction(Player_CheckHit)
339
if checkResult == true
340
object.health--
341
if object.health == 0
342
#platform: USE_ORIGINS
343
CallNativeFunction2(NotifyCallback, NOTIFY_KILL_BOSS, 0)
344
CallNativeFunction2(NotifyCallback, NOTIFY_BOSS_END, 1)
345
#endplatform
346
347
player.score += 1000
348
object.animation = ARZEGGANI_DEFEATED
349
object.animationTimer = 0
350
object.unused1 = 0
351
object.exploding = true
352
object.originPos.y = object.ypos
353
object.oscillationAngle = eggmanHammer[+1].oscillationAngle
354
object.state++
355
object[+1].state = EGGMANHAMMER_DESTROYED
356
357
object[+2].state = EGGMANARROW_FALLING
358
object[+3].state = EGGMANARROW_FALLING
359
object[+4].state = EGGMANARROW_FALLING
360
361
eggmanTotemPole[+5].timer = 144
362
object[+5].state = EGGMANTOTEMPOLE_LOWERING
363
364
eggmanTotemPole[+6].timer = 144
365
object[+6].state = EGGMANTOTEMPOLE_LOWERING
366
else
367
object.animation = ARZEGGANI_HIT
368
object.animationTimer = 0
369
object.invincibilityTimer = 64
370
PlaySfx(SfxName[Boss Hit], false)
371
end if
372
end if
373
end if
374
end if
375
next
376
end if
377
378
if object.state != ARZEGGMAN_ESCAPE
379
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
380
temp0 = player[currentPlayer].collisionRight
381
temp0 <<= 16
382
temp0 += player[currentPlayer].xpos
383
temp1 = stage.curXBoundary2
384
temp1 <<= 16
385
if temp0 > temp1
386
player[currentPlayer].xvel = 0
387
player[currentPlayer].speed = 0
388
player[currentPlayer].xpos = temp1
389
temp0 = player[currentPlayer].collisionRight
390
temp0 <<= 16
391
player[currentPlayer].xpos -= temp0
392
end if
393
next
394
end if
395
396
if object.exploding == true
397
temp0 = oscillation
398
temp0 &= 7
399
if temp0 == 0
400
Rand(temp0, 48)
401
temp0 -= 24
402
temp0 <<= 16
403
temp0 += object.xpos
404
Rand(temp1, 48)
405
temp1 -= 24
406
temp1 <<= 16
407
temp1 += object.ypos
408
CreateTempObject(TypeName[Explosion], 0, temp0, temp1)
409
object[tempObjectPos].drawOrder = 5
410
PlaySfx(SfxName[Explosion], false)
411
end if
412
end if
413
end event
414
415
416
event ObjectDraw
417
switch object.animation
418
default
419
case ARZEGGANI_INVISIBLE
420
break
421
422
case ARZEGGANI_IDLE
423
temp0 = object.animationTimer
424
temp0 >>= 3
425
object.animationTimer++
426
object.animationTimer &= 15
427
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
428
break
429
430
case ARZEGGANI_LAUGH
431
temp0 = object.animationTimer
432
temp0 &= 15
433
temp0 >>= 3
434
temp0 += 2
435
object.animationTimer++
436
if object.animationTimer == 50
437
object.animationTimer = 0
438
if player[0].animation != ANI_DYING
439
object.animation = ARZEGGANI_IDLE
440
end if
441
end if
442
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
443
break
444
445
case ARZEGGANI_HIT
446
temp0 = object.animationTimer
447
temp0 &= 1
448
temp0 += 2
449
object.animationTimer++
450
if object.animationTimer == 50
451
object.animationTimer = 0
452
object.animation = ARZEGGANI_IDLE
453
end if
454
DrawSpriteFX(4, FX_FLIP, object.xpos, object.ypos)
455
break
456
457
case ARZEGGANI_DEFEATED
458
temp0 = object.animationTimer
459
temp0 >>= 5
460
temp0 += 4
461
temp0 %= 5
462
object.animationTimer++
463
object.animationTimer &= 63
464
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
465
break
466
467
case ARZEGGANI_TOASTED
468
DrawSpriteFX(5, FX_FLIP, object.xpos, object.ypos)
469
break
470
471
case ARZEGGANI_PANIC
472
temp0 = object.animationTimer
473
temp0 >>= 3
474
object.animationTimer++
475
object.animationTimer &= 15
476
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
477
478
temp0 = object.animationTimer
479
temp0 >>= 2
480
temp0 &= 1
481
if temp0 == 1
482
DrawSpriteFX(15, FX_FLIP, object.xpos, object.ypos)
483
end if
484
break
485
486
end switch
487
end event
488
489
490
event ObjectStartup
491
CheckCurrentStageFolder("Zone03")
492
if checkResult == true
493
LoadSpriteSheet("Global/EggMobile.gif")
494
495
// Eggman Frames
496
SpriteFrame(-28, -28, 60, 20, 5, 1)
497
SpriteFrame(-28, -28, 60, 20, 66, 1)
498
SpriteFrame(-28, -28, 60, 20, 5, 22)
499
SpriteFrame(-28, -28, 60, 20, 66, 22)
500
SpriteFrame(-28, -28, 60, 20, 5, 43)
501
SpriteFrame(-28, -28, 60, 20, 66, 43)
502
503
// Eggmobile Body Frame
504
SpriteFrame(-32, -8, 64, 29, 1, 64)
505
506
// Eggmobile Jet Frames
507
SpriteFrame(31, 4, 12, 8, 66, 65)
508
SpriteFrame(30, 2, 14, 12, 66, 74)
509
SpriteFrame(31, -2, 22, 14, 66, 87)
510
SpriteFrame(31, -9, 32, 26, 94, 64)
511
SpriteFrame(31, -2, 22, 14, 66, 87)
512
SpriteFrame(31, -9, 32, 26, 94, 64)
513
SpriteFrame(31, 4, 12, 8, 66, 65)
514
SpriteFrame(30, 2, 14, 12, 66, 74)
515
516
// Sweat Frames
517
SpriteFrame(-3, -28, 11, 8, 79, 65)
518
SpriteFrame(0, 0, 0, 0, 7, 2)
519
520
if options.vsMode == true
521
foreach (TypeName[Eggman], arrayPos0, ALL_ENTITIES)
522
object[arrayPos0].type = TypeName[Blank Object]
523
next
524
end if
525
else
526
LoadSpriteSheet("MBZ/Objects.gif")
527
528
// Eggman Frames
529
SpriteFrame(-28, -28, 60, 20, 1, 1)
530
SpriteFrame(-28, -28, 60, 20, 62, 1)
531
SpriteFrame(-28, -28, 60, 20, 1, 22)
532
SpriteFrame(-28, -28, 60, 20, 62, 22)
533
SpriteFrame(-28, -28, 60, 20, 1, 43)
534
SpriteFrame(-28, -28, 60, 20, 62, 43)
535
536
// Eggmobile Body Frame
537
SpriteFrame(-32, -8, 64, 29, 415, 170)
538
539
// Eggmobile Jet Frames
540
SpriteFrame(31, 4, 12, 8, 57, 90)
541
SpriteFrame(30, 2, 14, 12, 57, 99)
542
SpriteFrame(31, -2, 22, 14, 34, 97)
543
SpriteFrame(31, -9, 32, 26, 72, 86)
544
SpriteFrame(31, -2, 22, 14, 34, 97)
545
SpriteFrame(31, -9, 32, 26, 72, 86)
546
SpriteFrame(31, 4, 12, 8, 57, 90)
547
SpriteFrame(30, 2, 14, 12, 57, 99)
548
549
// Sweat Frames
550
SpriteFrame(-3, -28, 11, 8, 45, 88)
551
SpriteFrame(0, 0, 0, 0, 7, 2)
552
end if
553
end event
554
555
556
// ========================
557
// Editor Events
558
// ========================
559
560
event RSDKDraw
561
DrawSprite(0)
562
DrawSprite(1)
563
end event
564
565
566
event RSDKLoad
567
CheckCurrentStageFolder("Zone03")
568
if checkResult == true
569
LoadSpriteSheet("Global/EggMobile.gif")
570
SpriteFrame(-28, -28, 60, 20, 5, 1)
571
SpriteFrame(-32, -8, 64, 29, 1, 64)
572
else
573
LoadSpriteSheet("MBZ/Objects.gif")
574
SpriteFrame(-28, -28, 60, 20, 1, 1)
575
SpriteFrame(-32, -8, 64, 29, 415, 170)
576
end if
577
578
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
579
end event
580
581