Path: blob/master/Sonic 1/Scripts/SBZ/Eggmobile.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Eggmobile Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.legAnim12private alias object.value1 : object.legAnimTimer13private alias object.value2 : object.flameAnim14private alias object.value3 : object.flameAnimTimer15private alias object.value4 : object.timer16private alias object.value5 : object.explosionTimer17private alias object.value6 : object.playerStopPos18private alias object.value7 : object.fadeTimer1920private alias 0 : EGGMOBILE_WAITING21private alias 1 : EGGMOBILE_ACTIVATE22private alias 2 : EGGMOBILE_RISE23private alias 3 : EGGMOBILE_FLEE24private alias 4 : EGGMOBILE_HIT25private alias 5 : EGGMOBILE_SEAT26private alias 5 : EGGMOBILE_BOSSRUSH2728private alias 0 : EGGMOBILE_ANI_IDLE29private alias 1 : EGGMOBILE_ANI_SEAT30private alias 2 : EGGMOBILE_ANI_FLYING31private alias 3 : EGGMOBILE_ANI_WASHIT3233private alias 0 : LEGS_IDLE34private alias 1 : LEGS_RETRACT35private alias 2 : LEGS_NONE3637private alias 0 : FLAME_INACTIVE38private alias 1 : FLAME_ACTIVE3940// Player Aliases41private alias object.state : player.state42private alias object.xpos : player.xpos43private alias object.xvel : player.xvel44private alias object.yvel : player.yvel45private alias object.speed : player.speed46private alias object.direction : player.direction47private alias object.gravity : player.gravity48private alias object.animation : player.animation49private alias object.controlMode : player.controlMode50private alias object.value40 : player.hitboxLeft51private alias object.value38 : player.hitboxTop52private alias object.value41 : player.hitboxRight53private alias object.value39 : player.hitboxBottom5455// Game Modes56private alias 0 : MODE_NOSAVE57private alias 1 : MODE_SAVEGAME58private alias 2 : MODE_TIMEATTACK5960// Tracks61private alias 1 : TRACK_ACTFINISH6263// Reserved Object Slot Aliases64private alias 30 : SLOT_ACTFINISH6566// Achievement Aliases67private alias 10 : ACHIEVEMENT_ONEFORTHEROAD686970// ========================71// Events72// ========================7374event ObjectUpdate75switch object.state76case EGGMOBILE_WAITING77foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)78BoxCollisionTest(C_SOLID, object.entityPos, -24, -96, 24, 96, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)79next80break8182case EGGMOBILE_ACTIVATE83object.priority = PRIORITY_ACTIVE84object.animation = EGGMOBILE_ANI_FLYING85object.legAnim = LEGS_RETRACT86object.yvel = -0x1800087object.state++88break8990case EGGMOBILE_RISE91object.ypos += object.yvel92object.timer++93if object.timer >= 5294object.flameAnim = FLAME_ACTIVE95object.xvel = 0x1800096object.yvel = -0x180097object.state++98end if99break100101case EGGMOBILE_HIT102object.explosionTimer++103temp0 = object.explosionTimer104temp0 &= 7105if temp0 == 4106Rand(temp0, 96)107temp0 -= 48108temp0 <<= 16109temp0 += object.xpos110Rand(temp1, 48)111temp1 -= 24112temp1 <<= 16113temp1 += object.ypos114CreateTempObject(TypeName[Explosion], 0, temp0, temp1)115object[tempObjectPos].drawOrder = 4116if object.fadeTimer < 256117PlaySfx(SfxName[Explosion], false)118end if119end if120121if object.fadeTimer < 256122object.timer++123if object.timer >= 30124PlaySfx(SfxName[Boss Hit], false)125object.yvel = 0x6000126object.timer = 0127end if128end if129// [Fall-through]130case EGGMOBILE_FLEE131object.xpos += object.xvel132object.ypos += object.yvel133temp0 = stage.newXBoundary2134temp0 += 212 // (screen.xcenter with the standard screen width of 424)135temp0 <<= 16136if object.xpos >= temp0137#platform: USE_ORIGINS138CheckNotEqual(options.gameMode, MODE_TIMEATTACK)139temp0 = checkResult140CheckEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)141temp0 &= checkResult142if temp0 != 0143CallNativeFunction2(NotifyCallback, NOTIFY_KILL_BOSS, 0)144CallNativeFunction2(NotifyCallback, NOTIFY_BOSS_END, true)145StopMusic()146object.state = EGGMOBILE_BOSSRUSH147object.fadeTimer = 0148else149#endplatform150#platform: USE_STANDALONE151if options.gameMode == MODE_TIMEATTACK152#endplatform153#platform: USE_ORIGINS154CheckEqual(options.gameMode, MODE_TIMEATTACK)155temp0 = checkResult156CheckNotEqual(game.oneStageFlag, false)157temp0 |= checkResult158if temp0 != false159#endplatform160object.type = TypeName[Blank Object]161ResetObjectEntity(SLOT_ACTFINISH, TypeName[Act Finish], 0, 0, 0)162object[SLOT_ACTFINISH].drawOrder = 6163object[SLOT_ACTFINISH].priority = PRIORITY_ACTIVE164stage.timeEnabled = false165PlayMusic(TRACK_ACTFINISH)166else167object.fadeTimer += 4168music.volume -= 2169SetScreenFade(0, 0, 0, object.fadeTimer)170if object.fadeTimer == 384171172#platform: USE_ORIGINS173// This variable isn't used anywhere in Final Zone, perhaps a scrapped achievement?174temp0 = StageStatsUsabilityParam5175temp0 &= 1176temp1 = StageStatsUsabilityParam5177temp1 &= 2178temp2 = StageStatsUsabilityParam5179temp2 &= 4180181CallNativeFunction4(NotifyCallback, NOTIFY_STATS_CHARA_ACTION, temp0, temp1, temp2)182CallNativeFunction2(NotifyCallback, NOTIFY_ACT_FINISH, 0)183184StageStatsUsabilityParam1 = 0185StageStatsUsabilityParam2 = 0186StageStatsUsabilityParam3 = 0187StageStatsUsabilityParam4 = 0188StageStatsUsabilityParam5 = 0189StatsUsabilityParam1 = 0190StatsUsabilityParam2 = 0191StatsUsabilityParam3 = 0192StatsUsabilityParam4 = 0193StatsUsabilityParam5 = 0194#endplatform195196if stage.debugMode == false197if options.stageSelectFlag == false198CallNativeFunction2(SetLeaderboard, 19, player.score)199end if200end if201202if options.gameMode == MODE_SAVEGAME203arrayPos1 = options.saveSlot204arrayPos1 <<= 3205arrayPos1 += 4206saveRAM[arrayPos1] = 20207WriteSaveRAM()208end if209210stage.activeList = PRESENTATION_STAGE211stage.listPos = 1212LoadStage()213end if214end if215#platform: USE_ORIGINS216end if217#endplatform218end if219220foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)221if player[currentPlayer].xpos >= object.playerStopPos222CheckEqual(player[currentPlayer].state, Player_State_Ground)223temp0 = checkResult224#platform: USE_ORIGINS225CheckEqual(player[currentPlayer].state, Player_State_Air_NoDropDash)226temp0 |= checkResult227#endplatform228CheckEqual(player[currentPlayer].state, Player_State_Air)229temp0 |= checkResult230CheckEqual(player[currentPlayer].state, Player_State_Fly)231temp0 |= checkResult232CheckEqual(player[currentPlayer].state, Player_State_GlideRight)233temp0 |= checkResult234CheckEqual(player[currentPlayer].state, Player_State_Roll)235temp0 |= checkResult236CheckEqual(player[currentPlayer].state, Player_State_RollJump)237temp0 |= checkResult238CheckEqual(player[currentPlayer].state, Player_State_Static)239temp0 |= checkResult240CheckEqual(player[currentPlayer].state, Player_State_Spindash)241temp0 |= checkResult242243if temp0 == true244player[currentPlayer].state = Player_State_Static245player[currentPlayer].direction = FACING_RIGHT246player[currentPlayer].controlMode = CONTROLMODE_NONE247if player[currentPlayer].gravity == 0248player[currentPlayer].xvel = 0249player[currentPlayer].speed = 0250if object.state == EGGMOBILE_FLEE251player[currentPlayer].animation = ANI_LOOKINGUP252else253player[currentPlayer].animation = ANI_STOPPED254end if255else256player[currentPlayer].speed = player[currentPlayer].xvel257player[currentPlayer].yvel += 0x3800258end if259else260if player[currentPlayer].state == Player_State_GlideSlide261player[currentPlayer].speed = 0262end if263end if264end if265next266break267268case EGGMOBILE_SEAT269// position == eggmobile.position270object.xpos = object[+10].xpos271object.ypos = object[+10].ypos272if object[+1].type == TypeName[Blank Object]273object.type = TypeName[Blank Object]274end if275break276277end switch278279if object.state == EGGMOBILE_FLEE280foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)281#platform: USE_STANDALONE282BoxCollisionTest(C_TOUCH, object.entityPos, -20, -16, 20, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)283#endplatform284#platform: USE_ORIGINS285BoxCollisionTest(C_TOUCH, object.entityPos, -20, -16, 20, 16, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)286#endplatform287288if checkResult == true289CallFunction(Player_CheckHit)290if checkResult == true291object.state = EGGMOBILE_HIT292object.animation = EGGMOBILE_ANI_WASHIT293PlaySfx(SfxName[Boss Hit], false)294object.timer = 0295if stage.debugMode == false296if currentPlayer == 0297// Grant the "One For the Road" Achievement298CallNativeFunction2(SetAchievement, ACHIEVEMENT_ONEFORTHEROAD, 100)299end if300end if301end if302end if303next304end if305end event306307308event ObjectDraw309switch object.animation310case EGGMOBILE_ANI_IDLE311DrawSpriteFX(16, FX_FLIP, object.xpos, object.ypos)312DrawSpriteFX(17, FX_FLIP, object.xpos, object.ypos)313break314315case EGGMOBILE_ANI_SEAT316DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)317break318319case EGGMOBILE_ANI_FLYING320temp0 = object.animationTimer321temp0 >>= 2322temp0 += 1323object.animationTimer++324object.animationTimer &= 7325DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)326break327328case EGGMOBILE_ANI_WASHIT329temp0 = object.animationTimer330temp0 >>= 2331temp0 += 3332object.animationTimer++333object.animationTimer &= 7334DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)335break336337end switch338339switch object.legAnim340case LEGS_IDLE341DrawSpriteFX(5, FX_FLIP, object.xpos, object.ypos)342break343344case LEGS_RETRACT345object.legAnimTimer++346if object.legAnimTimer >= 60347object.legAnim = LEGS_NONE348else349temp0 = object.legAnimTimer350temp0 /= 20351temp0 += 5352DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)353end if354break355356case LEGS_NONE357break358359end switch360361if object.flameAnim != FLAME_INACTIVE362temp0 = object.flameAnimTimer363temp0 /= 3364temp0 += 8365object.flameAnimTimer++366if object.flameAnimTimer > 21367object.flameAnimTimer = 18368end if369DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)370end if371end event372373374event ObjectStartup375LoadSpriteSheet("Global/Eggman.gif")376SpriteFrame(-28, -32, 64, 21, 131, 172)377SpriteFrame(-28, -32, 64, 56, 131, 58)378SpriteFrame(-28, -32, 64, 56, 66, 1)379SpriteFrame(-28, -32, 64, 56, 1, 172)380SpriteFrame(-28, -32, 64, 56, 66, 172)381SpriteFrame(-20, 16, 40, 21, 131, 115)382SpriteFrame(-20, 8, 48, 19, 172, 115)383SpriteFrame(-20, 8, 40, 16, 172, 135)384SpriteFrame(34, 1, 10, 9, 196, 2)385SpriteFrame(33, 0, 15, 11, 196, 12)386SpriteFrame(34, -1, 22, 14, 213, 1)387SpriteFrame(34, -8, 32, 26, 213, 16)388SpriteFrame(34, -1, 22, 14, 213, 1)389SpriteFrame(34, -8, 32, 26, 213, 16)390SpriteFrame(34, 1, 10, 9, 196, 2)391SpriteFrame(33, 0, 15, 11, 196, 12)392SpriteFrame(-28, -32, 27, 21, 131, 172)393SpriteFrame(-28, -11, 64, 35, 131, 193)394395foreach (TypeName[Eggmobile], arrayPos0, ALL_ENTITIES)396object[arrayPos0].direction = FACING_LEFT397if object[arrayPos0].propertyValue == 1398object[arrayPos0].state = EGGMOBILE_SEAT399object[arrayPos0].animation = EGGMOBILE_ANI_SEAT400object[arrayPos0].legAnim = LEGS_NONE401end if402next403end event404405406// ========================407// Editor Events408// ========================409410event RSDKEdit411if editor.returnVariable == true412switch editor.variableID413case EDIT_VAR_PROPVAL // property value414checkResult = object.propertyValue415break416417case 0 // type418checkResult = object.propertyValue419break420421end switch422else423switch editor.variableID424case EDIT_VAR_PROPVAL // property value425object.propertyValue = editor.variableValue426break427428case 0 // type429object.propertyValue = editor.variableValue430break431432end switch433end if434end event435436437event RSDKDraw438object.direction = FACING_LEFT439440if object.propertyValue == 1441DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)442else443DrawSpriteFX(16, FX_FLIP, object.xpos, object.ypos)444DrawSpriteFX(17, FX_FLIP, object.xpos, object.ypos)445end if446end event447448449event RSDKLoad450LoadSpriteSheet("Global/Eggman.gif")451SpriteFrame(-28, -32, 64, 21, 131, 172)452SpriteFrame(-28, -32, 64, 56, 131, 58)453SpriteFrame(-28, -32, 64, 56, 66, 1)454SpriteFrame(-28, -32, 64, 56, 1, 172)455SpriteFrame(-28, -32, 64, 56, 66, 172)456SpriteFrame(-20, 16, 40, 21, 131, 115)457SpriteFrame(-20, 8, 48, 19, 172, 115)458SpriteFrame(-20, 8, 40, 16, 172, 135)459SpriteFrame(34, 1, 10, 9, 196, 2)460SpriteFrame(33, 0, 15, 11, 196, 12)461SpriteFrame(34, -1, 22, 14, 213, 1)462SpriteFrame(34, -8, 32, 26, 213, 16)463SpriteFrame(34, -1, 22, 14, 213, 1)464SpriteFrame(34, -8, 32, 26, 213, 16)465SpriteFrame(34, 1, 10, 9, 196, 2)466SpriteFrame(33, 0, 15, 11, 196, 12)467SpriteFrame(-28, -32, 27, 21, 131, 172)468SpriteFrame(-28, -11, 64, 35, 131, 193)469470AddEditorVariable("type")471SetActiveVariable("type")472AddEnumVariable("EggMobile", 0)473AddEnumVariable("Seat", 1)474end event475476477