Path: blob/master/Sonic 2/Scripts/Continue/ContinueSetup.txt
1479 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Continue Setup Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.timer1213// States14private alias 0 : CONTINUE_INIT15private alias 1 : CONTINUE_FADEIN16private alias 2 : CONTINUE_DISPLAY17private alias 3 : CONTINUE_REVUP18private alias 4 : CONTINUE_RUN19private alias 5 : CONTINUE_ACCEPTED20private alias 6 : CONTINUE_TIMEDOUT2122// Player aliases23private alias object.type : player.type24private alias object.state : player.state25private alias object.animation : player.animation26private alias object.xpos : player.xpos27private alias object.ypos : player.ypos28private alias object.xvel : player.xvel29private alias object.speed : player.speed30private alias object.controlMode : player.controlMode313233// ========================34// Events35// ========================3637event ObjectUpdate38switch object.state39case CONTINUE_INIT40object.timer = 32041SetScreenFade(0x00, 0x00, 0x00, object.timer)42object.state++43break4445case CONTINUE_FADEIN46if object.timer > 047object.timer -= 848else49PlayMusic(0)50object.state++5152// Tell the Continue Screen object to start counting53object[-1].state++54end if55SetScreenFade(0x00, 0x00, 0x00, object.timer)56break5758case CONTINUE_DISPLAY59#platform: USE_STANDALONE60CheckTouchRect(0, 0, screen.xsize, screen.ysize)61if checkResult > -162keyPress[0].start = true63end if6465if keyPress[0].start == true66#endplatform6768#platform: USE_ORIGINS69checkResult = false70checkResult |= keyPress[0].start71checkResult |= keyPress[0].buttonA72checkResult |= keyPress[0].buttonC73if checkResult == true74#endplatform75player[0].animation = ANI_CONTINUE_UP76player[0].speed = 077PlaySfx(SfxName[Charge], false)78object.state++7980// Tell the Continue Screen object to stop counting81object[-1].state++82end if83break8485case CONTINUE_REVUP86if music.volume > 087// Fade out music88music.volume--89end if9091player[0].speed += 0x200092if player[0].speed == 0x9000093player[0].xvel = 0x10000094if player[1].type == TypeName[Blank Object]95object.state++96end if97end if9899if player[1].type != TypeName[Blank Object]100if player[0].speed == 0x20000101player[1].animation = ANI_CONTINUE_UP102player[1].speed = 0103PlaySfx(SfxName[Charge], false)104end if105106if player[0].speed > 0x20000107player[1].speed += 0x2000108if player[1].speed == 0x90000109player[1].xvel = 0x100000110object.state++111end if112end if113end if114break115116case CONTINUE_RUN117if music.volume > 0118music.volume--119end if120121temp0 = screen.xsize122temp0 += 32123if player[1].type == TypeName[Blank Object]124temp1 = player[0].xpos125else126temp1 = player[1].xpos127end if128129temp1 >>= 16130if temp1 >= temp0131object.state++132end if133break134135case CONTINUE_ACCEPTED136if music.volume > 0137music.volume--138end if139140object.timer += 4141142SetScreenFade(0x00, 0x00, 0x00, object.timer)143144if object.timer == 384145player.continues--146player.lives = 3147fadeColor = 0x000000148object.timer = 0149starPostID = 0150object.direction = FLIP_NONE // this object's direction doesn't even matter...151stage.activeList = recStageList152stage.listPos = recStage153LoadStage()154end if155break156157case CONTINUE_TIMEDOUT158object.timer += 4159SetScreenFade(0x00, 0x00, 0x00, object.timer)160if object.timer == 384161fadeColor = 0x000000162object.timer = 0163starPostID = 0164object.direction = FLIP_NONE // if you really wanna, ig165#platform: USE_STANDALONE166engine.state = 8167#endplatform168#platform: USE_ORIGINS169stage.activeList = PRESENTATION_STAGE170stage.listPos = 0171LoadStage()172#endplatform173end if174break175176end switch177178// Hide touch controls179options.touchControls = false180end event181182183event ObjectDraw184// Clear all old frames185// (This level doesn't have a background so this is needed to prevent old frame smear)186ClearScreen(1)187end event188189190event ObjectStartup191foreach (TypeName[Continue Setup], arrayPos0, ALL_ENTITIES)192object[arrayPos0].drawOrder = 0 // Draw Order 0 so we draw before everything else193next194195// Put the player in the middle of the screen196player[0].xpos = screen.xcenter197player[0].xpos <<= 16198199// Set the player's animation, although it gets set to ANI_CONTINUE a few lines below again anyway200player[0].animation = ANI_FANROTATE201202player[0].state = Player_State_ContinueRun203204// Different starting offsets based on P1205switch stage.playerListPos206case PLAYER_SONIC_A207case PLAYER_SONIC_TAILS_A208// 172 pixels209player[0].ypos = 0xAC0000210break211212case PLAYER_TAILS_A213// Also 172 pixels, still separate from the above for whatever reason214player[0].ypos = 0xAC0000215break216217case PLAYER_KNUCKLES_A // There's no check for Knuckles & Tails here in Origins, not that it's really needed anyway218// 176 pixels219player[0].ypos = 0xB00000220break221222#platform: USE_ORIGINS223case PLAYER_AMY_A224case PLAYER_AMY_TAILS_A225// 175 pixels226player[0].ypos = 0xAF0000227break228#endplatform229end switch230231// Set the proper P1 animation here232player[0].animation = ANI_CONTINUE233234if player[1].type != TypeName[Blank Object]235// Move P2 to the center of the screen too236player[1].xpos = screen.xcenter237player[1].xpos <<= 16238239// Set P2's animation, and then...240player[1].animation = ANI_FANROTATE241242player[1].state = Player_State_ContinueRun243244// Move the players a bit to make room for two245player[0].xpos -= 0x100000246player[1].xpos += 0x100000247player[1].ypos = player[0].ypos248#platform: USE_STANDALONE249player[1].ypos += 0x40000250251// ...now set P2's animation *again*...?252player[1].animation = ANI_BORED253#endplatform254255#platform: USE_ORIGINS256switch stage.playerListPos257case PLAYER_SONIC_A258case PLAYER_TAILS_A259case PLAYER_SONIC_TAILS_A260player[1].ypos += 0x40000261player[1].animation = ANI_BORED262break263264case PLAYER_KNUCKLES_A265case PLAYER_KNUCKLES_TAILS_A266player[1].xpos -= 0x40000267player[1].ypos += 0x30000268player[1].animation = ANI_BORED269break270271case PLAYER_AMY_A272case PLAYER_AMY_TAILS_A273player[1].ypos += 0x10000274player[1].animation = ANI_CONTINUE275break276end switch277#endplatform278end if279280stage.newXBoundary2 = screen.xsize281stage.newYBoundary2 = screen.ysize282283SetMusicTrack("Continue.ogg", 0, false)284285// Do note - this doesn't quite work when physical input is being used since the player doesn't check against this variable before pausing the game286stage.pauseEnabled = false287288#platform: USE_DECOMP289// Not in the original game, but this is for the above to fix an issue where290// pressing start to continue also pauses the entire game291player[0].controlMode = CONTROLMODE_NONE292#endplatform293294if player.continues == 0295// Player was most likely brought here from the dev menu, give them three free continues296player.continues = 3297end if298299options.touchControls = false300end event301302303// ========================304// Editor Events305// ========================306307event RSDKDraw308DrawSprite(0)309end event310311312event RSDKLoad313LoadSpriteSheet("Global/Display.gif")314SpriteFrame(-16, -16, 32, 32, 1, 143)315316SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")317end event318319320