diff --git a/include/types.h b/include/types.h index 3b609631..c327ba0e 100644 --- a/include/types.h +++ b/include/types.h @@ -382,6 +382,7 @@ struct MarioState /*????*/ u8 wasNetworkVisible; /*????*/ f32 minimumBoneY; /*????*/ f32 curAnimOffset; + /*????*/ u8 knockbackTimer; }; struct TextureInfo diff --git a/src/game/interaction.c b/src/game/interaction.c index 9fdf874e..afc2839f 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -694,9 +694,14 @@ u32 determine_knockback_action(struct MarioState *m, UNUSED s32 arg) { f32 mag = scaler * (f32)gServerSettings.playerKnockbackStrength * sign; m->forwardVel = mag; if (sign > 0 && terrainIndex == 1) { mag *= -1.0f; } + m->vel[0] = -mag * sins(m->interactObj->oFaceAngleYaw); m->vel[1] = (mag < 0) ? -mag : mag; m->vel[2] = -mag * coss(m->interactObj->oFaceAngleYaw); + m->slideVelX = m->vel[0]; + m->slideVelZ = m->vel[2]; + m->knockbackTimer = 3; + m->faceAngle[1] = m->interactObj->oFaceAngleYaw + (sign == 1.0f ? 0 : 0x8000); } diff --git a/src/game/mario.c b/src/game/mario.c index cf4eb245..af8a4089 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -1903,6 +1903,11 @@ static u8 prevent_hang(u32 hangPreventionActions[], u8* hangPreventionIndex) { */ s32 execute_mario_action(UNUSED struct Object *o) { s32 inLoop = TRUE; + + if (gMarioState->knockbackTimer > 0) { + gMarioState->knockbackTimer--; + } + // hide inactive players struct NetworkPlayer *np = &gNetworkPlayers[gMarioState->playerIndex]; if (gMarioState->playerIndex != 0) { diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 0512254a..75b7ea6d 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -1105,8 +1105,12 @@ u32 common_air_knockback_step(struct MarioState *m, u32 landAction, u32 hardFall f32 speed) { u32 stepResult; - if (m->interactObj == NULL || !(m->interactObj->oInteractType & INTERACT_PLAYER)) { - mario_set_forward_vel(m, speed); + if (m->knockbackTimer == 0) { + if (m->interactObj == NULL || !(m->interactObj->oInteractType & INTERACT_PLAYER)) { + mario_set_forward_vel(m, speed); + } + } else { + m->knockbackTimer = 3; } stepResult = perform_air_step(m, 0); diff --git a/src/game/mario_actions_moving.c b/src/game/mario_actions_moving.c index 42291e1a..733e4b45 100644 --- a/src/game/mario_actions_moving.c +++ b/src/game/mario_actions_moving.c @@ -1615,13 +1615,17 @@ s32 common_ground_knockback_action(struct MarioState *m, s32 animation, s32 arg2 #endif } - if (m->interactObj == NULL || !(m->interactObj->oInteractType & INTERACT_PLAYER)) { - if (m->forwardVel > 32.0f) { - m->forwardVel = 32.0f; - } - if (m->forwardVel < -32.0f) { - m->forwardVel = -32.0f; + if (m->knockbackTimer == 0) { + if (m->interactObj == NULL || !(m->interactObj->oInteractType & INTERACT_PLAYER)) { + if (m->forwardVel > 32.0f) { + m->forwardVel = 32.0f; + } + if (m->forwardVel < -32.0f) { + m->forwardVel = -32.0f; + } } + } else { + m->knockbackTimer = 3; } animFrame = set_mario_animation(m, animation); diff --git a/src/pc/djui/djui_panel_host_settings.c b/src/pc/djui/djui_panel_host_settings.c index 77d9455d..fe93c60b 100644 --- a/src/pc/djui/djui_panel_host_settings.c +++ b/src/pc/djui/djui_panel_host_settings.c @@ -15,7 +15,7 @@ static void djui_panel_host_settings_knockback_change(UNUSED struct DjuiBase* ca switch (sKnockbackIndex) { case 0: configPlayerKnockbackStrength = 10; break; case 1: configPlayerKnockbackStrength = 25; break; - default: configPlayerKnockbackStrength = 75; break; + default: configPlayerKnockbackStrength = 60; break; } }