Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIBaseUtilityComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/AI", description: "Component for utility AI system calculations")]
5
6// TODO:
7// - For handling orders, use enums
8
9class SCR_AIBaseUtilityComponent : AIBaseUtilityComponent
10{
11 // This can be set externally to request a breakpoint on next EvaluateBehavior
12 #ifdef AI_DEBUG
13 protected bool m_bEvaluationBreakpoint;
14 protected int m_iDiagCounter = 0;
15 #endif
16
17 //------------------------------------------------------------------------------------------------
21 void SendMessage(AIMessage msg, AIAgent receiver = null)
22 {
23 AICommunicationComponent commsComp = GetAIAgent().GetCommunicationComponent();
24 if (!commsComp)
25 return;
26
27 commsComp.RequestBroadcast(msg, receiver);
28 }
29
30 //------------------------------------------------------------------------------------------------
34 {
35 #ifdef AI_DEBUG
36 return m_iDiagCounter;
37 #else
38 return 0;
39 #endif
40 }
41
42 //------------------------------------------------------------------------------------------------
45 {
46 #ifdef AI_DEBUG
47 m_iDiagCounter++;
48 #endif
49 }
50
51 //------------------------------------------------------------------------------------------------
54 {
55 #ifdef AI_DEBUG
56 m_bEvaluationBreakpoint = true;
57 #endif
58 }
59
60 #ifdef AI_DEBUG
61 //------------------------------------------------------------------------------------------------
62 protected void AddDebugMessage(string str, EAIDebugMsgType messageType = EAIDebugMsgType.UTILITY)
63 {
64 SCR_AIInfoBaseComponent infoComp = SCR_AIInfoBaseComponent.Cast(GetOwner().FindComponent(SCR_AIInfoBaseComponent));
65 infoComp.AddDebugMessage(str, msgType: messageType);
66 }
67
68 //------------------------------------------------------------------------------------------------
69 protected void DebugLogActionsPriority()
70 {
71 array<ref AIActionBase> actions = {};
72 GetActions(actions);
73 foreach (AIActionBase action : actions)
74 {
75 string actionStr = GetActionLogString(action);
76 AddDebugMessage(actionStr);
77
78 SCR_AICompositeActionParallel parallelAction = SCR_AICompositeActionParallel.Cast(action);
79 if (parallelAction)
80 {
81 array<AIActionBase> subactions = {};
82 parallelAction.GetSubactions(subactions);
83 foreach (AIActionBase subaction : subactions)
84 {
85 string subactionStr = " " + GetActionLogString(subaction);
86 AddDebugMessage(subactionStr);
87 }
88 }
89
90 }
91 }
92
93 //------------------------------------------------------------------------------------------------
94 protected string GetActionLogString(AIActionBase action)
95 {
96 SCR_AIActionBase scrActionBase = SCR_AIActionBase.Cast(action);
97
98 string _strSuspended = string.Empty;
99 if (action.GetActionIsSuspended())
100 _strSuspended = "(S) ";
101 float score = action.Evaluate();
102 string _strDebugInfo;
103 if (scrActionBase)
104 _strDebugInfo = scrActionBase.GetActionDebugInfo();
105
106 return string.Format(" %1%2 %3 %4", _strSuspended, score.ToString(3, 1), action.Type().ToString(), _strDebugInfo);
107 }
108
109 #endif
110}
void SendMessage(AICommunicationComponent comms, SCR_AIActivityBase activity, vector position, float delay)
int DiagGetCounter()
void DiagIncreaseCounter()
void DiagSetBreakpoint()
EAIDebugMsgType
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
array< ref SCR_MenuActionPreset > GetActions()
Base class for all messages related to AI.
Definition AIMessage.c:14
void GetSubactions(notnull array< AIActionBase > outSubactions)
IEntity GetOwner()
Owner entity of the fuel tank.