Skip to content

Commit 016eca7

Browse files
authored
Crouch-jump constants recalc for bot ledge NavAreas (#1558)
* Apply a 7u height budget gap across all classes
1 parent 60bb10e commit 016eca7

3 files changed

Lines changed: 58 additions & 7 deletions

File tree

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +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;
46-
case NEO_CLASS_ASSAULT:
47-
[[fallthrough]];
48+
case NEO_CLASS_JUGGERNAUT:
49+
return NEO_JUGGERNAUT_CROUCH_JUMP_HEIGHT;
4850
case NEO_CLASS_SUPPORT:
49-
[[fallthrough]];
51+
return NEO_SUPPORT_CROUCH_JUMP_HEIGHT;
5052
case NEO_CLASS_VIP:
51-
[[fallthrough]];
52-
case NEO_CLASS_JUGGERNAUT:
53-
return NEO_CROUCH_JUMP_HEIGHT;
53+
return NEO_ASSAULT_CROUCH_JUMP_HEIGHT; // vip same as assault
54+
case NEO_CLASS_ASSAULT:
55+
return NEO_ASSAULT_CROUCH_JUMP_HEIGHT;
5456
default:
5557
Assert(false);
5658
return 0.f;

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: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,56 @@ 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+
// Juggernaut: 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+
// Then apply a uniform spare height budget gap of 7 units to all classes.
160+
// Formula: (Class Jump Height) + (Lift) - (Spare Gap)
161+
//
162+
// Precalculated bot crouch jump heights for use in bot locomotion/navigation checks:
163+
// ---
164+
// Recon: 54 + 18 - 7 = 65
165+
// Assault/VIP: 36 + 17 - 7 = 46
166+
// Support: 36 + 11 - 7 = 40
167+
// Juggernaut: 50.4 + 13 - 7 = 56.4 (rounded down to 56)
168+
123169
#define NEO_RECON_CROUCH_JUMP_HEIGHT 65.f
124-
#define NEO_CROUCH_JUMP_HEIGHT 56.f
170+
#define NEO_ASSAULT_CROUCH_JUMP_HEIGHT 46.f
171+
#define NEO_SUPPORT_CROUCH_JUMP_HEIGHT 40.f
172+
#define NEO_JUGGERNAUT_CROUCH_JUMP_HEIGHT 56.f
125173

126174
// END OF NEO MOVEMENT DEFINITIONS
127175
//////////////////////////////////////////////////////

0 commit comments

Comments
 (0)