Path: blob/main/Scripts/R5/CBSwitch.txt
1319 views
//------------------Sonic CD CBSwitch Script------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Timer6#alias Object.Value1 : Object.PrevResult78// HUD Alias9#alias Object[24].PropertyValue : HUD.CurrentTimePeriod1011// States12#alias 0 : CBSWITCH_POINTRIGHT_MAIN13#alias 4 : CBSWITCH_POINTRIGHT_START14#alias 5 : CBSWITCH_POINTRIGHT_TRANSITION1516#alias 3 : CBSWITCH_POINTLEFT_MAIN17#alias 1 : CBSWITCH_POINTLEFT_START18#alias 2 : CBSWITCH_POINTLEFT_TRANSITION1920// Stage SFX21#alias 3 : SFX_S_SWITCH2223// Time Period Aliases24#alias 1 : TIME_PAST252627sub ObjectPlayerInteraction2829// Only do checks if the Player wasn't already in the Switch last frame30if Object.PrevResult == false31if Player.XPos > Object.XPos32PlayerObjectCollision(C_TOUCH, 0, -12, 16, 16)3334// Regardless of what it is, store the current result for next frame35Object.PrevResult = CheckResult3637// Now that it's been stored, take a look at the actual result38if CheckResult == true39switch Object.State40case CBSWITCH_POINTRIGHT_MAIN41case CBSWITCH_POINTLEFT_MAIN42PlayStageSfx(SFX_S_SWITCH, false)4344#platform: Use_Haptics45HapticEffect(20, 0, 0, 0)46#endplatform4748if ConveyorBelt_Flag == 049ConveyorBelt_Flag = 350Object.State = CBSWITCH_POINTLEFT_START51else52ConveyorBelt_Flag = 053Object.State = CBSWITCH_POINTRIGHT_START54end if55break // not from the original scripts and unnecesary, but the syntax will look wrong otherwise56end switch57end if58else59PlayerObjectCollision(C_TOUCH, -16, -12, 0, 16)6061// Store the result for next frame62Object.PrevResult = CheckResult6364// And now look at the actual result65if CheckResult == true66switch Object.State67case CBSWITCH_POINTRIGHT_MAIN68case CBSWITCH_POINTLEFT_MAIN69PlayStageSfx(SFX_S_SWITCH, false)7071#platform: Use_Haptics72HapticEffect(20, 0, 0, 0)73#endplatform7475if ConveyorBelt_Flag == 076ConveyorBelt_Flag = 377Object.State = CBSWITCH_POINTLEFT_START78else79ConveyorBelt_Flag = 080Object.State = CBSWITCH_POINTRIGHT_START81end if8283break // not from the original scripts and unnecesary, but the syntax will look wrong otherwise84end switch85end if86end if87else88// The Player's still touched the Switch right after a, well, Switch89// so just hold and wait for them to move away90if Player.XPos > Object.XPos91PlayerObjectCollision(C_TOUCH, 0, -12, 16, 16)92Object.PrevResult = CheckResult93else94PlayerObjectCollision(C_TOUCH, -16, -12, 0, 16)95Object.PrevResult = CheckResult96end if97end if9899end sub100101102103104sub ObjectDraw105106switch Object.State107case CBSWITCH_POINTLEFT_START108if Object.Timer < 7109Object.Timer++110else111Object.Timer = 0112ConveyorBelt_Frame = 1113Object.State = CBSWITCH_POINTLEFT_TRANSITION114end if115break116117case CBSWITCH_POINTLEFT_TRANSITION118if Object.Timer < 7119Object.Timer++120else121Object.Timer = 0122ConveyorBelt_Frame = 2123Object.State = CBSWITCH_POINTLEFT_MAIN124end if125break126127case CBSWITCH_POINTRIGHT_START128if Object.Timer < 7129Object.Timer++130else131Object.Timer = 0132ConveyorBelt_Frame = 1133Object.State = CBSWITCH_POINTRIGHT_TRANSITION134end if135break136137case CBSWITCH_POINTRIGHT_TRANSITION138if Object.Timer < 7139Object.Timer++140else141Object.Timer = 0142ConveyorBelt_Frame = 0143Object.State = CBSWITCH_POINTRIGHT_MAIN144end if145break146147end switch148149DrawSprite(ConveyorBelt_Frame)150151end sub152153154sub ObjectStartup155LoadSpriteSheet("R5/Objects.gif")156157if HUD.CurrentTimePeriod == TIME_PAST158// The Past gets different Sprite Frames159160SpriteFrame(-4, -16, 32, 28, 1, 225)161SpriteFrame(-8, -36, 16, 48, 206, 207)162SpriteFrame(-28, -16, 32, 28, 34, 225)163else164SpriteFrame(-4, -16, 32, 28, 1, 18)165SpriteFrame(-8, -36, 16, 48, 125, 1)166SpriteFrame(-28, -16, 32, 28, 34, 18)167end if168169end sub170171172// ========================173// Editor Subs174// ========================175176sub RSDKDraw177DrawSprite(0)178end sub179180181sub RSDKLoad182LoadSpriteSheet("R5/Objects.gif")183SpriteFrame(-4, -16, 32, 28, 1, 18)184185SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")186end sub187188189