Path: blob/main/Scripts/Global/AttractMode.txt
1319 views
//----------------Sonic CD Attract Mode Script----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value1 : Object.DemoTime6#alias Object.Value2 : Object.DemoLength7#alias Object.Value3 : Object.DemoInput89// States10#alias 0 : ATTRACTMODE_SETUP11#alias 1 : ATTRACTMODE_HANDLE_INPUT1213// Control Modes14#alias 0 : CONTROLMODE_NORMAL1516// Demo ID Aliases17#alias 0 : DEMO_R11A18#alias 1 : DEMO_SS119#alias 2 : DEMO_R43C20#alias 3 : DEMO_SS621#alias 4 : DEMO_R82A2223// Priority24#alias 1 : PRIORITY_ACTIVE2526// Engine & CallBacks27#alias 2 : MESSAGE_LOSTFOCUS2829// Player Aliases30#alias 0 : PLAYER_SONIC_A31#alias 1 : PLAYER_TAILS_A3233// Presentation Stages34#alias 0 : STAGE_P_TITLE3536// Text Info type37#alias 0 : TEXTINFO_TEXTDATA38#alias 1 : TEXTINFO_TEXTSIZE394041sub ObjectMain42switch Object.State43case ATTRACTMODE_SETUP44if Player.ControlMode == CONTROLMODE_NORMAL45Object.State++46Object.DemoInput = Object.DemoLength47Object.DemoInput -= 6048end if49break5051case ATTRACTMODE_HANDLE_INPUT5253// Get the inputs for the current frame54GetTextInfo(TempValue0, MENU_1, TEXTINFO_TEXTDATA, 0, Object.DemoTime)5556// Set all the input stuff as needed57GetBit(Player.Up, TempValue0, 0)58GetBit(Player.Down, TempValue0, 1)59GetBit(Player.Left, TempValue0, 2)60GetBit(Player.Right, TempValue0, 3)61GetBit(Player.JumpPress, TempValue0, 4)62GetBit(Player.JumpHold, TempValue0, 5)6364if Object.DemoTime < Object.DemoLength65Object.DemoTime++66else67StopMusic()68Options.AttractMode = false69Stage.ActiveList = PRESENTATION_STAGE70Stage.ListPos = STAGE_P_TITLE71Transporter_Destroyed = false72MetalSonic_Destroyed = false73Good_Future = false74LoadStage()75LampPost.Check = 07677Engine.HapticsEnabled = SaveRAM[40]78end if7980if Object.DemoTime >= Object.DemoInput81// Fade out8283Music.Volume -= 28485Screen.CameraEnabled = false8687TempValue0 = Object.DemoTime88TempValue0 -= Object.DemoInput89TempValue0 <<= 390if TempValue0 > 25591TempValue0 = 25592end if9394SetScreenFade(0, 0, 0, TempValue0)95else96if KeyPress[0].ButtonA == true97Object.DemoTime = Object.DemoInput98end if99100if KeyPress[0].ButtonB == true101Object.DemoTime = Object.DemoInput102end if103104if KeyPress[0].ButtonC == true105Object.DemoTime = Object.DemoInput106end if107108if KeyPress[0].AnyStart == true109Object.DemoTime = Object.DemoInput110end if111112#platform: Mobile113CheckTouchRect(0, 0, Screen.XSize, 240)114if CheckResult > -1115Object.DemoTime = Object.DemoInput116end if117118if Engine.Message == MESSAGE_LOSTFOCUS119Object.DemoTime = Object.DemoInput120end if121#endplatform122123end if124break125end switch126127end sub128129130sub ObjectDraw131132if Object[20].Type != TypeName[Title Card]133Object.AnimationTimer++134Object.AnimationTimer %= 60135136if Object.AnimationTimer > 29137// Code would be here, presumably?138// This entire ObjectDraw sub exists, but nothing's actually drawn...139140// A fit guess would be the "Demo" sprite from below, but since it doesn't show up in the original game141// it may have been removed for accuracy reasons142end if143end if144145end sub146147148sub ObjectStartup149150// This Object never draws anything anyway, but load a sheet and set up Sprite Frames anyway151if Stage.ActiveList == REGULAR_STAGE152// Load the corresponding Display sheet for the current character153if Stage.PlayerListPos == PLAYER_SONIC_A154LoadSpriteSheet("Global/Display.gif")155end if156if Stage.PlayerListPos == PLAYER_TAILS_A157LoadSpriteSheet("Global/Display_t.gif")158end if159#platform: Use_Origins160if Stage.PlayerListPos == PLAYER_KNUCKLES161LoadSpriteSheet("Global/Display_k.gif")162end if163if Stage.PlayerListPos == PLAYER_AMY164LoadSpriteSheet("Global/Display_a.gif")165end if166#endplatform167168// "Demo" - unused169SpriteFrame(-17, -5, 34, 11, 1, 176)170else171LoadSpriteSheet("Special/Objects.gif")172173// "Demo" - unused174SpriteFrame(-17, -5, 34, 11, 83, 168)175end if176177ArrayPos0 = 32178while ArrayPos0 < 1056179if Object[ArrayPos0].Type == TypeName[Attract Mode]180if Options.AttractMode == true181182// Make the Object always active, regardless of where it's located in the stage183Object[ArrayPos0].Priority = PRIORITY_ACTIVE184185// Give it a high Draw Order as well... though nothing's ever really drawn by this Object186Object[ArrayPos0].DrawOrder = 6187188switch Object[ArrayPos0].PropertyValue189case DEMO_R11A190// Palmtree Panic Act 1, Present191192LoadTextFile(MENU_1, "Data/Game/Demos/Key11a.bin", 0)193LampPost.Check = 0194break195196case DEMO_SS1197// Special Stage 1198199LoadTextFile(MENU_1, "Data/Game/Demos/Special1.bin", 0)200LampPost.Check = 0201break202203case DEMO_R43C204// Tidal Tempest 3, Good Future205206LoadTextFile(MENU_1, "Data/Game/Demos/Key43c.bin", 0)207208// Move the Player to where the Attract Mode object is placed209Player.XPos = Object[ArrayPos0].XPos210Player.YPos = Object[ArrayPos0].YPos211212LampPost.Check = 33213break214215case DEMO_SS6216// Special Stage 6217218LoadTextFile(MENU_1, "Data/Game/Demos/Special6.bin", 0)219LampPost.Check = 0220break221222case DEMO_R82A223// Metallic Madness 2, Present224225LoadTextFile(MENU_1, "Data/Game/Demos/Key82a.bin", 0)226227// Move the Player to where the Attract Mode object's placed228Player.XPos = Object[ArrayPos0].XPos229Player.YPos = Object[ArrayPos0].YPos230231LampPost.Check = 33232break233234end switch235236// Get how long the Demo is, and store it in the Attract Mode Object237GetTextInfo(Object[ArrayPos0].DemoLength, MENU_1, TEXTINFO_TEXTSIZE, 0, 0)238239else240241// If Attract Mode isn't active, then remove the Object242Object[ArrayPos0].Type = TypeName[Blank Object]243244end if245end if246247ArrayPos0++248loop249end sub250251252// ========================253// Editor Subs254// ========================255256sub RSDKEdit257if Editor.ReturnVariable == true258switch Editor.VariableID259case EDIT_VAR_PROPVAL // Property Value260case 0 // DemoID261CheckResult = Object.PropertyValue262break263end switch264else265switch Editor.VariableID266case EDIT_VAR_PROPVAL // Property Value267case 0 // DemoID268Object.PropertyValue = Editor.VariableValue269break270end switch271end if272end sub273274275sub RSDKDraw276DrawSprite(0)277end sub278279280sub RSDKLoad281LoadSpriteSheet("Global/Display.gif")282SpriteFrame(-17, -5, 34, 11, 1, 176) // "Demo"283284AddEditorVariable("DemoID")285SetActiveVariable("DemoID")286AddEnumVariable("Palmtree Panic 1", 0)287AddEnumVariable("Special Zone 1", 1)288AddEnumVariable("Tidal Tempest 3", 2)289AddEnumVariable("Special Zone 6", 3)290AddEnumVariable("Metallic Madness 2", 4)291end sub292293294