Path: blob/master/Sonic 2/Scripts/CPZ/CPZSetup.txt
1478 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: CPZ Setup Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.aniTileTimer12// value1 is unused?13private alias object.value2 : object.scrollPos1415// Values used for updating the underwater Super Palette16private alias object.value6 : object.clrDivisor_R17private alias object.value7 : object.clrDivisor_G18private alias object.value8 : object.clrDivisor_B19private alias object.value9 : object.waterClrDivisor_R20private alias object.value10 : object.waterClrDivisor_G21private alias object.value11 : object.waterClrDivisor_B2223private alias object.value12 : object.drawingIndex24private alias object.value13 : object.rippleTimer25private alias object.value14 : object.paletteTimer26private alias object.value15 : object.bgTowerLightPalIndex27private alias object.value16 : object.rainbowLightPalIndex28private alias object.value17 : object.chemLiquidPalIndex129private alias object.value18 : object.chemLiquidPalIndex230private alias object.value19 : object.chemLiquidPalIndex33132// Tracks33private alias 0 : TRACK_STAGE34private alias 1 : TRACK_ACTFINISH35private alias 2 : TRACK_INVINCIBLE36private alias 3 : TRACK_CONTINUE37private alias 4 : TRACK_BOSS38private alias 5 : TRACK_GAMEOVER39private alias 6 : TRACK_DROWNING40private alias 7 : TRACK_SUPER4142// Reserved object slots43private alias 10 : SLOT_ZONESETUP44private alias 25 : SLOT_MUSICEVENT_CHANGE45private alias 26 : SLOT_MUSICEVENT_BOSS4647// Music Events48private alias 2 : MUSICEVENT_TRANSITION4950private alias 0 : MUSICEVENT_FLAG_NOCHANGE51private alias 1 : MUSICEVENT_FLAG_SPEEDUP52private alias 2 : MUSICEVENT_FLAG_SLOWDOWN5354// Music Loops55private alias 684580 : MUSIC_LOOP_CPZ56private alias 547578 : MUSIC_LOOP_CPZ_F5758private alias 38679 : MUSIC_LOOP_INV59private alias 30897 : MUSIC_LOOP_INV_F6061// Achievement Aliases62private alias 1 : ACHIEVEMENT_CHEMICALFREE636465// ========================66// Function Declarations67// ========================6869reserve function CPZSetup_getClrDivisor70reserve function CPZSetup_InitSuperSonicPal71reserve function CPZSetup_InitSuperTailsPal72reserve function CPZSetup_InitSuperKnuxPal73reserve function CPZSetup_InitSuperAmyPal74reserve function CPZSetup_SpeedUpMusic75reserve function CPZSetup_SlowDownMusic767778// ========================79// Static Values80// ========================8182public value CPZSetup_rotatingStairTimer = 083public value Water_flashTimer = 084public value CPZSetup_enteredWater = 085private value CPZSetup_hasAchievement = 086private value CPZSetup_waterTintActive = 0878889// ========================90// Tables91// ========================9293private table CPZSetup_bgTowerLightPalTable940xE00000, 0xC00000, 0xA00000, 0x800000, 0x600000, 0x400000, 0x200000, 0x400000950x600000, 0x800000, 0xA00000, 0xC00000, 0xE00000, 0xE02000, 0xE04000, 0xE0200096end table9798private table CPZSetup_rainbowLightPalTable990x00E000, 0x20C000, 0x40A000, 0x608000, 0x806000, 0xA04000, 0xC020001000xE00000, 0xC00020, 0xA00040, 0x800060, 0x600080, 0x4000A0, 0x2000C01010x0000E0, 0x0020C0, 0x0040A0, 0x006080, 0x008060, 0x00A040, 0x00C020102end table103104private table CPZSetup_chemLiquidPalTable1050x0040E0, 0x0000C0, 0x0000C01060x0060E0, 0x0020C0, 0x0000C01070x0040E0, 0x0040E0, 0x0000C01080x0020C0, 0x0060E0, 0x0020C01090x0000C0, 0x0040E0, 0x0040C01100x0000C0, 0x0020C0, 0x0040E01110x0000C0, 0x0000C0, 0x0060E01120x0020C0, 0x0000C0, 0x0040E01130x0020E0, 0x0000C0, 0x0020C0114end table115116private table CPZSetup_deformationTable1171, 2, 1, 3, 1, 2, 2, 1, 2, 3, 1, 2, 1, 2, 0, 01182, 0, 3, 2, 2, 3, 2, 2, 1, 3, 0, 0, 1, 0, 1, 31191, 2, 1, 3, 1, 2, 2, 1, 2, 3, 1, 2, 1, 2, 0, 01202, 0, 3, 2, 2, 3, 2, 2, 1, 3, 0, 0, 1, 0, 1, 3121end table122123// Unused palette table, also found in DEZSetup and EndSetup and even Mania's CPZ!124// These are actually colors for one of WFZ's palette cycles125// However, you won't find this in WFZSetup because in this 2013 remake, WFZ only uses 1 of the 3 palette cycles it had in the original game,126// this one being among the 2 that were cut127// Why they were cut, I have no idea, but at the very least, it's certainly a mystery how one of them ended up here of all places...128private table CPZSetup_unusedPalette1290x00E000, 0x00A000, 0x006000, 0x002000, 0x000000, 0x000020, 0x000060, 0x0020A0, 0x0060E0, 0x0020A0, 0x000060, 0x000020, 0x000000, 0x200000, 0x600000, 0xA000001300xE00000, 0xE04000, 0xE00000, 0xA00000, 0x600000, 0x200000, 0x000000, 0x202000, 0x606000, 0xA0A000, 0xE0E000, 0xA0A000, 0x606000, 0x202000, 0x000000, 0x0020001310x006000, 0x00A000132end table133134private table CPZSetup_replay_attract_S1350x380000, 0x1EC00001360x00, 101370x08, 521380x38, 11390x28, 51400x08, 351410x38, 11420x28, 81430x08, 2551440x08, 2141450x00, 91460x04, 31470x34, 11480x24, 91490x28, 21500x08, 541510x00, 21520x04, 21530x00, 11540x08, 1921550x38, 11560x28, 411570x08, 131580x0A, 11590x02, 261600x0A, 21610x08, 161620x00, 21630x04, 221640x00, 81650x08, 341660x38, 11670x28, 31680x08, 321690x00, 11700x04, 101710x00, 11720x08, 101730x00, 161740x04, 391750x00, 11760x02, 201770x00, 11780x04, 291790x00, 371800x04, 121810x00, 41820x04, 41830x00, 241840x30, 11850x20, 41860x04, 71870x00, 201880x04, 301890x00 // There's supposed to be an even amount of entries, since these come in pairs, but I guess this table felt like having an extra value?190end table191192private table CPZSetup_replay_attract_T1930x380000, 0x1F000001940x00, 531950x08, 451960x38, 11970x28, 61980x08, 341990x38, 12000x28, 92010x08, 552020x38, 12030x28, 212040x08, 2492050x38, 12060x28, 122070x08, 842080x38, 12090x28, 212100x08, 1382110x38, 12120x28, 92130x2A, 162140x0A, 92150x08, 962160x0A, 42170x02, 92180x0A, 22190x08, 712200x00, 112210x04, 442220x00, 132230x04, 42240x00, 42250x04, 102260x00, 92270x04, 92280x00, 32290x04, 392300x00, 62310x04, 112320x00, 72330x04, 52340x00, 132350x30, 12360x20, 32370x28, 12380x08, 52390x38, 12400x28, 32410x20, 22420x00, 42430x30, 12440x20, 42450x00, 42460x38, 12470x28, 42480x08, 42490x38, 12500x20, 52510x00, 32520x30, 12530x20, 62540x00, 32550x04, 12560x34, 12570x24, 52580x04, 32590x34, 12600x24, 12610x20, 42620x00, 42630x38, 12640x28, 42650x08, 22660x00, 32670x30, 12680x20, 42690x00, 42700x30, 12710x20, 42720x00, 42730x30, 12740x20, 42750x00, 42760x38, 12770x28, 42780x08, 42790x38, 12800x28, 12810x20, 42820x00, 42830x30, 12840x20, 42850x00, 42860x30, 12870x20, 52880x00, 42890x30, 12900x20, 52910x00, 32920x08, 122930x00, 112940x08, 342950x38, 12960x28, 212970x08, 32980x00, 132990x08, 1193000x38, 2301end table302303private table CPZSetup_replay_attract_K3040x380000, 0x1EC00003050x00, 543060x08, 453070x38, 13080x28, 73090x08, 343100x38, 13110x28, 203120x08, 0xFF3130x08, 2183140x38, 13150x28, 93160x08, 613170x38, 13180x28, 93190x08, 143200x00, 13210x04, 143220x00, 63230x08, 1103240x00, 103250x08, 103260x00, 243270x08, 53280x00, 73290x08, 203300x38, 13310x28, 13320x20, 33330x00, 53340x04, 393350x00, 263360x08, 573370x38, 13380x28, 163390x08, 73400x38, 13410x28, 223420x29, 23430x09, 313440x08, 213450x38, 13460x28, 113470x08, 1753480x0A, 13490x02, 2443500x32, 13510x22, 263520x2A, 13530x28, 13540x08, 43550x38, 13560x28, 243570x08, 23580x00, 253590x08, 53600x38, 13610x28, 103620x08, 323630x00, 13640x04, 233650x00, 43660x08, 20367end table368369370// ========================371// Function Definitions372// ========================373374// Wacky function to take a normal color and turn it into an underwater color375private function CPZSetup_getClrDivisor376// Regular Color377object.clrDivisor_R = temp1378object.clrDivisor_R >>= 16379380object.clrDivisor_G = temp1381object.clrDivisor_G >>= 8382object.clrDivisor_G &= 0xFF383384object.clrDivisor_B = temp1385object.clrDivisor_B &= 0xFF386387// Underwater Color388object.waterClrDivisor_R = temp2389object.waterClrDivisor_R >>= 16390391object.waterClrDivisor_G = temp2392object.waterClrDivisor_G >>= 8393object.waterClrDivisor_G &= 0xFF394395object.waterClrDivisor_B = temp2396object.waterClrDivisor_B &= 0xFF397398// Minimum of 1 (you cant divide by zero)399if object.waterClrDivisor_R == 0400object.waterClrDivisor_R = 1401end if402403if object.waterClrDivisor_G == 0404object.waterClrDivisor_G = 1405end if406407if object.waterClrDivisor_B == 0408object.waterClrDivisor_B = 1409end if410411object.clrDivisor_R <<= 8412object.clrDivisor_G <<= 8413object.clrDivisor_B <<= 8414object.clrDivisor_R /= object.waterClrDivisor_R415object.clrDivisor_G /= object.waterClrDivisor_G416object.clrDivisor_B /= object.waterClrDivisor_B417418if object.clrDivisor_R == 0419object.clrDivisor_R = 0x100420end if421422if object.clrDivisor_G == 0423object.clrDivisor_G = 0x100424end if425426if object.clrDivisor_B == 0427object.clrDivisor_B = 0x100428end if429end function430431432private function CPZSetup_InitSuperSonicPal433temp0 = 0434435// First Set of colors is just the regular underwater palette436GetPaletteEntry(1, 2, temp1)437SetTableValue(temp1, temp0, Player_SonicSuperAltPal)438temp0++439440GetPaletteEntry(1, 3, temp1)441SetTableValue(temp1, temp0, Player_SonicSuperAltPal)442temp0++443444GetPaletteEntry(1, 4, temp1)445SetTableValue(temp1, temp0, Player_SonicSuperAltPal)446temp0++447448GetPaletteEntry(1, 5, temp1)449SetTableValue(temp1, temp0, Player_SonicSuperAltPal)450temp0++451452CopyPalette(1, 0, 4, 2, 4)453while temp0 < 64454GetTableValue(temp1, temp0, Player_SonicSuperPal)455SetPaletteEntry(3, 0, temp1)456temp0++457458GetTableValue(temp1, temp0, Player_SonicSuperPal)459SetPaletteEntry(3, 1, temp1)460temp0++461462GetTableValue(temp1, temp0, Player_SonicSuperPal)463SetPaletteEntry(3, 2, temp1)464temp0++465466GetTableValue(temp1, temp0, Player_SonicSuperPal)467SetPaletteEntry(3, 3, temp1)468temp0 -= 3469470// Just mix the 2 palettes, we'll use the results as our new colors471SetPaletteFade(5, 3, 4, 48, 0, 4)472473GetPaletteEntry(5, 0, temp1)474SetTableValue(temp1, temp0, Player_SonicSuperAltPal)475temp0++476477GetPaletteEntry(5, 1, temp1)478SetTableValue(temp1, temp0, Player_SonicSuperAltPal)479temp0++480481GetPaletteEntry(5, 2, temp1)482SetTableValue(temp1, temp0, Player_SonicSuperAltPal)483temp0++484485GetPaletteEntry(5, 3, temp1)486SetTableValue(temp1, temp0, Player_SonicSuperAltPal)487temp0++488loop489end function490491492private function CPZSetup_InitSuperTailsPal493temp0 = 0494495GetPaletteEntry(1, 13, temp1)496SetTableValue(temp1, temp0, Player_TailsSuperAltPal)497temp0++498499GetPaletteEntry(1, 17, temp1)500SetTableValue(temp1, temp0, Player_TailsSuperAltPal)501temp0++502503GetPaletteEntry(1, 18, temp1)504SetTableValue(temp1, temp0, Player_TailsSuperAltPal)505temp0++506507GetPaletteEntry(1, 16, temp1)508SetTableValue(temp1, temp0, Player_TailsSuperAltPal)509temp0++510511while temp0 < 24512GetPaletteEntry(0, 13, temp1)513GetPaletteEntry(1, 13, temp2)514515CallFunction(CPZSetup_getClrDivisor)516517GetTableValue(temp1, temp0, Player_TailsSuperPal)518519temp2 = temp1520temp2 >>= 8521temp2 &= 0xFF522523temp3 = temp1524temp3 &= 0xFF525526temp1 >>= 16527528temp1 *= 0xF8529temp1 /= object.clrDivisor_R530531temp2 *= 0xF8532temp2 /= object.clrDivisor_G533534temp3 *= 0xF8535temp3 /= object.clrDivisor_B536537temp1 &= 0xF0538temp2 &= 0xF0539temp3 &= 0xF0540541if temp1 > 0xE0542temp1 = 0xE0543end if544545if temp2 > 0xE0546temp2 = 0xE0547end if548549if temp3 > 0xE0550temp3 = 0xE0551end if552553temp1 <<= 16554temp2 <<= 8555temp1 += temp2556temp1 += temp3557SetTableValue(temp1, temp0, Player_TailsSuperAltPal)558temp0++559560561GetPaletteEntry(0, 17, temp1)562GetPaletteEntry(1, 17, temp2)563564CallFunction(CPZSetup_getClrDivisor)565566GetTableValue(temp1, temp0, Player_TailsSuperPal)567568temp2 = temp1569temp2 >>= 8570temp2 &= 0xFF571572temp3 = temp1573temp3 &= 0xFF574575temp1 >>= 16576577temp1 *= 0x100578temp1 /= object.clrDivisor_R579580temp2 *= 0x100581temp2 /= object.clrDivisor_G582583temp3 *= 0x100584temp3 /= object.clrDivisor_B585586temp1 &= 0xF0587temp2 &= 0xF0588temp3 &= 0xF0589590if temp1 > 0xE0591temp1 = 0xE0592end if593594if temp2 > 0xE0595temp2 = 0xE0596end if597598if temp3 > 0xE0599temp3 = 0xE0600end if601602temp1 <<= 16603temp2 <<= 8604temp1 += temp2605temp1 += temp3606SetTableValue(temp1, temp0, Player_TailsSuperAltPal)607temp0++608609610GetPaletteEntry(0, 18, temp1)611GetPaletteEntry(1, 18, temp2)612613CallFunction(CPZSetup_getClrDivisor)614615GetTableValue(temp1, temp0, Player_TailsSuperPal)616617temp2 = temp1618temp2 >>= 8619temp2 &= 0xFF620621temp3 = temp1622temp3 &= 0xFF623624temp1 >>= 16625626temp1 *= 0x100627temp1 /= object.clrDivisor_R628629temp2 *= 0x100630temp2 /= object.clrDivisor_G631632temp3 *= 0x100633temp3 /= object.clrDivisor_B634635temp1 &= 0xF0636temp2 &= 0xF0637temp3 &= 0xF0638639if temp1 > 0xE0640temp1 = 0xE0641end if642643if temp2 > 0xE0644temp2 = 0xE0645end if646647if temp3 > 0xE0648temp3 = 0xE0649end if650651temp1 <<= 16652temp2 <<= 8653temp1 += temp2654temp1 += temp3655SetTableValue(temp1, temp0, Player_TailsSuperAltPal)656temp0++657658659GetPaletteEntry(0, 16, temp1)660GetPaletteEntry(1, 16, temp2)661662CallFunction(CPZSetup_getClrDivisor)663664GetTableValue(temp1, temp0, Player_TailsSuperPal)665666temp2 = temp1667temp2 >>= 8668temp2 &= 0xFF669670temp3 = temp1671temp3 &= 0xFF672673temp1 >>= 16674675temp1 *= 0x100676temp1 /= object.clrDivisor_R677678temp2 *= 0x100679temp2 /= object.clrDivisor_G680681temp3 *= 0x100682temp3 /= object.clrDivisor_B683684temp1 &= 0xF0685temp2 &= 0xF0686temp3 &= 0xF0687688if temp1 > 0xE0689temp1 = 0xE0690end if691692if temp2 > 0xE0693temp2 = 0xE0694end if695696if temp3 > 0xE0697temp3 = 0xE0698end if699700temp1 <<= 16701temp2 <<= 8702temp1 += temp2703temp1 += temp3704SetTableValue(temp1, temp0, Player_TailsSuperAltPal)705temp0++706loop707end function708709710private function CPZSetup_InitSuperKnuxPal711temp0 = 0712713GetPaletteEntry(1, 26, temp1)714SetTableValue(temp1, temp0, Player_KnuxSuperAltPal)715temp0++716717GetPaletteEntry(1, 27, temp1)718SetTableValue(temp1, temp0, Player_KnuxSuperAltPal)719temp0++720721GetPaletteEntry(1, 28, temp1)722SetTableValue(temp1, temp0, Player_KnuxSuperAltPal)723temp0++724end function725726727private function CPZSetup_InitSuperAmyPal728#platform: USE_ORIGINS729temp0 = 0730731GetPaletteEntry(1, 54, temp1)732SetTableValue(temp1, temp0, Player_AmySuperAltPal)733temp0++734735GetPaletteEntry(1, 50, temp1)736SetTableValue(temp1, temp0, Player_AmySuperAltPal)737temp0++738739GetPaletteEntry(1, 51, temp1)740SetTableValue(temp1, temp0, Player_AmySuperAltPal)741temp0++742743GetPaletteEntry(1, 52, temp1)744SetTableValue(temp1, temp0, Player_AmySuperAltPal)745temp0++746747GetPaletteEntry(1, 53, temp1)748SetTableValue(temp1, temp0, Player_AmySuperAltPal)749temp0++750751while temp0 < 30752temp4 = temp0753temp4 -= 5754755GetTableValue(temp1, temp4, Player_AmySuperAltPal)756757temp2 = temp1758temp2 >>= 8759temp2 &= 255760761temp3 = temp1762temp3 &= 255763764temp1 >>= 16765temp1 += 32766if temp1 > 255767temp1 = 255768end if769770temp2 += 32771if temp2 > 255772temp2 = 255773end if774775temp3 += 32776if temp3 > 255777temp3 = 255778end if779780temp1 <<= 16781temp2 <<= 8782temp1 += temp2783temp1 += temp3784SetTableValue(temp1, temp0, Player_AmySuperAltPal)785temp0++786loop787788temp6 = 25789while temp0 < 50790temp5 = 0791while temp5 < 5792temp4 = temp6793temp4 += temp5794GetTableValue(temp1, temp4, Player_AmySuperAltPal)795SetTableValue(temp1, temp0, Player_AmySuperAltPal)796temp0++797temp5++798loop799800temp6 -= 5801loop802#endplatform803end function804805806private function CPZSetup_SpeedUpMusic807CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])808temp0 = checkResult809CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)810temp0 &= checkResult811CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)812temp0 &= checkResult813if temp0 == false814switch music.currentTrack815case TRACK_STAGE816SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)817SwapMusicTrack("ChemicalPlant_F.ogg", TRACK_STAGE, MUSIC_LOOP_CPZ_F, 8000)818break819820case TRACK_INVINCIBLE821SetMusicTrack("ChemicalPlant_F.ogg", TRACK_STAGE, MUSIC_LOOP_CPZ_F)822SwapMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F, 8000)823break824825case TRACK_BOSS826case TRACK_DROWNING827case TRACK_SUPER828SetMusicTrack("ChemicalPlant_F.ogg", TRACK_STAGE, MUSIC_LOOP_CPZ_F)829SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)830break831end switch832else833stage.musicFlag = MUSICEVENT_FLAG_SPEEDUP834end if835end function836837838private function CPZSetup_SlowDownMusic839CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])840temp0 = checkResult841CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)842temp0 &= checkResult843CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)844temp0 &= checkResult845if temp0 == false846switch music.currentTrack847case TRACK_STAGE848SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)849SwapMusicTrack("ChemicalPlant.ogg", TRACK_STAGE, MUSIC_LOOP_CPZ, 12500)850break851852case TRACK_INVINCIBLE853SetMusicTrack("ChemicalPlant.ogg", TRACK_STAGE, MUSIC_LOOP_CPZ)854SwapMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV, 12500)855break856857case TRACK_BOSS858case TRACK_DROWNING859case TRACK_SUPER860SetMusicTrack("ChemicalPlant.ogg", TRACK_STAGE, MUSIC_LOOP_CPZ)861SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)862break863end switch864else865stage.musicFlag = MUSICEVENT_FLAG_SLOWDOWN866end if867end function868869870// ========================871// Events872// ========================873874event ObjectUpdate875#platform: USE_ORIGINS876if stage.state != STAGE_FROZEN877#endplatform878GetTableValue(temp0, 21, StageSetup_oscillationTable)879if temp0 == 0880CPZSetup_rotatingStairTimer++881CPZSetup_rotatingStairTimer &= 3882end if883884object.rippleTimer++885if object.rippleTimer > 7886tileLayer[1].deformationOffset++887object.rippleTimer = 0888end if889890// Animate the converyor belts in the background891object.aniTileTimer++892if object.aniTileTimer == 5893object.aniTileTimer = 0894895object.frame++896object.frame &= 7897temp0 = object.frame898temp0 += 768899Copy16x16Tile(767, temp0)900end if901902if Water_flashTimer > 0903Water_flashTimer--904end if905906// Manage the various cycling palettes throughout the stage907object.paletteTimer++908if object.paletteTimer == 8909object.paletteTimer = 0910911object.bgTowerLightPalIndex++912object.bgTowerLightPalIndex &= 15913GetTableValue(temp0, object.bgTowerLightPalIndex, CPZSetup_bgTowerLightPalTable)914SetPaletteEntry(0, 175, temp0)915916object.rainbowLightPalIndex++917object.rainbowLightPalIndex %= 21918GetTableValue(temp0, object.rainbowLightPalIndex, CPZSetup_rainbowLightPalTable)919SetPaletteEntry(0, 191, temp0)920921object.chemLiquidPalIndex1 += 3922object.chemLiquidPalIndex1 %= 27923GetTableValue(temp0, object.chemLiquidPalIndex1, CPZSetup_chemLiquidPalTable)924SetPaletteEntry(0, 188, temp0)925926object.chemLiquidPalIndex2 += 3927object.chemLiquidPalIndex2 %= 27928GetTableValue(temp0, object.chemLiquidPalIndex2, CPZSetup_chemLiquidPalTable)929SetPaletteEntry(0, 189, temp0)930931object.chemLiquidPalIndex3 += 3932object.chemLiquidPalIndex3 %= 27933GetTableValue(temp0, object.chemLiquidPalIndex3, CPZSetup_chemLiquidPalTable)934SetPaletteEntry(0, 190, temp0)935end if936937if CPZSetup_hasAchievement == false938if stage.debugMode == false939if stage.actNum == 2940if object[30].type == TypeName[Act Finish]941CPZSetup_hasAchievement = true942if CPZSetup_enteredWater == false943// Grant the "100% Chemical Free" Achievement944CallNativeFunction2(SetAchievement, ACHIEVEMENT_CHEMICALFREE, 100)945end if946end if947end if948end if949end if950#platform: USE_ORIGINS951end if952953object.drawingIndex = 0954CPZSetup_waterTintActive = 0955#endplatform956end event957958959event ObjectDraw960#platform: USE_ORIGINS961// If this check doesn't pass, the water tint is skipped over, and the foreground Girders are skipped over as well962// Unfortunately, this check always passes because the value is always set to 0 as seen above LOL963// (Interesting note though - this value does at least reach, but not surpass, 4 in 2PVS where 2 screens are active, does that mean anything?)964if CPZSetup_waterTintActive < 4965#endplatform966if object.drawingIndex == 0967// Activating the Water tint968969temp0 = stage.waterLevel970temp0 -= screen.yoffset971if temp0 < 0972temp0 = 0973end if974if temp0 > screen.ysize975temp0 = screen.ysize976end if977978SetActivePalette(0, 0, temp0)979if Water_flashTimer > 0980SetActivePalette(2, temp0, screen.ysize)981else982SetActivePalette(1, temp0, screen.ysize)983end if984985// Add the object to the draw list again, for the Girders986AddDrawListEntityRef(2, object.entityPos)987else988// Drawing the Girders989990temp0 = screen.xoffset991temp0 *= 6992temp0 >>= 3993temp0 &= 0x1FF994FlipSign(temp0)995temp0 += object.scrollPos996997temp1 = screen.yoffset998temp1 >>= 1999temp1 &= 0xFF1000FlipSign(temp1)10011002DrawSpriteScreenXY(0, temp0, temp1)1003DrawSpriteScreenXY(1, temp0, temp1)1004end if1005#platform: USE_ORIGINS1006end if1007#endplatform10081009object.drawingIndex ^= 11010#platform: USE_ORIGINS1011CPZSetup_waterTintActive++1012#endplatform1013end event101410151016event ObjectStartup1017LoadSpriteSheet("CPZ/Objects.gif")10181019// Reset the boss flashing color1020SetPaletteEntry(0, 192, 0x000000)10211022// Set the Chemical Plant music, and set its speedup/slowndown functions too1023SetMusicTrack("ChemicalPlant.ogg", TRACK_STAGE, MUSIC_LOOP_CPZ)1024SpeedUpMusic = CPZSetup_SpeedUpMusic1025SlowDownMusic = CPZSetup_SlowDownMusic10261027// Sprite Frames - Foreground Girder1028SpriteFrame(-16, 0, 32, 256, 224, 0)1029SpriteFrame(-16, 256, 32, 256, 224, 0)10301031// Conveyor Belt Tile - Frame 11032Copy16x16Tile(767, 768)10331034// Locky and Pocky are the ones swimming in these chemicals1035animalType1 = TypeName[Locky]1036animalType2 = TypeName[Pocky]10371038// Set object 10 to be a CPZ Setup object1039object[SLOT_ZONESETUP].type = TypeName[CPZ Setup]1040#platform: USE_STANDALONE1041object[SLOT_ZONESETUP].priority = PRIORITY_ACTIVE1042#endplatform1043#platform: USE_ORIGINS1044object[SLOT_ZONESETUP].priority = PRIORITY_ALWAYS1045#endplatform1046object[SLOT_ZONESETUP].drawOrder = 01047object[SLOT_ZONESETUP].scrollPos = 4961048object[SLOT_ZONESETUP].chemLiquidPalIndex2 = 11049object[SLOT_ZONESETUP].chemLiquidPalIndex3 = 210501051temp0 = screen.xcenter1052temp0 >>= 21053object[SLOT_ZONESETUP].scrollPos -= temp010541055CPZSetup_rotatingStairTimer = 010561057// Load the water palette1058LoadPalette("CPZ_WaterPal.act", 1, 0, 0, 256)10591060// Init underwater Super palettes1061CallFunction(CPZSetup_InitSuperSonicPal)1062CallFunction(CPZSetup_InitSuperTailsPal)1063CallFunction(CPZSetup_InitSuperKnuxPal)1064#platform: USE_ORIGINS1065CallFunction(CPZSetup_InitSuperAmyPal)1066#endplatform10671068// Load the eletric flash palette in case the player tries to swim with a lightning shield1069LoadPalette("ElectricFlash.act", 2, 0, 0, 256)10701071Water_flashTimer = 010721073// Reset the ripple effect1074arrayPos0 = 01075while arrayPos0 < 5761076temp0 = arrayPos01077temp0 &= 0x3F1078GetTableValue(stage.deformationData2[arrayPos0], temp0, CPZSetup_deformationTable)1079arrayPos0++1080loop10811082if options.attractMode == true1083switch stage.playerListPos1084case PLAYER_SONIC_A1085#platform: USE_ORIGINS1086case PLAYER_AMY_A // Amy isn't even able to show up in demos, but check for her anyway I guess1087#endplatform1088Player_attractTable = CPZSetup_replay_attract_S1089Player_attractTableSize = 1091090Player_attractDuration = 18001091break10921093case PLAYER_TAILS_A1094Player_attractTable = CPZSetup_replay_attract_T1095Player_attractTableSize = 2161096Player_attractDuration = 15601097break10981099case PLAYER_KNUCKLES_A1100Player_attractTable = CPZSetup_replay_attract_K1101Player_attractTableSize = 1261102Player_attractDuration = 16801103break1104end switch11051106CallFunction(Player_SetupAttractDemo)1107end if1108end event110911101111// ========================1112// Editor Events1113// ========================11141115event RSDKDraw1116DrawSprite(0)1117end event111811191120event RSDKLoad1121LoadSpriteSheet("Global/Display.gif")1122SpriteFrame(-16, -16, 32, 32, 1, 143)11231124SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")1125end event112611271128