Path: blob/master/SonicMania/Objects/AIZ/AIZSetup.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: AIZSetup Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectAIZSetup *AIZSetup;1011void AIZSetup_Update(void) {}1213void AIZSetup_LateUpdate(void) {}1415void AIZSetup_StaticUpdate(void)16{17#if MANIA_USE_PLUS18if (Zone->actID != 3 && !AIZSetup->hasSetupCutscene) {19#else20if (!AIZSetup->hasSetupCutscene) {21#endif22AIZSetup_SetupObjects();23AIZSetup_GetCutsceneSetupPtr();24AIZSetup->hasSetupCutscene = true;25}2627#if MANIA_USE_PLUS28if (AIZSetup->background4) {29#endif30if (ScreenInfo->position.x <= 4096)31AIZSetup->background2->scrollPos = 0;32else33AIZSetup->background2->scrollPos = 0x1000000;3435if (ScreenInfo->position.x <= 8704) {36AIZSetup->background2->drawGroup[0] = 0;37AIZSetup->background3->drawGroup[0] = DRAWGROUP_COUNT;38}39else {40AIZSetup->background2->drawGroup[0] = DRAWGROUP_COUNT;41AIZSetup->background3->drawGroup[0] = 0;42}43#if MANIA_USE_PLUS44}45else {46if (!(Zone->timer & 3)) {47++RSDK.GetTileLayer(0)->deformationOffsetW;48}4950if (!(Zone->timer & 1)) {51for (int32 i = Zone->fgLayer[0]; i <= Zone->fgLayer[1]; ++i) {52RSDK.GetTileLayer(i)->deformationOffsetW++;53}54}55}56#endif5758if (!(Zone->timer % 5)) {59RSDK.RotatePalette(0, 171, 174, true);60#if MANIA_USE_PLUS61RSDK.RotatePalette(1, 171, 174, true);62CutsceneHBH->paletteColors[43] = RSDK.GetPaletteEntry(0, 171);63CutsceneHBH->paletteColors[44] = RSDK.GetPaletteEntry(0, 172);64CutsceneHBH->paletteColors[45] = RSDK.GetPaletteEntry(0, 173);65CutsceneHBH->paletteColors[46] = RSDK.GetPaletteEntry(0, 174);66#endif67}6869if (!AIZSetup->playDrillSfx || RSDK_GET_ENTITY(SLOT_PAUSEMENU, PauseMenu)->classID == PauseMenu->classID) {70if (AIZSetup->playingDrillSfx) {71RSDK.StopSfx(AIZSetup->sfxDrill);72AIZSetup->playingDrillSfx = false;73}74}75else if (!AIZSetup->playingDrillSfx) {76RSDK.PlaySfx(AIZSetup->sfxDrill, 1, 255);77AIZSetup->playingDrillSfx = true;78}7980#if MANIA_USE_PLUS81--AIZSetup->bellPlantAniTimer;82if (AIZSetup->bellPlantAniTimer < 0) {83++AIZSetup->bellPlantAniFrame;84if (AIZSetup->bellPlantAniFramePos[AIZSetup->bellPlantAniFrame] == -1)85AIZSetup->bellPlantAniFrame = 0;8687AIZSetup->bellPlantAniTimer = AIZSetup->bellPlantAniDurations[AIZSetup->bellPlantAniFrame];88RSDK.DrawAniTiles(AIZSetup->aniTiles, 196, 16 * AIZSetup->bellPlantAniFramePos[AIZSetup->bellPlantAniFrame], 0, 16, 32);89}9091--AIZSetup->curlPlant1AniTimer;92if (AIZSetup->curlPlant1AniTimer < 0) {93++AIZSetup->curlPlant1AniFrame;94if (AIZSetup->curlPlant1AniFramePos[AIZSetup->curlPlant1AniFrame] == -1)95AIZSetup->curlPlant1AniFrame = 0;9697AIZSetup->curlPlant1AniTimer = AIZSetup->curlPlant1AniDurations[AIZSetup->curlPlant1AniFrame];98RSDK.DrawAniTiles(AIZSetup->aniTiles, 198, 16 * AIZSetup->curlPlant1AniFramePos[AIZSetup->curlPlant1AniFrame], 32, 16, 48);99}100101--AIZSetup->curlPlant2AniTimer;102if (AIZSetup->curlPlant2AniTimer < 0) {103++AIZSetup->curlPlant2AniFrame;104if (AIZSetup->curlPlant2AniFramePos[AIZSetup->curlPlant2AniFrame] == -1)105AIZSetup->curlPlant2AniFrame = 0;106107AIZSetup->curlPlant2AniTimer = AIZSetup->curlPlant2AniDurations[AIZSetup->curlPlant2AniFrame];108RSDK.DrawAniTiles(AIZSetup->aniTiles, 201, 16 * AIZSetup->curlPlant2AniFramePos[AIZSetup->curlPlant2AniFrame], 32, 16, 48);109}110#endif111}112113void AIZSetup_Draw(void) {}114115void AIZSetup_Create(void *data) {}116117void AIZSetup_StageLoad(void)118{119#if MANIA_USE_PLUS120if (Zone->actID != 3)121#endif122Zone->cameraBoundsB[0] = SCREEN_YSIZE;123124AIZSetup->hasSetupCutscene = false;125126AIZSetup->aniTiles = RSDK.LoadSpriteSheet("AIZ/AniTiles.gif", SCOPE_STAGE);127AIZSetup->knuxFrames = RSDK.LoadSpriteAnimation("Players/KnuxCutsceneAIZ.bin", SCOPE_STAGE);128129#if MANIA_USE_PLUS130if (RSDK.GetTileLayerID("Background 4") >= DRAWGROUP_COUNT) {131// Bug Details:132// AIZ->background4 doesn't get cleared here, so coming from AIZ Intro to AIZ Encore (same folder so object structs aren't reset)133// leaves background4's tileLayer pointer intact, though pointing to the wrong layers134// it also enables the behaviour in StaticUpdate that should only play in AIZ Intro135// Fix:136// AIZSetup->background4 = NULL;137// (though you should prolly clear the other 3 as well)138139for (int32 i = Zone->fgLayer[0]; i <= Zone->fgLayer[1]; ++i) {140int32 *deformData = RSDK.GetTileLayer(i)->deformationDataW;141142int32 angle = 0;143for (int32 d = 0; d < 0x200; ++d) {144deformData[d] = (2 * RSDK.Sin1024(angle)) >> 10;145angle += 16;146}147148memcpy(&deformData[0x200], &deformData[0], (0x200 * sizeof(int32)));149}150151int32 *deformData = RSDK.GetTileLayer(0)->deformationDataW;152for (int32 d = 0; d < 0x200; d += 16) {153int32 id = MAX(d, 0);154155int32 angle = 0;156int32 deform = RSDK.Rand(0, 4);157for (int32 i = 0; i < 16; ++i) {158deformData[id + i] = (deform * RSDK.Sin1024(angle)) >> 10;159angle += 64;160}161}162memcpy(&deformData[0x200], &deformData[0], (0x200 * sizeof(int32)));163}164else {165#endif166AIZSetup->background1 = RSDK.GetTileLayer(RSDK.GetTileLayerID("Background 1"));167AIZSetup->background2 = RSDK.GetTileLayer(RSDK.GetTileLayerID("Background 2"));168AIZSetup->background3 = RSDK.GetTileLayer(RSDK.GetTileLayerID("Background 3"));169AIZSetup->background4 = RSDK.GetTileLayer(RSDK.GetTileLayerID("Background 4"));170171for (int32 i = 0; i < AIZSetup->background2->scrollInfoCount; ++i) {172int32 parallaxFactor = AIZSetup->background2->scrollInfo[i].parallaxFactor;173AIZSetup->background2->scrollInfo[i].scrollPos = -TO_FIXED(0x700) - (TO_FIXED(34) * parallaxFactor);174}175176for (int32 i = 0; i < AIZSetup->background3->scrollInfoCount; ++i) {177int32 parallaxFactor = AIZSetup->background3->scrollInfo[i].parallaxFactor;178AIZSetup->background3->scrollInfo[i].scrollPos = -TO_FIXED(0x700) - (TO_FIXED(34) * parallaxFactor);179}180#if MANIA_USE_PLUS181}182#endif183184Animals->animalTypes[0] = ANIMAL_FLICKY;185Animals->animalTypes[1] = ANIMAL_RICKY;186187Music_SetMusicTrack("RubyPresence.ogg", TRACK_RUBYPRESENCE, 198457);188189AIZSetup->sfxDrill = RSDK.GetSfx("LRZ/Drill.wav");190AIZSetup->sfxBreak = RSDK.GetSfx("Stage/LedgeBreak3.wav");191AIZSetup->sfxImpact = RSDK.GetSfx("Stage/Impact4.wav");192AIZSetup->sfxHeliWoosh = RSDK.GetSfx("SPZ1/HeliWooshIn.wav");193194if (CHECK_CHARACTER_ID(ID_KNUCKLES, 1)) {195foreach_all(AIZTornado, tornado) { destroyEntity(tornado); }196foreach_all(AIZTornadoPath, node) { destroyEntity(node); }197}198199#if MANIA_USE_PLUS200BGSwitch->switchCallback[AIZ_BG_JUNGLE] = AIZSetup_BGSwitch_Jungle;201BGSwitch->switchCallback[AIZ_BG_SKY] = AIZSetup_BGSwitch_Sky;202203BGSwitch->layerIDs[0] = AIZ_BG_JUNGLE;204BGSwitch->layerIDs[1] = AIZ_BG_JUNGLE;205BGSwitch->layerIDs[2] = AIZ_BG_JUNGLE;206BGSwitch->layerIDs[3] = AIZ_BG_JUNGLE;207208RSDK.SetDrawGroupProperties(0, false, Water_DrawHook_ApplyWaterPalette);209RSDK.SetDrawGroupProperties(Zone->hudDrawGroup, false, Water_DrawHook_RemoveWaterPalette);210Water->waterPalette = 1;211#endif212}213214#if MANIA_USE_PLUS215void AIZSetup_BGSwitch_Jungle(void)216{217RSDK.GetTileLayer(0)->drawGroup[BGSwitch->screenID] = 0;218RSDK.GetTileLayer(1)->drawGroup[BGSwitch->screenID] = DRAWGROUP_COUNT;219}220221void AIZSetup_BGSwitch_Sky(void)222{223RSDK.GetTileLayer(0)->drawGroup[BGSwitch->screenID] = DRAWGROUP_COUNT;224RSDK.GetTileLayer(1)->drawGroup[BGSwitch->screenID] = 0;225}226#endif227228void AIZSetup_PlayerState_Static(void)229{230RSDK_THIS(Player);231self->active = ACTIVE_NORMAL;232self->visible = false;233self->position.x = 0;234self->position.y = 0;235self->stateInput = StateMachine_None;236}237238void AIZSetup_PlayerState_P2Enter(void)239{240RSDK_THIS(Player);241self->active = ACTIVE_NORMAL;242self->visible = true;243self->stateInput = Player_Input_P2_AI;244Player->respawnTimer = 240;245Player_HandleSidekickRespawn();246}247248void AIZSetup_HandleHeavyMovement(void)249{250EntityAIZKingClaw *claw = AIZSetup->claw;251252int32 x = -0x10000;253foreach_all(AIZEggRobo, robo)254{255if (robo->forKnux && x >= robo->position.x)256x = robo->position.x;257}258259if (x < (ScreenInfo->position.x + ScreenInfo->size.x + 32) << 16) {260foreach_all(AIZEggRobo, eggRobo)261{262if (eggRobo->forKnux)263eggRobo->position.x += 0x40000;264}265claw->position.x += 0x40000;266claw->position.y -= 0x4000;267}268}269270void AIZSetup_SetupObjects(void)271{272foreach_all(AIZTornado, tornado)273{274AIZSetup->tornado = tornado;275foreach_break;276}277278foreach_all(Platform, platform)279{280if (!platform->frameID) {281platform->drawGroup = Zone->objectDrawGroup[1] - 1;282AIZSetup->platform = platform;283foreach_break;284}285}286287foreach_all(AIZKingClaw, claw)288{289AIZSetup->claw = claw;290foreach_break;291}292293foreach_all(PhantomRuby, ruby)294{295AIZSetup->phantomRuby = ruby;296foreach_break;297}298299int32 id = 0;300foreach_all(Decoration, decoration) { AIZSetup->decorations[id++] = decoration; }301}302303void AIZSetup_GetCutsceneSetupPtr(void)304{305switch (GET_CHARACTER_ID(1)) {306default:307case ID_SONIC:308case ID_TAILS:309#if MANIA_USE_PLUS310case ID_MIGHTY:311case ID_RAY:312#endif313AIZSetup_CutsceneST_Setup();314break;315316case ID_KNUCKLES: AIZSetup_CutsceneK_Setup(); break;317}318}319320#if MANIA_USE_PLUS321void AIZSetup_Cutscene_SkipCB(void)322{323#if MANIA_USE_PLUS324if (globals->gameMode == MODE_ENCORE)325RSDK.SetScene("Encore Mode", "Green Hill Zone+ 1");326else327#endif328RSDK.SetScene("Mania Mode", "Green Hill Zone 1");329}330#endif331332void AIZSetup_CutsceneST_Setup(void)333{334RSDK_THIS(AIZSetup);335CutsceneSeq_StartSequence(self, AIZSetup_CutsceneSonic_EnterAIZ, AIZSetup_CutsceneSonic_EnterAIZJungle, AIZSetup_CutsceneSonic_EnterHeavies,336AIZSetup_CutsceneSonic_P2FlyIn, AIZSetup_CutsceneSonic_EnterClaw, AIZSetup_CutsceneSonic_WatchClaw,337AIZSetup_CutsceneSonic_RubyGrabbed, AIZSetup_CutsceneSonic_RubyAppear, AIZSetup_CutsceneSonic_RubyFX,338AIZSetup_Cutscene_LoadGHZ, StateMachine_None);339340#if MANIA_USE_PLUS341CutsceneSeq_SetSkipTypeCallback(AIZSetup_Cutscene_SkipCB);342#endif343}344345bool32 AIZSetup_CutsceneSonic_EnterAIZ(EntityCutsceneSeq *host)346{347MANIA_GET_PLAYER(player1, player2, camera);348EntityAIZTornado *tornado = AIZSetup->tornado;349350if (!host->timer) {351CutsceneSeq_LockAllPlayerControl();352player1->stateInput = StateMachine_None;353}354Zone->playerBoundActiveL[0] = false;355356if (player2->classID == Player->classID)357player2->state = AIZSetup_PlayerState_Static;358359if (tornado->position.x < ScreenInfo->size.x << 16)360camera->position.x = ScreenInfo->size.x << 16;361362return tornado->disableInteractions;363}364bool32 AIZSetup_CutsceneSonic_EnterAIZJungle(EntityCutsceneSeq *host)365{366MANIA_GET_PLAYER(player1, player2, camera);367UNUSED(player2);368UNUSED(camera);369370if (player1->position.x >= 0x27100000) {371Music_TransitionTrack(TRACK_HBHMISCHIEF, 0.01);372player1->right = false;373player1->left = true;374host->storedValue = player1->groundVel;375return true;376}377else {378player1->right = true;379}380return false;381}382bool32 AIZSetup_CutsceneSonic_EnterHeavies(EntityCutsceneSeq *host)383{384MANIA_GET_PLAYER(player1, player2, camera);385UNUSED(camera);386387if (player1->position.x >= 0x2A300000) {388if (player1->groundVel <= 0) {389if (!host->storedTimer) {390player1->right = false;391player1->left = false;392host->storedTimer = host->timer;393}394}395else {396if (player2->classID == Player->classID) {397player2->stateInput = StateMachine_None;398}399Player->targetLeaderPosition.x = player1->position.x - 0x200000;400Player->targetLeaderPosition.y = player1->position.y;401player1->state = Player_State_Ground;402player1->right = false;403player1->left = true;404}405}406else {407player1->state = Player_State_Static;408RSDK.SetSpriteAnimation(player1->aniFrames, ANI_SKID, &player1->animator, false, 0);409player1->groundVel = host->storedValue;410player1->velocity.x = host->storedValue;411player1->right = false;412player1->left = false;413if (player2 && player2->state == AIZSetup_PlayerState_Static)414player2->state = AIZSetup_PlayerState_P2Enter;415}416417if (host->storedTimer > 0 && host->timer > host->storedTimer + 15) {418player1->direction = FLIP_NONE;419return true;420}421422return false;423}424bool32 AIZSetup_CutsceneSonic_P2FlyIn(EntityCutsceneSeq *host)425{426MANIA_GET_PLAYER(player1, player2, camera);427UNUSED(camera);428429if (player2->classID == Player->classID) {430if (player2->onGround) {431player2->stateInput = StateMachine_None;432player2->direction = FLIP_NONE;433RSDK.SetSpriteAnimation(player2->aniFrames, 0, &player2->animator, true, 0);434player2->state = Player_State_Static;435return true;436}437else {438Player->targetLeaderPosition.x = player1->position.x - 0x200000;439Player->targetLeaderPosition.y = player1->position.y + 0x80000;440player2->position.x = Player->targetLeaderPosition.x;441player2->direction = FLIP_NONE;442}443}444else {445return host->timer > 10;446}447448return false;449}450bool32 AIZSetup_CutsceneSonic_EnterClaw(EntityCutsceneSeq *host)451{452MANIA_GET_PLAYER(player1, player2, camera);453454if (!host->timer) {455player1->camera = NULL;456Camera_SetupLerp(CAMERA_LERP_NORMAL, 0, AIZSetup->platform->position.x - 0x400000, camera->position.y, 3);457player1->stateInput = StateMachine_None;458player1->state = Player_State_Ground;459player1->up = true;460}461else {462if (camera->position.x >= camera->endLerpPos.x) {463if (host->storedTimer) {464if (host->timer >= host->storedTimer + 60)465return true;466}467else {468host->storedTimer = host->timer;469}470}471else {472player1->up = true;473if (player2->classID == Player->classID) {474player2->state = Player_State_Static;475}476}477}478return false;479}480bool32 AIZSetup_CutsceneSonic_WatchClaw(EntityCutsceneSeq *host)481{482EntityAIZKingClaw *claw = AIZSetup->claw;483484if (claw->position.y < -0x1C0000) {485claw->position.y += 0x10000;486}487else {488if (host->storedTimer) {489if (host->timer >= host->storedTimer + 60)490return true;491}492else {493host->storedTimer = host->timer;494claw->state = AIZKingClaw_State_Grab;495}496}497498return false;499}500bool32 AIZSetup_CutsceneSonic_RubyGrabbed(EntityCutsceneSeq *host)501{502MANIA_GET_PLAYER(player1, player2, camera);503UNUSED(player1);504UNUSED(camera);505506EntityAIZKingClaw *claw = AIZSetup->claw;507EntityPlatform *platform = AIZSetup->platform;508EntityPhantomRuby *ruby = AIZSetup->phantomRuby;509510if (!host->timer) {511claw->grabbedEntities[0] = (Entity *)platform;512claw->grabbedEntities[1] = (Entity *)ruby;513claw->grabCount = 2;514}515516if (claw->position.y > -0x520000) {517AIZSetup->playDrillSfx = true;518519if (!(host->timer % 5))520Camera_ShakeScreen(0, 0, 2);521522claw->position.y -= 0x4000;523524for (int32 i = 0; i < 3; ++i) {525EntityDecoration *decor = AIZSetup->decorations[i];526decor->drawFX |= FX_ROTATE;527decor->rotation = ((2 * (!(i & 1)) - 1) * RSDK.Sin256(16 * host->timer)) >> 7;528}529}530else {531if (host->storedTimer) {532if (host->values[0]) {533if (!host->values[1] && host->timer >= host->storedTimer && host->timer == host->storedTimer) {534return true;535}536}537else if (host->timer < host->storedTimer + 30) {538Vector2 result = MathHelpers_GetBezierPoint(((host->timer - host->storedTimer) << 16) / 30, claw->position.x, host->storedValue,539claw->position.x, host->storedValue - 0x500000, claw->position.x,540host->storedValue - 0x300000, claw->position.x, host->storedValue - 0x300000);541claw->position.y = result.y;542}543else if (host->timer != host->storedTimer + 30) {544if (!host->values[1] && host->timer >= host->storedTimer && host->timer == host->storedTimer) {545return true;546}547}548else {549host->values[0] = 1;550host->storedTimer = host->timer + 60;551}552}553else {554AIZSetup->playDrillSfx = false;555556host->storedTimer = host->timer;557host->storedValue = claw->position.y;558559AIZSetup->decorations[0]->rotSpeed = 0;560AIZSetup->decorations[1]->rotSpeed = 0;561562if (CHECK_CHARACTER_ID(ID_TAILS, 2))563RSDK.SetSpriteAnimation(player2->aniFrames, ANI_SKID, &player2->animator, true, 0);564565RSDK.PlaySfx(AIZSetup->sfxBreak, false, 0x00);566567Music_TransitionTrack(TRACK_EGGMAN1, 0.05);568}569}570571return false;572}573bool32 AIZSetup_CutsceneSonic_RubyAppear(EntityCutsceneSeq *host)574{575EntityPhantomRuby *ruby = AIZSetup->phantomRuby;576577if (!host->timer)578PhantomRuby_SetupFlash(ruby);579580return ruby->flashFinished;581}582bool32 AIZSetup_CutsceneSonic_RubyFX(EntityCutsceneSeq *host)583{584MANIA_GET_PLAYER(player1, player2, camera);585UNUSED(camera);586587EntityPhantomRuby *ruby = AIZSetup->phantomRuby;588589EntityFXRuby *fxRuby = NULL;590if (host->timer) {591fxRuby = AIZSetup->fxRuby;592}593else {594fxRuby = CREATE_ENTITY(FXRuby, NULL, ruby->position.x, ruby->position.y);595fxRuby->drawGroup = Zone->playerDrawGroup[1];596AIZSetup->fxRuby = fxRuby;597Camera_ShakeScreen(0, 4, 4);598player1->drawGroup = Zone->playerDrawGroup[1] + 1;599if (player2->classID == Player->classID)600player2->drawGroup = Zone->playerDrawGroup[1] + 1;601}602603if (!host->values[0]) {604if (fxRuby->fullyExpanded) {605if (host->storedTimer) {606if (host->timer == host->storedTimer + 30) {607fxRuby->delay = 64;608fxRuby->state = FXRuby_State_IncreaseStageDeform;609PhantomRuby_PlaySfx(RUBYSFX_ATTACK4);610Camera_ShakeScreen(0, 4, 4);611}612else if (host->timer == host->storedTimer + 210) {613fxRuby->delay = 32;614fxRuby->state = FXRuby_State_IncreaseStageDeform;615PhantomRuby_PlaySfx(RUBYSFX_ATTACK1);616Camera_ShakeScreen(0, 4, 4);617Music_FadeOut(0.025);618host->storedTimer = host->timer;619host->values[0] = true;620}621}622else {623host->storedTimer = host->timer;624}625626if (host->timer >= host->storedTimer + 32) {627int32 id = 0;628for (int32 angle = 0; angle < 0x80; angle += 0x40) {629EntityPlayer *player = RSDK_GET_ENTITY(id++, Player);630if (!player || player->classID == TYPE_BLANK)631break;632RSDK.SetSpriteAnimation(player->aniFrames, ANI_FAN, &player->animator, false, 0);633634int32 moveX = (player->position.x - player->position.x) >> 3;635int32 moveY = (0xA00 * RSDK.Sin256(2 * (host->timer + angle - host->storedTimer)) + ruby->position.y - player->position.y) >> 3;636637player->position.x += moveX;638player->position.y += moveY;639player->state = Player_State_Static;640player->tileCollisions = TILECOLLISION_NONE;641player->onGround = false;642}643}644}645}646else {647if (fxRuby->fadeWhite >= 512) {648if (fxRuby->fadeBlack >= 512) {649if (host->timer == host->storedTimer + 150)650return true;651}652else {653fxRuby->fadeBlack += 16;654}655}656else {657fxRuby->fadeWhite += 16;658}659}660return false;661}662663void AIZSetup_CutsceneK_Setup(void)664{665RSDK_THIS(AIZSetup);666CutsceneSeq_StartSequence(self, AIZSetup_CutsceneKnux_Chillin, AIZSetup_CutsceneKnux_StartDrillin, AIZSetup_CutsceneKnux_Drillin,667AIZSetup_CutsceneKnux_PrepareForTrouble, AIZSetup_CutsceneKnux_EnterThreat, AIZSetup_CutsceneKnux_HeaviesAppear,668AIZSetup_CutsceneKnux_RubyImpact, AIZSetup_CutsceneKnux_RubyFX, AIZSetup_Cutscene_LoadGHZ, StateMachine_None);669670#if MANIA_USE_PLUS671CutsceneSeq_SetSkipTypeCallback(AIZSetup_Cutscene_SkipCB);672#endif673}674675bool32 AIZSetup_CutsceneKnux_Chillin(EntityCutsceneSeq *host)676{677MANIA_GET_PLAYER(player1, player2, camera);678UNUSED(player2);679UNUSED(camera);680681if (!host->timer) {682player1->state = Player_State_Static;683player1->stateInput = StateMachine_None;684player1->direction = FLIP_X;685player1->drawFX = FX_FLIP;686RSDK.SetSpriteAnimation(AIZSetup->knuxFrames, 1, &player1->animator, true, 0);687}688689return host->timer == 180;690}691bool32 AIZSetup_CutsceneKnux_StartDrillin(EntityCutsceneSeq *host)692{693MANIA_GET_PLAYER(player1, player2, camera);694UNUSED(player2);695UNUSED(camera);696697switch (host->timer) {698case 0: RSDK.PlaySfx(AIZKingClaw->sfxClack, false, 0); break;699700case 10:701RSDK.PlaySfx(AIZKingClaw->sfxWalkerLegs, false, 0);702RSDK.SetSpriteAnimation(AIZSetup->knuxFrames, 2, &player1->animator, true, 0);703break;704705case 40: return true;706707default: break;708}709710return false;711}712bool32 AIZSetup_CutsceneKnux_Drillin(EntityCutsceneSeq *host)713{714if (host->timer < 120) {715AIZSetup->playDrillSfx = true;716717if (!(host->timer % 5))718Camera_ShakeScreen(0, 0, 2);719}720else if (host->timer == 120) {721AIZSetup->playDrillSfx = false;722RSDK.PlaySfx(AIZSetup->sfxBreak, false, 0x00);723Music_TransitionTrack(TRACK_HBHMISCHIEF, 0.02);724}725726return host->timer == 200;727}728bool32 AIZSetup_CutsceneKnux_PrepareForTrouble(EntityCutsceneSeq *host)729{730MANIA_GET_PLAYER(player1, player2, camera);731UNUSED(player2);732UNUSED(camera);733734if (player1->animator.animationID == 3 && player1->animator.frameID == player1->animator.frameCount - 1) {735RSDK.SetSpriteAnimation(AIZSetup->knuxFrames, 0, &player1->animator, true, 0);736}737738if (!host->timer) {739RSDK.SetSpriteAnimation(AIZSetup->knuxFrames, 3, &player1->animator, true, 0);740foreach_active(Animals, animal)741{742animal->active = ACTIVE_NORMAL;743animal->behaviour = ANIMAL_BEHAVE_FREE;744}745}746747return host->timer == 60;748}749bool32 AIZSetup_CutsceneKnux_EnterThreat(EntityCutsceneSeq *host)750{751MANIA_GET_PLAYER(player1, player2, camera);752UNUSED(player2);753754if (!host->timer) {755player1->camera = NULL;756Camera_SetupLerp(CAMERA_LERP_NORMAL, 0, player1->position.x - 0x600000, camera->position.y, 3);757}758else if (camera->position.x <= camera->endLerpPos.x) {759if (host->storedTimer) {760if (host->timer >= host->storedTimer + 60)761return true;762}763else {764host->storedTimer = host->timer;765}766}767else {768player1->state = Player_State_Static;769}770return false;771}772bool32 AIZSetup_CutsceneKnux_HeaviesAppear(EntityCutsceneSeq *host)773{774MANIA_GET_PLAYER(player1, player2, camera);775UNUSED(player2);776UNUSED(camera);777778EntityAIZKingClaw *claw = AIZSetup->claw;779EntityPhantomRuby *ruby = AIZSetup->phantomRuby;780781if (!host->timer) {782claw->grabbedEntities[0] = (Entity *)AIZSetup->platform;783claw->grabbedEntities[1] = (Entity *)ruby;784claw->grabCount = 2;785claw->angle = -16;786claw->position.y = -0x300000;787claw->position.x = 0x2F9C0000;788ruby->sfx = 0;789PhantomRuby_SetupFlash(ruby);790player1->drawGroup = Zone->playerDrawGroup[1] + 2;791RSDK.PlaySfx(AIZSetup->sfxHeliWoosh, false, 0);792}793794AIZSetup_HandleHeavyMovement();795796return ruby->position.x >= player1->position.x - 0x100000;797}798bool32 AIZSetup_CutsceneKnux_RubyImpact(EntityCutsceneSeq *host)799{800MANIA_GET_PLAYER(player1, player2, camera);801UNUSED(camera);802803EntityPhantomRuby *ruby = AIZSetup->phantomRuby;804805if (!host->timer) {806RSDK.PlaySfx(AIZSetup->sfxImpact, false, 0x00);807PhantomRuby_PlaySfx(RUBYSFX_REDCUBE);808Music_TransitionTrack(TRACK_EGGMAN1, 1.0);809810EntityFXRuby *fxRuby = CREATE_ENTITY(FXRuby, NULL, ruby->position.x, ruby->position.y);811fxRuby->drawGroup = Zone->playerDrawGroup[1];812AIZSetup->fxRuby = fxRuby;813player1->velocity.x = 0x20000;814player1->velocity.y = -0x40000;815player1->nextGroundState = StateMachine_None;816player1->nextAirState = StateMachine_None;817player1->state = Player_State_Static;818player1->onGround = false;819player1->drawGroup = Zone->playerDrawGroup[1] + 1;820821if (player2->classID == Player->classID)822player2->drawGroup = Zone->playerDrawGroup[1] + 1;823824Camera_ShakeScreen(0, 4, 4);825}826827AIZSetup_HandleHeavyMovement();828829if (player1->onGround) {830if (player1->velocity.x > 0)831player1->velocity.x -= 0x2000;832if (player1->velocity.x < 0)833player1->velocity.x = 0;834player1->state = Player_State_Static;835RSDK.SetSpriteAnimation(AIZSetup->knuxFrames, 5, &player1->animator, false, 0);836return true;837}838else {839player1->velocity.y += 0x3800;840841if (player1->velocity.x > 0)842player1->velocity.x -= 0x1000;843844if (player1->velocity.x < 0)845player1->velocity.x = 0;846847RSDK.SetSpriteAnimation(AIZSetup->knuxFrames, 4, &player1->animator, true, 0);848}849return false;850}851bool32 AIZSetup_CutsceneKnux_RubyFX(EntityCutsceneSeq *host)852{853MANIA_GET_PLAYER(player1, player2, camera);854UNUSED(player2);855UNUSED(camera);856857EntityFXRuby *fxRuby = AIZSetup->fxRuby;858859if (player1->velocity.x > 0)860player1->velocity.x -= 0x1000;861862if (player1->velocity.x < 0)863player1->velocity.x = 0;864865if (host->timer == 180) {866fxRuby->delay = 32;867fxRuby->state = FXRuby_State_IncreaseStageDeform;868869PhantomRuby_PlaySfx(RUBYSFX_ATTACK1);870Camera_ShakeScreen(0, 4, 4);871Music_FadeOut(0.025);872873host->storedTimer = host->timer;874host->values[0] = true;875}876877AIZSetup_HandleHeavyMovement();878879if (host->values[0]) {880if (fxRuby->fadeWhite < 0x200) {881fxRuby->fadeWhite += 0x10;882}883else if (fxRuby->fadeBlack >= 0x200) {884if (host->timer == host->storedTimer + 150)885return true;886}887else {888fxRuby->fadeBlack += 0x200;889}890}891892return false;893}894895bool32 AIZSetup_Cutscene_LoadGHZ(EntityCutsceneSeq *host)896{897UNUSED(host);898899RSDK.SetScene("Cutscenes", "Green Hill Zone");900RSDK.LoadScene();901902return true;903}904905#if GAME_INCLUDE_EDITOR906void AIZSetup_EditorDraw(void) {}907908void AIZSetup_EditorLoad(void)909{910RSDK_ACTIVE_VAR(BGSwitch, bgID);911RSDK_ENUM_VAR("Jungle BG", AIZ_BG_JUNGLE);912RSDK_ENUM_VAR("Sky BG", AIZ_BG_SKY);913914RSDK_ACTIVE_VAR(Decoration, type);915RSDK_ENUM_VAR("Leaf 1", AIZ_DECOR_LEAF1);916RSDK_ENUM_VAR("Leaf 2", AIZ_DECOR_LEAF2);917RSDK_ENUM_VAR("Leaf 3", AIZ_DECOR_LEAF3);918RSDK_ENUM_VAR("Leaf 4", AIZ_DECOR_LEAF4);919}920#endif921922void AIZSetup_Serialize(void) {}923924925