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 @@ -1515,6 +1515,9 @@ set(UNITY_SOURCE_NEO_BOT
neo/bot/neo_bot.cpp
neo/bot/neo_bot_path_compute.cpp
neo/bot/neo_bot_path_cost.cpp
neo/bot/neo_bot_obstacle_props.cpp
neo/bot/neo_bot_path_obstacles.cpp
neo/bot/neo_bot_prop_detour.cpp
neo/bot/neo_bot_path_reservation.cpp
neo/bot/neo_bot_body.cpp
neo/bot/neo_bot_locomotion.cpp
Expand Down Expand Up @@ -1577,6 +1580,9 @@ target_sources_grouped(
neo/bot/neo_bot.h
neo/bot/neo_bot_path_compute.h
neo/bot/neo_bot_path_cost.h
neo/bot/neo_bot_obstacle_props.h
neo/bot/neo_bot_path_obstacles.h
neo/bot/neo_bot_prop_detour.h
neo/bot/neo_bot_path_reservation.h
neo/bot/neo_bot_body.h
neo/bot/neo_bot_contextual_query_interface.h
Expand Down
37 changes: 36 additions & 1 deletion src/game/server/NextBot/Path/NextBotPathFollow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ void PathFollower::Invalidate( void )
m_avoidTimer.Invalidate();
m_waitTimer.Invalidate();
m_hindrance = NULL;

#ifdef NEO
m_pathObstacles.Reset();
#endif
}


Expand All @@ -114,6 +118,10 @@ void PathFollower::OnPathChanged( INextBot *bot, Path::ResultType result )
// start from the beginning
m_goal = FirstSegment();
m_result = result;

#ifdef NEO
m_pathObstacles.Reset();
#endif
}


Expand Down Expand Up @@ -684,6 +692,19 @@ void PathFollower::Update( INextBot *bot )
return;
}

#ifdef NEO
// look ahead for breakables and walk around props in the way, which the nav mesh does not know about,
// heading for the path segment past them rather than turning back for a goal the detour went around
m_pathObstacles.Update( bot, *this );
const Path::Segment *detourPathGoal = m_pathObstacles.GetPathGoal();
if ( detourPathGoal )
{
m_goal = detourPathGoal;
}

const bool isDetouring = m_pathObstacles.IsDetouring();
#endif

// use the direction towards the goal as 'forward' direction
Vector forward = m_goal->pos - mover->GetFeet();

Expand Down Expand Up @@ -739,8 +760,15 @@ void PathFollower::Update( INextBot *bot )
NDebugOverlay::Line( mover->GetFeet(), mover->GetFeet() + axisSize * left, 0, 0, 255, true, 0.1f );
}

#ifdef NEO
// a detour crosses only walkable floor, and the prop it goes around is no ledge to climb
const bool shouldClimb = !isDetouring;
#else
const bool shouldClimb = true;
#endif

// climb up ledges
if ( !Climbing( bot, m_goal, forward, left, goalRange ) )
if ( shouldClimb && !Climbing( bot, m_goal, forward, left, goalRange ) )
{
// a failed climb could mean an invalid path
if ( !IsValid() )
Expand Down Expand Up @@ -829,6 +857,13 @@ void PathFollower::Update( INextBot *bot )

Vector goalPos = m_goal->pos;

#ifdef NEO
if ( isDetouring )
{
goalPos = m_pathObstacles.GetMoveGoal();
}
#endif

// avoid small obstacles
forward = goalPos - mover->GetFeet();
forward.z = 0.0f;
Expand Down
8 changes: 8 additions & 0 deletions src/game/server/NextBot/Path/NextBotPathFollow.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include "nav_mesh.h"
#include "nav_pathfind.h"
#include "NextBotPath.h"
#ifdef NEO
#include "neo/bot/neo_bot_path_obstacles.h"
#endif

class INextBot;
class ILocomotion;
Expand Down Expand Up @@ -42,6 +45,10 @@ class PathFollower : public Path

Path::ResultType GetResult() const { return m_result; }

#ifdef NEO
CBaseEntity *GetBreakableInWay() const { return m_pathObstacles.GetBreakableInWay(); } // a breakable the last look ahead met on the path
#endif

private:
const Path::Segment *m_goal; // our current goal along the path
float m_minLookAheadRange;
Expand Down Expand Up @@ -83,6 +90,7 @@ class PathFollower : public Path
#ifdef NEO
bool HasFallenBelowPath( INextBot *bot ) const; // return true if we stand off the path, more than a step below it
bool m_wasOnGround;
CNEOBotPathObstacles m_pathObstacles; // looks ahead for props to steer around and breakables in the way
#endif

float m_goalTolerance;
Expand Down
27 changes: 4 additions & 23 deletions src/game/server/neo/bot/behavior/neo_bot_path_clear_breakable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,11 @@ CBaseEntity *CNEOBotPathClearBreakable::GetBreakableInPath( CNEOBot *me )
return nullptr;
}

const Path::Segment *goal = path->GetCurrentGoal();
if ( !goal )
// the path follower's look ahead for props also finds breakables in the way
CBaseEntity *breakable = path->GetBreakableInWay();
if ( breakable && breakable->IsAlive() && breakable->GetHealth() > 0 )
{
return nullptr;
}

// Trace forward along the path to look for breakables
// We use a hull trace to match the bot's collision size
trace_t tr;
UTIL_TraceHull( me->GetAbsOrigin() + Vector( 0, 0, 10 ),
goal->pos + Vector( 0, 0, 10 ),
me->GetBodyInterface()->GetHullMins(),
me->GetBodyInterface()->GetHullMaxs(),
MASK_NPCSOLID,
me->GetEntity(),
COLLISION_GROUP_NONE,
&tr );

if ( tr.DidHit() && tr.m_pEnt )
{
if ( me->IsAbleToBreak( tr.m_pEnt ) )
{
return tr.m_pEnt;
}
return breakable;
}

return nullptr;
Expand Down
Loading
Loading