Path: blob/master/Sonic 2/Scripts/WFZ/EggmanLaser.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Eggman Laser Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.timer12private alias object.value1 : object.boundsL13private alias object.value2 : object.boundsR14private alias object.value3 : object.coreOffset.y15private alias object.value4 : object.laserFrame16private alias object.value5 : object.laserHeight17private alias object.value6 : object.health18private alias object.value7 : object.invincibilityTimer19private alias object.value8 : object.explodeState20private alias object.value9 : object.flashPaletteIndex2122// States23private alias 0 : WFZEGGMANLASER_SETUP24private alias 1 : WFZEGGMANLASER_ENTERDELAY25private alias 2 : WFZEGGMANLASER_ENTERBOSS26private alias 3 : WFZEGGMANLASER_MOVING27private alias 4 : WFZEGGMANLASER_OPENSHELL28private alias 5 : WFZEGGMANLASER_CORESHOWDELAY29private alias 6 : WFZEGGMANLASER_SHOWCORE30private alias 7 : WFZEGGMANLASER_LASERDELAY31private alias 8 : WFZEGGMANLASER_SETUPLASER32private alias 9 : WFZEGGMANLASER_CHARGELASER33private alias 10 : WFZEGGMANLASER_FIRINGLASER34private alias 11 : WFZEGGMANLASER_LASERMOVE35private alias 12 : WFZEGGMANLASER_HIDECORE36private alias 13 : WFZEGGMANLASER_CLOSESHELL37private alias 14 : WFZEGGMANLASER_DESTROYED38private alias 15 : WFZEGGMANLASER_RESETBOUNDS3940// Explode States41private alias 0 : WFZEGGMANLASER_BOSS_ACTIVE42private alias 1 : WFZEGGMANLASER_BOSS_EXPLODE43private alias 2 : WFZEGGMANLASER_BOSS_DESTROYED4445// WFZEggman States46private alias 2 : WFZEGGMAN_ESCAPE4748// WFZEggmanDispenser Aliases49private alias object.value0 : wfzEggmanDispenser.timer50private alias object.value8 : wfzEggmanDispenser.exploding5152// WFZEggmanDispenser States53private alias 14 : WFZEGGMANDISPENSER_DESTROYED5455// WFZEggmanPlatform States56private alias 2 : WFZEGGMANPLATFORM_DESTROYED5758// WFZEggmanBarrier Aliases59private alias object.value0 : wfzEggmanBarrier.timer6061// Player Aliases62private alias object.xpos : player.xpos63private alias object.value40 : player.hitboxLeft64private alias object.value38 : player.hitboxTop65private alias object.value41 : player.hitboxRight66private alias object.value39 : player.hitboxBottom676869// ========================70// Static Values71// ========================7273private value EggmanLaser_laserSheetX = 0747576// ========================77// Events78// ========================7980event ObjectUpdate81switch object.state82case WFZEGGMANLASER_SETUP83object.boundsL = object.xpos84object.boundsL -= 0x60000085object.boundsR = object.xpos86object.boundsR += 0x60000087object.laserFrame = 688object.drawOrder = 489object.inkEffect = 39091CheckCurrentStageFolder("Zone11")92if checkResult == true93object.flashPaletteIndex = 19694else95object.flashPaletteIndex = 19296end if9798#platform: USE_STANDALONE99object.health = 8100#endplatform101#platform: USE_ORIGINS102if game.bossOneLife == false103object.health = 8104else105object.health = 1106end if107#endplatform108// [Fallthrough]109110case WFZEGGMANLASER_ENTERDELAY111object.timer++112if object.timer >= 90113object.timer = 0114object.state = WFZEGGMANLASER_ENTERBOSS115end if116break117118case WFZEGGMANLASER_ENTERBOSS119object.ypos += 0x4000120121object.timer++122if object.timer >= 96123object.timer = 0124object[-1].type = TypeName[Eggman Dispenser]125object.state = WFZEGGMANLASER_MOVING126127if player[0].xpos < object.xpos128object.xvel = -0x10000129else130object.xvel = 0x10000131end if132end if133break134135case WFZEGGMANLASER_MOVING136object.timer++137if object.timer > 112138object.timer = 0139object.state = WFZEGGMANLASER_OPENSHELL140else141object.xpos += object.xvel142if object.xvel > 0143if object.xpos >= object.boundsR144FlipSign(object.xvel)145end if146else147if object.xpos <= object.boundsL148FlipSign(object.xvel)149end if150end if151end if152break153154case WFZEGGMANLASER_OPENSHELL155object.animationTimer++156if object.animationTimer == 6157object.animationTimer = 0158159object.frame++160if object.frame == 3161object.state = WFZEGGMANLASER_CORESHOWDELAY162end if163end if164break165166case WFZEGGMANLASER_CORESHOWDELAY167object.timer++168if object.timer > 26169object.timer = 0170object.state = WFZEGGMANLASER_SHOWCORE171end if172break173174case WFZEGGMANLASER_SHOWCORE175object.coreOffset.y += 0x10000176177object.timer++178if object.timer > 12179object.timer = 0180object.state = WFZEGGMANLASER_LASERDELAY181end if182break183184case WFZEGGMANLASER_LASERDELAY185object.timer++186if object.timer > 60187object.timer = 15188object.animationTimer = 15189object.laserHeight = 8190object.alpha = 0x200191object.state = WFZEGGMANLASER_SETUPLASER192end if193break194195case WFZEGGMANLASER_SETUPLASER196if object.animationTimer > 2197object.laserFrame = 6198else199object.laserFrame = 5200end if201202object.animationTimer--203if object.animationTimer == 0204object.timer--205if object.timer == 0206object.state = WFZEGGMANLASER_CHARGELASER207else208object.animationTimer = object.timer209if object.timer == 13210PlaySfx(SfxName[Laser Charge], false)211end if212end if213end if214break215216case WFZEGGMANLASER_CHARGELASER217object.laserFrame -= 5218object.laserFrame ^= 1219object.laserFrame += 5220221object.timer++222if object.timer > 64223object.timer = 0224object.alpha = 0xA0225object.state = WFZEGGMANLASER_FIRINGLASER226object.laserFrame = 5227PlaySfx(SfxName[Large Laser], false)228end if229break230231case WFZEGGMANLASER_FIRINGLASER232object.laserHeight += 0x20233if object.laserHeight >= 0x80234object.alpha += 0x20235object.laserHeight = 167236object.timer = 0237238if player[0].xpos < object.xpos239object.xvel = -0x10000240else241object.xvel = 0x10000242end if243244object.state = WFZEGGMANLASER_LASERMOVE245end if246break247248case WFZEGGMANLASER_LASERMOVE249object.timer++250object.alpha--251252if object.timer > 112253object.timer = 0254object.state = WFZEGGMANLASER_HIDECORE255else256object.xpos += object.xvel257if object.xvel > 0258if object.xpos >= object.boundsR259object.xvel = 0260end if261else262if object.xpos <= object.boundsL263object.xvel = 0264end if265end if266end if267break268269case WFZEGGMANLASER_HIDECORE270object.coreOffset.y -= 0x10000271object.alpha -= 24272273object.timer++274if object.timer > 12275object.timer = 0276object.animationTimer = 0277object.state = WFZEGGMANLASER_CLOSESHELL278end if279break280281case WFZEGGMANLASER_CLOSESHELL282object.animationTimer++283if object.animationTimer == 6284object.animationTimer = 0285286object.frame--287if object.frame == 0288if player[0].xpos < object.xpos289object.xvel = -0x10000290else291object.xvel = 0x10000292end if293294object.state = WFZEGGMANLASER_MOVING295end if296end if297break298299case WFZEGGMANLASER_DESTROYED300if object.alpha > 0301object.alpha -= 24302end if303304object.timer++305if object.timer >= 180306object.timer = 0307object.explodeState = WFZEGGMANLASER_BOSS_DESTROYED308object.state = WFZEGGMANLASER_RESETBOUNDS309end if310break311312case WFZEGGMANLASER_RESETBOUNDS313temp0 = tileLayer[0].ysize314temp0 <<= 7315stage.newYBoundary2 = temp0316317temp0 <<= 16318stage.deathBoundary = temp0319320#platform: USE_ORIGINS321if game.oneStageFlag != false322game.callbackResult = -1323CallNativeFunction4(NotifyCallback, NOTIFY_STAGE_RETRY, 1, stage.listPos, 0)324325// (State 16 doesn't do anything)326object.state = 16327end if328#endplatform329break330331end switch332333if object.health != 0334if object.invincibilityTimer > 0335object.invincibilityTimer--336GetBit(temp0, object.invincibilityTimer, 0)337if temp0 == true338SetPaletteEntry(0, object.flashPaletteIndex, 0xE0E0E0)339else340SetPaletteEntry(0, object.flashPaletteIndex, 0x000000)341end if342end if343344if object.coreOffset.y > 0345foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)346BoxCollisionTest(C_TOUCH, object.entityPos, -16, 0, 16, 16, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)347if checkResult == true348if object.invincibilityTimer == 0349CallFunction(Player_CheckHit)350if checkResult == true351object.health--352if object.health == 0353#platform: USE_ORIGINS354CallNativeFunction2(NotifyCallback, NOTIFY_KILL_BOSS, 0)355CallNativeFunction2(NotifyCallback, NOTIFY_BOSS_END, 1)356stage.timeEnabled = false357CallNativeFunction2(NotifyCallback, NOTIFY_ACT_FINISH, 0)358#endplatform359360player.score += 1000361object.explodeState = WFZEGGMANLASER_BOSS_EXPLODE362object.timer = 0363object.state = WFZEGGMANLASER_DESTROYED364365object[-4].state = WFZEGGMAN_ESCAPE366367wfzEggmanBarrier[-3].timer = 240368wfzEggmanBarrier[-2].timer = 240369370wfzEggmanDispenser[-1].exploding = true371wfzEggmanDispenser[-1].timer = 0372object[-1].state = WFZEGGMANDISPENSER_DESTROYED373374CreateTempObject(TypeName[Explosion], 0, object[+1].xpos, object[+1].ypos)375object[+1].state = WFZEGGMANPLATFORM_DESTROYED376377CreateTempObject(TypeName[Explosion], 0, object[+2].xpos, object[+2].ypos)378object[+2].state = WFZEGGMANPLATFORM_DESTROYED379380CreateTempObject(TypeName[Explosion], 0, object[+3].xpos, object[+3].ypos)381object[+3].state = WFZEGGMANPLATFORM_DESTROYED382383StopSfx(SfxName[Laser Charge])384StopSfx(SfxName[Large Laser])385else386object.invincibilityTimer = 32387PlaySfx(SfxName[Boss Hit], false)388end if389end if390end if391else392if object.state == WFZEGGMANLASER_LASERMOVE393BoxCollisionTest(C_TOUCH, object.entityPos, -16, 0, 16, 168, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)394if checkResult == true395CallFunction(Player_Hit)396end if397end if398end if399next400end if401end if402403if object.explodeState == WFZEGGMANLASER_BOSS_EXPLODE404temp0 = oscillation405temp0 &= 7406if temp0 == 0407Rand(temp0, 96)408temp0 -= 48409temp0 <<= 16410temp0 += object.xpos411Rand(temp1, 48)412temp1 -= 24413temp1 <<= 16414temp1 += object.ypos415CreateTempObject(TypeName[Explosion], 0, temp0, temp1)416object[tempObjectPos].drawOrder = 5417PlaySfx(SfxName[Explosion], false)418end if419end if420end event421422423event ObjectDraw424if object.explodeState < WFZEGGMANLASER_BOSS_DESTROYED425// Draw Core426temp1 = object.ypos427temp1 += object.coreOffset.y428DrawSpriteXY(4, object.xpos, temp1)429430// Draw Shell431DrawSprite(object.frame)432433// Draw Laser434temp0 = 168435temp0 -= object.laserHeight436EditFrame(5, -16, 0, 32, object.laserHeight, EggmanLaser_laserSheetX, temp0)437DrawSpriteFX(object.laserFrame, FX_INK, object.xpos, temp1)438end if439end event440441442event ObjectStartup443CheckCurrentStageFolder("Zone11")444if checkResult == true445LoadSpriteSheet("SCZ/Objects.gif")446SpriteFrame(-32, -8, 64, 23, 311, 1) // Shell - Frame 1 - #0447SpriteFrame(-32, -8, 64, 22, 311, 25) // Shell - Frame 2 - #1448SpriteFrame(-32, -8, 64, 19, 311, 48) // Shell - Frame 3 - #2449SpriteFrame(-32, -8, 64, 13, 311, 68) // Shell - Frame 4 - #3450SpriteFrame(-16, -8, 32, 16, 376, 1) // Core - #4451SpriteFrame(-16, 0, 32, 168, 261, 1) // Laser Beam - #5452SpriteFrame(0, 0, 1, 1, 261, 168) // Laser Bottom - #6453EggmanLaser_laserSheetX = 261454else455LoadSpriteSheet("MBZ/Objects.gif")456SpriteFrame(-32, -8, 64, 23, 513, 139) // Shell - Frame 1 - #0457SpriteFrame(-32, -8, 64, 22, 578, 139) // Shell - Frame 2 - #1458SpriteFrame(-32, -8, 64, 19, 643, 139) // Shell - Frame 3 - #2459SpriteFrame(-32, -8, 64, 13, 578, 162) // Shell - Frame 4 - #3460SpriteFrame(-16, -8, 32, 16, 397, 1) // Core - #4461SpriteFrame(-16, 0, 32, 168, 480, 1) // Laser Beam - #5462SpriteFrame(0, 0, 1, 1, 480, 168) // Laser Bottom - #6463EggmanLaser_laserSheetX = 480464end if465end event466467468// ========================469// Editor Events470// ========================471472event RSDKDraw473DrawSprite(0)474end event475476477event RSDKLoad478CheckCurrentStageFolder("Zone11")479if checkResult == true480LoadSpriteSheet("SCZ/Objects.gif")481SpriteFrame(-32, -8, 64, 23, 311, 1)482else483LoadSpriteSheet("MBZ/Objects.gif")484SpriteFrame(-32, -8, 64, 23, 513, 139)485end if486487SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")488end event489490491