Path: blob/master/Sonic 1/Scripts/Credits/CreditsControl.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Credits 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 : CREDITSCONTROL_INIT // Initialization state14private alias 1 : CREDITSCONTROL_FADEIN // Fade in for when showing text15private alias 2 : CREDITSCONTROL_DISPLAY // Pausing to let the player read the credit text16private alias 3 : CREDITSCONTROL_FADEOUT // Fade out for when fading out of credits text17private alias 4 : CREDITSCONTROL_FADEIN2 // Speical fade in for when going to the angry Eggman screen18private alias 5 : CREDITSCONTROL_END_PAUSE // Pause for when on the angry Eggman screen19private alias 6 : CREDITSCONTROL_FADEOUT_FINAL // Fading out of the angry Eggman screen2021// Priority Aliases22private alias 1 : PRIORITY_ACTIVE2324// Presentation Stage Aliases25private alias 0 : STAGE_P_TITLE2627// Regular Stage Aliases28private alias 0 : STAGE_R_GHZ129private alias 4 : STAGE_R_MZ230private alias 8 : STAGE_R_SYZ331private alias 11 : STAGE_R_LZ332private alias 14 : STAGE_R_SLZ333private alias 15 : STAGE_R_SBZ134private alias 16 : STAGE_R_SBZ2353637// ========================38// Events39// ========================4041event ObjectUpdate42switch object.state43case CREDITSCONTROL_INIT44// Start the fade effect45object.timer = 32046SetScreenFade(0, 0, 0, object.timer)4748// Go to the fade-in state49object.state++5051// Only start the music on the first screen52// (This object is refreshed between gameplay demos so this has to be in an if statement)53if credits.screen == 054PlayMusic(0)55end if56break5758case CREDITSCONTROL_FADEIN59if object.timer > 060object.timer -= 861else62object.alpha = 12863object.state++64end if6566SetScreenFade(0, 0, 0, object.timer)67break6869case CREDITSCONTROL_DISPLAY70object.timer++7172// Pause for 136 frames73if object.timer == 13674object.timer = 075object.state++76end if77break7879case CREDITSCONTROL_FADEOUT80if object.timer < 25681object.timer += 882SetScreenFade(0, 0, 0, object.timer)83else84// Start the demo8586// Object gets cleared in a few frames anyway, but might as well87object.state = CREDITSCONTROL_INIT8889// Increment the scredits.screen value90// Note that this makes 1 the first value, with 0 coming last91credits.screen++92credits.screen %= 99394// Move the camera to the curresponding position95// Another note: The text isn't actual text being drawn,96// instead each screen is built into the level tiles/chunks97// Because of this, moving to the next credits screen means moving the camera down98temp0 = credits.screen99temp0 <<= 8100screen.yoffset = temp0101102// Turn on attract mode103options.attractMode = true104105// Load the appropriate demo stage106switch credits.screen107case 0108// Final demo (check out note above, demos go 1-8 and then end at 0)109110// Pay a visit to angry Eggman111object.state = CREDITSCONTROL_FADEIN2112113// Determine whether the ending is good or not based on emerald count114// Of course, change between 6 and 7 emeralds depending on emerald count setting115if options.superStates == false116if specialStage.emeralds >= 0x3F // Six 1's in binary117screen.yoffset = 0xA00118else119screen.yoffset = 0x900120end if121else122if specialStage.emeralds >= 0x7F // Seven 1's in binary123screen.yoffset = 0xA00124else125screen.yoffset = 0x900126end if127end if128break129130case 1131case 8132stage.activeList = REGULAR_STAGE133stage.listPos = STAGE_R_GHZ1134LoadStage()135break136137case 2138stage.activeList = REGULAR_STAGE139stage.listPos = STAGE_R_MZ2140LoadStage()141break142143case 3144stage.activeList = REGULAR_STAGE145stage.listPos = STAGE_R_SYZ3146LoadStage()147break148149case 4150stage.activeList = REGULAR_STAGE151stage.listPos = STAGE_R_LZ3152LoadStage()153break154155case 5156stage.activeList = REGULAR_STAGE157stage.listPos = STAGE_R_SLZ3158LoadStage()159break160161case 6162stage.activeList = REGULAR_STAGE163stage.listPos = STAGE_R_SBZ1164LoadStage()165break166167case 7168stage.activeList = REGULAR_STAGE169stage.listPos = STAGE_R_SBZ2170LoadStage()171break172173end switch174175// Set the screen to black176SetScreenFade(0, 0, 0, 255)177end if178break179180case CREDITSCONTROL_FADEIN2181// Fade-in for when going to ending screen182if object.timer > 0183object.timer -= 8184else185object.alpha = 128186object.state++187end if188189SetScreenFade(0, 0, 0, object.timer)190break191192case CREDITSCONTROL_END_PAUSE193object.timer++194195// Advance time is up196if object.timer == 1200197object.timer = 0198object.state++199end if200201// Advance if the player wants to skip the cutscene, too202if keyPress[0].start == true203object.timer = 0204object.state = CREDITSCONTROL_FADEOUT_FINAL205end if206207if keyPress[0].buttonA == true208object.timer = 0209object.state = CREDITSCONTROL_FADEOUT_FINAL210end if211212if keyPress[0].buttonB == true213object.timer = 0214object.state = CREDITSCONTROL_FADEOUT_FINAL215end if216217if keyPress[0].buttonC == true218object.timer = 0219object.state = CREDITSCONTROL_FADEOUT_FINAL220end if221222#platform: MOBILE223if object.timer > 60224CheckTouchRect(0, 0, screen.xsize, screen.ysize)225226if checkResult > -1227object.timer = 0228object.state = CREDITSCONTROL_FADEOUT_FINAL229end if230end if231#endplatform232break233234case CREDITSCONTROL_FADEOUT_FINAL235// Final fade-out before going back236if object.timer < 256237object.timer += 8238SetScreenFade(0, 0, 0, object.timer)239else240// Go back to the menu now241242stage.activeList = PRESENTATION_STAGE243stage.listPos = STAGE_P_TITLE244StopMusic()245246options.attractMode = false247248#platform: USE_STANDALONE249engine.state = 7250#endplatform251#platform: USE_ORIGINS252engine.state = 8253#endplatform254SetScreenFade(0, 0, 0, 255)255#platform: USE_ORIGINS256CallNativeFunction2(NotifyCallback, NOTIFY_STATS_MOVIE, true)257#endplatform258end if259break260261end switch262263// Center the text around the screen264temp0 = screen.xcenter265FlipSign(temp0)266temp0 += 256267screen.xoffset = temp0268end event269270271event ObjectStartup272SetMusicTrack("Credits.ogg", 0, false)273274// Hide touch controls275options.touchControls = false276277// Position the screen based on the current credits screen278// -> This scene is entirely refreshed between demo playbacks, so we can't look at where the camera was previously279temp0 = credits.screen280temp0 <<= 8281screen.yoffset = temp0282283foreach (TypeName[Credits Control], arrayPos0, ALL_ENTITIES)284object[arrayPos0].priority = PRIORITY_ACTIVE285next286end event287288289// ========================290// Editor Events291// ========================292293event RSDKDraw294DrawSprite(0)295end event296297298event RSDKLoad299LoadSpriteSheet("Global/Display.gif")300SpriteFrame(-16, -16, 32, 32, 1, 143)301302SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")303end event304305306