3 ref SCR_BTParam<AIWaypoint> m_Waypoint =
new SCR_BTParam<AIWaypoint>(
SCR_AIActionTask.WAYPOINT_PORT);
4 ref SCR_BTParam<vector> m_vAttackLocation =
new SCR_BTParam<vector>(
SCR_AIActionTask.ATTACK_LOCATION_PORT);
6 protected ref array<AIAgent> m_aRadialCoverAgents = {};
8 void InitParameters(AIWaypoint waypoint,
float priorityLevel)
11 m_vAttackLocation.Init(
this, vector.Zero);
16 void SCR_AIDefendActivity(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint, AIWaypoint waypoint, vector attackLocation,
float priority = PRIORITY_ACTIVITY_DEFEND,
float priorityLevel = PRIORITY_LEVEL_NORMAL)
18 InitParameters(waypoint, priorityLevel);
19 m_sBehaviorTree =
"AI/BehaviorTrees/Chimera/Group/ActivityDefend.bt";
20 SetPriority(priority);
23 m_vAttackLocation.m_Value = attackLocation;
28 float waypointRadius = waypoint.GetCompletionRadius();
29 vector waypointPositionWorld = waypoint.GetOrigin();
30 if (attackLocation == vector.Zero)
32 float rotationAngle = waypoint.GetAngles()[1] * Math.DEG2RAD;
33 vector attackPositionWorld;
34 attackPositionWorld[0] = waypointPositionWorld[0] + Math.Sin(rotationAngle) * waypointRadius;
35 attackPositionWorld[2] = waypointPositionWorld[2] + Math.Cos(rotationAngle) * waypointRadius;
36 attackPositionWorld[1] = waypointPositionWorld[1];
37 m_vAttackLocation.m_Value = attackPositionWorld;
41 m_vAttackLocation.m_Value = (attackLocation - waypointPositionWorld).Normalized() * waypointRadius + waypointPositionWorld;
47 void AddAgentToRadialCover (AIAgent agent)
49 if (m_aRadialCoverAgents.Find(agent) == -1)
50 m_aRadialCoverAgents.Insert(agent);
54 void ClearRadialCoverAgents ()
56 m_aRadialCoverAgents.Clear();
60 int FindRadialCoverAgent (AIAgent agent)
62 return m_aRadialCoverAgents.Find(agent);
66 int GetRadialCoverAgentsCount ()
68 return m_aRadialCoverAgents.Count();
72 override string GetActionDebugInfo()
74 return this.ToString() +
" defending area of " +
m_Waypoint.ToString();
78 override void OnActionDeselected()
80 super.OnActionDeselected();
83 group.ReleaseCompartments();
84 SendCancelMessagesToAllAgents();
88 override void OnActionFailed()
90 super.OnActionFailed();
93 group.ReleaseCompartments();
94 SendCancelMessagesToAllAgents();
98 override void OnActionCompleted()
100 super.OnActionCompleted();
101 SendCancelMessagesToAllAgents();