Path: blob/master/Sonic 2/Scripts/EHZ/Eggman.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Eggman Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// Using EHZEggman as a prefix here because there's like 12 "Eggman" objects in the game so it's less confusing this way89// ========================10// Aliases11// ========================1213private alias object.value0 : object.timer14private alias object.value2 : object.exploding15private alias object.value3 : object.heliAnim16private alias object.value4 : object.heliAnimTimer17private alias object.value6 : object.heliSfxTimer18private alias object.value8 : object.health19private alias object.value9 : object.invincibilityTimer20private alias object.value10 : object.didHitPlayer2122// Eggman States23private alias 0 : EHZEGGMAN_AWAITPLAYER24private alias 1 : EHZEGGMAN_FLYIN25private alias 2 : EHZEGGMAN_ENTERCAR26private alias 3 : EHZEGGMAN_STARTCAR27private alias 4 : EHZEGGMAN_INCAR28private alias 5 : EHZEGGMAN_EXPLODE29private alias 6 : EHZEGGMAN_EXITCAR30private alias 7 : EHZEGGMAN_FLEE31private alias 8 : EHZEGGMAN_ESCAPE3233// Eggman Animations34private alias 0 : EHZEGGANI_INVISIBLE35private alias 1 : EHZEGGANI_IDLE36private alias 2 : EHZEGGANI_LAUGH37private alias 3 : EHZEGGANI_HIT38private alias 4 : EHZEGGANI_DEFEATED39private alias 5 : EHZEGGANI_TOASTED40private alias 6 : EHZEGGANI_PANIC4142// Eggman Heli Animations43private alias 0 : HELIANI_ACTIVE44private alias 1 : HELIANI_ENTERCAR45private alias 2 : HELIANI_RETRACTING46private alias 3 : HELIANI_NONE47private alias 4 : HELIANI_EXTENDING48private alias 5 : HELIANI_EXITCAR4950// Car Wheel Aliases51private alias object.value0 : eggmanWheel.timer52private alias object.value1 : eggmanWheel.xOffset53private alias object.value2 : eggmanWheel.parent5455// Car Aliases56private alias object.value1 : eggmanCar.drawPos.y57private alias object.value2 : eggmanCar.boundsL58private alias object.value3 : eggmanCar.boundsR5960// Car Drill States61private alias 0 : EHZEGGMANDRILL_ATTATCHED62private alias 2 : EHZEGGMANDRILL_FIRED6364// Player Aliases65private alias object.xpos : player.xpos66private alias object.xvel : player.xvel67private alias object.speed : player.speed68private alias object.animation : player.animation69private alias object.collisionRight : player.collisionRight7071private alias object.value40 : player.hitboxLeft72private alias object.value38 : player.hitboxTop73private alias object.value41 : player.hitboxRight74private alias object.value39 : player.hitboxBottom7576// Music Events77private alias 26 : SLOT_MUSICEVENT_BOSS7879private alias 0 : MUSICEVENT_FADETOBOSS80private alias 1 : MUSICEVENT_FADETOSTAGE818283// ========================84// Function Declarations85// ========================8687reserve function EHZEggman_PlayHeliSfx888990// ========================91// Function Definitions92// ========================9394private function EHZEggman_PlayHeliSfx95if object.heliSfxTimer == 096PlaySfx(SfxName[Helicopter], false)97end if98object.heliSfxTimer++99object.heliSfxTimer &= 31100end function101102103// ========================104// Events105// ========================106107event ObjectUpdate108switch object.state109case EHZEGGMAN_AWAITPLAYER110temp0 = object.ixpos111temp0 -= 200112stage.newXBoundary1 = temp0113114temp0 = object.ixpos115temp0 += 200116stage.newXBoundary2 = temp0117118if player[0].xpos > object.xpos119object.animation = EHZEGGANI_IDLE120ResetObjectEntity(SLOT_MUSICEVENT_BOSS, TypeName[Music Event], MUSICEVENT_FADETOBOSS, 0, 0)121object[SLOT_MUSICEVENT_BOSS].priority = PRIORITY_ACTIVE122123// The Car!!!!124object[+1].type = TypeName[Eggman Car]125object[+1].xpos = object.xpos126object[+1].xpos += 0x1590000127object[+1].ypos = object.ypos128eggmanCar[+1].boundsL = object.xpos129eggmanCar[+1].boundsL -= 0x1180000130temp0 = object.ixpos131temp0 -= 200132temp0 += screen.xcenter133if camera[0].xpos < temp0134temp0 -= camera[0].xpos135temp0 <<= 16136eggmanCar[+1].boundsL -= temp0137end if138139eggmanCar[+1].boundsR = object.xpos140eggmanCar[+1].boundsR += 0x1500000141object[+1].priority = PRIORITY_ACTIVE142143// Drrrrrill144object[+2].type = TypeName[Eggman Drill]145object[+2].priority = PRIORITY_ACTIVE146147// Back Wheel148object[-1].type = TypeName[Eggman Wheel]149eggmanWheel[-1].xOffset = -0x2C0000150eggmanWheel[-1].parent = object[+1].entityPos151object[-1].priority = PRIORITY_ACTIVE152153// Front Wheel 1154object[+3].type = TypeName[Eggman Wheel]155eggmanWheel[+3].xOffset = -0xC0000156eggmanWheel[+3].parent = object[+1].entityPos157object[+3].priority = PRIORITY_ACTIVE158159// Front Wheel 2160object[+4].type = TypeName[Eggman Wheel]161eggmanWheel[+4].xOffset = 0x1C0000162eggmanWheel[+4].parent = object[+1].entityPos163object[+4].priority = PRIORITY_ACTIVE164165object.xpos += 0x1580000166object.ypos -= 0x13F0000167object.priority = PRIORITY_ACTIVE168object.state++169end if170break171172case EHZEGGMAN_FLYIN173CallFunction(EHZEggman_PlayHeliSfx)174object.xpos -= 0x10000175object.ypos += 0x10000176object.timer++177if object.timer == 320178object.heliAnim = HELIANI_ENTERCAR179object.heliAnimTimer = 0180object.timer = 0181object.state++182end if183break184185case EHZEGGMAN_ENTERCAR186break187188case EHZEGGMAN_STARTCAR189object.timer++190if object.timer == 24191object.timer = 0192193#platform: USE_STANDALONE194object.health = 8195#endplatform196#platform: USE_ORIGINS197if game.bossOneLife == false198object.health = 8199else200object.health = 1201end if202#endplatform203204object.state++205object[+1].xvel = -0x20000206object[+1].state++207end if208break209210case EHZEGGMAN_INCAR211break212213case EHZEGGMAN_EXPLODE214object.timer++215if object.timer == 180216object.timer = 0217object.heliAnim = HELIANI_EXTENDING218object.animation = EHZEGGANI_TOASTED219object.exploding = false220object.state++221ResetObjectEntity(SLOT_MUSICEVENT_BOSS, TypeName[Music Event], MUSICEVENT_FADETOSTAGE, 0, 0)222object[SLOT_MUSICEVENT_BOSS].priority = PRIORITY_ACTIVE223temp0 = tileLayer[0].xsize224temp0 <<= 7225stage.newXBoundary2 = temp0226end if227break228229case EHZEGGMAN_EXITCAR230break231232case EHZEGGMAN_FLEE233CallFunction(EHZEggman_PlayHeliSfx)234object.ypos -= 0x10000235236object.timer++237if object.timer == 96238object.timer = 0239object.direction = FLIP_X240object.animation = EHZEGGANI_PANIC241object.state++242end if243break244245case EHZEGGMAN_ESCAPE246if object.outOfBounds == false247CallFunction(EHZEggman_PlayHeliSfx)248end if249object.xpos += 0x60000250251temp0 = stage.newXBoundary2252temp0 += 128253temp0 <<= 16254if object.xpos >= temp0255object.type = TypeName[Blank Object]256end if257break258259end switch260261if object.health != 0262if object.invincibilityTimer > 0263object.invincibilityTimer--264GetBit(temp0, object.invincibilityTimer, 0)265if temp0 == true // Palette flashing when hit266SetPaletteEntry(0, 192, 0xE0E0E0)267else268SetPaletteEntry(0, 192, 0x000000)269end if270end if271272foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)273if object.invincibilityTimer == 0 // Invulnerable?274CheckEqual(player[currentPlayer].animation, ANI_HURT)275temp0 = checkResult276CheckEqual(player[currentPlayer].animation, ANI_DYING)277temp0 |= checkResult278CheckEqual(player[currentPlayer].animation, ANI_DROWNING)279temp0 |= checkResult280if temp0 != false281if object.animation != EHZEGGANI_LAUGH282object.animation = EHZEGGANI_LAUGH283object.animationTimer = 0284end if285286if currentPlayer == 0287object.didHitPlayer = true288end if289end if290291BoxCollisionTest(C_TOUCH, object.entityPos, -24, -24, 24, 24, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)292if checkResult == true293CallFunction(Player_CheckHit)294if checkResult == true295object.health--296if object.health == 0297#platform: USE_ORIGINS298CallNativeFunction2(NotifyCallback, NOTIFY_KILL_BOSS, 0)299CallNativeFunction2(NotifyCallback, NOTIFY_BOSS_END, 1)300#endplatform301302player.score += 1000303object.animation = EHZEGGANI_DEFEATED304object.animationTimer = 0305object.exploding = true306object.state++307308// The Car!!!!309object[+1].state++310object[+1].yvel = -0x18000311object[+1].ypos = eggmanCar[+1].drawPos.y312313if object[+2].state == EHZEGGMANDRILL_ATTATCHED314object[+2].state = EHZEGGMANDRILL_FIRED315if object.direction == FLIP_NONE316object[+2].xvel = -0x30000317else318object[+2].xvel = 0x30000319end if320end if321else322object.animation = EHZEGGANI_HIT323object.animationTimer = 0324object.invincibilityTimer = 32325PlaySfx(SfxName[Boss Hit], false)326end if327end if328end if329end if330next331end if332333// R Boundary334if object.state != EHZEGGMAN_ESCAPE335foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)336temp0 = player[currentPlayer].collisionRight337temp0 <<= 16338temp0 += player[currentPlayer].xpos339temp1 = stage.curXBoundary2340temp1 <<= 16341if temp0 > temp1342player[currentPlayer].xvel = 0343player[currentPlayer].speed = 0344player[currentPlayer].xpos = temp1345temp0 = player[currentPlayer].collisionRight346temp0 <<= 16347player[currentPlayer].xpos -= temp0348end if349next350end if351352if object.exploding == true353temp0 = oscillation354temp0 &= 7355if temp0 == 0356Rand(temp0, 96)357temp0 -= 48358temp0 <<= 16359temp0 += object.xpos360361Rand(temp1, 48)362temp1 -= 24363temp1 <<= 16364temp1 += object.ypos365366CreateTempObject(TypeName[Explosion], 0, temp0, temp1)367object[tempObjectPos].drawOrder = 5368PlaySfx(SfxName[Explosion], false)369end if370end if371end event372373374event ObjectDraw375if object.animation != EHZEGGANI_INVISIBLE376switch object.heliAnim377case HELIANI_ACTIVE378temp0 = object.heliAnimTimer379temp0 >>= 1380temp0 += 12381382object.heliAnimTimer++383object.heliAnimTimer &= 3384DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)385break386387case HELIANI_ENTERCAR388temp0 = object.heliAnimTimer389temp0 /= 6390temp0 += 8391392object.heliAnimTimer++393if object.heliAnimTimer == 24394object.heliAnimTimer = 0395object.heliAnim = HELIANI_RETRACTING396end if397398DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)399break400401case HELIANI_RETRACTING402temp0 = object.heliAnimTimer403temp0 <<= 16404temp0 += object.ypos405DrawSpriteFX(7, FX_FLIP, object.xpos, temp0)406407object.heliAnimTimer++408if object.heliAnimTimer == 12409object.state++410object.heliAnim = HELIANI_NONE411end if412break413414case HELIANI_NONE415break416417case HELIANI_EXTENDING418object.heliAnimTimer--419if object.heliAnimTimer > 0420temp0 = object.heliAnimTimer421else422temp0 = 0423end if424425temp0 <<= 16426temp0 += object.ypos427DrawSpriteFX(7, FX_FLIP, object.xpos, temp0)428429if object.heliAnimTimer == -12430object.heliAnimTimer = 24431object.heliAnim = HELIANI_EXITCAR432end if433break434435case HELIANI_EXITCAR436object.heliAnimTimer--437438temp0 = object.heliAnimTimer439temp0 /= 6440temp0 += 8441442if object.heliAnimTimer == 0443object.heliAnim = HELIANI_ACTIVE444object.state++445end if446447DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)448break449450end switch451452DrawSpriteFX(6, FX_FLIP, object.xpos, object.ypos)453end if454455switch object.animation456default457case EHZEGGANI_INVISIBLE458break459460case EHZEGGANI_IDLE461temp0 = object.animationTimer462temp0 >>= 3463object.animationTimer++464object.animationTimer &= 15465DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)466break467468case EHZEGGANI_LAUGH469temp0 = object.animationTimer470temp0 &= 15471temp0 >>= 3472temp0 += 2473474object.animationTimer++475if object.animationTimer == 50476object.animationTimer = 0477if player[0].animation != ANI_DYING478object.animation = EHZEGGANI_IDLE479end if480end if481482DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)483break484485case EHZEGGANI_HIT486temp0 = object.animationTimer487temp0 &= 1488temp0 += 2489490object.animationTimer++491if object.animationTimer == 50492object.animationTimer = 0493object.animation = EHZEGGANI_IDLE494end if495496DrawSpriteFX(4, FX_FLIP, object.xpos, object.ypos)497break498499case EHZEGGANI_DEFEATED500temp0 = object.animationTimer501temp0 >>= 5502temp0 += 4503temp0 %= 5504505object.animationTimer++506object.animationTimer &= 63507DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)508break509510case EHZEGGANI_TOASTED511DrawSpriteFX(5, FX_FLIP, object.xpos, object.ypos)512break513514case EHZEGGANI_PANIC515temp0 = object.animationTimer516temp0 >>= 3517518object.animationTimer++519object.animationTimer &= 15520DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)521522temp0 = object.animationTimer523temp0 >>= 2524temp0 &= 1525if temp0 == 1526DrawSpriteFX(14, FX_FLIP, object.xpos, object.ypos)527end if528break529530end switch531end event532533534event ObjectStartup535// Check if in EHZ536CheckCurrentStageFolder("Zone01")537if checkResult == true538// Load EHZ stuff539LoadSpriteSheet("EHZ/Objects.gif")540541// Eggman Frames542SpriteFrame(-28, -28, 60, 20, 70, 155)543SpriteFrame(-28, -28, 60, 20, 131, 155)544SpriteFrame(-28, -28, 60, 20, 70, 176)545SpriteFrame(-28, -28, 60, 20, 131, 176)546SpriteFrame(-28, -28, 60, 20, 70, 197)547SpriteFrame(-28, -28, 60, 20, 131, 197)548549// Eggmobile Body Frame550SpriteFrame(-32, -8, 64, 29, 0, 209)551552// Boss Helicopter Frames553SpriteFrame(2, -40, 16, 16, 65, 239)554SpriteFrame(-62, -40, 144, 16, 1, 239)555SpriteFrame(-46, -40, 112, 16, 17, 239)556SpriteFrame(-30, -40, 80, 16, 33, 239)557SpriteFrame(-14, -40, 48, 16, 49, 239)558SpriteFrame(2, -40, 80, 16, 65, 222)559SpriteFrame(-62, -40, 79, 16, 1, 239)560561// Sweat Frame562SpriteFrame(-3, -28, 11, 8, 27, 53)563564// Erase the boss in VS mode565if options.vsMode == true566foreach (TypeName[Eggman], arrayPos0, ALL_ENTITIES)567object[arrayPos0].type = TypeName[Blank Object]568next569end if570else571LoadSpriteSheet("MBZ/Objects.gif")572573// Eggman Frames574SpriteFrame(-28, -28, 60, 20, 1, 1)575SpriteFrame(-28, -28, 60, 20, 62, 1)576SpriteFrame(-28, -28, 60, 20, 1, 22)577SpriteFrame(-28, -28, 60, 20, 62, 22)578SpriteFrame(-28, -28, 60, 20, 1, 43)579SpriteFrame(-28, -28, 60, 20, 62, 43)580581// Eggmobile Body Frame582SpriteFrame(-32, -8, 64, 29, 415, 170)583584// Boss Helicopter Frames585SpriteFrame(2, -40, 16, 16, 169, 91)586SpriteFrame(-62, -40, 144, 16, 105, 91)587SpriteFrame(-46, -40, 112, 16, 121, 91)588SpriteFrame(-30, -40, 80, 16, 137, 91)589SpriteFrame(-14, -40, 48, 16, 153, 91)590SpriteFrame(2, -40, 80, 16, 42, 64)591SpriteFrame(-62, -40, 79, 16, 105, 91)592593// Sweat Frame594SpriteFrame(-3, -28, 11, 8, 45, 88)595596// No need to erase the boss in VS mode when in MBZ since it should never even be active there anyway597end if598end event599600601// ========================602// Editor Events603// ========================604605event RSDKDraw606DrawSprite(0)607DrawSprite(1)608609if editor.showGizmos == true610editor.drawingOverlay = true611612// Draw lines connecting the whole network of boss objects613DrawArrow(object.xpos, object.ypos, object[-1].xpos, object[-1].ypos, 255, 255, 0) // Back Wheel614DrawArrow(object.xpos, object.ypos, object[+1].xpos, object[+1].ypos, 255, 255, 0) // Car615DrawArrow(object.xpos, object.ypos, object[+2].xpos, object[+2].ypos, 255, 255, 0) // Drill616DrawArrow(object.xpos, object.ypos, object[+3].xpos, object[+3].ypos, 255, 255, 0) // Front Wheel 1617DrawArrow(object.xpos, object.ypos, object[+4].xpos, object[+4].ypos, 255, 255, 0) // Front Wheel 2618619// Draw arena bounds620// Left bounds depends on screen size, this is a rough estimation621temp0 = 224; temp1 = 208; temp2 = 200; temp3 = 32;622CallFunction(EditorHelpers_DrawHitbox)623624editor.drawingOverlay = false625end if626end event627628629event RSDKLoad630CheckCurrentStageFolder("Zone01")631if checkResult == true632LoadSpriteSheet("EHZ/Objects.gif")633SpriteFrame(-28, -28, 60, 20, 70, 155)634SpriteFrame(-32, -8, 64, 29, 0, 209)635else636LoadSpriteSheet("MBZ/Objects.gif")637SpriteFrame(-28, -28, 60, 20, 1, 1)638SpriteFrame(-32, -8, 64, 29, 415, 170)639end if640641SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")642end event643644645