Path: blob/main/Scripts/Mission/MechaBu2.txt
1319 views
//-----------------Sonic CD Mecha Bu 2 Script-----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//3//-------Used on Mission "M110 - Extreme! Gotta Go Fast"------//45// Aliases6#alias Object.Value0 : Object.Timer78#alias Object.Value2 : Object.XOriginPos9#alias Object.Value3 : Object.YOriginPos10#alias Object.Value4 : Object.HornTimer11#alias Object.Value5 : Object.SFXTimer1213#alias Object.PropertyValue : Object.Quality1415// States16#alias 0 : MECHABU2_FINDGROUND17#alias 1 : MECHABU2_BACKTRACK18#alias 2 : MECHABU2_ADVANCE1920// SFX Aliases21#alias 1 : SFX_S_BUZZSAW2223// Collision Sides24#alias 0 : CSIDE_FLOOR2526// Badnik Quality / Property Values27#alias 0 : GOOD_QUALITY28#alias 1 : BAD_QUALITY293031sub ObjectMain32switch Object.State33case MECHABU2_FINDGROUND34// See if there's any ground to be found at the Bu's current position35ObjectTileCollision(CSIDE_FLOOR, 0, 15, 0)3637if CheckResult == true38// Floor detected, go to the normal movement states now3940Object.State = MECHABU2_BACKTRACK41else42// The Bu's still in the air, so move a pixel down4344Object.YPos += 0x1000045end if4647if Object.State == MECHABU2_FINDGROUND // But you're already there...4849ArrayPos0 = 3250while ArrayPos0 < 105651if Object[ArrayPos0].PropertyValue <= 152TempValue3 = -1653else54TempValue3 = -3255TempValue3 *= Object[ArrayPos0].PropertyValue56TempValue3 += 1657end if5859TempValue4 = 166061TempValue0 = Object[ArrayPos0].iXPos62TempValue0 -= Object.iXPos6364CheckGreater(TempValue0, TempValue3)65TempValue1 = CheckResult66CheckLower(TempValue0, TempValue4)67TempValue1 &= CheckResult68if TempValue1 == true69TempValue2 = Object[ArrayPos0].iYPos70TempValue1 = Object.iYPos71TempValue1 += 1672TempValue2 -= TempValue173CheckGreater(TempValue2, -16)74TempValue1 = CheckResult75CheckLower(TempValue2, 15)76TempValue1 &= CheckResult77if TempValue1 == true78Object.iYPos = Object[ArrayPos0].iYPos79Object.iYPos -= 3280Object.State = MECHABU2_BACKTRACK81ArrayPos0 = 200082end if83end if84ArrayPos0++85loop86end if87break8889case MECHABU2_BACKTRACK90if Object.Timer < 41691Object.Timer++9293// Move 0.3125 pixels right (opposite of the direction the Bu's currently towards)94Object.XPos += 0x500095else96// Change direction, start going ahead now9798Object.Timer = 099Object.State = MECHABU2_ADVANCE100end if101102// Stay with the ground even when going backwards, quite the fancy moonwalk!103ObjectTileGrip(CSIDE_FLOOR, 0, 15, 0)104break105106case MECHABU2_ADVANCE107if Object.Timer < 416108Object.Timer++109110// Move 0.3125 pixels to the left (in the direction the Bu is facing)111Object.XPos -= 0x5000112else113// Change direction once again, start going backwards114115Object.Timer = 0116Object.State = MECHABU2_BACKTRACK117end if118119// Track the ground, the Bu should always be grounded120ObjectTileGrip(CSIDE_FLOOR, 0, 15, 0)121break122123end switch124125// See if the Bu should become a Flower instead126CallFunction(StageSetup_CheckGoodFuture)127end sub128129130sub ObjectPlayerInteraction131132// Huh, it doesn't seem like the Mecha Bu ever reaches state 3, so this check133// is effectivly useless134if Object.State < 3135136// Check collision with the main Mecha Bu137PlayerObjectCollision(C_ENEMY,-16,-14,16,14)138if CheckResult == true139CallFunction(Player_BadnikBreak)140end if141142// Make sure the Bu hasn't become a Flower (destroyed) before checking for other parts143if Object.Type == TypeName[MechaBu2]144if Object.HornTimer > 59145if Object.Direction == FACING_RIGHT146PlayerObjectCollision(C_TOUCH, -30, -32, -8, 0)147else148PlayerObjectCollision(C_TOUCH, 8, -32, 30, 0)149end if150if CheckResult == true151CallFunction(Player_Hit)152end if153else154if Object.Direction == FACING_RIGHT155PlayerObjectCollision(C_TOUCH, -36, -16, -14, 16)156else157PlayerObjectCollision(C_TOUCH, 14, -16, 36, 16)158end if159if CheckResult == true160CallFunction(Player_Hit)161end if162end if163end if164end if165end sub166167168sub ObjectDraw169170Object.SFXTimer++171if Object.SFXTimer == 48172Object.SFXTimer = 0173PlayStageSfx(SFX_S_BUZZSAW, false)174end if175176TempValue0 = Object.AnimationTimer177TempValue0 /= 3178179Object.AnimationTimer++180Object.AnimationTimer %= 6181182if Object.HornTimer > 59183TempValue0 += 5184DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)185DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)186DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos)187else188TempValue0 += 2189DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)190DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)191DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)192end if193194Object.HornTimer++195Object.HornTimer %= 120196end sub197198199sub ObjectStartup200201LoadSpriteSheet("R8/Objects.gif")202203SpriteFrame(-24, -16, 48, 32, 173, 140) // #0 - Mecha Bu body204205SpriteFrame(-23, -17, 16, 24, 156, 177) // #1 - Mecha Bu Horn frame 0206SpriteFrame(-31, -32, 24, 32, 230, 1) // #2 - Mecha Bu Saw frame 0207SpriteFrame(-31, -32, 24, 32, 173, 173) // #3 - Mecha Bu Saw frame 1208209SpriteFrame(-33, -8, 24, 16, 131, 177) // #4 - Mecha Bu Horn frame 1210SpriteFrame(-37, -16, 24, 32, 230, 1) // #5 - Mecha Bu Saw frame 0211SpriteFrame(-37, -16, 24, 32, 173, 173) // #6 - Mecha Bu Saw frame 1212213// Cycle through all Objects in the level and find all Mecha Bu's214ArrayPos0 = 32215while ArrayPos0 < 1056216if Object[ArrayPos0].Type == TypeName[Mecha Bu2]217218// Store their its starting position219// (These don't ever seem to be used, though?)220221Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos222Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos223224if Object[ArrayPos0].Quality == BAD_QUALITY225Object[ArrayPos0].Direction = FACING_LEFT226end if227end if228229ArrayPos0++230loop231end sub232233234// ========================235// Editor Subs236// ========================237238sub RSDKDraw239DrawSprite(0)240end sub241242243sub RSDKLoad244LoadSpriteSheet("R8/Objects.gif")245246SpriteFrame(-24, -16, 48, 32, 173, 140) // #0 - Mecha Bu body247248SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")249end sub250251252253254