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
31 changes: 31 additions & 0 deletions src/game/server/neo/bot/neo_bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1802,10 +1802,41 @@ bool CNEOBot::IsLineOfFireClear(const Vector& where, const LineOfFireFlags flags
}


//-----------------------------------------------------------------------------------------------------
// Return whether there is a friendly player blocking the line of fire
bool CNEOBot::IsLineOfFireClearOfFriendlies(const Vector& from, CBaseEntity* who) const
{
if (NEORules()->IsTeamplay())
{
trace_t playerTrace;
CTraceFilterSimple playerFilter(this, COLLISION_GROUP_NONE);
const Vector to = who->WorldSpaceCenter();
UTIL_TraceLine(from, to, MASK_SHOT_HULL, &playerFilter, &playerTrace);

if (playerTrace.DidHit())
{
if (playerTrace.m_pEnt && playerTrace.m_pEnt->IsPlayer())
{
// If it's a friendly player, line of fire is NOT clear
if (playerTrace.m_pEnt->GetTeamNumber() == GetTeamNumber())
{
return false;
}
}
}
}
return true;
}

//-----------------------------------------------------------------------------------------------------
// Return true if a weapon has no obstructions along the line between the given point and entity
bool CNEOBot::IsLineOfFireClear(const Vector& from, CBaseEntity* who, const LineOfFireFlags flags) const
{
if (!IsLineOfFireClearOfFriendlies(from, who))
{
return false; // Friendly player blocking line of fire
}

trace_t trace;
NextBotTraceFilterIgnoreActors botFilter(NULL, COLLISION_GROUP_NONE);
CTraceFilterIgnoreFriendlyCombatItems ignoreFriendlyCombatFilter(this, COLLISION_GROUP_NONE, GetTeamNumber());
Expand Down
1 change: 1 addition & 0 deletions src/game/server/neo/bot/neo_bot.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class CNEOBot : public NextBotPlayer< CNEO_Player >, public CGameEventListener
bool IsLineOfFireClear(CBaseEntity* who, const LineOfFireFlags flags) const; // return true if a weapon has no obstructions along the line from our eye to the given entity
bool IsLineOfFireClear(const Vector& from, const Vector& to, const LineOfFireFlags flags) const; // return true if a weapon has no obstructions along the line between the given points
bool IsLineOfFireClear(const Vector& from, CBaseEntity* who, const LineOfFireFlags flags) const; // return true if a weapon has no obstructions along the line between the given point and entity
bool IsLineOfFireClearOfFriendlies(const Vector& from, CBaseEntity* who) const;

bool IsEntityBetweenTargetAndSelf(CBaseEntity* other, CBaseEntity* target); // return true if "other" is positioned inbetween us and "target"

Expand Down