From 66932d84a46f1e7329c43b6f3bd350c48222ae9f Mon Sep 17 00:00:00 2001 From: Arceveti <73617174+Arceveti@users.noreply.github.com> Date: Wed, 29 Sep 2021 11:30:07 -0700 Subject: [PATCH] Add DISABLE_LEVEL_SPECIFIC_CHECKS --- include/config.h | 14 ++- src/game/behaviors/capswitch.inc.c | 9 ++ src/game/behaviors/coin.inc.c | 4 + src/game/behaviors/fish.inc.c | 37 +++++--- src/game/behaviors/flamethrower.inc.c | 15 ++-- src/game/behaviors/piranha_plant.inc.c | 8 +- src/game/behaviors/whomp.inc.c | 22 ++--- src/game/camera.c | 120 ++++++++++++++----------- src/game/level_update.c | 13 ++- src/game/mario_actions_automatic.c | 8 +- src/game/mario_actions_cutscene.c | 7 +- src/game/mario_actions_submerged.c | 3 +- src/game/object_helpers.c | 9 +- src/game/object_helpers.h | 4 +- src/game/puppycam2.c | 3 +- 15 files changed, 166 insertions(+), 110 deletions(-) diff --git a/include/config.h b/include/config.h index 2b393dee..88106dc8 100644 --- a/include/config.h +++ b/include/config.h @@ -26,6 +26,10 @@ #endif // TARGET_N64 // -- GAME SETTINGS -- +// Disables some mechanics that change behavior depending on hardcoded level numbers. +// You may also need to change sLevelsWithRooms in object_helpers.c +// TODO: separate this into separate defines, behavior params, or make these mechanics otherwise dynamic +// #define DISABLE_LEVEL_SPECIFIC_CHECKS // Disable lives and hide the lives counter #define DISABLE_LIVES // Air/Breath meter is separate from health meter when underwater @@ -127,12 +131,10 @@ //#define SKIP_TITLE_SCREEN // Uncomment this if you want to keep the mario head and not skip it //#define KEEP_MARIO_HEAD -#ifdef KEEP_MARIO_HEAD // safeguard -//Goddard easter egg from Shindou (has no effect if KEEP_MARIO_HEAD is disabled) +// Goddard easter egg from Shindou (has no effect if KEEP_MARIO_HEAD is disabled) #define GODDARD_EASTER_EGG // Disables the demo that plays when idle on the start screen (has no effect if KEEP_MARIO_HEAD is disabled) #define DISABLE_DEMO -#endif // KEEP_MARIO_HEAD // -- CAMERA SETTINGS -- // Remove course specific camera processing @@ -204,3 +206,9 @@ //#define UNLOCK_ALL // If you want to change the extended boundaries mode, go to engine/extended_bounds.h and change EXTENDED_BOUNDS_MODE + +// -- Compatibility safeguards. Don't mess with these unless you know what you're doing.-- +#ifndef KEEP_MARIO_HEAD +#undef GODDARD_EASTER_EGG +#define DISABLE_DEMO +#endif diff --git a/src/game/behaviors/capswitch.inc.c b/src/game/behaviors/capswitch.inc.c index d79f8970..2688634f 100644 --- a/src/game/behaviors/capswitch.inc.c +++ b/src/game/behaviors/capswitch.inc.c @@ -7,6 +7,14 @@ void cap_switch_act_0(void) { cur_obj_scale(0.5f); o->oPosY += 71.0f; spawn_object_relative_with_scale(0, 0, -71, 0, 0.5f, o, MODEL_CAP_SWITCH_BASE, bhvCapSwitchBase); +#ifdef DISABLE_LEVEL_SPECIFIC_CHECKS + if (save_file_get_flags() & sCapSaveFlags[o->oBehParams2ndByte]) { + o->oAction = 3; + o->header.gfx.scale[1] = 0.1f; + } else { + o->oAction = 1; + } +#else if (gCurrLevelNum != LEVEL_UNKNOWN_32) { if (save_file_get_flags() & sCapSaveFlags[o->oBehParams2ndByte]) { o->oAction = 3; @@ -17,6 +25,7 @@ void cap_switch_act_0(void) { } else { o->oAction = 1; } +#endif } void cap_switch_act_1(void) { diff --git a/src/game/behaviors/coin.inc.c b/src/game/behaviors/coin.inc.c index 7436c13f..3dd847d2 100644 --- a/src/game/behaviors/coin.inc.c +++ b/src/game/behaviors/coin.inc.c @@ -216,7 +216,11 @@ void coin_inside_boo_act_0(void) { s16 marioMoveYaw; struct Object *parent = o->parentObj; cur_obj_become_intangible(); +#ifdef DISABLE_LEVEL_SPECIFIC_CHECKS + if (o->oTimer == 0) { +#else if (o->oTimer == 0 && gCurrLevelNum == LEVEL_BBH) { +#endif cur_obj_set_model(MODEL_BLUE_COIN); cur_obj_scale(0.7f); } diff --git a/src/game/behaviors/fish.inc.c b/src/game/behaviors/fish.inc.c index f72291d7..67a95b34 100644 --- a/src/game/behaviors/fish.inc.c +++ b/src/game/behaviors/fish.inc.c @@ -26,7 +26,11 @@ static void fish_spawner_act_spawn(void) { // Spawn and animate the schoolQuantity of fish if Mario enters render distance // or the stage is Secret Aquarium. // Fish moves randomly within a range of 700.0f. +#ifdef DISABLE_LEVEL_SPECIFIC_CHECKS + if (o->oDistanceToMario < minDistToMario) { +#else if (o->oDistanceToMario < minDistToMario || gCurrLevelNum == LEVEL_SA) { +#endif for (i = 0; i < schoolQuantity; i++) { fishObject = spawn_object(o, model, bhvFish); fishObject->oBehParams2ndByte = o->oBehParams2ndByte; @@ -67,7 +71,7 @@ void bhv_fish_spawner_loop(void) { */ static void fish_vertical_roam(s32 speed) { f32 parentY = o->parentObj->oPosY; - +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS // If the stage is Secret Aquarium, the fish can // travel as far vertically as they wish. if (gCurrLevelNum == LEVEL_SA) { @@ -76,9 +80,10 @@ static void fish_vertical_roam(s32 speed) { } o->oPosY = approach_f32_symmetric(o->oPosY, o->oFishGoalY, speed); - // Allow the fish to roam vertically if within - // range of the fish spawner. - } else if (parentY - 100.0f - o->oFishDepthDistance < o->oPosY + // Allow the fish to roam vertically if within range of the fish spawner. + } else +#endif + if (parentY - 100.0f - o->oFishDepthDistance < o->oPosY && o->oPosY < parentY + 1000.0f + o->oFishDepthDistance) { o->oPosY = approach_f32_symmetric(o->oPosY, o->oFishGoalY, speed); } @@ -100,11 +105,11 @@ static void fish_act_roam(void) { // Initializes some variables when the fish first begins roaming. if (o->oTimer == 0) { o->oForwardVel = random_float() * 2 + 3.0f; - if (gCurrLevelNum == LEVEL_SA) { - o->oFishHeightOffset = random_float() * 700.0f; - } else { - o->oFishHeightOffset = random_float() * 100.0f; - } +#ifdef DISABLE_LEVEL_SPECIFIC_CHECKS + o->oFishHeightOffset = random_float() * 100.0f; +#else + o->oFishHeightOffset = random_float() * ((gCurrLevelNum == LEVEL_SA) ? 700.0f : 100.0f); +#endif o->oFishRoamDistance = random_float() * 500 + 200.0f; } @@ -217,25 +222,29 @@ void bhv_fish_loop(void) { // oFishWaterLevel tracks if a fish has roamed out of water. // This can't happen in Secret Aquarium, so set it to 0. o->oFishWaterLevel = find_water_level(o->oPosX, o->oPosZ); +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS if (gCurrLevelNum == LEVEL_SA) { o->oFishWaterLevel = 0.0f; } +#endif // Apply hitbox and resolve wall collisions o->oWallHitboxRadius = 30.0f; cur_obj_resolve_wall_collisions(); - +#ifdef DISABLE_LEVEL_SPECIFIC_CHECKS + if (o->oFishWaterLevel < FLOOR_LOWER_LIMIT_MISC) { + obj_mark_for_deletion(o); + return; + } +#else // Delete fish if it's drifted to an area with no water. if (gCurrLevelNum != LEVEL_UNKNOWN_32) { if (o->oFishWaterLevel < FLOOR_LOWER_LIMIT_MISC) { obj_mark_for_deletion(o); return; } - - // Unreachable code, perhaps for debugging or testing. - } else { - o->oFishWaterLevel = 1000.0f; } +#endif // Call fish action methods and apply physics engine. cur_obj_call_action_function(sFishActions); diff --git a/src/game/behaviors/flamethrower.inc.c b/src/game/behaviors/flamethrower.inc.c index 8c4e600f..66d3f1ca 100644 --- a/src/game/behaviors/flamethrower.inc.c +++ b/src/game/behaviors/flamethrower.inc.c @@ -39,9 +39,13 @@ void bhv_flamethrower_loop(void) { s32 flameTimeRemaining; s32 model; if (o->oAction == 0) { - if (gCurrLevelNum != LEVEL_BBH || gMarioOnMerryGoRound == TRUE) - if (o->oDistanceToMario < 2000.0f) +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS + if (gCurrLevelNum != LEVEL_BBH || gMarioOnMerryGoRound == TRUE) { + if (o->oDistanceToMario < 2000.0f) { o->oAction++; + } + } +#endif } else if (o->oAction == 1) { model = MODEL_RED_FLAME; flameVel = 95.0f; @@ -50,12 +54,13 @@ void bhv_flamethrower_loop(void) { if (o->oBehParams2ndByte == 2) flameVel = 50.0f; flameTimeRemaining = 1; - if (o->oTimer < 60) + if (o->oTimer < 60) { flameTimeRemaining = 15; - else if (o->oTimer < 74) + } else if (o->oTimer < 74) { flameTimeRemaining = 75 - o->oTimer; // Range: [15..2] - else + } else { o->oAction++; + } o->oFlameThowerTimeRemaining = flameTimeRemaining; flame = spawn_object_relative(o->oBehParams2ndByte, 0, 0, 0, o, model, bhvFlamethrowerFlame); flame->oForwardVel = flameVel; diff --git a/src/game/behaviors/piranha_plant.inc.c b/src/game/behaviors/piranha_plant.inc.c index 371bf557..d97e53ab 100644 --- a/src/game/behaviors/piranha_plant.inc.c +++ b/src/game/behaviors/piranha_plant.inc.c @@ -309,13 +309,15 @@ void (*TablePiranhaPlantActions[])(void) = { */ void bhv_piranha_plant_loop(void) { cur_obj_call_action_function(TablePiranhaPlantActions); - +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS // In WF, hide all Piranha Plants once high enough up. if (gCurrLevelNum == LEVEL_WF) { - if (gMarioObject->oPosY > 3400.0f) + if (gMarioObject->oPosY > 3400.0f) { cur_obj_hide(); - else + } else { cur_obj_unhide(); + } } +#endif o->oInteractStatus = 0; } diff --git a/src/game/behaviors/whomp.inc.c b/src/game/behaviors/whomp.inc.c index f98de7d8..d1517601 100644 --- a/src/game/behaviors/whomp.inc.c +++ b/src/game/behaviors/whomp.inc.c @@ -52,23 +52,19 @@ void whomp_turn(void) { } void whomp_patrol(void) { - s16 marioAngle; - f32 distWalked; - f32 patrolDist; - - marioAngle = abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw); - distWalked = cur_obj_lateral_dist_to_home(); - if (gCurrLevelNum == LEVEL_BITS) - patrolDist = 200.0f; - else - patrolDist = 700.0f; - + s16 marioAngle = abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw); + f32 distWalked = cur_obj_lateral_dist_to_home(); +#ifdef DISABLE_LEVEL_SPECIFIC_CHECKS // Make this a behavior param? + f32 patrolDist = 700.0f; +#else + f32 patrolDist = ((gCurrLevelNum == LEVEL_BITS) ? 200.0f : 700.0f); +#endif cur_obj_init_animation_with_accel_and_sound(0, 1.0f); o->oForwardVel = 3.0f; - if (distWalked > patrolDist) + if (distWalked > patrolDist) { o->oAction = 7; - else if (marioAngle < 0x2000) { + } else if (marioAngle < 0x2000) { if (o->oDistanceToMario < 1500.0f) { o->oForwardVel = 9.0f; cur_obj_init_animation_with_accel_and_sound(0, 3.0f); diff --git a/src/game/camera.c b/src/game/camera.c index cc7aa740..0c91c8e7 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -1525,12 +1525,12 @@ s32 update_boss_fight_camera(struct Camera *c, Vec3f focus, Vec3f pos) { pos[1] += 125.f; } } - +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS // Prevent the camera from going to the ground in the outside boss fight if (gCurrLevelNum == LEVEL_BBH) { pos[1] = 2047.f; } - +#endif // Rotate from C-Button input if (sCSideButtonYaw < 0) { sModeOffsetYaw += 0x200; @@ -1610,11 +1610,15 @@ void mode_parallel_tracking_camera(struct Camera *c) { * Fixed camera mode, the camera rotates around a point and looks and zooms toward Mario. */ void mode_fixed_camera(struct Camera *c) { +#ifdef DISABLE_LEVEL_SPECIFIC_CHECKS + set_fov_function(CAM_FOV_APP_45); +#else if (gCurrLevelNum == LEVEL_BBH) { set_fov_function(CAM_FOV_BBH); } else { set_fov_function(CAM_FOV_APP_45); } +#endif c->nextYaw = update_fixed_camera(c, c->focus, c->pos); c->yaw = c->nextYaw; pan_ahead_of_player(c); @@ -2149,9 +2153,11 @@ s16 update_default_camera(struct Camera *c) { } if ((gCameraMovementFlags & CAM_MOVE_ZOOMED_OUT) && (sSelectionFlags & CAM_MODE_MARIO_ACTIVE)) { posHeight = 610.f; +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS if (gCurrLevelArea == AREA_SSL_PYRAMID || gCurrLevelNum == LEVEL_CASTLE) { posHeight /= 2; } +#endif } // Make Lakitu fly above the gas @@ -2806,9 +2812,9 @@ void update_camera(struct Camera *c) { gCamera = c; update_camera_hud_status(c); if (c->cutscene == 0 && - #ifdef PUPPYCAM +#ifdef PUPPYCAM !gPuppyCam.enabled && - #endif +#endif !(gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON)) { // Only process R_TRIG if 'fixed' is not selected in the menu if (cam_select_alt_mode(0) == CAM_SELECTION_MARIO) { @@ -2831,9 +2837,9 @@ void update_camera(struct Camera *c) { sStatusFlags |= CAM_FLAG_FRAME_AFTER_CAM_INIT; } - #ifdef PUPPYCAM +#ifdef PUPPYCAM if (!gPuppyCam.enabled || c->cutscene != 0 || gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON) { - #endif +#endif // Store previous geometry information sMarioGeometry.prevFloorHeight = sMarioGeometry.currFloorHeight; sMarioGeometry.prevCeilHeight = sMarioGeometry.currCeilHeight; @@ -2903,62 +2909,65 @@ void update_camera(struct Camera *c) { } } } - #ifdef PUPPYCAM +#ifdef PUPPYCAM } - #endif +#endif // Start any Mario-related cutscenes start_cutscene(c, get_cutscene_from_mario_status(c)); gCheckingSurfaceCollisionsForCamera = FALSE; - #ifdef PUPPYCAM +#ifdef PUPPYCAM if (!gPuppyCam.enabled || c->cutscene != 0 || gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON) { - #endif - if (gCurrLevelNum != LEVEL_CASTLE) { - // If fixed camera is selected as the alternate mode, then fix the camera as long as the right - // trigger is held - if ((c->cutscene == 0 && - (gPlayer1Controller->buttonDown & R_TRIG) && cam_select_alt_mode(0) == CAM_SELECTION_FIXED) - || (gCameraMovementFlags & CAM_MOVE_FIX_IN_PLACE) - || (sMarioCamState->action) == ACT_GETTING_BLOWN) { +#endif +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS + if (gCurrLevelNum != LEVEL_CASTLE) { +#endif + // If fixed camera is selected as the alternate mode, then fix the camera as long as the right + // trigger is held + if ((c->cutscene == 0 && + (gPlayer1Controller->buttonDown & R_TRIG) && cam_select_alt_mode(0) == CAM_SELECTION_FIXED) + || (gCameraMovementFlags & CAM_MOVE_FIX_IN_PLACE) + || (sMarioCamState->action) == ACT_GETTING_BLOWN) { - // If this is the first frame that R_TRIG is held, play the "click" sound - if (c->cutscene == 0 && (gPlayer1Controller->buttonPressed & R_TRIG) - && cam_select_alt_mode(0) == CAM_SELECTION_FIXED) { - sCameraSoundFlags |= CAM_SOUND_FIXED_ACTIVE; - play_sound_rbutton_changed(); + // If this is the first frame that R_TRIG is held, play the "click" sound + if (c->cutscene == 0 && (gPlayer1Controller->buttonPressed & R_TRIG) + && cam_select_alt_mode(0) == CAM_SELECTION_FIXED) { + sCameraSoundFlags |= CAM_SOUND_FIXED_ACTIVE; + play_sound_rbutton_changed(); + } + + // Fixed mode only prevents Lakitu from moving. The camera pos still updates, so + // Lakitu will fly to his next position as normal whenever R_TRIG is released. + gLakituState.posHSpeed = 0.f; + gLakituState.posVSpeed = 0.f; + + vec3f_get_yaw(gLakituState.focus, gLakituState.pos, &c->nextYaw); + c->yaw = c->nextYaw; + gCameraMovementFlags &= ~CAM_MOVE_FIX_IN_PLACE; + } else { + // Play the "click" sound when fixed mode is released + if (sCameraSoundFlags & CAM_SOUND_FIXED_ACTIVE) { + play_sound_rbutton_changed(); + sCameraSoundFlags &= ~CAM_SOUND_FIXED_ACTIVE; + } } - - // Fixed mode only prevents Lakitu from moving. The camera pos still updates, so - // Lakitu will fly to his next position as normal whenever R_TRIG is released. - gLakituState.posHSpeed = 0.f; - gLakituState.posVSpeed = 0.f; - - vec3f_get_yaw(gLakituState.focus, gLakituState.pos, &c->nextYaw); - c->yaw = c->nextYaw; - gCameraMovementFlags &= ~CAM_MOVE_FIX_IN_PLACE; +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS } else { - // Play the "click" sound when fixed mode is released - if (sCameraSoundFlags & CAM_SOUND_FIXED_ACTIVE) { - play_sound_rbutton_changed(); - sCameraSoundFlags &= ~CAM_SOUND_FIXED_ACTIVE; + if ((gPlayer1Controller->buttonPressed & R_TRIG) && cam_select_alt_mode(0) == CAM_SELECTION_FIXED) { + play_sound_button_change_blocked(); } } - } else { - if ((gPlayer1Controller->buttonPressed & R_TRIG) && cam_select_alt_mode(0) == CAM_SELECTION_FIXED) { - play_sound_button_change_blocked(); - } - } +#endif - update_lakitu(c); - #ifdef PUPPYCAM + update_lakitu(c); +#ifdef PUPPYCAM } - //Just a cute little bit that syncs puppycamera up to vanilla when playing a vanilla cutscene :3 + // Just a cute little bit that syncs puppycamera up to vanilla when playing a vanilla cutscene :3 if (c->cutscene != 0) { gPuppyCam.yawTarget = gCamera->yaw; gPuppyCam.yaw = gCamera->yaw; - if (gMarioState->action == ACT_ENTERING_STAR_DOOR) - { //god this is stupid and the fact I have to continue doing this is testament to the idiocy of the star door cutscene >:( - gPuppyCam.yawTarget = gMarioState->faceAngle[1]+0x8000; - gPuppyCam.yaw = gMarioState->faceAngle[1]+0x8000; + if (gMarioState->action == ACT_ENTERING_STAR_DOOR) { // god this is stupid and the fact I have to continue doing this is testament to the idiocy of the star door cutscene >:( + gPuppyCam.yawTarget = gMarioState->faceAngle[1] + 0x8000; + gPuppyCam.yaw = gMarioState->faceAngle[1] + 0x8000; } } if (c->cutscene == 0 && gPuppyCam.enabled && !(gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON)) { @@ -2983,7 +2992,7 @@ void update_camera(struct Camera *c) { gLakituState.roll += sHandheldShakeRoll; gLakituState.roll += gLakituState.keyDanceRoll; } - #endif +#endif gLakituState.lastFrameAction = sMarioCamState->action; } @@ -3246,9 +3255,11 @@ void zoom_out_if_paused_and_outside(struct GraphNodeCamera *camera) { camera->focus[2] = gCamera->areaCenZ; vec3f_get_yaw(camera->focus, sMarioCamState->pos, &yaw); vec3f_set_dist_and_angle(sMarioCamState->pos, camera->pos, 6000.f, 0x1000, yaw); +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS if (gCurrLevelNum != LEVEL_THI) { find_in_bounds_yaw_wdw_bob_thi(camera->pos, camera->focus, 0); } +#endif } } else { sFramesPaused++; @@ -4926,11 +4937,11 @@ void check_blocking_area_processing(const u8 *mode) { *mode == CAMERA_MODE_BEHIND_MARIO || *mode == CAMERA_MODE_WATER_SURFACE) { sStatusFlags |= CAM_FLAG_BLOCK_AREA_PROCESSING; } - +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS if (gCurrLevelNum == LEVEL_DDD || gCurrLevelNum == LEVEL_WDW || gCurrLevelNum == LEVEL_COTMC) { sStatusFlags &= ~CAM_FLAG_BLOCK_AREA_PROCESSING; } - +#endif if ((*mode == CAMERA_MODE_BEHIND_MARIO && !(sMarioCamState->action & (ACT_FLAG_SWIMMING | ACT_FLAG_METAL_WATER))) || *mode == CAMERA_MODE_INSIDE_CANNON) { @@ -7358,12 +7369,14 @@ void cutscene_bowser_arena_start(struct Camera *c) { * Create the dialog box depending on which bowser fight Mario is in. */ void bowser_fight_intro_dialog(UNUSED struct Camera *c) { +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS switch (gCurrLevelNum) { case LEVEL_BOWSER_1: create_dialog_box(DIALOG_067); break; case LEVEL_BOWSER_2: create_dialog_box(DIALOG_092); break; case LEVEL_BOWSER_3: create_dialog_box(DIALOG_093); break; default: break; } +#endif } /** @@ -7640,11 +7653,12 @@ void cutscene_goto_cvar_pos(struct Camera *c, f32 goalDist, s16 goalPitch, s16 r nextPitch = goalPitch; vec3f_copy(sCutsceneVars[0].point, sCutsceneVars[3].point); sStatusFlags &= ~CAM_FLAG_SMOOTH_MOVEMENT; - +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS if (gCurrLevelNum == LEVEL_TTM) { nextYaw = atan2s(sCutsceneVars[3].point[2] - c->areaCenZ, sCutsceneVars[3].point[0] - c->areaCenX); } +#endif } else { if (c->cutscene == CUTSCENE_PREPARE_CANNON) { vec3f_get_dist_and_angle(c->pos, sCutsceneVars[0].point, &curDist, &curPitch, &curYaw); @@ -7928,14 +7942,14 @@ void cutscene_suffocation(struct Camera *c) { void cutscene_enter_pool_start(struct Camera *c) { vec3f_copy(sCutsceneVars[3].point, sMarioCamState->pos); - +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS if (gCurrLevelNum == LEVEL_CASTLE) { // entering HMC vec3f_set(sCutsceneVars[3].point, 2485.f, -1589.f, -2659.f); } if (gCurrLevelNum == LEVEL_HMC) { // entering CotMC vec3f_set(sCutsceneVars[3].point, 3350.f, -4589.f, 4800.f); } - +#endif vec3f_copy(sCutsceneVars[0].point, c->focus); } diff --git a/src/game/level_update.c b/src/game/level_update.c index 07a81885..35c1b275 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -433,7 +433,7 @@ void init_mario_after_warp(void) { play_cap_music(SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP)); } -#ifndef VERSION_JP +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS if (gCurrLevelNum == LEVEL_BOB && get_current_background_music() != SEQUENCE_ARGS(4, SEQ_LEVEL_SLIDE) && sTimerRunning) { @@ -443,7 +443,7 @@ void init_mario_after_warp(void) { if (sWarpDest.levelNum == LEVEL_CASTLE && sWarpDest.areaIdx == 1 && (sWarpDest.nodeId == 31 || sWarpDest.nodeId == 32)) play_sound(SOUND_MENU_MARIO_CASTLE_WARP, gGlobalSoundSource); -#ifndef VERSION_JP +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS if (sWarpDest.levelNum == LEVEL_CASTLE_GROUNDS && sWarpDest.areaIdx == 1 && (sWarpDest.nodeId == 7 || sWarpDest.nodeId == 10 || sWarpDest.nodeId == 20 || sWarpDest.nodeId == 30)) { @@ -573,6 +573,7 @@ s16 music_unchanged_through_warp(s16 arg) { s16 unchanged = TRUE; s16 currBgMusic; +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS if (levelNum == LEVEL_BOB && levelNum == gCurrLevelNum && destArea == gCurrAreaIndex) { currBgMusic = get_current_background_music(); if (currBgMusic == SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP | SEQ_VARIATION) @@ -580,6 +581,7 @@ s16 music_unchanged_through_warp(s16 arg) { unchanged = FALSE; } } else { +#endif u16 destParam1 = gAreas[destArea].musicParam; u16 destParam2 = gAreas[destArea].musicParam2; @@ -589,7 +591,9 @@ s16 music_unchanged_through_warp(s16 arg) { if (get_current_background_music() != destParam2) { unchanged = FALSE; } +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS } +#endif return unchanged; } @@ -969,16 +973,17 @@ void basic_update(UNUSED s16 *arg) { } s32 play_mode_normal(void) { +#ifndef DISABLE_DEMO if (gCurrDemoInput != NULL) { print_intro_text(); if (gPlayer1Controller->buttonPressed & END_DEMO) { - level_trigger_warp(gMarioState, - gCurrLevelNum == LEVEL_PSS ? WARP_OP_DEMO_END : WARP_OP_DEMO_NEXT); + level_trigger_warp(gMarioState, gCurrLevelNum == LEVEL_PSS ? WARP_OP_DEMO_END : WARP_OP_DEMO_NEXT); } else if (!gWarpTransition.isActive && sDelayedWarpOp == WARP_OP_NONE && (gPlayer1Controller->buttonPressed & START_BUTTON)) { level_trigger_warp(gMarioState, WARP_OP_DEMO_NEXT); } } +#endif warp_area(); check_instant_warp(); diff --git a/src/game/mario_actions_automatic.c b/src/game/mario_actions_automatic.c index 3d53800a..a14dfc30 100644 --- a/src/game/mario_actions_automatic.c +++ b/src/game/mario_actions_automatic.c @@ -28,15 +28,9 @@ #define HANG_LEFT_CEIL 2 void add_tree_leaf_particles(struct MarioState *m) { - f32 leafHeight; - if (m->usedObj->behavior == segmented_to_virtual(bhvTree)) { // make leaf effect spawn higher on the Shifting Sand Land palm tree - if (gCurrLevelNum == LEVEL_SSL) { - leafHeight = 250.0f; - } else { - leafHeight = 100.0f; - } + f32 leafHeight = (obj_has_model(m->usedObj, MODEL_SSL_PALM_TREE) ? 250.0f : 100.0f); if (m->pos[1] - m->floorHeight > leafHeight) { m->particleFlags |= PARTICLE_LEAF; } diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index 906894c5..31e2c793 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -950,11 +950,15 @@ s32 act_warp_door_spawn(struct MarioState *m) { m->usedObj->oInteractStatus = INT_STATUS_WARP_DOOR_PUSHED; } } else if (m->usedObj->oAction == 0) { +#ifdef DISABLE_LEVEL_SPECIFIC_CHECKS + set_mario_action(m, ACT_IDLE, 0); +#else if (gNeverEnteredCastle == TRUE && gCurrLevelNum == LEVEL_CASTLE) { set_mario_action(m, ACT_READING_AUTOMATIC_DIALOG, DIALOG_021); } else { set_mario_action(m, ACT_IDLE, 0); } +#endif } set_mario_animation(m, MARIO_ANIM_FIRST_PERSON); stop_and_set_height_to_floor(m); @@ -972,7 +976,7 @@ s32 act_emerge_from_pipe(struct MarioState *m) { marioObj->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE; play_sound_if_no_flag(m, SOUND_MARIO_YAHOO, MARIO_MARIO_SOUND_PLAYED); - +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS if (gCurrLevelNum == LEVEL_THI) { if (gCurrAreaIndex == 2) { play_sound_if_no_flag(m, SOUND_MENU_EXIT_PIPE, MARIO_ACTION_SOUND_PLAYED); @@ -980,6 +984,7 @@ s32 act_emerge_from_pipe(struct MarioState *m) { play_sound_if_no_flag(m, SOUND_MENU_ENTER_PIPE, MARIO_ACTION_SOUND_PLAYED); } } +#endif if (launch_mario_until_land(m, ACT_JUMP_LAND_STOP, MARIO_ANIM_SINGLE_JUMP, 8.0f)) { mario_set_forward_vel(m, 0.0f); diff --git a/src/game/mario_actions_submerged.c b/src/game/mario_actions_submerged.c index 712d47da..90e177b0 100644 --- a/src/game/mario_actions_submerged.c +++ b/src/game/mario_actions_submerged.c @@ -145,10 +145,11 @@ static void apply_water_current(struct MarioState *m, Vec3f step) { yawToWhirlpool -= (s16)(0x2000 * 1000.0f / (distance + 1000.0f)); if (whirlpool->strength >= 0) { +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS if (gCurrLevelNum == LEVEL_DDD && gCurrAreaIndex == 2) { whirlpoolRadius = 4000.0f; } - +#endif if (distance >= 26.0f && distance < whirlpoolRadius) { strength = whirlpool->strength * (1.0f - distance / whirlpoolRadius); } diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index dc1df145..4627e61e 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -155,6 +155,7 @@ Gfx *geo_switch_area(s32 callContext, struct GraphNode *node, UNUSED void *conte if (gMarioObject == NULL) { switchCase->selectedCase = 0; } else { +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS if (gCurrLevelNum == LEVEL_BBH) { // In BBH, check for a floor manually, since there is an intangible floor. In custom hacks this can be removed. find_room_floor(gMarioObject->oPosX, gMarioObject->oPosY, gMarioObject->oPosZ, &floor); @@ -162,7 +163,9 @@ Gfx *geo_switch_area(s32 callContext, struct GraphNode *node, UNUSED void *conte // Since no intangible floors are nearby, use Mario's floor instead. floor = gMarioState->floor; } - +#else + floor = gMarioState->floor; +#endif if (floor) { gMarioCurrentRoom = floor->room; roomCase = floor->room - 1; @@ -2458,11 +2461,11 @@ void cur_obj_spawn_star_at_y_offset(f32 targetX, f32 targetY, f32 targetZ, f32 o } // Extra functions for HackerSM64 -void obj_set_model(struct Object *obj, s32 modelID) { +void obj_set_model(struct Object *obj, ModelID16 modelID) { obj->header.gfx.sharedChild = gLoadedGraphNodes[modelID]; } -s32 obj_has_model(struct Object *obj, u16 modelID) { +s32 obj_has_model(struct Object *obj, ModelID16 modelID) { return (obj->header.gfx.sharedChild == gLoadedGraphNodes[modelID]); } diff --git a/src/game/object_helpers.h b/src/game/object_helpers.h index 83bb8dff..ca2a42c4 100644 --- a/src/game/object_helpers.h +++ b/src/game/object_helpers.h @@ -273,8 +273,8 @@ void cur_obj_spawn_loot_blue_coin(void); void cur_obj_spawn_star_at_y_offset(f32 targetX, f32 targetY, f32 targetZ, f32 offsetY); // Extra functions for HackerSM64 -void obj_set_model(struct Object *obj, s32 modelID); -s32 obj_has_model(struct Object *obj, u16 modelID); +void obj_set_model(struct Object *obj, ModelID16 modelID); +s32 obj_has_model(struct Object *obj, ModelID16 modelID); u32 obj_get_model_id(struct Object *obj); // End of HackerSM64 stuff diff --git a/src/game/puppycam2.c b/src/game/puppycam2.c index 638645c6..38e0a6a6 100644 --- a/src/game/puppycam2.c +++ b/src/game/puppycam2.c @@ -486,10 +486,11 @@ void puppycam_init(void) { gPuppyCam.targetObj2 = NULL; gPuppyCam.intendedFlags = PUPPYCAM_BEHAVIOUR_DEFAULT; - +#ifndef DISABLE_LEVEL_SPECIFIC_CHECKS if (gCurrLevelNum == LEVEL_PSS || (gCurrLevelNum == LEVEL_TTM && gCurrAreaIndex == 2) || (gCurrLevelNum == LEVEL_CCM && gCurrAreaIndex == 2)) { gPuppyCam.intendedFlags |= PUPPYCAM_BEHAVIOUR_SLIDE_CORRECTION; } +#endif gPuppyCam.flags = gPuppyCam.intendedFlags; gPuppyCam.zoom = gPuppyCam.zoomPoints[1]; gPuppyCam.zoomSet = 1;