1717// ---------------------------------------------------------------------------------------------
1818CNEOBotCtgLoneWolf::CNEOBotCtgLoneWolf ( void )
1919{
20- m_hGhost = nullptr ;
2120 m_bPursuingDropThreat = false ;
2221 m_vecDropThreatPos = CNEO_Player::VECTOR_INVALID_WAYPOINT;
2322 m_closestCapturePoint = CNEO_Player::VECTOR_INVALID_WAYPOINT;
@@ -26,7 +25,6 @@ CNEOBotCtgLoneWolf::CNEOBotCtgLoneWolf( void )
2625// ---------------------------------------------------------------------------------------------
2726ActionResult< CNEOBot > CNEOBotCtgLoneWolf::OnStart ( CNEOBot *me, Action< CNEOBot > *priorAction )
2827{
29- m_hGhost = nullptr ;
3028 m_hPursueTarget = nullptr ;
3129 m_bPursuingDropThreat = false ;
3230 m_useAttemptTimer.Invalidate ();
@@ -84,7 +82,7 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval
8482 }
8583
8684 // Always need to find the ghost to act on it
87- if ( !UpdateGhostHandle ( me ) )
85+ if ( !GetGhost ( ) )
8886 {
8987 return Done ( " Ghost not found" );
9088 }
@@ -99,7 +97,7 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval
9997 float flDistGhostToGoal = FLT_MAX;
10098 if ( m_closestCapturePoint != CNEO_Player::VECTOR_INVALID_WAYPOINT )
10199 {
102- const Vector& vecStart = me-> IsCarryingGhost () ? me-> GetAbsOrigin () : m_hGhost-> GetAbsOrigin ( );
100+ const Vector& vecStart = GetGhostPosition ( me );
103101 flDistGhostToGoal = vecStart.DistTo ( m_closestCapturePoint );
104102 }
105103
@@ -112,7 +110,7 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval
112110 float flMyTotalDist = flDistGhostToGoal;
113111 if ( !me->IsCarryingGhost () )
114112 {
115- flMyTotalDist += me->GetAbsOrigin ().DistTo ( m_hGhost-> GetAbsOrigin ( ) );
113+ flMyTotalDist += me->GetAbsOrigin ().DistTo ( GetGhostPosition ( me ) );
116114 }
117115
118116 // Count enemies and find if one is closer to our goal
@@ -150,7 +148,7 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval
150148
151149 bool bSafeToCap = ((m_closestCapturePoint != CNEO_Player::VECTOR_INVALID_WAYPOINT) && (flMyTotalDistSq < flClosestEnemyDistToGoalSq));
152150
153- CWeaponGhost *pGhostWeapon = m_hGhost. Get ();
151+ CWeaponGhost *pGhostWeapon = GetGhost ();
154152 CBaseCombatCharacter *pGhostOwner = pGhostWeapon ? pGhostWeapon->GetOwner () : nullptr ;
155153 bool bGhostHeldByEnemy = (pGhostOwner && pGhostOwner->GetTeamNumber () != me->GetTeamNumber ());
156154
@@ -249,7 +247,7 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval
249247
250248 if ( !m_repathTimer.HasStarted () || m_repathTimer.IsElapsed () )
251249 {
252- CNEOBotPathCompute (me, m_path, m_hGhost-> GetAbsOrigin ( ), FASTEST_ROUTE);
250+ CNEOBotPathCompute (me, m_path, GetGhostPosition ( me ), FASTEST_ROUTE);
253251 m_path.Update (me);
254252 m_repathTimer.Start ( RandomFloat ( 0 .3f , 0 .5f ) );
255253 }
@@ -264,7 +262,7 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval
264262 // Ghost is free for taking
265263 if ( bSafeToCap || (bIs1v1 && m_stalemateTimer.HasStarted () && m_stalemateTimer.IsElapsed ()) )
266264 {
267- float flDistToGhostSq = me->GetAbsOrigin ().DistToSqr (m_hGhost-> GetAbsOrigin ( ));
265+ float flDistToGhostSq = me->GetAbsOrigin ().DistToSqr (GetGhostPosition ( me ));
268266 float flAmbushDistSq = CNEOBotCtgLoneWolf::GetDetpackDeployDistanceSq ( me );
269267
270268 if ( flDistToGhostSq < flAmbushDistSq)
@@ -276,13 +274,13 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval
276274 else
277275 {
278276 // Try to cap before enemy can stop us.
279- return SuspendFor (new CNEOBotCtgCapture (m_hGhost. Get ()), " Picking up ghost to make a run for it!" );
277+ return SuspendFor (new CNEOBotCtgCapture (GetGhost ()), " Picking up ghost to make a run for it!" );
280278 }
281279 }
282280
283281 if ( !m_repathTimer.HasStarted () || m_repathTimer.IsElapsed () )
284282 {
285- CNEOBotPathCompute (me, m_path, m_hGhost-> GetAbsOrigin ( ), FASTEST_ROUTE);
283+ CNEOBotPathCompute (me, m_path, GetGhostPosition ( me ), FASTEST_ROUTE);
286284 m_path.Update (me);
287285 m_repathTimer.Start ( RandomFloat ( 0 .2f , 0 .5f ) );
288286 }
@@ -303,7 +301,7 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval
303301 }
304302
305303 // Hide out of sight of ghost to ambush anyone that picks up the ghost
306- float flDistToGhostSq = me->GetAbsOrigin ().DistToSqr (m_hGhost-> GetAbsOrigin ( ));
304+ float flDistToGhostSq = me->GetAbsOrigin ().DistToSqr (GetGhostPosition ( me ));
307305 float flAmbushDistSq = CNEOBotCtgLoneWolf::GetDetpackDeployDistanceSq ( me );
308306 if (flDistToGhostSq < flAmbushDistSq)
309307 {
@@ -314,7 +312,7 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval
314312 // Get near the ghost first before surveying hiding spots
315313 if ( !m_repathTimer.HasStarted () || m_repathTimer.IsElapsed () )
316314 {
317- CNEOBotPathCompute (me, m_path, m_hGhost-> GetAbsOrigin ( ), FASTEST_ROUTE);
315+ CNEOBotPathCompute (me, m_path, GetGhostPosition ( me ), FASTEST_ROUTE);
318316 m_path.Update (me);
319317 m_repathTimer.Start ( RandomFloat ( 0 .5f , 1 .0f ) );
320318 }
@@ -391,7 +389,7 @@ Vector CNEOBotCtgLoneWolf::GetNearestCapturePoint( CNEOBot *me, bool bEnemyCapPo
391389
392390 if ( NEORules ()->m_pGhostCaps .Count () > 0 )
393391 {
394- const Vector& vecStart = me-> IsCarryingGhost () ? me-> GetAbsOrigin () : ( m_hGhost. Get () ? m_hGhost-> GetAbsOrigin () : me-> GetAbsOrigin () );
392+ const Vector& vecStart = GetGhostPosition ( me );
395393
396394 for ( int i=0 ; i<NEORules ()->m_pGhostCaps .Count (); ++i )
397395 {
@@ -446,14 +444,31 @@ class CCollectPotentiallyVisibleAreas
446444};
447445
448446// ---------------------------------------------------------------------------------------------
449- bool CNEOBotCtgLoneWolf::UpdateGhostHandle ( CNEOBot *me )
447+ Vector CNEOBotCtgLoneWolf::GetGhostPosition ( CNEOBot *me )
450448{
451- if ( !m_hGhost )
449+ if ( me-> IsCarryingGhost () )
452450 {
453- m_hGhost = dynamic_cast <CWeaponGhost*>( gEntList .FindEntityByClassname ( nullptr , " weapon_ghost" ) );
451+ return me->GetAbsOrigin ();
452+ }
453+
454+ CWeaponGhost *pGhost = GetGhost ();
455+ if ( pGhost )
456+ {
457+ CBaseEntity *pParent = pGhost->GetMoveParent ();
458+ if ( pParent )
459+ {
460+ return pParent->GetAbsOrigin ();
461+ }
462+ return pGhost->GetAbsOrigin ();
454463 }
455464
456- return ( m_hGhost != nullptr );
465+ return me->GetAbsOrigin ();
466+ }
467+
468+ // ---------------------------------------------------------------------------------------------
469+ CWeaponGhost* CNEOBotCtgLoneWolf::GetGhost ()
470+ {
471+ return NEORules ()->m_pGhost ;
457472}
458473
459474// ---------------------------------------------------------------------------------------------
0 commit comments