Path: blob/main/Scripts/Special/SpecialSetup.txt
1319 views
//---------------Sonic CD Special Setup Script----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases56// Universal7#alias Object.Value5 : Object.ScreenDepth89// HUD Alias10#alias Object.Value0 : HUD.UFOsCount11#alias Object.Value1 : HUD.TimeSeconds12#alias Object.Value2 : HUD.TimeFrames13#alias Object.Value6 : HUD.BonusUFONo // "No" akin to Entity No, not as in "is there no UFO?"14#alias Object.Value7 : HUD.WaterTimer1516// UFO Alias17#alias Object.YPos : Object.ZPos1819// SSSonic Aliases20#alias Player.ControlMode : SSSonic.ControlMode2122// ControlMode Aliases23#alias -1 : CONTROLMODE_NONE2425// Stage Finish State Aliases26#alias 9 : STAGEFINISH_LOADLEVELSELECT2728// Game Mode Aliases29#alias 2 : MODE_TIMEATTACK3031// Stage SFX32#alias 5 : SFX_S_TIMEUFO33#alias 7 : SFX_S_DROWNALERT3435// Soundtrack36#alias 0 : OST_JP3738// Priority39#alias 1 : PRIORITY_ACTIVE4041// Tile Layer Types42#alias 4 : LAYER_3DSKY434445sub ObjectMain463DScene.NoVertices = 0473DScene.NoFaces = 04849// Update the oscillation value50// Although it's normally used for synced movements throughout a stage, the Oscillation value is never actually used within the Special Stage51Oscillation++52if Oscillation == 51253Oscillation = 054end if5556// Time is managed here5758if HUD[4].UFOsCount > 05960// This used to be checking if it was false, but Origins changed it up a bit61if Stage.TimeEnabled == true62// However, this is a bit faulty and results on a time ufo sometimes appearing in time attack, so let's exclude any of this from time attack for decomp63#platform: Use_Decomp64if Options.GameMode != MODE_TIMEATTACK65#endplatform66// Progress the timer67HUD[4].TimeFrames++68if HUD[4].TimeFrames == 6069HUD[4].TimeFrames = 07071if HUD[4].TimeSeconds > 072if HUD[4].TimeSeconds < 673// Time's almost up, play a jingle to alert the player74PlayStageSfx(SFX_S_DROWNALERT, false)75end if7677HUD[4].TimeSeconds--78if HUD[4].TimeSeconds < 2079// Less than 20 seconds left, quickly, spawn a time UFO to help the player!80ArrayPos0 = HUD[4].BonusUFONo8182// Make sure the bonus UFO doesn't exist already83if Object[ArrayPos0].Type != TypeName[UFO]84PlayStageSfx(SFX_S_TIMEUFO, false)8586ArrayPos1 = ArrayPos087ArrayPos1++8889Object[ArrayPos0].Type = TypeName[UFO]90Object[ArrayPos0].Priority = PRIORITY_ACTIVE91Object[ArrayPos0].PropertyValue = 292Object[ArrayPos0].XPos = Object[ArrayPos1].XPos93Object[ArrayPos0].ZPos = Object[ArrayPos1].ZPos94end if95end if96else97// This will never happen on Time Attack98if Options.GameMode != MODE_TIMEATTACK99// Time's over, so start the stage results100Object[30].Type = TypeName[Stage Finish]101if Stage.ActNo == 8102// If in the Robotnik Special Stage, then go to the Level Select103Object[30].State = STAGEFINISH_LOADLEVELSELECT104Object[30].DrawOrder = 7105else106// Nope, we can just do normal results107Object[30].DrawOrder = 6108end if109SSSonic.ControlMode = CONTROLMODE_NONE110end if111end if112end if113114if HUD[4].WaterTimer > 0115if HUD[4].WaterTimer > 1116if HUD[4].WaterTimer > 20117TempValue0 = HUD[4].TimeFrames118TempValue0 &= 1119120if HUD[4].TimeSeconds > 0121HUD[4].TimeSeconds -= TempValue0122else123// In Time Attack, you can't run out of time124if Options.GameMode != MODE_TIMEATTACK125// No more time left, end the stage by spawning the results126Object[30].Type = TypeName[Stage Finish]127128if Stage.ActNo == 8129// If in the Robotnik Special Stage, then go back to the Level Select rather than the normal SS results130131Object[30].State = STAGEFINISH_LOADLEVELSELECT132Object[30].DrawOrder = 7133else134// We're in a normal stage, so show the results as normal135136Object[30].DrawOrder = 6137end if138139SSSonic.ControlMode = CONTROLMODE_NONE140end if141end if142else143if Object[3].Type != TypeName[WaterSplash]144HUD[4].WaterTimer = 0145end if146end if147148HUD[4].WaterTimer--149else150if Object[3].Type != TypeName[WaterSplash]151HUD[4].WaterTimer = 0152else153TempValue0 = HUD[4].TimeFrames154TempValue0 &= 1155156if HUD[4].TimeSeconds > 0157HUD[4].TimeSeconds -= TempValue0158else159160// In Time Attack, you can't muddle your time up and time out161if Options.GameMode != MODE_TIMEATTACK162163// Player wasted too much time puddling around and now time's up, end the stage164Object[30].Type=TypeName[Stage Finish]165166if Stage.ActNo == 8167168// If we're in Robotnik's secret Special Stage, then return to the level select169170Object[30].State = STAGEFINISH_LOADLEVELSELECT171Object[30].DrawOrder = 7172173else174175// We're in a normal stage, so show the normal results176177Object[30].DrawOrder = 6178179end if180181SSSonic.ControlMode = CONTROLMODE_NONE182end if183184end if185end if186end if187end if188#platform: Use_Decomp189end if190#endplatform191end if192end if193194end sub195196197sub ObjectDraw198// Sort the drawing orders of all entities199// (Things further away from the camera should be drawn first and things closest should be last, etc.)200201TempValue0 = 0202TempValue1 = Screen.DrawListSize[3]203while TempValue0 < TempValue1204TempValue2 = TempValue1205TempValue2--206207while TempValue2 > TempValue0208TempValue3 = TempValue2209TempValue2--210211// Get the object slots of the two objects212GetDrawListEntityRef(ArrayPos0, 3, TempValue3)213GetDrawListEntityRef(ArrayPos1, 3, TempValue2)214215// Compare their sorted draw orders216if Object[ArrayPos0].ScreenDepth > Object[ArrayPos1].ScreenDepth217// Swap them around if needed218SetDrawListEntityRef(ArrayPos0, 3, TempValue2)219SetDrawListEntityRef(ArrayPos1, 3, TempValue3)220end if221loop222223TempValue0++224loop225226end sub227228229sub ObjectStartup230231// Despite not having any SpriteFrames to draw with, go ahead and load the Special Stage objects sheet anyway232// (It doesn't make much of a difference but hey, may as well anyway!)233LoadSpriteSheet("Special/Objects.gif")234235// Set the ground to the "3d Sky" layer type236// -> This way, it'll render in high-quality mode if possible, as opposed to the "3d Floor" type237TileLayer[0].Type = LAYER_3DSKY238239if Options.Soundtrack == OST_JP240SetMusicTrack("JP/SpecialStage.ogg", 0, true)241SetMusicTrack("JP/ZoneComplete.ogg", 1, false)242else243SetMusicTrack("US/SpecialStage.ogg", 0, 270972)244SetMusicTrack("US/ZoneComplete.ogg", 1, false)245end if246247Stage.PauseEnabled = false248249// Origins changed this up a bit - before, Time would always be disabled, but Origins makes it enabled for standard play250if Options.GameMode == MODE_TIMEATTACK251Stage.TimeEnabled = false252else253Stage.TimeEnabled = true254end if255256Object[23].Type = TypeName[Special Setup]257Object[23].Priority = PRIORITY_ACTIVE258259// Give it a draw order lower right before the primary one, to make sure it can sort all the upcoming 3d entities correctly260Object[23].DrawOrder = 2261262// Cycle through all Blank Objects?263// There was likely a proper name here in the original source,264// but it was an invalid name so upon compiling, it got resolved as 0265// What this original name was though, we have no idea...266ArrayPos0 = 32267while ArrayPos0 < 1056268if Object[ArrayPos0].Type == TypeName[Blank Object]269// If the object is blank... then blank it again...270ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)271end if272273ArrayPos0++274loop275276end sub277278279// ========================280// Editor Subs281// ========================282283sub RSDKDraw284DrawSprite(0)285end sub286287288sub RSDKLoad289LoadSpriteSheet("Global/Display.gif")290SpriteFrame(-16, -16, 32, 32, 1, 143) // "Script" Box291292SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")293end sub294295296