Path: blob/master/Sonic 2/Scripts/Ending/EndSetup.txt
1478 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Ending Setup Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.timer12private alias object.value2 : object.blendAmount13private alias object.value3 : object.tornadoTimer14// values 4-13 are unused...15private alias object.value14 : object.paletteTimer16private alias object.value15 : object.bgTowerLightPalIndex17private alias object.value16 : object.rainbowLightPalIndex18private alias object.value17 : object.chemLiquidPalIndex119private alias object.value18 : object.chemLiquidPalIndex220private alias object.value19 : object.chemLiquidPalIndex32122private alias object.value20 : object.srcBlendPal2324private alias 0 : ENDSETUP_INIT25private alias 1 : ENDSETUP_FADEINIMAGE26private alias 2 : ENDSETUP_DISPLAYIMAGE27private alias 3 : ENDSETUP_FADEOUTIMAGE28private alias 4 : ENDSETUP_ENTERPLAYER29private alias 5 : ENDSETUP_PLAYERFALLING30private alias 6 : ENDSETUP_SPAWNTORNADO31private alias 7 : ENDSETUP_TORNADOSPAWNED3233// Player Aliases34private alias object.type : player.type35private alias object.state : player.state36private alias object.visible : player.visible37private alias object.xpos : player.xpos38private alias object.ypos : player.ypos39private alias object.speed : player.speed40private alias object.frame : player.frame41private alias object.animation : player.animation42private alias object.prevAnimation : player.prevAnimation4344private alias object.value0 : player.rings45private alias object.value7 : player.invincibleTimer46private alias object.value8 : player.blinkTimer47private alias object.value18 : player.sortedDrawOrder4849// Tracks50private alias 0 : TRACK_STAGE5152// Super States53private alias 1 : SUPERSTATE_SUPER545556// ========================57// Static Values58// ========================5960public value EndingSetup_scrollVelocity.x = 061public value EndingSetup_scrollVelocity.y = 0626364// ========================65// Tables66// ========================6768// All these tables are copies of DEZ's tables69private table EndingSetup_bgTowerPalTable700xE00000, 0xC00000, 0xA00000, 0x800000, 0x600000, 0x400000, 0x200000, 0x400000710x600000, 0x800000, 0xA00000, 0xC00000, 0xE00000, 0xE02000, 0xE04000, 0xE0200072end table7374private table EndingSetup_blendLightPalTable750x00E000, 0x20C000, 0x40A000, 0x608000, 0x806000, 0xA04000, 0xC02000760xE00000, 0xC00020, 0xA00040, 0x800060, 0x600080, 0x4000A0, 0x2000C0770x0000E0, 0x0020C0, 0x0040A0, 0x006080, 0x008060, 0x00A040, 0x00C02078end table7980private table EndingSetup_chemLiquidPalTable810x0040E0, 0x0000C0, 0x0000C0820x0060E0, 0x0020C0, 0x0000C0830x0040E0, 0x0040E0, 0x0000C0840x0020C0, 0x0060E0, 0x0020C0850x0000C0, 0x0040E0, 0x0040C0860x0000C0, 0x0020C0, 0x0040E0870x0000C0, 0x0000C0, 0x0060E0880x0020C0, 0x0000C0, 0x0040E0890x0020E0, 0x0000C0, 0x0020C090end table9192// Unused table, also in CPZ and DEZ93// See CPZSetup/DEZSetup for full explanation94private table EndingSetup_unusedPalette950x00E000, 0x00A000, 0x006000, 0x002000, 0x000000, 0x000020, 0x000060, 0x0020A0960x0060E0, 0x0020A0, 0x000060, 0x000020, 0x000000, 0x200000, 0x600000, 0xA00000970xE00000, 0xE04000, 0xE00000, 0xA00000, 0x600000, 0x200000, 0x000000, 0x202000980x606000, 0xA0A000, 0xE0E000, 0xA0A000, 0x606000, 0x202000, 0x000000, 0x002000990x006000, 0x00A000100end table101102103// ========================104// Events105// ========================106107event ObjectUpdate108// Update palette cycling109// (This is just a duplicate of the DEZ palette cycle code, here so that DEZ will look normal for the short moment it appears)110object.paletteTimer++111if object.paletteTimer == 8112object.paletteTimer = 0113114object.bgTowerLightPalIndex++115object.bgTowerLightPalIndex &= 15116GetTableValue(temp0, object.bgTowerLightPalIndex, EndingSetup_bgTowerPalTable)117SetPaletteEntry(0, 175, temp0)118119object.rainbowLightPalIndex++120object.rainbowLightPalIndex %= 21121GetTableValue(temp0, object.rainbowLightPalIndex, EndingSetup_blendLightPalTable)122SetPaletteEntry(0, 191, temp0)123124object.chemLiquidPalIndex1 += 3125object.chemLiquidPalIndex1 %= 27126GetTableValue(temp0, object.chemLiquidPalIndex1, EndingSetup_chemLiquidPalTable)127SetPaletteEntry(0, 188, temp0)128129object.chemLiquidPalIndex2 += 3130object.chemLiquidPalIndex2 %= 27131GetTableValue(temp0, object.chemLiquidPalIndex2, EndingSetup_chemLiquidPalTable)132SetPaletteEntry(0, 189, temp0)133134object.chemLiquidPalIndex3 += 3135object.chemLiquidPalIndex3 %= 27136GetTableValue(temp0, object.chemLiquidPalIndex3, EndingSetup_chemLiquidPalTable)137SetPaletteEntry(0, 190, temp0)138end if139140switch object.state141case ENDSETUP_INIT142// Start off with making the clouds go really fast, to give the illusion Sonic himself is falling really fast143EndingSetup_scrollVelocity.x = -0x06000144EndingSetup_scrollVelocity.y = -0x10000145146object.state = ENDSETUP_FADEINIMAGE147player[0].animation = ANI_FANROTATE148149temp0 = 0150while temp0 < 256151// Set up palettes for the fades152153// Quick palette map:154// > Palette ID 0 is the normal one with everything on it155// > Palette ID 1 is global (main-character-only)156// > Palette ID 2 is off-white, used when the picture slides of Tails are playing157// > Palette ID 3 is full white, used when Sonic's falling in the void158159SetPaletteEntry(2, temp0, 0xE0E0E0)160SetPaletteEntry(3, temp0, 0xFFFFFF)161temp0++162loop163164// Start the music!165PlayMusic(TRACK_STAGE)166167// Check if it's the good ending168if specialStage.emeralds >= 0x7F169// Do some anti-Tails checks in case his Super form is turned off170// (Which it always is, meaning Tails never really gets a good ending)171CheckEqual(stage.playerListPos, PLAYER_TAILS_A)172temp0 = checkResult173CheckEqual(options.superTails, false)174temp0 &= checkResult175#platform: USE_ORIGINS176// Amy doesn't get her super form in the ending either177CheckEqual(stage.playerListPos, PLAYER_AMY)178temp0 |= checkResult179CheckEqual(stage.playerListPos, PLAYER_AMY_TAILS)180temp0 |= checkResult181#endplatform182183if temp0 == false184// Make the player go Super185Player_superState = SUPERSTATE_SUPER186187player[0].sortedDrawOrder = 5188189#platform: USE_STANDALONE190if stage.playerListPos == PLAYER_KNUCKLES_A191// Knuckles gets to glide down all cool and all192player[0].animation = ANI_GLIDING193player[0].prevAnimation = ANI_GLIDING194player[0].frame = 2195else196// Tails gets to fly down197// (Though again, this doesn't get used since the variable for it is turned off)198player[0].animation = ANI_FLYING199end if200#endplatform201202player[0].speed = 0x100000203player[0].invincibleTimer = 60204player[0].blinkTimer = 0205player[0].visible = true206player[0].rings = 0xFFFF // In case the player has their super form, this makes sure they don't lose it207208switch stage.playerListPos209case PLAYER_SONIC_A210case PLAYER_SONIC_TAILS_A211// Super Sonic does his air run when descending212player[0].animation = ANI_RUNNING213214// Make Super Sonic appear rather than just standard Sonic215arrayPos0 = stage.entityPos216stage.entityPos = 0217LoadAnimation("SuperSonic.ani")218stage.entityPos = arrayPos0219break220221#platform: USE_ORIGINS222case PLAYER_TAILS_A223player[0].animation = ANI_FLYING224break225226case PLAYER_KNUCKLES_A227case PLAYER_KNUCKLES_TAILS_A228player[0].animation = ANI_GLIDING229player[0].prevAnimation = ANI_GLIDING230player[0].frame = 2231break232233case PLAYER_AMY_A234case PLAYER_AMY_TAILS_A235break236#endplatform237end switch238end if239end if240241object.srcBlendPal = 3242SetPaletteFade(1, 0, object.srcBlendPal, object.blendAmount, 0, 255)243244#platform: USE_STANDALONE245if stage.playerListPos != PLAYER_SONIC_A246if stage.playerListPos != PLAYER_SONIC_TAILS_A247// Don't display the images for other characters and make them fall for a really long time instead248249// Set the active layer to space250stage.activeLayer[0] = 1251252// And put the player up in the sky253player[0].xpos = 0x00D40000254player[0].ypos = 0x01050000255256object.frame = 4257object.blendAmount = 976258object.state = ENDSETUP_ENTERPLAYER259end if260end if261#endplatform262263#platform: USE_ORIGINS264// I don't really know what was wrong with how it worked before, but they changed this check265switch stage.playerListPos266case PLAYER_TAILS_A267case PLAYER_KNUCKLES_A268case PLAYER_KNUCKLES_TAILS_A269case PLAYER_AMY_A270case PLAYER_AMY_TAILS_A271stage.activeLayer[0] = 1272player[0].xpos = 0x00D40000273player[0].ypos = 0x01050000274object.frame = 4275object.blendAmount = 976276object.state = ENDSETUP_ENTERPLAYER277break278end switch279#endplatform280281SetActivePalette(1, 0, screen.ysize)282break283284case ENDSETUP_FADEINIMAGE285object.blendAmount -= 8286SetPaletteFade(1, 0, object.srcBlendPal, object.blendAmount, 0, 255)287if object.blendAmount <= 0288object.timer = 360289object.state = ENDSETUP_DISPLAYIMAGE290end if291break292293case ENDSETUP_DISPLAYIMAGE294object.timer--295if object.timer == 0296object.state = ENDSETUP_FADEOUTIMAGE297if object.frame == 3298// Final image was just shown, use the full white palette for the fade299object.srcBlendPal = 3300else301// Use the off-white/grey palette302object.srcBlendPal = 2303end if304end if305break306307case ENDSETUP_FADEOUTIMAGE308object.blendAmount += 8309SetPaletteFade(1, 0, object.srcBlendPal, object.blendAmount, 0, 255)310if object.blendAmount >= 736311object.frame++312if object.frame == 4313// Final image was just displayed - go on to the in-game portion of the cutscene now314315// Set the active layer to space316stage.activeLayer[0] = 1317318player[0].xpos = 0x00D40000319player[0].ypos = 0x01050000320321object.state = ENDSETUP_ENTERPLAYER322else323// Start the next image324object.state = ENDSETUP_FADEINIMAGE325end if326end if327break328329case ENDSETUP_ENTERPLAYER330object.blendAmount -= 8331temp0 = object.blendAmount332temp0 -= 512333if temp0 < 0334temp0 = 0335end if336337SetPaletteFade(1, 0, object.srcBlendPal, temp0, 0, 63)338SetPaletteFade(1, 0, object.srcBlendPal, object.blendAmount, 64, 255)339340if object.blendAmount <= 0341object.state = ENDSETUP_PLAYERFALLING342SetActivePalette(0, 0, screen.ysize)343end if344// [Fallthrough]345case ENDSETUP_PLAYERFALLING346object.tornadoTimer++347348player[0].ypos += 0x10000349if player[0].ypos >= 0x1E00000350object.state = ENDSETUP_SPAWNTORNADO351end if352break353354case ENDSETUP_SPAWNTORNADO355object.tornadoTimer++356object.timer--357if object.timer < 0358Rand(object.timer, 32)359temp0 = screen.ysize360temp0 += camera[0].ypos361temp0 += 16362temp0 <<= 16363CreateTempObject(TypeName[Cloud], 0, 0, temp0)364Rand(object[tempObjectPos].frame, 4)365if object[tempObjectPos].frame == 3366object[tempObjectPos].frame = 2367else368FlipSign(object[tempObjectPos].frame)369object[tempObjectPos].frame += 2370end if371object[tempObjectPos].drawOrder = object[tempObjectPos].frame372object[tempObjectPos].drawOrder++373374temp0 = screen.xsize375Rand(object[tempObjectPos].xpos, temp0)376object[tempObjectPos].xpos <<= 16377378temp0 = screen.ysize379temp0 += camera[0].ypos380temp0 += 16381temp0 <<= 16382CreateTempObject(TypeName[Cloud], 0, 0, temp0)383Rand(object[tempObjectPos].frame, 4)384if object[tempObjectPos].frame == 3385object[tempObjectPos].frame = 2386else387FlipSign(object[tempObjectPos].frame)388object[tempObjectPos].frame += 2389end if390391object[tempObjectPos].drawOrder = object[tempObjectPos].frame392object[tempObjectPos].drawOrder++393394temp0 = screen.xsize395Rand(object[tempObjectPos].xpos, temp0)396object[tempObjectPos].xpos += temp0397object[tempObjectPos].xpos <<= 16398end if399400temp0 = 488401402#platform: USE_STANDALONE403if stage.playerListPos != PLAYER_SONIC_A404if stage.playerListPos != PLAYER_SONIC_TAILS_A405// The other characters don't get special images at all, so make their timer ridiculously long406temp0 = 2608407end if408end if409#endplatform410411#platform: USE_ORIGINS412// Again, what was wrong before?413switch stage.playerListPos414case PLAYER_TAILS_A415case PLAYER_KNUCKLES_A416case PLAYER_KNUCKLES_TAILS_A417case PLAYER_AMY_A418case PLAYER_AMY_TAILS_A419temp0 = 2608420end switch421#endplatform422423if object.tornadoTimer == temp0424// Spawn the Tornado425426object[33].type = TypeName[Tornado]427object[33].priority = PRIORITY_ACTIVE428429object[33].ypos = screen.ycenter430object[33].ypos += camera[0].ypos431object[33].ypos += 21432433#platform: USE_STANDALONE434if stage.playerListPos != PLAYER_TAILS_A435// Shift the Tornado a bit for other characters since they have a different hitbox than Tails436object[33].ypos += 4437end if438#endplatform439440#platform: USE_ORIGINS441switch stage.playerListPos442case PLAYER_SONIC_A443case PLAYER_KNUCKLES_A444case PLAYER_SONIC_TAILS_A445case PLAYER_KNUCKLES_TAILS_A446object[33].ypos += 4447break448449case PLAYER_AMY_A450case PLAYER_AMY_TAILS_A451object[33].ypos++452break453end switch454#endplatform455456// Turn the YPos from screen-space into world-space457object[33].ypos <<= 16458459// Although the Tornado itself doesn't use transparency, the logo rendered by it does460object[33].inkEffect = INK_ALPHA461object[33].alpha = 0462end if463464// (Clouds are stabalized by Tornado object, not here)465466if EndingSetup_scrollVelocity.y >= 0467object.state = ENDSETUP_TORNADOSPAWNED468end if469break470471case ENDSETUP_TORNADOSPAWNED472object.timer--473if object.timer < 0474Rand(object.timer, 32)475temp0 = screen.xsize476temp0 += 16477temp0 <<= 17478CreateTempObject(TypeName[Cloud], 0, temp0, 0)479480Rand(object[tempObjectPos].frame, 4)481if object[tempObjectPos].frame == 3482object[tempObjectPos].frame = 2483else484FlipSign(object[tempObjectPos].frame)485object[tempObjectPos].frame += 2486end if487488object[tempObjectPos].drawOrder = object[tempObjectPos].frame489object[tempObjectPos].drawOrder++490object[tempObjectPos].priority = PRIORITY_ACTIVE491492temp0 = screen.ysize493Rand(object[tempObjectPos].ypos, temp0)494object[tempObjectPos].ypos += camera[0].ypos495object[tempObjectPos].ypos -= screen.ycenter496object[tempObjectPos].ypos <<= 16497end if498break499500end switch501502// Hide the touch controls503options.touchControls = false504end event505506507event ObjectDraw508if object.frame < 4509temp0 = screen.xcenter510temp0 <<= 16511temp1 = screen.ycenter512temp1 <<= 16513DrawSpriteXY(object.frame, temp0, temp1)514end if515end event516517518event ObjectStartup519LoadSpriteSheet("Ending/Objects.gif")520521// Ending pictures522SpriteFrame(-48, -36, 96, 72, 318, 1) // Animals looking up at the sky523SpriteFrame(-48, -36, 96, 72, 415, 1) // Tails among the crowd of animals524SpriteFrame(-48, -36, 96, 72, 318, 74) // Tails firing up the Tornado525SpriteFrame(-48, -36, 96, 72, 415, 74) // Tornado in the air with a couple of flickies in tow526527SetMusicTrack("Ending.ogg", TRACK_STAGE, false)528529// No badniks appear in this stage, so no freed animals should appear, either530// (The flickies are just spawned directly)531animalType1 = TypeName[Blank Object]532animalType2 = TypeName[Blank Object]533534// Remove P2535player[1].type = TypeName[Blank Object]536playerCount = 1537538// Place this object into the level and setup its values539object[10].type = TypeName[Ending Setup]540object[10].priority = PRIORITY_ACTIVE541object[10].chemLiquidPalIndex2 = 1542object[10].chemLiquidPalIndex3 = 2543object[10].blendAmount = 0x100544545// P1 is controlled via other objects, so blank its state546player[0].state = Player_State_Static547548#platform: USE_ORIGINS549if specialStage.emeralds >= 0x7F550CallNativeFunction2(NotifyCallback, NOTIFY_GOOD_ENDING, 0)551end if552#endplatform553end event554555556// ========================557// Editor Events558// ========================559560event RSDKDraw561DrawSprite(0)562end event563564565event RSDKLoad566LoadSpriteSheet("Ending/Objects.gif")567SpriteFrame(-48, -36, 96, 72, 318, 1) // Ending Cutscene Image 1 - #0568569SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")570end event571572573