Path: blob/master/Sonic 2/Scripts/OOZ/OOZSetup.txt
1479 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: OOZ 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.lightAniTileDelay13private alias object.value2 : object.lightAniTileFrame14private alias object.value3 : object.diamondAniTileDelay15private alias object.value4 : object.diamondAniTileFrame16private alias object.value5 : object.oilAniTileDelay17private alias object.value6 : object.oilAniTileFrame18private alias object.value7 : object.updatedBG19private alias object.value8 : object.oilSlideTimer2021// Tile Flag Aliases22private alias 0 : TILE_NORMAL23private alias 1 : TILE_OILPOOL24private alias 3 : TILE_OILSTRIP25private alias 5 : TILE_OILSLIDE2627// Tile Info ID Aliases28private alias 1 : TILEINFO_DIRECTION29private alias 8 : TILEINFO_ANGLEB3031// Player Aliases32private alias object.state : player.state33private alias object.xpos : player.xpos34private alias object.ypos : player.ypos35private alias object.iypos : player.iypos36private alias object.xvel : player.xvel37private alias object.yvel : player.yvel38private alias object.speed : player.speed39private alias object.drawOrder : player.drawOrder40private alias object.direction : player.direction41private alias object.gravity : player.gravity42private alias object.pushing : player.pushing43private alias object.left : player.left44private alias object.right : player.right45private alias object.jumpPress : player.jumpPress46private alias object.controlLock : player.controlLock47private alias object.angle : player.angle48private alias object.frame : player.frame49private alias object.animation : player.animation50private alias object.animationSpeed : player.animationSpeed51private alias object.collisionMode : player.collisionMode52private alias object.collisionBottom : player.collisionBottom53private alias object.tileCollisions : player.tileCollisions5455private alias object.value1 : player.timer56private alias object.value14 : player.skidding57private alias object.value18 : player.sortedDrawOrder58private alias object.value20 : player.topSpeed59private alias object.value35 : player.jumpAbilityState6061// Tracks62private alias 0 : TRACK_STAGE63private alias 1 : TRACK_ACTFINISH64private alias 2 : TRACK_INVINCIBLE65private alias 3 : TRACK_CONTINUE66private alias 4 : TRACK_BOSS67private alias 5 : TRACK_GAMEOVER68private alias 6 : TRACK_DROWNING69private alias 7 : TRACK_SUPER7071// Reserved object slots72private alias 10 : SLOT_ZONESETUP73private alias 25 : SLOT_MUSICEVENT_CHANGE74private alias 26 : SLOT_MUSICEVENT_BOSS7576// Music Events77private alias 2 : MUSICEVENT_TRANSITION7879private alias 0 : MUSICEVENT_FLAG_NOCHANGE80private alias 1 : MUSICEVENT_FLAG_SPEEDUP81private alias 2 : MUSICEVENT_FLAG_SLOWDOWN8283// Music Loops84private alias 293572 : MUSIC_LOOP_OOZ85private alias 235236 : MUSIC_LOOP_OOZ_F8687private alias 38679 : MUSIC_LOOP_INV88private alias 30897 : MUSIC_LOOP_INV_F899091// ========================92// Function Declarations93// ========================9495// These first four functions are run by the Player Object, the ones with "PlayerState" in them are assigned to the player's state96reserve function OOZSetup_OilWalkAnimSpeed97reserve function OOZSetup_PlayerState_OilPool98reserve function OOZSetup_HandleOilMovement99reserve function OOZSetup_PlayerState_OilSlide100101reserve function OOZSetup_SpeedUpMusic102reserve function OOZSetup_SlowDownMusic103104105// ========================106// Tables107// ========================108109private table OOZSetup_deformTable1101, 2, 1, 3, 1, 2, 2, 1, 2, 3, 1, 2, 1, 2, 0, 01112, 0, 3, 2, 2, 3, 2, 2, 1, 3, 0, 0, 1, 0, 1, 31121, 2, 1, 3, 1, 2, 2, 1, 2, 3, 1, 2, 1, 2, 0, 01132, 0, 3, 2, 2, 3, 2, 2, 1, 3, 0, 0, 1, 0, 1, 3114end table115116private table OOZSetup_lightAniFrameTable117816, 12118817, 6119818, 10120819, 4121end table122123private table OOZSetup_diamondAniFrameTable1124820, 7125821, 7126822, 7127823, 7128end table129130private table OOZSetup_diamondAniFrameTable2131824, 7132826, 7133828, 7134830, 7135end table136137// This is MCZ's palette cycle, why is this here? I do not know138private table OOZSetup_paletteCycle1390xC00000, 0xE06000, 0xE0C000, 0xE0E080140end table141142143// ========================144// Function Definitions145// ========================146147// TODO: update these to match new player func names148149private function OOZSetup_OilWalkAnimSpeed150player.animationSpeed = player.speed151if player.animationSpeed < 0152FlipSign(player.animationSpeed)153end if154player.animationSpeed *= 120155player.animationSpeed /= 0x60000156player.animationSpeed += 20157end function158159160private function OOZSetup_PlayerState_OilPool161if player.animation != ANI_SKIDDING162temp7 = true163else164temp7 = false165end if166167CallFunction(Player_HandleGroundMovement)168if player.gravity == GRAVITY_AIR169#platform: USE_STANDALONE170player.state = Player_State_Air171#endplatform172#platform: USE_ORIGINS173player.state = Player_State_Air_NoDropDash174#endplatform175CallFunction(Player_HandleAirMovement)176else177CallFunction(Player_HandleOnGround)178if player.speed == 0179if player.collisionMode == CMODE_FLOOR180if player.timer < 240181player.animation = ANI_STOPPED182player.timer++183else184player.animation = ANI_WAITING185if stage.playerListPos == PLAYER_KNUCKLES_A186player.timer++187if player.timer == 834188player.timer = 0189player.animation = ANI_STOPPED190end if191end if192end if193end if194else195player.timer = 0196if player.speed > 0197if player.speed < 0x5F5C2198player.animation = ANI_WALKING199CallFunction(Player_HandleWalkAnimSpeed)200else201if player.speed > 0x9FFFF202player.animation = ANI_PEELOUT203else204player.animation = ANI_RUNNING205end if206CallFunction(Player_HandleRunAnimSpeed)207end if208else209if player.speed > -0x5F5C2210player.animation = ANI_WALKING211CallFunction(Player_HandleWalkAnimSpeed)212else213if player.speed < -0x9FFFF214player.animation = ANI_PEELOUT215else216player.animation = ANI_RUNNING217end if218CallFunction(Player_HandleRunAnimSpeed)219end if220end if221end if222223if player.skidding > 0224if temp7 == true225PlaySfx(SfxName[Skidding], false)226end if227player.animation = ANI_SKIDDING228player.animationSpeed = 0229230player.skidding--231if ringTimer == 0232CreateTempObject(TypeName[Dust Puff], 0, player.xpos, player.ypos)233player[tempObjectPos].iypos += player.collisionBottom234player[tempObjectPos].drawOrder = player.sortedDrawOrder235end if236237if player.speed > 0238player.direction = FACING_RIGHT239else240player.direction = FACING_LEFT241end if242end if243244if player.collisionMode == CMODE_FLOOR245if player.pushing == 2246player.animation = ANI_PUSHING247player.animationSpeed = 0248end if249end if250251if player.jumpPress == true252CallFunction(Player_Action_Jump)253end if254end if255end function256257258private function OOZSetup_HandleOilMovement259if player.controlLock > 0260player.controlLock--261Sin256(temp0, player.angle)262temp0 *= 0x2000263temp0 >>= 8264player.speed += temp0265else266if player.left == true267temp0 = player.topSpeed268FlipSign(temp0)269if player.speed > temp0270player.speed -= 0x400271end if272273if player.speed <= 0274player.direction = FACING_LEFT275end if276end if277278if player.right == true279if player.speed < player.topSpeed280player.speed += 0x400281end if282283if player.speed >= 0284player.direction = FACING_RIGHT285end if286end if287288temp0 = player.left289temp0 |= player.right290if temp0 == false291if player.speed > 0292player.speed -= 4293if player.speed < 0294player.speed = 0295end if296else297player.speed += 4298if player.speed > 0299player.speed = 0300end if301end if302303if player.speed > 0x2000304Sin256(temp0, player.angle)305temp0 *= 0x2000306temp0 >>= 8307player.speed += temp0308end if309310if player.speed < -0x2000311Sin256(temp0, player.angle)312temp0 *= 0x2000313temp0 >>= 8314player.speed += temp0315end if316317if player.angle > 192318if player.angle < 228319if player.speed > -0x10000320if player.speed < 0x10000321player.controlLock = 30322end if323end if324end if325end if326327if player.angle > 28328if player.angle < 64329if player.speed > -0x10000330if player.speed < 0x10000331player.controlLock = 30332end if333end if334end if335end if336else337Sin256(temp0, player.angle)338temp0 *= 0x2000339temp0 >>= 8340player.speed += temp0341if player.right == true342if player.left == false343if player.angle > 192344if player.angle < 228345if player.speed < 0x28000346if player.speed > -0x20000347player.controlLock = 30348end if349end if350end if351end if352end if353else354if player.left == true355if player.angle > 28356if player.angle < 64357if player.speed > -0x28000358if player.speed < 0x20000359player.controlLock = 30360end if361end if362end if363end if364end if365end if366end if367end if368end function369370371private function OOZSetup_PlayerState_OilSlide372CallFunction(OOZSetup_HandleOilMovement)373374if player.gravity == GRAVITY_AIR375#platform: USE_STANDALONE376player.state = Player_State_Air377#endplatform378#platform: USE_ORIGINS379player.state = Player_State_Air_NoDropDash380#endplatform381CallFunction(Player_HandleAirMovement)382else383CallFunction(Player_HandleOnGround)384if player.speed == 0385if player.collisionMode == CMODE_FLOOR386if player.timer < 240387player.animation = ANI_STOPPED388player.timer++389else390player.animation = ANI_WAITING391if stage.playerListPos == PLAYER_KNUCKLES_A392player.timer++393if player.timer == 834394player.timer = 0395player.animation = ANI_STOPPED396end if397end if398end if399end if400else401player.timer = 0402if player.animation != ANI_WATERSLIDE403if player.speed > 0404if player.speed < 0x30000405player.animation = ANI_WALKING406CallFunction(OOZSetup_OilWalkAnimSpeed)407else408player.animation = ANI_RUNNING409player.animationSpeed = 240410end if411else412if player.speed > -0x30000413player.animation = ANI_WALKING414CallFunction(OOZSetup_OilWalkAnimSpeed)415else416player.animation = ANI_RUNNING417player.animationSpeed = 240418end if419end if420end if421end if422423player.skidding = 0424if player.collisionMode == CMODE_FLOOR425if player.pushing == 2426player.animation = ANI_PUSHING427player.animationSpeed = 0428end if429end if430431if player.jumpPress == true432CallFunction(Player_Action_Jump)433end if434#platform: USE_ORIGINS435switch player.collisionMode436case CMODE_LWALL437if player.angle <= 192438if player.speed > -0x20000439if player.speed < 0x20000440player.gravity = GRAVITY_AIR441player.angle = 0442player.collisionMode = CMODE_FLOOR443player.speed = player.xvel444end if445end if446end if447break448case CMODE_ROOF449if player.speed > -0x20000450if player.speed < 0x20000451player.gravity = GRAVITY_AIR452player.angle = 0453player.collisionMode = CMODE_FLOOR454player.speed = player.xvel455end if456end if457break458case CMODE_RWALL459if player.angle >= 64460if player.speed > -0x20000461if player.speed < 0x20000462player.gravity = GRAVITY_AIR463player.angle = 0464player.collisionMode = CMODE_FLOOR465player.speed = player.xvel466end if467end if468end if469break470end switch471#endplatform472end if473end function474475476private function OOZSetup_SpeedUpMusic477CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])478temp0 = checkResult479CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)480temp0 &= checkResult481CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)482temp0 &= checkResult483if temp0 == false484switch music.currentTrack485case TRACK_STAGE486SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)487SwapMusicTrack("OilOcean_F.ogg", TRACK_STAGE, MUSIC_LOOP_OOZ_F, 8000)488break489490case TRACK_INVINCIBLE491SetMusicTrack("OilOcean_F.ogg", TRACK_STAGE, MUSIC_LOOP_OOZ_F)492SwapMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F, 8000)493break494495case TRACK_BOSS496case TRACK_DROWNING497case TRACK_SUPER498SetMusicTrack("OilOcean_F.ogg", TRACK_STAGE, MUSIC_LOOP_OOZ_F)499SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)500break501502end switch503else504stage.musicFlag = MUSICEVENT_FLAG_SPEEDUP505end if506end function507508509private function OOZSetup_SlowDownMusic510CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])511temp0 = checkResult512CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)513temp0 &= checkResult514CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)515temp0 &= checkResult516if temp0 == false517switch music.currentTrack518case TRACK_STAGE519SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)520SwapMusicTrack("OilOcean.ogg", TRACK_STAGE, MUSIC_LOOP_OOZ, 12500)521break522523case TRACK_INVINCIBLE524SetMusicTrack("OilOcean.ogg", TRACK_STAGE, MUSIC_LOOP_OOZ)525SwapMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV, 12500)526break527528case TRACK_BOSS529case TRACK_DROWNING530case TRACK_SUPER531SetMusicTrack("OilOcean.ogg", TRACK_STAGE, MUSIC_LOOP_OOZ)532SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)533break534535end switch536else537stage.musicFlag = MUSICEVENT_FLAG_SLOWDOWN538end if539end function540541542// ========================543// Events544// ========================545546event ObjectUpdate547// Slightly update the BG for the boss548// (Realigns the city, otherwise the BG would look like the boss takes place in the sky)549if options.vsMode == false550if stage.actNum == 2551if object.updatedBG == false552if camera[0].ypos < 256553if camera[0].xpos > 8512554temp0 = screen.yoffset555temp0 *= 44556temp0 <<= 8557temp1 = screen.yoffset558temp1 >>= 2559temp1 += 128560tileLayer[1].scrollPos = screen.yoffset561tileLayer[1].scrollPos *= temp1562tileLayer[1].scrollPos <<= 8563tileLayer[1].scrollPos -= temp0564FlipSign(tileLayer[1].scrollPos)565tileLayer[1].parallaxFactor = temp1566567object.updatedBG = true568end if569end if570end if571end if572end if573574object.deformTimer++575if object.deformTimer > 7576object.deformTimer = 0577tileLayer[1].deformationOffset++578RotatePalette(0, 170, 173, false)579end if580581if object.lightAniTileDelay < 2582GetTableValue(temp0, object.lightAniTileFrame, OOZSetup_lightAniFrameTable)583584Copy16x16Tile(756, temp0)585object.lightAniTileFrame++586587GetTableValue(object.lightAniTileDelay, object.lightAniTileFrame, OOZSetup_lightAniFrameTable)588object.lightAniTileFrame++589object.lightAniTileFrame &= 7590else591object.lightAniTileDelay--592end if593594if object.diamondAniTileDelay < 2595GetTableValue(temp0, object.diamondAniTileFrame, OOZSetup_diamondAniFrameTable1)596Copy16x16Tile(757, temp0)597598GetTableValue(temp0, object.diamondAniTileFrame, OOZSetup_diamondAniFrameTable2)599Copy16x16Tile(758, temp0)600temp0++601602Copy16x16Tile(759, temp0)603604object.diamondAniTileFrame++605GetTableValue(object.diamondAniTileDelay, object.diamondAniTileFrame, OOZSetup_diamondAniFrameTable1)606object.diamondAniTileFrame++607object.diamondAniTileFrame &= 7608else609object.diamondAniTileDelay--610end if611612// Oil!!!613if object.oilAniTileDelay < 2614temp0 = object.oilAniTileFrame615temp0 += 768616Copy16x16Tile(760, temp0)617temp0++618619Copy16x16Tile(761, temp0)620temp0++621622Copy16x16Tile(762, temp0)623temp0++624625Copy16x16Tile(763, temp0)626temp0 += 21627628Copy16x16Tile(764, temp0)629temp0++630631Copy16x16Tile(765, temp0)632temp0++633634Copy16x16Tile(766, temp0)635temp0++636637Copy16x16Tile(767, temp0)638639object.oilAniTileDelay = 18640object.oilAniTileFrame += 4641object.oilAniTileFrame %= 24642else643object.oilAniTileDelay--644end if645646foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)647if player[currentPlayer].state == Player_State_Static648if player[currentPlayer].ypos < -0x800000649// If the Player's up in the sky while static they were likely sent there by a Ball Cannon, so return them to normal now650#platform: USE_STANDALONE651player[currentPlayer].state = Player_State_Air652#endplatform653#platform: USE_ORIGINS654player[currentPlayer].state = Player_State_Air_NoDropDash655#endplatform656player[currentPlayer].gravity = GRAVITY_AIR657player[currentPlayer].jumpAbilityState = 0658player[currentPlayer].tileCollisions = true659end if660end if661662if player[currentPlayer].animation == ANI_TWIRL663// (This is just to make sure the last frame in the Twirl animation isn't seen, since it's the same as the first frame and the animation loops)664player[currentPlayer].frame %= 24665end if666667temp1 = player[currentPlayer].xpos668temp1 >>= 16669temp2 = player[currentPlayer].ypos670temp2 >>= 16671temp2 += 6672673Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEB)674switch temp0675default676case TILE_NORMAL677break678679case TILE_OILPOOL680if player[currentPlayer].yvel > -1681player[currentPlayer].state = OOZSetup_PlayerState_OilPool682if player[currentPlayer].animation == ANI_JUMPING683player[currentPlayer].animation = ANI_WALKING684end if685player[currentPlayer].gravity = GRAVITY_GROUND686player[currentPlayer].yvel = 0687player[currentPlayer].ypos += 0x10000688end if689break690691case TILE_OILSTRIP692if player[currentPlayer].gravity == GRAVITY_GROUND693player[currentPlayer].state = OOZSetup_PlayerState_OilSlide694end if695break696697case TILE_OILSLIDE698if player[currentPlayer].gravity == GRAVITY_GROUND699player[currentPlayer].state = OOZSetup_PlayerState_OilSlide700player[currentPlayer].animation = ANI_WATERSLIDE701Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_DIRECTION)702switch temp0703case FLIP_NONE704case FLIP_Y705if player[currentPlayer].speed > -0x80000706player[currentPlayer].speed -= 0x4000707end if708break709710case FLIP_X711case FLIP_XY712if player[currentPlayer].speed < 0x80000713player[currentPlayer].speed += 0x4000714end if715break716717end switch718719if player[currentPlayer].speed < 0720player[currentPlayer].direction = FACING_LEFT721else722player[currentPlayer].direction = FACING_RIGHT723end if724725if currentPlayer == 0726if object.oilSlideTimer == 0727PlaySfx(SfxName[Oil Slide], false)728end if729object.oilSlideTimer++730object.oilSlideTimer &= 15731end if732end if733break734735end switch736next737end event738739740event ObjectStartup741SetMusicTrack("OilOcean.ogg", TRACK_STAGE, MUSIC_LOOP_OOZ)742743SpeedUpMusic = OOZSetup_SpeedUpMusic744SlowDownMusic = OOZSetup_SlowDownMusic745746animalType1 = TypeName[Rocky]747animalType2 = TypeName[Pecky]748749// This is resetting the boss flash color, [OOZ Eggman] does this too though so it's somewhat redundant750SetPaletteEntry(0, 192, 0x000000)751752object[SLOT_ZONESETUP].type = TypeName[OOZ Setup]753object[SLOT_ZONESETUP].priority = PRIORITY_ACTIVE754755stage.newYBoundary2 = 1896756stage.deathBoundary = stage.newYBoundary2757stage.deathBoundary -= 8758stage.deathBoundary <<= 16759760arrayPos0 = 0761while arrayPos0 < 576762temp0 = arrayPos0763temp0 &= 63764GetTableValue(stage.deformationData2[arrayPos0], temp0, OOZSetup_deformTable)765arrayPos0++766loop767768// Slightly update the BG for the boss if the player is respawning at the closest starpost to the boss769// (Realigns the city, otherwise the BG would look like the boss takes place in the sky)770if stage.actNum == 2771tileLayer[1].scrollPos = 0772tileLayer[1].parallaxFactor = 44773if camera[0].ypos < 640774if camera[0].xpos > 8444775tileLayer[1].parallaxFactor = 128776object[SLOT_ZONESETUP].updatedBG = true777end if778end if779end if780end event781782783// ========================784// Editor Events785// ========================786787event RSDKDraw788DrawSprite(0)789end event790791792event RSDKLoad793LoadSpriteSheet("Global/Display.gif")794SpriteFrame(-16, -16, 32, 32, 1, 143)795796SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")797end event798799800