Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/game/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,12 @@ target_sources_grouped(
FILES
neo/bot/neo_bot.cpp
neo/bot/neo_bot.h
neo/bot/neo_bot_path_compute.cpp
neo/bot/neo_bot_path_compute.h
neo/bot/neo_bot_path_cost.cpp
neo/bot/neo_bot_path_cost.h
neo/bot/neo_bot_path_reservation.cpp
neo/bot/neo_bot_path_reservation.h
neo/bot/neo_bot_body.cpp
neo/bot/neo_bot_body.h
neo/bot/neo_bot_contextual_query_interface.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "neo_player.h"
#include "bot/neo_bot.h"
#include "bot/behavior/nav_entities/neo_bot_nav_ent_destroy_entity.h"
#include "bot/neo_bot_path_compute.h"

extern ConVar neo_bot_path_lookahead_range;

Expand Down Expand Up @@ -133,8 +134,7 @@ ActionResult< CNEOBot > CNEOBotNavEntDestroyEntity::Update( CNEOBot *me, float i
{
m_repathTimer.Start( RandomFloat( 1.0f, 2.0f ) );

CNEOBotPathCost cost( me, FASTEST_ROUTE );
m_path.Compute( me, target->GetAbsOrigin(), cost );
CNEOBotPathCompute( me, m_path, target->GetAbsOrigin(), FASTEST_ROUTE );
}

m_path.Update( me );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "neo_player.h"
#include "bot/neo_bot.h"
#include "bot/behavior/nav_entities/neo_bot_nav_ent_move_to.h"
#include "bot/neo_bot_path_compute.h"

extern ConVar neo_bot_path_lookahead_range;

Expand Down Expand Up @@ -90,8 +91,7 @@ ActionResult< CNEOBot > CNEOBotNavEntMoveTo::Update( CNEOBot *me, float interval
{
m_repathTimer.Start( RandomFloat( 1.0f, 2.0f ) );

CNEOBotPathCost cost( me, FASTEST_ROUTE );
m_path.Compute( me, m_goalPosition, cost );
CNEOBotPathCompute( me, m_path, m_goalPosition, FASTEST_ROUTE );
}

// move into position
Expand Down
4 changes: 2 additions & 2 deletions src/game/server/neo/bot/behavior/neo_bot_approach_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "neo_player.h"
#include "bot/neo_bot.h"
#include "bot/behavior/neo_bot_approach_object.h"
#include "bot/neo_bot_path_compute.h"

extern ConVar neo_bot_path_lookahead_range;

Expand Down Expand Up @@ -53,8 +54,7 @@ ActionResult< CNEOBot > CNEOBotApproachObject::Update( CNEOBot *me, float interv
{
m_repathTimer.Start( RandomFloat( 1.0f, 2.0f ) );

CNEOBotPathCost cost( me, FASTEST_ROUTE );
m_path.Compute( me, m_loot->GetAbsOrigin(), cost );
CNEOBotPathCompute( me, m_path, m_loot->GetAbsOrigin(), FASTEST_ROUTE );
}

// move to the loot
Expand Down
13 changes: 5 additions & 8 deletions src/game/server/neo/bot/behavior/neo_bot_attack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "team_control_point_master.h"
#include "bot/neo_bot.h"
#include "bot/behavior/neo_bot_attack.h"
#include "bot/neo_bot_path_compute.h"

#include "nav_mesh.h"

Expand Down Expand Up @@ -80,13 +81,11 @@ ActionResult< CNEOBot > CNEOBotAttack::Update( CNEOBot *me, float interval )

if ( isUsingCloseRangeWeapon )
{
CNEOBotPathCost cost( me, FASTEST_ROUTE );
m_chasePath.Update( me, threat->GetEntity(), cost );
CNEOBotPathUpdateChase( me, m_chasePath, threat->GetEntity(), FASTEST_ROUTE );
}
else
{
CNEOBotPathCost cost( me, DEFAULT_ROUTE );
m_chasePath.Update( me, threat->GetEntity(), cost );
CNEOBotPathUpdateChase( me, m_chasePath, threat->GetEntity(), DEFAULT_ROUTE );
}
}
else
Expand Down Expand Up @@ -115,13 +114,11 @@ ActionResult< CNEOBot > CNEOBotAttack::Update( CNEOBot *me, float interval )

if ( isUsingCloseRangeWeapon )
{
CNEOBotPathCost cost( me, FASTEST_ROUTE );
m_path.Compute( me, threat->GetLastKnownPosition(), cost );
CNEOBotPathCompute( me, m_path, threat->GetLastKnownPosition(), FASTEST_ROUTE );
}
else
{
CNEOBotPathCost cost( me, DEFAULT_ROUTE );
m_path.Compute( me, threat->GetLastKnownPosition(), cost );
CNEOBotPathCompute( me, m_path, threat->GetLastKnownPosition(), DEFAULT_ROUTE );
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_behavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ ActionResult< CNEOBot > CNEOBotMainAction::Update( CNEOBot *me, float interval )
me->m_flLastShouldAimTime = gpGlobals->curtime;
}
me->m_qPrevShouldAim = qDirectShouldAimQuery;

me->RepathIfFriendlyBlockingLineOfFire();

return Continue();
}
Expand Down
7 changes: 3 additions & 4 deletions src/game/server/neo/bot/behavior/neo_bot_get_ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "neo_gamerules.h"
#include "bot/neo_bot.h"
#include "bot/behavior/neo_bot_get_ammo.h"
#include "bot/neo_bot_path_compute.h"
#include "items.h"

extern ConVar neo_bot_path_lookahead_range;
Expand Down Expand Up @@ -116,9 +117,8 @@ bool CNEOBotGetAmmo::IsPossible( CNEOBot *me )
NDebugOverlay::Cross3D( closestAmmo->WorldSpaceCenter(), 5.0f, 255, 255, 0, true, 999.9 );
}

CNEOBotPathCost cost( me, FASTEST_ROUTE );
PathFollower path;
if ( !path.Compute( me, closestAmmo->WorldSpaceCenter(), cost ) || !path.IsValid() || path.GetResult() != Path::COMPLETE_PATH )
if ( !CNEOBotComputePath( me, path, closestAmmo->WorldSpaceCenter(), FASTEST_ROUTE ) || !path.IsValid() || path.GetResult() != Path::COMPLETE_PATH )
{
if ( me->IsDebugging( NEXTBOT_BEHAVIOR ) )
{
Expand Down Expand Up @@ -153,8 +153,7 @@ ActionResult< CNEOBot > CNEOBotGetAmmo::OnStart( CNEOBot *me, Action< CNEOBot >

m_ammo = s_possibleAmmo;

CNEOBotPathCost cost( me, FASTEST_ROUTE );
if ( !m_path.Compute( me, m_ammo->WorldSpaceCenter(), cost ) || !m_path.IsValid() || m_path.GetResult() != Path::COMPLETE_PATH )
if ( !CNEOBotComputePath( me, m_path, m_ammo->WorldSpaceCenter(), FASTEST_ROUTE ) || !m_path.IsValid() || m_path.GetResult() != Path::COMPLETE_PATH )
{
return Done( "No path to ammo!" );
}
Expand Down
10 changes: 4 additions & 6 deletions src/game/server/neo/bot/behavior/neo_bot_get_health.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "bot/neo_bot.h"
//#include "item_healthkit.h"
#include "bot/behavior/neo_bot_get_health.h"
#include "bot/neo_bot_path_compute.h"

extern ConVar neo_bot_path_lookahead_range;
extern ConVar neo_bot_health_critical_ratio;
Expand Down Expand Up @@ -138,9 +139,8 @@ bool CNEOBotGetHealth::IsPossible( CNEOBot *me )
return false;
}

CNEOBotPathCost cost( me, FASTEST_ROUTE );
PathFollower path;
if ( !path.Compute( me, closestHealth->WorldSpaceCenter(), cost ) || !path.IsValid() || path.GetResult() != Path::COMPLETE_PATH )
if ( !CNEOBotPathCompute( me, path, closestHealth->WorldSpaceCenter(), FASTEST_ROUTE ) || !path.IsValid() || path.GetResult() != Path::COMPLETE_PATH )
{
if ( me->IsDebugging( NEXTBOT_BEHAVIOR ) )
{
Expand Down Expand Up @@ -175,8 +175,7 @@ ActionResult< CNEOBot > CNEOBotGetHealth::OnStart( CNEOBot *me, Action< CNEOBot
m_healthKit = s_possibleHealth;
m_isGoalCharger = m_healthKit->ClassMatches( "*charger*" );

CNEOBotPathCost cost( me, SAFEST_ROUTE );
if ( !m_path.Compute( me, m_healthKit->WorldSpaceCenter(), cost ) )
if (!CNEOBotPathCompute(me, m_path, m_healthKit->WorldSpaceCenter(), SAFEST_ROUTE))
{
return Done( "No path to health!" );
}
Expand Down Expand Up @@ -212,8 +211,7 @@ ActionResult< CNEOBot > CNEOBotGetHealth::Update( CNEOBot *me, float interval )
{
// this can occur if we overshoot the health kit's location
// because it is momentarily gone
CNEOBotPathCost cost( me, SAFEST_ROUTE );
if ( !m_path.Compute( me, m_healthKit->WorldSpaceCenter(), cost ) )
if ( !CNEOBotPathCompute( me, m_path, m_healthKit->WorldSpaceCenter(), SAFEST_ROUTE ) )
{
return Done( "No path to health!" );
}
Expand Down
4 changes: 2 additions & 2 deletions src/game/server/neo/bot/behavior/neo_bot_melee_attack.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "cbase.h"
#include "bot/neo_bot.h"
#include "bot/behavior/neo_bot_melee_attack.h"
#include "bot/neo_bot_path_compute.h"

#include "nav_mesh.h"

Expand Down Expand Up @@ -59,8 +60,7 @@ ActionResult< CNEOBot > CNEOBotMeleeAttack::Update( CNEOBot *me, float interval
me->PressFireButton();

// chase them down
CNEOBotPathCost cost( me, FASTEST_ROUTE );
m_path.Update( me, threat->GetEntity(), cost );
CNEOBotPathUpdateChase( me, m_path, threat->GetEntity(), FASTEST_ROUTE );

return Continue();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "neo_player.h"
#include "bot/neo_bot.h"
#include "bot/behavior/neo_bot_move_to_vantage_point.h"
#include "bot/neo_bot_path_compute.h"

#include "nav_mesh.h"

Expand Down Expand Up @@ -46,8 +47,7 @@ ActionResult< CNEOBot > CNEOBotMoveToVantagePoint::Update( CNEOBot *me, float in
{
m_repathTimer.Start( 1.0f );

CNEOBotPathCost cost( me, FASTEST_ROUTE );
if ( !m_path.Compute( me, m_vantageArea->GetCenter(), cost ) )
if ( !CNEOBotPathCompute( me, m_path, m_vantageArea->GetCenter(), FASTEST_ROUTE ) )
{
return Done( "No path to vantage point exists" );
}
Expand Down
4 changes: 2 additions & 2 deletions src/game/server/neo/bot/behavior/neo_bot_retreat_to_cover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "neo_player.h"
#include "bot/neo_bot.h"
#include "bot/behavior/neo_bot_retreat_to_cover.h"
#include "bot/neo_bot_path_compute.h"

extern ConVar neo_bot_path_lookahead_range;
ConVar neo_bot_retreat_to_cover_range( "neo_bot_retreat_to_cover_range", "1000", FCVAR_CHEAT );
Expand Down Expand Up @@ -235,8 +236,7 @@ ActionResult< CNEOBot > CNEOBotRetreatToCover::Update( CNEOBot *me, float interv
{
m_repathTimer.Start( RandomFloat( 0.3f, 0.5f ) );

CNEOBotPathCost cost( me, RETREAT_ROUTE );
m_path.Compute( me, m_coverArea->GetCenter(), cost );
CNEOBotPathCompute( me, m_path, m_coverArea->GetCenter(), RETREAT_ROUTE );
}

m_path.Update( me );
Expand Down
16 changes: 6 additions & 10 deletions src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "bot/neo_bot.h"
#include "bot/behavior/neo_bot_attack.h"
#include "bot/behavior/neo_bot_seek_and_destroy.h"
#include "bot/neo_bot_path_compute.h"
#include "nav_mesh.h"
#include "neo_ghost_cap_point.h"

Expand Down Expand Up @@ -365,11 +366,10 @@ void CNEOBotSeekAndDestroy::RecomputeSeekPath( CNEOBot *me )
CBaseEntity* pClosestWeapon = pWeapons[i];
if ( pClosestWeapon )
{
CNEOBotPathCost cost( me, SAFEST_ROUTE );
m_hTargetEntity = pClosestWeapon;
m_bGoingToTargetEntity = true;
m_vGoalPos = pClosestWeapon->WorldSpaceCenter();
if ( m_path.Compute( me, m_vGoalPos, cost, 0.0f, true, true ) && m_path.IsValid() && m_path.GetResult() == Path::COMPLETE_PATH )
if ( CNEOBotPathCompute( me, m_path, m_vGoalPos, SAFEST_ROUTE ) && m_path.IsValid() && m_path.GetResult() == Path::COMPLETE_PATH )
return;
}
}
Expand Down Expand Up @@ -482,8 +482,7 @@ void CNEOBotSeekAndDestroy::RecomputeSeekPath( CNEOBot *me )
}
}
m_bGoingToTargetEntity = true;
CNEOBotPathCost cost(me, bQuickToGoalPos ? FASTEST_ROUTE : SAFEST_ROUTE);
if (m_path.Compute(me, m_vGoalPos, cost, 0.0f, true, true) && m_path.IsValid() && m_path.GetResult() == Path::COMPLETE_PATH)
if ( CNEOBotPathCompute( me, m_path, m_vGoalPos, bQuickToGoalPos ? FASTEST_ROUTE : SAFEST_ROUTE ) && m_path.IsValid() && m_path.GetResult() == Path::COMPLETE_PATH )
{
return;
}
Expand All @@ -508,11 +507,10 @@ void CNEOBotSeekAndDestroy::RecomputeSeekPath( CNEOBot *me )
{
for ( int i = 0; i < 10; i++ )
{
CNEOBotPathCost cost( me, SAFEST_ROUTE );
m_hTargetEntity = pSpawns[RandomInt( 0, pSpawns.Size() - 1 )];
m_bGoingToTargetEntity = true;
m_vGoalPos = m_hTargetEntity->WorldSpaceCenter();
if ( m_path.Compute( me, m_vGoalPos, cost, 0.0f, true, true ) && m_path.IsValid() && m_path.GetResult() == Path::COMPLETE_PATH )
if ( CNEOBotPathCompute( me, m_path, m_vGoalPos, SAFEST_ROUTE ) && m_path.IsValid() && m_path.GetResult() == Path::COMPLETE_PATH )
return;
}
}
Expand All @@ -522,10 +520,9 @@ void CNEOBotSeekAndDestroy::RecomputeSeekPath( CNEOBot *me )
{
// No spawns we can get to? Just wander... somewhere!

CNEOBotPathCost cost( me, SAFEST_ROUTE );
Vector vWanderPoint = TheNavAreas[RandomInt( 0, TheNavAreas.Size() - 1 )]->GetCenter();
m_vGoalPos = vWanderPoint;
if ( m_path.Compute( me, vWanderPoint, cost ) )
if ( CNEOBotPathCompute( me, m_path, vWanderPoint, SAFEST_ROUTE ) )
return;
}

Expand Down Expand Up @@ -560,8 +557,7 @@ EventDesiredResult< CNEOBot > CNEOBotSeekAndDestroy::OnCommandApproach( CNEOBot*
m_bOverrideApproach = true;
m_vOverrideApproach = pos;

CNEOBotPathCost cost( me, SAFEST_ROUTE );
m_path.Compute( me, m_vOverrideApproach, cost );
CNEOBotPathCompute( me, m_path, m_vOverrideApproach, SAFEST_ROUTE );

return TryContinue();
}
Loading