Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R3/BossBody.txt
1319 views
1
//-----------------Sonic CD Boss Body 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.YOriginPos
8
#alias Object.Value2 : Object.YVelocity
9
#alias Object.Value3 : Object.YGearPos
10
#alias Object.Value4 : Object.AttackTimer
11
#alias Object.Value5 : Object.DamageTimer
12
#alias Object.Value6 : Object.YControllerPos
13
14
// Pinball Bomb Aliases
15
#alias Object.Value1 : Object.XVelocity
16
17
// Eggman Aliases
18
#alias Object[-1].YPos : Eggman.YPos
19
#alias Object[-1].Value0 : Eggman.FrameTimer
20
#alias Object[-1].State : Eggman.State
21
#alias Object[-1].Priority : Eggman.Priority
22
23
// Extending Platform Aliases
24
#alias Object[+1].Value2 : EPlatform.Length
25
26
// States
27
#alias 0 : BOSSBODY_DESCEND
28
#alias 1 : BOSSBODY_DROP_BOMBS
29
#alias 2 : BOSSBODY_HIT_1
30
#alias 3 : BOSSBODY_DRAG_EGGMAN_1
31
#alias 4 : BOSSBODY_HIT_2
32
#alias 5 : BOSSBODY_DRAG_EGGMAN_2
33
#alias 6 : BOSSBODY_HIT_3
34
#alias 7 : BOSSBODY_DESTROYED
35
36
// Eggman States
37
#alias 0 : EGGANI_IDLE
38
#alias 1 : EGGANI_HURT
39
#alias 2 : EGGANI_NERVOUS
40
#alias 3 : EGGANI_FLEE
41
42
// Global SFX
43
#alias 22 : SFX_G_EXPLOSION
44
45
// Priority
46
#alias 0 : PRIORITY_BOUNDS
47
#alias 1 : PRIORITY_ACTIVE
48
49
// Function declarations
50
#function BossBody_LaunchBomb
51
52
53
function BossBody_LaunchBomb
54
TempValue0 = Player.YPos
55
TempValue0 -= Object.YPos
56
57
if TempValue0 < 0x2400000
58
CreateTempObject(TypeName[Pinball Bomb], 0, Object.XPos, Object.YPos)
59
60
Rand(Object[TempObjectPos].XVelocity, 0x400)
61
62
Object[TempObjectPos].XVelocity <<= 8
63
64
if Object.AttackTimer < 128
65
FlipSign(Object[TempObjectPos].XVelocity)
66
Object[TempObjectPos].XPos -= 0x80000
67
else
68
Object[TempObjectPos].XPos += 0x80000
69
end if
70
71
Object[TempObjectPos].YPos += 0x180000
72
73
Object[TempObjectPos].YVelocity = 0x30000
74
75
Object[TempObjectPos].DrawOrder = 2
76
end if
77
end function
78
79
80
sub ObjectMain
81
switch Object.State
82
case BOSSBODY_DESCEND
83
Object.YPos = Player.YPos
84
Object.YPos &= 0xFFFF0000 // Truncate the value
85
// Height Limit
86
if Object.YPos < Object.YOriginPos
87
Object.YPos = Object.YOriginPos
88
Object.Frame = 0
89
end if
90
91
if Object.YPos > Object.YVelocity
92
Object.YPos = Object.YVelocity
93
Object.Frame = 0
94
Object.State = BOSSBODY_DROP_BOMBS
95
Object.Priority = PRIORITY_ACTIVE
96
end if
97
98
if Object.YPos != Object.YGearPos
99
Object.YGearPos = Object.YPos
100
Object.Frame++
101
Object.Frame %= 9
102
end if
103
104
Eggman.YPos = Object.YPos
105
106
Object.AttackTimer++
107
Object.AttackTimer &= 255
108
109
if Object.AttackTimer == 0
110
CallFunction(BossBody_LaunchBomb)
111
end if
112
113
if Object.AttackTimer == 128
114
CallFunction(BossBody_LaunchBomb)
115
end if
116
break
117
118
case BOSSBODY_DROP_BOMBS
119
Eggman.YPos = Object.YPos
120
121
if EPlatform.Length < 8 // if the platform didn't close, keep shooting
122
Object.AttackTimer++
123
Object.AttackTimer &= 255
124
else
125
Object.AttackTimer = 32
126
end if
127
128
if Object.AttackTimer == 0
129
CallFunction(BossBody_LaunchBomb)
130
end if
131
132
if Object.AttackTimer == 128
133
CallFunction(BossBody_LaunchBomb)
134
end if
135
break
136
137
case BOSSBODY_HIT_1
138
if Object.YPos > Object.YVelocity
139
Object.YPos -= 0x28000
140
Object.Frame++
141
Object.Frame %= 9
142
else
143
Object.YPos = Object.YVelocity
144
Object.Frame = 0
145
Object.State = BOSSBODY_DRAG_EGGMAN_1
146
end if
147
148
Eggman.YPos = Object.YPos
149
if Object.DamageTimer == 2
150
CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)
151
Object[TempObjectPos].iXPos -= 32
152
Object[TempObjectPos].iYPos += 10
153
end if
154
155
if Object.DamageTimer == 3
156
CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)
157
Object[TempObjectPos].iXPos += 32
158
Object[TempObjectPos].iYPos += 6
159
end if
160
161
if Object.DamageTimer == 4
162
CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)
163
Object[TempObjectPos].iYPos += 4
164
end if
165
break
166
167
case BOSSBODY_DRAG_EGGMAN_1
168
Eggman.YPos = Object.YPos
169
break
170
171
case BOSSBODY_HIT_2
172
if Object.YPos > Object.YVelocity
173
Object.YPos -= 0x28000
174
Object.Frame++
175
Object.Frame %= 9
176
else
177
Object.YPos = Object.YVelocity
178
Object.Frame = 0
179
Object.State = BOSSBODY_DRAG_EGGMAN_2
180
end if
181
182
Eggman.YPos = Object.YPos
183
if Object.DamageTimer == 2
184
CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)
185
Object[TempObjectPos].iXPos -= 32
186
Object[TempObjectPos].iYPos -= 48
187
end if
188
189
if Object.DamageTimer == 3
190
CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)
191
Object[TempObjectPos].iXPos += 32
192
Object[TempObjectPos].iYPos -= 52
193
end if
194
195
if Object.DamageTimer == 4
196
CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)
197
Object[TempObjectPos].iYPos -= 56
198
end if
199
break
200
201
case BOSSBODY_DRAG_EGGMAN_2
202
Eggman.YPos = Object.YPos
203
break
204
205
case BOSSBODY_HIT_3
206
if Object.YPos > Object.YVelocity
207
Object.YPos -= 0x28000
208
Object.Frame++
209
Object.Frame %= 9
210
Music.Volume--
211
else
212
Object.YPos = Object.YVelocity
213
Object.Frame = 0
214
Object.State = BOSSBODY_DESTROYED
215
Object.Timer = 0
216
Object.Priority = PRIORITY_ACTIVE
217
218
#platform: Use_Haptics
219
HapticEffect(76, 0, 0, 0)
220
#endplatform
221
end if
222
223
if Object.DamageTimer > 0
224
Eggman.YPos = Object.DamageTimer
225
Eggman.YPos <<= 17
226
FlipSign(Eggman.YPos)
227
Eggman.YPos += Object.YPos
228
else
229
230
if Eggman.State == EGGANI_IDLE
231
Eggman.State = EGGANI_FLEE
232
Eggman.Priority = PRIORITY_ACTIVE
233
Eggman.FrameTimer &= 7
234
end if
235
236
if Eggman.State == EGGANI_NERVOUS
237
Eggman.State = EGGANI_FLEE
238
Eggman.Priority = PRIORITY_ACTIVE
239
Eggman.FrameTimer &= 7
240
end if
241
242
end if
243
244
if Object.DamageTimer == 2
245
CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)
246
Object[TempObjectPos].iXPos -= 16
247
Object[TempObjectPos].iYPos -= 52
248
end if
249
250
if Object.DamageTimer == 3
251
CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)
252
Object[TempObjectPos].iXPos += 16
253
Object[TempObjectPos].iYPos -= 56
254
end if
255
break
256
257
case BOSSBODY_DESTROYED
258
TempValue0 = Object.Timer
259
TempValue0 &= 3
260
if TempValue0 == 0
261
Rand(TempValue0, 128)
262
TempValue0 -= 64
263
TempValue0 <<= 16
264
TempValue0 += Object.XPos
265
Rand(TempValue1, 48)
266
TempValue1 -= 24
267
TempValue1 <<= 16
268
TempValue1 += Object.YPos
269
CreateTempObject(TypeName[Explosion], 0, TempValue0, TempValue1)
270
PlaySfx(SFX_G_EXPLOSION, false)
271
end if
272
273
Object.Timer++
274
if Object.Timer == 80
275
Player.Score += 1000
276
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
277
PlayMusic(0)
278
end if
279
break
280
281
end switch
282
end sub
283
284
285
sub ObjectPlayerInteraction
286
switch Object.State
287
case BOSSBODY_DROP_BOMBS
288
case BOSSBODY_DRAG_EGGMAN_1
289
#platform: Use_Standalone
290
PlayerObjectCollision(C_TOUCH, -64, -16, 64, 16)
291
#endplatform
292
#platform: Use_Origins
293
PlayerObjectCollision(C_ENEMY, -64, -16, 64, 16)
294
#endplatform
295
if CheckResult == true
296
Player.YVelocity = 0
297
Object.YVelocity -= 0x480000
298
299
Object.DamageTimer = 1
300
Object.State++
301
302
Eggman.State = EGGANI_HURT
303
PlaySfx(SFX_G_EXPLOSION, false)
304
305
#platform: Use_Haptics
306
HapticEffect(75, 0, 0, 0)
307
#endplatform
308
end if
309
break
310
311
case BOSSBODY_DRAG_EGGMAN_2
312
#platform: Use_Standalone
313
PlayerObjectCollision(C_TOUCH, -64, -16, 64, 16)
314
#endplatform
315
#platform: Use_Origins
316
PlayerObjectCollision(C_ENEMY, -64, -16, 64, 16)
317
#endplatform
318
if CheckResult == true
319
#platform: Use_Origins
320
EngineCallback(NOTIFY_KILL_BOSS)
321
// Tell HE2 that the boss fight ended
322
game.callbackParam0 = true
323
EngineCallback(NOTIFY_BOSS_END)
324
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
325
StopMusic()
326
end if
327
#endplatform
328
Player.YVelocity = 0
329
Object.YVelocity -= 0x800000
330
Object.DamageTimer = 1
331
Object.State++
332
PlaySfx(SFX_G_EXPLOSION, false)
333
334
#platform: Use_Haptics
335
HapticEffect(75, 0, 0, 0)
336
#endplatform
337
end if
338
break
339
end switch
340
end sub
341
342
343
sub ObjectDraw
344
switch Object.State
345
case BOSSBODY_DESCEND
346
case BOSSBODY_DROP_BOMBS
347
DrawSprite(4)
348
DrawSprite(5)
349
350
if Object.AttackTimer < 128
351
if Object.AttackTimer < 8
352
TempValue0 = Object.AttackTimer
353
TempValue0 >>= 1
354
TempValue0 += 7
355
else
356
TempValue0 = 8
357
end if
358
DrawSprite(TempValue0)
359
DrawSprite(12)
360
else
361
if Object.AttackTimer < 136
362
TempValue0 = Object.AttackTimer
363
TempValue0 -= 128
364
TempValue0 >>= 1
365
TempValue0 += 11
366
else
367
TempValue0 = 12
368
end if
369
DrawSprite(8)
370
DrawSprite(TempValue0)
371
end if
372
373
DrawSprite(6)
374
DrawSprite(3)
375
376
TempValue0 = Object.Frame
377
TempValue0 /= 3
378
DrawSprite(TempValue0)
379
break
380
381
case BOSSBODY_HIT_1
382
case BOSSBODY_DRAG_EGGMAN_1
383
case BOSSBODY_HIT_2
384
TempValue0 = Object.DamageTimer
385
TempValue0 &= 1
386
if TempValue0 == 0
387
DrawSprite(4)
388
DrawSprite(5)
389
DrawSprite(3)
390
else
391
DrawSprite(16)
392
DrawSprite(17)
393
DrawSprite(15)
394
end if
395
396
if Object.DamageTimer > 0
397
Object.DamageTimer++
398
Object.DamageTimer &= 15
399
end if
400
401
TempValue0 = Object.Frame
402
TempValue0 /= 3
403
DrawSprite(TempValue0)
404
break
405
406
case BOSSBODY_DRAG_EGGMAN_2
407
TempValue1 = Object.YPos
408
TempValue1 += Object.YControllerPos
409
410
TempValue0 = Object.DamageTimer
411
TempValue0 &= 1
412
if TempValue0 == 0
413
DrawSprite(4)
414
DrawSprite(5)
415
DrawSpriteXY(18, Object.XPos, TempValue1)
416
DrawSprite(3)
417
else
418
DrawSprite(16)
419
DrawSprite(17)
420
DrawSpriteXY(19, Object.XPos, TempValue1)
421
DrawSprite(15)
422
end if
423
424
if Eggman.State == EGGANI_NERVOUS
425
if Object.YControllerPos < 0x100000
426
Object.YControllerPos += 0x8000
427
end if
428
end if
429
430
if Object.DamageTimer > 0
431
Object.DamageTimer++
432
Object.DamageTimer &= 15
433
end if
434
435
TempValue0 = Object.Frame
436
TempValue0 /= 3
437
DrawSprite(TempValue0)
438
break
439
440
case BOSSBODY_HIT_3
441
TempValue0 = Object.YPos
442
TempValue0 -= 0x200000
443
444
if TempValue0 < Object.YVelocity
445
DrawSprite(16)
446
DrawSprite(17)
447
DrawSprite(3)
448
else
449
TempValue1 = Object.YPos
450
TempValue1 += Object.YControllerPos
451
452
TempValue0 = Object.DamageTimer
453
TempValue0 &= 1
454
if TempValue0 == 0
455
DrawSprite(4)
456
DrawSprite(5)
457
DrawSprite(3)
458
else
459
DrawSprite(16)
460
DrawSprite(17)
461
DrawSprite(15)
462
end if
463
464
if Object.YControllerPos < 0x100000
465
Object.YControllerPos += 0x8000
466
end if
467
end if
468
469
if Object.DamageTimer > 0
470
Object.DamageTimer++
471
Object.DamageTimer &= 15
472
end if
473
474
TempValue0 = Object.Frame
475
TempValue0 /= 3
476
DrawSprite(TempValue0)
477
break
478
479
case BOSSBODY_DESTROYED
480
DrawSprite(3)
481
DrawSprite(0)
482
break
483
end switch
484
end sub
485
486
487
sub ObjectStartup
488
LoadSpriteSheet("R3/Objects2.gif")
489
490
// Gear
491
SpriteFrame(-80, -16, 32, 32, 134, 0) // #0 - Egg Tilter Gear Frame 0
492
SpriteFrame(-80, -16, 32, 32, 167, 0) // #1 - Egg Tilter Gear Frame 1
493
SpriteFrame(-80, -16, 32, 32, 200, 0) // #2 - Egg Tilter Gear Frame 2
494
495
// Egg Tilter
496
SpriteFrame(-64, -16, 128, 32, 1, 67) // #3 - Body
497
SpriteFrame(-48, -32, 32, 32, 1, 100) // #4 - EggMobile Container Right
498
SpriteFrame(16, -32, 32, 32, 34, 100) // #5 - EggMobile Container Left
499
SpriteFrame(-24, 16, 48, 8, 148, 141) // #6 - Bomb Launcher Frame
500
501
// Egg Tilter Bomb Launcher Right Cannon
502
SpriteFrame(-24, 24, 24, 24, 148, 149) // #7 - Right Cannon
503
SpriteFrame(-24, 16, 24, 24, 148, 149) // #8 - Right Cannon Fire Frame 0
504
SpriteFrame(-24, 8, 24, 24, 148, 149) // #9 - Right Cannon Fire Frame 1
505
SpriteFrame(-24, 16, 24, 24, 148, 149) // #10 - Right Cannon Fire Frame 2
506
507
// Egg Tilter Bomb Launcher Left Cannon
508
SpriteFrame(0, 24, 24, 24, 172, 149) // #11 - Left Cannon
509
SpriteFrame(0, 16, 24, 24, 172, 149) // #12 - Left Cannon Fire Frame 0
510
SpriteFrame(0, 8, 24, 24, 172, 149) // #13 - Left Cannon Fire Frame 1
511
SpriteFrame(0, 16, 24, 24, 172, 149) // #14 - Left Cannon Fire Frame 2
512
513
// Damage Sprites (and controller)
514
SpriteFrame(-64, -16, 128, 32, 117, 33) // #15 - Egg Tilter Body Flicker
515
516
SpriteFrame(-48, -32, 32, 32, 1, 133) // #16 - EggMobile Container Right Flicker
517
SpriteFrame(16, -32, 32, 32, 34, 133) // #17 - EggMobile Container Left Flicker
518
519
SpriteFrame(-24, -32, 48, 16, 148, 107) // #18 - Egg Tilter Controller
520
SpriteFrame(-24, -32, 48, 16, 148, 124) // #19 - Egg Tilter Controller Flicker
521
522
// Used to be below LoadSpriteSheet, moved here for consistency
523
ArrayPos0 = 32
524
while ArrayPos0 < 1056
525
if Object[ArrayPos0].Type == TypeName[Boss Body]
526
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
527
Object[ArrayPos0].YGearPos = Object[ArrayPos0].YPos
528
Object[ArrayPos0].YVelocity = Object[ArrayPos0].YPos
529
Object[ArrayPos0].YVelocity += 0xE40000
530
end if
531
ArrayPos0++
532
loop
533
end sub
534
535
536
// ========================
537
// Editor Subs
538
// ========================
539
540
sub RSDKDraw
541
DrawSprite(2)
542
DrawSprite(3)
543
DrawSprite(4)
544
DrawSprite(5)
545
DrawSprite(6)
546
DrawSprite(1)
547
DrawSprite(0)
548
end sub
549
550
551
sub RSDKLoad
552
LoadSpriteSheet("R3/Objects2.gif")
553
554
// Gear
555
SpriteFrame(-80, -16, 32, 32, 134, 0) // #0 - Egg Tilter Gear Frame 0
556
// Egg Tilter
557
SpriteFrame(-64, -16, 128, 32, 1, 67) // #1 - Body
558
SpriteFrame(-48, -32, 32, 32, 1, 100) // #2 - EggMobile Container Right
559
SpriteFrame(16, -32, 32, 32, 34, 100) // #3 - EggMobile Container Left
560
// Egg Tilter Bomb Launcher Right Cannon
561
SpriteFrame(-24, 24, 24, 24, 148, 149) // #4 - Right Cannon
562
// Egg Tilter Bomb Launcher Left Cannon
563
SpriteFrame(0, 24, 24, 24, 172, 149) // #5 - Left Cannon
564
SpriteFrame(-24, 16, 48, 8, 148, 141) // #6 - Bomb Launcher Frame
565
566
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
567
end sub
568
569