Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIConfigComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/AI", description: "Component for utility AI system calculations")]
5
6class 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;
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("", UIWidgets.Object, "Handling configs for weapon types", category: "Weapon Handling")]
69 ref array<ref SCR_AIWeaponTypeHandlingConfig> m_aWeaponTypeHandlingConfig;
71 ref array<int> m_aMinSuppressiveMagCountSpec = {}; // This array is passed to AIWeaponTargetSelector
72
73 [Attribute("", UIWidgets.Object, "Default weapon handling config", category: "Weapon Handling")]
75
76 [Attribute("{3EA0ED1A7C3B8FE5}AI/BehaviorTrees/Chimera/Soldier/HandleWeapon_Default.bt", UIWidgets.Auto, "Fallback BT when nothing found in WeaponTypeSelectionConfig", category: "Weapon Handling")]
78
79 //------------------------------------------------------------------------------------------------
80 override void OnPostInit(IEntity owner)
81 {
82 super.OnPostInit(owner);
83 SetEventMask(owner, EntityEvent.INIT);
84 }
85
86 //------------------------------------------------------------------------------------------------
87 override void EOnInit(IEntity owner)
88 {
89 SCR_AISettingsComponent settings = SCR_AISettingsComponent.GetInstance();
90 if (!settings)
91 return;
92
93 // If the settings component is enabled, overwrite current settings by global ones
94 m_EnableMovement = settings.m_EnableMovement;
95 m_EnableDangerEvents = settings.m_EnableDangerEvents;
96 m_EnablePerception = settings.m_EnablePerception;
97 m_EnableAttack = settings.m_EnableAttack;
98 m_EnableTakeCover = settings.m_EnableTakeCover;
99 m_EnableLooking = settings.m_EnableLooking;
100 m_EnableCommunication = settings.m_EnableCommunication;
101 m_EnableLeaderStop = settings.m_EnableLeaderStop;
102 m_EnableAimingError = settings.m_EnableAimError;
103
104 typename type_EMessageType_Goal = EMessageType_Goal;
105 typename type_EMessageType_Info = EMessageType_Info;
106
107 // Map weapon handling configs based on weapon type
108 // Initialize min magazine specification array
110 m_aMinSuppressiveMagCountSpec.Insert(SCR_AIWeaponTypeHandlingConfig.DEFAULT_LOW_MAG_THRESHOLD);
112 m_aMinSuppressiveMagCountSpec[0] = m_DefaultWeaponTypeHandlingConfig.m_iMinSuppressiveMagCountThreshold;
114 {
115 m_mWeaponTypeHandlingConfig[config.m_eWeaponType] = config;
116
117 m_aMinSuppressiveMagCountSpec.Insert(config.m_eWeaponType);
118 m_aMinSuppressiveMagCountSpec.Insert(config.m_iMinSuppressiveMagCountThreshold);
119 }
120
121 foreach (SCR_AIDangerReaction reaction : m_aDangerReactions)
122 m_mDangerReactions[reaction.m_eType] = reaction;
123
124 m_aGoalReactionsPacked.Resize(type_EMessageType_Goal.GetVariableCount());
125 foreach (SCR_AIGoalReaction reaction : m_aGoalReactions)
126 {
127 if (reaction.m_eType != EMessageType_Goal.NONE)
128 m_aGoalReactionsPacked[reaction.m_eType] = reaction;
129 }
130
131 m_aInfoReactionsPacked.Resize(type_EMessageType_Info.GetVariableCount());
132 foreach (SCR_AIInfoReaction reaction : m_aInfoReactions)
133 {
134 if (reaction.m_eType != EMessageType_Info.NONE)
135 m_aInfoReactionsPacked[reaction.m_eType] = reaction;
136 }
137 }
138
139 //------------------------------------------------------------------------------------------------
141 {
143 if (!config)
145
146 return config;
147 }
148
149 //------------------------------------------------------------------------------------------------
153 void PerformGoalReaction(SCR_AIUtilityComponent utility, SCR_AIMessageBase message)
154 {
155 SCR_AIMessageGoal goalMessage = SCR_AIMessageGoal.Cast(message);
156 if (!goalMessage)
157 {
158 Debug.Error("Message mismatch");
159 return;
160 }
161 SCR_AIGoalReaction reaction = m_aGoalReactionsPacked[goalMessage.m_MessageType];
162 if (reaction)
163 {
164 reaction.PerformReaction(utility, message);
165 return;
166 }
167 }
168
169 //------------------------------------------------------------------------------------------------
174 {
175 SCR_AIMessageGoal goalMessage = SCR_AIMessageGoal.Cast(message);
176 if (!goalMessage)
177 {
178 Debug.Error("Message mismatch");
179 return;
180 }
181 SCR_AIGoalReaction reaction = m_aGoalReactionsPacked[goalMessage.m_MessageType];
182 if (reaction)
183 {
184 reaction.PerformReaction(utility, message);
185 return;
186 }
187 }
188
189 //------------------------------------------------------------------------------------------------
194 {
195 SCR_AIMessageInfo infoMessage = SCR_AIMessageInfo.Cast(message);
196 if (!infoMessage)
197 {
198 Debug.Error("Message mismatch");
199 return;
200 }
201 SCR_AIInfoReaction reaction = m_aInfoReactionsPacked[infoMessage.m_MessageType];
202 if (reaction)
203 {
204 reaction.PerformReaction(utility, message);
205 return;
206 }
207 }
208
209 //------------------------------------------------------------------------------------------------
213 void PerformInfoReaction(SCR_AIUtilityComponent utility, SCR_AIMessageBase message)
214 {
215 SCR_AIMessageInfo infoMessage = SCR_AIMessageInfo.Cast(message);
216 if (!infoMessage)
217 {
218 Debug.Error("Message mismatch");
219 return;
220 }
221 SCR_AIInfoReaction reaction = m_aInfoReactionsPacked[infoMessage.m_MessageType];
222 if (reaction)
223 {
224 reaction.PerformReaction(utility, message);
225 return;
226 }
227 }
228
229 //------------------------------------------------------------------------------------------------
234 bool PerformDangerReaction(SCR_AIUtilityComponent utility, AIDangerEvent dangerEvent, int dangerEventCount)
235 {
236 SCR_AIDangerReaction reaction = m_mDangerReactions[dangerEvent.GetDangerType()];
237 if (reaction)
238 {
239 return reaction.PerformReaction(utility, utility.m_ThreatSystem, dangerEvent, dangerEventCount);
240 }
241 return false;
242 }
243
244 //------------------------------------------------------------------------------------------------
247 void AddDefaultBehaviors(SCR_AIUtilityComponent utility)
248 {
249 foreach (SCR_AIReactionBase reaction : m_aDefaultReactions)
250 {
251 reaction.PerformReaction(utility); // @TODO: This has to work for all reactions, now it would work only on default ones
252 }
253 }
254
255 //------------------------------------------------------------------------------------------------
259 {
260 foreach (SCR_AIReactionBase reaction : m_aDefaultReactions)
261 {
262 reaction.PerformReaction(utility); // @TODO: This has to work for all reactions, now it would work only on default ones
263 }
264 }
265
266 //------------------------------------------------------------------------------------------------
269 {
271 {
272 if (configItem.m_eWeaponType == EWeaponType.WT_NONE || configItem.m_eWeaponType == weaponType) // NONE will work as ANY, first filter = weapon type
273 {
274 if (configItem.m_eMuzzleType == muzzleType) // second filter = muzzle type
275 {
276 return configItem.m_sBehaviorTree;
277 }
278 }
279 }
281 }
282}
ref array< ref SCR_AIInfoReaction > m_aInfoReactionsPacked
bool m_EnableTakeCover
ref array< ref SCR_AIGoalReaction > m_aGoalReactions
bool m_EnableLooking
ref array< ref SCR_AIGoalReaction > m_aGoalReactionsPacked
ref array< ref SCR_AIWeaponTypeHandlingConfig > m_aWeaponTypeHandlingConfig
ref map< EWeaponType, ref SCR_AIWeaponTypeHandlingConfig > m_mWeaponTypeHandlingConfig
ref array< int > m_aMinSuppressiveMagCountSpec
ref array< ref SCR_AIReactionBase > m_aDefaultReactions
void AddDefaultBehaviors(SCR_AIUtilityComponent utility)
bool m_EnableLeaderStop
ref array< ref SCR_AIInfoReaction > m_aInfoReactions
void PerformInfoReaction(SCR_AIGroupUtilityComponent utility, SCR_AIMessageBase message)
ref SCR_AITargetReaction_SelectedTargetChangedBase m_Reaction_SelectedTargetChanged
bool m_EnableAttack
bool PerformDangerReaction(SCR_AIUtilityComponent utility, AIDangerEvent dangerEvent, int dangerEventCount)
ref SCR_AITargetReactionBase m_Reaction_UnknownTarget
void PerformGoalReaction(SCR_AIUtilityComponent utility, SCR_AIMessageBase message)
ref array< ref SCR_AIDangerReaction > m_aDangerReactions
ResourceName GetTreeNameForWeaponType(EWeaponType weaponType, EMuzzleType muzzleType)
Returns resource name set for specific WeaponType and MuzzleType as sub-filter.
ResourceName m_sDefaultWeaponBehaviorTree
bool m_EnableDangerEvents
ref map< EAIDangerEventType, ref SCR_AIDangerReaction > m_mDangerReactions
ref array< ref SCR_AIWeaponTypeSelectionConfig > m_aWeaponTypeSelectionConfig
void AddDefaultActivities(SCR_AIGroupUtilityComponent utility)
ref SCR_AITargetReactionBase m_Reaction_RetreatFromTarget
bool m_EnableAimingError
SCR_AIWeaponTypeHandlingConfig GetWeaponTypeHandlingConfig(EWeaponType weaponType)
bool m_EnablePerception
bool m_EnableMovement
ref SCR_AIWeaponTypeHandlingConfig m_DefaultWeaponTypeHandlingConfig
bool m_EnableCommunication
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
EMessageType_Goal
EMessageType_Info
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Event which gets broadcasted from danger-causing places to AI.
Definition Debug.c:13
proto external int SetEventMask(notnull IEntity owner, int mask)
This reaction is called every time selected target changes from anything to anything,...
void EOnInit(IEntity owner)
Definition Types.c:486
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14
EWeaponType
Definition EWeaponType.c:13
EMuzzleType
Definition EMuzzleType.c:13