mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 13:35:12 +00:00
Fix another ~200+ crashes that could happen from mods
This commit is contained in:
parent
d30b1e61a6
commit
8ed8fc31d2
16 changed files with 241 additions and 15 deletions
|
@ -1195,8 +1195,10 @@ static s32 bhv_cmd_load_collision_data_ext(void) {
|
|||
void stub_behavior_script_2(void) {
|
||||
}
|
||||
|
||||
#define BEHAVIOR_CMD_TABLE_MAX 66
|
||||
|
||||
typedef s32 (*BhvCommandProc)(void);
|
||||
static BhvCommandProc BehaviorCmdTable[] = {
|
||||
static BhvCommandProc BehaviorCmdTable[BEHAVIOR_CMD_TABLE_MAX] = {
|
||||
bhv_cmd_begin, //00
|
||||
bhv_cmd_delay, //01
|
||||
bhv_cmd_call, //02
|
||||
|
@ -1344,7 +1346,11 @@ cur_obj_update_begin:;
|
|||
if (!skipBehavior) {
|
||||
do {
|
||||
if (!gCurBhvCommand) { break; }
|
||||
bhvCmdProc = BehaviorCmdTable[*gCurBhvCommand >> 24];
|
||||
|
||||
u32 index = *gCurBhvCommand >> 24;
|
||||
if (index >= BEHAVIOR_CMD_TABLE_MAX) { break; }
|
||||
|
||||
bhvCmdProc = BehaviorCmdTable[index];
|
||||
bhvProcResult = bhvCmdProc();
|
||||
} while (bhvProcResult == BHV_PROC_CONTINUE);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,9 @@ void bhv_tiny_star_particles_init(void) {
|
|||
for (i = 0; i < 7; i++) {
|
||||
particle = spawn_object(o, MODEL_CARTOON_STAR, bhvWallTinyStarParticle);
|
||||
if (particle == NULL) { continue; }
|
||||
particle->oMoveAngleYaw = o->parentObj->oMoveAngleYaw + D_8032F2E4[2 * i] + 0x8000;
|
||||
if (o->parentObj) {
|
||||
particle->oMoveAngleYaw = o->parentObj->oMoveAngleYaw + D_8032F2E4[2 * i] + 0x8000;
|
||||
}
|
||||
particle->oVelY = sins(D_8032F2E4[2 * i + 1]) * 25.0f;
|
||||
particle->oForwardVel = coss(D_8032F2E4[2 * i + 1]) * 25.0f;
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ void bhv_fish_spawner_loop(void) {
|
|||
* Allows the fish to swim vertically.
|
||||
*/
|
||||
static void fish_vertical_roam(s32 speed) {
|
||||
if (!o->parentObj) { return; }
|
||||
f32 parentY = o->parentObj->oPosY;
|
||||
|
||||
// If the stage is Secret Aquarium, the fish can
|
||||
|
|
|
@ -13,6 +13,7 @@ struct ObjectHitbox sScuttlebugHitbox = {
|
|||
};
|
||||
|
||||
s32 update_angle_from_move_flags(s32 *angle) {
|
||||
if (!angle) { return 0; }
|
||||
if (o->oMoveFlags & OBJ_MOVE_HIT_WALL) {
|
||||
*angle = o->oWallAngle;
|
||||
return 1;
|
||||
|
|
|
@ -4123,6 +4123,7 @@ s32 is_within_100_units_of_mario(f32 posX, f32 posY, f32 posZ) {
|
|||
}
|
||||
|
||||
s32 set_or_approach_f32_asymptotic(f32 *dst, f32 goal, f32 scale) {
|
||||
if (!dst) { return FALSE; }
|
||||
if (sStatusFlags & CAM_FLAG_SMOOTH_MOVEMENT) {
|
||||
approach_f32_asymptotic_bool(dst, goal, scale);
|
||||
} else {
|
||||
|
@ -4141,6 +4142,7 @@ s32 set_or_approach_f32_asymptotic(f32 *dst, f32 goal, f32 scale) {
|
|||
* Edits the current value directly, returns TRUE if the target has been reached, FALSE otherwise.
|
||||
*/
|
||||
s32 approach_f32_asymptotic_bool(f32 *current, f32 target, f32 multiplier) {
|
||||
if (!current) { return FALSE; }
|
||||
if (multiplier > 1.f) {
|
||||
multiplier = 1.f;
|
||||
}
|
||||
|
@ -4166,6 +4168,7 @@ f32 approach_f32_asymptotic(f32 current, f32 target, f32 multiplier) {
|
|||
* reciprocal of what it would be in the previous two functions.
|
||||
*/
|
||||
s32 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor) {
|
||||
if (!current) { return FALSE; }
|
||||
s16 temp = *current;
|
||||
|
||||
if (divisor == 0) {
|
||||
|
@ -4232,6 +4235,7 @@ void approach_vec3s_asymptotic(Vec3s current, Vec3s target, s16 xMul, s16 yMul,
|
|||
}
|
||||
|
||||
s32 camera_approach_s16_symmetric_bool(s16 *current, s16 target, s16 increment) {
|
||||
if (!current) { return FALSE; }
|
||||
s16 dist = target - *current;
|
||||
|
||||
if (increment < 0) {
|
||||
|
@ -4284,6 +4288,7 @@ s32 camera_approach_s16_symmetric(s16 current, s16 target, s16 increment) {
|
|||
}
|
||||
|
||||
s32 set_or_approach_s16_symmetric(s16 *current, s16 target, s16 increment) {
|
||||
if (!current) { return FALSE; }
|
||||
if (sStatusFlags & CAM_FLAG_SMOOTH_MOVEMENT) {
|
||||
camera_approach_s16_symmetric_bool(current, target, increment);
|
||||
} else {
|
||||
|
@ -4302,6 +4307,7 @@ s32 set_or_approach_s16_symmetric(s16 *current, s16 target, s16 increment) {
|
|||
* It could possibly be an older version of the function
|
||||
*/
|
||||
s32 camera_approach_f32_symmetric_bool(f32 *current, f32 target, f32 increment) {
|
||||
if (!current) { return FALSE; }
|
||||
f32 dist = target - *current;
|
||||
|
||||
if (increment < 0) {
|
||||
|
@ -5098,7 +5104,8 @@ s32 trigger_cutscene_dialog(s32 trigger) {
|
|||
* Updates the camera based on which C buttons are pressed this frame
|
||||
*/
|
||||
void handle_c_button_movement(struct Camera *c) {
|
||||
s16 cSideYaw;
|
||||
if (!c) { return; }
|
||||
s16 cSideYaw = 0;
|
||||
|
||||
// Zoom in
|
||||
if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & U_CBUTTONS) {
|
||||
|
@ -5238,9 +5245,8 @@ u8 open_door_cutscene(u8 pullResult, u8 pushResult) {
|
|||
* @return the cutscene that should start, 0 if none
|
||||
*/
|
||||
u8 get_cutscene_from_mario_status(struct Camera *c) {
|
||||
UNUSED u8 unused1[4];
|
||||
if (!c) { return 0; }
|
||||
u8 cutscene = c->cutscene;
|
||||
UNUSED u8 unused2[12];
|
||||
|
||||
if (cutscene == 0) {
|
||||
// A cutscene started by an object, if any, will start if nothing else happened
|
||||
|
@ -5621,6 +5627,7 @@ static UNUSED void stop_transitional_movement(void) {
|
|||
* @return TRUE if the base pos was updated
|
||||
*/
|
||||
s32 set_camera_mode_fixed(struct Camera *c, s16 x, s16 y, s16 z) {
|
||||
if (!c) { return FALSE; }
|
||||
s32 basePosSet = FALSE;
|
||||
f32 posX = x;
|
||||
f32 posY = y;
|
||||
|
@ -5643,6 +5650,7 @@ s32 set_camera_mode_fixed(struct Camera *c, s16 x, s16 y, s16 z) {
|
|||
}
|
||||
|
||||
void set_camera_mode_8_directions(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (c->mode != CAMERA_MODE_8_DIRECTIONS) {
|
||||
c->mode = CAMERA_MODE_8_DIRECTIONS;
|
||||
sStatusFlags &= ~CAM_FLAG_SMOOTH_MOVEMENT;
|
||||
|
@ -5660,6 +5668,7 @@ void set_camera_mode_8_directions(struct Camera *c) {
|
|||
* set it to be so.
|
||||
*/
|
||||
void set_camera_mode_boss_fight(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (c->mode != CAMERA_MODE_BOSS_FIGHT) {
|
||||
transition_to_camera_mode(c, CAMERA_MODE_BOSS_FIGHT, 15);
|
||||
sModeOffsetYaw = c->nextYaw - DEGREES(45);
|
||||
|
@ -5667,6 +5676,7 @@ void set_camera_mode_boss_fight(struct Camera *c) {
|
|||
}
|
||||
|
||||
void set_camera_mode_close_cam(u8 *mode) {
|
||||
if (!mode) { return; }
|
||||
if (*mode != CAMERA_MODE_CLOSE) {
|
||||
sStatusFlags &= ~CAM_FLAG_SMOOTH_MOVEMENT;
|
||||
*mode = CAMERA_MODE_CLOSE;
|
||||
|
@ -5683,6 +5693,7 @@ void set_camera_mode_close_cam(u8 *mode) {
|
|||
* Otherwise jump to radial mode.
|
||||
*/
|
||||
void set_camera_mode_radial(struct Camera *c, s16 transitionTime) {
|
||||
if (!c) { return; }
|
||||
Vec3f focus;
|
||||
s16 yaw;
|
||||
|
||||
|
@ -5709,6 +5720,7 @@ void set_camera_mode_radial(struct Camera *c, s16 transitionTime) {
|
|||
* Start parallel tracking mode using the path `path`
|
||||
*/
|
||||
void parallel_tracking_init(struct Camera *c, struct ParallelTrackingPoint *path) {
|
||||
if (!c) { return; }
|
||||
if (c->mode != CAMERA_MODE_PARALLEL_TRACKING) {
|
||||
sParTrackPath = path;
|
||||
sParTrackIndex = 0;
|
||||
|
@ -5758,10 +5770,12 @@ void check_blocking_area_processing(const u8 *mode) {
|
|||
sStatusFlags &= ~CAM_FLAG_BLOCK_AREA_PROCESSING;
|
||||
}
|
||||
|
||||
if ((*mode == CAMERA_MODE_BEHIND_MARIO &&
|
||||
!(sMarioCamState->action & (ACT_FLAG_SWIMMING | ACT_FLAG_METAL_WATER))) ||
|
||||
*mode == CAMERA_MODE_INSIDE_CANNON) {
|
||||
sStatusFlags |= CAM_FLAG_BLOCK_AREA_PROCESSING;
|
||||
if (mode) {
|
||||
if ((*mode == CAMERA_MODE_BEHIND_MARIO &&
|
||||
!(sMarioCamState->action & (ACT_FLAG_SWIMMING | ACT_FLAG_METAL_WATER))) ||
|
||||
*mode == CAMERA_MODE_INSIDE_CANNON) {
|
||||
sStatusFlags |= CAM_FLAG_BLOCK_AREA_PROCESSING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5772,7 +5786,7 @@ BAD_RETURN(s32) cam_rr_exit_building_side(struct Camera *c) {
|
|||
|
||||
BAD_RETURN(s32) cam_rr_exit_building_top(struct Camera *c) {
|
||||
set_camera_mode_8_directions(c);
|
||||
if (c->pos[1] < 6343.f) {
|
||||
if (c && c->pos[1] < 6343.f) {
|
||||
c->pos[1] = 7543.f;
|
||||
gLakituState.goalPos[1] = c->pos[1];
|
||||
gLakituState.curPos[1] = c->pos[1];
|
||||
|
@ -5781,12 +5795,13 @@ BAD_RETURN(s32) cam_rr_exit_building_top(struct Camera *c) {
|
|||
}
|
||||
|
||||
BAD_RETURN(s32) cam_rr_enter_building_window(struct Camera *c) {
|
||||
if (c->mode != CAMERA_MODE_FIXED) {
|
||||
if (c && c->mode != CAMERA_MODE_FIXED) {
|
||||
set_camera_mode_fixed(c, -2974, 478, -3975);
|
||||
}
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_rr_enter_building(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (c->mode != CAMERA_MODE_FIXED) {
|
||||
set_camera_mode_fixed(c, -2953, 798, -3943);
|
||||
}
|
||||
|
@ -5797,6 +5812,7 @@ BAD_RETURN(s32) cam_rr_enter_building(struct Camera *c) {
|
|||
}
|
||||
|
||||
BAD_RETURN(s32) cam_rr_enter_building_side(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (c->mode != CAMERA_MODE_FIXED) {
|
||||
sStatusFlags &= ~CAM_FLAG_SMOOTH_MOVEMENT;
|
||||
c->mode = CAMERA_MODE_FIXED;
|
||||
|
@ -5808,6 +5824,7 @@ BAD_RETURN(s32) cam_rr_enter_building_side(struct Camera *c) {
|
|||
* Fix the camera in place as Mario gets exits out the MC cave into the waterfall.
|
||||
*/
|
||||
BAD_RETURN(s32) cam_cotmc_exit_waterfall(UNUSED struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
gCameraMovementFlags |= CAM_MOVE_FIX_IN_PLACE;
|
||||
}
|
||||
|
||||
|
@ -5816,6 +5833,7 @@ BAD_RETURN(s32) cam_cotmc_exit_waterfall(UNUSED struct Camera *c) {
|
|||
* Activated when Mario is walking in front of the snowman's head.
|
||||
*/
|
||||
BAD_RETURN(s32) cam_sl_snowman_head_8dir(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
sStatusFlags |= CAM_FLAG_BLOCK_AREA_PROCESSING;
|
||||
transition_to_camera_mode(c, CAMERA_MODE_8_DIRECTIONS, 60);
|
||||
s8DirModeBaseYaw = 0x1D27;
|
||||
|
@ -5826,6 +5844,7 @@ BAD_RETURN(s32) cam_sl_snowman_head_8dir(struct Camera *c) {
|
|||
* trigger.
|
||||
*/
|
||||
BAD_RETURN(s32) cam_sl_free_roam(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
transition_to_camera_mode(c, CAMERA_MODE_FREE_ROAM, 60);
|
||||
}
|
||||
|
||||
|
@ -5833,6 +5852,7 @@ BAD_RETURN(s32) cam_sl_free_roam(struct Camera *c) {
|
|||
* Warps the camera underneath the floor, used in HMC to move under the elevator platforms
|
||||
*/
|
||||
void move_camera_through_floor_while_descending(struct Camera *c, f32 height) {
|
||||
if (!c) { return; }
|
||||
UNUSED f32 pad;
|
||||
|
||||
if ((sMarioGeometry.currFloorHeight < height - 100.f)
|
||||
|
@ -5844,6 +5864,7 @@ void move_camera_through_floor_while_descending(struct Camera *c, f32 height) {
|
|||
}
|
||||
|
||||
BAD_RETURN(s32) cam_hmc_enter_maze(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
s16 pitch, yaw;
|
||||
f32 dist;
|
||||
|
||||
|
@ -5860,18 +5881,22 @@ BAD_RETURN(s32) cam_hmc_enter_maze(struct Camera *c) {
|
|||
}
|
||||
|
||||
BAD_RETURN(s32) cam_hmc_elevator_black_hole(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
move_camera_through_floor_while_descending(c, 1536.f);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_hmc_elevator_maze_emergency_exit(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
move_camera_through_floor_while_descending(c, 2355.f);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_hmc_elevator_lake(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
move_camera_through_floor_while_descending(c, 1843.f);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_hmc_elevator_maze(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
move_camera_through_floor_while_descending(c, 1843.f);
|
||||
}
|
||||
|
||||
|
@ -5879,6 +5904,7 @@ BAD_RETURN(s32) cam_hmc_elevator_maze(struct Camera *c) {
|
|||
* Starts the "Enter Pyramid Top" cutscene.
|
||||
*/
|
||||
BAD_RETURN(s32) cam_ssl_enter_pyramid_top(UNUSED struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
start_object_cutscene_without_focus(CUTSCENE_ENTER_PYRAMID_TOP);
|
||||
}
|
||||
|
||||
|
@ -5887,6 +5913,7 @@ BAD_RETURN(s32) cam_ssl_enter_pyramid_top(UNUSED struct Camera *c) {
|
|||
* radial.
|
||||
*/
|
||||
BAD_RETURN(s32) cam_ssl_pyramid_center(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
sStatusFlags |= CAM_FLAG_BLOCK_AREA_PROCESSING;
|
||||
transition_to_camera_mode(c, CAMERA_MODE_CLOSE, 90);
|
||||
}
|
||||
|
@ -5895,6 +5922,7 @@ BAD_RETURN(s32) cam_ssl_pyramid_center(struct Camera *c) {
|
|||
* Changes the mode back to outward radial in the boss room inside the pyramid.
|
||||
*/
|
||||
BAD_RETURN(s32) cam_ssl_boss_room(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
sStatusFlags |= CAM_FLAG_BLOCK_AREA_PROCESSING;
|
||||
transition_to_camera_mode(c, CAMERA_MODE_OUTWARD_RADIAL, 90);
|
||||
}
|
||||
|
@ -5903,6 +5931,7 @@ BAD_RETURN(s32) cam_ssl_boss_room(struct Camera *c) {
|
|||
* Moves the camera to through the tunnel by forcing sModeOffsetYaw
|
||||
*/
|
||||
BAD_RETURN(s32) cam_thi_move_cam_through_tunnel(UNUSED struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (sModeOffsetYaw < DEGREES(60)) {
|
||||
sModeOffsetYaw = DEGREES(60);
|
||||
}
|
||||
|
@ -5912,6 +5941,7 @@ BAD_RETURN(s32) cam_thi_move_cam_through_tunnel(UNUSED struct Camera *c) {
|
|||
* Aligns the camera to look through the tunnel
|
||||
*/
|
||||
BAD_RETURN(s32) cam_thi_look_through_tunnel(UNUSED struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
// ~82.5 degrees
|
||||
if (sModeOffsetYaw > 0x3AAA) {
|
||||
sModeOffsetYaw = 0x3AAA;
|
||||
|
@ -5924,6 +5954,7 @@ BAD_RETURN(s32) cam_thi_look_through_tunnel(UNUSED struct Camera *c) {
|
|||
* @see sCamBOB for bounds.
|
||||
*/
|
||||
BAD_RETURN(s32) cam_bob_tower(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
sStatusFlags |= CAM_FLAG_BLOCK_AREA_PROCESSING;
|
||||
transition_to_camera_mode(c, CAMERA_MODE_RADIAL, 90);
|
||||
}
|
||||
|
@ -5937,6 +5968,7 @@ BAD_RETURN(s32) cam_bob_tower(struct Camera *c) {
|
|||
* @see sCamBOB
|
||||
*/
|
||||
BAD_RETURN(s32) cam_bob_default_free_roam(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
transition_to_camera_mode(c, CAMERA_MODE_FREE_ROAM, 90);
|
||||
}
|
||||
|
||||
|
@ -5945,6 +5977,7 @@ BAD_RETURN(s32) cam_bob_default_free_roam(struct Camera *c) {
|
|||
* Used in both the castle and HMC.
|
||||
*/
|
||||
BAD_RETURN(s32) cam_castle_hmc_start_pool_cutscene(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if ((sMarioCamState->action != ACT_SPECIAL_DEATH_EXIT)
|
||||
&& (sMarioCamState->action != ACT_SPECIAL_EXIT_AIRBORNE)) {
|
||||
start_cutscene(c, CUTSCENE_ENTER_POOL);
|
||||
|
@ -5956,6 +5989,7 @@ BAD_RETURN(s32) cam_castle_hmc_start_pool_cutscene(struct Camera *c) {
|
|||
* to the castle lobby
|
||||
*/
|
||||
BAD_RETURN(s32) cam_castle_lobby_entrance(UNUSED struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
vec3f_set(sCastleEntranceOffset, -813.f - sFixedModeBasePosition[0],
|
||||
378.f - sFixedModeBasePosition[1], 1103.f - sFixedModeBasePosition[2]);
|
||||
}
|
||||
|
@ -5964,6 +5998,7 @@ BAD_RETURN(s32) cam_castle_lobby_entrance(UNUSED struct Camera *c) {
|
|||
* Make the camera look up the stairs from the 2nd to 3rd floor of the castle
|
||||
*/
|
||||
BAD_RETURN(s32) cam_castle_look_upstairs(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
struct Surface *floor;
|
||||
f32 floorHeight = find_floor(c->pos[0], c->pos[1], c->pos[2], &floor);
|
||||
|
||||
|
@ -5978,6 +6013,7 @@ BAD_RETURN(s32) cam_castle_look_upstairs(struct Camera *c) {
|
|||
* Make the camera look down the stairs towards the basement star door
|
||||
*/
|
||||
BAD_RETURN(s32) cam_castle_basement_look_downstairs(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
struct Surface *floor;
|
||||
f32 floorHeight = find_floor(c->pos[0], c->pos[1], c->pos[2], &floor);
|
||||
|
||||
|
@ -5992,6 +6028,7 @@ BAD_RETURN(s32) cam_castle_basement_look_downstairs(struct Camera *c) {
|
|||
* changes to fixed mode.
|
||||
*/
|
||||
BAD_RETURN(s32) cam_castle_enter_lobby(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (c->mode != CAMERA_MODE_FIXED) {
|
||||
sStatusFlags &= ~CAM_FLAG_SMOOTH_MOVEMENT;
|
||||
set_fixed_cam_axis_sa_lobby(c->mode);
|
||||
|
@ -6004,6 +6041,7 @@ BAD_RETURN(s32) cam_castle_enter_lobby(struct Camera *c) {
|
|||
* Starts spiral stairs mode.
|
||||
*/
|
||||
BAD_RETURN(s32) cam_castle_enter_spiral_stairs(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
transition_to_camera_mode(c, CAMERA_MODE_SPIRAL_STAIRS, 20);
|
||||
}
|
||||
|
||||
|
@ -6012,6 +6050,7 @@ BAD_RETURN(s32) cam_castle_enter_spiral_stairs(struct Camera *c) {
|
|||
* This was replaced with cam_castle_close_mode
|
||||
*/
|
||||
static UNUSED BAD_RETURN(s32) cam_castle_leave_spiral_stairs(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (c->mode == CAMERA_MODE_SPIRAL_STAIRS) {
|
||||
transition_to_camera_mode(c, CAMERA_MODE_CLOSE, 30);
|
||||
} else {
|
||||
|
@ -6024,6 +6063,7 @@ static UNUSED BAD_RETURN(s32) cam_castle_leave_spiral_stairs(struct Camera *c) {
|
|||
* every door leaving the lobby and spiral staircase.
|
||||
*/
|
||||
BAD_RETURN(s32) cam_castle_close_mode(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
set_camera_mode_close_cam(&c->mode);
|
||||
}
|
||||
|
||||
|
@ -6032,6 +6072,7 @@ BAD_RETURN(s32) cam_castle_close_mode(struct Camera *c) {
|
|||
* fixed-mode when Mario leaves the room.
|
||||
*/
|
||||
BAD_RETURN(s32) cam_castle_leave_lobby_sliding_door(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
cam_castle_close_mode(c);
|
||||
c->doorStatus = DOOR_ENTER_LOBBY;
|
||||
}
|
||||
|
@ -6040,18 +6081,22 @@ BAD_RETURN(s32) cam_castle_leave_lobby_sliding_door(struct Camera *c) {
|
|||
* Just calls cam_castle_enter_lobby
|
||||
*/
|
||||
BAD_RETURN(s32) cam_castle_enter_lobby_sliding_door(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
cam_castle_enter_lobby(c);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_6(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
parallel_tracking_init(c, sBBHLibraryParTrackPath);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_fall_off_roof(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
set_camera_mode_close_cam(&c->mode);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_fall_into_pool(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
Vec3f dir;
|
||||
set_camera_mode_close_cam(&c->mode);
|
||||
vec3f_set(dir, 0.f, 0.f, 300.f);
|
||||
|
@ -6062,23 +6107,28 @@ BAD_RETURN(s32) cam_bbh_fall_into_pool(struct Camera *c) {
|
|||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_1(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
set_camera_mode_fixed(c, 956, 440, 1994);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_leave_front_door(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
c->doorStatus = DOOR_LEAVING_SPECIAL;
|
||||
cam_bbh_room_1(c);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_2_lower(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
set_camera_mode_fixed(c, 2591, 400, 1284);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_4(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
set_camera_mode_fixed(c, 3529, 340, -1384);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_8(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
set_camera_mode_fixed(c, -500, 740, -1306);
|
||||
}
|
||||
|
||||
|
@ -6087,6 +6137,7 @@ BAD_RETURN(s32) cam_bbh_room_8(struct Camera *c) {
|
|||
* set the camera mode to fixed and position to (-2172, 200, 675)
|
||||
*/
|
||||
BAD_RETURN(s32) cam_bbh_room_5_library(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
set_camera_mode_fixed(c, -2172, 200, 675);
|
||||
}
|
||||
|
||||
|
@ -6096,52 +6147,62 @@ BAD_RETURN(s32) cam_bbh_room_5_library(struct Camera *c) {
|
|||
* if coming from the library.
|
||||
*/
|
||||
BAD_RETURN(s32) cam_bbh_room_5_library_to_hidden_transition(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (set_camera_mode_fixed(c, -2172, 200, 675) == 1) {
|
||||
transition_next_state(c, 20);
|
||||
}
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_5_hidden_to_library_transition(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (set_camera_mode_fixed(c, -1542, 320, -307) == 1) {
|
||||
transition_next_state(c, 20);
|
||||
}
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_5_hidden(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
c->doorStatus = DOOR_LEAVING_SPECIAL;
|
||||
set_camera_mode_fixed(c, -1542, 320, -307);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_3(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
set_camera_mode_fixed(c, -1893, 320, 2327);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_7_mr_i(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
set_camera_mode_fixed(c, 1371, 360, -1302);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_7_mr_i_to_coffins_transition(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (set_camera_mode_fixed(c, 1371, 360, -1302) == 1) {
|
||||
transition_next_state(c, 20);
|
||||
}
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_7_coffins_to_mr_i_transition(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (set_camera_mode_fixed(c, 2115, 260, -772) == 1) {
|
||||
transition_next_state(c, 20);
|
||||
}
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_elevator_room_lower(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
c->doorStatus = DOOR_LEAVING_SPECIAL;
|
||||
set_camera_mode_close_cam(&c->mode);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_0_back_entrance(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
set_camera_mode_close_cam(&c->mode);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_elevator(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (c->mode == CAMERA_MODE_FIXED) {
|
||||
set_camera_mode_close_cam(&c->mode);
|
||||
c->pos[1] = -405.f;
|
||||
|
@ -6150,55 +6211,66 @@ BAD_RETURN(s32) cam_bbh_elevator(struct Camera *c) {
|
|||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_12_upper(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
c->doorStatus = DOOR_LEAVING_SPECIAL;
|
||||
set_camera_mode_fixed(c, -2932, 296, 4429);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_enter_front_door(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
set_camera_mode_close_cam(&c->mode);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_2_library(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
set_camera_mode_fixed(c, 3493, 440, 617);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_2_library_to_trapdoor_transition(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (set_camera_mode_fixed(c, 3493, 440, 617) == 1) {
|
||||
transition_next_state(c, 20);
|
||||
}
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_2_trapdoor(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
set_camera_mode_fixed(c, 3502, 440, 1217);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_2_trapdoor_transition(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (set_camera_mode_fixed(c, 3502, 440, 1217) == 1) {
|
||||
transition_next_state(c, 20);
|
||||
}
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_9_attic(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
set_camera_mode_fixed(c, -670, 460, 372);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_9_attic_transition(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (set_camera_mode_fixed(c, -670, 460, 372) == 1) {
|
||||
transition_next_state(c, 20);
|
||||
}
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_9_mr_i_transition(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
if (set_camera_mode_fixed(c, 131, 380, -263) == 1) {
|
||||
transition_next_state(c, 20);
|
||||
}
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_13_balcony(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
set_camera_mode_fixed(c, 210, 420, 3109);
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) cam_bbh_room_0(struct Camera *c) {
|
||||
if (!c) { return; }
|
||||
c->doorStatus = DOOR_LEAVING_SPECIAL;
|
||||
set_camera_mode_fixed(c, -204, 807, 204);
|
||||
}
|
||||
|
@ -6215,6 +6287,7 @@ BAD_RETURN(s32) cam_ccm_leave_slide_shortcut(UNUSED struct Camera *c) {
|
|||
* Apply any modes that are triggered by special floor surface types
|
||||
*/
|
||||
u32 surface_type_modes(struct Camera *c) {
|
||||
if (!c) { return 0; }
|
||||
u32 modeChanged = 0;
|
||||
|
||||
switch (sMarioGeometry.currFloorType) {
|
||||
|
@ -6650,6 +6723,7 @@ static struct CameraTrigger* get_camera_trigger(s16 levelNum) {
|
|||
* @return the camera's mode after processing, although this is unused in the code
|
||||
*/
|
||||
s16 camera_course_processing(struct Camera *c) {
|
||||
if (!c) { return 0; }
|
||||
if (!gCameraUseCourseSpecificSettings) { return 0; }
|
||||
s16 level = gCurrLevelNum;
|
||||
s16 mode;
|
||||
|
@ -6977,7 +7051,8 @@ s32 rotate_camera_around_walls(struct Camera *c, Vec3f cPos, s16 *avoidYaw, s16
|
|||
* Note: Also finds the water level, but waterHeight is unused
|
||||
*/
|
||||
void find_mario_floor_and_ceil(struct PlayerGeometry *pg) {
|
||||
struct Surface *surf;
|
||||
if (!pg) { return; }
|
||||
struct Surface *surf = NULL;
|
||||
s16 tempCheckingSurfaceCollisionsForCamera = gCheckingSurfaceCollisionsForCamera;
|
||||
gCheckingSurfaceCollisionsForCamera = TRUE;
|
||||
|
||||
|
|
|
@ -322,6 +322,7 @@ void mario_grab_used_object(struct MarioState *m) {
|
|||
}
|
||||
|
||||
void mario_drop_held_object(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
if (m->playerIndex != 0) { return; }
|
||||
|
||||
if (m->heldObj != NULL) {
|
||||
|
@ -351,6 +352,7 @@ void mario_drop_held_object(struct MarioState *m) {
|
|||
}
|
||||
|
||||
void mario_throw_held_object(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
if (m->playerIndex != 0) { return; }
|
||||
|
||||
if (m->heldObj != NULL) {
|
||||
|
@ -377,6 +379,7 @@ void mario_throw_held_object(struct MarioState *m) {
|
|||
}
|
||||
|
||||
void mario_stop_riding_and_holding(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
mario_drop_held_object(m);
|
||||
mario_stop_riding_object(m);
|
||||
|
||||
|
@ -387,10 +390,12 @@ void mario_stop_riding_and_holding(struct MarioState *m) {
|
|||
}
|
||||
|
||||
u32 does_mario_have_normal_cap_on_head(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
return (m->flags & (MARIO_CAPS | MARIO_CAP_ON_HEAD)) == (MARIO_NORMAL_CAP | MARIO_CAP_ON_HEAD);
|
||||
}
|
||||
|
||||
void mario_blow_off_cap(struct MarioState *m, f32 capSpeed) {
|
||||
if (!m) { return; }
|
||||
if (m->playerIndex != 0) { return; }
|
||||
struct Object *capObject;
|
||||
|
||||
|
@ -423,6 +428,7 @@ void mario_blow_off_cap(struct MarioState *m, f32 capSpeed) {
|
|||
}
|
||||
|
||||
u32 mario_lose_cap_to_enemy(struct MarioState* m, u32 arg) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->playerIndex != 0) { return FALSE; }
|
||||
u32 wasWearingCap = FALSE;
|
||||
|
||||
|
@ -436,6 +442,7 @@ u32 mario_lose_cap_to_enemy(struct MarioState* m, u32 arg) {
|
|||
}
|
||||
|
||||
void mario_retrieve_cap(struct MarioState* m) {
|
||||
if (!m) { return; }
|
||||
mario_drop_held_object(m);
|
||||
save_file_clear_flags(SAVE_FLAG_CAP_ON_KLEPTO | SAVE_FLAG_CAP_ON_UKIKI);
|
||||
m->flags &= ~MARIO_CAP_ON_HEAD;
|
||||
|
@ -443,6 +450,7 @@ void mario_retrieve_cap(struct MarioState* m) {
|
|||
}
|
||||
|
||||
u32 able_to_grab_object(struct MarioState *m, UNUSED struct Object *o) {
|
||||
if (!m || !o) { return FALSE; }
|
||||
u32 action = m->action;
|
||||
|
||||
if (action == ACT_DIVE_SLIDE || action == ACT_DIVE) {
|
||||
|
|
|
@ -84,6 +84,7 @@ s32 is_anim_past_end(struct MarioState *m) {
|
|||
* Sets Mario's animation without any acceleration, running at its default rate.
|
||||
*/
|
||||
s16 set_mario_animation(struct MarioState *m, s32 targetAnimID) {
|
||||
if (!m) { return 0; }
|
||||
struct Object *o = m->marioObj;
|
||||
if (!o || !m->animation) { return 0; }
|
||||
struct Animation *targetAnim = m->animation->targetAnim;
|
||||
|
@ -298,6 +299,7 @@ void play_mario_jump_sound(struct MarioState *m) {
|
|||
* Adjusts the volume/pitch of sounds from Mario's speed.
|
||||
*/
|
||||
void adjust_sound_for_speed(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
s32 absForwardVel = (m->forwardVel > 0.0f) ? m->forwardVel : -m->forwardVel;
|
||||
set_sound_moving_speed(SOUND_BANK_MOVING, (absForwardVel > 100) ? 100 : absForwardVel);
|
||||
}
|
||||
|
@ -306,6 +308,7 @@ void adjust_sound_for_speed(struct MarioState *m) {
|
|||
* Spawns particles if the step sound says to, then either plays a step sound or relevant other sound.
|
||||
*/
|
||||
void play_sound_and_spawn_particles(struct MarioState *m, u32 soundBits, u32 waveParticleType) {
|
||||
if (!m) { return; }
|
||||
if (m->terrainSoundAddend == (SOUND_TERRAIN_WATER << 16)) {
|
||||
if (waveParticleType != 0) {
|
||||
set_mario_particle_flags(m, PARTICLE_SHALLOW_WATER_SPLASH, FALSE);
|
||||
|
@ -336,6 +339,7 @@ void play_sound_and_spawn_particles(struct MarioState *m, u32 soundBits, u32 wav
|
|||
* Plays an environmental sound if one has not been played since the last action change.
|
||||
*/
|
||||
void play_mario_action_sound(struct MarioState *m, u32 soundBits, u32 waveParticleType) {
|
||||
if (!m) { return; }
|
||||
if (!(m->flags & MARIO_ACTION_SOUND_PLAYED)) {
|
||||
play_sound_and_spawn_particles(m, soundBits, waveParticleType);
|
||||
m->flags |= MARIO_ACTION_SOUND_PLAYED;
|
||||
|
@ -346,6 +350,7 @@ void play_mario_action_sound(struct MarioState *m, u32 soundBits, u32 wavePartic
|
|||
* Plays a landing sound, accounting for metal cap.
|
||||
*/
|
||||
void play_mario_landing_sound(struct MarioState *m, u32 soundBits) {
|
||||
if (!m) { return; }
|
||||
play_sound_and_spawn_particles(
|
||||
m, (m->flags & MARIO_METAL_CAP) ? SOUND_ACTION_METAL_LANDING : soundBits, 1);
|
||||
}
|
||||
|
@ -356,6 +361,7 @@ void play_mario_landing_sound(struct MarioState *m, u32 soundBits) {
|
|||
* played once per action.
|
||||
*/
|
||||
void play_mario_landing_sound_once(struct MarioState *m, u32 soundBits) {
|
||||
if (!m) { return; }
|
||||
play_mario_action_sound(
|
||||
m, (m->flags & MARIO_METAL_CAP) ? SOUND_ACTION_METAL_LANDING : soundBits, 1);
|
||||
}
|
||||
|
@ -364,6 +370,7 @@ void play_mario_landing_sound_once(struct MarioState *m, u32 soundBits) {
|
|||
* Plays a heavy landing (ground pound, etc.) sound, accounting for metal cap.
|
||||
*/
|
||||
void play_mario_heavy_landing_sound(struct MarioState *m, u32 soundBits) {
|
||||
if (!m) { return; }
|
||||
play_sound_and_spawn_particles(
|
||||
m, (m->flags & MARIO_METAL_CAP) ? SOUND_ACTION_METAL_HEAVY_LANDING : soundBits, 1);
|
||||
}
|
||||
|
@ -374,6 +381,7 @@ void play_mario_heavy_landing_sound(struct MarioState *m, u32 soundBits) {
|
|||
* making sure the sound is only played once per action.
|
||||
*/
|
||||
void play_mario_heavy_landing_sound_once(struct MarioState *m, u32 soundBits) {
|
||||
if (!m) { return; }
|
||||
play_mario_action_sound(
|
||||
m, (m->flags & MARIO_METAL_CAP) ? SOUND_ACTION_METAL_HEAVY_LANDING : soundBits, 1);
|
||||
}
|
||||
|
@ -382,6 +390,7 @@ void play_mario_heavy_landing_sound_once(struct MarioState *m, u32 soundBits) {
|
|||
* Plays action and Mario sounds relevant to what was passed into the function.
|
||||
*/
|
||||
void play_mario_sound(struct MarioState *m, s32 actionSound, s32 marioSound) {
|
||||
if (!m) { return; }
|
||||
if (actionSound == SOUND_ACTION_TERRAIN_JUMP) {
|
||||
play_mario_action_sound(m, (m->flags & MARIO_METAL_CAP) ? (s32) SOUND_ACTION_METAL_JUMP
|
||||
: (s32) SOUND_ACTION_TERRAIN_JUMP, 1);
|
||||
|
@ -403,6 +412,7 @@ void play_mario_sound(struct MarioState *m, s32 actionSound, s32 marioSound) {
|
|||
**************************************************/
|
||||
|
||||
bool mario_can_bubble(struct MarioState* m) {
|
||||
if (!m) { return false; }
|
||||
if (!gServerSettings.bubbleDeath) { return false; }
|
||||
if (m->playerIndex != 0) { return false; }
|
||||
if (m->action == ACT_BUBBLED) { return false; }
|
||||
|
@ -422,6 +432,7 @@ bool mario_can_bubble(struct MarioState* m) {
|
|||
}
|
||||
|
||||
void mario_set_bubbled(struct MarioState* m) {
|
||||
if (!m) { return; }
|
||||
if (m->playerIndex != 0) { return; }
|
||||
if (m->action == ACT_BUBBLED) { return; }
|
||||
|
||||
|
@ -450,6 +461,7 @@ void mario_set_bubbled(struct MarioState* m) {
|
|||
* Sets Mario's other velocities from his forward speed.
|
||||
*/
|
||||
void mario_set_forward_vel(struct MarioState *m, f32 forwardVel) {
|
||||
if (!m) { return; }
|
||||
m->forwardVel = forwardVel;
|
||||
|
||||
m->slideVelX = sins(m->faceAngle[1]) * m->forwardVel;
|
||||
|
@ -463,6 +475,7 @@ void mario_set_forward_vel(struct MarioState *m, f32 forwardVel) {
|
|||
* Returns the slipperiness class of Mario's floor.
|
||||
*/
|
||||
s32 mario_get_floor_class(struct MarioState *m) {
|
||||
if (!m) { return SURFACE_CLASS_NOT_SLIPPERY; }
|
||||
s32 floorClass;
|
||||
|
||||
// The slide terrain type defaults to slide slipperiness.
|
||||
|
@ -535,6 +548,7 @@ s8 sTerrainSounds[7][6] = {
|
|||
* This depends on surfaces and terrain.
|
||||
*/
|
||||
u32 mario_get_terrain_sound_addend(struct MarioState *m) {
|
||||
if (!m) { return SURFACE_CLASS_NOT_SLIPPERY; }
|
||||
s16 floorSoundType;
|
||||
s16 terrainType = m->area->terrainType & TERRAIN_MASK;
|
||||
s32 ret = SOUND_TERRAIN_DEFAULT << 16;
|
||||
|
@ -782,6 +796,7 @@ s32 mario_floor_is_steep(struct MarioState *m) {
|
|||
* Finds the floor height relative from Mario given polar displacement.
|
||||
*/
|
||||
f32 find_floor_height_relative_polar(struct MarioState *m, s16 angleFromMario, f32 distFromMario) {
|
||||
if (!m) { return 0; }
|
||||
struct Surface *floor;
|
||||
f32 floorY;
|
||||
|
||||
|
@ -797,6 +812,7 @@ f32 find_floor_height_relative_polar(struct MarioState *m, s16 angleFromMario, f
|
|||
* Returns the slope of the floor based off points around Mario.
|
||||
*/
|
||||
s16 find_floor_slope(struct MarioState *m, s16 yawOffset) {
|
||||
if (!m) { return 0; }
|
||||
struct Surface *floor;
|
||||
f32 forwardFloorY, backwardFloorY;
|
||||
f32 forwardYDelta, backwardYDelta;
|
||||
|
@ -826,6 +842,8 @@ s16 find_floor_slope(struct MarioState *m, s16 yawOffset) {
|
|||
* Adjusts Mario's camera and sound based on his action status.
|
||||
*/
|
||||
void update_mario_sound_and_camera(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
|
||||
// only update for local player
|
||||
if (m != &gMarioStates[0]) { return; }
|
||||
|
||||
|
@ -858,6 +876,7 @@ void update_mario_sound_and_camera(struct MarioState *m) {
|
|||
* Transitions Mario to a steep jump action.
|
||||
*/
|
||||
void set_steep_jump_action(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
m->marioObj->oMarioSteepJumpYaw = m->faceAngle[1];
|
||||
|
||||
if (m->forwardVel > 0.0f) {
|
||||
|
@ -880,6 +899,7 @@ void set_steep_jump_action(struct MarioState *m) {
|
|||
* Sets Mario's vertical speed from his forward speed.
|
||||
*/
|
||||
void set_mario_y_vel_based_on_fspeed(struct MarioState *m, f32 initialVelY, f32 multiplier) {
|
||||
if (!m) { return; }
|
||||
// get_additive_y_vel_for_jumps is always 0 and a stubbed function.
|
||||
// It was likely trampoline related based on code location.
|
||||
m->vel[1] = initialVelY + get_additive_y_vel_for_jumps() + m->forwardVel * multiplier;
|
||||
|
@ -1096,6 +1116,7 @@ static u32 set_mario_action_cutscene(struct MarioState *m, u32 action, UNUSED u3
|
|||
* specific function if needed.
|
||||
*/
|
||||
u32 set_mario_action(struct MarioState *m, u32 action, u32 actionArg) {
|
||||
if (!m) { return FALSE; }
|
||||
u32 returnValue = 0;
|
||||
smlua_call_event_hooks_mario_action_params_ret_int(HOOK_BEFORE_SET_MARIO_ACTION, m, action, &returnValue);
|
||||
if (returnValue == 1) { return TRUE; } else if (returnValue) { action = returnValue; }
|
||||
|
@ -1141,6 +1162,7 @@ u32 set_mario_action(struct MarioState *m, u32 action, u32 actionArg) {
|
|||
* Puts Mario into a specific jumping action from a landing action.
|
||||
*/
|
||||
s32 set_jump_from_landing(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->quicksandDepth >= 11.0f) {
|
||||
if (m->heldObj == NULL) {
|
||||
return set_mario_action(m, ACT_QUICKSAND_JUMP_LAND, 0);
|
||||
|
@ -1197,6 +1219,7 @@ s32 set_jump_from_landing(struct MarioState *m) {
|
|||
* either a quicksand or steep jump.
|
||||
*/
|
||||
s32 set_jumping_action(struct MarioState *m, u32 action, u32 actionArg) {
|
||||
if (!m) { return FALSE; }
|
||||
UNUSED u32 currAction = m->action;
|
||||
|
||||
if (m->quicksandDepth >= 11.0f) {
|
||||
|
@ -1221,6 +1244,7 @@ s32 set_jumping_action(struct MarioState *m, u32 action, u32 actionArg) {
|
|||
* Drop anything Mario is holding and set a new action.
|
||||
*/
|
||||
s32 drop_and_set_mario_action(struct MarioState *m, u32 action, u32 actionArg) {
|
||||
if (!m) { return FALSE; }
|
||||
mario_stop_riding_and_holding(m);
|
||||
|
||||
return set_mario_action(m, action, actionArg);
|
||||
|
@ -1230,6 +1254,7 @@ s32 drop_and_set_mario_action(struct MarioState *m, u32 action, u32 actionArg) {
|
|||
* Increment Mario's hurt counter and set a new action.
|
||||
*/
|
||||
s32 hurt_and_set_mario_action(struct MarioState *m, u32 action, u32 actionArg, s16 hurtCounter) {
|
||||
if (!m) { return FALSE; }
|
||||
m->hurtCounter = hurtCounter;
|
||||
|
||||
return set_mario_action(m, action, actionArg);
|
||||
|
@ -1240,6 +1265,7 @@ s32 hurt_and_set_mario_action(struct MarioState *m, u32 action, u32 actionArg, s
|
|||
* actions. A common variant of the below function.
|
||||
*/
|
||||
s32 check_common_action_exits(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->input & INPUT_A_PRESSED) {
|
||||
return set_mario_action(m, ACT_JUMP, 0);
|
||||
}
|
||||
|
@ -1261,6 +1287,7 @@ s32 check_common_action_exits(struct MarioState *m) {
|
|||
* object holding actions. A holding variant of the above function.
|
||||
*/
|
||||
s32 check_common_hold_action_exits(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->input & INPUT_A_PRESSED) {
|
||||
return set_mario_action(m, ACT_HOLD_JUMP, 0);
|
||||
}
|
||||
|
@ -1281,6 +1308,7 @@ s32 check_common_hold_action_exits(struct MarioState *m) {
|
|||
* Transitions Mario from a submerged action to a walking action.
|
||||
*/
|
||||
s32 transition_submerged_to_walking(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->playerIndex == 0) {
|
||||
set_camera_mode(m->area->camera, m->area->camera->defMode, 1);
|
||||
}
|
||||
|
@ -1299,6 +1327,7 @@ s32 transition_submerged_to_walking(struct MarioState *m) {
|
|||
* non-submerged action. This also applies the water surface camera preset.
|
||||
*/
|
||||
s32 set_water_plunge_action(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->action == ACT_BUBBLED) { return FALSE; }
|
||||
if (m->action == ACT_IN_CANNON) { return FALSE; }
|
||||
|
||||
|
@ -1333,6 +1362,7 @@ u8 sSquishScaleOverTime[16] = { 0x46, 0x32, 0x32, 0x3C, 0x46, 0x50, 0x50, 0x3C,
|
|||
* Applies the squish to Mario's model via scaling.
|
||||
*/
|
||||
void squish_mario_model(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
if (m->squishTimer == 0xFF && m->bounceSquishTimer == 0) { return; }
|
||||
|
||||
// If no longer squished, scale back to default.
|
||||
|
@ -1362,6 +1392,7 @@ void squish_mario_model(struct MarioState *m) {
|
|||
* Debug function that prints floor normal, velocity, and action information.
|
||||
*/
|
||||
void debug_print_speed_action_normal(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
f32 steepness;
|
||||
f32 floor_nY;
|
||||
|
||||
|
@ -1383,6 +1414,8 @@ void debug_print_speed_action_normal(struct MarioState *m) {
|
|||
* Update the button inputs for Mario.
|
||||
*/
|
||||
void update_mario_button_inputs(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
|
||||
// don't update remote inputs
|
||||
if (m->playerIndex != 0) { return; }
|
||||
|
||||
|
|
|
@ -2198,6 +2198,7 @@ s32 check_common_airborne_cancels(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 mario_execute_airborne_action(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
u32 cancel;
|
||||
|
||||
if (check_common_airborne_cancels(m)) {
|
||||
|
|
|
@ -323,6 +323,7 @@ s32 act_top_of_pole(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos) {
|
||||
if (!m) { return 0; }
|
||||
UNUSED s32 unused;
|
||||
struct Surface *ceil;
|
||||
struct Surface *floor;
|
||||
|
@ -1075,6 +1076,7 @@ s32 check_common_automatic_cancels(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 mario_execute_automatic_action(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 cancel;
|
||||
|
||||
if (check_common_automatic_cancels(m)) {
|
||||
|
|
|
@ -91,6 +91,7 @@ static Vec4s sJumboStarKeyframes[27] = {
|
|||
* that's the end of the string.
|
||||
*/
|
||||
s32 get_credits_str_width(char *str) {
|
||||
if (!str) { return 0; }
|
||||
u32 c;
|
||||
s32 length = 0;
|
||||
|
||||
|
@ -240,6 +241,7 @@ static void stub_is_textbox_active(u16 *a0) {
|
|||
* numStars has reached a milestone and prevNumStarsForDialog has not reached it.
|
||||
*/
|
||||
s32 get_star_collection_dialog(struct MarioState *m) {
|
||||
if (!m) { return 0; }
|
||||
s32 dialogID = 0;
|
||||
|
||||
if (smlua_call_event_hooks_ret_int(HOOK_GET_STAR_COLLECTION_DIALOG, &dialogID)) {
|
||||
|
@ -272,6 +274,8 @@ s32 get_star_collection_dialog(struct MarioState *m) {
|
|||
|
||||
// save menu handler
|
||||
void handle_save_menu(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
|
||||
// wait for the menu to show up
|
||||
if (is_anim_past_end(m) && gSaveOptSelectIndex != 0) {
|
||||
// save and continue / save and quit
|
||||
|
@ -310,6 +314,7 @@ void handle_save_menu(struct MarioState *m) {
|
|||
* and yaw plus relative yaw.
|
||||
*/
|
||||
struct Object *spawn_obj_at_mario_rel_yaw(struct MarioState *m, s32 model, const BehaviorScript *behavior, s16 relYaw) {
|
||||
if (!m || !behavior) { return NULL; }
|
||||
struct Object *o = spawn_object(m->marioObj, model, behavior);
|
||||
if (o == NULL) { return NULL; }
|
||||
|
||||
|
@ -327,6 +332,7 @@ struct Object *spawn_obj_at_mario_rel_yaw(struct MarioState *m, s32 model, const
|
|||
* SOUND_ACTION_UNKNOWN43D.
|
||||
*/
|
||||
void cutscene_take_cap_off(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
m->flags &= ~MARIO_CAP_ON_HEAD;
|
||||
m->flags |= MARIO_CAP_IN_HAND;
|
||||
play_sound(SOUND_ACTION_UNKNOWN43D, m->marioObj->header.gfx.cameraToObject);
|
||||
|
@ -338,6 +344,7 @@ void cutscene_take_cap_off(struct MarioState *m) {
|
|||
* SOUND_ACTION_UNKNOWN43E.
|
||||
*/
|
||||
void cutscene_put_cap_on(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
m->flags &= ~MARIO_CAP_IN_HAND;
|
||||
m->flags |= MARIO_CAP_ON_HEAD;
|
||||
play_sound(SOUND_ACTION_UNKNOWN43E, m->marioObj->header.gfx.cameraToObject);
|
||||
|
@ -353,6 +360,7 @@ void cutscene_put_cap_on(struct MarioState *m) {
|
|||
* 3: Mario must not be in first person mode.
|
||||
*/
|
||||
s32 mario_ready_to_speak(struct MarioState* m) {
|
||||
if (!m) { return FALSE; }
|
||||
u32 actionGroup = m->action & ACT_GROUP_MASK;
|
||||
s32 isReadyToSpeak = FALSE;
|
||||
|
||||
|
@ -367,6 +375,7 @@ s32 mario_ready_to_speak(struct MarioState* m) {
|
|||
}
|
||||
|
||||
u8 should_start_or_continue_dialog(struct MarioState* m, struct Object* object) {
|
||||
if (!m) { return FALSE; }
|
||||
if (!m->visibleToEnemies) { return FALSE; }
|
||||
if (m->playerIndex == 0) { return TRUE; }
|
||||
return (gContinueDialogFunctionObject == object);
|
||||
|
@ -379,6 +388,8 @@ u8 should_start_or_continue_dialog(struct MarioState* m, struct Object* object)
|
|||
// 1 = starting dialog
|
||||
// 2 = speaking
|
||||
s32 set_mario_npc_dialog(struct MarioState* m, s32 actionArg, u8 (*inContinueDialogFunction)(void)) {
|
||||
if (!m) { return 0; }
|
||||
|
||||
s32 dialogState = 0;
|
||||
|
||||
if (m->playerIndex == 0) {
|
||||
|
@ -424,6 +435,7 @@ s32 set_mario_npc_dialog(struct MarioState* m, s32 actionArg, u8 (*inContinueDia
|
|||
// 9 - 22: looking away from npc
|
||||
// 23: end
|
||||
s32 act_reading_npc_dialog(struct MarioState *m) {
|
||||
if (!m) { return 23; }
|
||||
s32 headTurnAmount = 0;
|
||||
s16 angleToNPC;
|
||||
|
||||
|
@ -1820,6 +1832,7 @@ s32 act_putting_on_cap(struct MarioState *m) {
|
|||
|
||||
void stuck_in_ground_handler(struct MarioState *m, s32 animation, s32 unstuckFrame, s32 target2,
|
||||
s32 target3, s32 endAction) {
|
||||
if (!m) { return; }
|
||||
s32 animFrame = set_mario_animation(m, animation);
|
||||
|
||||
if (m->input & INPUT_A_PRESSED) {
|
||||
|
@ -2984,6 +2997,8 @@ static s32 check_for_instant_quicksand(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 mario_execute_cutscene_action(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
|
||||
s32 cancel;
|
||||
|
||||
if (check_for_instant_quicksand(m)) {
|
||||
|
|
|
@ -67,12 +67,14 @@ struct LandingAction sBackflipLandAction = {
|
|||
Mat4 sFloorAlignMatrix[MAX_PLAYERS];
|
||||
|
||||
s16 tilt_body_running(struct MarioState *m) {
|
||||
if (!m) { return 0; }
|
||||
s16 pitch = find_floor_slope(m, 0);
|
||||
pitch = pitch * m->forwardVel / 40.0f;
|
||||
return -pitch;
|
||||
}
|
||||
|
||||
void play_step_sound(struct MarioState *m, s16 frame1, s16 frame2) {
|
||||
if (!m) { return; }
|
||||
if (is_anim_past_frame(m, frame1) || is_anim_past_frame(m, frame2)) {
|
||||
if (m->flags & MARIO_METAL_CAP) {
|
||||
if (m->marioObj->header.gfx.animInfo.animID == MARIO_ANIM_TIPTOE) {
|
||||
|
@ -91,18 +93,21 @@ void play_step_sound(struct MarioState *m, s16 frame1, s16 frame2) {
|
|||
}
|
||||
|
||||
void align_with_floor(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
m->pos[1] = m->floorHeight + get_character_anim_offset(m);
|
||||
mtxf_align_terrain_triangle(sFloorAlignMatrix[m->playerIndex], m->pos, m->faceAngle[1], 40.0f);
|
||||
m->marioObj->header.gfx.throwMatrix = &sFloorAlignMatrix[m->playerIndex];
|
||||
}
|
||||
|
||||
s32 begin_walking_action(struct MarioState *m, f32 forwardVel, u32 action, u32 actionArg) {
|
||||
if (!m) { return 0; }
|
||||
m->faceAngle[1] = m->intendedYaw;
|
||||
mario_set_forward_vel(m, forwardVel);
|
||||
return set_mario_action(m, action, actionArg);
|
||||
}
|
||||
|
||||
void check_ledge_climb_down(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
struct WallCollisionData wallCols;
|
||||
struct Surface *floor;
|
||||
f32 floorHeight;
|
||||
|
@ -140,6 +145,7 @@ void check_ledge_climb_down(struct MarioState *m) {
|
|||
}
|
||||
|
||||
void slide_bonk(struct MarioState *m, u32 fastAction, u32 slowAction) {
|
||||
if (!m) { return; }
|
||||
if (m->forwardVel > 16.0f) {
|
||||
mario_bonk_reflection(m, TRUE);
|
||||
drop_and_set_mario_action(m, fastAction, 0);
|
||||
|
@ -150,6 +156,8 @@ void slide_bonk(struct MarioState *m, u32 fastAction, u32 slowAction) {
|
|||
}
|
||||
|
||||
s32 set_triple_jump_action(struct MarioState *m, UNUSED u32 action, UNUSED u32 actionArg) {
|
||||
if (!m) { return FALSE; }
|
||||
|
||||
if (m->flags & MARIO_WING_CAP) {
|
||||
return set_mario_action(m, ACT_FLYING_TRIPLE_JUMP, 0);
|
||||
} else if (m->forwardVel > 20.0f || (gServerSettings.enableCheats && gCheats.alwaysTripleJump && m->playerIndex == 0)) {
|
||||
|
@ -162,6 +170,7 @@ s32 set_triple_jump_action(struct MarioState *m, UNUSED u32 action, UNUSED u32 a
|
|||
}
|
||||
|
||||
void update_sliding_angle(struct MarioState *m, f32 accel, f32 lossFactor) {
|
||||
if (!m) { return; }
|
||||
s32 newFacingDYaw;
|
||||
s16 facingDYaw;
|
||||
|
||||
|
@ -224,6 +233,7 @@ void update_sliding_angle(struct MarioState *m, f32 accel, f32 lossFactor) {
|
|||
}
|
||||
|
||||
s32 update_sliding(struct MarioState *m, f32 stopSpeed) {
|
||||
if (!m) { return FALSE; }
|
||||
f32 lossFactor;
|
||||
f32 accel;
|
||||
f32 oldSpeed;
|
||||
|
@ -288,6 +298,7 @@ s32 update_sliding(struct MarioState *m, f32 stopSpeed) {
|
|||
}
|
||||
|
||||
void apply_slope_accel(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
f32 slopeAccel;
|
||||
|
||||
struct Surface *floor = m->floor;
|
||||
|
@ -340,6 +351,7 @@ void apply_slope_accel(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 apply_landing_accel(struct MarioState *m, f32 frictionFactor) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 stopped = FALSE;
|
||||
|
||||
apply_slope_accel(m);
|
||||
|
@ -356,6 +368,7 @@ s32 apply_landing_accel(struct MarioState *m, f32 frictionFactor) {
|
|||
}
|
||||
|
||||
void update_shell_speed(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
f32 maxTargetSpeed;
|
||||
f32 targetSpeed;
|
||||
|
||||
|
@ -399,6 +412,7 @@ void update_shell_speed(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 apply_slope_decel(struct MarioState *m, f32 decelCoef) {
|
||||
if (!m) { return 0; }
|
||||
f32 decel;
|
||||
s32 stopped = FALSE;
|
||||
|
||||
|
@ -426,6 +440,7 @@ s32 apply_slope_decel(struct MarioState *m, f32 decelCoef) {
|
|||
}
|
||||
|
||||
s32 update_decelerating_speed(struct MarioState *m) {
|
||||
if (!m) { return 0; }
|
||||
s32 stopped = FALSE;
|
||||
|
||||
if ((m->forwardVel = approach_f32(m->forwardVel, 0.0f, 1.0f, 1.0f)) == 0.0f) {
|
||||
|
@ -440,6 +455,7 @@ s32 update_decelerating_speed(struct MarioState *m) {
|
|||
}
|
||||
|
||||
void update_walking_speed(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
f32 maxTargetSpeed;
|
||||
f32 targetSpeed;
|
||||
|
||||
|
@ -477,6 +493,7 @@ void update_walking_speed(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 should_begin_sliding(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->input & INPUT_ABOVE_SLIDE) {
|
||||
s32 slideLevel = (m->area->terrainType & TERRAIN_MASK) == TERRAIN_SLIDE;
|
||||
s32 movingBackward = m->forwardVel <= -1.0f;
|
||||
|
@ -490,11 +507,13 @@ s32 should_begin_sliding(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 analog_stick_held_back(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s16 intendedDYaw = m->intendedYaw - m->faceAngle[1];
|
||||
return intendedDYaw < -0x471C || intendedDYaw > 0x471C;
|
||||
}
|
||||
|
||||
s32 check_ground_dive_or_punch(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
UNUSED s32 unused;
|
||||
|
||||
if (m->input & INPUT_B_PRESSED) {
|
||||
|
@ -511,6 +530,7 @@ s32 check_ground_dive_or_punch(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 begin_braking_action(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
mario_drop_held_object(m);
|
||||
|
||||
if (m->actionState == 1) {
|
||||
|
@ -526,6 +546,7 @@ s32 begin_braking_action(struct MarioState *m) {
|
|||
}
|
||||
|
||||
void anim_and_audio_for_walk(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
s32 val14;
|
||||
struct Object *marioObj = m->marioObj;
|
||||
s32 val0C = TRUE;
|
||||
|
@ -617,6 +638,7 @@ void anim_and_audio_for_walk(struct MarioState *m) {
|
|||
}
|
||||
|
||||
void anim_and_audio_for_hold_walk(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
s32 val0C;
|
||||
s32 val08 = TRUE;
|
||||
f32 val04;
|
||||
|
@ -674,12 +696,14 @@ void anim_and_audio_for_hold_walk(struct MarioState *m) {
|
|||
}
|
||||
|
||||
void anim_and_audio_for_heavy_walk(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
s32 val04 = (s32)(m->intendedMag * 0x10000);
|
||||
set_mario_anim_with_accel(m, MARIO_ANIM_WALK_WITH_HEAVY_OBJ, val04);
|
||||
play_step_sound(m, 26, 79);
|
||||
}
|
||||
|
||||
void push_or_sidle_wall(struct MarioState *m, Vec3f startPos) {
|
||||
if (!m) { return; }
|
||||
s16 wallAngle;
|
||||
s16 dWallAngle;
|
||||
f32 dx = m->pos[0] - startPos[0];
|
||||
|
@ -721,6 +745,7 @@ void push_or_sidle_wall(struct MarioState *m, Vec3f startPos) {
|
|||
}
|
||||
|
||||
void tilt_body_walking(struct MarioState *m, s16 startYaw) {
|
||||
if (!m) { return; }
|
||||
struct MarioBodyState *val0C = m->marioBodyState;
|
||||
UNUSED struct Object *marioObj = m->marioObj;
|
||||
s16 animID = m->marioObj->header.gfx.animInfo.animID;
|
||||
|
@ -755,6 +780,7 @@ void tilt_body_walking(struct MarioState *m, s16 startYaw) {
|
|||
}
|
||||
|
||||
void tilt_body_ground_shell(struct MarioState *m, s16 startYaw) {
|
||||
if (!m) { return; }
|
||||
struct MarioBodyState *val0C = m->marioBodyState;
|
||||
struct Object *marioObj = m->marioObj;
|
||||
s16 dYaw = m->faceAngle[1] - startYaw;
|
||||
|
@ -787,6 +813,7 @@ void tilt_body_ground_shell(struct MarioState *m, s16 startYaw) {
|
|||
}
|
||||
|
||||
s32 act_walking(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
Vec3f startPos;
|
||||
s16 startYaw = m->faceAngle[1];
|
||||
|
||||
|
@ -850,6 +877,7 @@ s32 act_walking(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_move_punching(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (should_begin_sliding(m)) {
|
||||
return set_mario_action(m, ACT_BEGIN_SLIDING, 0);
|
||||
}
|
||||
|
@ -885,6 +913,7 @@ s32 act_move_punching(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_hold_walking(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->heldObj != NULL && m->heldObj->behavior == segmented_to_virtual(smlua_override_behavior(bhvJumpingBox))) {
|
||||
return set_mario_action(m, ACT_CRAZY_BOX_BOUNCE, 0);
|
||||
}
|
||||
|
@ -939,6 +968,7 @@ s32 act_hold_walking(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_hold_heavy_walking(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->input & INPUT_B_PRESSED) {
|
||||
return set_mario_action(m, ACT_HEAVY_THROW, 0);
|
||||
}
|
||||
|
@ -972,6 +1002,7 @@ s32 act_hold_heavy_walking(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_turning_around(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->input & INPUT_ABOVE_SLIDE) {
|
||||
return set_mario_action(m, ACT_BEGIN_SLIDING, 0);
|
||||
}
|
||||
|
@ -1023,6 +1054,7 @@ s32 act_turning_around(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_finish_turning_around(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->input & INPUT_ABOVE_SLIDE) {
|
||||
return set_mario_action(m, ACT_BEGIN_SLIDING, 0);
|
||||
}
|
||||
|
@ -1047,6 +1079,7 @@ s32 act_finish_turning_around(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_braking(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (!(m->input & INPUT_FIRST_PERSON)
|
||||
&& (m->input
|
||||
& (INPUT_NONZERO_ANALOG | INPUT_A_PRESSED | INPUT_OFF_FLOOR | INPUT_ABOVE_SLIDE))) {
|
||||
|
@ -1082,6 +1115,7 @@ s32 act_braking(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_decelerating(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 val0C;
|
||||
s16 slopeClass = mario_get_floor_class(m);
|
||||
|
||||
|
@ -1144,6 +1178,7 @@ s32 act_decelerating(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_hold_decelerating(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 val0C;
|
||||
s16 slopeClass = mario_get_floor_class(m);
|
||||
|
||||
|
@ -1210,6 +1245,7 @@ s32 act_hold_decelerating(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_riding_shell_ground(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s16 startYaw = m->faceAngle[1];
|
||||
|
||||
if (m->input & INPUT_A_PRESSED) {
|
||||
|
@ -1256,6 +1292,7 @@ s32 act_riding_shell_ground(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_crawling(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 val04;
|
||||
|
||||
if (should_begin_sliding(m)) {
|
||||
|
@ -1309,6 +1346,7 @@ s32 act_crawling(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_burning_ground(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->input & INPUT_A_PRESSED) {
|
||||
return set_mario_action(m, ACT_BURNING_JUMP, 0);
|
||||
}
|
||||
|
@ -1365,12 +1403,14 @@ s32 act_burning_ground(struct MarioState *m) {
|
|||
}
|
||||
|
||||
void tilt_body_butt_slide(struct MarioState *m) {
|
||||
if (!m) { return; }
|
||||
s16 intendedDYaw = m->intendedYaw - m->faceAngle[1];
|
||||
m->marioBodyState->torsoAngle[0] = (s32)(5461.3335f * m->intendedMag / 32.0f * coss(intendedDYaw));
|
||||
m->marioBodyState->torsoAngle[2] = (s32)(-(5461.3335f * m->intendedMag / 32.0f * sins(intendedDYaw)));
|
||||
}
|
||||
|
||||
void common_slide_action(struct MarioState *m, u32 endAction, u32 airAction, s32 animation) {
|
||||
if (!m) { return; }
|
||||
Vec3f pos;
|
||||
|
||||
vec3f_copy(pos, m->pos);
|
||||
|
@ -1425,6 +1465,7 @@ void common_slide_action(struct MarioState *m, u32 endAction, u32 airAction, s32
|
|||
|
||||
s32 common_slide_action_with_jump(struct MarioState *m, u32 stopAction, u32 jumpAction, u32 airAction,
|
||||
s32 animation) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->actionTimer == 5) {
|
||||
if (m->input & INPUT_A_PRESSED) {
|
||||
return set_jumping_action(m, jumpAction, 0);
|
||||
|
@ -1442,6 +1483,7 @@ s32 common_slide_action_with_jump(struct MarioState *m, u32 stopAction, u32 jump
|
|||
}
|
||||
|
||||
s32 act_butt_slide(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 cancel = common_slide_action_with_jump(m, ACT_BUTT_SLIDE_STOP, ACT_JUMP, ACT_BUTT_SLIDE_AIR,
|
||||
MARIO_ANIM_SLIDE);
|
||||
tilt_body_butt_slide(m);
|
||||
|
@ -1449,6 +1491,7 @@ s32 act_butt_slide(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_hold_butt_slide(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 cancel;
|
||||
|
||||
if (m->marioObj->oInteractStatus & INT_STATUS_MARIO_DROP_OBJECT) {
|
||||
|
@ -1462,6 +1505,7 @@ s32 act_hold_butt_slide(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_crouch_slide(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 cancel;
|
||||
|
||||
if (m->input & INPUT_ABOVE_SLIDE) {
|
||||
|
@ -1499,6 +1543,7 @@ s32 act_crouch_slide(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_slide_kick_slide(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->input & INPUT_A_PRESSED) {
|
||||
queue_rumble_data_mario(m, 5, 80);
|
||||
return set_jumping_action(m, ACT_FORWARD_ROLLOUT, 0);
|
||||
|
@ -1528,6 +1573,7 @@ s32 act_slide_kick_slide(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 stomach_slide_action(struct MarioState *m, u32 stopAction, u32 airAction, s32 animation) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->actionTimer == 5) {
|
||||
if (!(m->input & INPUT_ABOVE_SLIDE) && (m->input & (INPUT_A_PRESSED | INPUT_B_PRESSED))) {
|
||||
queue_rumble_data_mario(m, 5, 80);
|
||||
|
@ -1550,11 +1596,13 @@ s32 stomach_slide_action(struct MarioState *m, u32 stopAction, u32 airAction, s3
|
|||
}
|
||||
|
||||
s32 act_stomach_slide(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 cancel = stomach_slide_action(m, ACT_STOMACH_SLIDE_STOP, ACT_FREEFALL, MARIO_ANIM_SLIDE_DIVE);
|
||||
return cancel;
|
||||
}
|
||||
|
||||
s32 act_hold_stomach_slide(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 cancel;
|
||||
|
||||
if (m->marioObj->oInteractStatus & INT_STATUS_MARIO_DROP_OBJECT) {
|
||||
|
@ -1566,6 +1614,7 @@ s32 act_hold_stomach_slide(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_dive_slide(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (!(m->input & INPUT_ABOVE_SLIDE) && (m->input & (INPUT_A_PRESSED | INPUT_B_PRESSED))) {
|
||||
queue_rumble_data_mario(m, 5, 80);
|
||||
return set_mario_action(m, m->forwardVel > 0.0f ? ACT_FORWARD_ROLLOUT : ACT_BACKWARD_ROLLOUT,
|
||||
|
@ -1597,6 +1646,7 @@ s32 act_dive_slide(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 common_ground_knockback_action(struct MarioState *m, s32 animation, s32 arg2, s32 arg3, s32 arg4) {
|
||||
if (!m) { return 0; }
|
||||
s32 animFrame;
|
||||
|
||||
if (arg3) {
|
||||
|
@ -1656,6 +1706,7 @@ s32 common_ground_knockback_action(struct MarioState *m, s32 animation, s32 arg2
|
|||
}
|
||||
|
||||
s32 act_hard_backward_ground_kb(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 animFrame =
|
||||
common_ground_knockback_action(m, MARIO_ANIM_FALL_OVER_BACKWARDS, 43, TRUE, m->actionArg);
|
||||
if (animFrame == 43 && m->health < 0x100) {
|
||||
|
@ -1676,6 +1727,7 @@ s32 act_hard_backward_ground_kb(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_hard_forward_ground_kb(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 animFrame =
|
||||
common_ground_knockback_action(m, MARIO_ANIM_LAND_ON_STOMACH, 21, TRUE, m->actionArg);
|
||||
if (animFrame == 23 && m->health < 0x100) {
|
||||
|
@ -1686,26 +1738,31 @@ s32 act_hard_forward_ground_kb(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_backward_ground_kb(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
common_ground_knockback_action(m, MARIO_ANIM_BACKWARD_KB, 22, TRUE, m->actionArg);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s32 act_forward_ground_kb(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
common_ground_knockback_action(m, MARIO_ANIM_FORWARD_KB, 20, TRUE, m->actionArg);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s32 act_soft_backward_ground_kb(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
common_ground_knockback_action(m, MARIO_ANIM_SOFT_BACK_KB, 100, FALSE, m->actionArg);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s32 act_soft_forward_ground_kb(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
common_ground_knockback_action(m, MARIO_ANIM_SOFT_FRONT_KB, 100, FALSE, m->actionArg);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s32 act_ground_bonk(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 animFrame =
|
||||
common_ground_knockback_action(m, MARIO_ANIM_GROUND_BONK, 32, TRUE, m->actionArg);
|
||||
if (animFrame == 32) {
|
||||
|
@ -1715,6 +1772,7 @@ s32 act_ground_bonk(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_death_exit_land(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 animFrame;
|
||||
|
||||
apply_landing_accel(m, 0.9f);
|
||||
|
@ -1737,6 +1795,7 @@ s32 act_death_exit_land(struct MarioState *m) {
|
|||
}
|
||||
|
||||
u32 common_landing_action(struct MarioState *m, s16 animation, u32 airAction) {
|
||||
if (!m) { return 0; }
|
||||
u32 stepResult;
|
||||
|
||||
if (m->input & INPUT_NONZERO_ANALOG) {
|
||||
|
@ -1774,6 +1833,7 @@ u32 common_landing_action(struct MarioState *m, s16 animation, u32 airAction) {
|
|||
|
||||
s32 common_landing_cancels(struct MarioState *m, struct LandingAction *landingAction,
|
||||
s32 (*setAPressAction)(struct MarioState *, u32, u32)) {
|
||||
if (!m) { return 0; }
|
||||
//! Everything here, including floor steepness, is checked before checking
|
||||
// if Mario is actually on the floor. This leads to e.g. remote sliding.
|
||||
|
||||
|
@ -1807,6 +1867,7 @@ s32 common_landing_cancels(struct MarioState *m, struct LandingAction *landingAc
|
|||
}
|
||||
|
||||
s32 act_jump_land(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (common_landing_cancels(m, &sJumpLandAction, set_jumping_action)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1816,6 +1877,7 @@ s32 act_jump_land(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_freefall_land(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (common_landing_cancels(m, &sFreefallLandAction, set_jumping_action)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1825,6 +1887,7 @@ s32 act_freefall_land(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_side_flip_land(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (common_landing_cancels(m, &sSideFlipLandAction, set_jumping_action)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1836,6 +1899,7 @@ s32 act_side_flip_land(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_hold_jump_land(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->marioObj->oInteractStatus & INT_STATUS_MARIO_DROP_OBJECT) {
|
||||
return drop_and_set_mario_action(m, ACT_JUMP_LAND_STOP, 0);
|
||||
}
|
||||
|
@ -1849,6 +1913,7 @@ s32 act_hold_jump_land(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_hold_freefall_land(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->marioObj->oInteractStatus & INT_STATUS_MARIO_DROP_OBJECT) {
|
||||
return drop_and_set_mario_action(m, ACT_FREEFALL_LAND_STOP, 0);
|
||||
}
|
||||
|
@ -1862,6 +1927,7 @@ s32 act_hold_freefall_land(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_long_jump_land(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
#ifdef VERSION_SH
|
||||
// BLJ (Backwards Long Jump) speed build up fix, crushing SimpleFlips's dreams since July 1997
|
||||
if (m->forwardVel < 0.0f) {
|
||||
|
@ -1889,6 +1955,7 @@ s32 act_long_jump_land(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_double_jump_land(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (common_landing_cancels(m, &sDoubleJumpLandAction, set_triple_jump_action)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1897,6 +1964,7 @@ s32 act_double_jump_land(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_triple_jump_land(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
m->input &= ~INPUT_A_PRESSED;
|
||||
|
||||
if (common_landing_cancels(m, &sTripleJumpLandAction, set_jumping_action)) {
|
||||
|
@ -1912,6 +1980,7 @@ s32 act_triple_jump_land(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 act_backflip_land(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (!(m->input & INPUT_Z_DOWN)) {
|
||||
m->input &= ~INPUT_A_PRESSED;
|
||||
}
|
||||
|
@ -1930,6 +1999,7 @@ s32 act_backflip_land(struct MarioState *m) {
|
|||
|
||||
s32 quicksand_jump_land_action(struct MarioState *m, s32 animation1, s32 animation2, u32 endAction,
|
||||
u32 airAction) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->actionTimer++ < 6) {
|
||||
m->quicksandDepth -= (7 - m->actionTimer) * 0.8f;
|
||||
if (m->quicksandDepth < 1.0f) {
|
||||
|
@ -1955,12 +2025,14 @@ s32 quicksand_jump_land_action(struct MarioState *m, s32 animation1, s32 animati
|
|||
}
|
||||
|
||||
s32 act_quicksand_jump_land(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 cancel = quicksand_jump_land_action(m, MARIO_ANIM_SINGLE_JUMP, MARIO_ANIM_LAND_FROM_SINGLE_JUMP,
|
||||
ACT_JUMP_LAND_STOP, ACT_FREEFALL);
|
||||
return cancel;
|
||||
}
|
||||
|
||||
s32 act_hold_quicksand_jump_land(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 cancel = quicksand_jump_land_action(m, MARIO_ANIM_JUMP_WITH_LIGHT_OBJ,
|
||||
MARIO_ANIM_JUMP_LAND_WITH_LIGHT_OBJ, ACT_HOLD_JUMP_LAND_STOP,
|
||||
ACT_HOLD_FREEFALL);
|
||||
|
@ -1968,6 +2040,7 @@ s32 act_hold_quicksand_jump_land(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 check_common_moving_cancels(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
if (m->pos[1] < m->waterLevel - 100) {
|
||||
return set_water_plunge_action(m);
|
||||
}
|
||||
|
@ -1990,6 +2063,7 @@ s32 check_common_moving_cancels(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 mario_execute_moving_action(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 cancel;
|
||||
|
||||
if (check_common_moving_cancels(m)) {
|
||||
|
|
|
@ -483,6 +483,7 @@ s32 check_common_object_cancels(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 mario_execute_object_action(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 cancel;
|
||||
|
||||
if (check_common_object_cancels(m)) {
|
||||
|
|
|
@ -1127,6 +1127,7 @@ s32 check_common_stationary_cancels(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 mario_execute_stationary_action(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 cancel;
|
||||
|
||||
if (check_common_stationary_cancels(m)) {
|
||||
|
|
|
@ -179,6 +179,7 @@ void apply_water_current(struct MarioState *m, Vec3f step) {
|
|||
}
|
||||
|
||||
u32 perform_water_step(struct MarioState *m) {
|
||||
if (!m) { return 0; }
|
||||
UNUSED u32 unused;
|
||||
u32 stepResult;
|
||||
Vec3f nextPos;
|
||||
|
@ -1588,6 +1589,7 @@ static s32 check_common_submerged_cancels(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 mario_execute_submerged_action(struct MarioState *m) {
|
||||
if (!m) { return FALSE; }
|
||||
s32 cancel;
|
||||
|
||||
if (check_common_submerged_cancels(m)) {
|
||||
|
|
|
@ -332,6 +332,7 @@ static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos) {
|
|||
}
|
||||
|
||||
s32 perform_ground_step(struct MarioState *m) {
|
||||
if (!m) { return 0; }
|
||||
s32 i;
|
||||
u32 stepResult;
|
||||
Vec3f intendedPos;
|
||||
|
@ -682,6 +683,7 @@ void apply_vertical_wind(struct MarioState *m) {
|
|||
}
|
||||
|
||||
s32 perform_air_step(struct MarioState *m, u32 stepArg) {
|
||||
if (!m) { return 0; }
|
||||
Vec3f intendedPos;
|
||||
s32 i;
|
||||
s32 quarterStepResult;
|
||||
|
|
|
@ -671,8 +671,10 @@ struct Object *spawn_object_at_origin(struct Object *parent, UNUSED s32 unusedAr
|
|||
if (obj == NULL) { return NULL; }
|
||||
|
||||
obj->parentObj = parent;
|
||||
obj->header.gfx.areaIndex = parent->header.gfx.areaIndex;
|
||||
obj->header.gfx.activeAreaIndex = parent->header.gfx.areaIndex;
|
||||
if (parent) {
|
||||
obj->header.gfx.areaIndex = parent->header.gfx.areaIndex;
|
||||
obj->header.gfx.activeAreaIndex = parent->header.gfx.areaIndex;
|
||||
}
|
||||
obj->globalPlayerIndex = 0;
|
||||
|
||||
if (model >= MAX_LOADED_GRAPH_NODES) { model = MODEL_ERROR_MODEL; }
|
||||
|
|
Loading…
Reference in a new issue