Path: blob/main/Scripts/R5/RisePlatform.txt
1319 views
//---------------Sonic CD Rise Platform Script----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Pressed6#alias Object.Value1 : Object.PlatformY7#alias Object.Value2 : Object.ChangeY8#alias Object.Value3 : Object.YVelocity9#alias Object.Value4 : Object.StartPosY10#alias Object.Value5 : Object.Timer1112// States13#alias 0 : RISEPLATFORM_AWAITPLAYER14#alias 1 : RISEPLATFORM_PRELAUNCH15#alias 2 : RISEPLATFORM_LAUNCH16#alias 3 : RISEPLATFORM_RISE17#alias 4 : RISEPLATFORM_HALT18#alias 5 : RISEPLATFORM_ARRIVED1920// Priority21#alias 1 : PRIORITY_ACTIVE22#alias 3 : PRIORITY_XBOUNDS232425sub ObjectMain2627switch Object.State28case RISEPLATFORM_AWAITPLAYER29Object.ChangeY = 03031if Object.Pressed == true32// If the Player's stepped onto the Platform, then get ready3334Object.State = RISEPLATFORM_PRELAUNCH3536// Make the Object always active, needed for its respawn restoring method37Object.Priority = PRIORITY_ACTIVE3839Object.YVelocity = 040Object.Timer = 041end if42break4344case RISEPLATFORM_PRELAUNCH45// Dip for a moment before taking off4647Object.ChangeY = Object.YVelocity4849if Object.Timer < 850Object.Timer++51else52Object.Timer = 053Object.State++54end if55break5657case RISEPLATFORM_LAUNCH5859// If the Object hasn't yet reached a speed of 5 pixels per frame, then...60if Object.YVelocity > -0x5000061// Speed it up at a rate of 0.0625 pixels per frame upwards62Object.YVelocity -= 0x100063else64// Ideal Velocity reached, switch to the timer-based State now65Object.State++66end if6768Object.ChangeY = Object.YVelocity69break7071case RISEPLATFORM_RISE72if Object.Timer < 8073// Just rise for about a second and some74Object.Timer++75else76Object.Timer = 077Object.State++78end if7980Object.ChangeY = Object.YVelocity81break8283case RISEPLATFORM_HALT8485// Until the Object's fully stopped, decelerate at a rate of 0.0625 pixels per frame86if Object.YVelocity < 087Object.YVelocity += 0x100088else89// Ding! - And now we've arrived!90Object.State++91end if9293Object.ChangeY = Object.YVelocity94break9596case RISEPLATFORM_ARRIVED97// From here, the Object just acts as a normal Platform9899if Object.Pressed == true100if Object.PlatformY < 16101Object.PlatformY++102TempValue0 = Object.PlatformY103TempValue0 &= 3104if TempValue0 == 3105Object.ChangeY = 0x10000106else107Object.ChangeY = 0108end if109else110Object.ChangeY = 0111end if112else113if Object.PlatformY > 0114Object.PlatformY--115TempValue0 = Object.PlatformY116TempValue0 &= 3117if TempValue0 == 3118Object.ChangeY = -0x10000119else120Object.ChangeY = 0121end if122else123Object.ChangeY = 0124end if125end if126break127128end switch129130// If the Object is Out Of Bounds, then...131if Object.OutOfBounds == true132133// First, backup the object's current Y Position134TempValue0 = Object.YPos135136// Then, move the Object back to its starting Y Position137Object.YPos = Object.StartPosY138139// See if this new, original position is Out Of Bounds too140if Object.OutOfBounds == true141142// If it is, then restore the Object to its original state (incl. keeping it at its starting position, from above)143Object.PlatformY = 0144Object.State = RISEPLATFORM_AWAITPLAYER145146else147148// That spot is still in bounds, so in order to prevent teleporting in front of the Player,149// Move the Platform back to its current Y Position150Object.YPos = TempValue0151152end if153end if154155// Reset for next frame156Object.Pressed = false157158end sub159160161sub ObjectPlayerInteraction162163PlayerObjectCollision(C_PLATFORM, -16, -16, 16, 12)164165if CheckResult == true166// If the Player is on the Platform, then move the Player along with it and let the Platform Object know167Object.Pressed = true168Player.YPos += Object.ChangeY169end if170171end sub172173174sub ObjectDraw175176// Movement is done here rather than ObjectMain because of the ObjectPlayerInteraction inbetween177Object.YPos += Object.ChangeY178179// And now just draw the Platform at its Position, no DrawSpriteXY needed here or anything!180DrawSprite(0)181182end sub183184185sub ObjectStartup186LoadSpriteSheet("R5/Objects.gif")187188// Small Platform Frame189SpriteFrame(-16, -16, 32, 32, 1, 51)190191// Cycle through all Rise Platform Objects in the Stage192ArrayPos0 = 32193while ArrayPos0 < 1056194if Object[ArrayPos0].Type == TypeName[Rise Platform]195196// Store the Platform's starting Y Position197Object[ArrayPos0].StartPosY = Object[ArrayPos0].YPos198199Object[ArrayPos0].Priority = PRIORITY_XBOUNDS200201end if202203ArrayPos0++204loop205206end sub207208209// ========================210// Editor Subs211// ========================212213sub RSDKDraw214DrawSprite(0)215216if Editor.ShowGizmos == true217Editor.DrawingOverlay = true218219// Draw the Platform's destination220221TempValue0 = Object.YPos222TempValue0 -= 53084160223DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue0, 255, 255, 255)224225Editor.DrawingOverlay = false226end if227end sub228229230sub RSDKLoad231LoadSpriteSheet("R5/Objects.gif")232SpriteFrame(-16, -16, 32, 32, 1, 51)233234SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")235end sub236237238