Path: blob/main/Scripts/R5/TubeSwitch.txt
1319 views
//----------------Sonic CD Tube Switch Script-----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.InTube6#alias Object.Value1 : Object.LedgeStop78// Player Aliases9#alias Player.Value2 : Player.RollAnimationSpeed10#alias Player.Value6 : Player.MinRollSpeed1112// Warp Star Aliases13#alias Object.Value0 : Object.Timer1415// Global SFX16#alias 6 : SFX_G_CHARGE17#alias 7 : SFX_G_RELEASE1819// Gravity20#alias 0 : GRAVITY_GROUND21#alias 1 : GRAVITY_AIR2223// Collision Modes24#alias 0 : CMODE_FLOOR25#alias 3 : CMODE_RWALL2627// Warp Destination28#alias 0 : WARPDEST_NONE293031// 0 - standard (biased towards right)32// 1 - standard (biased towards left)33// 2 - downards sender34// 3 - downards conveyer tube35// 4 - upwards conveyer tube36// 5 - XXXXXX37// 7 - vertical tunnel, middle38// 8 - vertical tunnel, endpoints394041sub ObjectPlayerInteraction42PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)4344#platform: Use_Origins45if CheckResult == true46if Stage.PlayerListPos == PLAYER_KNUCKLES47if Player.State == Player_State_LedgePullUp48CheckResult = false49Object.LedgeStop = true50end if51end if52end if53#endplatform5455if CheckResult == true56switch Object.PropertyValue57case 058#platform: Use_Origins59if Object.LedgeStop == true60Player.Speed = 161Object.LedgeStop = false62end if63#endplatform6465if Player.Speed >= 066if Player.State != Player_State_TubeRoll67PlaySfx(SFX_G_CHARGE, false)68end if69Player.Direction = FACING_RIGHT70Player.State = Player_State_TubeRoll71Player.Animation = ANI_JUMPING72Player.MinRollSpeed = 0x2000073if Player.Speed < 0x2000074Player.Speed = 0x2000075end if76else77if Player.Speed > -0x2000078Player.Speed = -0x2000079end if80Player.State = Player_State_Roll81Player.Animation = ANI_JUMPING82end if83break8485case 186if Player.Speed <= 087if Player.State != Player_State_TubeRoll88PlaySfx(SFX_G_CHARGE, false)89end if90Player.State = Player_State_TubeRoll91Player.Animation = ANI_JUMPING92Player.MinRollSpeed = 0x8000093if Player.Speed > -0x2000094Player.Speed = -0x2000095end if96else97if Player.Speed < 0x2000098Player.Speed = 0x2000099end if100Player.State = Player_State_Roll101Player.Animation = ANI_JUMPING102end if103break104105case 2106Player.Gravity = GRAVITY_AIR107Player.CollisionMode = CMODE_FLOOR108Player.XVelocity = 0109Player.Speed = 0110break111112case 3113if ConveyorBelt_Flag == 0114if Player.YPos < Object.YPos115if Player.State != Player_State_Static116PlaySfx(SFX_G_RELEASE, false)117end if118Player.State = Player_State_Static119if Player.Animation != ANI_JUMPING120Player.Animation = ANI_JUMPING121end if122Player.RollAnimationSpeed = 240123Player.Speed = 0124Player.Timer = 0125Player.XPos = Object.XPos126Player.XVelocity = 0127Player.YVelocity = 0xA0000128end if129else130if Player.State == Player_State_Static131#platform: Use_Origins132Player.State = Player_State_Air_NoDropDash133#endplatform134135#platform: Use_Standalone136Player.State = Player_State_Air137#endplatform138end if139end if140break141142case 4143if ConveyorBelt_Flag == 3144if Player.YPos > Object.YPos145// Hold the Player's Warp, if needed146// -> This section of code wasn't in the initial version of the game (Steam)147// and is only present in updated versions (mobile & Origins)148if Warp.Destination > WARPDEST_NONE149if Warp.Timer == 0150Warp.Timer = 1151152ResetObjectEntity(3, TypeName[Warp Star], 0, Player.XPos, Player.YPos)153Object[3].Timer = 7154Object[3].DrawOrder = 4155end if156end if157158if Player.State != Player_State_Static159PlaySfx(SFX_G_RELEASE, false)160end if161162Player.State = Player_State_Static163if Player.Animation != ANI_JUMPING164Player.Animation = ANI_JUMPING165end if166Player.RollAnimationSpeed = 240167Player.Speed = 0168Player.Timer = 0169Player.XPos = Object.XPos170Player.XVelocity = 0171Player.YVelocity = -0x80000172end if173else174if Player.State == Player_State_Static175#platform: Use_Origins176Player.State = Player_State_Air_NoDropDash177#endplatform178179#platform: Use_Standalone180Player.State = Player_State_Air181#endplatform182end if183end if184break185186case 5187if Player.YVelocity < 0188Player.Gravity = GRAVITY_GROUND189Player.State = Player_State_TubeRoll190Player.Animation = ANI_JUMPING191Player.CollisionMode = CMODE_RWALL192Player.Angle = 64193Player.Speed = -0xA0000194Player.MinRollSpeed = 0xA0000195end if196break197198case 6199if Player.YVelocity > 0200Player.Gravity = GRAVITY_GROUND201Player.State = Player_State_TubeRoll202Player.Animation = ANI_JUMPING203Player.CollisionMode = CMODE_RWALL204Player.Angle = 64205Player.Speed = Player.YVelocity206Player.MinRollSpeed = 0xA0000207end if208break209210case 7211Player.Gravity = GRAVITY_GROUND212Player.State = Player_State_TubeRoll213Player.Animation = ANI_JUMPING214if Player.CollisionMode != CMODE_RWALL215Player.CollisionMode = CMODE_RWALL216Player.Angle = 64217end if218219if ConveyorBelt_Flag == 3220Player.Speed = -0xD0000221Player.MinRollSpeed = 0xD0000222else223Player.Speed = 0xA0000224Player.MinRollSpeed = 0xA0000225end if226break227228case 8229if ConveyorBelt_Flag == 3230Player.Gravity = GRAVITY_GROUND231Player.State = Player_State_TubeRoll232Player.Animation = ANI_JUMPING233Player.CollisionMode = CMODE_RWALL234Player.Angle = 64235Player.Speed = -0xD0000236Player.MinRollSpeed = 0xD0000237if Object.InTube == false238PlaySfx(SFX_G_RELEASE, false)239end if240end if241break242end switch243244Object.InTube = true245else246Object.InTube = false247end if248end sub249250251// ========================252// Editor Subs253// ========================254255// TODO: gonna hold off on doing editor stuff for this one, wanna wait 'til i can actually see everything before i start doing stuff256// basic notes are labelled up above through if someone else wants to do it257258sub RSDKDraw259// Draw a square out of Tube Switch icons260261TempValue0 = Object.XPos262TempValue0 -= 0x80000263TempValue1 = Object.YPos264TempValue1 -= 0x80000265DrawSpriteXY(0, TempValue0, TempValue1)266TempValue0 += 0x100000267DrawSpriteXY(0, TempValue0, TempValue1)268TempValue1 += 0x100000269DrawSpriteXY(0, TempValue0, TempValue1)270TempValue0 -= 0x100000271DrawSpriteXY(0, TempValue0, TempValue1)272273if Editor.ShowGizmos == true274TempValue0 = Object.XPos275TempValue0 -= 8276TempValue1 = Object.YPos277TempValue1 -= 8278DrawRectOutline(TempValue0, TempValue1, 16, 16, 255, 255, 255, 255)279end if280end sub281282283sub RSDKLoad284LoadSpriteSheet("Global/Display.gif")285SpriteFrame(-8, -8, 16, 16, 173, 67) // "T" (ubeswitch) icon286287SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")288end sub289290291