Path: blob/main/Scripts/Global/SignPost.txt
1319 views
//-----------------Sonic CD Sign Post 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.FrameTimer78// Player Aliases9#alias Player.Value4 : Player.InvincibleTimer1011// ActFinish Aliases12#alias Object[30].DrawOrder : ActFinish.DrawOrder13#alias Object[30].Priority : ActFinish.Priority1415// States16#alias 0 : SIGNPOST_IDLE17#alias 1 : SIGNPOST_FLIP18#alias 2 : SIGNPOST_MOVE_PLAYER19#alias 3 : SIGNPOST_STOP_PLAYER20#alias 4 : SIGNPOST_BLANK2122// Control Mode23#alias -1 : CONTROLMODE_NONE2425// Player26#alias 0 : PLAYER_SONIC_A27#alias 1 : PLAYER_TAILS_A2829// Global SFX30#alias 15 : SFX_G_SIGNPOST3132// Property Values33#alias 0 : UPDATE_TILELAYER_134#alias 1 : UPDATE_TILELAYER_235#alias 2 : COMMON_SIGN36#alias 3 : HANDLE_MULTIPLE_SIGNS3738// Priority39#alias 1 : PRIORITY_ACTIVE40#alias 3 : PRIORITY_XBOUNDS414243sub ObjectMain44switch Object.State45case SIGNPOST_IDLE46Object.Frame = 14748TempValue0 = Object.YPos49TempValue0 += 0x60000050if Player.YPos < TempValue0 // Makes sure the player triggers the signpost no matter the height51Stage.NewXBoundary1 = Object.XPos52Stage.NewXBoundary1 >>= 1653Stage.NewXBoundary1 -= Screen.CenterX54Stage.NewXBoundary1 -= Screen.CenterX5556Stage.NewXBoundary2 = Object.XPos57Stage.NewXBoundary2 >>= 1658Stage.NewXBoundary2 += Screen.CenterX5960if Player.XPos > Object.XPos // Check that the player crossed the sign post61Stage.NewXBoundary1 = Object.XPos62Stage.NewXBoundary1 >>= 1663Stage.NewXBoundary1 -= Screen.CenterX64#platform: Use_Origins65EngineCallback(NOTIFY_TOUCH_SIGNPOST)66#endplatform67Stage.TimeEnabled = false6869Object.State = SIGNPOST_FLIP70Object.Timer = 87172PlaySfx(SFX_G_SIGNPOST, false)7374#platform: Use_Haptics75HapticEffect(50, 0, 0, 0)76#endplatform7778end if79end if80break8182case SIGNPOST_FLIP83Music.Volume--84Object.FrameTimer++85if Object.FrameTimer == 28687Object.FrameTimer = 088Object.Frame++89if Object.Frame == 590// Spawn a ring sparkle at random location close to the sign post91Rand(TempValue0, 48)92TempValue0 <<= 1693TempValue0 += Object.XPos94TempValue0 -= 0x1800009596Rand(TempValue1, 32)97TempValue1 <<= 1698TempValue1 += Object.YPos99TempValue1 -= 0x1C0000100CreateTempObject(TypeName[Ring Sparkle], 0, TempValue0, TempValue1)101102Object.Timer--103if Object.Timer == 0104105if Object[0].Type == TypeName[Blank Object] // Check if the player already leave by itself106Object.State = SIGNPOST_BLANK107if Object.PropertyValue < 3108PlayMusic(1)109else110if Object.OutOfBounds == false111PlayMusic(1)112end if113end if114115Object[30].Type = TypeName[ActFinish]116ActFinish.DrawOrder = 6117ActFinish.Priority = PRIORITY_ACTIVE118else // Otherwise the signpost will do it itself.119Player.ControlMode = CONTROLMODE_NONE120Player.Up = false121Player.Down = false122Player.Left = false123Player.JumpPress = false124Player.JumpHold = false125Object.State = SIGNPOST_MOVE_PLAYER126end if127128end if129130end if131132if Object.Frame == 9133// Spawn a ring sparkle at random location close to the sign post134Rand(TempValue0, 48)135TempValue0 <<= 16136TempValue0 += Object.XPos137TempValue0 -= 0x180000138139Rand(TempValue1, 32)140TempValue1 <<= 16141TempValue1 += Object.YPos142TempValue1 -= 0x1C0000143CreateTempObject(TypeName[Ring Sparkle], 0, TempValue0, TempValue1)144// Resets the animation cycle145Object.Frame = 1146end if147148end if149// Freezes the player after leaving the screen150TempValue0 = 40151TempValue0 += Screen.CenterX152TempValue0 <<= 16153TempValue0 += Object.XPos154if Player.XPos > TempValue0155Player.XPos = TempValue0156Player.Speed = 0157Player.XVelocity = 0158end if159break160161case SIGNPOST_MOVE_PLAYER162if Object[0].Type == TypeName[Blank Object]163Object.State = SIGNPOST_BLANK164if Object.PropertyValue < 3165PlayMusic(1)166else167if Object.OutOfBounds == false168PlayMusic(1)169end if170end if171Object[30].Type = TypeName[ActFinish]172ActFinish.DrawOrder = 6173ActFinish.Priority = PRIORITY_ACTIVE174end if175176if Player.ControlMode == CONTROLMODE_NONE177Player.Right = true178end if179180TempValue0 = Screen.CenterX181TempValue0 <<= 16182TempValue0 += Object.XPos183184if Player.XPos > TempValue0185if Object.PropertyValue < 3186PlayMusic(1)187else188if Object.OutOfBounds == false189PlayMusic(1)190end if191end if192Object.State = SIGNPOST_STOP_PLAYER193194Object[30].Type = TypeName[ActFinish]195ActFinish.DrawOrder = 6196ActFinish.Priority = PRIORITY_ACTIVE197else198#platform: Use_Origins199// Some Mission Mode stuff200if Player.Animation == ANI_PUSHING201PlayMusic(1)202Object.State = SIGNPOST_BLANK203Object[30].Type = TypeName[ActFinish]204Object[30].DrawOrder = 6205Object[30].Priority = PRIORITY_ACTIVE206end if207#endplatform208end if209break210211case SIGNPOST_STOP_PLAYER212if Player.ControlMode == CONTROLMODE_NONE213Player.Right = true214end if215TempValue0 = 40216TempValue0 += Screen.CenterX217TempValue0 <<= 16218TempValue0 += Object.XPos219if Player.XPos > TempValue0220Player.XPos = TempValue0221Player.Speed = 0222Player.XVelocity = 0223end if224break225226case SIGNPOST_BLANK227break228end switch229230#platform: Use_Origins231if game.playMode == BOOT_PLAYMODE_MISSION232if Object.State > SIGNPOST_IDLE233// Origins gives the player invincibility, in case the game stops you close to a hazard234Player.InvincibleTimer = 80235end if236end if237#endplatform238end sub239240241sub ObjectDraw242DrawSprite(0)243DrawSprite(Object.Frame)244end sub245246247sub ObjectStartup248if Stage.PlayerListPos == PLAYER_SONIC_A // PLAYER_SONIC in origins249LoadSpriteSheet("Global/Items2.gif")250end if251if Stage.PlayerListPos == PLAYER_TAILS_A // PLAYER_TAILS in origins252LoadSpriteSheet("Global/Items2_t.gif")253end if254#platform: Use_Origins255// the file name suffixes are lowercase in every other script, but for some reason they're uppercase here in this script only? sure ig..?256if Stage.PlayerListPos == PLAYER_KNUCKLES257LoadSpriteSheet("Global/Items2_K.gif")258end if259if Stage.PlayerListPos == PLAYER_AMY260LoadSpriteSheet("Global/Items2_A.gif")261end if262#endplatform263264SpriteFrame(-12, -12, 24, 24, 0, 150) // #0 - Sign Post265SpriteFrame(-24, -44, 48, 32, 34, 99) // #1 - Sign Post Head (Eggman)266SpriteFrame(-16, -44, 32, 32, 1, 183) // #2 - Sign Post Head (Flip 1)267SpriteFrame(-4, -44, 8, 32, 25, 150) // #3 - Sign Post Head (Flip 2)268SpriteFrame(-16, -44, 32, 32, 1, 216) // #4 - Sign Post Head (Flip 3)269SpriteFrame(-24, -44, 48, 32, 34, 132) // #5 - Sign Post Head (Player)270SpriteFrame(-16, -44, 32, 32, 1, 183) // #6 - Sign Post Head (Flip 1)271SpriteFrame(-4, -44, 8, 32, 25, 150) // #7 - Sign Post Head (Flip 2)272SpriteFrame(-16, -44, 32, 32, 1, 216) // #8 - Sign Post Head (Flip 3)273274ArrayPos0 = 32275while ArrayPos0 < 1056276if Object[ArrayPos0].Type == TypeName[Sign Post]277Object[ArrayPos0].Priority = PRIORITY_XBOUNDS278279// If needed, let's extend the stage a bit by repeating the last column of chunks280if Object[ArrayPos0].PropertyValue < 2281TempValue0 = TileLayer[0].XSize282TempValue0 -= 2283284TempValue1 = TileLayer[0].XSize285TempValue2 = Object[ArrayPos0].iYPos286TempValue2 += 64287TempValue2 >>= 7288289GetTileLayerEntry(TempValue3, 0, TempValue0, TempValue2)290SetTileLayerEntry(TempValue3, 0, TempValue1, TempValue2)291292TempValue0++293TempValue1++294GetTileLayerEntry(TempValue3, 0, TempValue0, TempValue2)295SetTileLayerEntry(TempValue3, 0, TempValue1, TempValue2)296297if Object[ArrayPos0].PropertyValue == UPDATE_TILELAYER_2298TempValue0--299TempValue1--300TempValue2--301GetTileLayerEntry(TempValue3, 0, TempValue0, TempValue2)302SetTileLayerEntry(TempValue3, 0, TempValue1, TempValue2)303304TempValue0++305TempValue1++306GetTileLayerEntry(TempValue3, 0, TempValue0, TempValue2)307SetTileLayerEntry(TempValue3, 0, TempValue1, TempValue2)308end if309end if310end if311ArrayPos0++312loop313end sub314315316// ========================317// Editor Subs318// ========================319320sub RSDKEdit321if Editor.ReturnVariable == true322switch Editor.VariableID323case EDIT_VAR_PROPVAL // Property Value324CheckResult = Object.PropertyValue325break326case 0 // Type327CheckResult = Object.PropertyValue328break329end switch330else331switch Editor.VariableID332case EDIT_VAR_PROPVAL // Property Value333Object.PropertyValue = Editor.VariableValue334break335case 0 // Type336Object.PropertyValue = Editor.VariableValue337break338end switch339end if340end sub341342343sub RSDKDraw344DrawSprite(0)345DrawSprite(1)346end sub347348349sub RSDKLoad350LoadSpriteSheet("Global/Items2.gif")351SpriteFrame(-12, -12, 24, 24, 0, 150) // #0 - Sign Post352SpriteFrame(-24, -44, 48, 32, 34, 99) // #1 - Sign Post Head (Eggman)353354355AddEditorVariable("Type")356SetActiveVariable("Type")357AddEnumVariable("Updates TileLayer (1)", 0)358AddEnumVariable("Updates TileLayer (2)", 1)359AddEnumVariable("Normal", 2)360AddEnumVariable("Normal (Handles Multiple SignPosts)", 3)361end sub362363364