Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIClearActionsForDefendActivity.c
Go to the documentation of this file.
2{
3 static const string PORT_WAYPOINT = "WaypointIn";
4
5 [Attribute("false", UIWidgets.CheckBox, "Keep turrets occupied?")];
6 bool m_bKeepTurrets;
7
8 [Attribute("false", UIWidgets.CheckBox, "Keep smart actions occupied?")];
9 bool m_bKeepSA;
10
11 [Attribute("true", UIWidgets.Auto, "Keep sector covers")];
12 bool m_bKeepSectorCovers;
13
14 [Attribute("500", UIWidgets.EditBox, "Update interval")]
15 protected float m_fUpdateInterval_ms;
16
17 protected float m_fNextUpdate_ms;
18
21 protected bool m_bSendingCancel;
22 protected SCR_MailboxComponent m_Mailbox;
24
25 //------------------------------------------------------------------------------------------------
26 static override bool VisibleInPalette() {return true;}
27
28 //------------------------------------------------------------------------------------------------
29 override void OnInit(AIAgent owner)
30 {
31 m_groupOwner = SCR_AIGroup.Cast(owner);
32 if (!m_groupOwner)
33 {
34 m_groupOwner = SCR_AIGroup.Cast(owner.GetParentGroup());
35 if (!m_groupOwner)
36 {
37 SCR_AgentMustBeAIGroup(this, owner);
38 return;
39 }
40 }
42 if (!utility)
43 return;
44 m_Mailbox = utility.m_Mailbox;
45 m_RelatedActivity = SCR_AIDefendActivity.Cast(utility.GetCurrentAction());
46 }
47
48 //------------------------------------------------------------------------------------------------
49 override void OnEnter(AIAgent owner)
50 {
51 m_bSendingCancel = true;
52 }
53
54 //------------------------------------------------------------------------------------------------
55 override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
56 {
57 if (!m_groupOwner)
58 return ENodeResult.FAIL;
59 IEntity waypointEnt;
60
62 return ENodeResult.FAIL;
63
64 GetVariableIn(PORT_WAYPOINT,waypointEnt);
65
66 bool waitingForCancel = false;
67 bool cancelSent;
68 array<AIAgent> agents = {};
69 m_groupOwner.GetAgents(agents);
70 foreach (AIAgent agent : agents)
71 {
72 SCR_ChimeraAIAgent chimeraAIAgent = SCR_ChimeraAIAgent.Cast(agent);
73 if (!chimeraAIAgent)
74 continue;
75 SCR_AIUtilityComponent utility = chimeraAIAgent.m_UtilityComponent;
76 if (!utility)
77 continue;
78 SCR_AIBehaviorBase currBehavior = utility.GetCurrentBehavior();
79 if (SCR_AIDefendBehavior.Cast(currBehavior) && !m_bKeepSectorCovers)
80 {
81 waitingForCancel = true;
83 {
85 m_Mailbox.RequestBroadcast(cancelMessage, agent);
86 cancelSent = true;
87 continue;
88 }
89 break;
90 }
91 if (SCR_AIPerformActionBehavior.Cast(currBehavior) && !m_bKeepSA)
92 {
93 waitingForCancel = true;
95 {
97 m_Mailbox.RequestBroadcast(cancelMessage, agent);
98 cancelSent = true;
99 continue;
100 }
101 break;
102 }
103 if (utility.m_AIInfo.HasUnitState(EUnitState.IN_TURRET) && !m_bKeepTurrets)
104 {
105 waitingForCancel = true;
107 {
108 IEntity agentEntity = agent.GetControlledEntity();
109 IEntity vehicle = CompartmentAccessComponent.GetVehicleIn(agentEntity);
111 SCR_AIMessage_GetOut getOutMessage = SCR_AIMessage_GetOut.Create(vehicle, params, m_RelatedActivity);
112 m_Mailbox.RequestBroadcast(getOutMessage, agent);
113 cancelSent = true;
114 continue;
115 }
116 break;
117 }
118 }
119 if (cancelSent)
120 m_bSendingCancel = false;
121 if (waitingForCancel)
122 {
123 return ENodeResult.RUNNING;
124 }
125 return ENodeResult.SUCCESS;
126 }
127
128 //------------------------------------------------------------------------------------------------
129 protected static ref TStringArray s_aVarsIn = {
130 PORT_WAYPOINT
131 };
133 {
134 return s_aVarsIn;
135 }
136
137 //------------------------------------------------------------------------------------------------
138 static override string GetOnHoverDescription()
139 {
140 return "ClearActionsForDefendActivity: Goes over all group members and makes them leave the actions they were assigned to. Returns RUNNING until all canceled behaviors are done.";
141 }
142
143 //------------------------------------------------------------------------------------------------
144 static override bool CanReturnRunning() { return true; }
145}
void SCR_AgentMustBeAIGroup(Node node, AIAgent owner)
Definition NodeError.c:14
void SCR_AIBehaviorBase(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity)
proto bool GetVariableIn(string name, out void val)
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
ENodeResult
Definition ENodeResult.c:13
SCR_FieldOfViewSettings Attribute
array< string > TStringArray
Definition Types.c:385