Path: blob/main/Scripts/R5/BreakWall.txt
1319 views
//---------------Sonic CD Breakable Wall Script---------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.XVelocity6#alias Object.Value1 : Object.YVelocity78// The object isn't cleared upon being destroyed, it's just given a new state and made hidden instead...9#alias Object.State : Object.Destroyed1011// HUD Alias12#alias Object[24].PropertyValue : HUD.CurrentTimePeriod1314// Time Period Aliases15#alias 0 : TIME_PRESENT16#alias 1 : TIME_PAST17#alias 2 : TIME_GOOD_FUTURE18#alias 3 : TIME_BAD_FUTURE1920// Global SFX21#alias 22 : SFX_G_EXPLOSION2223// Priority24#alias 0 : PRIORITY_BOUNDS25#alias 1 : PRIORITY_ACTIVE2627// Property Values28#alias 0 : BREAKWALL29#alias 1 : BREAKWALL_DEBRIS_130#alias 2 : BREAKWALL_DEBRIS_231#alias 3 : BREAKWALL_DEBRIS_332#alias 4 : BREAKWALL_DEBRIS_433#alias 5 : BREAKWALL_DEBRIS_534#alias 6 : BREAKWALL_DEBRIS_635#alias 7 : BREAKWALL_DEBRIS_736#alias 8 : BREAKWALL_DEBRIS_8373839sub ObjectMain4041if Object.PropertyValue > 04243// Update Movements44Object.XPos += Object.XVelocity45Object.YPos += Object.YVelocity4647// Apply a Gravity of 0.25 px per frame48Object.YVelocity += 0x40004950if Object.OutOfBounds == true51// Unload when no longer needed52Object.Type = TypeName[Blank Object]53end if5455else56if Object.Destroyed == true5758// Check to see if the Player's *not* within this giant range59PlayerObjectCollision(C_TOUCH, -384, -256, 384, 256)6061if CheckResult == false6263// The Player is nowhere near this object, so it's safe to reset since it's likely out of view now64Object.Destroyed = false65Object.Priority = PRIORITY_BOUNDS6667end if6869// Why a standard Object.OutOfBounds check isn't used is beyond me...7071end if72end if7374end sub757677sub ObjectPlayerInteraction7879if Object.PropertyValue < 180if Object.Destroyed == false81CheckResult = false82if Player.Animation == ANI_JUMPING83CheckResult = true84end if85#platform: Use_Origins86if Stage.PlayerListPos == PLAYER_KNUCKLES87CheckResult = true88end if89if Stage.PlayerListPos == PLAYER_AMY90if Player.Animation == ANI_HAMMER_JUMP91CheckResult = true92end if93if Player.Animation == ANI_HAMMER_DASH94CheckResult = true95end if96end if97#endplatform98if CheckResult == true99#platform: Use_Origins100PlayerObjectCollision(C_ENEMY, -18, -48, 18, 48)101#endplatform102#platform: Use_Standalone103PlayerObjectCollision(C_TOUCH, -18, -48, 18, 48)104#endplatform105if CheckResult == true106Object.Destroyed = true107Object.Priority = PRIORITY_ACTIVE108PlaySfx(SFX_G_EXPLOSION, false)109110// Spawn all the Wall Fragments111// - TempValue1 is left position (8 pixels left from this object's position)112// - TempValue2 is right position (8 pixels right from this object's position)113// - TempValue3 is Y Position, starting 24 pixels from this object's position114115TempValue1 = Object.XPos116TempValue1 -= 0x80000117118TempValue2 = Object.XPos119TempValue2 += 0x80000120121TempValue3 = Object.YPos122TempValue3 -= 0x180000123124CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_1, TempValue1, TempValue3)125Object[TempObjectPos].XVelocity = -0x10000126Object[TempObjectPos].YVelocity = -0x20000127Object[TempObjectPos].DrawOrder = 5128129CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_2, TempValue2, TempValue3)130Object[TempObjectPos].XVelocity = 0x10000131Object[TempObjectPos].YVelocity = -0x20000132Object[TempObjectPos].DrawOrder = 5133134TempValue3 += 0x100000135136CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_3, TempValue1, TempValue3)137Object[TempObjectPos].XVelocity = -0x20000138Object[TempObjectPos].YVelocity = -0x10000139Object[TempObjectPos].DrawOrder = 5140141CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_4, TempValue2, TempValue3)142Object[TempObjectPos].XVelocity = 0x20000143Object[TempObjectPos].YVelocity = -0x10000144Object[TempObjectPos].DrawOrder = 5145146TempValue3 += 0x100000147148CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_5, TempValue1, TempValue3)149Object[TempObjectPos].XVelocity = -0x40000150Object[TempObjectPos].YVelocity = 0151Object[TempObjectPos].DrawOrder = 5152153CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_6, TempValue2, TempValue3)154Object[TempObjectPos].XVelocity = 0x40000155Object[TempObjectPos].YVelocity = 0156Object[TempObjectPos].DrawOrder = 5157158TempValue3 += 0x100000159160CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_7, TempValue1, TempValue3)161Object[TempObjectPos].XVelocity = -0x20000162Object[TempObjectPos].YVelocity = 0x10000163Object[TempObjectPos].DrawOrder = 5164165CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_8, TempValue2, TempValue3)166Object[TempObjectPos].XVelocity = 0x20000167Object[TempObjectPos].YVelocity = 0x10000168Object[TempObjectPos].DrawOrder = 5169end if170else171PlayerObjectCollision(C_BOX, -16, -48, 16, 48)172PlayerObjectCollision(C_TOUCH, -16, -48, 16, 48)173if CheckResult == true174if Player.XPos < Object.XPos175Player.XPos = Player.CollisionLeft176Player.XPos <<= 16177Player.XPos += Object.XPos178Player.XPos -= 0x100000179else180Player.XPos = Player.CollisionRight181Player.XPos <<= 16182Player.XPos += Object.XPos183Player.XPos += 0x100000184end if185end if186end if187end if188end if189190end sub191192193sub ObjectDraw194195if Object.Destroyed == false196DrawSprite(Object.PropertyValue)197end if198199end sub200201202sub ObjectStartup203204switch HUD.CurrentTimePeriod205case TIME_PRESENT206LoadSpriteSheet("R5/Objects.gif")207SpriteFrame(-16, -48, 32, 96, 223, 141)208TempValue0 = 223209TempValue1 = 239210TempValue2 = 141211break212213case TIME_PAST214LoadSpriteSheet("R5/Objects3.gif")215SpriteFrame(-16, -48, 32, 96, 132, 1)216TempValue0 = 132217TempValue1 = 148218TempValue2 = 1219break220221case TIME_GOOD_FUTURE222LoadSpriteSheet("R5/Objects3.gif")223SpriteFrame(-16, -48, 32, 96, 66, 1)224TempValue0 = 66225TempValue1 = 82226TempValue2 = 1227break228229case TIME_BAD_FUTURE230LoadSpriteSheet("R5/Objects3.gif")231SpriteFrame(-16, -48, 32, 96, 99, 1)232TempValue0 = 99233TempValue1 = 115234TempValue2 = 1235break236237end switch238239TempValue2 += 16240SpriteFrame(-8, -8, 16, 16, TempValue0, TempValue2)241SpriteFrame(-8, -8, 16, 16, TempValue1, TempValue2)242243TempValue2 += 16244SpriteFrame(-8, -8, 16, 16, TempValue0, TempValue2)245SpriteFrame(-8, -8, 16, 16, TempValue1, TempValue2)246247TempValue2 += 16248SpriteFrame(-8, -8, 16, 16, TempValue0, TempValue2)249SpriteFrame(-8, -8, 16, 16, TempValue1, TempValue2)250251TempValue2 += 16252SpriteFrame(-8, -8, 16, 16, TempValue0, TempValue2)253SpriteFrame(-8, -8, 16, 16, TempValue1, TempValue2)254255end sub256257258// ========================259// Editor Subs260// ========================261262sub RSDKDraw263DrawSprite(0)264265if Editor.ShowGizmos == true266TempValue0 = Object.iXPos267TempValue0 -= 16268TempValue1 = Object.iYPos269TempValue1 -= 48270271DrawRectOutline(TempValue0, TempValue1, 32, 96, 255, 255, 255, 255)272end if273274// TODO: perhaps it would be cool to show the deactivation hitbox, but at the same time, is it even that important anways?275end sub276277278sub RSDKLoad279LoadSpriteSheet("R5/Objects.gif")280281// TODO: support other time periods282// Surely there's a better way to do it than a load of unique and boring checkCurrentStageFolder checks?283SpriteFrame(-16, -48, 32, 96, 223, 141)284285286// Although used by the object, it shouldn't be set from the editor287SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")288end sub289290291