Path: blob/main/Scripts/R5/BossPlatform.txt
1319 views
//---------------Sonic CD Boss Platform Script----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Notes:5// This Boss Platform is the main controller in this Boss Fight so I'll put everything here67// The order of Objects in the scene is:8// - Boss Spikes9// - Boss Bomb10// - Bomb Carrier11// - Boss Top12// - Boss Back Panel13// - Eggman14// - Boss Platform1516// All the Objects in this Boss Fight are very interconnected, they reach and interact with each other often17// As such, it is paramount that they are all setup right, or else the Fight will break quite so!1819// Aliases2021// Value0 servers two distinct purposes across this Object's different states22// For clarity, they're just separately named23#alias Object.Value0 : Object.Timer24#alias Object.Value0 : Object.Bounces2526#alias Object.Value1 : Object.BaseX27#alias Object.Value2 : Object.YVelocity28#alias Object.Value5 : Object.Grind29#alias Object.Value6 : Object.SparksTimer3031// These set of Values are for the Conveyor Belt beneath the Boss32// BeltFrame corresponds to one of the palette banks33#alias Object.Value3 : Object.BeltSpeed34#alias Object.Value4 : Object.BeltTimer35#alias Object.Value7 : Object.BeltFrame3637// States38#alias 0 : BOSSPLATFORM_IDLE39#alias 1 : BOSSPLATFORM_SHAKE40#alias 2 : BOSSPLATFORM_FALL_141#alias 3 : BOSSPLATFORM_FIGHT_142#alias 4 : BOSSPLATFORM_FALL_243#alias 5 : BOSSPLATFORM_FIGHT_244#alias 6 : BOSSPLATFORM_FALL_345#alias 7 : BOSSPLATFORM_FIGHT_346#alias 8 : BOSSPLATFORM_FALL_447#alias 9 : BOSSPLATFORM_FIGHT_448#alias 10 : BOSSPLATFORM_EGGFLEE49#alias 11 : BOSSPLATFORM_EXPLODE5051// Boss Top Aliases52#alias Object.Value1 : Object.BoundsR53#alias Object.Value2 : Object.OldBoundsR5455// Boss Spark Aliases56#alias Object.Value1 : Object.XVelocity5758// Bomb Carrier States59#alias 3 : BOMBCARRIER_SLIDERIGHT6061// Boss Top States62#alias 1 : BOSSTOP_MOVEBOUNDS6364// Boss Spark States65#alias 0 : BOSSSPARK_GRIND66#alias 1 : BOSSSPARK_LAND6768// Eggman Aliases69#alias 0 : EGGMAN_IDLE70#alias 2 : EGGMAN_DAMAGED71#alias 3 : EGGMAN_PANICK_JUMP72#alias 6 : EGGMAN_FLEE7374// Fade Music Property Values75#alias 1 : FADEMUSIC_TO_LEVEL7677// Collision Sides78#alias 0 : CSIDE_FLOOR7980// Gravity81#alias 0 : GRAVITY_GROUND8283// Global SFX84#alias 22 : SFX_G_EXPLOSION8586// Stage SFX87#alias 3 : SFX_S_BOSSHIT88#alias 4 : SFX_S_IMPACT18990// Ink Effect91#alias 2 : INK_ALPHA929394// Function declarations95#function BossPlatform_Conveyor_Update96#function BossPlatform_Conveyor_WindDown97#function BossPlatform_SpawnLandingSparks9899function BossPlatform_Conveyor_Update100101if Player.Gravity == GRAVITY_GROUND102// The Player's on the Ground, so that means we can push 'em around and all that stuff103104if Player.ObjectInteraction == true105if Player.Speed > Object.BeltSpeed106// The Player's going faster than the Conveyor Belt, but the Belt's gotta keep up!107108// Increase the Belt's Speed by ~0.02 pixels109Object.BeltSpeed += 0x600110111// Cap the Belt Speed to be ~5.81 pixels per frame maximum112if Object.BeltSpeed > 0x5D000113Object.BeltSpeed = 0x5D000114end if115else116// The Player's going slower than (or the same speed as) the Conveyor Belt117118// Let's help the Player a bit and decelerate at a rate of about 0.02 pixels per frame119Object.BeltSpeed -= 0x600120121// Enforce a lower minimum cap of 0.75 pixels per frame122if Object.BeltSpeed < 0xC000123Object.BeltSpeed = 0xC000124end if125end if126127// First, set TempValue0 to be the value of a speed of 2 pixels to the left per frame128TempValue0 = -0x20000129130// Then, add the Belt's actual speed to it131TempValue0 += Object.BeltSpeed132133// Don't wanna become positive...134if TempValue0 > 0135TempValue0 = 0136end if137138// And now compare the Player's speed with Temp0139// (Do note, TempValue0 is a speed in the left direction, where values are negative,140// so "smaller" values are faster)141if Player.Speed < TempValue0142// If the Player's going faster than Temp0, enforce a maximum speed143144Player.Speed = TempValue0145Player.XVelocity = TempValue0146end if147148// And then, y'know, actually act as a Conveyor Belt and push the Player left149Player.XPos -= Object.BeltSpeed150end if151else152// The Player's in the Air, slow down the Conveyor belt153154// If the Player is flying, make the Belt decelerate faster155if Player.State == Player_State_Fly156// Make it decelerate by around 0.031 pixels per frame157Object.BeltSpeed -= 0x800158else159// The Player's just in the air normally, decelerate at a rate of 0.0039 pixels per frame160Object.BeltSpeed -= 0x100161end if162163// Enforce a minumum speed of 0.75 pixels per frame164if Object.BeltSpeed < 0xC000165Object.BeltSpeed = 0xC000166end if167168// Did the Player press the jump button earlier this frame?169// (The Player Object is in slot 0, while this one's all the way170// down in the Stage Object list, which is why this can be checked this way)171if Player.JumpPress == true172173// Player.JumpStrength is normally a positive number, which is why this needs to be done174TempValue0 = Player.JumpStrength175FlipSign(TempValue0)176177// If the Player's Y Velocity is equal to their base Jump Strength, then that means178// they just jumped this frame179// -> There's nothing that needs to be accounted for on behalf of slopes because,180// the arena's all just one flat line181if Player.YVelocity == TempValue0182// Silently reset their Horizontal movement values, in order to make their jumping183// more responsive184185Player.XVelocity = 0186Player.Speed = 0187end if188189end if190end if191192// Update the Grinding on the Boss's Platform193194TempValue0 = Object.BeltSpeed195196// Subtract the baseline speed - 0.75 per frame - from it197TempValue0 -= 0xC000198199// And then divide the remainder from that to level it down from 0-3200TempValue0 /= 0x1B000201switch TempValue0202case 0203// Lowest grind speed...204205Object.BeltTimer++206Object.Grind++207Object.SparksTimer++208209// The Speed's so low, the Boss isn't even shaking...210Object.XPos = Object.BaseX211Object[-2].XPos = Object.XPos212break213214case 1215// Getting faster...216217Object.BeltTimer += 2218Object.Grind += 2219Object.SparksTimer += 4220221// Get the lowest bit of the global Oscillation value222TempValue1 = Oscillation223TempValue1 &= 1224225// Shake the boss either a pixel left or back to its neutral position - a 2-pixel movement range226if TempValue1 == 1227Object.XPos = Object.BaseX228Object.XPos -= 0x10000229else230Object.XPos = Object.BaseX231end if232233// And then move the Boss Back Panel to match234Object[-2].XPos = Object.XPos235break236237case 2238case 3239// Woah! That's a pretty fast speed!240// Cases 2/3 are just combined here for simplicity's sake241242Object.BeltTimer += 4243Object.Grind += 4244Object.SparksTimer += 8245246// Get the lowest bit of the Oscillation value247TempValue1 = Oscillation248TempValue1 &= 1249250// From that result, move the Boss a pixel either left or right - a 3-pixel movement range251if TempValue1 == 1252Object.XPos = Object.BaseX253Object.XPos -= 0x10000254else255Object.XPos = Object.BaseX256Object.XPos += 0x10000257end if258259// And yup, carry the Boss Back Panel along for the ride too!260Object[-2].XPos = Object.XPos261break262263end switch264265// Update the Conveyor Belt animation266// - This Boss erases the normal Conveyor Belt Object,267// which is why this now has to be done here268if Object.BeltTimer > 3269Object.BeltTimer = 0270271Object.BeltFrame--272if Object.BeltFrame < 0273Object.BeltFrame = 2274end if275276SetActivePalette(Object.BeltFrame, 0, Screen.YSize)277end if278279// Enforce Left Bounds280281TempValue0 = Player.CollisionLeft282TempValue0 <<= 16283TempValue0 += Player.XPos284285// Is the Player behind the Boss Spikes?286if TempValue0 < Object[-6].XPos287// Move them to be ahead of the Boss Spikes288289Player.XPos = Object[-6].XPos290TempValue0 = Player.CollisionLeft291TempValue0 <<= 16292Player.XPos -= TempValue0293end if294295// Enforce Right Bounds296297TempValue0 = Player.CollisionRight298TempValue0 <<= 16299TempValue0 += Player.XPos300301// Object[-3] is the Boss Top, where the Right bounds are stored302TempValue1 = Object[-3].BoundsR303304// Is the Player ahead of the Right Bounds?305if TempValue0 > TempValue1306Player.XPos = TempValue1307308TempValue0 = Player.CollisionRight309TempValue0 <<= 16310Player.XPos -= TempValue0311312if Player.State == Player_State_Fly313// if the Player's flying, then do some stuff to make sure they don't go too far314315Player.Speed = 0316Player.XVelocity = 0317end if318end if319320end function321322323function BossPlatform_Conveyor_WindDown324// For the most part, this function is just a slimmed version of BossPlatform_Conveyor_Update325326// Slow down the Conveyor Belt, at a rate of 0.0625 pixels per frame327Object.BeltSpeed -= 0x1000328if Object.BeltSpeed < 0329// Nope, don't wanna step into the negatives!330Object.BeltSpeed = 0331end if332333if Player.Gravity == GRAVITY_GROUND334// The Player's on the Ground335336if Player.ObjectInteraction == true337TempValue0 = -0x20000338TempValue0 += Object.BeltSpeed339340if TempValue0 > 0341TempValue0 = 0342end if343344if Player.Speed < TempValue0345Player.Speed = TempValue0346Player.XVelocity = TempValue0347end if348349Player.XPos -= Object.BeltSpeed350end if351else352// The Player's in the air353354if Player.JumpPress == true355TempValue0 = Player.JumpStrength356FlipSign(TempValue0)357358if Player.YVelocity == TempValue0359Player.XVelocity = 0360Player.Speed = 0361end if362end if363end if364365// Even if the boss is defeated, still update some of the grinding stuff366// Just, without all the Boss shaking side of the stuff367368TempValue0 = Object.BeltSpeed369TempValue0 /= 0x1B000370371switch TempValue0372case 0373Object.BeltTimer++374Object.Grind++375Object.SparksTimer++376break377378case 1379Object.BeltTimer += 2380Object.Grind += 2381Object.SparksTimer += 4382break383384case 2385case 3386Object.BeltTimer += 4387Object.Grind += 4388Object.SparksTimer += 8389break390391end switch392393if Object.BeltTimer > 3394Object.BeltTimer = 0395Object.BeltFrame--396if Object.BeltFrame < 0397Object.BeltFrame = 2398end if399400SetActivePalette(Object.BeltFrame, 0, Screen.YSize)401end if402403// Enforce Left Bounds404405TempValue0 = Player.CollisionLeft406TempValue0 <<= 16407TempValue0 += Player.XPos408if TempValue0 < Object[-6].XPos409Player.XPos = Object[-6].XPos410TempValue0 = Player.CollisionLeft411TempValue0 <<= 16412Player.XPos -= TempValue0413end if414415// No enforcing Right Bounds here, the Object's already quite literally a giant box in its ObjectPlayerInteraction416417end function418419420function BossPlatform_SpawnLandingSparks421422// As you may have guessed, this Function spawns all the cool Sparks the Boss makes423// Preconditions:424// - TempValue0 is set to the Y Offset for the Sparks425426CreateTempObject(TypeName[Boss Spark], BOSSSPARK_LAND, Object.XPos, Object.YPos)427Object[TempObjectPos].XPos -= 0x100000428Object[TempObjectPos].YPos += TempValue0429Object[TempObjectPos].XVelocity = -0x10000430Object[TempObjectPos].YVelocity = -0x18000431432CreateTempObject(TypeName[Boss Spark], BOSSSPARK_LAND, Object.XPos, Object.YPos)433Object[TempObjectPos].XPos += 0x100000434Object[TempObjectPos].YPos += TempValue0435Object[TempObjectPos].XVelocity = -0x10000436Object[TempObjectPos].YVelocity = -0x18000437438TempValue0 += 0x80000439440CreateTempObject(TypeName[Boss Spark], BOSSSPARK_LAND, Object.XPos, Object.YPos)441Object[TempObjectPos].XPos -= 0x180000442Object[TempObjectPos].YPos += TempValue0443Object[TempObjectPos].XVelocity = -0x10000444Object[TempObjectPos].YVelocity = -0x18000445446CreateTempObject(TypeName[Boss Spark], BOSSSPARK_LAND, Object.XPos, Object.YPos)447Object[TempObjectPos].XPos -= 0x40000448Object[TempObjectPos].YPos += TempValue0449Object[TempObjectPos].XVelocity = -0x10000450Object[TempObjectPos].YVelocity = -0x18000451452CreateTempObject(TypeName[Boss Spark], BOSSSPARK_LAND, Object.XPos, Object.YPos)453Object[TempObjectPos].XPos += 0x180000454Object[TempObjectPos].YPos += TempValue0455Object[TempObjectPos].XVelocity = -0x10000456Object[TempObjectPos].YVelocity = -0x18000457458CreateTempObject(TypeName[Boss Spark], BOSSSPARK_LAND, Object.XPos, Object.YPos)459Object[TempObjectPos].XPos += 0x40000460Object[TempObjectPos].YPos += TempValue0461Object[TempObjectPos].XVelocity = -0x10000462Object[TempObjectPos].YVelocity = -0x18000463464TempValue0 += 0x80000465466CreateTempObject(TypeName[Boss Spark], BOSSSPARK_LAND, Object.XPos, Object.YPos)467Object[TempObjectPos].XPos -= 0x100000468Object[TempObjectPos].YPos += TempValue0469Object[TempObjectPos].XVelocity = -0x10000470Object[TempObjectPos].YVelocity = -0x18000471472CreateTempObject(TypeName[Boss Spark], BOSSSPARK_LAND, Object.XPos, Object.YPos)473Object[TempObjectPos].XPos += 0x100000474Object[TempObjectPos].YPos += TempValue0475Object[TempObjectPos].XVelocity = -0x10000476Object[TempObjectPos].YVelocity = -0x18000477478end function479480481sub ObjectMain482483switch Object.State484case BOSSPLATFORM_SHAKE485if Object.Timer < 60486Object.Timer++487488// Get the lowest bit of the Timer489TempValue0 = Object.Timer490TempValue0 &= 1491492// Shake a bit, direction depending on what that Bit is493if TempValue0 == 1494// Move a pixel down495Object.YPos += 0x20000496else497// Move a pixel up498Object.YPos -= 0x20000499end if500else501// Start falling502503Object.Timer = 0504Object.State = BOSSPLATFORM_FALL_1505506// Make Robotnik go into his shock animation507Object[-1].State = EGGMAN_DAMAGED508Object[-1].Frame = 0509Object[-1].Timer = 0510end if511512// Move Robotnik along, to be 28 pixels above the Platform's Y Position513Object[-1].YPos = Object.YPos514Object[-1].YPos -= 0x1C0000515516// And then move the Boss's Back Panel too517Object[-2].YPos = Object.YPos518519// Start up the Conveyor520CallFunction(BossPlatform_Conveyor_Update)521522// For now, regardless of the Coveyor's Speed, stay at the base position523Object.XPos = Object.BaseX524525// And apply this to the Boss Back Panel as well526Object[-2].XPos = Object.BaseX527break528529case BOSSPLATFORM_FALL_1530531// Accelerate the falling speed at a rate of about 0.09 pixels per frame532Object.YVelocity += 0x1800533534// And then, y'know, do the actual falling535Object.YPos += Object.YVelocity536537// Check to see if this Object's hit the ground538// (Note the use of 31 for the Y Offset here, it changes for every falling cycle)539ObjectTileCollision(CSIDE_FLOOR, 0, 31, 0)540541if CheckResult == true542Screen.ShakeY = 4543544PlayStageSfx(SFX_S_IMPACT1, false)545546// Bounce once547if Object.Bounces < 1548Object.Bounces++549550// Tone the Y Velocity down a bit and turn it right around!551Object.YVelocity >>= 1552FlipSign(Object.YVelocity)553else554// Start the first main phase of the Fight555556Object.State = BOSSPLATFORM_FIGHT_1557Object[-1].State = EGGMAN_IDLE558Object.Bounces = 0559Object.Grind = 0560end if561562// Spawn Sparks, with an offset of 19 pixels563TempValue0 = 0x130000564CallFunction(BossPlatform_SpawnLandingSparks)565566#platform: Use_Haptics567HapticEffect(97, 0, 0, 0)568#endplatform569end if570571572Object[-1].YPos = Object.YPos573Object[-1].YPos -= 0x1C0000574575Object[-2].YPos = Object.YPos576577// Update the Conveyor Belt, but...578CallFunction(BossPlatform_Conveyor_Update)579580// Revert whatever it does to the Boss's position, as the Boss is still in the air581Object.XPos = Object.BaseX582Object[-2].XPos = Object.BaseX583break584585case BOSSPLATFORM_FIGHT_1586// First main phase of the fight587588CallFunction(BossPlatform_Conveyor_Update)589590if Object.Grind > 2399591Object.State++592end if593594if Object.SparksTimer > 47595Object.SparksTimer %= 48596597// Create a Spark, with properties of:598// - 24 pixels right from the Boss Platform599// - 27 pixels below the Boss Platform600// - Starting X Velocity of one pixel a frame to the left601CreateTempObject(TypeName[Boss Spark], BOSSSPARK_GRIND, Object.XPos, Object.YPos)602Object[TempObjectPos].XPos += 0x180000603Object[TempObjectPos].YPos += 0x1B0000604Object[TempObjectPos].XVelocity = -0x10000605end if606break607608case BOSSPLATFORM_FALL_2609610// Falling acceleration speed rate of about 0.09 pixels per frame611Object.YVelocity += 0x1800612613Object.YPos += Object.YVelocity614615// Check to see if the Boss Platform's hit the ground616// Note that the Y Offset is 23 here, shorter than the 31 from last time617ObjectTileCollision(CSIDE_FLOOR, 0, 23, 0)618619if CheckResult == true620Screen.ShakeY = 4621622PlayStageSfx(SFX_S_IMPACT1, false)623624// Bounce once when initially hitting the ground625if Object.Bounces < 1626Object.Bounces++627628// Lower Velocity it turn it around629Object.YVelocity >>= 1630FlipSign(Object.YVelocity)631else632Object.State = BOSSPLATFORM_FIGHT_2633Object.Bounces = 0634Object.Grind = 0635end if636637// Spawn landing Sparks, with an offset of 11 pixels638TempValue0 = 0xB0000639CallFunction(BossPlatform_SpawnLandingSparks)640641#platform: Use_Haptics642HapticEffect(97, 0, 0, 0)643#endplatform644end if645646// Move Eggman to match this Object's position, 28 pixels above647Object[-1].YPos = Object.YPos648Object[-1].YPos -= 0x1C0000649650// And move the Boss Back Panel along as well651Object[-2].YPos = Object.YPos652653// Update the Conveyor underneat the Boss, even if the Boss may not be on it654// -> With this, however, the Boss's Base Position isn't restored afterwards655// so the Boss may still shake slightly horizontally while in the air656CallFunction(BossPlatform_Conveyor_Update)657break658659case BOSSPLATFORM_FIGHT_2660CallFunction(BossPlatform_Conveyor_Update)661662if Object.Grind > 2399663Object.State++664end if665666if Object.SparksTimer > 47667Object.SparksTimer %= 48668669// Create a Boss Spark, with values of:670// - 24 pixels right from the Boss's Position671// - 19 pixels below the Boss's Position672// - X Velocity of 1 pixel left per frame673CreateTempObject(TypeName[Boss Spark], BOSSSPARK_GRIND, Object.XPos, Object.YPos)674Object[TempObjectPos].XPos += 0x180000675Object[TempObjectPos].YPos += 0x130000676Object[TempObjectPos].XVelocity = -0x10000677end if678break679680case BOSSPLATFORM_FALL_3681682// Fall with an acceleration speed of about 0.09 pixels per frame683Object.YVelocity += 0x1800684685Object.YPos += Object.YVelocity686687// Check for Floor collision, now with a Y Offset of 15688ObjectTileCollision(CSIDE_FLOOR, 0, 15, 0)689690if CheckResult == true691Screen.ShakeY = 4692693PlayStageSfx(SFX_S_IMPACT1, false)694695// Bounce a single time upon initially landing696if Object.Bounces < 1697Object.Bounces++698699Object.YVelocity >>= 1700FlipSign(Object.YVelocity)701else702Object.State = BOSSPLATFORM_FIGHT_3703Object.Bounces = 0704Object.Grind = 0705end if706707// Create landing Sparks, with an offset of 3 pixels this time708TempValue0 = 0x30000709CallFunction(BossPlatform_SpawnLandingSparks)710711#platform: Use_Haptics712HapticEffect(97, 0, 0, 0)713#endplatform714end if715716// Carry Eggman along, to be 28 pixels above this Platform's Position717Object[-1].YPos = Object.YPos718Object[-1].YPos -= 0x1C0000719720// And his Back Panel, too721Object[-2].YPos = Object.YPos722723CallFunction(BossPlatform_Conveyor_Update)724break725726case BOSSPLATFORM_FIGHT_3727CallFunction(BossPlatform_Conveyor_Update)728729if Object.Grind > 2399730Object.State++731Object[-1].State = EGGMAN_PANICK_JUMP732Object[-1].Frame = 0733Object[-1].Timer = 0734end if735736if Object.SparksTimer > 47737Object.SparksTimer %= 48738739// Create a Boss Spark Object, with starting values of:740// - X Position of 24 pixels right of this Boss Platform741// - Y Position of 11 pixels below this Boss Platform742// - X Velocity of 1 pixel left per frame743CreateTempObject(TypeName[Boss Spark], BOSSSPARK_GRIND, Object.XPos, Object.YPos)744Object[TempObjectPos].XPos += 0x180000745Object[TempObjectPos].YPos += 0xB0000746Object[TempObjectPos].XVelocity = -0x10000747end if748break749750case BOSSPLATFORM_FALL_4751752// Apply a falling acceleration of roughly 0.09 pixels per frame753Object.YVelocity += 0x1800754755Object.YPos += Object.YVelocity756757// Check for Ground Collision, now with an even smaller Y Offset of 7 pixels758ObjectTileCollision(CSIDE_FLOOR, 0, 7, 0)759760if CheckResult == true761Screen.ShakeY = 4762763PlayStageSfx(SFX_S_IMPACT1, false)764765// Just like every other time, bounce one time upon initially landing766if Object.Bounces < 1767Object.Bounces++768769// Minimize & flip the Y Velocity770Object.YVelocity >>= 1771FlipSign(Object.YVelocity)772else773Object.State = BOSSPLATFORM_FIGHT_4774Object.Bounces = 0775Object.Grind = 0776end if777778// Spawn some Landing Sparks, with an offset of 3 pixels up779TempValue0 = -0x30000780CallFunction(BossPlatform_SpawnLandingSparks)781782#platform: Use_Haptics783HapticEffect(97, 0, 0, 0)784#endplatform785end if786787// Carry Eggman along, keeping him 28 pixels above this Object's Base Y Position788Object[-1].YPos = Object.YPos789Object[-1].YPos -= 0x1C0000790791// And then Eggman's control Panel too, he needs something to hold on to!792Object[-2].YPos = Object.YPos793794CallFunction(BossPlatform_Conveyor_Update)795break796797case BOSSPLATFORM_FIGHT_4798// We're in the final strech now!799800CallFunction(BossPlatform_Conveyor_Update)801802if Object.Grind > 2399803Object.State++804805// Make Robotnik start running away806Object[-1].State = EGGMAN_FLEE807Object[-1].Frame = 0808Object[-1].Timer = 0809810// Move him to draw ontop of this Boss Platform Object and all its other accessories811Object[-1].DrawOrder = 4812813// Move this Object back to its Base Position, and move the Boss Back Panel with it too814Object.XPos = Object.BaseX815Object[-2].XPos = Object.XPos816817Object.Timer = 0818end if819820if Object.SparksTimer > 47821Object.SparksTimer %= 48822823// Create a Boss Spark, with properties of:824// - 24 pixels left right from this Platform825// - 3 pixels below this Platform Object826// - Velocity of 1 pixel left per frame827CreateTempObject(TypeName[Boss Spark], BOSSSPARK_GRIND, Object.XPos, Object.YPos)828Object[TempObjectPos].XPos += 0x180000829Object[TempObjectPos].YPos += 0x30000830Object[TempObjectPos].XVelocity = -0x10000831end if832break833834case BOSSPLATFORM_EGGFLEE835if Object.Timer == 19836Object.Timer = 0837TempValue0 = -0x30000838CallFunction(BossPlatform_SpawnLandingSparks)839end if840841Object.Timer++842843if Object.BeltSpeed > 0844// If the Belt's still running, then slow it down845846CallFunction(BossPlatform_Conveyor_WindDown)847848// Restore Stage Bounds, in a way to make the camera pan to the right849// -> The full restoring of those bounds is done right below, with the Boss Platform's OldBoundsR850Stage.XBoundary2 += 4851else852853#platform: Use_Origins854// Some addditions for Origins855856// Let the game know that we've "killed" the boss857// Poor Robotnik, I hope he's alright...858EngineCallback(NOTIFY_KILL_BOSS)859860// Tell HE2 that the boss fight ended861game.callbackParam0 = true862EngineCallback(NOTIFY_BOSS_END)863864if game.playMode == BOOT_PLAYMODE_BOSSRUSH865// In Boss Rush, stop the music since we're getting sent to the next zone now866867StopMusic()868end if869#endplatform870871// Restore the Stage's Bounds to normal872Stage.NewXBoundary2 = Object[-3].OldBoundsR873874Object.State++875Object.Timer = 0876877// Both this object and BossTop uses alpha for it's red flashing878Object.InkEffect = INK_ALPHA879Object[-3].InkEffect = INK_ALPHA880881#platform: Use_Haptics882HapticEffect(97, 0, 0, 0)883#endplatform884end if885break886887case BOSSPLATFORM_EXPLODE888889// Oscillate the red flashing of this & the Boss Top's red flashing890891Sin(TempValue0, Object.Timer)892893TempValue0 /= 3894if TempValue0 < 0895// Stay in the positives here896FlipSign(TempValue0)897end if898899if TempValue0 > 255900// Cap at 255901TempValue0 = 255902end if903904// Set this and the Boss Top's Alpha to be the same905Object.Alpha = TempValue0906Object[-3].Alpha = TempValue0907908TempValue0 = Object.Timer909TempValue0 &= 127910911if TempValue0 == 0912// Create an Explosion, 32 pixels left and 16 pixels above this Object913914CreateTempObject(TypeName[Boss Explosion], 0, Object.XPos, Object.YPos)915Object[TempObjectPos].XPos -= 0x200000916Object[TempObjectPos].YPos -= 0x100000917end if918919if TempValue0 == 32920// Create an Explosion, now 16 pixels left from this object921922CreateTempObject(TypeName[Boss Explosion], 0, Object.XPos, Object.YPos)923Object[TempObjectPos].XPos -= 0x100000924end if925926if TempValue0 == 64927// Create an Explosion, this one 32 pixels to the right and 16 pixels above this Object928929CreateTempObject(TypeName[Boss Explosion], 0, Object.XPos, Object.YPos)930Object[TempObjectPos].XPos += 0x200000931Object[TempObjectPos].YPos -= 0x100000932end if933934TempValue0 = Object.Timer935TempValue0 &= 31936if TempValue0 == 0937PlaySfx(SFX_G_EXPLOSION, false)938end if939940Object.Timer += 8941if Object.Timer > 960942Player.Score += 1000943CreateTempObject(TypeName[Fade Music], FADEMUSIC_TO_LEVEL, 0, 0)944945// Clear all of the Boss's Objects946947// Let's start with this one - the Boss Platform948TempValue0 = Object.EntityNo949ResetObjectEntity(TempValue0, TypeName[Blank Object], 0, 0, 0)950951// Then, the Eggman Object952TempValue0--953ResetObjectEntity(TempValue0, TypeName[Blank Object], 0, 0, 0)954955// Then, the Boss Back Panel Object956TempValue0--957ResetObjectEntity(TempValue0, TypeName[Blank Object], 0, 0, 0)958959// After that comes the Boss Top Object960TempValue0--961ResetObjectEntity(TempValue0, TypeName[Blank Object], 0, 0, 0)962963// Then the Bomb Carrier Object964TempValue0--965ResetObjectEntity(TempValue0, TypeName[Blank Object], 0, 0, 0)966967// And finally, the Boss Bomb Object968TempValue0--969ResetObjectEntity(TempValue0, TypeName[Blank Object], 0, 0, 0)970971// The Object after all those, the Boss Spikes Object, is left alone972end if973break974975end switch976977end sub978979980sub ObjectPlayerInteraction981982if Object.State == BOSSPLATFORM_IDLE983// See if the Player's hit the currently static machine984985PlayerObjectCollision(C_TOUCH, -32, -48, 32, 32)986987if CheckResult == true988FlipSign(Player.XVelocity)989FlipSign(Player.YVelocity)990TempValue0 = Player.XVelocity991TempValue1 = Player.YVelocity992Player.Speed = TempValue0993Player.XVelocity = TempValue0994Player.YVelocity = TempValue1995Object.State = BOSSPLATFORM_SHAKE996997// Set the Object's Base/Origin Position, this needs to be stored as the Object will998// slightly shake horizontally during the Boss Fight999Object.BaseX = Object.XPos10001001// Tell the Boss Top to start moving the stage boundary left1002Object[-3].State = BOSSTOP_MOVEBOUNDS10031004// Made the Bomb Carrier start up, as well1005Object[-4].State = BOMBCARRIER_SLIDERIGHT10061007// Ka-thunk!1008PlayStageSfx(SFX_S_BOSSHIT, false)10091010#platform: Use_Haptics1011HapticEffect(97, 0, 0, 0)1012#endplatform10131014#platform: Use_Origins1015if Stage.PlayerListPos == PLAYER_KNUCKLES1016if Player.Animation == ANI_GLIDING1017Player.Animation = ANI_GLIDING_DROP1018Player.State = Player_State_GlideDrop1019end if1020end if1021#endplatform1022end if1023else1024// Just act as a box for the Player1025// -> All the actual cool, fun stuff is done over in ObjectMain instead1026PlayerObjectCollision(C_BOX, -32, -256, 32, 24)1027end if10281029end sub103010311032sub ObjectDraw10331034// Each State gets its own Drawing routine1035// -> For the most part, these are all the same, but with different latter frames for the Boss Platform's bottom1036switch Object.State1037case BOSSPLATFORM_IDLE1038case BOSSPLATFORM_SHAKE1039case BOSSPLATFORM_FALL_11040DrawSprite(0)1041DrawSprite(1)1042break10431044case BOSSPLATFORM_FIGHT_11045DrawSprite(0)1046DrawSprite(2)1047break10481049case BOSSPLATFORM_FALL_21050case BOSSPLATFORM_FIGHT_21051DrawSprite(0)1052DrawSprite(3)1053break10541055case BOSSPLATFORM_FALL_31056case BOSSPLATFORM_FIGHT_31057DrawSprite(0)1058DrawSprite(4)1059break10601061case BOSSPLATFORM_FALL_41062case BOSSPLATFORM_FIGHT_41063DrawSprite(0)1064DrawSprite(5)1065break10661067case BOSSPLATFORM_EGGFLEE1068DrawSprite(0)1069DrawSprite(5)10701071// Now that Robotnik's fleeing, he's taking the Control Panel sprite with him,1072// so draw our own here1073DrawSprite(6)1074break10751076case BOSSPLATFORM_EXPLODE1077DrawSprite(0)1078DrawSprite(5)1079DrawSprite(6)10801081// Draw the Red Flashing Frame, with an Alpha of whatever Object.Alpha is set to1082DrawSpriteFX(7, FX_INK, Object.XPos, Object.YPos)1083break10841085end switch10861087end sub108810891090sub ObjectStartup10911092LoadSpriteSheet("R5/Objects2.gif")10931094// Boss Platform Frames10951096// Main Boss Platform Frame1097SpriteFrame(-32, -48, 64, 48, 1, 50)10981099// Perfect, Ungrinded Bottom Frame1100SpriteFrame(-32, 0, 64, 32, 1, 98)11011102// Gently Grinded Bottom Frame1103SpriteFrame(-32, 0, 64, 32, 1, 131)11041105// Slightly move Grinded Frame1106SpriteFrame(-32, 0, 64, 24, 1, 164)11071108// Considerably more Grinded Frame1109SpriteFrame(-32, 0, 64, 16, 1, 189)11101111// Heavily Grinded Frame (- there's almost nothing left now!)1112SpriteFrame(-32, 0, 64, 8, 1, 206)11131114// Control Panel Frame (normally part of Eggman's sprite itself, for the most part)1115SpriteFrame(-32, -48, 26, 24, 1, 215)11161117// Flashing Red Boss Platform Frame1118SpriteFrame(-32, -48, 64, 56, 75, 50)11191120end sub112111221123// ========================1124// Editor Subs1125// ========================11261127sub RSDKDraw1128DrawSprite(0)1129end sub113011311132sub RSDKLoad1133LoadSpriteSheet("R5/Objects2.gif")1134SpriteFrame(-32, -48, 64, 48, 1, 50)1135SpriteFrame(-32, 0, 64, 32, 1, 98)11361137SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")1138end sub113911401141