Path: blob/master/Sonic 1/Scripts/SLZ/Eggman.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: SLZ Eggman Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// Using SLZEggman as a prefix here because there's like 6 "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.oscillateAngle16private alias object.value4 : object.timer17private alias object.value5 : object.flameAnim18private alias object.value6 : object.flameAnimTimer19private alias object.value7 : object.health20private alias object.value8 : object.invincibilityTimer21private alias object.value9 : object.targetSeeSaw22private alias object.value10 : object.boundsL23private alias object.value11 : object.boundsR24private alias object.value12 : object.targetScreenPos.y25private alias object.value13 : object.playerHit // as in, if Eggman's been hit by the player at all (as opposed to getting hit by a seesaw bomb)2627// SeeSaw Aliases28private alias object.value0 : object.orbTimer29private alias object.value8 : object.orbTargetPos.x30private alias object.value9 : object.orbTargetPos.y31private alias object.value10 : object.orbFrame32private alias object.value12 : object.stood3334private alias 2 : SEESAW_ORB_LAUNCHED35private alias 3 : SEESAW_NO_ORB3637// Eggman States38private alias 0 : SLZEGGMAN_AWAITPLAYER39private alias 1 : SLZEGGMAN_ENTEREGGMAN40private alias 2 : SLZEGGMAN_MOVEANDDROP41private alias 3 : SLZEGGMAN_DROPPEDBALL42private alias 4 : SLZEGGMAN_EXPLODE43private alias 5 : SLZEGGMAN_DEFEATFALL44private alias 6 : SLZEGGMAN_DEFEATRISE45private alias 7 : SLZEGGMAN_FLEE46private alias 8 : SLZEGGMAN_ESCAPE4748// Eggman Animations49private alias 0 : SLZEGGANI_INVISIBLE50private alias 1 : SLZEGGANI_IDLE51private alias 2 : SLZEGGANI_LAUGH52private alias 3 : SLZEGGANI_HIT53private alias 4 : SLZEGGANI_DEFEATED54private alias 5 : SLZEGGANI_TOASTED55private alias 6 : SLZEGGANI_PANIC5657// Flame Animations58private alias 0 : FLAME_INACTIVE59private alias 1 : FLAME_ACTIVE60private alias 2 : FLAME_EXPLODE6162// Music Events63private alias 26 : SLOT_MUSICEVENT_BOSS6465private alias 0 : MUSICEVENT_FADETOBOSS66private alias 1 : MUSICEVENT_FADETOSTAGE67private alias 2 : MUSICEVENT_TRANSITION6869// Player Aliases70private alias object.xpos : player.xpos71private alias object.xvel : player.xvel72private alias object.speed : player.speed73private alias object.animation : player.animation74private alias object.collisionRight : player.collisionRight7576private alias object.value40 : player.hitboxLeft77private alias object.value38 : player.hitboxTop78private alias object.value41 : player.hitboxRight79private alias object.value39 : player.hitboxBottom8081// Achievement Aliases82private alias 7 : ACHIEVEMENT_BOMBSAWAY838485// ========================86// Function Declarations87// ========================8889reserve function SLZEggman_Hit90reserve function SLZEggman_DropSpikeBall91reserve function SLZEggman_Oscillate929394// ========================95// Tables96// ========================9798// entityPos offsets99private table SLZEggman_seesawSlotOffsets1002, 3, 1101end table102103// x positions of where Eggman should drop bombs104private table SLZEggman_seesawDropPos[6]105106107// ========================108// Function Definitions109// ========================110111private function SLZEggman_Hit112object.health--113if object.health == 0114#platform: USE_ORIGINS115CallNativeFunction2(NotifyCallback, NOTIFY_KILL_BOSS, 0)116CallNativeFunction2(NotifyCallback, NOTIFY_BOSS_END, true)117#endplatform118player.score += 1000119object.flameAnim = FLAME_INACTIVE120object.animation = SLZEGGANI_DEFEATED121object.animationTimer = 0122object.state = SLZEGGMAN_EXPLODE123if stage.debugMode == false124if object.playerHit == false125// Grant the "Bombs Away" Achievement126CallNativeFunction2(SetAchievement, ACHIEVEMENT_BOMBSAWAY, 100)127end if128end if129else130object.animation = SLZEGGANI_HIT131object.animationTimer = 0132object.invincibilityTimer = 32133PlaySfx(SfxName[Boss Hit], false)134end if135end function136137138private function SLZEggman_DropSpikeBall139arrayPos0 = object.entityPos140temp1 = object.targetSeeSaw141temp1 >>= 1142GetTableValue(temp2, temp1, SLZEggman_seesawSlotOffsets)143arrayPos0 -= temp2144if object[arrayPos0].state == SEESAW_NO_ORB145if object[arrayPos0].stood == false146object.xpos = temp0147object[arrayPos0].state = SEESAW_ORB_LAUNCHED148object[arrayPos0].xvel = 0149object[arrayPos0].yvel = 0150object[arrayPos0].orbTargetPos.x = object.xpos151object[arrayPos0].orbTargetPos.y = object.ypos152object[arrayPos0].orbTargetPos.y += 0x200000153object[arrayPos0].orbTimer = 240154object[arrayPos0].orbFrame = 2155object[arrayPos0].animationTimer = 44156object.timer = 40157object.flameAnim = FLAME_INACTIVE158object.state++ // should move state into SLZEGGMAN_DROPPEDBALL159end if160end if161end function162163164private function SLZEggman_Oscillate165Sin256(temp0, object.oscillateAngle)166temp0 <<= 10167object.ypos += temp0168object.oscillateAngle += 2169object.oscillateAngle &= 0xFF170end function171172173// ========================174// Events175// ========================176177event ObjectUpdate178switch object.state179case SLZEGGMAN_AWAITPLAYER180if player[0].xpos >= object[-3].xpos181temp0 = object[-3].ixpos182temp0 -= screen.xcenter183stage.newXBoundary1 = temp0184temp0 = object[-3].ixpos185temp0 += screen.xcenter186stage.newXBoundary2 = temp0187if screen.yoffset == object.targetScreenPos.y188object.state++189object.priority = PRIORITY_ACTIVE190ResetObjectEntity(SLOT_MUSICEVENT_BOSS, TypeName[Music Event], MUSICEVENT_FADETOBOSS, 0, 0)191object[SLOT_MUSICEVENT_BOSS].priority = PRIORITY_ACTIVE192else193object.targetScreenPos.y = screen.yoffset194end if195end if196break197198case SLZEGGMAN_ENTEREGGMAN199object.xpos += object.xvel200temp0 = object[-3].xpos201temp0 += 0x800000202if object.xpos < temp0203object.state++204temp1 = screen.xcenter205temp1 -= 4206temp1 <<= 8207temp1 /= 160208temp1 *= -512209object.xvel = temp1210end if211object.ypos = object.originPos.y212CallFunction(SLZEggman_Oscillate)213break214215case SLZEGGMAN_MOVEANDDROP216object.xpos += object.xvel217if object.direction == FLIP_NONE218if object.xpos <= object.boundsL219object.xpos = object.boundsL220FlipSign(object.xvel)221object.direction ^= FLIP_X222else223GetTableValue(temp0, object.targetSeeSaw, SLZEggman_seesawDropPos)224if object.xpos <= temp0225CallFunction(SLZEggman_DropSpikeBall)226object.targetSeeSaw--227if object.targetSeeSaw < 0228object.targetSeeSaw = 1229end if230end if231object.targetSeeSaw &= 14232end if233else234if object.xpos >= object.boundsR235object.xpos = object.boundsR236FlipSign(object.xvel)237object.direction ^= FLIP_X238else239GetTableValue(temp0, object.targetSeeSaw, SLZEggman_seesawDropPos)240if object.xpos >= temp0241CallFunction(SLZEggman_DropSpikeBall)242object.targetSeeSaw++243if object.targetSeeSaw > 5244object.targetSeeSaw = 4245end if246end if247object.targetSeeSaw |= 1248end if249end if250object.ypos = object.originPos.y251CallFunction(SLZEggman_Oscillate)252break253254case SLZEGGMAN_DROPPEDBALL255object.timer--256if object.timer <= 0257object.flameAnim = FLAME_ACTIVE258object.state--259end if260break261262case SLZEGGMAN_EXPLODE263object.timer++264temp0 = object.timer265temp0 &= 7266if temp0 == 4267Rand(temp0, 96)268temp0 -= 48269temp0 <<= 16270temp0 += object.xpos271Rand(temp1, 48)272temp1 -= 24273temp1 <<= 16274temp1 += object.ypos275CreateTempObject(TypeName[Explosion], 0, temp0, temp1)276PlaySfx(SfxName[Explosion], false)277end if278279if object.timer == 180280object.animation = SLZEGGANI_TOASTED281object.animationTimer = 0282object.timer = 0283object.direction = FLIP_X284ResetObjectEntity(SLOT_MUSICEVENT_BOSS, TypeName[Music Event], MUSICEVENT_FADETOSTAGE, 0, 0)285object[SLOT_MUSICEVENT_BOSS].priority = PRIORITY_ACTIVE286object.state++287end if288break289290case SLZEGGMAN_DEFEATFALL291object.ypos += object.yvel292object.yvel += 0x1800293object.timer++294if object.timer == 38295object.yvel = 0296object.timer = 0297object.animationTimer = 0298object.state++299end if300break301302case SLZEGGMAN_DEFEATRISE303if object.timer < 48304object.ypos += object.yvel305object.yvel -= 0x800306object.timer++307else308object.timer = 0309object.yvel = 0310object.originPos.y = object.ypos311object.state++312end if313break314315case SLZEGGMAN_FLEE316object.ypos = object.originPos.y317CallFunction(SLZEggman_Oscillate)318if object.timer < 8319object.timer++320else321object.timer = 0322object.animation = SLZEGGANI_PANIC323object.animationTimer = 0324object.flameAnim = FLAME_EXPLODE325object.flameAnimTimer = 0326object.priority = PRIORITY_ACTIVE327temp0 = tileLayer[0].xsize328temp0 <<= 7329stage.newXBoundary2 = temp0330object.state++331end if332break333334case SLZEGGMAN_ESCAPE335object.xpos += 0x40000336object.originPos.y -= 0x4000337object.ypos = object.originPos.y338CallFunction(SLZEggman_Oscillate)339340if object.outOfBounds == true341object.type = TypeName[Blank Object]342object.priority = PRIORITY_BOUNDS343end if344break345346end switch347348if object.health != 0349if object.invincibilityTimer > 0350object.invincibilityTimer--351end if352353foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)354if object.invincibilityTimer == 0355CheckEqual(player[currentPlayer].animation, ANI_HURT)356temp0 = checkResult357CheckEqual(player[currentPlayer].animation, ANI_DYING)358temp0 |= checkResult359CheckEqual(player[currentPlayer].animation, ANI_DROWNING)360temp0 |= checkResult361if temp0 != false362if object.animation != SLZEGGANI_LAUGH363object.animation = SLZEGGANI_LAUGH364object.animationTimer = 0365end if366end if367368#platform: USE_STANDALONE369BoxCollisionTest(C_TOUCH, object.entityPos, -20, -16, 20, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)370#endplatform371#platform: USE_ORIGINS372BoxCollisionTest(C_TOUCH, object.entityPos, -20, -16, 20, 16, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)373#endplatform374if checkResult == true375CallFunction(Player_CheckHit)376if checkResult == true377object.playerHit = true // since we've hit Eggman ourselves instead of using a seesaw bomb, we're no longer eligible for the Bombs Away achievement..378CallFunction(SLZEggman_Hit)379end if380end if381end if382next383384if object.invincibilityTimer == 0385foreach (TypeName[SeeSaw], arrayPos0, ACTIVE_ENTITIES)386if object[arrayPos0].state != SEESAW_NO_ORB387temp0 = object[arrayPos0].xpos388temp1 = object[arrayPos0].ypos389object[arrayPos0].xpos = object[arrayPos0].orbTargetPos.x390object[arrayPos0].ypos = object[arrayPos0].orbTargetPos.y391BoxCollisionTest(C_TOUCH, object.entityPos, -20, -16, 20, 16, arrayPos0, -7, -7, 7, 7)392if checkResult == true393CallFunction(SLZEggman_Hit)394CreateTempObject(TypeName[Smoke Puff], 0, object[arrayPos0].orbTargetPos.x, object[arrayPos0].orbTargetPos.y)395PlaySfx(SfxName[Explosion], false)396object[arrayPos0].state = SEESAW_NO_ORB397object[arrayPos0].orbTimer = 0398end if399object[arrayPos0].xpos = temp0400object[arrayPos0].ypos = temp1401end if402next403end if404end if405406if object.state < SLZEGGMAN_ESCAPE407foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)408temp0 = player[currentPlayer].collisionRight409temp0 <<= 16410temp0 += player[currentPlayer].xpos411temp1 = stage.curXBoundary2412temp1 <<= 16413if temp0 > temp1414player[currentPlayer].xvel = 0415player[currentPlayer].speed = 0416player[currentPlayer].xpos = temp1417temp0 = player[currentPlayer].collisionRight418temp0 <<= 16419player[currentPlayer].xpos -= temp0420end if421next422end if423end event424425426event ObjectDraw427switch object.animation428case SLZEGGANI_INVISIBLE429break430431case SLZEGGANI_IDLE432temp0 = object.animationTimer433temp0 /= 6434object.animationTimer++435object.animationTimer %= 12436DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)437DrawSpriteFX(20, FX_FLIP, object.xpos, object.ypos)438break439440case SLZEGGANI_LAUGH441temp0 = object.animationTimer442temp0 %= 10443temp0 /= 5444temp0 += 9445object.animationTimer++446if object.animationTimer == 50447object.animationTimer = 0448if player[0].animation != ANI_DYING449object.animation = SLZEGGANI_IDLE450end if451end if452DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)453DrawSpriteFX(20, FX_FLIP, object.xpos, object.ypos)454break455456case SLZEGGANI_HIT457temp0 = object.animationTimer458temp0 &= 1459temp0 += 2460temp1 = temp0461temp1 += 17462object.animationTimer++463if object.animationTimer == 30464object.animationTimer = 0465object.animation = SLZEGGANI_IDLE466end if467DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)468DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)469break470471case SLZEGGANI_DEFEATED472temp0 = object.animationTimer473temp0 >>= 5474temp0 += 4475object.animationTimer++476object.animationTimer &= 63477DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)478DrawSpriteFX(20, FX_FLIP, object.xpos, object.ypos)479break480481case SLZEGGANI_TOASTED482DrawSpriteFX(6, FX_FLIP, object.xpos, object.ypos)483DrawSpriteFX(20, FX_FLIP, object.xpos, object.ypos)484break485486case SLZEGGANI_PANIC487temp0 = object.animationTimer488temp0 >>= 2489temp0 += 7490object.animationTimer++491object.animationTimer %= 7492DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)493DrawSpriteFX(20, FX_FLIP, object.xpos, object.ypos)494break495496end switch497498switch object.flameAnim499case FLAME_ACTIVE500temp0 = object.flameAnimTimer501temp0 >>= 2502temp0 += 11503object.flameAnimTimer++504object.flameAnimTimer &= 7505DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)506break507508case FLAME_EXPLODE509temp0 = object.flameAnimTimer510temp0 /= 3511temp0 += 11512object.flameAnimTimer++513if object.flameAnimTimer > 21514object.flameAnimTimer = 18515end if516DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)517break518519end switch520end event521522523event ObjectStartup524LoadSpriteSheet("Global/Eggman.gif")525SpriteFrame(-28, -32, 64, 56, 1, 1)526SpriteFrame(-28, -32, 64, 56, 66, 1)527SpriteFrame(-28, -32, 64, 56, 131, 1)528SpriteFrame(-28, -32, 64, 56, 1, 58)529SpriteFrame(-28, -32, 64, 56, 1, 1)530SpriteFrame(-28, -32, 64, 56, 1, 58)531SpriteFrame(-28, -32, 64, 56, 66, 58)532SpriteFrame(-28, -32, 64, 56, 131, 58)533SpriteFrame(-28, -32, 64, 56, 66, 1)534SpriteFrame(-28, -32, 64, 56, 1, 115)535SpriteFrame(-28, -32, 64, 56, 66, 115)536SpriteFrame(34, 1, 10, 9, 196, 2)537SpriteFrame(33, 0, 15, 11, 196, 12)538SpriteFrame(34, -1, 22, 14, 213, 1)539SpriteFrame(34, -8, 32, 26, 213, 16)540SpriteFrame(34, -1, 22, 14, 213, 1)541SpriteFrame(34, -8, 32, 26, 213, 16)542SpriteFrame(34, 1, 10, 9, 196, 2)543SpriteFrame(33, 0, 15, 11, 196, 12)544SpriteFrame(-12, 17, 24, 16, 213, 135)545SpriteFrame(-12, 17, 24, 16, 213, 43)546547foreach (TypeName[Eggman], arrayPos0, ALL_ENTITIES)548if object[arrayPos0].type == TypeName[Eggman]549object[arrayPos0].priority = PRIORITY_XBOUNDS550arrayPos1 = arrayPos0551arrayPos1 -= 3552object[arrayPos0].xpos = object[arrayPos1].xpos553object[arrayPos0].xpos += 0xE80000554object[arrayPos0].ypos = object[arrayPos1].ypos555object[arrayPos0].ypos -= 0xAC0000556557temp1 = screen.xcenter558temp0 -= 4559temp1 <<= 8560temp1 /= 160561temp1 *= -256562object[arrayPos0].xvel = temp1563564object[arrayPos0].targetSeeSaw = 4565object[arrayPos0].originPos.x = object[arrayPos0].xpos566object[arrayPos0].originPos.y = object[arrayPos0].ypos567object[arrayPos0].animation = SLZEGGANI_IDLE568569#platform: USE_ORIGINS570if game.bossOneLife == false571object[arrayPos0].health = 8572else573object[arrayPos0].health = 1574end if575#endplatform576#platform: USE_STANDALONE577object[arrayPos0].health = 8578#endplatform579580temp0 = screen.xcenter581temp0 -= 160 // xcenter if screen width was 320 like the original game582temp0 -= 4583if temp0 < 0584temp0 = 0585end if586temp0 <<= 16587object[arrayPos0].xpos += temp0588temp0 += 0x980000589590object[arrayPos0].boundsL = object[arrayPos1].xpos591object[arrayPos0].boundsL -= temp0592object[arrayPos0].boundsR = object[arrayPos1].xpos593object[arrayPos0].boundsR += temp0594595temp0 -= 0x980000596temp1 = object[arrayPos1].xpos597temp1 -= 0x280000598SetTableValue(temp1, 2, SLZEggman_seesawDropPos)599temp1 += 0x500000600SetTableValue(temp1, 3, SLZEggman_seesawDropPos)601arrayPos1++602603object[arrayPos1].xpos -= temp0604temp1 = object[arrayPos1].xpos605temp1 -= 0x280000606SetTableValue(temp1, 0, SLZEggman_seesawDropPos)607temp1 += 0x500000608SetTableValue(temp1, 1, SLZEggman_seesawDropPos)609arrayPos1++610611object[arrayPos1].xpos += temp0612temp1 = object[arrayPos1].xpos613temp1 -= 0x280000614SetTableValue(temp1, 4, SLZEggman_seesawDropPos)615temp1 += 0x500000616SetTableValue(temp1, 5, SLZEggman_seesawDropPos)617618object[arrayPos0].flameAnim = FLAME_ACTIVE619end if620next621end event622623624// ========================625// Editor Events626// ========================627628event RSDKDraw629DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)630DrawSpriteFX(1, FX_FLIP, object.xpos, object.ypos)631end event632633634event RSDKLoad635LoadSpriteSheet("Global/Eggman.gif")636SpriteFrame(-28, -32, 64, 56, 1, 1)637SpriteFrame(-12, 17, 24, 16, 213, 43)638639SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")640end event641642643