Path: blob/master/Sonic 1/Scripts/LZ/LZSetup.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: LZ Setup Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.deformTimer12private alias object.value1 : object.paletteTimer113private alias object.value2 : object.beltPaletteTimer14private alias object.value3 : object.beltPaletteIndex15private alias object.value4 : object.waterfallLoopTimer16private alias object.value5 : object.playingWaterfallLoop17private alias object.value6 : object.clrDivisor_R18private alias object.value7 : object.clrDivisor_G19private alias object.value8 : object.clrDivisor_B20private alias object.value9 : object.waterClrDivisor_R21private alias object.value10 : object.waterClrDivisor_G22private alias object.value11 : object.waterClrDivisor_B2324// Player Aliases25private alias object.state : player.state26private alias object.xpos : player.xpos27private alias object.ypos : player.ypos28private alias object.xvel : player.xvel29private alias object.speed : player.speed30private alias object.gravity : player.gravity31private alias object.animation : player.animation32private alias object.direction : player.direction33private alias object.collisionBottom : player.collisionBottom3435// Tile Info ID Aliases36private alias 0 : TILEINFO_INDEX37private alias 1 : TILEINFO_DIRECTION38private alias 8 : TILEINFO_ANGLEB3940// Tile Flag Aliases41private alias 1 : TILE_WATERSLIDE4243// Tracks44private alias 0 : TRACK_STAGE45private alias 2 : TRACK_INVINCIBLE46private alias 4 : TRACK_BOSS47private alias 6 : TRACK_DROWNING4849// Reserved Object Slot Aliases50private alias 10 : SLOT_ZONESETUP51private alias 25 : SLOT_MUSICEVENT_CHANGE5253// Music Events54private alias 0 : MUSICEVENT_FADETOBOSS55private alias 1 : MUSICEVENT_FADETOSTAGE56private alias 2 : MUSICEVENT_TRANSITION5758private alias 0 : MUSICEVENT_FLAG_NOCHANGE59private alias 1 : MUSICEVENT_FLAG_SPEEDUP60private alias 2 : MUSICEVENT_FLAG_SLOWDOWN6162// Music Loops63private alias 84444 : MUSIC_LOOP_LZ64private alias 67538 : MUSIC_LOOP_LZ_F6566private alias 1 : MUSIC_LOOP_SBZ67private alias 1 : MUSIC_LOOP_SBZ_F6869private alias 39528 : MUSIC_LOOP_INV70private alias 30436 : MUSIC_LOOP_INV_F717273// ========================74// Function Declarations75// ========================7677reserve function LZSetup_SetupRippleDeform178reserve function LZSetup_SetupRippleDeform279reserve function LZSetup_getClrDivisor80reserve function LZSetup_InitSuperSonicPal81reserve function LZSetup_InitSuperTailsPal82reserve function LZSetup_InitSuperKnuxPal83reserve function LZSetup_InitSuperAmyPal84reserve function LZSetup_SpeedUpMusicLZ85reserve function LZSetup_SlowDownMusicLZ86reserve function LZSetup_SpeedUpMusicSBZ387reserve function LZSetup_SlowDownMusicSBZ3888990// ========================91// Static Values92// ========================9394public value Water_flashTimer = 0 // Uses "Water_" since all water objects use it from the setup so its easier to make new objs this way95public value LZSetup_beltDirection = 0969798// ========================99// Tables100// ========================101102private table LZSetup_beltPalDelayTable1032, 2, 1104end table105106107private table LZSetup_replay_credits_STK1080xA000000, 0x62C00001090x08, 491100x00, 91110x08, 1021120x00, 861130x02, 131140x00, 111150x02, 101160x00, 91170x02, 131180x00, 71190x08, 131200x38, 11210x28, 31220x08, 381230x00, 271240x01, 131250x00, 131260x02, 131270x00, 101280x02, 71290x08, 91300x38, 11310x28, 41320x08, 271330x00, 131340x02, 121350x00, 121360x02, 101370x00, 151380x02, 71390x00, 141400x02, 101410x00, 351420x30, 11430x20, 41440x00, 81450x02, 6146end table147148149private function LZSetup_SetupRippleDeform1150stage.deformationData1[arrayPos0] = 1151arrayPos0++152153stage.deformationData1[arrayPos0] = 1154arrayPos0++155156stage.deformationData1[arrayPos0] = 2157arrayPos0++158159stage.deformationData1[arrayPos0] = 2160arrayPos0++161162stage.deformationData1[arrayPos0] = 3163arrayPos0++164165stage.deformationData1[arrayPos0] = 3166arrayPos0++167168stage.deformationData1[arrayPos0] = 3169arrayPos0++170171stage.deformationData1[arrayPos0] = 3172arrayPos0++173174stage.deformationData1[arrayPos0] = 2175arrayPos0++176177stage.deformationData1[arrayPos0] = 2178arrayPos0++179180stage.deformationData1[arrayPos0] = 1181arrayPos0++182183stage.deformationData1[arrayPos0] = 1184arrayPos0++185end function186187188private function LZSetup_SetupRippleDeform2189stage.deformationData1[arrayPos0] = -1190arrayPos0++191192stage.deformationData1[arrayPos0] = -1193arrayPos0++194195stage.deformationData1[arrayPos0] = -2196arrayPos0++197198stage.deformationData1[arrayPos0] = -2199arrayPos0++200201stage.deformationData1[arrayPos0] = -3202arrayPos0++203204stage.deformationData1[arrayPos0] = -3205arrayPos0++206207stage.deformationData1[arrayPos0] = -3208arrayPos0++209210stage.deformationData1[arrayPos0] = -3211arrayPos0++212213stage.deformationData1[arrayPos0] = -2214arrayPos0++215216stage.deformationData1[arrayPos0] = -2217arrayPos0++218219stage.deformationData1[arrayPos0] = -1220arrayPos0++221222stage.deformationData1[arrayPos0] = -1223arrayPos0++224end function225226227// Wacky function to take a normal color and turn it into an underwater color228private function LZSetup_getClrDivisor229// Regular Color230object.clrDivisor_R = temp1231object.clrDivisor_R >>= 16232233object.clrDivisor_G = temp1234object.clrDivisor_G >>= 8235object.clrDivisor_G &= 0xFF236237object.clrDivisor_B = temp1238object.clrDivisor_B &= 0xFF239240// Underwater Color241object.waterClrDivisor_R = temp2242object.waterClrDivisor_R >>= 16243244object.waterClrDivisor_G = temp2245object.waterClrDivisor_G >>= 8246object.waterClrDivisor_G &= 0xFF247248object.waterClrDivisor_B = temp2249object.waterClrDivisor_B &= 0xFF250251// Minimum of 1 (don't wanna divide by 0!)252if object.waterClrDivisor_R == 0253object.waterClrDivisor_R = 1254end if255256if object.waterClrDivisor_G == 0257object.waterClrDivisor_G = 1258end if259260if object.waterClrDivisor_B == 0261object.waterClrDivisor_B = 1262end if263264object.clrDivisor_R <<= 8265object.clrDivisor_G <<= 8266object.clrDivisor_B <<= 8267268object.clrDivisor_R /= object.waterClrDivisor_R269object.clrDivisor_G /= object.waterClrDivisor_G270object.clrDivisor_B /= object.waterClrDivisor_B271272if object.clrDivisor_R == 0273object.clrDivisor_R = 0x100274end if275276if object.clrDivisor_G == 0277object.clrDivisor_G = 0x100278end if279280if object.clrDivisor_B == 0281object.clrDivisor_B = 0x100282end if283end function284285286private function LZSetup_InitSuperSonicPal287temp0 = 0288289// First Set of colors is just the regular underwater palette290GetPaletteEntry(1, 2, temp1)291SetTableValue(temp1, temp0, Player_SonicSuperAltPal)292temp0++293294GetPaletteEntry(1, 3, temp1)295SetTableValue(temp1, temp0, Player_SonicSuperAltPal)296temp0++297298GetPaletteEntry(1, 4, temp1)299SetTableValue(temp1, temp0, Player_SonicSuperAltPal)300temp0++301302GetPaletteEntry(1, 5, temp1)303SetTableValue(temp1, temp0, Player_SonicSuperAltPal)304temp0++305306while temp0 < 64307GetPaletteEntry(0, 2, temp1) // Regular color308GetPaletteEntry(1, 2, temp2) // Underwater color309310CallFunction(LZSetup_getClrDivisor)311312GetTableValue(temp1, temp0, Player_SonicSuperPal)313314// Get the green in the color315temp2 = temp1316temp2 >>= 8317temp2 &= 0xFF318319// Get the blue in the color320temp3 = temp1321temp3 &= 0xFF322323// Get the red in the color324temp1 >>= 16325326temp1 *= 0xE0327temp1 /= object.clrDivisor_R328329temp2 *= 0xE0330temp2 /= object.clrDivisor_G331332temp3 *= 0xE0333temp3 /= object.clrDivisor_B334335// Max of 0xE0336// -> Note that this game uses the "raw" colors from the original game rather than337// "corrected" colors seen in many emulators338// With this system, the brighest a color can be is E0E0E0, with all339// the reds, greens, and blues having a max of 224, or E0340temp1 &= 0xF0341temp2 &= 0xF0342temp3 &= 0xF0343if temp1 > 0xE0344temp1 = 0xE0345end if346if temp2 > 0xE0347temp2 = 0xE0348end if349if temp3 > 0xE0350temp3 = 0xE0351end if352353temp1 <<= 16354temp2 <<= 8355temp1 += temp2356temp1 += temp3357SetTableValue(temp1, temp0, Player_SonicSuperAltPal)358temp0++359360// Color 2361GetPaletteEntry(0, 3, temp1) // Regular color362GetPaletteEntry(1, 3, temp2) // Underwater color363364CallFunction(LZSetup_getClrDivisor)365366GetTableValue(temp1, temp0, Player_SonicSuperPal)367368temp2 = temp1369temp2 >>= 8370temp2 &= 0xFF371372temp3 = temp1373temp3 &= 0xFF374375temp1 >>= 16376377temp1 *= 0xE8378temp1 /= object.clrDivisor_R379380temp2 *= 0xE8381temp2 /= object.clrDivisor_G382383temp3 *= 0xE8384temp3 /= object.clrDivisor_B385386temp1 &= 0xF0387temp2 &= 0xF0388temp3 &= 0xF0389if temp1 > 0xE0390temp1 = 0xE0391end if392if temp2 > 0xE0393temp2 = 0xE0394end if395if temp3 > 0xE0396temp3 = 0xE0397end if398399temp1 <<= 16400temp2 <<= 8401temp1 += temp2402temp1 += temp3403SetTableValue(temp1, temp0, Player_SonicSuperAltPal)404temp0++405406// Color 3407GetPaletteEntry(0, 4, temp1) // Regular color408GetPaletteEntry(1, 4, temp2) // Underwater color409410CallFunction(LZSetup_getClrDivisor)411412GetTableValue(temp1, temp0, Player_SonicSuperPal)413414temp2 = temp1415temp2 >>= 8416temp2 &= 0xFF417418temp3 = temp1419temp3 &= 0xFF420421temp1 >>= 16422423temp1 *= 0xF4424temp1 /= object.clrDivisor_R425426temp2 *= 0xF4427temp2 /= object.clrDivisor_G428429temp3 *= 0xF4430temp3 /= object.clrDivisor_B431432temp1 &= 0xF0433temp2 &= 0xF0434temp3 &= 0xF0435if temp1 > 0xE0436temp1 = 0xE0437end if438if temp2 > 0xE0439temp2 = 0xE0440end if441if temp3 > 0xE0442temp3 = 0xE0443end if444445temp1 <<= 16446temp2 <<= 8447temp1 += temp2448temp1 += temp3449SetTableValue(temp1, temp0, Player_SonicSuperAltPal)450temp0++451452// Color 4453GetPaletteEntry(0, 5, temp1) // Regular color454GetPaletteEntry(1, 5, temp2) // Underwater color455456CallFunction(LZSetup_getClrDivisor)457458GetTableValue(temp1, temp0, Player_SonicSuperPal)459temp2 = temp1460temp2 >>= 8461temp2 &= 0xFF462463temp3 = temp1464temp3 &= 0xFF465466temp1 >>= 16467468temp1 *= 0x100469temp1 /= object.clrDivisor_R470471temp2 *= 0x100472temp2 /= object.clrDivisor_G473474temp3 *= 0x100475temp3 /= object.clrDivisor_B476477temp1 &= 0xF0478temp2 &= 0xF0479temp3 &= 0xF0480if temp1 > 0xE0481temp1 = 0xE0482end if483if temp2 > 0xE0484temp2 = 0xE0485end if486if temp3 > 0xE0487temp3 = 0xE0488end if489490temp1 <<= 16491temp2 <<= 8492temp1 += temp2493temp1 += temp3494SetTableValue(temp1, temp0, Player_SonicSuperAltPal)495temp0++496loop497end function498499500private function LZSetup_InitSuperTailsPal501temp0 = 0502503GetPaletteEntry(1, 13, temp1)504SetTableValue(temp1, temp0, Player_TailsSuperAltPal)505temp0++506507GetPaletteEntry(1, 17, temp1)508SetTableValue(temp1, temp0, Player_TailsSuperAltPal)509temp0++510511GetPaletteEntry(1, 18, temp1)512SetTableValue(temp1, temp0, Player_TailsSuperAltPal)513temp0++514515GetPaletteEntry(1, 16, temp1)516SetTableValue(temp1, temp0, Player_TailsSuperAltPal)517temp0++518519while temp0 < 24520// Color 1521GetPaletteEntry(0, 13, temp1)522GetPaletteEntry(1, 13, temp2)523524CallFunction(LZSetup_getClrDivisor)525526GetTableValue(temp1, temp0, Player_TailsSuperPal)527528temp2 = temp1529temp2 >>= 8530temp2 &= 0xFF531532temp3 = temp1533temp3 &= 0xFF534535temp1 >>= 16536537temp1 *= 0xF8538temp1 /= object.clrDivisor_R539540temp2 *= 0xF8541temp2 /= object.clrDivisor_G542543temp3 *= 0xF8544temp3 /= object.clrDivisor_B545546temp1 &= 0xF0547temp2 &= 0xF0548temp3 &= 0xF0549if temp1 > 0xE0550temp1 = 0xE0551end if552if temp2 > 0xE0553temp2 = 0xE0554end if555if temp3 > 0xE0556temp3 = 0xE0557end if558559temp1 <<= 16560temp2 <<= 8561temp1 += temp2562temp1 += temp3563SetTableValue(temp1, temp0, Player_TailsSuperAltPal)564temp0++565566// Color 2567GetPaletteEntry(0, 17, temp1)568GetPaletteEntry(1, 17, temp2)569570CallFunction(LZSetup_getClrDivisor)571572GetTableValue(temp1, temp0, Player_TailsSuperPal)573574temp2 = temp1575temp2 >>= 8576temp2 &= 0xFF577578temp3 = temp1579temp3 &= 0xFF580581temp1 >>= 16582583temp1 *= 0x100584temp1 /= object.clrDivisor_R585586temp2 *= 0x100587temp2 /= object.clrDivisor_G588589temp3 *= 0x100590temp3 /= object.clrDivisor_B591592temp1 &= 0xF0593temp2 &= 0xF0594temp3 &= 0xF0595if temp1 > 0xE0596temp1 = 0xE0597end if598if temp2 > 0xE0599temp2 = 0xE0600end if601if temp3 > 0xE0602temp3 = 0xE0603end if604605temp1 <<= 16606temp2 <<= 8607temp1 += temp2608temp1 += temp3609SetTableValue(temp1, temp0, Player_TailsSuperAltPal)610temp0++611612// Color 3613GetPaletteEntry(0, 18, temp1)614GetPaletteEntry(1, 18, temp2)615616CallFunction(LZSetup_getClrDivisor)617618GetTableValue(temp1, temp0, Player_TailsSuperPal)619620temp2 = temp1621temp2 >>= 8622temp2 &= 0xFF623624temp3 = temp1625temp3 &= 0xFF626627temp1 >>= 16628629temp1 *= 0x100630temp1 /= object.clrDivisor_R631632temp2 *= 0x100633temp2 /= object.clrDivisor_G634635temp3 *= 0x100636temp3 /= object.clrDivisor_B637638temp1 &= 0xF0639temp2 &= 0xF0640temp3 &= 0xF0641if temp1 > 0xE0642temp1 = 0xE0643end if644if temp2 > 0xE0645temp2 = 0xE0646end if647if temp3 > 0xE0648temp3 = 0xE0649end if650651temp1 <<= 16652temp2 <<= 8653temp1 += temp2654temp1 += temp3655SetTableValue(temp1, temp0, Player_TailsSuperAltPal)656temp0++657658// Color 4659GetPaletteEntry(0, 16, temp1)660GetPaletteEntry(1, 16, temp2)661662CallFunction(LZSetup_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 &= 0xF0687if temp1 > 0xE0688temp1 = 0xE0689end if690691if temp2 > 0xE0692temp2 = 0xE0693end if694695if temp3 > 0xE0696temp3 = 0xE0697end if698699temp1 <<= 16700temp2 <<= 8701temp1 += temp2702temp1 += temp3703SetTableValue(temp1, temp0, Player_TailsSuperAltPal)704temp0++705loop706end function707708709private function LZSetup_InitSuperKnuxPal710temp0 = 0711712GetPaletteEntry(1, 26, temp1)713SetTableValue(temp1, temp0, Player_KnuxSuperAltPal)714temp0++715716GetPaletteEntry(1, 27, temp1)717SetTableValue(temp1, temp0, Player_KnuxSuperAltPal)718temp0++719720GetPaletteEntry(1, 28, temp1)721SetTableValue(temp1, temp0, Player_KnuxSuperAltPal)722temp0++723end function724725private function LZSetup_InitSuperAmyPal726#platform: USE_ORIGINS727temp0 = 0728GetPaletteEntry(1, 66, temp1)729SetTableValue(temp1, temp0, Player_AmySuperAltPal)730temp0++731GetPaletteEntry(1, 67, temp1)732SetTableValue(temp1, temp0, Player_AmySuperAltPal)733temp0++734GetPaletteEntry(1, 68, temp1)735SetTableValue(temp1, temp0, Player_AmySuperAltPal)736temp0++737GetPaletteEntry(1, 64, temp1)738SetTableValue(temp1, temp0, Player_AmySuperAltPal)739temp0++740GetPaletteEntry(1, 65, temp1)741SetTableValue(temp1, temp0, Player_AmySuperAltPal)742temp0++743while temp0 < 30744temp4 = temp0745temp4 -= 5746GetTableValue(temp1, temp4, Player_AmySuperAltPal)747temp2 = temp1748temp2 >>= 8749temp2 &= 255750temp3 = temp1751temp3 &= 255752temp1 >>= 16753temp1 += 32754if temp1 > 255755temp1 = 255756end if757temp2 += 32758if temp2 > 255759temp2 = 255760end if761temp3 += 32762if temp3 > 255763temp3 = 255764end if765temp1 <<= 16766temp2 <<= 8767temp1 += temp2768temp1 += temp3769SetTableValue(temp1, temp0, Player_AmySuperAltPal)770temp0++771loop772temp6 = 25773while temp0 < 50774temp5 = 0775while temp5 < 5776temp4 = temp6777temp4 += temp5778GetTableValue(temp1, temp4, Player_AmySuperAltPal)779SetTableValue(temp1, temp0, Player_AmySuperAltPal)780temp0++781temp5++782loop783temp6 -= 5784loop785#endplatform786end function787788789private function LZSetup_SpeedUpMusicLZ790CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])791temp0 = checkResult792CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)793temp0 &= checkResult794CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)795temp0 &= checkResult796if temp0 == false797switch music.currentTrack798case TRACK_STAGE799SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)800SwapMusicTrack("Labyrinth_F.ogg", TRACK_STAGE, MUSIC_LOOP_LZ_F, 8000)801break802803case TRACK_INVINCIBLE804SetMusicTrack("Labyrinth_F.ogg", TRACK_STAGE, MUSIC_LOOP_LZ_F)805SwapMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F, 8000)806break807808case TRACK_BOSS809case TRACK_DROWNING810SetMusicTrack("Labyrinth_F.ogg", TRACK_STAGE, MUSIC_LOOP_LZ_F)811SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)812break813814end switch815else816stage.musicFlag = MUSICEVENT_FLAG_SPEEDUP817end if818end function819820821private function LZSetup_SlowDownMusicLZ822CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])823temp0 = checkResult824CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)825temp0 &= checkResult826CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)827temp0 &= checkResult828if temp0 == false829switch music.currentTrack830case TRACK_STAGE831SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)832SwapMusicTrack("Labyrinth.ogg", TRACK_STAGE, MUSIC_LOOP_LZ, 12500)833break834835case TRACK_INVINCIBLE836SetMusicTrack("Labyrinth.ogg", TRACK_STAGE, MUSIC_LOOP_LZ)837SwapMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV, 12500)838break839840case TRACK_BOSS841case TRACK_DROWNING842SetMusicTrack("Labyrinth.ogg", TRACK_STAGE, MUSIC_LOOP_LZ)843SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)844break845846end switch847else848stage.musicFlag = MUSICEVENT_FLAG_SLOWDOWN849end if850end function851852853private function LZSetup_SpeedUpMusicSBZ3854CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])855temp0 = checkResult856CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)857temp0 &= checkResult858CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)859temp0 &= checkResult860if temp0 == false861switch music.currentTrack862case TRACK_STAGE863SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)864SwapMusicTrack("ScrapBrain_F.ogg", TRACK_STAGE, MUSIC_LOOP_SBZ_F, 8000)865break866867case TRACK_INVINCIBLE868SetMusicTrack("ScrapBrain_F.ogg", TRACK_STAGE, MUSIC_LOOP_SBZ_F)869SwapMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F, 8000)870break871872case TRACK_BOSS873case TRACK_DROWNING874SetMusicTrack("ScrapBrain_F.ogg", TRACK_STAGE, MUSIC_LOOP_SBZ_F)875SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)876break877878end switch879else880stage.musicFlag = MUSICEVENT_FLAG_SPEEDUP881end if882end function883884885private function LZSetup_SlowDownMusicSBZ3886CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])887temp0 = checkResult888CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)889temp0 &= checkResult890CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)891temp0 &= checkResult892if temp0 == false893switch music.currentTrack894case TRACK_STAGE895SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)896SwapMusicTrack("ScrapBrain.ogg", TRACK_STAGE, MUSIC_LOOP_SBZ, 12500)897break898899case TRACK_INVINCIBLE900SetMusicTrack("ScrapBrain.ogg", TRACK_STAGE, MUSIC_LOOP_SBZ)901SwapMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV, 12500)902break903904case TRACK_BOSS905case TRACK_DROWNING906SetMusicTrack("ScrapBrain.ogg", TRACK_STAGE, MUSIC_LOOP_SBZ)907SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)908break909910end switch911else912stage.musicFlag = MUSICEVENT_FLAG_SLOWDOWN913end if914end function915916917// ========================918// Events919// ========================920921event ObjectUpdate922object.deformTimer++923if object.deformTimer > 1924tileLayer[0].deformationOffsetW++925tileLayer[1].deformationOffsetW++926object.deformTimer = 0927end if928929object.paletteTimer1++930if object.paletteTimer1 == 3931object.paletteTimer1 = 0932RotatePalette(0, 171, 174, false)933RotatePalette(1, 171, 174, false)934end if935936if object.beltPaletteTimer > 0937object.beltPaletteTimer--938else939object.beltPaletteIndex++940object.beltPaletteIndex %= 3941GetTableValue(object.beltPaletteTimer, object.beltPaletteIndex, LZSetup_beltPalDelayTable)942943RotatePalette(0, 187, 189, LZSetup_beltDirection)944RotatePalette(1, 187, 189, LZSetup_beltDirection)945end if946947// Handle Player Tile Interactions948foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)949temp1 = player[currentPlayer].xpos950temp1 >>= 16951952temp2 = player[currentPlayer].ypos953temp2 >>= 16954temp2 += player[currentPlayer].collisionBottom955temp2--956957Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_INDEX)958959// Check if it's a waterfall tile960CheckEqual(temp0, 71)961temp3 = checkResult962CheckEqual(temp0, 72)963temp3 |= checkResult964965if temp3 == true966// Force unstick Knuckles, if needed967968CheckEqual(player[currentPlayer].state, Player_State_GlideLeft)969temp3 = checkResult970CheckEqual(player[currentPlayer].state, Player_State_GlideRight)971temp3 |= checkResult972CheckEqual(player[currentPlayer].state, Player_State_Climb)973temp3 |= checkResult974CheckEqual(player[currentPlayer].state, Player_State_LedgePullUp)975temp3 |= checkResult976if temp3 == true977if player[currentPlayer].state == Player_State_GlideLeft978FlipSign(player[currentPlayer].xvel)979FlipSign(player[currentPlayer].speed)980end if981982player[currentPlayer].state = Player_State_GlideDrop983player[currentPlayer].animation = ANI_GLIDING_DROP984end if985end if986987if player[currentPlayer].gravity == GRAVITY_GROUND988Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEB)989if temp0 == TILE_WATERSLIDE990player[currentPlayer].state = Player_State_WaterSlide991992Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_DIRECTION)993switch temp0994case FLIP_NONE995case FLIP_Y996player[currentPlayer].direction = FACING_LEFT997break998999case FLIP_X1000case FLIP_XY1001player[currentPlayer].direction = FACING_RIGHT1002break10031004end switch1005end if1006end if1007next10081009if player[0].state == Player_State_WaterSlide1010if object.waterfallLoopTimer == 01011if object.playingWaterfallLoop == false1012PlaySfx(SfxName[Waterfall], false)1013StopSfx(SfxName[Waterfall Loop])1014object.playingWaterfallLoop = true1015else1016StopSfx(SfxName[Waterfall])1017PlaySfx(SfxName[Waterfall Loop], false)1018end if1019end if10201021object.waterfallLoopTimer++1022object.waterfallLoopTimer &= 0x3F1023else1024if object.waterfallLoopTimer != 01025object.waterfallLoopTimer++1026object.waterfallLoopTimer &= 0x3F1027else1028object.waterfallLoopTimer = 01029object.playingWaterfallLoop = false1030end if1031end if10321033if Water_flashTimer > 01034Water_flashTimer--1035end if1036end event103710381039event ObjectDraw1040// Change the palette to the underwater one after the water level's Y Pos1041temp0 = stage.waterLevel1042temp0 -= screen.yoffset10431044// Enforce a minimum of 01045if temp0 < 01046temp0 = 01047end if10481049// Enforce a maximum of the screen's vertical size1050if temp0 > screen.ysize1051temp0 = screen.ysize1052end if10531054// Set the above water palette from the upper part of the screen1055SetActivePalette(0, 0, temp0)10561057// Set the underwater palette for the bottom part of the screen1058if Water_flashTimer > 01059// Use the lightning palette if needed1060SetActivePalette(2, temp0, screen.ysize)1061else1062// Otherwise, use the normal water palette1063SetActivePalette(1, temp0, screen.ysize)1064end if1065end event106610671068event ObjectStartup1069// If in acts 1-3, set the normal Labyrinth music1070if stage.actNum < 41071// Set the speed up/slow down functions, too1072SetMusicTrack("Labyrinth.ogg", TRACK_STAGE, MUSIC_LOOP_LZ)1073SpeedUpMusic = LZSetup_SpeedUpMusicLZ1074SlowDownMusic = LZSetup_SlowDownMusicLZ1075else1076// If in "act 4" - AKA SBZ 3 - then use Scrap Brain's music instead1077SetMusicTrack("ScrapBrain.ogg", TRACK_STAGE, MUSIC_LOOP_SBZ)1078SpeedUpMusic = LZSetup_SpeedUpMusicSBZ31079SlowDownMusic = LZSetup_SlowDownMusicSBZ31080end if10811082// Pecky and Rocky are the inhabitants of this labyrinth1083animalType1 = TypeName[Pecky]1084animalType2 = TypeName[Rocky]10851086// Place an LZ Setup Object into the scene1087object[SLOT_ZONESETUP].type = TypeName[LZ Setup]1088object[SLOT_ZONESETUP].priority = PRIORITY_ACTIVE1089object[SLOT_ZONESETUP].drawOrder = 010901091// Start the initial palette cycle stuff1092GetTableValue(object[SLOT_ZONESETUP].beltPaletteTimer, 0, LZSetup_beltPalDelayTable)10931094// Set stage deformation data1095// (FG layer properties)10961097arrayPos0 = 01098CallFunction(LZSetup_SetupRippleDeform1)10991100arrayPos0 = 1281101CallFunction(LZSetup_SetupRippleDeform1)11021103arrayPos0 = 1601104CallFunction(LZSetup_SetupRippleDeform2)11051106arrayPos0 = 0x1001107while arrayPos0 < 5761108arrayPos1 = arrayPos01109arrayPos1 -= 0x1001110stage.deformationData1[arrayPos0] = stage.deformationData1[arrayPos1]1111arrayPos0++1112loop11131114SetLayerDeformation(3, 128, 4, 0, 0, 0)11151116if stage.actNum < 41117// If in acts 1-3, then only load the LZ underwater palette1118LoadPalette("LZ_WaterPal.act", 1, 0, 0, 256)1119else1120// SBZ3: Load not only the water palette, but also the main stage palette1121LoadPalette("SBZ3_Pal.act", 0, 128, 128, 192)1122LoadPalette("SBZ3_WaterPal.act", 1, 0, 0, 256)1123end if11241125// Set up Super colors1126CallFunction(LZSetup_InitSuperSonicPal)1127CallFunction(LZSetup_InitSuperTailsPal)1128CallFunction(LZSetup_InitSuperKnuxPal)1129#platform: USE_ORIGINS1130CallFunction(LZSetup_InitSuperAmyPal)1131#endplatform11321133// Load the eletric flash palette in case the player gets wet with a lightning shield1134LoadPalette("ElectricFlash.act", 2, 0, 0, 256)11351136// Reset the flash timer1137Water_flashTimer = 011381139if options.attractMode == true1140if credits.screen > 01141Player_attractTable = LZSetup_replay_credits_STK1142Player_attractTableSize = 761143Player_attractDuration = 5401144end if11451146CallFunction(Player_SetupAttractDemo)1147end if1148end event114911501151// ========================1152// Editor Events1153// ========================11541155event RSDKDraw1156DrawSprite(0)1157end event115811591160event RSDKLoad1161LoadSpriteSheet("Global/Display.gif")1162SpriteFrame(-16, -16, 32, 32, 1, 143)11631164SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")1165end event116611671168