Skip to content

Commit 4bf68ef

Browse files
committed
Crouch-jump constants recalc for bot ledge NavAreas
1 parent 67efc01 commit 4bf68ef

3 files changed

Lines changed: 50 additions & 2 deletions

File tree

src/game/server/neo/bot/neo_bot_locomotion.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,21 @@ class CNEOBotLocomotion : public PlayerLocomotion
3838

3939
inline float CNEOBotLocomotion::GetMaxJumpHeight( void ) const
4040
{
41+
// NEO JANK: Assumes [MD]'s g_bMovementOptimizations = true, where we assume sv_gravity is 800 for navigation.
42+
// Changing that setting can potentially break bot navigation.
4143
auto me = (CNEO_Player*)GetBot()->GetEntity();
4244
switch (me->GetClass())
4345
{
4446
case NEO_CLASS_RECON:
4547
return NEO_RECON_CROUCH_JUMP_HEIGHT;
48+
case NEO_CLASS_JUGGERNAUT:
49+
return NEO_JUGGERNAUT_CROUCH_JUMP_HEIGHT;
4650
case NEO_CLASS_ASSAULT:
4751
[[fallthrough]];
4852
case NEO_CLASS_SUPPORT:
4953
[[fallthrough]];
5054
case NEO_CLASS_VIP:
5155
[[fallthrough]];
52-
case NEO_CLASS_JUGGERNAUT:
5356
return NEO_CROUCH_JUMP_HEIGHT;
5457
default:
5558
Assert(false);

src/game/shared/gamemovement.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2575,6 +2575,7 @@ bool CGameMovement::CheckJumpButton( void )
25752575
flMul = sqrt(2 * GetCurrentGravity() * GAMEMOVEMENT_JUMP_HEIGHT);
25762576
}
25772577
#else
2578+
// NEO JANK: Remember to update NEO_RECON_CROUCH_JUMP_HEIGHT/etc if you change these values.
25782579
auto neoPlayer = static_cast<CNEO_Player*>(player);
25792580
if ( g_bMovementOptimizations )
25802581
{

src/game/shared/neo/neo_player_shared.h

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,52 @@ COMPILE_TIME_ASSERT(NEO_RECON_CROUCH_SPEED > NEO_ASSAULT_CROUCH_SPEED);
120120
COMPILE_TIME_ASSERT(NEO_ASSAULT_CROUCH_SPEED == NEO_SUPPORT_CROUCH_SPEED);
121121
COMPILE_TIME_ASSERT(NEO_ASSAULT_CROUCH_SPEED == NEO_VIP_CROUCH_SPEED);
122122

123+
// NEO Jank: As an optimization, these constants are calculated for default gravity,
124+
// and bot climbing behavior may be odd if sv_gravity is changed.
125+
// See [MD]'s g_bMovementOptimizations for additional context.
126+
//
127+
// At time of comment, these constants were only used by neo_bot_locomotion.h
128+
// where these values determine if a bot will attempt to climb a ledge between NavAreas.
129+
// At time of analysis, NEO_RECON_CROUCH_JUMP_HEIGHT potentially was historically calculated based on
130+
// (GAMEMOVEMENT_JUMP_HEIGHT * class multiplier) + (Support Hull Crouch/Stand Difference),
131+
//
132+
// From this point on we will refer to (GAMEMOVEMENT_JUMP_HEIGHT * class multiplier) as "Class Jump Height".
133+
// For sake of consistency, we will use the precomputed jump heights assuming g_bMovementOptimizations = true.
134+
//
135+
// Class Jump Height: Derived from `sqrt(2 * gravity * jump_height)` from `gamemovement.cpp`.
136+
// But for simplicity we use the optimized values provided under the g_bMovementOptimizations = true case:
137+
// - Recon: 54.0 units
138+
// - Juggernaut: 50.4 units
139+
// - Others: 36.0 units
140+
//
141+
// Hull Crouch/Stand Difference (aka: "Lift"):
142+
// ---
143+
// Derived from neo_gamerules.cpp: Vector viewDelta = ( hullSizeNormal - hullSizeCrouch );
144+
// Variables are defined in shareddefs.h as VEC_HULL_MAX_SCALED and VEC_DUCK_HULL_MAX_SCALED.
145+
// Instead of deriving these values by hand, a breakpoint can be placed in CGameMovement::CanUnduck()
146+
// while configuring the bot class with the bot_class command, to log the variable values.
147+
//
148+
// Lift = VEC_HULL_MAX_SCALED.z - VEC_DUCK_HULL_MAX_SCALED.z
149+
// ---
150+
// Recon: 64 - 46 = 18
151+
// Assault: 65 - 48 = 17
152+
// Support: 70 - 59 = 11
153+
// VIP: 65 - 48 = 17
154+
//
155+
// Juggernaught: 88 - 75 = 13
156+
// (Base Hull Max = 70) + (NEO_JUGGERNAUT_MAXHULL_OFFSET.z = 18) = 88
157+
// (Base Hull Duck Max = 59) + (NEO_JUGGERNAUT_DUCK_MAXHULL_OFFSET.z = 16) = 75
158+
//
159+
// Proposed bot crouch jump heights:
160+
// ---
161+
// Recon: 54 + 11 = 65
162+
// Assault/VIP = 36 + 11 = 47
163+
// Support = 36 + 11 = 47
164+
// Juggernaut = 50.4 + 11 = 61.4 (rounded for simplicity)
165+
123166
#define NEO_RECON_CROUCH_JUMP_HEIGHT 65.f
124-
#define NEO_CROUCH_JUMP_HEIGHT 56.f
167+
#define NEO_CROUCH_JUMP_HEIGHT 47.f
168+
#define NEO_JUGGERNAUT_CROUCH_JUMP_HEIGHT 62.f
125169

126170
// END OF NEO MOVEMENT DEFINITIONS
127171
//////////////////////////////////////////////////////

0 commit comments

Comments
 (0)