Path: blob/master/Sonic 1/Scripts/Global/DeathEvent.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Death Event Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value1 : object.leftTextPos12private alias object.value2 : object.rightTextPos13private alias object.value3 : object.timer14private alias object.value4 : object.timeOver1516// States17private alias 0 : DEATHEVENT_GAMEOVER18private alias 1 : DEATHEVENT_TIMEOVER19private alias 2 : DEATHEVENT_DEATH20private alias 3 : DEATHEVENT_DEATH_TA21private alias 4 : DEATHEVENT_WAITFORCALLBACK22private alias 5 : DEATHEVENT_RETRY23private alias 6 : DEATHEVENT_SETSCREENFADE2425// Game Modes Aliases26private alias 1 : MODE_SAVEGAME2728// Presentation Stage Aliases29private alias 0 : STAGE_P_TITLE30private alias 4 : STAGE_P_CONTINUE313233// ========================34// Events35// ========================3637event ObjectUpdate38switch object.state39case DEATHEVENT_GAMEOVER40#platform: USE_ORIGINS41if game.playMode == BOOT_PLAYMODE_CLASSIC42CheckEqual(object.timeOver, false)43temp0 = checkResult44CheckEqual(stage.minutes, 9)45temp0 &= checkResult46CheckEqual(stage.seconds, 59)47temp0 &= checkResult48CheckEqual(stage.milliSeconds, 99)49temp0 &= checkResult50temp0 |= game.timeOver5152if temp0 != false53if player.continues == 054object.timeOver = true55else56recMilliSeconds = 057recSeconds = 058recMinutes = 059game.timeOver = false60end if61end if62end if63#endplatform64// [Fall-through]65case DEATHEVENT_TIMEOVER66#platform: USE_ORIGINS67object.timeOver |= object.state6869if game.playMode == BOOT_PLAYMODE_BOSSRUSH70object.type = TypeName[Blank Object]71end if72#endplatform7374temp0 = screen.xcenter75temp0 -= 7276if object.leftTextPos < temp077object.leftTextPos += 1678if object.leftTextPos > temp079object.leftTextPos = temp080end if81end if8283temp0 += 8084if object.rightTextPos > temp085object.rightTextPos -= 1686if object.rightTextPos < temp087object.rightTextPos = temp088end if89end if9091if object.timer < 28892object.timer += 493else94#platform: USE_ORIGINS95if object.timeOver == true96if lampPostID > 097recMilliSeconds = 9998recSeconds = 5999recMinutes = 9100game.timeOver = true101else102recMilliSeconds = 0103recSeconds = 0104recMinutes = 0105end if106end if107#endplatform108109if object.state == DEATHEVENT_GAMEOVER110recStageList = stage.activeList111recStage = stage.listPos112stage.activeList = PRESENTATION_STAGE113114if player.continues == 0115stage.listPos = STAGE_P_TITLE116#platform: USE_STANDALONE117engine.state = 8118#endplatform119CallNativeFunction2(ShowPromoPopup, 0, "GameOverPromo") // still in Origins btw120else121stage.listPos = STAGE_P_CONTINUE122end if123124lampPostID = 0125126if options.gameMode == MODE_SAVEGAME127arrayPos1 = options.saveSlot128arrayPos1 <<= 3129arrayPos1++130if saveRAM[arrayPos1] < 3 // lives131saveRAM[arrayPos1] = 3132end if133arrayPos1++134saveRAM[arrayPos1] = 0 // score135arrayPos1++136saveRAM[arrayPos1] = 50000 // score bonus137player.score = 0138WriteSaveRAM()139end if140else141if options.gameMode == MODE_SAVEGAME142arrayPos1 = options.saveSlot143arrayPos1 <<= 3144arrayPos1++145saveRAM[arrayPos1] = player.lives146WriteSaveRAM()147end if148end if149150#platform: USE_STANDALONE151if object.state == DEATHEVENT_TIMEOVER152recMilliSeconds = 0153recSeconds = 0154recMinutes = 0155end if156#endplatform157158#platform: USE_ORIGINS159if object.state == DEATHEVENT_GAMEOVER160CallNativeFunction2(NotifyCallback, NOTIFY_TIME_OVER, game.timeOver)161end if162163if object.state == DEATHEVENT_TIMEOVER164player.deadResetRings = true165end if166#endplatform167168LoadStage()169end if170171if object.timer > 0172music.volume -= 2173SetScreenFade(0, 0, 0, object.timer)174else175if keyPress[0].buttonA == true176object.timer = 0177end if178179if keyPress[0].buttonB == true180object.timer = 0181end if182183if keyPress[0].buttonC == true184object.timer = 0185end if186187#platform: MOBILE188CheckTouchRect(0, 0, screen.xsize, screen.ysize)189if checkResult > -1190object.timer = 0191end if192#endplatform193end if194break195196case DEATHEVENT_DEATH197#platform: USE_ORIGINS198CheckNotEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)199temp0 = checkResult200CheckNotEqual(game.oneStageFlag, false)201checkResult &= temp0202203if checkResult != false204game.callbackResult = -1205CallNativeFunction4(NotifyCallback, NOTIFY_STAGE_RETRY, false, stage.listPos, 0)206object.state = DEATHEVENT_WAITFORCALLBACK207if options.gameMode == MODE_SAVEGAME208arrayPos1 = options.saveSlot209arrayPos1 <<= 3210arrayPos1++211saveRAM[arrayPos1] = player.lives212WriteSaveRAM()213end if214else215#endplatform216if object.timer < 288217music.volume -= 2218object.timer += 4219else220if options.gameMode == MODE_SAVEGAME221arrayPos1 = options.saveSlot222arrayPos1 <<= 3223arrayPos1++224saveRAM[arrayPos1] = player.lives225WriteSaveRAM()226end if227228#platform: USE_STANDALONE229LoadStage()230#endplatform231232#platform: USE_ORIGINS233if game.playMode != BOOT_PLAYMODE_MISSION234LoadStage()235end if236#endplatform237end if238239SetScreenFade(0, 0, 0, object.timer)240#platform: USE_ORIGINS241end if242243player.deadResetRings = true244#endplatform245break246247case DEATHEVENT_DEATH_TA248if object.timer < 288249music.volume -= 2250object.timer += 4251else252timeAttack.result = 100000253player.score = 0254lampPostID = 0255recMilliSeconds = 0256recSeconds = 0257recMinutes = 0258stage.milliSeconds = 0259stage.seconds = 0260stage.minutes = 0261engine.state = 8262263#platform: USE_ORIGINS264CallNativeFunction4(NotifyCallback, NOTIFY_STATS_ENEMY, StageStatsUsabilityParam1, StageStatsUsabilityParam2, StageStatsUsabilityParam3)265StageStatsUsabilityParam1 = 0266StageStatsUsabilityParam2 = 0267StageStatsUsabilityParam3 = 0268StageStatsUsabilityParam4 = 0269StageStatsUsabilityParam5 = 0270StatsUsabilityParam1 = 0271StatsUsabilityParam2 = 0272StatsUsabilityParam3 = 0273StatsUsabilityParam4 = 0274StatsUsabilityParam5 = 0275#endplatform276end if277SetScreenFade(0, 0, 0, object.timer)278break279280#platform: USE_ORIGINS281case DEATHEVENT_WAITFORCALLBACK282if game.callbackResult >= 0283object.timer = 0284object.state = DEATHEVENT_RETRY285end if286break287288case DEATHEVENT_RETRY289if object.timer < 288290music.volume -= 2291object.timer += 4292else293if game.callbackResult == 0294engine.state = 8295else296LoadStage()297end if298end if299300SetScreenFade(0, 0, 0, object.timer)301break302303case DEATHEVENT_SETSCREENFADE304SetScreenFade(0, 0, 0, 255)305break306#endplatform307end switch308end event309310311event ObjectDraw312switch object.state313case DEATHEVENT_GAMEOVER314DrawSpriteScreenXY(0, object.leftTextPos, 96)315DrawSpriteScreenXY(2, object.rightTextPos, 96)316break317318case DEATHEVENT_TIMEOVER319DrawSpriteScreenXY(1, object.leftTextPos, 96)320DrawSpriteScreenXY(2, object.rightTextPos, 96)321break322323end switch324end event325326327event ObjectStartup328LoadSpriteSheet("Global/Display.gif")329330// Death Event frames331SpriteFrame(0, 0, 64, 16, 1, 239) // 0 - "Game"332SpriteFrame(0, 0, 56, 16, 66, 239) // 1 - "Time"333SpriteFrame(0, 0, 64, 16, 123, 239) // 2 - "Over"334end event335336337// ========================338// Editor Events339// ========================340341event RSDKDraw342DrawSprite(0)343end event344345346event RSDKLoad347LoadSpriteSheet("Global/Display.gif")348SpriteFrame(-16, -16, 32, 32, 1, 143)349350SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")351end event352353354