Path: blob/master/Sonic 1/Scripts/SBZ/FZEggman.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: FZ Eggman 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.invincibilityTimer13private alias object.value2 : object.health // health counts up instead of down this time...14private alias object.value3 : object.boundsR15private alias object.value4 : object.isVulnerable16private alias object.value5 : object.floorPos1718// Piston aliases19private alias object.value0 : fzPiston.fzEggmanSlot20private alias object.propertyValue : fzPiston.hasEggman2122// Piston States23private alias 0 : FZPISTON_IDLE24private alias 1 : FZPISTON_SETUP_CRUSHING2526// Plasma Emitter Aliases27private alias object.xpos : plasmaEmitter.xpos28private alias object.ypos : plasmaEmitter.ypos29private alias object.state : plasmaEmitter.emitting30private alias object.value0 : plasmaEmitter.timer3132// Plasma Ball Aliases33private alias object.value1 : plasmaBall.targetPos.x3435// EggMobile aliases36private alias object.xpos : eggmobile.xpos37private alias object.ypos : eggmobile.ypos38private alias object.state : eggmobile.state39private alias object.value6 : eggmobile.playerStopPos4041// Eggman States42private alias 0 : FZEGGMAN_AWAITPLAYER43private alias 1 : FZEGGMAN_STARTFIGHT44private alias 2 : FZEGGMAN_SETUP_PISTONATTACK45private alias 3 : FZEGGMAN_PISTONATTACK46private alias 4 : FZEGGMAN_SETUP_PLASMAATTACK47private alias 5 : FZEGGMAN_PLASMAATTACK48private alias 6 : FZEGGMAN_FLEE49private alias 7 : FZEGGMAN_RUNNINGAWAY50private alias 8 : FZEGGMAN_JUMPED5152// Eggman Animations53private alias 0 : FZEGGANI_INVISIBLE54private alias 1 : FZEGGANI_IDLE55private alias 2 : FZEGGANI_LAUGH56private alias 3 : FZEGGANI_HIT57private alias 4 : FZEGGANI_DEFEATED58private alias 5 : FZEGGANI_TOASTED5960// Player Aliases61private alias object.state : player.state62private alias object.xpos : player.xpos63private alias object.xvel : player.xvel64private alias object.speed : player.speed65private alias object.animation : player.animation66private alias object.collisionRight : player.collisionRight67private alias object.value16 : player.isSidekick68private alias object.value40 : player.hitboxLeft69private alias object.value38 : player.hitboxTop70private alias object.value41 : player.hitboxRight71private alias object.value39 : player.hitboxBottom7273// Path ID Aliases74private alias 0 : PATH_A757677// ========================78// Function Declarations79// ========================8081reserve function FZEggman_CheckBossHit8283// ========================84// Tables85// ========================8687private table FZEggman_destroyFrameTable888, 4, 9, 489end table9091// in pairs of 292// so entities +1 & +2 would go, then +2 & +3, etc etc93private table FZEggman_pistonAttackSlots941, 2952, 3963, 4974, 198end table99100101// ========================102// Function Definitions103// ========================104105private function FZEggman_CheckBossHit106CheckEqual(player[currentPlayer].animation, ANI_JUMPING)107temp0 = checkResult108CheckEqual(player[currentPlayer].animation, ANI_GLIDING)109temp0 |= checkResult110CheckEqual(player[currentPlayer].animation, ANI_GLIDING_STOP)111temp0 |= checkResult112#platform: USE_ORIGINS113if stage.playerListPos == PLAYER_AMY114if player[currentPlayer].isSidekick == false115CheckEqual(player[currentPlayer].animation, ANI_HAMMER_JUMP)116temp0 |= checkResult117CheckEqual(player[currentPlayer].animation, ANI_HAMMER_DASH)118temp0 |= checkResult119end if120end if121#endplatform122123if temp0 == true124player[currentPlayer].xvel = 0x30000125if player[currentPlayer].xpos < object.xpos126FlipSign(player[currentPlayer].xvel)127end if128129player[currentPlayer].speed = player[currentPlayer].xvel130if player[currentPlayer].animation == ANI_GLIDING131player[currentPlayer].animation = ANI_GLIDING_DROP132player[currentPlayer].state = Player_State_GlideDrop133end if134checkResult = true135else136checkResult = false137end if138end function139140141// ========================142// Events143// ========================144145event ObjectUpdate146switch object.state147case FZEGGMAN_AWAITPLAYER148temp1 = screen.xcenter149temp2 = temp1150if temp1 == 160151temp1 += 16152end if153154temp0 = object.ixpos155temp0 -= temp1156stage.newXBoundary1 = temp0157temp0 += temp1158temp0 += temp2159stage.newXBoundary2 = temp0160temp0 = object.entityPos161fzPiston[+1].fzEggmanSlot = temp0162fzPiston[+2].fzEggmanSlot = temp0163fzPiston[+3].fzEggmanSlot = temp0164fzPiston[+4].fzEggmanSlot = temp0165object.boundsR = object.ixpos166object.boundsR += 656167object.floorPos = object.ypos168object.floorPos -= 0x400000169object.state++170break171172case FZEGGMAN_STARTFIGHT173if player[0].xpos >= object.xpos174object.xpos = 0175object.ypos = 0176object.isVulnerable = true177object.state++178end if179break180181case FZEGGMAN_SETUP_PISTONATTACK182object.animation = FZEGGANI_IDLE183Rand(temp0, 8)184temp1 = temp0185temp1 &= 1186temp0 &= 6187GetTableValue(temp2, temp0, FZEggman_pistonAttackSlots)188temp0++189GetTableValue(temp3, temp0, FZEggman_pistonAttackSlots)190191arrayPos0 = object.entityPos192arrayPos0 += temp2193object[arrayPos0].state = FZPISTON_SETUP_CRUSHING194if temp1 == 0195fzPiston[arrayPos0].hasEggman = true196end if197198arrayPos0 = object.entityPos199arrayPos0 += temp3200object[arrayPos0].state = FZPISTON_SETUP_CRUSHING201if temp1 == 1202fzPiston[arrayPos0].hasEggman = true203end if204205PlaySfx(SfxName[Large Wall], false)206object.timer = 160207object.state++208break209210case FZEGGMAN_PISTONATTACK211object.timer--212if object.timer <= 0213if object.health == 8214temp1 = screen.xcenter215temp0 = object.boundsR216temp0 -= temp1217stage.newXBoundary1 = temp0218temp0 += temp1219temp0 += temp1220stage.newXBoundary2 = temp0221object.xpos = plasmaEmitter[+5].xpos222object.xpos += 0x380000223object.ypos = plasmaEmitter[+5].ypos224eggmobile[+7].playerStopPos = object.boundsR225eggmobile[+7].playerStopPos <<= 16226object.direction = FLIP_X227arrayPos0 = object.entityPos228arrayPos0 += 5229ResetObjectEntity(arrayPos0, TypeName[Explosion], 0, object[arrayPos0].xpos, object[arrayPos0].ypos)230object.isVulnerable = false // you can't underflow the value if it counts up AND you disable attacks :bigthinker:231object.animation = FZEGGANI_TOASTED232object.state = FZEGGMAN_FLEE233else234object.state++235end if236end if237break238239case FZEGGMAN_SETUP_PLASMAATTACK240plasmaEmitter[+5].emitting = true241plasmaEmitter[+5].timer = 330242243temp0 = 0244temp1 = 0245while temp0 < 4246CreateTempObject(TypeName[Plasma Ball], 0, plasmaEmitter[+5].xpos, plasmaEmitter[+5].ypos)247object[tempObjectPos].inkEffect = INK_ADD248object[tempObjectPos].alpha = 0x00249plasmaBall[tempObjectPos].targetPos.x = 4250temp0++251plasmaBall[tempObjectPos].targetPos.x = temp1252plasmaBall[tempObjectPos].targetPos.x += plasmaEmitter[+5].xpos253plasmaBall[tempObjectPos].targetPos.x -= 0x100000254Rand(temp2, 32)255temp2 -= 16256temp2 <<= 16257plasmaBall[tempObjectPos].targetPos.x += temp2258temp1 -= 0x4F0000259loop260261object.timer = 330262object.state++263break264265case FZEGGMAN_PLASMAATTACK266object.timer--267if object.timer <= 0268object.state = FZEGGMAN_SETUP_PISTONATTACK269end if270break271272case FZEGGMAN_FLEE273object.ypos += object.yvel274object.yvel += 0x1000275276if object.ypos >= object.floorPos277ObjectTileCollision(CSIDE_FLOOR, 0, 28, PATH_A)278if checkResult == true279object.animation = FZEGGANI_INVISIBLE280object.xvel = 0x10000281object.yvel = -0x10000282object.timer = 0283object.animation = FZEGGANI_TOASTED284object.state++285end if286end if287break288289case FZEGGMAN_RUNNINGAWAY290object.xpos += object.xvel291object.ypos += object.yvel292ObjectTileCollision(CSIDE_FLOOR, 0, 28, PATH_A)293if checkResult == false294object.yvel += 0x1000295else296object.yvel = 0297end if298299temp1 = 0300foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)301if player[currentPlayer].xpos > temp1302temp1 = player[currentPlayer].xpos303end if304next305306// fun code307temp0 = object.xpos308temp0 -= temp1309if temp0 < 0310object.xvel = 0x50000311else312object.xvel = 0x40000313temp0 -= 0x700000314if temp0 >= 0315object.xvel -= 0x10000316temp0 -= 0x80000317if temp0 >= 0318object.xvel -= 0x10000319temp0 -= 0x80000320if temp0 >= 0321object.xvel -= 0x8000322temp0 -= 0x80000323if temp0 >= 0324object.xvel -= 0x8000325temp0 -= 0x80000326if temp0 >= 0327object.xvel -= 0x8000328temp0 -= 0x380000329if temp0 >= 0330object.xvel = 0331end if332end if333end if334end if335end if336end if337end if338339temp0 = eggmobile[+7].xpos340temp0 -= 0x300000341if object.xpos >= temp0342object.xvel = 0x24000343object.yvel = -0x4C000344object.state++345end if346break347348case FZEGGMAN_JUMPED349object.xpos += object.xvel350object.ypos += object.yvel351object.yvel += 0x3400352353if object.xpos >= eggmobile[+7].xpos354object.xpos = eggmobile[+7].xpos355object.xvel = 0356end if357358if object.yvel > 0359if object.ypos >= eggmobile[+7].ypos360object.ypos = eggmobile[+7].ypos361object.yvel = 0362eggmobile[+7].state++363object.type = TypeName[Blank Object]364end if365end if366break367368end switch369370switch object.animation371case FZEGGANI_INVISIBLE372object.frame = 0373break374375case FZEGGANI_IDLE376object.animationTimer++377if object.animationTimer == 14378object.animationTimer = 0379end if380object.frame = object.animationTimer381object.frame /= 7382object.frame++383break384385case FZEGGANI_LAUGH386if object.yvel == 0387object.frame = 3388else389object.frame = 4390end if391break392393case FZEGGANI_HIT394object.frame = object.invincibilityTimer395object.frame &= 1396object.frame += 5397break398399case FZEGGANI_DEFEATED400object.frame = 7401break402403case FZEGGANI_TOASTED404object.timer++405if object.timer >= 28406object.timer = 0407end if408temp0 = object.timer409temp0 /= 7410GetTableValue(object.frame, temp0, FZEggman_destroyFrameTable)411break412413end switch414415if object.invincibilityTimer != 0416object.invincibilityTimer--417end if418419if object.isVulnerable == true420if player[0].xpos < object.xpos421object.direction = FLIP_NONE422else423object.direction = FLIP_X424end if425426foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)427#platform: USE_STANDALONE428BoxCollisionTest(C_TOUCH, object.entityPos, -33, -37, 33, 6, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)429#endplatform430#platform: USE_ORIGINS431BoxCollisionTest(C_TOUCH, object.entityPos, -33, -37, 33, 6, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)432#endplatform433if checkResult == true434CallFunction(FZEggman_CheckBossHit)435if checkResult == true436if object.invincibilityTimer == 0437if object.health < 8438object.animation = FZEGGANI_HIT439object.invincibilityTimer = 100440PlaySfx(SfxName[Boss Hit], false)441#platform: USE_STANDALONE442object.health++443#endplatform444#platform: USE_ORIGINS445if game.bossOneLife == false446object.health++447else448object.health = 8449end if450451if object.health == 8452// Nothing. There's literally nothing here LMAO453end if454#endplatform455end if456end if457end if458end if459next460end if461462// Handle Stage right boundary463// -> This doesn't do anything most of the time, since there's already the wall on the right of the arena464foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)465temp0 = player[currentPlayer].collisionRight466temp0 <<= 16467temp0 += player[currentPlayer].xpos468temp1 = stage.curXBoundary2469temp1 <<= 16470if temp0 > temp1471player[currentPlayer].xvel = 0472player[currentPlayer].speed = 0473player[currentPlayer].xpos = temp1474temp0 = player[currentPlayer].collisionRight475temp0 <<= 16476player[currentPlayer].xpos -= temp0477end if478next479end event480481482event ObjectDraw483if object.state >= FZEGGMAN_PISTONATTACK484DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)485end if486end event487488489event ObjectStartup490LoadSpriteSheet("SBZ/Objects.gif")491SpriteFrame(-22, -23, 38, 51, 1, 209)492SpriteFrame(-22, -24, 38, 52, 42, 208)493SpriteFrame(-22, -23, 38, 51, 84, 209)494SpriteFrame(-16, -16, 46, 44, 350, 165)495SpriteFrame(-16, -23, 46, 55, 350, 210)496SpriteFrame(-22, -24, 42, 52, 225, 266)497SpriteFrame(-22, -32, 42, 64, 225, 319)498SpriteFrame(-30, -24, 60, 44, 289, 165)499SpriteFrame(-24, -23, 54, 43, 236, 221)500SpriteFrame(-21, -25, 51, 52, 296, 213)501502foreach (TypeName[FZ Eggman], arrayPos0, ALL_ENTITIES)503object[arrayPos0].priority = PRIORITY_ACTIVE504505// Normally boss health would be set here, as with other bosses, but this boss's health counts up rather that counting down506next507end event508509510// ========================511// Editor Events512// ========================513514event RSDKDraw515DrawSprite(0)516end event517518519event RSDKLoad520LoadSpriteSheet("SBZ/Objects.gif")521SpriteFrame(-22, -23, 38, 51, 1, 209)522523SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")524end event525526527