+1








f3e61a31aa
* buffers: refresh 15 and revert to base decomp * behavior script * color helper functions * extended bounds * egeo_layout * fixed model ids * camera conf improved * message panel ucode small * graph node * level script * mathutil updates * mathutil updates (allow unused funcs) * behaviors a - beta_fish * Add librtc and fix some data declarations * Move GRUCODE define to proper location in makefile * Refresh 15 * extra * Make ROM name smaller and change messages printed on build a bit * Fix console (lol) * Update UNF to latest master * Make ucode load from .o's (and also fix Super3D) * Fix crash with rumble + custom mario model * graph node and mathutil * removed behaviors * Ldtob documentation * _Putfld labeling * area * behavior actions * camera * debug updates * bubbles * envfx snow * farcall helpers * game init * geo misc * hud * only check if VC on render init * ingame menu * revert goddard to base decomp * insn disasm * interaction documentation * level geo * level update defines * macro special objects formatting changes * main.h documentation * map parser documentation & formatting * airborne documentation * mario actions automatic documentation * mario actions cutscene documentation * mario actions moving documentation and options * mario actions object documentation and options * mario stationary documentation * mario submerged documentation * mario misc documentation * mario step: ledge grab fixes and documentation * mario documentation * memory.h documentation * moving textures * object behaviors * object collision * fix flamethrower bug * object helpers * object list processor documentation * paintings * platform displacement * print / printf * puppycam absf * puppyprint updates and formatting changes * rendering graph node performance optimizations * rumble opt and doc * hqvm back to ultrasm64 * save file documentation and unlock defines * s2d engine * reset various files to ultrasm64 * file select * intro geo documentation * screen transition documentation * segment2.h * shadow overhaul * skybox refactor * sound init: clean up define usage + documentation * spawn object optimizations and documentation * spawn sound cleanup * sram to ultrasm64 * star select cleanup * title screen cleanup * dialogs / text * rename stomp smoke * stomp smoke -> small water splash * updated README * compilation flags * optimized file positions + support function/data sections * surface collision performance improvements * surface load optimizations * camera conf documentation * Allow easier command for opening puppyprint debug * Rearranged framebuffers & fixed puppyprint console printing * Fix shadow scaling and shifting * Fix SILHOUETTE, OBJECTS_REJ, and ucode loading, also clean up render phase system a bit. * Fixed build with BETTER_HANGING off * Clean up OBJECTS_REJ ifdefs * Fix duplicate comment & graph render layers/flags bitmask * Fixed build with BETTER_HANGING off * Fix Fast64 importing by reverting sSegmentTable change * Readded missing functions that caused build errors with Mario head enabled * Fixed clang compilation issues * Add INTER mode for geo_update_layer_transparency * Fix build warnings * bugfix: miscalculation in obj_turn_toward_object * Some puppytech fixes * Further Puppycamera fixes * Fix BUGFIX_DIALOG_TIME_STOP Fixes #136 * Fix sliding platform bparams * Add LEGACY_SHADOW_IDS define for Fast64 compatibility * Apply suggested changes * Better find_in_bounds_yaw_wdw_bob_thi ifdef * Fix build warnings for unused functions * Fixed stale reference bug from obj_mark_for_deletion change * Fixed incorrect digit for 100s #145 * Change groundpound-fix define and functionality to just disable bonking * Fixed puppyroll #134 * Adjust height value for terrain angle to kick in * fixed hi score flashing * Remove menudata backup (#131) Not considered important enough to keep * Fix fread() build warning * Add COURSE_NUM_TO_INDEX to save_file_get_star_flags check in bhv_unagi_init * Fix approach_s16 return value * Use boolean defines for oCapDoScaleVertically * Make the door lock a part of the key door model to eliminate z-fighting, also reduce z fighting on numbered doors with AUTO_LOD enabled. * Move flames to LAYER_TRANSPARENT_INTER * Resolved some compiler warnings and added FALL_THROUGH define (#168) * Address some more compiler warnings with different define toggles * Remove unnecessary fallthrough attribute * fixed geo_process_billboard floating point exception * Allow water to face any direction * Initialize focOffset so that BBH doesn't crash * Removed superfluous RDP commands when switching microcodes which would override scissor * Set OBJ_FLAG_DONT_CALC_COLL_DIST on bhvUkikiCage * Fix rumble build * Fixed UNLOCK_FPS strobing * Update src/game/object_helpers.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Update src/game/object_helpers.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Fix LEGACY_SHADOW_IDS id conflict * Use the vanilla default value for rotating fire bars if bparam2 is 0 * START_LEVEL safeguard * Fix some drawing distance issues caused by AUTO_COLLISION_DISTANCE * Fix rumble build * Fixed spline poll code using the wrong values for keyframes * Update readme with better credits Better credits for individual contributors * add arthur * added falco and moose * add fazana * le funny typo * added S2DEX engine to credits * silhouette + axo + ratio * remove specific callouts + add auto col distance * Update data/behavior_data.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Update data/behavior_data.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Update data/behavior_data.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Revert formatting changes to match vanilla decomp * Re-implement Y buffer for find_ceil * Re-implement POWER_STARS_HEAL for normal Power Stars * Start level comment & exit course comment/collapse * utilize reonucam technique for FAST_VERTICAL_CAMERA_MOVEMENT * Fix "MAX_REFERENCED_WALLS" typo * Allow stop_and_set_height_to_floor to work at any height if Mario is teleporting (#213) * Revert stop_and_set_height_to_floor to vanilla Fixes #208 * Fixed sAudioEnabled so that it disables audio CPU processing as well * Fixed puppyprint debug RDP us calculations * Renamed sAudioEnabled to gAudioEnabled * Replaced mtxf_to_mtx_asm with an equivalent implementation that supports WORLD_SCALE * Moved extended bounds and world scale configuration to a new config_world.h file * Default all objects to non-rej (#227) Fixes #221 (Default all objects to non-rej) * Fix #221 * Fix VISUAL_DEBUG breaking/crashing when OBJECTS_REJ is disabled (#211) * Fix VISUAL_DEBUG breaking/crashing when OBJECTS_REJ is disabled * Change vtl decrement in visual_surface_display from 6 to 3 Fixes #207 * Make area in SL igloo wider to prevent a softlock (#233) Fixes #210 * Fix coin formation coins being deleted if they spawn in the middle of a floor, also fix TTM slide coin position (#232) Fixes #201 * Make UNLOCK_ALL apply to more things * Fix wrong ifdef/ifndef in bhv_invisible_objects_under_bridge_init * Change chain chomp load/unload distances depending on number of segments (#237) Fixes #192 * added WATER_PLUNGE_UPWARP define * Add reonucam patch (#239) * added reonucam patch Fixes #218 * Fix how shadows handle water/transparency/height (#228) * Fix how shadows handle water/transparency/height * Change shadow check for flying carpets from a level specific check to a oPlatformOnTrackType check Fixes #179 * added reonucam credit * delete unnecesary patches * Apply suggested changes * murdered more patches * UNLOCK_ALL unlocks the cap boxes * UNLOCK_ALL unlocks cap boxes (slightly more epic edition) * revert ceil buffer * Renamed HD_INTRO_TEXTURES define, separated intro floombas * prevent double definition of floombas * actually prevent floomba redefinition * Develop/refactor default defines (#242) * Changed default config options * Added build dir to includePaths for pngs * disable NO_SLEEP by default * Disable puppyprint by default Sorry fazana 😔 * fix typos * add comment about BETTER_REVERB console perf * disable blue coin switch retry by default * Update config_audio.h Co-authored-by: Reonu <danileon95@gmail.com> Co-authored-by: Mr-Wiseguy <68165316+Mr-Wiseguy@users.noreply.github.com> * revert air step line to vanilla to fix bitfs scaling platform issue (#247) Fixes #200 * Fix stuttering on thin slopes (#248) * Fix stuttering on thin slopes * Revert vec3f_find_ceil calls to vanilla * Rename vec3f_find_ceil to find_mario_ceil * Update src/engine/surface_collision.h Fixes #249 * Swap static and dynamic surface checks back to vanilla order (#253) * Swap static and dynamic surface checks back to vanilla order * re-enable DISABLE_ALL config Fixes #251 #252 * Fixed save and quitting while in widescreen (#257) * Fixed save and quitting while in widescreen * use define for the level * all my homies hate ifdefs * skip wall offsets < 0 (#255) Fixes #255 * #264: Document non-stop stars' issues (#267) * #264: Document non-stop stars' issues * Update include/config/config_game.h * nonstop vanilla comment * derive margin_radius from radius after capping at 200 (#266) Fixes #259 * Config cleanup/refactor (#269) * Moved puppyprint define to graphics / rearranged some debug defines for ease of access * Moved compatibility safeguards to config_safeguards.h * spacing and comment formatting * #272 Move GFX_POOL_SIZE to config_graphics.h * disable EASIER_DIALOG_TRIGGER by default * prevent redefining warnings * small ifdef typo * changed ifndef to undefs Fixes #262 Fixes #272 * Improved movement config documentation related to turning around (#271) Fixes #270 * rename CUSTOM_DEBUG, add comments (#275) * Update README.md (#277) * v2.0.0 Co-authored-by: CrashOveride95 <crashoveride953@gmail.com> Co-authored-by: Arceveti <73617174+Arceveti@users.noreply.github.com> Co-authored-by: n64 <n64> Co-authored-by: Fazana <52551480+FazanaJ@users.noreply.github.com> Co-authored-by: Mr-Wiseguy <mrwiseguyromhacking@gmail.com> Co-authored-by: aglab2 <aglab3@gmail.com> Co-authored-by: gheskett <gheskett@gmail.com> Co-authored-by: Reonu <danileon95@gmail.com> Co-authored-by: Axollyon <20480418+Axollyon@users.noreply.github.com> Co-authored-by: Mr-Wiseguy <68165316+Mr-Wiseguy@users.noreply.github.com>
485 lines
15 KiB
C
485 lines
15 KiB
C
#include <PR/ultratypes.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 "engine/math_util.h"
|
|
#include "rumble_init.h"
|
|
|
|
/**
|
|
* 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);
|
|
if (is_anim_at_end(m)) {
|
|
set_mario_action(m, endAction, 0);
|
|
}
|
|
}
|
|
|
|
s32 mario_update_punch_sequence(struct MarioState *m) {
|
|
u32 endAction, crouchEndAction;
|
|
s32 animFrame;
|
|
|
|
if (m->action & ACT_FLAG_MOVING) {
|
|
endAction = ACT_WALKING, crouchEndAction = ACT_CROUCH_SLIDE;
|
|
} else {
|
|
endAction = ACT_IDLE, crouchEndAction = ACT_CROUCHING;
|
|
}
|
|
|
|
switch (m->actionArg) {
|
|
case ACT_ARG_PUNCH_SEQUENCE_YAH:
|
|
play_sound(SOUND_MARIO_PUNCH_YAH, m->marioObj->header.gfx.cameraToObject);
|
|
FALL_THROUGH;
|
|
case ACT_ARG_PUNCH_SEQUENCE_FIRST_PUNCH:
|
|
set_mario_animation(m, MARIO_ANIM_FIRST_PUNCH);
|
|
if (is_anim_past_end(m)) {
|
|
m->actionArg = ACT_ARG_PUNCH_SEQUENCE_FIRST_PUNCH_FAST;
|
|
} else {
|
|
m->actionArg = ACT_ARG_PUNCH_SEQUENCE_FIRST_PUNCH;
|
|
}
|
|
|
|
if (m->marioObj->header.gfx.animInfo.animFrame >= 2) {
|
|
if (mario_check_object_grab(m)) {
|
|
return TRUE;
|
|
}
|
|
|
|
m->flags |= MARIO_PUNCHING;
|
|
}
|
|
|
|
if (m->actionArg == ACT_ARG_PUNCH_SEQUENCE_FIRST_PUNCH_FAST) {
|
|
m->marioBodyState->punchState = (PUNCH_STATE_TYPE_FIRST_PUNCH | 0x4);
|
|
}
|
|
break;
|
|
|
|
case ACT_ARG_PUNCH_SEQUENCE_FIRST_PUNCH_FAST:
|
|
set_mario_animation(m, MARIO_ANIM_FIRST_PUNCH_FAST);
|
|
|
|
if (m->marioObj->header.gfx.animInfo.animFrame <= 0) {
|
|
m->flags |= MARIO_PUNCHING;
|
|
}
|
|
|
|
if (m->input & INPUT_B_PRESSED) {
|
|
m->actionArg = ACT_ARG_PUNCH_SEQUENCE_WAH;
|
|
}
|
|
|
|
if (is_anim_at_end(m)) {
|
|
set_mario_action(m, endAction, 0);
|
|
}
|
|
break;
|
|
|
|
case ACT_ARG_PUNCH_SEQUENCE_WAH:
|
|
play_sound(SOUND_MARIO_PUNCH_WAH, m->marioObj->header.gfx.cameraToObject);
|
|
// fallthrough
|
|
case ACT_ARG_PUNCH_SEQUENCE_SECOND_PUNCH:
|
|
set_mario_animation(m, MARIO_ANIM_SECOND_PUNCH);
|
|
if (is_anim_past_end(m)) {
|
|
m->actionArg = ACT_ARG_PUNCH_SEQUENCE_SECOND_PUNCH_FAST;
|
|
} else {
|
|
m->actionArg = ACT_ARG_PUNCH_SEQUENCE_SECOND_PUNCH;
|
|
}
|
|
|
|
if (m->marioObj->header.gfx.animInfo.animFrame > 0) {
|
|
m->flags |= MARIO_PUNCHING;
|
|
}
|
|
|
|
if (m->actionArg == ACT_ARG_PUNCH_SEQUENCE_SECOND_PUNCH_FAST) {
|
|
m->marioBodyState->punchState = (PUNCH_STATE_TYPE_SECOND_PUNCH | 0x4);
|
|
}
|
|
break;
|
|
|
|
case ACT_ARG_PUNCH_SEQUENCE_SECOND_PUNCH_FAST:
|
|
set_mario_animation(m, MARIO_ANIM_SECOND_PUNCH_FAST);
|
|
if (m->marioObj->header.gfx.animInfo.animFrame <= 0) {
|
|
m->flags |= MARIO_PUNCHING;
|
|
}
|
|
|
|
if (m->input & INPUT_B_PRESSED) {
|
|
m->actionArg = ACT_ARG_PUNCH_SEQUENCE_GROUND_KICK;
|
|
}
|
|
|
|
if (is_anim_at_end(m)) {
|
|
set_mario_action(m, endAction, 0);
|
|
}
|
|
break;
|
|
|
|
case ACT_ARG_PUNCH_SEQUENCE_GROUND_KICK:
|
|
play_mario_action_sound(m, SOUND_MARIO_PUNCH_HOO, 1);
|
|
animFrame = set_mario_animation(m, MARIO_ANIM_GROUND_KICK);
|
|
if (animFrame == 0) {
|
|
m->marioBodyState->punchState = (PUNCH_STATE_TYPE_KICK | 0x6);
|
|
}
|
|
|
|
if (animFrame >= 0 && animFrame < 8) {
|
|
m->flags |= MARIO_KICKING;
|
|
}
|
|
|
|
if (is_anim_at_end(m)) {
|
|
set_mario_action(m, endAction, 0);
|
|
}
|
|
break;
|
|
|
|
case ACT_ARG_PUNCH_SEQUENCE_BREAKDANCE:
|
|
play_mario_action_sound(m, SOUND_MARIO_PUNCH_HOO, 1);
|
|
set_mario_animation(m, MARIO_ANIM_BREAKDANCE);
|
|
animFrame = m->marioObj->header.gfx.animInfo.animFrame;
|
|
|
|
if (animFrame >= 2 && animFrame < 8) {
|
|
m->flags |= MARIO_TRIPPING;
|
|
}
|
|
|
|
if (is_anim_at_end(m)) {
|
|
set_mario_action(m, crouchEndAction, 0);
|
|
}
|
|
break;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
s32 act_punching(struct MarioState *m) {
|
|
if (m->input & INPUT_STOMPED) {
|
|
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
|
|
}
|
|
|
|
if (m->input & (INPUT_NONZERO_ANALOG | INPUT_A_PRESSED | INPUT_OFF_FLOOR | INPUT_ABOVE_SLIDE)) {
|
|
return check_common_action_exits(m);
|
|
}
|
|
|
|
if (m->actionState == ACT_STATE_PUNCHING_CAN_JUMP_KICK && (m->input & INPUT_A_DOWN)) {
|
|
return set_mario_action(m, ACT_JUMP_KICK, 0);
|
|
}
|
|
|
|
m->actionState = ACT_STATE_PUNCHING_NO_JUMP_KICK;
|
|
if (m->actionArg == 0) {
|
|
m->actionTimer = 7;
|
|
}
|
|
|
|
mario_set_forward_vel(m, sPunchingForwardVelocities[m->actionTimer]);
|
|
if (m->actionTimer > 0) {
|
|
m->actionTimer--;
|
|
}
|
|
|
|
mario_update_punch_sequence(m);
|
|
perform_ground_step(m);
|
|
return FALSE;
|
|
}
|
|
|
|
s32 act_picking_up(struct MarioState *m) {
|
|
if (m->input & INPUT_STOMPED) {
|
|
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
|
|
}
|
|
|
|
if (m->input & INPUT_OFF_FLOOR) {
|
|
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
|
|
}
|
|
|
|
if (m->actionState == ACT_STATE_PICKING_UP_GRAB && 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);
|
|
play_sound_if_no_flag(m, SOUND_MARIO_HRMM, MARIO_MARIO_SOUND_PLAYED);
|
|
m->actionState = ACT_STATE_PICKING_UP_HOLDING;
|
|
}
|
|
|
|
if (m->actionState == ACT_STATE_PICKING_UP_HOLDING) {
|
|
if (m->heldObj->oInteractionSubtype & INT_SUBTYPE_GRABS_MARIO) {
|
|
m->marioBodyState->grabPos = GRAB_POS_HEAVY_OBJ;
|
|
set_mario_animation(m, MARIO_ANIM_GRAB_HEAVY_OBJECT);
|
|
if (is_anim_at_end(m)) {
|
|
set_mario_action(m, ACT_HOLD_HEAVY_IDLE, 0);
|
|
}
|
|
} else {
|
|
m->marioBodyState->grabPos = GRAB_POS_LIGHT_OBJ;
|
|
set_mario_animation(m, MARIO_ANIM_PICK_UP_LIGHT_OBJ);
|
|
if (is_anim_at_end(m)) {
|
|
set_mario_action(m, ACT_HOLD_IDLE, 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
stationary_ground_step(m);
|
|
return FALSE;
|
|
}
|
|
|
|
s32 act_dive_picking_up(struct MarioState *m) {
|
|
if (m->input & INPUT_STOMPED) {
|
|
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
|
|
}
|
|
|
|
#ifdef HANDS_FREE_HOLDING_FIX
|
|
if (m->input & INPUT_OFF_FLOOR) {
|
|
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
|
|
}
|
|
if (m->input & INPUT_ABOVE_SLIDE) {
|
|
return drop_and_set_mario_action(m, ACT_BEGIN_SLIDING, 0);
|
|
}
|
|
#else
|
|
//! 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.
|
|
if (m->input & INPUT_OFF_FLOOR) {
|
|
return set_mario_action(m, ACT_FREEFALL, 0);
|
|
}
|
|
|
|
if (m->input & INPUT_ABOVE_SLIDE) {
|
|
return set_mario_action(m, ACT_BEGIN_SLIDING, 0);
|
|
}
|
|
#endif
|
|
|
|
animated_stationary_ground_step(m, MARIO_ANIM_STOP_SLIDE_LIGHT_OBJ, ACT_HOLD_IDLE);
|
|
return FALSE;
|
|
}
|
|
|
|
s32 act_placing_down(struct MarioState *m) {
|
|
if (m->input & INPUT_STOMPED) {
|
|
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
|
|
}
|
|
|
|
if (m->input & INPUT_OFF_FLOOR) {
|
|
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
|
|
}
|
|
|
|
if (++m->actionTimer == 8) {
|
|
mario_drop_held_object(m);
|
|
}
|
|
|
|
animated_stationary_ground_step(m, MARIO_ANIM_PLACE_LIGHT_OBJ, ACT_IDLE);
|
|
return FALSE;
|
|
}
|
|
|
|
s32 act_throwing(struct MarioState *m) {
|
|
if (m->heldObj && (m->heldObj->oInteractionSubtype & INT_SUBTYPE_HOLDABLE_NPC)) {
|
|
return set_mario_action(m, ACT_PLACING_DOWN, 0);
|
|
}
|
|
|
|
if (m->input & INPUT_STOMPED) {
|
|
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
|
|
}
|
|
|
|
if (m->input & INPUT_OFF_FLOOR) {
|
|
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
|
|
}
|
|
|
|
if (++m->actionTimer == 7) {
|
|
mario_throw_held_object(m);
|
|
play_sound_if_no_flag(m, SOUND_MARIO_WAH2, MARIO_MARIO_SOUND_PLAYED);
|
|
play_sound_if_no_flag(m, SOUND_ACTION_THROW, MARIO_ACTION_SOUND_PLAYED);
|
|
#if ENABLE_RUMBLE
|
|
queue_rumble_data(3, 50);
|
|
#endif
|
|
}
|
|
|
|
animated_stationary_ground_step(m, MARIO_ANIM_GROUND_THROW, ACT_IDLE);
|
|
return FALSE;
|
|
}
|
|
|
|
s32 act_heavy_throw(struct MarioState *m) {
|
|
if (m->input & INPUT_STOMPED) {
|
|
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
|
|
}
|
|
|
|
if (m->input & INPUT_OFF_FLOOR) {
|
|
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
|
|
}
|
|
|
|
if (++m->actionTimer == 13) {
|
|
mario_drop_held_object(m);
|
|
play_sound_if_no_flag(m, SOUND_MARIO_WAH2, MARIO_MARIO_SOUND_PLAYED);
|
|
play_sound_if_no_flag(m, SOUND_ACTION_THROW, MARIO_ACTION_SOUND_PLAYED);
|
|
#if ENABLE_RUMBLE
|
|
queue_rumble_data(3, 50);
|
|
#endif
|
|
}
|
|
|
|
animated_stationary_ground_step(m, MARIO_ANIM_HEAVY_THROW, ACT_IDLE);
|
|
return FALSE;
|
|
}
|
|
|
|
s32 act_stomach_slide_stop(struct MarioState *m) {
|
|
if (m->input & INPUT_STOMPED) {
|
|
return set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
|
|
}
|
|
|
|
if (m->input & INPUT_OFF_FLOOR) {
|
|
return set_mario_action(m, ACT_FREEFALL, 0);
|
|
}
|
|
|
|
if (m->input & INPUT_ABOVE_SLIDE) {
|
|
return set_mario_action(m, ACT_BEGIN_SLIDING, 0);
|
|
}
|
|
|
|
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 == ACT_STATE_PICKING_UP_GRAB) {
|
|
m->actionState = ACT_STATE_PICKING_UP_HOLDING;
|
|
m->angleVel[1] = 0;
|
|
m->marioBodyState->grabPos = GRAB_POS_BOWSER;
|
|
mario_grab_used_object(m);
|
|
#if ENABLE_RUMBLE
|
|
queue_rumble_data(5, 80);
|
|
#endif
|
|
play_sound(SOUND_MARIO_HRMM, m->marioObj->header.gfx.cameraToObject);
|
|
}
|
|
|
|
set_mario_animation(m, MARIO_ANIM_GRAB_BOWSER);
|
|
if (is_anim_at_end(m)) {
|
|
set_mario_action(m, ACT_HOLDING_BOWSER, 0);
|
|
}
|
|
|
|
stationary_ground_step(m);
|
|
return FALSE;
|
|
}
|
|
|
|
s32 act_holding_bowser(struct MarioState *m) {
|
|
s16 spin;
|
|
|
|
if (m->input & INPUT_B_PRESSED) {
|
|
if (m->angleVel[1] <= -0xE00 || m->angleVel[1] >= 0xE00) {
|
|
play_sound(SOUND_MARIO_SO_LONGA_BOWSER, m->marioObj->header.gfx.cameraToObject);
|
|
} else {
|
|
play_sound(SOUND_MARIO_HERE_WE_GO, m->marioObj->header.gfx.cameraToObject);
|
|
}
|
|
return set_mario_action(m, ACT_RELEASING_BOWSER, 0);
|
|
}
|
|
|
|
if (m->angleVel[1] == 0) {
|
|
if (m->actionTimer++ > 120) {
|
|
return set_mario_action(m, ACT_RELEASING_BOWSER, 1);
|
|
}
|
|
|
|
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;
|
|
|
|
spin = CLAMP(spin, -0x80, 0x80);
|
|
|
|
m->twirlYaw = m->intendedYaw;
|
|
m->angleVel[1] += spin;
|
|
|
|
m->angleVel[1] = CLAMP(m->angleVel[1], -0x1000, 0x1000);
|
|
}
|
|
} else {
|
|
m->actionArg = 0;
|
|
m->angleVel[1] = approach_s32(m->angleVel[1], 0x0, 0x40, 0x40);
|
|
}
|
|
|
|
// spin = starting yaw
|
|
spin = m->faceAngle[1];
|
|
m->faceAngle[1] += m->angleVel[1];
|
|
|
|
// play sound on overflow
|
|
if (m->angleVel[1] <= -0x100 && spin < m->faceAngle[1]) {
|
|
#if ENABLE_RUMBLE
|
|
queue_rumble_data(4, 20);
|
|
#endif
|
|
play_sound(SOUND_OBJ_BOWSER_SPINNING, m->marioObj->header.gfx.cameraToObject);
|
|
}
|
|
if (m->angleVel[1] >= 0x100 && spin > m->faceAngle[1]) {
|
|
#if ENABLE_RUMBLE
|
|
queue_rumble_data(4, 20);
|
|
#endif
|
|
play_sound(SOUND_OBJ_BOWSER_SPINNING, m->marioObj->header.gfx.cameraToObject);
|
|
}
|
|
|
|
stationary_ground_step(m);
|
|
if (m->angleVel[1] >= 0) {
|
|
m->marioObj->header.gfx.angle[0] = -m->angleVel[1];
|
|
} else {
|
|
m->marioObj->header.gfx.angle[0] = m->angleVel[1];
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
s32 act_releasing_bowser(struct MarioState *m) {
|
|
if (++m->actionTimer == 1) {
|
|
if (m->actionArg == 0) {
|
|
#if ENABLE_RUMBLE
|
|
queue_rumble_data(5, 50);
|
|
#endif
|
|
mario_throw_held_object(m);
|
|
} else {
|
|
#if ENABLE_RUMBLE
|
|
queue_rumble_data(4, 50);
|
|
#endif
|
|
mario_drop_held_object(m);
|
|
}
|
|
}
|
|
|
|
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;
|
|
if (m->pos[1] < waterSurface) {
|
|
return set_water_plunge_action(m);
|
|
}
|
|
|
|
if (m->input & INPUT_SQUISHED) {
|
|
return drop_and_set_mario_action(m, ACT_SQUISHED, 0);
|
|
}
|
|
|
|
if (m->health < 0x100) {
|
|
return drop_and_set_mario_action(m, ACT_STANDING_DEATH, 0);
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
s32 mario_execute_object_action(struct MarioState *m) {
|
|
s32 cancel = FALSE;
|
|
|
|
if (check_common_object_cancels(m)) {
|
|
return TRUE;
|
|
}
|
|
|
|
if (mario_update_quicksand(m, 0.5f)) {
|
|
return TRUE;
|
|
}
|
|
|
|
/* 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 */
|
|
|
|
if (!cancel && (m->input & INPUT_IN_WATER)) {
|
|
m->particleFlags |= PARTICLE_IDLE_WATER_WAVE;
|
|
}
|
|
|
|
return cancel;
|
|
}
|