sm64pc/src/game/mario_actions_object.c

491 lines
14 KiB
C
Raw Normal View History

2019-08-25 04:46:40 +00:00
#include <ultra64.h>
#include "sm64.h"
#include "mario_actions_object.h"
#include "types.h"
#include "mario_step.h"
#include "mario.h"
#include "audio/external.h"
#include "interaction.h"
#include "audio_defines.h"
#include "engine/math_util.h"
2020-04-03 18:57:26 +00:00
#include "thread6.h"
2019-08-25 04:46:40 +00:00
/**
* Used by act_punching() to determine Mario's forward velocity during each
* animation frame.
*/
s8 sPunchingForwardVelocities[8] = { 0, 1, 1, 2, 3, 5, 7, 10 };
void animated_stationary_ground_step(struct MarioState *m, s32 animation, u32 endAction) {
stationary_ground_step(m);
set_mario_animation(m, animation);
2019-09-01 19:50:50 +00:00
if (is_anim_at_end(m)) {
2019-08-25 04:46:40 +00:00
set_mario_action(m, endAction, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
}
s32 mario_update_punch_sequence(struct MarioState *m) {
u32 endAction, crouchEndAction;
s32 animFrame;
2019-09-01 19:50:50 +00:00
if (m->action & ACT_FLAG_MOVING) {
2019-08-25 04:46:40 +00:00
endAction = ACT_WALKING, crouchEndAction = ACT_CROUCH_SLIDE;
2019-09-01 19:50:50 +00:00
} else {
2019-08-25 04:46:40 +00:00
endAction = ACT_IDLE, crouchEndAction = ACT_CROUCHING;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
switch (m->actionArg) {
case 0:
2019-10-05 19:08:05 +00:00
play_sound(SOUND_MARIO_PUNCH_YAH, m->marioObj->header.gfx.cameraToObject);
2019-08-25 04:46:40 +00:00
// Fall-through:
case 1:
set_mario_animation(m, MARIO_ANIM_FIRST_PUNCH);
2019-09-01 19:50:50 +00:00
if (is_anim_past_end(m)) {
2019-08-25 04:46:40 +00:00
m->actionArg = 2;
2019-09-01 19:50:50 +00:00
} else {
2019-08-25 04:46:40 +00:00
m->actionArg = 1;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
if (m->marioObj->header.gfx.unk38.animFrame >= 2) {
2019-09-01 19:50:50 +00:00
if (mario_check_object_grab(m)) {
2019-08-25 04:46:40 +00:00
return TRUE;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
m->flags |= MARIO_PUNCHING;
}
2019-09-01 19:50:50 +00:00
if (m->actionArg == 2) {
2020-02-03 05:51:26 +00:00
m->marioBodyState->punchState = (0 << 6) | 4;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
break;
case 2:
set_mario_animation(m, MARIO_ANIM_FIRST_PUNCH_FAST);
2019-09-01 19:50:50 +00:00
if (m->marioObj->header.gfx.unk38.animFrame <= 0) {
2019-08-25 04:46:40 +00:00
m->flags |= MARIO_PUNCHING;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_B_PRESSED) {
2019-08-25 04:46:40 +00:00
m->actionArg = 3;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (is_anim_at_end(m)) {
2019-08-25 04:46:40 +00:00
set_mario_action(m, endAction, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
break;
case 3:
2019-10-05 19:08:05 +00:00
play_sound(SOUND_MARIO_PUNCH_WAH, m->marioObj->header.gfx.cameraToObject);
2019-08-25 04:46:40 +00:00
// Fall-through:
case 4:
set_mario_animation(m, MARIO_ANIM_SECOND_PUNCH);
2019-09-01 19:50:50 +00:00
if (is_anim_past_end(m)) {
2019-08-25 04:46:40 +00:00
m->actionArg = 5;
2019-09-01 19:50:50 +00:00
} else {
2019-08-25 04:46:40 +00:00
m->actionArg = 4;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->marioObj->header.gfx.unk38.animFrame > 0) {
2019-08-25 04:46:40 +00:00
m->flags |= MARIO_PUNCHING;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->actionArg == 5) {
2020-02-03 05:51:26 +00:00
m->marioBodyState->punchState = (1 << 6) | 4;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
break;
case 5:
set_mario_animation(m, MARIO_ANIM_SECOND_PUNCH_FAST);
2019-09-01 19:50:50 +00:00
if (m->marioObj->header.gfx.unk38.animFrame <= 0) {
2019-08-25 04:46:40 +00:00
m->flags |= MARIO_PUNCHING;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_B_PRESSED) {
2019-08-25 04:46:40 +00:00
m->actionArg = 6;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (is_anim_at_end(m)) {
2019-08-25 04:46:40 +00:00
set_mario_action(m, endAction, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
break;
case 6:
2019-10-05 19:08:05 +00:00
play_mario_action_sound(m, SOUND_MARIO_PUNCH_HOO, 1);
2019-08-25 04:46:40 +00:00
animFrame = set_mario_animation(m, MARIO_ANIM_GROUND_KICK);
2019-09-01 19:50:50 +00:00
if (animFrame == 0) {
2020-02-03 05:51:26 +00:00
m->marioBodyState->punchState = (2 << 6) | 6;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (animFrame >= 0 && animFrame < 8) {
2019-08-25 04:46:40 +00:00
m->flags |= MARIO_KICKING;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (is_anim_at_end(m)) {
2019-08-25 04:46:40 +00:00
set_mario_action(m, endAction, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
break;
case 9:
2019-10-05 19:08:05 +00:00
play_mario_action_sound(m, SOUND_MARIO_PUNCH_HOO, 1);
2019-08-25 04:46:40 +00:00
set_mario_animation(m, MARIO_ANIM_BREAKDANCE);
animFrame = m->marioObj->header.gfx.unk38.animFrame;
2019-09-01 19:50:50 +00:00
if (animFrame >= 2 && animFrame < 8) {
2019-08-25 04:46:40 +00:00
m->flags |= MARIO_TRIPPING;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (is_anim_at_end(m)) {
2019-08-25 04:46:40 +00:00
set_mario_action(m, crouchEndAction, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
break;
}
return FALSE;
}
s32 act_punching(struct MarioState *m) {
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_UNKNOWN_10) {
2020-04-03 18:57:26 +00:00
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->input & (INPUT_NONZERO_ANALOG | INPUT_A_PRESSED | INPUT_OFF_FLOOR | INPUT_ABOVE_SLIDE)) {
2019-08-25 04:46:40 +00:00
return check_common_action_exits(m);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->actionState == 0 && (m->input & INPUT_A_DOWN)) {
2019-08-25 04:46:40 +00:00
return set_mario_action(m, ACT_JUMP_KICK, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
m->actionState = 1;
2019-09-01 19:50:50 +00:00
if (m->actionArg == 0) {
2019-08-25 04:46:40 +00:00
m->actionTimer = 7;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
mario_set_forward_vel(m, sPunchingForwardVelocities[m->actionTimer]);
2019-09-01 19:50:50 +00:00
if (m->actionTimer > 0) {
2019-08-25 04:46:40 +00:00
m->actionTimer--;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
mario_update_punch_sequence(m);
perform_ground_step(m);
return FALSE;
}
s32 act_picking_up(struct MarioState *m) {
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_UNKNOWN_10) {
2020-04-03 18:57:26 +00:00
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_OFF_FLOOR) {
2019-08-25 04:46:40 +00:00
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
if (m->actionState == 0 && is_anim_at_end(m)) {
//! While the animation is playing, it is possible for the used object
// to unload. This allows you to pick up a vacant or newly loaded object
// slot (cloning via fake object).
mario_grab_used_object(m);
2019-10-05 19:08:05 +00:00
play_sound_if_no_flag(m, SOUND_MARIO_HRMM, MARIO_MARIO_SOUND_PLAYED);
2019-08-25 04:46:40 +00:00
m->actionState = 1;
}
if (m->actionState == 1) {
2019-09-01 19:50:50 +00:00
if (m->heldObj->oInteractionSubtype & INT_SUBTYPE_GRABS_MARIO) {
2019-08-25 04:46:40 +00:00
m->marioBodyState->grabPos = GRAB_POS_HEAVY_OBJ;
set_mario_animation(m, MARIO_ANIM_GRAB_HEAVY_OBJECT);
2019-09-01 19:50:50 +00:00
if (is_anim_at_end(m)) {
2019-12-02 02:52:53 +00:00
set_mario_action(m, ACT_HOLD_HEAVY_IDLE, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
} else {
m->marioBodyState->grabPos = GRAB_POS_LIGHT_OBJ;
set_mario_animation(m, MARIO_ANIM_PICK_UP_LIGHT_OBJ);
2019-09-01 19:50:50 +00:00
if (is_anim_at_end(m)) {
2019-12-02 02:52:53 +00:00
set_mario_action(m, ACT_HOLD_IDLE, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
}
}
stationary_ground_step(m);
return FALSE;
}
s32 act_dive_picking_up(struct MarioState *m) {
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_UNKNOWN_10) {
2020-04-03 18:57:26 +00:00
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-12-02 02:52:53 +00:00
//! Hands-free holding. Landing on a slope or being pushed off a ledge while
// landing from a dive grab sets mario's action to a non-holding action
// without dropping the object, causing the hands-free holding glitch.
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_OFF_FLOOR) {
2019-08-25 04:46:40 +00:00
return set_mario_action(m, ACT_FREEFALL, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_ABOVE_SLIDE) {
2019-08-25 04:46:40 +00:00
return set_mario_action(m, ACT_BEGIN_SLIDING, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-12-02 02:52:53 +00:00
animated_stationary_ground_step(m, MARIO_ANIM_STOP_SLIDE_LIGHT_OBJ, ACT_HOLD_IDLE);
2019-08-25 04:46:40 +00:00
return FALSE;
}
s32 act_placing_down(struct MarioState *m) {
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_UNKNOWN_10) {
2020-04-03 18:57:26 +00:00
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_OFF_FLOOR) {
2019-08-25 04:46:40 +00:00
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (++m->actionTimer == 8) {
2019-08-25 04:46:40 +00:00
mario_drop_held_object(m);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
animated_stationary_ground_step(m, MARIO_ANIM_PLACE_LIGHT_OBJ, ACT_IDLE);
return FALSE;
}
s32 act_throwing(struct MarioState *m) {
2019-09-01 19:50:50 +00:00
if (m->heldObj && (m->heldObj->oInteractionSubtype & INT_SUBTYPE_HOLDABLE_NPC)) {
2019-08-25 04:46:40 +00:00
return set_mario_action(m, ACT_PLACING_DOWN, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_UNKNOWN_10) {
2020-04-03 18:57:26 +00:00
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_OFF_FLOOR) {
2019-08-25 04:46:40 +00:00
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
if (++m->actionTimer == 7) {
mario_throw_held_object(m);
2019-10-05 19:08:05 +00:00
play_sound_if_no_flag(m, SOUND_MARIO_WAH2, MARIO_MARIO_SOUND_PLAYED);
2019-11-03 19:36:27 +00:00
play_sound_if_no_flag(m, SOUND_ACTION_THROW, MARIO_ACTION_SOUND_PLAYED);
2020-04-03 18:57:26 +00:00
#ifdef VERSION_SH
queue_rumble_data(3, 50);
#endif
2019-08-25 04:46:40 +00:00
}
animated_stationary_ground_step(m, MARIO_ANIM_GROUND_THROW, ACT_IDLE);
return FALSE;
}
s32 act_heavy_throw(struct MarioState *m) {
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_UNKNOWN_10) {
2020-04-03 18:57:26 +00:00
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_OFF_FLOOR) {
2019-08-25 04:46:40 +00:00
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
if (++m->actionTimer == 13) {
mario_drop_held_object(m);
2019-10-05 19:08:05 +00:00
play_sound_if_no_flag(m, SOUND_MARIO_WAH2, MARIO_MARIO_SOUND_PLAYED);
2019-11-03 19:36:27 +00:00
play_sound_if_no_flag(m, SOUND_ACTION_THROW, MARIO_ACTION_SOUND_PLAYED);
2020-04-03 18:57:26 +00:00
#ifdef VERSION_SH
queue_rumble_data(3, 50);
#endif
2019-08-25 04:46:40 +00:00
}
animated_stationary_ground_step(m, MARIO_ANIM_HEAVY_THROW, ACT_IDLE);
return FALSE;
}
s32 act_stomach_slide_stop(struct MarioState *m) {
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_UNKNOWN_10) {
2020-04-03 18:57:26 +00:00
return set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_OFF_FLOOR) {
2019-08-25 04:46:40 +00:00
return set_mario_action(m, ACT_FREEFALL, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_ABOVE_SLIDE) {
2019-08-25 04:46:40 +00:00
return set_mario_action(m, ACT_BEGIN_SLIDING, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
animated_stationary_ground_step(m, MARIO_ANIM_SLOW_LAND_FROM_DIVE, ACT_IDLE);
return FALSE;
}
s32 act_picking_up_bowser(struct MarioState *m) {
if (m->actionState == 0) {
m->actionState = 1;
m->angleVel[1] = 0;
m->marioBodyState->grabPos = GRAB_POS_BOWSER;
mario_grab_used_object(m);
2020-04-03 18:57:26 +00:00
#ifdef VERSION_SH
queue_rumble_data(5, 80);
#endif
2019-08-25 04:46:40 +00:00
play_sound(SOUND_MARIO_HRMM, m->marioObj->header.gfx.cameraToObject);
}
set_mario_animation(m, MARIO_ANIM_GRAB_BOWSER);
2019-09-01 19:50:50 +00:00
if (is_anim_at_end(m)) {
2019-08-25 04:46:40 +00:00
set_mario_action(m, ACT_HOLDING_BOWSER, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
stationary_ground_step(m);
return FALSE;
}
s32 act_holding_bowser(struct MarioState *m) {
s16 spin;
if (m->input & INPUT_B_PRESSED) {
#ifndef VERSION_JP
2019-09-01 19:50:50 +00:00
if (m->angleVel[1] <= -0xE00 || m->angleVel[1] >= 0xE00) {
2019-10-05 19:08:05 +00:00
play_sound(SOUND_MARIO_SO_LONGA_BOWSER, m->marioObj->header.gfx.cameraToObject);
2019-09-01 19:50:50 +00:00
} else {
2019-10-05 19:08:05 +00:00
play_sound(SOUND_MARIO_HERE_WE_GO, m->marioObj->header.gfx.cameraToObject);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
#else
2019-10-05 19:08:05 +00:00
play_sound(SOUND_MARIO_HERE_WE_GO, m->marioObj->header.gfx.cameraToObject);
2019-08-25 04:46:40 +00:00
#endif
return set_mario_action(m, ACT_RELEASING_BOWSER, 0);
}
if (m->angleVel[1] == 0) {
2019-09-01 19:50:50 +00:00
if (m->actionTimer++ > 120) {
2019-08-25 04:46:40 +00:00
return set_mario_action(m, ACT_RELEASING_BOWSER, 1);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
set_mario_animation(m, MARIO_ANIM_HOLDING_BOWSER);
} else {
m->actionTimer = 0;
set_mario_animation(m, MARIO_ANIM_SWINGING_BOWSER);
}
if (m->intendedMag > 20.0f) {
if (m->actionArg == 0) {
m->actionArg = 1;
m->twirlYaw = m->intendedYaw;
} else {
// spin = acceleration
spin = (s16)(m->intendedYaw - m->twirlYaw) / 0x80;
2019-09-01 19:50:50 +00:00
if (spin < -0x80) {
2019-08-25 04:46:40 +00:00
spin = -0x80;
2019-09-01 19:50:50 +00:00
}
if (spin > 0x80) {
2019-08-25 04:46:40 +00:00
spin = 0x80;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
m->twirlYaw = m->intendedYaw;
m->angleVel[1] += spin;
2019-09-01 19:50:50 +00:00
if (m->angleVel[1] > 0x1000) {
2019-08-25 04:46:40 +00:00
m->angleVel[1] = 0x1000;
2019-09-01 19:50:50 +00:00
}
if (m->angleVel[1] < -0x1000) {
2019-08-25 04:46:40 +00:00
m->angleVel[1] = -0x1000;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
}
} else {
m->actionArg = 0;
m->angleVel[1] = approach_s32(m->angleVel[1], 0, 64, 64);
}
// spin = starting yaw
spin = m->faceAngle[1];
m->faceAngle[1] += m->angleVel[1];
// play sound on overflow
2019-09-01 19:50:50 +00:00
if (m->angleVel[1] <= -0x100 && spin < m->faceAngle[1]) {
2020-04-03 18:57:26 +00:00
#ifdef VERSION_SH
queue_rumble_data(4, 20);
#endif
2019-10-05 19:08:05 +00:00
play_sound(SOUND_OBJ_BOWSER_SPINNING, m->marioObj->header.gfx.cameraToObject);
2019-09-01 19:50:50 +00:00
}
if (m->angleVel[1] >= 0x100 && spin > m->faceAngle[1]) {
2020-04-03 18:57:26 +00:00
#ifdef VERSION_SH
queue_rumble_data(4, 20);
#endif
2019-10-05 19:08:05 +00:00
play_sound(SOUND_OBJ_BOWSER_SPINNING, m->marioObj->header.gfx.cameraToObject);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
stationary_ground_step(m);
2019-09-01 19:50:50 +00:00
if (m->angleVel[1] >= 0) {
2019-08-25 04:46:40 +00:00
m->marioObj->header.gfx.angle[0] = -m->angleVel[1];
2019-09-01 19:50:50 +00:00
} else {
2019-08-25 04:46:40 +00:00
m->marioObj->header.gfx.angle[0] = m->angleVel[1];
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
return FALSE;
}
s32 act_releasing_bowser(struct MarioState *m) {
if (++m->actionTimer == 1) {
2019-09-01 19:50:50 +00:00
if (m->actionArg == 0) {
2020-04-03 18:57:26 +00:00
#ifdef VERSION_SH
queue_rumble_data(4, 50);
#endif
2019-08-25 04:46:40 +00:00
mario_throw_held_object(m);
2019-09-01 19:50:50 +00:00
} else {
2020-04-03 18:57:26 +00:00
#ifdef VERSION_SH
queue_rumble_data(4, 50);
#endif
2019-08-25 04:46:40 +00:00
mario_drop_held_object(m);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
}
m->angleVel[1] = 0;
animated_stationary_ground_step(m, MARIO_ANIM_RELEASE_BOWSER, ACT_IDLE);
return FALSE;
}
s32 check_common_object_cancels(struct MarioState *m) {
f32 waterSurface = m->waterLevel - 100;
2019-09-01 19:50:50 +00:00
if (m->pos[1] < waterSurface) {
2019-08-25 04:46:40 +00:00
return set_water_plunge_action(m);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->input & INPUT_SQUISHED) {
2019-08-25 04:46:40 +00:00
return drop_and_set_mario_action(m, ACT_SQUISHED, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (m->health < 0x100) {
2019-08-25 04:46:40 +00:00
return drop_and_set_mario_action(m, ACT_STANDING_DEATH, 0);
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
return FALSE;
}
s32 mario_execute_object_action(struct MarioState *m) {
s32 cancel;
2019-09-01 19:50:50 +00:00
if (check_common_object_cancels(m)) {
2019-08-25 04:46:40 +00:00
return TRUE;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
if (mario_update_quicksand(m, 0.5f)) {
2019-08-25 04:46:40 +00:00
return TRUE;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
/* clang-format off */
switch (m->action) {
case ACT_PUNCHING: cancel = act_punching(m); break;
case ACT_PICKING_UP: cancel = act_picking_up(m); break;
case ACT_DIVE_PICKING_UP: cancel = act_dive_picking_up(m); break;
case ACT_STOMACH_SLIDE_STOP: cancel = act_stomach_slide_stop(m); break;
case ACT_PLACING_DOWN: cancel = act_placing_down(m); break;
case ACT_THROWING: cancel = act_throwing(m); break;
case ACT_HEAVY_THROW: cancel = act_heavy_throw(m); break;
case ACT_PICKING_UP_BOWSER: cancel = act_picking_up_bowser(m); break;
case ACT_HOLDING_BOWSER: cancel = act_holding_bowser(m); break;
case ACT_RELEASING_BOWSER: cancel = act_releasing_bowser(m); break;
}
/* clang-format on */
2019-09-01 19:50:50 +00:00
if (!cancel && (m->input & INPUT_IN_WATER)) {
2020-03-02 03:42:52 +00:00
m->particleFlags |= PARTICLE_IDLE_WATER_WAVE;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
return cancel;
}