Skip to content

Commit 9a4fe78

Browse files
committed
Look outward from juggernaut if not ready to activate
1 parent 5026cbc commit 9a4fe78

3 files changed

Lines changed: 52 additions & 7 deletions

File tree

src/game/server/neo/bot/behavior/neo_bot_jgr_capture.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,7 @@ ActionResult<CNEOBot> CNEOBotJgrCapture::Update( CNEOBot *me, float interval )
123123
}
124124

125125
// Look away from the juggernaut to watch for threats
126-
Vector vecAwayFromJgr = me->GetAbsOrigin() - m_hObjective->GetAbsOrigin();
127-
Vector2D vecLookDir2D = vecAwayFromJgr.AsVector2D();
128-
vecLookDir2D.NormalizeInPlace();
129-
const Vector vecLookPos = me->EyePosition() + Vector( vecLookDir2D.x, vecLookDir2D.y, 0.0f ) * 500.0f;
130-
me->GetBodyInterface()->AimHeadTowards( vecLookPos, IBody::IMPORTANT, 0.1f, nullptr, "Facing away from Juggernaut to watch for threats" );
126+
CNEOBotJgrCapture::LookAwayFrom( me, m_hObjective );
131127

132128
me->ReleaseUseButton();
133129
m_useAttemptTimer.Invalidate();
@@ -145,7 +141,9 @@ ActionResult<CNEOBot> CNEOBotJgrCapture::Update( CNEOBot *me, float interval )
145141
#endif
146142
me->ReleaseUseButton();
147143
m_useAttemptTimer.Invalidate();
148-
return SuspendFor( new CNEOBotRetreatToCover( JGR_CAPTURE_LOCKED_RETREAT_TIME ), "Juggernaut is locked, taking cover to wait for it to unlock" );
144+
145+
// Look away from the juggernaut while it's locked to watch for threats
146+
CNEOBotJgrCapture::LookAwayFrom( me, m_hObjective );
149147
}
150148

151149
const Vector vecObjectiveCenter = m_hObjective->WorldSpaceCenter();
@@ -222,3 +220,19 @@ ActionResult<CNEOBot> CNEOBotJgrCapture::Update( CNEOBot *me, float interval )
222220

223221
return Continue();
224222
}
223+
224+
//---------------------------------------------------------------------------------------------
225+
void CNEOBotJgrCapture::LookAwayFrom( CNEOBot *me, CBaseEntity *pTarget )
226+
{
227+
if ( !pTarget )
228+
{
229+
return;
230+
}
231+
232+
Vector vecAwayFromTarget = me->GetAbsOrigin() - pTarget->GetAbsOrigin();
233+
Vector2D vecLookDir2D = vecAwayFromTarget.AsVector2D();
234+
vecLookDir2D.NormalizeInPlace();
235+
236+
const Vector vecLookPos = me->EyePosition() + Vector( vecLookDir2D.x, vecLookDir2D.y, 0.0f ) * 500.0f;
237+
me->GetBodyInterface()->AimHeadTowards( vecLookPos, IBody::IMPORTANT, 0.1f, nullptr, "Facing away from target to watch for threats" );
238+
}

src/game/server/neo/bot/behavior/neo_bot_jgr_capture.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class CNEOBotJgrCapture : public Action<CNEOBot>
1919
virtual ActionResult<CNEOBot> OnSuspend( CNEOBot *me, Action<CNEOBot> *interruptingAction ) override;
2020
virtual ActionResult<CNEOBot> OnResume( CNEOBot *me, Action<CNEOBot> *interruptingAction ) override;
2121

22+
static void LookAwayFrom( CNEOBot *me, CBaseEntity *pTarget );
23+
2224
private:
2325
void StopMoving( CNEOBot *me );
2426

src/game/server/neo/bot/behavior/neo_bot_jgr_seek.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "neo_gamerules.h"
44
#include "bot/neo_bot.h"
55
#include "bot/neo_bot_path_compute.h"
6+
#include "bot/behavior/neo_bot_attack.h"
67
#include "bot/behavior/neo_bot_jgr_seek.h"
78
#include "bot/behavior/neo_bot_jgr_escort.h"
89
#include "bot/behavior/neo_bot_jgr_enemy.h"
@@ -65,7 +66,24 @@ ActionResult< CNEOBot > CNEOBotJgrSeek::Update( CNEOBot *me, float interval )
6566

6667
if ( FStrEq( classname, "neo_juggernaut" ) )
6768
{
68-
return SuspendFor( new CNEOBotJgrCapture( static_cast<CNEO_Juggernaut*>(m_hTargetEntity.Get()) ), "Capturing Juggernaut" );
69+
CNEO_Juggernaut *pJgr = static_cast<CNEO_Juggernaut*>( m_hTargetEntity.Get() );
70+
if ( pJgr )
71+
{
72+
CBasePlayer *pActivatingPlayer = pJgr->GetActivatingPlayer();
73+
if ( NEORules()->IsJuggernautLocked()
74+
|| ( pActivatingPlayer && me->InSameTeam( pActivatingPlayer ) && pActivatingPlayer != me ) )
75+
{
76+
CNEOBotJgrCapture::LookAwayFrom( me, pJgr );
77+
m_path.Invalidate(); // wait at juggernaut
78+
if ( me->GetVisionInterface()->GetPrimaryKnownThreat() )
79+
{
80+
return SuspendFor( new CNEOBotAttack, "Intercepting enemies near juggernaut" );
81+
}
82+
return Continue();
83+
}
84+
}
85+
86+
return SuspendFor( new CNEOBotJgrCapture( pJgr ), "Capturing Juggernaut" );
6987
}
7088
}
7189
}
@@ -98,6 +116,17 @@ void CNEOBotJgrSeek::RecomputeSeekPath( CNEOBot *me )
98116
CBaseEntity* pJuggernaut = gEntList.FindEntityByClassname(NULL, "neo_juggernaut");
99117
if (pJuggernaut)
100118
{
119+
const float useRangeSq = CNEO_Juggernaut::GetUseDistanceSquared() * 0.8f;
120+
if ( me->GetAbsOrigin().DistToSqr( pJuggernaut->GetAbsOrigin() ) < useRangeSq )
121+
{
122+
// We're already at the goal, no need to path.
123+
m_vGoalPos = pJuggernaut->WorldSpaceCenter();
124+
m_bGoingToTargetEntity = true;
125+
m_hTargetEntity = pJuggernaut;
126+
m_path.Invalidate();
127+
return;
128+
}
129+
101130
m_vGoalPos = pJuggernaut->WorldSpaceCenter();
102131
m_bGoingToTargetEntity = true;
103132
m_hTargetEntity = pJuggernaut;

0 commit comments

Comments
 (0)