-
Notifications
You must be signed in to change notification settings - Fork 22
Bots can attack toward an optional coordinate #2000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,21 +53,6 @@ ActionResult< CNEOBot > CNEOBotCtgEscort::Update( CNEOBot *me, float interval ) | |
| { | ||
| return Done( "Ghost carrier is not a teammate anymore" ); | ||
| } | ||
|
|
||
| // Check if we can assist the Ghost Carrier (if they are a bot) | ||
| CNEOBot *pBotGhostCarrier = ToNEOBot( pGhostCarrier ); | ||
| if ( pBotGhostCarrier ) | ||
| { | ||
| const CKnownEntity *carrierThreat = pBotGhostCarrier->GetVisionInterface()->GetPrimaryKnownThreat(); | ||
| if ( carrierThreat ) | ||
| { | ||
| // Check if the threat has a clear shot at our friend | ||
| if ( me->IsLineOfFireClear( carrierThreat->GetLastKnownPosition(), pGhostCarrier, CNEOBot::LINE_OF_FIRE_FLAGS_DEFAULT ) ) | ||
| { | ||
| return SuspendFor( new CNEOBotAttack, "Assisting Ghost Carrier with their threat" ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if ( m_repathTimer.IsElapsed() ) | ||
| { | ||
|
|
@@ -83,17 +68,25 @@ ActionResult< CNEOBot > CNEOBotCtgEscort::Update( CNEOBot *me, float interval ) | |
| } | ||
| } | ||
|
|
||
| if ( const CKnownEntity *threat = me->GetVisionInterface()->GetPrimaryKnownThreat(true) ) | ||
| { | ||
| const Vector& ghosterPos = pGhostCarrier->GetAbsOrigin(); | ||
| const Vector& threatPos = threat->GetLastKnownPosition(); | ||
| if ( me->GetAbsOrigin().DistToSqr( threatPos ) > ghosterPos.DistToSqr( threatPos ) ) | ||
| { | ||
| return SuspendFor( new CNEOBotAttack( ghosterPos ), "Engaging threats while regrouping with ghoster" ); | ||
| } | ||
| else | ||
| { | ||
| return SuspendFor( new CNEOBotAttack(), "Intercepting threat while protecting ghoster" ); | ||
| } | ||
| } | ||
|
|
||
| bool bCanSeeCarrier = me->GetVisionInterface()->IsLineOfSightClear( pGhostCarrier->WorldSpaceCenter() ); | ||
| if ( bCanSeeCarrier ) | ||
| { | ||
| m_lostSightOfCarrierTimer.Invalidate(); | ||
|
|
||
| const CKnownEntity *threat = me->GetVisionInterface()->GetPrimaryKnownThreat(true); | ||
| if ( threat && threat->GetEntity() && threat->GetEntity()->IsAlive() ) | ||
| { | ||
| return SuspendFor( new CNEOBotAttack, "Breaking away from ghoster to engage threat" ); | ||
| } | ||
|
|
||
| if ( !m_bHasGoal ) | ||
| { | ||
| // Asymmetric defense: No goal cap zone, so defend the carrier. | ||
|
|
@@ -158,17 +151,6 @@ ActionResult< CNEOBot > CNEOBotCtgEscort::Update( CNEOBot *me, float interval ) | |
|
|
||
| if ( !m_bHasGoal ) | ||
| { | ||
| // Asymmetric defense: No goal cap zone, so defend the carrier. | ||
| if ( pBotGhostCarrier ) | ||
| { | ||
| const CKnownEntity *carrierThreat = pBotGhostCarrier->GetVisionInterface()->GetPrimaryKnownThreat(); | ||
| if ( carrierThreat && carrierThreat->GetEntity() && carrierThreat->GetEntity()->IsAlive() ) | ||
| { | ||
| me->GetVisionInterface()->AddKnownEntity( carrierThreat->GetEntity() ); | ||
| return SuspendFor( new CNEOBotAttack, "Attacking enemy during asymmetric defense" ); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This Attack transition was actually fine since there's no movement goal, but ironically removing this proactive attack behavior both simplifies this behavior, and is actually the more effective tactic against another bot team on the map isolation. |
||
| } | ||
| } | ||
|
|
||
| // No active threats to carrier | ||
| float flDistToCarrierSq = me->GetAbsOrigin().DistToSqr( pGhostCarrier->GetAbsOrigin() ); | ||
| if ( flDistToCarrierSq > flSafeRadiusSq ) | ||
|
|
@@ -190,6 +172,7 @@ ActionResult< CNEOBot > CNEOBotCtgEscort::Update( CNEOBot *me, float interval ) | |
| Vector& vecMoveTarget = m_vecGoalPos; | ||
|
|
||
|
|
||
| CNEOBot *pBotGhostCarrier = ToNEOBot( pGhostCarrier ); | ||
| if ( m_role == ROLE_SCREEN && pBotGhostCarrier ) | ||
| { | ||
| CWeaponGhost *pGhost = dynamic_cast<CWeaponGhost*>( pBotGhostCarrier->Weapon_GetSlot( 0 ) ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,7 +103,7 @@ class CSearchForCoverFromGrenade : public ISearchSurroundingAreasFunctor | |
| const CNavArea *grenadeArea = TheNavMesh->GetNavArea( m_grenade->GetAbsOrigin() ); | ||
| if ( grenadeArea ) | ||
| { | ||
| if ( area->IsPotentiallyVisible( grenadeArea ) ) | ||
| if ( grenadeArea->IsPotentiallyVisible( area ) ) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this PR I took some time to review whether the directionality of observation made sense for every call for IsPotentiallyVisible and IsCompletelyVisible. |
||
| { | ||
| // area is exposed to grenade line of sight | ||
| return true; | ||
|
|
@@ -212,14 +212,14 @@ ActionResult< CNEOBot > CNEOBotRetreatFromGrenade::Update( CNEOBot *me, float in | |
| bool bIsExposed = false; | ||
| if ( grenadeArea && me->GetLastKnownArea() ) | ||
| { | ||
| if ( me->GetLastKnownArea()->IsPotentiallyVisible( grenadeArea ) ) | ||
| if ( grenadeArea->IsPotentiallyVisible( me->GetLastKnownArea() ) ) | ||
| { | ||
| bIsExposed = true; | ||
| } | ||
| } | ||
|
|
||
| // track projectile and relation to escape destination every update | ||
| if ( !m_coverArea || ( grenadeArea && m_coverArea->IsPotentiallyVisible( grenadeArea ) ) ) | ||
| if ( !m_coverArea || ( grenadeArea && grenadeArea->IsPotentiallyVisible( m_coverArea ) ) ) | ||
| { | ||
| m_coverArea = FindCoverArea( me ); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By adding an optional vector position parameter to CNEOBotAttack, we can direct bots to search for cover in the direction of the vector position. For example, in this case we are directing the bots to attack the enemy while advancing between cover spots that are directionally closer to their commanding player's ping waypoint.
One known design tradeoff is that bots will not immediate change their direction of movement if the player places another ping when the bots are in the Attack behavior. My thinking is that this is okay, as bots should terminate the attack behavior earlier when they both have the optional goal waypoint while not seeing the enemy when moving between cover. I think it's fine not to interrupt the bots in the middle of their current plan, as it's more important that they don't change their minds indecisively and get destroyed when executing a cover plan.