Path: blob/main/Scripts/R1/CLedge5.txt
1319 views
//---------------Sonic CD Crumble Ledge 5 Script--------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.HitboxLeft6#alias Object.Value1 : Object.HitboxRight7#alias Object.Value2 : Object.Timer8#alias Object.Value3 : Object.Length9#alias Object.Value4 : Object.YVelocity1011// States12#alias 0 : CLEDGE5_IDLE13#alias 1 : CLEDGE5_DELAY_FROM_RIGHT14#alias 2 : CLEDGE5_DELAY_FROM_LEFT15#alias 3 : CLEDGE5_COLLAPSE_RIGHT16#alias 4 : CLEDGE5_COLLAPSE_LEFT17#alias 5 : CLEDGE5_RESTORE // Unused1819#alias 6 : CLEDGE5_DEBRIS2021// Stage SFX22#alias 0 : SFX_S_CRUMBLE2324// Priority25#alias 0 : PRIORITY_BOUNDS26#alias 1 : PRIORITY_ACTIVE272829sub ObjectMain30switch Object.State31case CLEDGE5_DELAY_FROM_RIGHT32if Object.Timer > 033Object.Timer--34else35PlayStageSfx(SFX_S_CRUMBLE, false)36Object.State = CLEDGE5_COLLAPSE_RIGHT37end if38break3940case CLEDGE5_DELAY_FROM_LEFT41if Object.Timer > 042Object.Timer--43else44PlayStageSfx(SFX_S_CRUMBLE, false)45Object.State = CLEDGE5_COLLAPSE_LEFT46end if47break4849case CLEDGE5_COLLAPSE_RIGHT50Object.Timer++51if Object.Timer == 1252Object.Timer = 053if Object.HitboxRight > Object.HitboxLeft5455Object.HitboxRight -= 1656TempValue0 = Object.HitboxRight57TempValue0 += 858TempValue0 <<= 1659TempValue0 += Object.XPos60CreateTempObject(TypeName[Crumble Ledge 5], 0, TempValue0, Object.YPos)61Object[TempObjectPos].State = CLEDGE5_DEBRIS62if Object.Length == 163Object[TempObjectPos].Frame = 464else65if Object.Length == Object.PropertyValue66Object[TempObjectPos].Frame = 267else68Object[TempObjectPos].Frame = 369end if70end if71Object.Length--72else73ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)74end if75end if76break7778case CLEDGE5_COLLAPSE_LEFT79Object.Timer++80if Object.Timer == 128182Object.Timer = 083if Object.HitboxLeft < Object.HitboxRight8485Object.HitboxLeft += 1686TempValue0 = Object.HitboxLeft87TempValue0 -= 888TempValue0 <<= 1689TempValue0 += Object.XPos9091CreateTempObject(TypeName[Crumble Ledge 5], 0, TempValue0, Object.YPos)92Object[TempObjectPos].State = CLEDGE5_DEBRIS9394if Object.Length == 195Object[TempObjectPos].Frame = 296else97if Object.Length == Object.PropertyValue98Object[TempObjectPos].Frame = 499else100Object[TempObjectPos].Frame = 3101end if102end if103Object.Length--104else105ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)106end if107end if108break109110case CLEDGE5_RESTORE111if Object.OutOfBounds == true112Object.State = CLEDGE5_IDLE113Object.Length = Object.PropertyValue114115Object.HitboxLeft = Object.PropertyValue116Object.HitboxLeft <<= 3117118Object.HitboxRight = Object.HitboxLeft119FlipSign(Object.HitboxLeft)120121Object.Priority = PRIORITY_BOUNDS122Object.Timer = 0123end if124break125126case CLEDGE5_DEBRIS127Object.YVelocity += 0x4000128if Object.YVelocity > 0129Object.YPos += Object.YVelocity130end if131132if Object.OutOfBounds == true133Object.Type = TypeName[Blank Object]134end if135break136137end switch138end sub139140141sub ObjectPlayerInteraction142if Object.State == CLEDGE5_IDLE143PlayerObjectCollision(C_PLATFORM, Object.HitboxLeft, -24, Object.HitboxRight, 16)144if CheckResult == true145Object.Timer = 1146Object.Priority = PRIORITY_ACTIVE147if Player.XPos > Object.XPos148Object.State = CLEDGE5_DELAY_FROM_RIGHT149else150Object.State = CLEDGE5_DELAY_FROM_LEFT151end if152end if153else154PlayerObjectCollision(C_PLATFORM, Object.HitboxLeft, -24, Object.HitboxRight, 16)155end if156end sub157158159160sub ObjectDraw161switch Object.State162case CLEDGE5_IDLE163case CLEDGE5_DELAY_FROM_RIGHT164case CLEDGE5_DELAY_FROM_LEFT165case CLEDGE5_COLLAPSE_RIGHT166TempValue0 = 0167TempValue1 = Object.HitboxLeft168TempValue1 <<= 16169TempValue1 += 0x80000170TempValue1 += Object.XPos171TempValue2 = Object.PropertyValue172TempValue2--173while TempValue0 < Object.Length174DrawSpriteXY(0, TempValue1, Object.YPos)175DrawSpriteXY(1, TempValue1, Object.YPos)176if TempValue0 == TempValue2177DrawSpriteXY(4, TempValue1, Object.YPos)178else179if TempValue0 == 0180DrawSpriteXY(2, TempValue1, Object.YPos)181else182DrawSpriteXY(3, TempValue1, Object.YPos)183end if184end if185TempValue0++186TempValue1 += 0x100000187loop188break189190case CLEDGE5_COLLAPSE_LEFT191TempValue0 = 0192TempValue1 = Object.HitboxRight193TempValue1 <<= 16194TempValue1 -= 0x80000195TempValue1 += Object.XPos196TempValue2 = Object.PropertyValue197TempValue2--198while TempValue0 < Object.Length199DrawSpriteXY(0, TempValue1, Object.YPos)200DrawSpriteXY(1, TempValue1, Object.YPos)201if TempValue0 == TempValue2202DrawSpriteXY(2, TempValue1, Object.YPos)203else204if TempValue0 == 0205DrawSpriteXY(4, TempValue1, Object.YPos)206else207DrawSpriteXY(3, TempValue1, Object.YPos)208end if209end if210TempValue0++211TempValue1 -= 0x100000212loop213break214215case CLEDGE5_DEBRIS216DrawSprite(0)217DrawSprite(1)218DrawSprite(Object.Frame)219break220end switch221end sub222223224sub ObjectStartup225LoadSpriteSheet("R1/Objects2.gif")226227SpriteFrame(-8, -40, 16, 48, 163, 1) // #0 - Ledge top228SpriteFrame(-8, 8, 16, 16, 190, 66) // #1 - Ledge middle229SpriteFrame(-8, 24, 16, 16, 82, 49) // #2 - Ledge bottom left230SpriteFrame(-8, 24, 16, 16, 98, 49) // #3 - Ledge bottom middle231SpriteFrame(-8, 24, 16, 16, 130, 49) // #4 - Ledge bottom right232233// original code have this below LoadSpriteSheet, moved for consistency with the rest234ArrayPos0 = 32235while ArrayPos0 < 1056236if Object[ArrayPos0].Type == TypeName[Crumble Ledge 5]237Object[ArrayPos0].Length = Object[ArrayPos0].PropertyValue238Object[ArrayPos0].HitboxLeft = Object[ArrayPos0].PropertyValue239Object[ArrayPos0].HitboxLeft <<= 3240Object[ArrayPos0].HitboxRight = Object[ArrayPos0].HitboxLeft241FlipSign(Object[ArrayPos0].HitboxLeft)242end if243ArrayPos0++244loop245end sub246247248// ========================249// Editor Subs250// ========================251252sub RSDKDraw253Object.Length = Object.PropertyValue254Object.HitboxLeft = Object.PropertyValue255Object.HitboxLeft <<= 3256Object.HitboxRight = Object.HitboxLeft257FlipSign(Object.HitboxLeft)258259TempValue0 = 0260TempValue1 = Object.HitboxLeft261TempValue1 <<= 16262TempValue1 += 0x80000263TempValue1 += Object.XPos264TempValue2 = Object.PropertyValue265TempValue2--266while TempValue0 < Object.Length267DrawSpriteXY(0, TempValue1, Object.YPos)268DrawSpriteXY(1, TempValue1, Object.YPos)269if TempValue0 == TempValue2270DrawSpriteXY(4, TempValue1, Object.YPos)271else272if TempValue0 == 0273DrawSpriteXY(2, TempValue1, Object.YPos)274else275DrawSpriteXY(3, TempValue1, Object.YPos)276end if277end if278TempValue0++279TempValue1 += 0x100000280loop281end sub282283284sub RSDKLoad285LoadSpriteSheet("R1/Objects2.gif")286287SpriteFrame(-8, -40, 16, 48, 163, 1) // #0 - Ledge top288SpriteFrame(-8, 8, 16, 16, 190, 66) // #1 - Ledge middle289SpriteFrame(-8, 24, 16, 16, 82, 49) // #2 - Ledge bottom left290SpriteFrame(-8, 24, 16, 16, 98, 49) // #3 - Ledge bottom middle291SpriteFrame(-8, 24, 16, 16, 130, 49) // #4 - Ledge bottom right292293SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")294end sub295296297