Path: blob/main/Scripts/R8/MechaBu.txt
1319 views
//-----------------Sonic CD Mecha Bu Script-------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Timer67#alias Object.Value2 : Object.XOriginPos8#alias Object.Value3 : Object.YOriginPos9#alias Object.Value4 : Object.HornTimer10#alias Object.Value5 : Object.SFXTimer1112#alias Object.PropertyValue : Object.Quality1314// States15#alias 0 : MECHABU_FINDGROUND16#alias 1 : MECHABU_BACKTRACK17#alias 2 : MECHABU_ADVANCE1819// Stage SFX20#alias 1 : SFX_S_BUZZSAW2122// Badnik Quality / Property Values23#alias 0 : GOOD_QUALITY24#alias 1 : BAD_QUALITY2526// Collision Sides27#alias 0 : CSIDE_FLOOR282930sub ObjectMain31switch Object.State32case MECHABU_FINDGROUND33// See if there's any ground to be found at the Bu's current position34ObjectTileCollision(CSIDE_FLOOR, 0, 15, 0)3536if CheckResult == true37// Floor detected, go to the normal movement states now3839Object.State = MECHABU_BACKTRACK40else41// The Bu's still in the air, so move a pixel down4243Object.YPos += 0x1000044end if45break4647case MECHABU_BACKTRACK48if Object.Timer < 41649Object.Timer++5051// Move 0.3125 pixels right (opposite of the direction the Bu's currently towards)52Object.XPos += 0x500053else54// Change direction, start going ahead now5556Object.Timer = 057Object.State = MECHABU_ADVANCE58end if5960// Stay with the ground even when going backwards, quite the fancy moonwalk!61ObjectTileGrip(CSIDE_FLOOR, 0, 15, 0)62break6364case MECHABU_ADVANCE65if Object.Timer < 41666Object.Timer++6768// Move 0.3125 pixels to the left (in the direction the Bu is facing)69Object.XPos -= 0x500070else71// Change direction once again, start going backwards7273Object.Timer = 074Object.State = MECHABU_BACKTRACK75end if7677// Track the ground, the Bu should always be grounded78ObjectTileGrip(CSIDE_FLOOR, 0, 15, 0)79break8081end switch8283// See if the Bu should become a Flower instead84CallFunction(StageSetup_CheckGoodFuture)8586end sub878889sub ObjectPlayerInteraction90// Huh, it doesn't seem like the Mecha Bu ever reaches state 3, so this check91// is effectivly useless92if Object.State < 39394// Check collision with the main Mecha Bu95#platform: Use_Standalone96PlayerObjectCollision(C_TOUCH, -16, -14, 16, 14)97#endplatform98#platform: Use_Origins99PlayerObjectCollision(C_ENEMY, -16, -14, 16, 14)100#endplatform101if CheckResult == true102CallFunction(Player_BadnikBreak)103end if104105// Make sure the Bu hasn't become a Flower (destroyed) before checking for other parts106if Object.Type == TypeName[Mecha Bu]107108// Bug Details:109// The PlayerObjectCollision boxes here for MechaBu are swapped for both positions of its horn.110// As to how this happened is unclear, most likely a programming oversight.111if Object.HornTimer > 59112PlayerObjectCollision(C_TOUCH, -30, -32, -8, 0) // Timer is over 59 frames, use "Lower" Hitbox113if CheckResult == true114CallFunction(Player_Hit)115end if116else117PlayerObjectCollision(C_TOUCH, -36, -16, -14, 16) // Timer is under 59 frames, use "Raised" Hitbox118if CheckResult == true119CallFunction(Player_Hit)120end if121end if122end if123end if124125end sub126127128sub ObjectDraw129Object.SFXTimer++130if Object.SFXTimer == 48131Object.SFXTimer = 0132PlayStageSfx(SFX_S_BUZZSAW, false)133end if134135TempValue0 = Object.AnimationTimer136TempValue0 /= 3137138Object.AnimationTimer++139Object.AnimationTimer %= 6140141if Object.Quality == GOOD_QUALITY142143// Bug Details:144// MechaBu has it's saw rendering behind its body. Another programming oversight...?145if Object.HornTimer > 59146TempValue0 += 5147DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos) // Draw Raised Saw Sprite148DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos) // Draw Body Sprite149DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos) // Draw Raised Arm Sprite150else151TempValue0 += 2152DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos) // Draw Lower Saw Sprite153DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos) // Draw Body Sprite154DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos) // Draw Lower Arm Sprite155end if156157// Start the HornTimer, reset every 120 frames158Object.HornTimer++159Object.HornTimer %= 120160else161TempValue0 += 5162DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos) // Draw Raised Saw Sprite163DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos) // Draw Body Sprite164DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos) // Draw Raised Arm Sprite165end if166167end sub168169170sub ObjectStartup171172LoadSpriteSheet("R8/Objects.gif")173174SpriteFrame(-24, -16, 48, 32, 173, 140) // #0 - Mecha Bu body175176SpriteFrame(-23, -17, 16, 24, 156, 177) // #1 - Mecha Bu Horn frame 0177SpriteFrame(-31, -32, 24, 32, 230, 1) // #2 - Mecha Bu Saw frame 0178SpriteFrame(-31, -32, 24, 32, 173, 173) // #3 - Mecha Bu Saw frame 1179180SpriteFrame(-33, -8, 24, 16, 131, 177) // #4 - Mecha Bu Horn frame 1181SpriteFrame(-37, -16, 24, 32, 230, 1) // #5 - Mecha Bu Saw frame 0182SpriteFrame(-37, -16, 24, 32, 173, 173) // #6 - Mecha Bu Saw frame 1183184// Cycle through all Objects in the level and find all Mecha Bu's185ArrayPos0 = 32186while ArrayPos0 < 1056187if Object[ArrayPos0].Type == TypeName[Mecha Bu]188189// Store their its starting position190// (These don't ever seem to be used, though?)191192Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos193Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos194195end if196197ArrayPos0++198loop199200end sub201202203// ========================204// Editor Subs205// ========================206207sub RSDKEdit208if Editor.ReturnVariable == true209switch Editor.VariableID210case EDIT_VAR_PROPVAL // Property Value211CheckResult = Object.PropertyValue212CheckResult &= 1213break214case 0 // condition215CheckResult = Object.PropertyValue216CheckResult &= 1217break218end switch219else220switch Editor.VariableID221case EDIT_VAR_PROPVAL // Property Value222Object.PropertyValue = Editor.VariableValue223Object.PropertyValue &= 1224break225case 0 // condition226Object.PropertyValue = Editor.VariableValue227Object.PropertyValue &= 1228break229end switch230end if231end sub232233sub RSDKDraw234if Object.PropertyValue == GOOD_QUALITY235DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos) // Draw Body Sprite236DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos) // Draw Lower Saw Sprite237DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos) // Draw Lower Arm Sprite238else239DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos) // Draw Body Sprite240DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos) // Draw Raised Saw Sprite241DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos) // Draw Raised Arm Sprite242end if243end sub244245246sub RSDKLoad247248LoadSpriteSheet("R8/Objects.gif")249250SpriteFrame(-24, -16, 48, 32, 173, 140) // #0 - Mecha Bu body251252SpriteFrame(-23, -17, 16, 24, 156, 177) // #1 - Mecha Bu Horn frame 0253SpriteFrame(-31, -32, 24, 32, 230, 1) // #2 - Mecha Bu Saw frame 0254SpriteFrame(-31, -32, 24, 32, 173, 173) // #3 - Mecha Bu Saw frame 1255256SpriteFrame(-33, -8, 24, 16, 131, 177) // #4 - Mecha Bu Horn frame 1257SpriteFrame(-37, -16, 24, 32, 230, 1) // #5 - Mecha Bu Saw frame 0258SpriteFrame(-37, -16, 24, 32, 173, 173) // #6 - Mecha Bu Saw frame 1259260AddEditorVariable("condition")261SetActiveVariable("condition")262AddEnumVariable("Good Quality", GOOD_QUALITY)263AddEnumVariable("Bad Quality", BAD_QUALITY)264end sub265266267