From b87421dd9df5fcc90c8b93a28a4c88a56b4a7307 Mon Sep 17 00:00:00 2001 From: MysterD Date: Sat, 12 Mar 2022 02:12:11 -0800 Subject: [PATCH] Made death animations/warps a lot less janky --- src/game/interaction.c | 40 +++++++++---------- src/game/mario.c | 18 +++++++++ src/game/mario.h | 1 + src/game/mario_actions_airborne.c | 10 ++--- src/game/mario_actions_automatic.c | 2 +- src/game/mario_actions_cutscene.c | 38 ++++++++---------- src/game/mario_actions_submerged.c | 12 ++++-- src/pc/controller/controller_keyboard_debug.c | 2 +- 8 files changed, 71 insertions(+), 52 deletions(-) diff --git a/src/game/interaction.c b/src/game/interaction.c index 398f7422..338abe8e 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -2163,30 +2163,30 @@ void mario_process_interactions(struct MarioState *m) { } void check_death_barrier(struct MarioState *m) { - if (!gServerSettings.bubbleDeath) { - if (m->pos[1] < m->floorHeight + 2048.0f) { - if (level_trigger_warp(m, WARP_OP_WARP_FLOOR) == 20 && !(m->flags & MARIO_UNKNOWN_18)) { - play_sound(SOUND_MARIO_WAAAOOOW, m->marioObj->header.gfx.cameraToObject); - } - } - return; - } + if (m->playerIndex != 0) { return; } if (m->pos[1] < m->floorHeight + 2048.0f) { - switch (gCurrCourseNum) { - case COURSE_COTMC: // (20) Cavern of the Metal Cap - case COURSE_TOTWC: // (21) Tower of the Wing Cap - case COURSE_VCUTM: // (22) Vanish Cap Under the Moat - case COURSE_WMOTR: // (23) Winged Mario over the Rainbow - break; - default: - m->pos[1] = m->floorHeight + 2048.0f; - if (m->vel[1] < 0) { m->vel[1] = 0; } - mario_set_bubbled(m); - return; + if (mario_can_bubble(m)) { + switch (gCurrCourseNum) { + case COURSE_COTMC: // (20) Cavern of the Metal Cap + case COURSE_TOTWC: // (21) Tower of the Wing Cap + case COURSE_VCUTM: // (22) Vanish Cap Under the Moat + case COURSE_WMOTR: // (23) Winged Mario over the Rainbow + break; + default: + mario_set_bubbled(m); + return; + } } + + if (m->action == ACT_BUBBLED) { + m->pos[1] = m->floorHeight + 2048.0f; + if (m->vel[1] < 0) { m->vel[1] = 0; } + return; + } + if (level_trigger_warp(m, WARP_OP_WARP_FLOOR) == 20 && !(m->flags & MARIO_UNKNOWN_18)) { - play_character_sound(m, CHAR_SOUND_WAAAOOOW); + play_sound(SOUND_MARIO_WAAAOOOW, m->marioObj->header.gfx.cameraToObject); } } } diff --git a/src/game/mario.c b/src/game/mario.c index 09c98359..92c697c1 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -36,6 +36,7 @@ #include "save_file.h" #include "sound_init.h" #include "thread6.h" +#include "obj_behaviors.h" #include "pc/configfile.h" #include "pc/cheats.h" #include "pc/network/network.h" @@ -394,6 +395,23 @@ void play_mario_sound(struct MarioState *m, s32 actionSound, s32 marioSound) { * ACTIONS * **************************************************/ +bool mario_can_bubble(struct MarioState* m) { + if (!gServerSettings.bubbleDeath) { return false; } + if (m->playerIndex != 0) { return false; } + if (m->action == ACT_BUBBLED) { return false; } + + u8 allInBubble = TRUE; + for (int i = 1; i < MAX_PLAYERS; i++) { + if (!is_player_active(&gMarioStates[i])) { continue; } + if (gMarioStates[i].action != ACT_BUBBLED && gMarioStates[i].health >= 0x100) { + allInBubble = FALSE; + break; + } + } + if (allInBubble) { return false; } + return true; +} + void mario_set_bubbled(struct MarioState* m) { if (m->playerIndex != 0) { return; } if (m->action == ACT_BUBBLED) { return; } diff --git a/src/game/mario.h b/src/game/mario.h index 5c9d0e3c..7443bb90 100644 --- a/src/game/mario.h +++ b/src/game/mario.h @@ -27,6 +27,7 @@ void play_mario_landing_sound_once(struct MarioState *m, u32 soundBits); void play_mario_heavy_landing_sound(struct MarioState *m, u32 soundBits); void play_mario_heavy_landing_sound_once(struct MarioState *m, u32 soundBits); void play_mario_sound(struct MarioState *m, s32 primarySoundBits, s32 scondarySoundBits); +bool mario_can_bubble(struct MarioState* m); void mario_set_bubbled(struct MarioState* m); void mario_set_forward_vel(struct MarioState *m, f32 speed); s32 mario_get_floor_class(struct MarioState *m); diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 1a79fc9e..0c925f00 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -1569,13 +1569,11 @@ s32 act_lava_boost(struct MarioState *m) { if (m != &gMarioStates[0]) { // never kill remote marios m->health = 0x100; + } else if (mario_can_bubble(m)) { + m->health = 0xFF; + mario_set_bubbled(m); } else { - if (gServerSettings.bubbleDeath) { - m->health = 0xFF; - mario_set_bubbled(m); - } else { - level_trigger_warp(m, WARP_OP_DEATH); - } + level_trigger_warp(m, WARP_OP_DEATH); } } diff --git a/src/game/mario_actions_automatic.c b/src/game/mario_actions_automatic.c index 7ab8cf1e..48047f47 100644 --- a/src/game/mario_actions_automatic.c +++ b/src/game/mario_actions_automatic.c @@ -945,7 +945,7 @@ s32 act_bubbled(struct MarioState* m) { } if (allInBubble) { level_trigger_warp(m, WARP_OP_DEATH); - return set_mario_action(m, ACT_DEATH_ON_BACK, 0); + return set_mario_action(m, ACT_SOFT_BONK, 0); } } diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index 999be621..1e6d07e1 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -762,7 +762,9 @@ s32 act_fall_after_star_grab(struct MarioState *m) { s32 common_death_handler(struct MarioState *m, s32 animation, s32 frameToDeathWarp) { s32 animFrame = set_mario_animation(m, animation); if (animFrame == frameToDeathWarp) { - if (gServerSettings.bubbleDeath) { + if (m->playerIndex != 0) { + // do nothing + } else if (mario_can_bubble(m)) { mario_set_bubbled(m); } else { level_trigger_warp(m, WARP_OP_DEATH); @@ -825,7 +827,9 @@ s32 act_quicksand_death(struct MarioState *m) { play_character_sound_if_no_flag(m, CHAR_SOUND_WAAAOOOW, MARIO_MARIO_SOUND_PLAYED); } if ((m->quicksandDepth += 5.0f) >= 180.0f) { - if (gServerSettings.bubbleDeath) { + if (m->playerIndex != 0) { + // do nothing + } else if (mario_can_bubble(m)) { mario_set_bubbled(m); } else { level_trigger_warp(m, WARP_OP_DEATH); @@ -841,18 +845,14 @@ s32 act_quicksand_death(struct MarioState *m) { s32 act_eaten_by_bubba(struct MarioState *m) { play_character_sound_if_no_flag(m, CHAR_SOUND_DYING, MARIO_ACTION_SOUND_PLAYED); set_mario_animation(m, MARIO_ANIM_A_POSE); - if (m != &gMarioStates[0]) { - // never kill remote marios - m->health = 0x100; - } - if (gServerSettings.bubbleDeath) { - if (m->playerIndex == 0) { + + if (m->actionTimer++ == 60) { + if (m->playerIndex != 0) { + // do nothing + } else if (mario_can_bubble(m)) { m->health = 0xFF; mario_set_bubbled(m); - } - } else { - m->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; - if (m->actionTimer++ == 60) { + } else { level_trigger_warp(m, WARP_OP_DEATH); } } @@ -1717,19 +1717,15 @@ s32 act_squished(struct MarioState *m) { // squished for more than 10 seconds, so kill Mario if (m->actionArg++ > 300) { - // 0 units of health - if (m != &gMarioStates[0]) { + if (m->playerIndex != 0) { // never kill remote marios m->health = 0x100; - } else if (gServerSettings.bubbleDeath) { - m->health = 0xFF; - } - - m->hurtCounter = 0; - - if (gServerSettings.bubbleDeath) { + } else if (mario_can_bubble(m)) { mario_set_bubbled(m); } else { + // 0 units of health + m->health = 0x00FF; + m->hurtCounter = 0; level_trigger_warp(m, WARP_OP_DEATH); // woosh, he's gone! set_mario_action(m, ACT_DISAPPEARED, 0); diff --git a/src/game/mario_actions_submerged.c b/src/game/mario_actions_submerged.c index 47a9c1e8..8454287f 100644 --- a/src/game/mario_actions_submerged.c +++ b/src/game/mario_actions_submerged.c @@ -928,7 +928,9 @@ static s32 act_drowning(struct MarioState *m) { set_mario_animation(m, MARIO_ANIM_DROWNING_PART2); m->marioBodyState->eyeState = MARIO_EYES_DEAD; if (m->marioObj->header.gfx.animInfo.animFrame == 30) { - if (gServerSettings.bubbleDeath) { + if (m->playerIndex != 0) { + // do nothing + } else if (mario_can_bubble(m)) { mario_set_bubbled(m); } else { level_trigger_warp(m, WARP_OP_DEATH); @@ -954,7 +956,9 @@ static s32 act_water_death(struct MarioState *m) { set_mario_animation(m, MARIO_ANIM_WATER_DYING); if (set_mario_animation(m, MARIO_ANIM_WATER_DYING) == 35) { - if (gServerSettings.bubbleDeath) { + if (m->playerIndex != 0) { + // do nothing + } else if (mario_can_bubble(m)) { mario_set_bubbled(m); } else { level_trigger_warp(m, WARP_OP_DEATH); @@ -1065,7 +1069,9 @@ static s32 act_caught_in_whirlpool(struct MarioState *m) { if ((marioObj->oMarioWhirlpoolPosY += m->vel[1]) < 0.0f) { marioObj->oMarioWhirlpoolPosY = 0.0f; if (distance < 16.1f && m->actionTimer++ == 16) { - if (gServerSettings.bubbleDeath) { + if (m->playerIndex != 0) { + // do nothing + } else if (mario_can_bubble(m)) { mario_set_bubbled(m); } else { level_trigger_warp(m, WARP_OP_DEATH); diff --git a/src/pc/controller/controller_keyboard_debug.c b/src/pc/controller/controller_keyboard_debug.c index 7e862c5b..7f57c8c2 100644 --- a/src/pc/controller/controller_keyboard_debug.c +++ b/src/pc/controller/controller_keyboard_debug.c @@ -45,7 +45,7 @@ static void debug_warp_level1() { } static void debug_warp_level2() { - dynos_warp_to_level(LEVEL_BOWSER_2, 1, 1); + dynos_warp_to_level(LEVEL_WF, 1, 1); } static void debug_grand_star(void) {