Skip to content

Commit

Permalink
Duck bbox fix for headbugs
Browse files Browse the repository at this point in the history
Adds convar sv_duck_collision_fix that will fix headbugs by updating the player bbox after the duck code instead of at the end of the tick. Before it could use your standing bbox for trigger checks through the ceiling because it had raised your origin from the duck. The rocket jump gamemode will not use this fix as it is undesired and unwanted headbugs will instead be fixed manually in the map.
  • Loading branch information
chrb22 authored and Gocnak committed Nov 12, 2019
1 parent 9abfa52 commit dbcc8cc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions mp/src/game/shared/gamemovement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4616,6 +4616,18 @@ void CGameMovement::PlayerMove( void )

UpdateDuckJumpEyeOffset();
Duck();

if (sv_duck_collision_fix.GetBool())
{
if ( player->GetFlags() & FL_DUCKING )
{
player->SetCollisionBounds( VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX );
}
else
{
player->SetCollisionBounds( VEC_HULL_MIN, VEC_HULL_MAX );
}
}

// Don't run ladder code if dead on on a train
if ( !player->pl.deadflag && !(player->GetFlags() & FL_ONTRAIN) )
Expand Down
2 changes: 2 additions & 0 deletions mp/src/game/shared/momentum/mom_system_gamemode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void CGameModeBase::SetGameModeVars()
sv_maxspeed.SetValue(260);
sv_stopspeed.SetValue(75);
sv_considered_on_ground.SetValue(1);
sv_duck_collision_fix.SetValue(true);
}

void CGameModeBase::OnPlayerSpawn(CMomentumPlayer *pPlayer)
Expand Down Expand Up @@ -90,6 +91,7 @@ void CGameMode_RJ::SetGameModeVars()
sv_maxspeed.SetValue(240);
sv_stopspeed.SetValue(100);
sv_considered_on_ground.SetValue(2);
sv_duck_collision_fix.SetValue(false);
}

void CGameMode_RJ::OnPlayerSpawn(CMomentumPlayer *pPlayer)
Expand Down
3 changes: 2 additions & 1 deletion mp/src/game/shared/movevars_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,5 @@ ConVar r_AirboatViewDampenDamp( "r_AirboatViewDampenDamp", "1.0", FCVAR_CHEAT |
ConVar r_AirboatViewZHeight( "r_AirboatViewZHeight", "0.0", FCVAR_CHEAT | FCVAR_NOTIFY | FCVAR_REPLICATED );

// Momentum convars
ConVar sv_considered_on_ground("sv_considered_on_ground", "1.0", 0, "Amount of units you have to be above the ground to be considered on ground", true, 0.0f, true, 5.f);
ConVar sv_considered_on_ground("sv_considered_on_ground", "1.0", 0, "Amount of units you have to be above the ground to be considered on ground", true, 0.0f, true, 5.f);
ConVar sv_duck_collision_fix("sv_duck_collision_fix", "1", 0, "Fixes headbugs by updating the collision box after duck code instead of at the end of the tick", true, 0, true, 1);
1 change: 1 addition & 0 deletions mp/src/game/shared/movevars_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ extern ConVar r_AirboatViewZHeight;

// Momentum convars
extern ConVar sv_considered_on_ground;
extern ConVar sv_duck_collision_fix;

#endif // MOVEVARS_SHARED_H

0 comments on commit dbcc8cc

Please sign in to comment.