Path: blob/main/Scripts/R3/BossBody.txt
1319 views
//-----------------Sonic CD Boss Body Script------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Timer6#alias Object.Value1 : Object.YOriginPos7#alias Object.Value2 : Object.YVelocity8#alias Object.Value3 : Object.YGearPos9#alias Object.Value4 : Object.AttackTimer10#alias Object.Value5 : Object.DamageTimer11#alias Object.Value6 : Object.YControllerPos1213// Pinball Bomb Aliases14#alias Object.Value1 : Object.XVelocity1516// Eggman Aliases17#alias Object[-1].YPos : Eggman.YPos18#alias Object[-1].Value0 : Eggman.FrameTimer19#alias Object[-1].State : Eggman.State20#alias Object[-1].Priority : Eggman.Priority2122// Extending Platform Aliases23#alias Object[+1].Value2 : EPlatform.Length2425// States26#alias 0 : BOSSBODY_DESCEND27#alias 1 : BOSSBODY_DROP_BOMBS28#alias 2 : BOSSBODY_HIT_129#alias 3 : BOSSBODY_DRAG_EGGMAN_130#alias 4 : BOSSBODY_HIT_231#alias 5 : BOSSBODY_DRAG_EGGMAN_232#alias 6 : BOSSBODY_HIT_333#alias 7 : BOSSBODY_DESTROYED3435// Eggman States36#alias 0 : EGGANI_IDLE37#alias 1 : EGGANI_HURT38#alias 2 : EGGANI_NERVOUS39#alias 3 : EGGANI_FLEE4041// Global SFX42#alias 22 : SFX_G_EXPLOSION4344// Priority45#alias 0 : PRIORITY_BOUNDS46#alias 1 : PRIORITY_ACTIVE4748// Function declarations49#function BossBody_LaunchBomb505152function BossBody_LaunchBomb53TempValue0 = Player.YPos54TempValue0 -= Object.YPos5556if TempValue0 < 0x240000057CreateTempObject(TypeName[Pinball Bomb], 0, Object.XPos, Object.YPos)5859Rand(Object[TempObjectPos].XVelocity, 0x400)6061Object[TempObjectPos].XVelocity <<= 86263if Object.AttackTimer < 12864FlipSign(Object[TempObjectPos].XVelocity)65Object[TempObjectPos].XPos -= 0x8000066else67Object[TempObjectPos].XPos += 0x8000068end if6970Object[TempObjectPos].YPos += 0x1800007172Object[TempObjectPos].YVelocity = 0x300007374Object[TempObjectPos].DrawOrder = 275end if76end function777879sub ObjectMain80switch Object.State81case BOSSBODY_DESCEND82Object.YPos = Player.YPos83Object.YPos &= 0xFFFF0000 // Truncate the value84// Height Limit85if Object.YPos < Object.YOriginPos86Object.YPos = Object.YOriginPos87Object.Frame = 088end if8990if Object.YPos > Object.YVelocity91Object.YPos = Object.YVelocity92Object.Frame = 093Object.State = BOSSBODY_DROP_BOMBS94Object.Priority = PRIORITY_ACTIVE95end if9697if Object.YPos != Object.YGearPos98Object.YGearPos = Object.YPos99Object.Frame++100Object.Frame %= 9101end if102103Eggman.YPos = Object.YPos104105Object.AttackTimer++106Object.AttackTimer &= 255107108if Object.AttackTimer == 0109CallFunction(BossBody_LaunchBomb)110end if111112if Object.AttackTimer == 128113CallFunction(BossBody_LaunchBomb)114end if115break116117case BOSSBODY_DROP_BOMBS118Eggman.YPos = Object.YPos119120if EPlatform.Length < 8 // if the platform didn't close, keep shooting121Object.AttackTimer++122Object.AttackTimer &= 255123else124Object.AttackTimer = 32125end if126127if Object.AttackTimer == 0128CallFunction(BossBody_LaunchBomb)129end if130131if Object.AttackTimer == 128132CallFunction(BossBody_LaunchBomb)133end if134break135136case BOSSBODY_HIT_1137if Object.YPos > Object.YVelocity138Object.YPos -= 0x28000139Object.Frame++140Object.Frame %= 9141else142Object.YPos = Object.YVelocity143Object.Frame = 0144Object.State = BOSSBODY_DRAG_EGGMAN_1145end if146147Eggman.YPos = Object.YPos148if Object.DamageTimer == 2149CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)150Object[TempObjectPos].iXPos -= 32151Object[TempObjectPos].iYPos += 10152end if153154if Object.DamageTimer == 3155CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)156Object[TempObjectPos].iXPos += 32157Object[TempObjectPos].iYPos += 6158end if159160if Object.DamageTimer == 4161CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)162Object[TempObjectPos].iYPos += 4163end if164break165166case BOSSBODY_DRAG_EGGMAN_1167Eggman.YPos = Object.YPos168break169170case BOSSBODY_HIT_2171if Object.YPos > Object.YVelocity172Object.YPos -= 0x28000173Object.Frame++174Object.Frame %= 9175else176Object.YPos = Object.YVelocity177Object.Frame = 0178Object.State = BOSSBODY_DRAG_EGGMAN_2179end if180181Eggman.YPos = Object.YPos182if Object.DamageTimer == 2183CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)184Object[TempObjectPos].iXPos -= 32185Object[TempObjectPos].iYPos -= 48186end if187188if Object.DamageTimer == 3189CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)190Object[TempObjectPos].iXPos += 32191Object[TempObjectPos].iYPos -= 52192end if193194if Object.DamageTimer == 4195CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)196Object[TempObjectPos].iYPos -= 56197end if198break199200case BOSSBODY_DRAG_EGGMAN_2201Eggman.YPos = Object.YPos202break203204case BOSSBODY_HIT_3205if Object.YPos > Object.YVelocity206Object.YPos -= 0x28000207Object.Frame++208Object.Frame %= 9209Music.Volume--210else211Object.YPos = Object.YVelocity212Object.Frame = 0213Object.State = BOSSBODY_DESTROYED214Object.Timer = 0215Object.Priority = PRIORITY_ACTIVE216217#platform: Use_Haptics218HapticEffect(76, 0, 0, 0)219#endplatform220end if221222if Object.DamageTimer > 0223Eggman.YPos = Object.DamageTimer224Eggman.YPos <<= 17225FlipSign(Eggman.YPos)226Eggman.YPos += Object.YPos227else228229if Eggman.State == EGGANI_IDLE230Eggman.State = EGGANI_FLEE231Eggman.Priority = PRIORITY_ACTIVE232Eggman.FrameTimer &= 7233end if234235if Eggman.State == EGGANI_NERVOUS236Eggman.State = EGGANI_FLEE237Eggman.Priority = PRIORITY_ACTIVE238Eggman.FrameTimer &= 7239end if240241end if242243if Object.DamageTimer == 2244CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)245Object[TempObjectPos].iXPos -= 16246Object[TempObjectPos].iYPos -= 52247end if248249if Object.DamageTimer == 3250CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)251Object[TempObjectPos].iXPos += 16252Object[TempObjectPos].iYPos -= 56253end if254break255256case BOSSBODY_DESTROYED257TempValue0 = Object.Timer258TempValue0 &= 3259if TempValue0 == 0260Rand(TempValue0, 128)261TempValue0 -= 64262TempValue0 <<= 16263TempValue0 += Object.XPos264Rand(TempValue1, 48)265TempValue1 -= 24266TempValue1 <<= 16267TempValue1 += Object.YPos268CreateTempObject(TypeName[Explosion], 0, TempValue0, TempValue1)269PlaySfx(SFX_G_EXPLOSION, false)270end if271272Object.Timer++273if Object.Timer == 80274Player.Score += 1000275ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)276PlayMusic(0)277end if278break279280end switch281end sub282283284sub ObjectPlayerInteraction285switch Object.State286case BOSSBODY_DROP_BOMBS287case BOSSBODY_DRAG_EGGMAN_1288#platform: Use_Standalone289PlayerObjectCollision(C_TOUCH, -64, -16, 64, 16)290#endplatform291#platform: Use_Origins292PlayerObjectCollision(C_ENEMY, -64, -16, 64, 16)293#endplatform294if CheckResult == true295Player.YVelocity = 0296Object.YVelocity -= 0x480000297298Object.DamageTimer = 1299Object.State++300301Eggman.State = EGGANI_HURT302PlaySfx(SFX_G_EXPLOSION, false)303304#platform: Use_Haptics305HapticEffect(75, 0, 0, 0)306#endplatform307end if308break309310case BOSSBODY_DRAG_EGGMAN_2311#platform: Use_Standalone312PlayerObjectCollision(C_TOUCH, -64, -16, 64, 16)313#endplatform314#platform: Use_Origins315PlayerObjectCollision(C_ENEMY, -64, -16, 64, 16)316#endplatform317if CheckResult == true318#platform: Use_Origins319EngineCallback(NOTIFY_KILL_BOSS)320// Tell HE2 that the boss fight ended321game.callbackParam0 = true322EngineCallback(NOTIFY_BOSS_END)323if game.playMode == BOOT_PLAYMODE_BOSSRUSH324StopMusic()325end if326#endplatform327Player.YVelocity = 0328Object.YVelocity -= 0x800000329Object.DamageTimer = 1330Object.State++331PlaySfx(SFX_G_EXPLOSION, false)332333#platform: Use_Haptics334HapticEffect(75, 0, 0, 0)335#endplatform336end if337break338end switch339end sub340341342sub ObjectDraw343switch Object.State344case BOSSBODY_DESCEND345case BOSSBODY_DROP_BOMBS346DrawSprite(4)347DrawSprite(5)348349if Object.AttackTimer < 128350if Object.AttackTimer < 8351TempValue0 = Object.AttackTimer352TempValue0 >>= 1353TempValue0 += 7354else355TempValue0 = 8356end if357DrawSprite(TempValue0)358DrawSprite(12)359else360if Object.AttackTimer < 136361TempValue0 = Object.AttackTimer362TempValue0 -= 128363TempValue0 >>= 1364TempValue0 += 11365else366TempValue0 = 12367end if368DrawSprite(8)369DrawSprite(TempValue0)370end if371372DrawSprite(6)373DrawSprite(3)374375TempValue0 = Object.Frame376TempValue0 /= 3377DrawSprite(TempValue0)378break379380case BOSSBODY_HIT_1381case BOSSBODY_DRAG_EGGMAN_1382case BOSSBODY_HIT_2383TempValue0 = Object.DamageTimer384TempValue0 &= 1385if TempValue0 == 0386DrawSprite(4)387DrawSprite(5)388DrawSprite(3)389else390DrawSprite(16)391DrawSprite(17)392DrawSprite(15)393end if394395if Object.DamageTimer > 0396Object.DamageTimer++397Object.DamageTimer &= 15398end if399400TempValue0 = Object.Frame401TempValue0 /= 3402DrawSprite(TempValue0)403break404405case BOSSBODY_DRAG_EGGMAN_2406TempValue1 = Object.YPos407TempValue1 += Object.YControllerPos408409TempValue0 = Object.DamageTimer410TempValue0 &= 1411if TempValue0 == 0412DrawSprite(4)413DrawSprite(5)414DrawSpriteXY(18, Object.XPos, TempValue1)415DrawSprite(3)416else417DrawSprite(16)418DrawSprite(17)419DrawSpriteXY(19, Object.XPos, TempValue1)420DrawSprite(15)421end if422423if Eggman.State == EGGANI_NERVOUS424if Object.YControllerPos < 0x100000425Object.YControllerPos += 0x8000426end if427end if428429if Object.DamageTimer > 0430Object.DamageTimer++431Object.DamageTimer &= 15432end if433434TempValue0 = Object.Frame435TempValue0 /= 3436DrawSprite(TempValue0)437break438439case BOSSBODY_HIT_3440TempValue0 = Object.YPos441TempValue0 -= 0x200000442443if TempValue0 < Object.YVelocity444DrawSprite(16)445DrawSprite(17)446DrawSprite(3)447else448TempValue1 = Object.YPos449TempValue1 += Object.YControllerPos450451TempValue0 = Object.DamageTimer452TempValue0 &= 1453if TempValue0 == 0454DrawSprite(4)455DrawSprite(5)456DrawSprite(3)457else458DrawSprite(16)459DrawSprite(17)460DrawSprite(15)461end if462463if Object.YControllerPos < 0x100000464Object.YControllerPos += 0x8000465end if466end if467468if Object.DamageTimer > 0469Object.DamageTimer++470Object.DamageTimer &= 15471end if472473TempValue0 = Object.Frame474TempValue0 /= 3475DrawSprite(TempValue0)476break477478case BOSSBODY_DESTROYED479DrawSprite(3)480DrawSprite(0)481break482end switch483end sub484485486sub ObjectStartup487LoadSpriteSheet("R3/Objects2.gif")488489// Gear490SpriteFrame(-80, -16, 32, 32, 134, 0) // #0 - Egg Tilter Gear Frame 0491SpriteFrame(-80, -16, 32, 32, 167, 0) // #1 - Egg Tilter Gear Frame 1492SpriteFrame(-80, -16, 32, 32, 200, 0) // #2 - Egg Tilter Gear Frame 2493494// Egg Tilter495SpriteFrame(-64, -16, 128, 32, 1, 67) // #3 - Body496SpriteFrame(-48, -32, 32, 32, 1, 100) // #4 - EggMobile Container Right497SpriteFrame(16, -32, 32, 32, 34, 100) // #5 - EggMobile Container Left498SpriteFrame(-24, 16, 48, 8, 148, 141) // #6 - Bomb Launcher Frame499500// Egg Tilter Bomb Launcher Right Cannon501SpriteFrame(-24, 24, 24, 24, 148, 149) // #7 - Right Cannon502SpriteFrame(-24, 16, 24, 24, 148, 149) // #8 - Right Cannon Fire Frame 0503SpriteFrame(-24, 8, 24, 24, 148, 149) // #9 - Right Cannon Fire Frame 1504SpriteFrame(-24, 16, 24, 24, 148, 149) // #10 - Right Cannon Fire Frame 2505506// Egg Tilter Bomb Launcher Left Cannon507SpriteFrame(0, 24, 24, 24, 172, 149) // #11 - Left Cannon508SpriteFrame(0, 16, 24, 24, 172, 149) // #12 - Left Cannon Fire Frame 0509SpriteFrame(0, 8, 24, 24, 172, 149) // #13 - Left Cannon Fire Frame 1510SpriteFrame(0, 16, 24, 24, 172, 149) // #14 - Left Cannon Fire Frame 2511512// Damage Sprites (and controller)513SpriteFrame(-64, -16, 128, 32, 117, 33) // #15 - Egg Tilter Body Flicker514515SpriteFrame(-48, -32, 32, 32, 1, 133) // #16 - EggMobile Container Right Flicker516SpriteFrame(16, -32, 32, 32, 34, 133) // #17 - EggMobile Container Left Flicker517518SpriteFrame(-24, -32, 48, 16, 148, 107) // #18 - Egg Tilter Controller519SpriteFrame(-24, -32, 48, 16, 148, 124) // #19 - Egg Tilter Controller Flicker520521// Used to be below LoadSpriteSheet, moved here for consistency522ArrayPos0 = 32523while ArrayPos0 < 1056524if Object[ArrayPos0].Type == TypeName[Boss Body]525Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos526Object[ArrayPos0].YGearPos = Object[ArrayPos0].YPos527Object[ArrayPos0].YVelocity = Object[ArrayPos0].YPos528Object[ArrayPos0].YVelocity += 0xE40000529end if530ArrayPos0++531loop532end sub533534535// ========================536// Editor Subs537// ========================538539sub RSDKDraw540DrawSprite(2)541DrawSprite(3)542DrawSprite(4)543DrawSprite(5)544DrawSprite(6)545DrawSprite(1)546DrawSprite(0)547end sub548549550sub RSDKLoad551LoadSpriteSheet("R3/Objects2.gif")552553// Gear554SpriteFrame(-80, -16, 32, 32, 134, 0) // #0 - Egg Tilter Gear Frame 0555// Egg Tilter556SpriteFrame(-64, -16, 128, 32, 1, 67) // #1 - Body557SpriteFrame(-48, -32, 32, 32, 1, 100) // #2 - EggMobile Container Right558SpriteFrame(16, -32, 32, 32, 34, 100) // #3 - EggMobile Container Left559// Egg Tilter Bomb Launcher Right Cannon560SpriteFrame(-24, 24, 24, 24, 148, 149) // #4 - Right Cannon561// Egg Tilter Bomb Launcher Left Cannon562SpriteFrame(0, 24, 24, 24, 172, 149) // #5 - Left Cannon563SpriteFrame(-24, 16, 48, 8, 148, 141) // #6 - Bomb Launcher Frame564565SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")566end sub567568569