Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScenarioFrameworkActionOnDamage.c
Go to the documentation of this file.
3{
4 [Attribute(desc: "Entity to check for damage.")]
5 ref SCR_ScenarioFrameworkGet m_Getter;
6
7 [Attribute(desc: "Checked Conditions.")]
8 ref array<ref SCR_ScenarioFrameworkDamageContextConditionBase> m_aDamageContextConditions;
9
10 [Attribute(desc: "Actions to be executed if conditions' evaluation is successful.")]
11 ref array<ref SCR_ScenarioFrameworkActionBase> m_aActions;
12
13 [Attribute(defvalue: SCR_EScenarioFrameworkLogicOperators.AND.ToString(), UIWidgets.ComboBox, "Which Boolean Logic will be used for Damage Conditions", "", enums: SCR_EScenarioFrameworkLogicOperatorHelper.GetParamInfo(), category: "Activation")]
14 SCR_EScenarioFrameworkLogicOperators m_eActivationConditionLogic;
15
16 //------------------------------------------------------------------------------------------------
17 override void OnActivate(IEntity object)
18 {
19 if (!CanActivate())
20 return;
21
22 if (!ValidateInputEntity(object, m_Getter, m_Entity))
23 return;
24
25 AIGroup group = AIGroup.Cast(m_Entity);
26 if (!group)
27 {
28 SetupInvoker(m_Entity);
29 return;
30 }
31
32 array<AIAgent> agents = {};
33 group.GetAgents(agents);
34 IEntity controlledEntity;
35
36 foreach (AIAgent agent : agents)
37 {
38 controlledEntity = agent.GetControlledEntity();
39 if (controlledEntity)
40 SetupInvoker(controlledEntity);
41 }
42 }
43
44 //------------------------------------------------------------------------------------------------
45 void SetupInvoker(IEntity object)
46 {
47 SCR_DamageManagerComponent objectDmgManager = SCR_DamageManagerComponent.GetDamageManager(object);
48 if (!objectDmgManager)
49 return;
50
51 objectDmgManager.GetOnDamage().Remove(OnDamage);
52 objectDmgManager.GetOnDamage().Insert(OnDamage);
53 }
54
55 //------------------------------------------------------------------------------------------------
57 void OnDamage(BaseDamageContext damageContext)
58 {
59 if (!damageContext)
60 return;
61
62 if (!EvaluateConditions(damageContext))
63 return;
64
65 foreach (SCR_ScenarioFrameworkActionBase actions : m_aActions)
66 {
67 actions.OnActivate(m_Entity);
68 }
69 }
70
71 //------------------------------------------------------------------------------------------------
72 override array<ref SCR_ScenarioFrameworkActionBase> GetSubActions()
73 {
74 array<ref SCR_ScenarioFrameworkActionBase> allActions = {};
75
76 foreach (SCR_ScenarioFrameworkActionBase action : m_aActions)
77 {
78 allActions.Insert(action);
79 }
80
81 return allActions;
82 }
83
84 //------------------------------------------------------------------------------------------------
85 bool EvaluateConditions(BaseDamageContext damageContext)
86 {
87 switch (m_eActivationConditionLogic)
88 {
90 return EvaluateConditionsAND(damageContext);
91
93 return EvaluateConditionsOR(damageContext);
94
96 return EvaluateConditionsNAND(damageContext);
97
99 return EvaluateConditionsXOR(damageContext);
100 }
101
102 return false;
103 }
104
105 //------------------------------------------------------------------------------------------------
106 bool EvaluateConditionsAND(BaseDamageContext damageContext)
107 {
108 if (m_aDamageContextConditions.IsEmpty())
109 return false;
110
111 foreach (SCR_ScenarioFrameworkDamageContextConditionBase action : m_aDamageContextConditions)
112 {
113 if (!action.Init(damageContext))
114 return false;
115 }
116
117 return true;
118 }
119
120 //------------------------------------------------------------------------------------------------
121 bool EvaluateConditionsOR(BaseDamageContext damageContext)
122 {
123 foreach (SCR_ScenarioFrameworkDamageContextConditionBase action : m_aDamageContextConditions)
124 {
125 if (action.Init(damageContext))
126 return true;
127 }
128
129 return false;
130 }
131
132 //------------------------------------------------------------------------------------------------
133 bool EvaluateConditionsNAND(BaseDamageContext damageContext)
134 {
135 return !EvaluateConditionsAND(damageContext);
136 }
137
138 //------------------------------------------------------------------------------------------------
139 bool EvaluateConditionsXOR(BaseDamageContext damageContext)
140 {
141 bool priorSuccess = false;
142 foreach (SCR_ScenarioFrameworkDamageContextConditionBase action : m_aDamageContextConditions)
143 {
144 bool success = action.Init(damageContext);
145 if (priorSuccess && success)
146 return false;
147
148 priorSuccess |= success;
149 }
150 return priorSuccess;
151 }
152}
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
override void OnActivate()
SCR_CharacterBloodHitZone OnDamage
Resilience - incapacitation or death, depending on game mode settings.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_FieldOfViewSettings Attribute