Path: blob/master/Sonic 2/Scripts/ARZ/Eggman.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Eggman Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// Using ARZEggman as a prefix here because there's like 12 "Eggman" objects in the game so its less confusing this way89// ========================10// Aliases11// ========================1213private alias object.value0 : object.originPos.x14private alias object.value1 : object.originPos.y15private alias object.value2 : object.oscillationAngle16private alias object.value4 : object.timer17private alias object.value5 : object.unused1 // Technically, it *is* used... but it's never used anywhere important18private alias object.value6 : object.unused2 // Technically, it *is* used... but it's never used anywhere important19private alias object.value7 : object.health20private alias object.value8 : object.invincibilityTimer21private alias object.value9 : object.exploding2223// Eggman States24private alias 0 : ARZEGGMAN_AWAITPLAYER25private alias 1 : ARZEGGMAN_BOSSFIGHT26private alias 2 : ARZEGGMAN_EXPLODE27private alias 3 : ARZEGGMAN_DEFEATFALL28private alias 4 : ARZEGGMAN_DEFEATRISE29private alias 5 : ARZEGGMAN_FLEE30private alias 6 : ARZEGGMAN_ESCAPE3132// Eggman Animations33private alias 0 : ARZEGGANI_INVISIBLE34private alias 1 : ARZEGGANI_IDLE35private alias 2 : ARZEGGANI_LAUGH36private alias 3 : ARZEGGANI_HIT37private alias 4 : ARZEGGANI_DEFEATED38private alias 5 : ARZEGGANI_TOASTED39private alias 6 : ARZEGGANI_PANIC4041// EggmanHammer Aliases42private alias object.value0 : eggmanHammer.originPos.x43private alias object.value1 : eggmanHammer.originPos.y44private alias object.value2 : eggmanHammer.oscillationAngle45private alias object.value3 : eggmanHammer.timer46private alias object.value4 : eggmanHammer.boundsR47private alias object.value5 : eggmanHammer.boundsL48private alias object.value7 : eggmanHammer.boundsOffset49private alias object.value8 : eggmanHammer.hideFlames50private alias object.value12 : eggmanHammer.arrowVelocity5152// EggmanHammer States53private alias 4 : EGGMANHAMMER_DESTROYED54private alias 5 : EGGMANHAMMER_DEBRIS5556// EggmanTotemPole Aliases57private alias object.value3 : eggmanTotemPole.timer5859// EggmanTotemPole States60private alias 3 : EGGMANTOTEMPOLE_LOWERING6162// EggmanArrow States63private alias 2 : EGGMANARROW_FALLING6465// Player Aliases66private alias object.xpos : player.xpos67private alias object.xvel : player.xvel68private alias object.speed : player.speed69private alias object.animation : player.animation70private alias object.collisionRight : player.collisionRight7172private alias object.value40 : player.hitboxLeft73private alias object.value38 : player.hitboxTop74private alias object.value41 : player.hitboxRight75private alias object.value39 : player.hitboxBottom7677// Music Events78private alias 26 : SLOT_MUSICEVENT_BOSS7980private alias 0 : MUSICEVENT_FADETOBOSS81private alias 1 : MUSICEVENT_FADETOSTAGE828384// ========================85// Function Declarations86// ========================8788reserve function ARZEggman_Oscillate899091// ========================92// Tables93// ========================9495// No flames so this isn't used at all96// It's the same table as the one in [CPZ Eggman], likely just here because the entire CPZ script was used as a base97private table ARZEggman_flameAnimFrameTable987, 8, 8, 7, 7, 1699end table100101102// ========================103// Function Definitions104// ========================105106private function ARZEggman_Oscillate107object.ypos = object.originPos.y108Sin256(temp0, object.oscillationAngle)109temp0 <<= 10110object.ypos += temp0111object.oscillationAngle += 2112object.oscillationAngle &= 255113114object[+1].xpos = object.xpos115object[+1].ypos = object.ypos116object[+1].direction = object.direction117end function118119120// ========================121// Events122// ========================123124event ObjectUpdate125switch object.state126case ARZEGGMAN_AWAITPLAYER127temp0 = object.ixpos128temp0 -= screen.xcenter129stage.newXBoundary1 = temp0130131temp0 = object.ixpos132temp0 += screen.xcenter133stage.newXBoundary2 = temp0134135if player[0].xpos > object.xpos136object.animation = ARZEGGANI_IDLE137ResetObjectEntity(SLOT_MUSICEVENT_BOSS, TypeName[Music Event], MUSICEVENT_FADETOBOSS, 0, 0)138object[SLOT_MUSICEVENT_BOSS].priority = PRIORITY_ACTIVE139140object[+1].type = TypeName[Eggman Hammer]141eggmanHammer[+1].timer = 168142143object.ypos -= 0xF80000144object.originPos.y = object.ypos145146object[+1].xpos = object.xpos147object[+1].ypos = object.ypos148eggmanHammer[+1].originPos.x = object.xpos149eggmanHammer[+1].originPos.y = object.ypos150object[+1].frame = 3151object[+1].priority = PRIORITY_ACTIVE152153object[+5].type = TypeName[Eggman Totem]154object[+5].xpos = object.ixpos155object[+5].xpos -= screen.xcenter156object[+5].xpos += 16157object[+5].xpos <<= 16158159eggmanHammer[+1].boundsR = object[+5].xpos160eggmanHammer[+1].boundsR += 0x5A0000161162eggmanTotemPole[+5].timer = 136163object[+5].drawOrder = 2164object[+5].priority = PRIORITY_ACTIVE165166eggmanHammer[+1].boundsOffset = 0xC800167eggmanHammer[+1].boundsOffset *= screen.xcenter168eggmanHammer[+1].boundsOffset /= 160169eggmanHammer[+1].arrowVelocity = 0x30000170eggmanHammer[+1].arrowVelocity *= screen.xcenter171eggmanHammer[+1].arrowVelocity /= 160172173object[+6].type = TypeName[Eggman Totem]174object[+6].xpos = object.ixpos175object[+6].xpos += screen.xcenter176object[+6].xpos -= 16177object[+6].xpos <<= 16178179eggmanHammer[+1].boundsL = object[+6].xpos180eggmanHammer[+1].boundsL -= 0x5A0000181182eggmanTotemPole[+6].timer = 136183object[+6].direction = FLIP_X184object[+6].drawOrder = 2185object[+6].priority = PRIORITY_ACTIVE186187#platform: USE_STANDALONE188object.health = 8189#endplatform190#platform: USE_ORIGINS191if game.bossOneLife == false192object.health = 8193else194object.health = 1195end if196#endplatform197198object.priority = PRIORITY_ACTIVE199object.state++200end if201break202203case ARZEGGMAN_BOSSFIGHT204break205206case ARZEGGMAN_EXPLODE207object.timer++208if object.timer == 60209if object.direction == FLIP_NONE210object[+1].xvel = -0x10000211else212object[+1].xvel = 0x10000213end if214215object[+1].yvel = -0x40000216object[+1].state++217end if218219if object.timer == 180220object.timer = 0221object.animation = ARZEGGANI_TOASTED222object.exploding = false223object.state++224225ResetObjectEntity(SLOT_MUSICEVENT_BOSS, TypeName[Music Event], MUSICEVENT_FADETOSTAGE, 0, 0)226object[SLOT_MUSICEVENT_BOSS].priority = PRIORITY_ACTIVE227228temp0 = tileLayer[0].xsize229temp0 <<= 7230stage.newXBoundary2 = temp0231eggmanHammer[+1].hideFlames = true232end if233break234235case ARZEGGMAN_DEFEATFALL236object.ypos += object.yvel237object.yvel += 0x1800238239object.timer++240if object.timer == 38241object.yvel = 0242object.timer = 0243object.animationTimer = 0244eggmanHammer[+1].hideFlames = false245object.state++246end if247248object[+1].xpos = object.xpos249object[+1].ypos = object.ypos250object[+1].direction = object.direction251break252253case ARZEGGMAN_DEFEATRISE254if object.timer < 48255object.ypos += object.yvel256object.yvel -= 0x800257object.timer++258else259object.timer = 0260object.yvel = 0261object.originPos.y = object.ypos262object.state++263end if264265object[+1].xpos = object.xpos266object[+1].ypos = object.ypos267object[+1].direction = object.direction268break269270case ARZEGGMAN_FLEE271object.ypos = object.originPos.y272CallFunction(ARZEggman_Oscillate)273274if object.timer < 8275object.timer++276else277object.timer = 0278object.animation = ARZEGGANI_PANIC279object.animationTimer = 0280object.unused1 = 2281object.unused2 = 0282object.direction = FLIP_X283object.priority = PRIORITY_ACTIVE284285#platform: USE_STANDALONE286temp0 = tileLayer[0].xsize287temp0 <<= 7288stage.newXBoundary2 = temp0289#endplatform290291object.state++292end if293break294295case ARZEGGMAN_ESCAPE296object.xpos += 0x40000297object.originPos.y -= 0x4000298299CallFunction(ARZEggman_Oscillate)300301if object.outOfBounds == true302object.type = TypeName[Blank Object]303object[+1].type = TypeName[Blank Object]304end if305break306307end switch308309if object.health != 0310if object.invincibilityTimer > 0311object.invincibilityTimer--312GetBit(temp0, object.invincibilityTimer, 0)313if temp0 == true314SetPaletteEntry(0, 192, 0xE0E0E0)315else316SetPaletteEntry(0, 192, 0x000000)317end if318end if319320foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)321if object.invincibilityTimer == 0322CheckEqual(player[currentPlayer].animation, ANI_HURT)323temp0 = checkResult324CheckEqual(player[currentPlayer].animation, ANI_DYING)325temp0 |= checkResult326CheckEqual(player[currentPlayer].animation, ANI_DROWNING)327temp0 |= checkResult328if temp0 != 0329if object.animation != ARZEGGANI_LAUGH330object.animation = ARZEGGANI_LAUGH331object.animationTimer = 0332end if333end if334335BoxCollisionTest(C_TOUCH, object.entityPos, -24, -24, 24, 24, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)336if checkResult == true337CallFunction(Player_CheckHit)338if checkResult == true339object.health--340if object.health == 0341#platform: USE_ORIGINS342CallNativeFunction2(NotifyCallback, NOTIFY_KILL_BOSS, 0)343CallNativeFunction2(NotifyCallback, NOTIFY_BOSS_END, 1)344#endplatform345346player.score += 1000347object.animation = ARZEGGANI_DEFEATED348object.animationTimer = 0349object.unused1 = 0350object.exploding = true351object.originPos.y = object.ypos352object.oscillationAngle = eggmanHammer[+1].oscillationAngle353object.state++354object[+1].state = EGGMANHAMMER_DESTROYED355356object[+2].state = EGGMANARROW_FALLING357object[+3].state = EGGMANARROW_FALLING358object[+4].state = EGGMANARROW_FALLING359360eggmanTotemPole[+5].timer = 144361object[+5].state = EGGMANTOTEMPOLE_LOWERING362363eggmanTotemPole[+6].timer = 144364object[+6].state = EGGMANTOTEMPOLE_LOWERING365else366object.animation = ARZEGGANI_HIT367object.animationTimer = 0368object.invincibilityTimer = 64369PlaySfx(SfxName[Boss Hit], false)370end if371end if372end if373end if374next375end if376377if object.state != ARZEGGMAN_ESCAPE378foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)379temp0 = player[currentPlayer].collisionRight380temp0 <<= 16381temp0 += player[currentPlayer].xpos382temp1 = stage.curXBoundary2383temp1 <<= 16384if temp0 > temp1385player[currentPlayer].xvel = 0386player[currentPlayer].speed = 0387player[currentPlayer].xpos = temp1388temp0 = player[currentPlayer].collisionRight389temp0 <<= 16390player[currentPlayer].xpos -= temp0391end if392next393end if394395if object.exploding == true396temp0 = oscillation397temp0 &= 7398if temp0 == 0399Rand(temp0, 48)400temp0 -= 24401temp0 <<= 16402temp0 += object.xpos403Rand(temp1, 48)404temp1 -= 24405temp1 <<= 16406temp1 += object.ypos407CreateTempObject(TypeName[Explosion], 0, temp0, temp1)408object[tempObjectPos].drawOrder = 5409PlaySfx(SfxName[Explosion], false)410end if411end if412end event413414415event ObjectDraw416switch object.animation417default418case ARZEGGANI_INVISIBLE419break420421case ARZEGGANI_IDLE422temp0 = object.animationTimer423temp0 >>= 3424object.animationTimer++425object.animationTimer &= 15426DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)427break428429case ARZEGGANI_LAUGH430temp0 = object.animationTimer431temp0 &= 15432temp0 >>= 3433temp0 += 2434object.animationTimer++435if object.animationTimer == 50436object.animationTimer = 0437if player[0].animation != ANI_DYING438object.animation = ARZEGGANI_IDLE439end if440end if441DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)442break443444case ARZEGGANI_HIT445temp0 = object.animationTimer446temp0 &= 1447temp0 += 2448object.animationTimer++449if object.animationTimer == 50450object.animationTimer = 0451object.animation = ARZEGGANI_IDLE452end if453DrawSpriteFX(4, FX_FLIP, object.xpos, object.ypos)454break455456case ARZEGGANI_DEFEATED457temp0 = object.animationTimer458temp0 >>= 5459temp0 += 4460temp0 %= 5461object.animationTimer++462object.animationTimer &= 63463DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)464break465466case ARZEGGANI_TOASTED467DrawSpriteFX(5, FX_FLIP, object.xpos, object.ypos)468break469470case ARZEGGANI_PANIC471temp0 = object.animationTimer472temp0 >>= 3473object.animationTimer++474object.animationTimer &= 15475DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)476477temp0 = object.animationTimer478temp0 >>= 2479temp0 &= 1480if temp0 == 1481DrawSpriteFX(15, FX_FLIP, object.xpos, object.ypos)482end if483break484485end switch486end event487488489event ObjectStartup490CheckCurrentStageFolder("Zone03")491if checkResult == true492LoadSpriteSheet("Global/EggMobile.gif")493494// Eggman Frames495SpriteFrame(-28, -28, 60, 20, 5, 1)496SpriteFrame(-28, -28, 60, 20, 66, 1)497SpriteFrame(-28, -28, 60, 20, 5, 22)498SpriteFrame(-28, -28, 60, 20, 66, 22)499SpriteFrame(-28, -28, 60, 20, 5, 43)500SpriteFrame(-28, -28, 60, 20, 66, 43)501502// Eggmobile Body Frame503SpriteFrame(-32, -8, 64, 29, 1, 64)504505// Eggmobile Jet Frames506SpriteFrame(31, 4, 12, 8, 66, 65)507SpriteFrame(30, 2, 14, 12, 66, 74)508SpriteFrame(31, -2, 22, 14, 66, 87)509SpriteFrame(31, -9, 32, 26, 94, 64)510SpriteFrame(31, -2, 22, 14, 66, 87)511SpriteFrame(31, -9, 32, 26, 94, 64)512SpriteFrame(31, 4, 12, 8, 66, 65)513SpriteFrame(30, 2, 14, 12, 66, 74)514515// Sweat Frames516SpriteFrame(-3, -28, 11, 8, 79, 65)517SpriteFrame(0, 0, 0, 0, 7, 2)518519if options.vsMode == true520foreach (TypeName[Eggman], arrayPos0, ALL_ENTITIES)521object[arrayPos0].type = TypeName[Blank Object]522next523end if524else525LoadSpriteSheet("MBZ/Objects.gif")526527// Eggman Frames528SpriteFrame(-28, -28, 60, 20, 1, 1)529SpriteFrame(-28, -28, 60, 20, 62, 1)530SpriteFrame(-28, -28, 60, 20, 1, 22)531SpriteFrame(-28, -28, 60, 20, 62, 22)532SpriteFrame(-28, -28, 60, 20, 1, 43)533SpriteFrame(-28, -28, 60, 20, 62, 43)534535// Eggmobile Body Frame536SpriteFrame(-32, -8, 64, 29, 415, 170)537538// Eggmobile Jet Frames539SpriteFrame(31, 4, 12, 8, 57, 90)540SpriteFrame(30, 2, 14, 12, 57, 99)541SpriteFrame(31, -2, 22, 14, 34, 97)542SpriteFrame(31, -9, 32, 26, 72, 86)543SpriteFrame(31, -2, 22, 14, 34, 97)544SpriteFrame(31, -9, 32, 26, 72, 86)545SpriteFrame(31, 4, 12, 8, 57, 90)546SpriteFrame(30, 2, 14, 12, 57, 99)547548// Sweat Frames549SpriteFrame(-3, -28, 11, 8, 45, 88)550SpriteFrame(0, 0, 0, 0, 7, 2)551end if552end event553554555// ========================556// Editor Events557// ========================558559event RSDKDraw560DrawSprite(0)561DrawSprite(1)562end event563564565event RSDKLoad566CheckCurrentStageFolder("Zone03")567if checkResult == true568LoadSpriteSheet("Global/EggMobile.gif")569SpriteFrame(-28, -28, 60, 20, 5, 1)570SpriteFrame(-32, -8, 64, 29, 1, 64)571else572LoadSpriteSheet("MBZ/Objects.gif")573SpriteFrame(-28, -28, 60, 20, 1, 1)574SpriteFrame(-32, -8, 64, 29, 415, 170)575end if576577SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")578end event579580581