Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIActivity.c
Go to the documentation of this file.
1
6{
7 SAFE = 10,
8 ALWAYS = 1000 // Special value for settings to run in all activities
9}
10
11class SCR_AIActivityBase : SCR_AIActionBase
12{
14 ref SCR_BTParam<bool> m_bIsWaypointRelated = new SCR_BTParam<bool>(SCR_AIActionTask.WAYPOINT_RELATED_PORT);
15 AIWaypoint m_RelatedWaypoint = null;
16 bool m_bAllowFireteamRebalance = true; // Allows rebalancing of fireteams while this activity exists
17
18 array<ref SCR_AIActivityFeatureBase> GetActivityFeatures()
19 {
20 return null;
21 }
22
24 {
25 array<ref SCR_AIActivityFeatureBase> features = GetActivityFeatures();
26 if (!features) return null;
27
28 foreach (SCR_AIActivityFeatureBase feature : features)
29 if (feature && feature.IsInherited(featureType))
30 return feature;
31
32 return null;
33 }
34
35 //---------------------------------------------------------------------------------------------------------------------------------
36 void InitParameters(AIWaypoint relatedWaypoint)
37 {
38 bool isWaypointRelated = relatedWaypoint != null;
39 m_bIsWaypointRelated.Init(this, isWaypointRelated);
40 m_RelatedWaypoint = relatedWaypoint;
41 }
42
43 //---------------------------------------------------------------------------------------------------------------------------------
44 void SCR_AIActivityBase(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint)
45 {
46 m_Utility = utility;
47 InitParameters(relatedWaypoint);
48 }
49
50 //------------------------------------------------------------------------------------
52 {
53 AICommunicationComponent comms = m_Utility.m_Owner.GetCommunicationComponent();
54 if (!comms)
55 return;
56
57 // Send to all agents
58 array<AIAgent> agents = {};
59 m_Utility.m_Owner.GetAgents(agents);
60 foreach (AIAgent agent : agents)
61 {
62 if (!agent)
63 continue;
64
66
67 msg.SetReceiver(agent);
68 comms.RequestBroadcast(msg, agent);
69 }
70 }
71
72 //---------------------------------------------------------------------------------------------------------------------------------
75 void Fail(bool doNotCompleteWaypoint)
76 {
77 // If doNotCompleteWaypoint == true, the waypoint completed first and should not be completed for the second time
78 // we break the reference here deliberately and activity wont touch the waypoint from there on
79 if (doNotCompleteWaypoint)
80 m_RelatedWaypoint = null;
81
82 Fail();
83 }
84
85 //---------------------------------------------------------------------------------------------------------------------------------
86 // Called from OnActionFailed and OnActionCompleted of the child behavior
88
89 //---------------------------------------------------------------------------------------------------------------------------------
90 // Called from constructor of the child behavior. Here we can register child behaviors.
92
93 //---------------------------------------------------------------------------------------------------------------------------------
94 #ifdef AI_DEBUG
95 override void AddDebugMessage(string str)
96 {
97 if (!m_Utility || !m_Utility.m_Owner)
98 return;
99 SCR_AIInfoBaseComponent infoComp = SCR_AIInfoBaseComponent.Cast(m_Utility.m_Owner.FindComponent(SCR_AIInfoBaseComponent));
100 infoComp.AddDebugMessage(string.Format("%1: %2", this, str), msgType: EAIDebugMsgType.ACTION);
101 }
102 #endif
103};
104
105class SCR_AIIdleActivity : SCR_AIActivityBase
106{
107 //---------------------------------------------------------------------------------------------------------------------------------
108 void SCR_AIIdleActivity(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint)
109 {
110 m_sBehaviorTree = "AI/BehaviorTrees/Chimera/Group/ActivityIdle.bt";
111 SetPriority(1.0);
112 }
113};
ResourceName m_sBehaviorTree
void OnChildBehaviorFinished(SCR_AIBehaviorBase childBehavior)
SCR_AIActivityFeatureBase FindActivityFeature(typename featureType)
void Fail(bool doNotCompleteWaypoint)
void SendCancelMessagesToAllAgents()
array< ref SCR_AIActivityFeatureBase > GetActivityFeatures()
ref SCR_BTParam< bool > m_bIsWaypointRelated
void SCR_AIActivityBase(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint)
void InitParameters(AIWaypoint relatedWaypoint)
enum SCR_EAIActivityCause m_Utility
void OnChildBehaviorCreated(SCR_AIBehaviorBase childBehavior)
AIWaypoint m_RelatedWaypoint
bool m_bAllowFireteamRebalance
SCR_EAIActivityCause
@ ALWAYS
@ SAFE
void SCR_AIBehaviorBase(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity)
EAIDebugMsgType