Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIConfigComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/AI", description: "Component for utility AI system calculations")]
2 class SCR_AIConfigComponentClass : ScriptComponentClass
3 {
4 }
5 
6 class SCR_AIConfigComponent : ScriptComponent
7 {
8  // @TODO: Implement into the rest of the AI
9  [Attribute( defvalue: "0.5", uiwidget: UIWidgets.Slider, desc: "Unit skill", params: "0 1 0.01" )]
10  float m_Skill;
11 
12  [Attribute( defvalue: "1", uiwidget: UIWidgets.CheckBox, desc: "Alow movement" )]
14 
15  [Attribute( defvalue: "1", uiwidget: UIWidgets.CheckBox, desc: "Allow reacting on danger events" )]
17 
18  [Attribute( defvalue: "1", uiwidget: UIWidgets.CheckBox, desc: "Allow reacting on perceived targets" )]
20 
21  [Attribute( defvalue: "1", uiwidget: UIWidgets.CheckBox, desc: "Allow shooting and attacking in general" )]
23 
24  [Attribute( defvalue: "1", uiwidget: UIWidgets.CheckBox, desc: "Allow finding and taking cover" )]
26 
27  [Attribute( defvalue: "1", uiwidget: UIWidgets.CheckBox, desc: "Allow aiming and gestures in general" )]
29 
30  [Attribute( defvalue: "1", uiwidget: UIWidgets.CheckBox, desc: "Allow sending AI messages" )]
32 
33  [Attribute( defvalue: "0", uiwidget: UIWidgets.CheckBox, desc: "Allow leader to stop when formation is deformed" )]
35 
36  [Attribute( defvalue: "1", uiwidget: UIWidgets.CheckBox, desc: "Allow artificial aiming error for AI." )]
38 
39  [Attribute("", UIWidgets.Object)]
40  ref array<ref SCR_AIReactionBase> m_aDefaultReactions;
41 
42  [Attribute("", UIWidgets.Object)]
43  ref array<ref SCR_AIDangerReaction> m_aDangerReactions;
44  ref map<EAIDangerEventType, ref SCR_AIDangerReaction> m_mDangerReactions = new map<EAIDangerEventType, ref SCR_AIDangerReaction>();
45 
46  [Attribute("", UIWidgets.Object)]
47  ref array<ref SCR_AIGoalReaction> m_aGoalReactions;
48 
49  ref array<ref SCR_AIGoalReaction> m_aGoalReactionsPacked = {};
50 
51  [Attribute("", UIWidgets.Object)]
52  ref array<ref SCR_AIInfoReaction> m_aInfoReactions;
53 
54  ref array<ref SCR_AIInfoReaction> m_aInfoReactionsPacked = {};
55 
56  [Attribute("", UIWidgets.Object)]
58 
59  [Attribute("", UIWidgets.Object)]
61 
62  [Attribute("", UIWidgets.Object)]
64 
65  [Attribute("", UIWidgets.Auto, "Specifies which behavior tree is used for specific weapon type", category: "Weapon Handling")]
66  ref array<ref SCR_AIWeaponTypeSelectionConfig> m_aWeaponTypeSelectionConfig;
67 
68  [Attribute("{3EA0ED1A7C3B8FE5}AI/BehaviorTrees/Chimera/Soldier/HandleWeapon_Default.bt", UIWidgets.Auto, "Fallback BT when nothing found in WeaponTypeSelectionConfig", category: "Weapon Handling")]
70 
71  //------------------------------------------------------------------------------------------------
72  override void OnPostInit(IEntity owner)
73  {
74  super.OnPostInit(owner);
75  SetEventMask(owner, EntityEvent.INIT);
76  }
77 
78  //------------------------------------------------------------------------------------------------
79  override void EOnInit(IEntity owner)
80  {
81  SCR_AISettingsComponent settings = SCR_AISettingsComponent.GetInstance();
82  if (!settings)
83  return;
84 
85  // If the settings component is enabled, overwrite current settings by global ones
86  m_EnableMovement = settings.m_EnableMovement;
87  m_EnableDangerEvents = settings.m_EnableDangerEvents;
88  m_EnablePerception = settings.m_EnablePerception;
89  m_EnableAttack = settings.m_EnableAttack;
90  m_EnableTakeCover = settings.m_EnableTakeCover;
91  m_EnableLooking = settings.m_EnableLooking;
92  m_EnableCommunication = settings.m_EnableCommunication;
93  m_EnableLeaderStop = settings.m_EnableLeaderStop;
94  m_EnableAimingError = settings.m_EnableAimError;
95 
96  typename type_EMessageType_Goal = EMessageType_Goal;
97  typename type_EMessageType_Info = EMessageType_Info;
98 
99  foreach (SCR_AIDangerReaction reaction : m_aDangerReactions)
100  {
101  m_mDangerReactions[reaction.m_eType] = reaction;
102  }
103 
104  m_aGoalReactionsPacked.Resize(type_EMessageType_Goal.GetVariableCount());
105  foreach (SCR_AIGoalReaction reaction : m_aGoalReactions)
106  {
107  if(reaction.m_eType != EMessageType_Goal.NONE)
108  m_aGoalReactionsPacked[reaction.m_eType] = reaction;
109  }
110 
111  m_aInfoReactionsPacked.Resize(type_EMessageType_Info.GetVariableCount());
112  foreach (SCR_AIInfoReaction reaction : m_aInfoReactions)
113  {
114  if(reaction.m_eType != EMessageType_Info.NONE)
115  m_aInfoReactionsPacked[reaction.m_eType] = reaction;
116  }
117  }
118 
119  //------------------------------------------------------------------------------------------------
123  void PerformGoalReaction(SCR_AIUtilityComponent utility, SCR_AIMessageBase message)
124  {
125  SCR_AIMessageGoal goalMessage = SCR_AIMessageGoal.Cast(message);
126  if (!goalMessage)
127  {
128  Debug.Error("Message mismatch");
129  return;
130  }
131  SCR_AIGoalReaction reaction = m_aGoalReactionsPacked[goalMessage.m_MessageType];
132  if (reaction)
133  {
134  reaction.PerformReaction(utility, message);
135  return;
136  }
137  }
138 
139  //------------------------------------------------------------------------------------------------
143  void PerformGoalReaction(SCR_AIGroupUtilityComponent utility, SCR_AIMessageBase message)
144  {
145  SCR_AIMessageGoal goalMessage = SCR_AIMessageGoal.Cast(message);
146  if (!goalMessage)
147  {
148  Debug.Error("Message mismatch");
149  return;
150  }
151  SCR_AIGoalReaction reaction = m_aGoalReactionsPacked[goalMessage.m_MessageType];
152  if (reaction)
153  {
154  reaction.PerformReaction(utility, message);
155  return;
156  }
157  }
158 
159  //------------------------------------------------------------------------------------------------
163  void PerformInfoReaction(SCR_AIGroupUtilityComponent utility, SCR_AIMessageBase message)
164  {
165  SCR_AIMessageInfo infoMessage = SCR_AIMessageInfo.Cast(message);
166  if (!infoMessage)
167  {
168  Debug.Error("Message mismatch");
169  return;
170  }
171  SCR_AIInfoReaction reaction = m_aInfoReactionsPacked[infoMessage.m_MessageType];
172  if (reaction)
173  {
174  reaction.PerformReaction(utility, message);
175  return;
176  }
177  }
178 
179  //------------------------------------------------------------------------------------------------
183  void PerformInfoReaction(SCR_AIUtilityComponent utility, SCR_AIMessageBase message)
184  {
185  SCR_AIMessageInfo infoMessage = SCR_AIMessageInfo.Cast(message);
186  if (!infoMessage)
187  {
188  Debug.Error("Message mismatch");
189  return;
190  }
191  SCR_AIInfoReaction reaction = m_aInfoReactionsPacked[infoMessage.m_MessageType];
192  if (reaction)
193  {
194  reaction.PerformReaction(utility, message);
195  return;
196  }
197  }
198 
199  //------------------------------------------------------------------------------------------------
204  bool PerformDangerReaction(SCR_AIUtilityComponent utility, AIDangerEvent dangerEvent)
205  {
206  SCR_AIDangerReaction reaction = m_mDangerReactions[dangerEvent.GetDangerType()];
207  if (reaction)
208  {
209  return reaction.PerformReaction(utility, utility.m_ThreatSystem, dangerEvent);
210  }
211  return false;
212  }
213 
214  //------------------------------------------------------------------------------------------------
217  void AddDefaultBehaviors(SCR_AIUtilityComponent utility)
218  {
219  foreach (SCR_AIReactionBase reaction : m_aDefaultReactions)
220  {
221  reaction.PerformReaction(utility); // @TODO: This has to work for all reactions, now it would work only on default ones
222  }
223  }
224 
225  //------------------------------------------------------------------------------------------------
228  void AddDefaultActivities(SCR_AIGroupUtilityComponent utility)
229  {
230  foreach (SCR_AIReactionBase reaction : m_aDefaultReactions)
231  {
232  reaction.PerformReaction(utility); // @TODO: This has to work for all reactions, now it would work only on default ones
233  }
234  }
235 
236  //------------------------------------------------------------------------------------------------
238  ResourceName GetTreeNameForWeaponType(EWeaponType weaponType, EMuzzleType muzzleType)
239  {
241  {
242  if (configItem.m_eWeaponType == EWeaponType.WT_NONE || configItem.m_eWeaponType == weaponType) // NONE will work as ANY, first filter = weapon type
243  {
244  if (configItem.m_eMuzzleType == muzzleType) // second filter = muzzle type
245  {
246  return configItem.m_sBehaviorTree;
247  }
248  }
249  }
251  }
252 }
PerformInfoReaction
void PerformInfoReaction(SCR_AIGroupUtilityComponent utility, SCR_AIMessageBase message)
Definition: SCR_AIConfigComponent.c:163
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
m_aDefaultReactions
ref array< ref SCR_AIReactionBase > m_aDefaultReactions
Definition: SCR_AIConfigComponent.c:40
GetTreeNameForWeaponType
ResourceName GetTreeNameForWeaponType(EWeaponType weaponType, EMuzzleType muzzleType)
Returns resource name set for specific WeaponType and MuzzleType as sub-filter.
Definition: SCR_AIConfigComponent.c:238
m_mDangerReactions
ref map< EAIDangerEventType, ref SCR_AIDangerReaction > m_mDangerReactions
Definition: SCR_AIConfigComponent.c:44
m_EnableTakeCover
bool m_EnableTakeCover
Definition: SCR_AIConfigComponent.c:25
Attribute
SCR_AIConfigComponentClass ScriptComponentClass Attribute(defvalue:"0.5", uiwidget:UIWidgets.Slider, desc:"Unit skill", params:"0 1 0.01")] float m_Skill
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
m_EnableLeaderStop
bool m_EnableLeaderStop
Definition: SCR_AIConfigComponent.c:34
m_EnableMovement
bool m_EnableMovement
Definition: SCR_AIConfigComponent.c:13
m_EnableDangerEvents
bool m_EnableDangerEvents
Definition: SCR_AIConfigComponent.c:16
AddDefaultActivities
void AddDefaultActivities(SCR_AIGroupUtilityComponent utility)
Definition: SCR_AIConfigComponent.c:228
EMessageType_Info
EMessageType_Info
Definition: SCR_AIMessage.c:1
PerformGoalReaction
void PerformGoalReaction(SCR_AIUtilityComponent utility, SCR_AIMessageBase message)
Definition: SCR_AIConfigComponent.c:123
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
m_EnableAimingError
bool m_EnableAimingError
Definition: SCR_AIConfigComponent.c:37
SCR_AIWeaponTypeSelectionConfig
Definition: SCR_AIWeaponTypeSelectionConfig.c:2
m_EnableCommunication
bool m_EnableCommunication
Definition: SCR_AIConfigComponent.c:31
m_aGoalReactionsPacked
ref array< ref SCR_AIGoalReaction > m_aGoalReactionsPacked
Definition: SCR_AIConfigComponent.c:49
SCR_AIMessageGoal
Definition: SCR_AIMessage.c:69
m_Reaction_SelectedTargetChanged
ref SCR_AITargetReaction_SelectedTargetChangedBase m_Reaction_SelectedTargetChanged
Definition: SCR_AIConfigComponent.c:63
SCR_AIDangerReaction
Definition: SCR_AIDangerReaction.c:4
m_Reaction_RetreatFromTarget
ref SCR_AITargetReactionBase m_Reaction_RetreatFromTarget
Definition: SCR_AIConfigComponent.c:60
SCR_AIConfigComponentClass
Definition: SCR_AIConfigComponent.c:2
m_EnableAttack
bool m_EnableAttack
Definition: SCR_AIConfigComponent.c:22
OnPostInit
override void OnPostInit(IEntity owner)
Called on PostInit when all components are added.
Definition: SCR_AIConfigComponent.c:72
SCR_AIInfoReaction
Definition: SCR_AIInfoReaction.c:6
EMessageType_Goal
EMessageType_Goal
Definition: SCR_AIMessage.c:15
EOnInit
override void EOnInit(IEntity owner)
Definition: SCR_AIConfigComponent.c:79
EMuzzleType
EMuzzleType
Definition: EMuzzleType.c:12
m_aInfoReactionsPacked
ref array< ref SCR_AIInfoReaction > m_aInfoReactionsPacked
Definition: SCR_AIConfigComponent.c:54
m_Reaction_UnknownTarget
ref SCR_AITargetReactionBase m_Reaction_UnknownTarget
Definition: SCR_AIConfigComponent.c:57
SCR_AITargetReactionBase
Definition: SCR_AITargetReaction.c:5
m_EnableLooking
bool m_EnableLooking
Definition: SCR_AIConfigComponent.c:28
SCR_AIGoalReaction
Definition: SCR_AIGoalReaction.c:6
SCR_AIMessageInfo
Definition: SCR_AIMessage.c:95
EWeaponType
EWeaponType
Definition: EWeaponType.c:12
m_EnablePerception
bool m_EnablePerception
Definition: SCR_AIConfigComponent.c:19
m_aInfoReactions
ref array< ref SCR_AIInfoReaction > m_aInfoReactions
Definition: SCR_AIConfigComponent.c:52
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
m_aGoalReactions
ref array< ref SCR_AIGoalReaction > m_aGoalReactions
Definition: SCR_AIConfigComponent.c:47
m_aDangerReactions
ref array< ref SCR_AIDangerReaction > m_aDangerReactions
Definition: SCR_AIConfigComponent.c:43
PerformDangerReaction
bool PerformDangerReaction(SCR_AIUtilityComponent utility, AIDangerEvent dangerEvent)
Definition: SCR_AIConfigComponent.c:204
m_sDefaultWeaponBehaviorTree
ResourceName m_sDefaultWeaponBehaviorTree
Definition: SCR_AIConfigComponent.c:69
AddDefaultBehaviors
void AddDefaultBehaviors(SCR_AIUtilityComponent utility)
Definition: SCR_AIConfigComponent.c:217
SCR_AIReactionBase
Definition: SCR_AIReactionBase.c:6
m_aWeaponTypeSelectionConfig
ref array< ref SCR_AIWeaponTypeSelectionConfig > m_aWeaponTypeSelectionConfig
Definition: SCR_AIConfigComponent.c:66
SCR_AIMessageBase
Definition: SCR_AIMessage.c:44
SCR_AITargetReaction_SelectedTargetChangedBase
This reaction is called every time selected target changes from anything to anything,...
Definition: SCR_AITargetReaction.c:12
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180