Path: blob/master/Sonic 1/Scripts/Ending/EndingControl.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Ending Control Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.timer1213private alias 0 : ENDINGCONTROL_INIT14private alias 1 : ENDINGCONTROL_FADEIN15private alias 2 : ENDINGCONTROL_MAIN16private alias 3 : ENDINGCONTROL_NONE1718private alias 5 : ENDINGPOSE_HOLDEMERALDS1920// Player Aliases21private alias object.xpos : player.xpos22private alias object.ypos : player.ypos23private alias object.speed : player.speed24private alias object.controlMode : player.controlMode25private alias object.up : player.up26private alias object.down: player.down27private alias object.left : player.left28private alias object.right : player.right29private alias object.jumpPress : player.jumpPress30private alias object.jumpHold : player.jumpHold31private alias object.value1 : player.timer3233// Ending Pose Aliases34private alias object.value1 : object.logoPos353637// ========================38// Events39// ========================4041event ObjectUpdate42switch object.state43case ENDINGCONTROL_INIT44PlayMusic(0)4546object.state++47// [Fallthrough]48case ENDINGCONTROL_FADEIN49player[0].controlMode = CONTROLMODE_NONE50player[0].up = false51player[0].down = false52player[0].left = true53player[0].right = false54player[0].jumpHold = false55player[0].jumpPress = false5657if options.superStates == false58// Six emeralds59temp0 = 0x3F60else61// Seven emeralds62temp0 = 0x7F63end if6465if specialStage.emeralds >= temp066// If this is the good ending, then make the player start closer to the final ending position67// (object[+1] is a node on the closer hill in the scene, normally a Blank Object can it can be whatever if you really wanna)68player[0].xpos = object[+1].xpos69player[0].ypos = object[+1].ypos70end if7172foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)73if currentPlayer == 074player[currentPlayer].speed = -0x6000075else76// For all non-P1 players, start them to the right side of P1, hehind them77player[currentPlayer].speed = -0x6000078player[currentPlayer].xpos = player[0].xpos79player[currentPlayer].xpos += 0x40000080player[currentPlayer].ypos = player[0].ypos8182StopSfx(SfxName[Skidding])83end if84next8586if object.timer > 087object.timer -= 1688else89temp0 = 42490temp0 += screen.xcenter91stage.newXBoundary2 = temp092object.state++93end if9495SetScreenFade(0, 0, 0, object.timer)96break9798case ENDINGCONTROL_MAIN99temp0 = object.xpos100temp0 -= 0x180000101foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)102if player[currentPlayer].speed < -0x60000103// Enforce a minimum speed of 6 pixels per second, even if Sonic's on an uphill slope or all that stuff104player[currentPlayer].speed = -0x60000105end if106107if player[currentPlayer].xpos < temp0108// Sonic accidentally ran past the ending position, make him skid and turn around for a little bit now109player[currentPlayer].left = false110player[currentPlayer].right = true111end if112113if player[currentPlayer].xpos > object.xpos114if player[currentPlayer].right == true115// Sonic's turned around at reached the ending point, so now let's stop him and do all the fancy stuff116117player[currentPlayer].right = false118player[currentPlayer].speed = 0x00000119120if currentPlayer == playerCount121// Huh? currentPlayer should never match playerCount, but if it is, then increase state to ENDINGCONTROL_NONE?122// Not quite sure why this exists, this is really strange...123object.state++124else125if currentPlayer == 0126ResetObjectEntity(currentPlayer, TypeName[Ending Pose], 0, object.xpos, object.ypos)127object[currentPlayer].controlMode = CONTROLMODE_NONE128object[currentPlayer].drawOrder = 6129130if options.superStates == false131// Six emeralds132temp0 = 0x3F133else134// Seven emeralds135temp0 = 0x7F136end if137138if specialStage.emeralds < temp0139// Normal Ending Frames140141switch stage.playerListPos142case PLAYER_SONIC_A143case PLAYER_SONIC_TAILS_A144object[currentPlayer].frame = 0145break146147case PLAYER_TAILS_A148object[currentPlayer].frame = 13149break150151case PLAYER_KNUCKLES_A152object[currentPlayer].frame = 24153break154#platform: USE_ORIGINS155case PLAYER_AMY_A156object[currentPlayer].frame = 45157break158#endplatform159160end switch161else162// Good Ending Frames163164switch stage.playerListPos165case PLAYER_SONIC_A166case PLAYER_SONIC_TAILS_A167object[currentPlayer].frame = 4168break169170case PLAYER_TAILS_A171object[currentPlayer].frame = 16172break173174case PLAYER_KNUCKLES_A175object[currentPlayer].frame = 27176break177#platform: USE_ORIGINS178case PLAYER_AMY_A179object[currentPlayer].frame += 45180object[currentPlayer].frame += 4181break182#endplatform183end switch184185// Put them in the Good Ending state too, looks like the Emeralds are starting to do something186object[currentPlayer].state = ENDINGPOSE_HOLDEMERALDS187end if188189object[currentPlayer].logoPos = 224190end if191end if192end if193end if194next195break196197// State 3 (dubbed ENDINGCONTROL_NONE here) doesn't do anything198// The object shouldn't even get to that state, unless something's *really* wrong199200end switch201end event202203204event ObjectStartup205foreach (TypeName[Ending Control], arrayPos0, ALL_ENTITIES)206object[arrayPos0].priority = PRIORITY_ACTIVE207object[arrayPos0].timer = 272208next209end event210211212// ========================213// Editor Events214// ========================215216event RSDKDraw217DrawSprite(0)218219if editor.showGizmos == true220editor.drawingOverlay = true221222if TypeName[Player Object] > 0223object.type = TypeName[Player Object]224object.inkEffect = INK_BLEND225// object.direction = FACING_LEFT // You can't use ink effects and flip at the same time :(226DrawSpriteFX(0, FX_INK, object[+1].xpos, object[+1].ypos)227end if228229// Draw a line from this object to the start position teleport node230DrawArrow(object.xpos, object.ypos, object[+1].xpos, object[+1].ypos, 0xFF, 0xFF, 0x00)231232editor.drawingOverlay = false233end if234end event235236237event RSDKLoad238LoadSpriteSheet("Global/Display.gif")239SpriteFrame(-16, -16, 32, 32, 1, 143)240241SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")242end event243244245