Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DamageIntensityHolder.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 {
4  NO_DAMAGE = 0,
5  LOW,
7  HIGH,
8  CRITICAL,
9 }
10 
11 //------------------------------------------------------------------------------------------------
13 [BaseContainerProps(configRoot: true)]
14 class SCR_DamageIntensityHolder
15 {
16  [Attribute()]
17  protected ref array<ref SCR_DamageIntensityEntry> m_aDamageIntensityEntries;
18 
19  protected ref SCR_SortedArray<SCR_DamageIntensityEntry> m_SortedDamageIntensityEntries;
20 
21  //------------------------------------------------------------------------------------------------
22  SCR_DamageIntensityEntry GetValidIntensityEntry(float value)
23  {
24  if (value < 0)
25  {
26  Print("'SCR_DamageIntensityEntry' Damage scaled cannot be less than 0!", LogLevel.WARNING);
27  value = 0;
28  }
29 
31  for (int i = 0, count = m_SortedDamageIntensityEntries.Count(); i < count; i++)
32  {
33  //~ Check if entry is valid damage state
34  entry = m_SortedDamageIntensityEntries.Get(i);
35  if (!entry || !entry.IsValidDamageState(value))
36  continue;
37 
38  //~ Valid entry
39  return entry;
40  }
41 
42  return null;
43  }
44 
45  //------------------------------------------------------------------------------------------------
46  SCR_DamageIntensityEntry GetValidIntensityEntry(notnull array<HitZone> hitZones)
47  {
48  if (hitZones.IsEmpty())
49  return null;
50 
51  float healthScaled = 0;
52  foreach (HitZone hitZone : hitZones)
53  {
54  healthScaled += hitZone.GetHealthScaled();
55  }
56 
57  return GetValidIntensityEntry(healthScaled / hitZones.Count());
58  }
59 
60  //------------------------------------------------------------------------------------------------
61  SCR_DamageIntensityEntry GetValidIntensityEntry(notnull HitZone hitZone)
62  {
63  return GetValidIntensityEntry(hitZone.GetHealthScaled());
64  }
65 
66  //------------------------------------------------------------------------------------------------
67  SCR_DamageIntensityEntry GetValidIntensityEntry(notnull SCR_DamageManagerComponent damageManager)
68  {
69  HitZone defaultHitZone = damageManager.GetDefaultHitZone();
70  if (defaultHitZone)
71  return GetValidIntensityEntry(defaultHitZone.GetHealthScaled());
72 
73  return null;
74  }
75 
76  //------------------------------------------------------------------------------------------------
77  SCR_UIName GetValidIntensityUIInfo(float value)
78  {
79  SCR_DamageIntensityEntry entry = GetValidIntensityEntry(value);
80 
81  if (entry)
82  return entry.GetUiInfo();
83 
84  return null;
85  }
86 
87  //------------------------------------------------------------------------------------------------
88  SCR_UIName GetValidIntensityUIInfo(notnull array<HitZone> hitZones)
89  {
90  SCR_DamageIntensityEntry entry = GetValidIntensityEntry(hitZones);
91 
92  if (entry)
93  return entry.GetUiInfo();
94 
95  return null;
96  }
97 
98  //------------------------------------------------------------------------------------------------
99  SCR_UIName GetValidIntensityUIInfo(notnull HitZone hitZone)
100  {
101  SCR_DamageIntensityEntry entry = GetValidIntensityEntry(hitZone);
102 
103  if (entry)
104  return entry.GetUiInfo();
105 
106  return null;
107  }
108 
109  //------------------------------------------------------------------------------------------------
110  SCR_UIName GetValidIntensityUIInfo(notnull SCR_DamageManagerComponent damageManager)
111  {
112  SCR_DamageIntensityEntry entry = GetValidIntensityEntry(damageManager);
113 
114  if (entry)
115  return entry.GetUiInfo();
116 
117  return null;
118  }
119 
120  //------------------------------------------------------------------------------------------------
121  SCR_EDamageIntensityType GetValidIntensityType(float value)
122  {
123  SCR_DamageIntensityEntry entry = GetValidIntensityEntry(value);
124 
125  if (entry)
126  return entry.GetDamageIntensityType();
127 
128  return SCR_EDamageIntensityType.NO_DAMAGE;
129  }
130 
131  //------------------------------------------------------------------------------------------------
132  SCR_EDamageIntensityType GetValidIntensityType(notnull array<HitZone> hitZones)
133  {
134  SCR_DamageIntensityEntry entry = GetValidIntensityEntry(hitZones);
135 
136  if (entry)
137  return entry.GetDamageIntensityType();
138 
139  return SCR_EDamageIntensityType.NO_DAMAGE;
140  }
141 
142  //------------------------------------------------------------------------------------------------
143  SCR_EDamageIntensityType GetValidIntensityType(notnull HitZone hitZone)
144  {
145  SCR_DamageIntensityEntry entry = GetValidIntensityEntry(hitZone);
146 
147  if (entry)
148  return entry.GetDamageIntensityType();
149 
150  return SCR_EDamageIntensityType.NO_DAMAGE;
151  }
152 
153  //------------------------------------------------------------------------------------------------
154  SCR_EDamageIntensityType GetValidIntensityType(notnull SCR_DamageManagerComponent damageManager)
155  {
156  SCR_DamageIntensityEntry entry = GetValidIntensityEntry(damageManager);
157 
158  if (entry)
159  return entry.GetDamageIntensityType();
160 
161  return SCR_EDamageIntensityType.NO_DAMAGE;
162  }
163 
164  //------------------------------------------------------------------------------------------------
166  {
168  for (int i = 0, count = m_SortedDamageIntensityEntries.Count(); i < count; i++)
169  {
170  entry = m_SortedDamageIntensityEntries.Get(i);
171  if (entry && entry.GetDamageIntensityType() == type)
172  return entry;
173  }
174 
175  return null;
176  }
177 
178  //------------------------------------------------------------------------------------------------
179  SCR_UIName GetIntensityUIInfo(SCR_EDamageIntensityType type)
180  {
181  SCR_DamageIntensityEntry entry = GetIntensityEntry(type);
182  if (entry)
183  return entry.GetUiInfo();
184 
185  return null;
186  }
187 
188  //------------------------------------------------------------------------------------------------
189  string GetIntensityName(SCR_EDamageIntensityType type)
190  {
191  SCR_UIName uiInfo = GetIntensityUIInfo(type);
192  if (uiInfo)
193  return uiInfo.GetName();
194 
195  return string.Empty;
196  }
197 
198  //------------------------------------------------------------------------------------------------
199  void SCR_DamageIntensityHolder()
200  {
201  m_SortedDamageIntensityEntries = new SCR_SortedArray<SCR_DamageIntensityEntry>();
202  foreach (SCR_DamageIntensityEntry entry : m_aDamageIntensityEntries)
203  {
204  if (!entry || !entry.m_bIsEnabled || !entry.GetUiInfo())
205  continue;
206 
207  m_SortedDamageIntensityEntries.Insert(entry.m_iOrder, entry);
208  }
209  }
210 }
211 
212 //------------------------------------------------------------------------------------------------
215 {
216  [Attribute(desc: "The intensity enum associated with the min and max damage", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(SCR_EDamageIntensityType))]
217  protected SCR_EDamageIntensityType m_eDamageIntensityType;
218 
219  [Attribute("1", desc: "If false it will be ignored")]
220  bool m_bIsEnabled;
221 
222  [Attribute(desc: "A lower order means it is checked before any with a higher order")]
223  int m_iOrder;
224 
225  [Attribute(desc: "Damage state UI info. If left null the entry will be ignored")]
226  protected ref SCR_UIName m_UiInfo;
227 
228  [Attribute(desc: "If value (generally health scaled) is equal or greater than min and smaller (or equal and smaller if 1 or 0) than max than this intensity entry is valid", params: "0 inf")]
229  protected float m_fMaxValue;
230 
231  [Attribute(desc: "If value (generally health scaled) is equal or greater than min and smaller than max than this intensity entry is valid. Generally this is damage scaled but does not need to be", params: "0 inf")]
232  protected float m_fMinValue;
233 
234  //------------------------------------------------------------------------------------------------
235  SCR_UIName GetUiInfo()
236  {
237  return m_UiInfo;
238  }
239 
240  //------------------------------------------------------------------------------------------------
241  SCR_EDamageIntensityType GetDamageIntensityType()
242  {
243  return m_eDamageIntensityType;
244  }
245 
246  //------------------------------------------------------------------------------------------------
247  bool IsValidDamageState(float value)
248  {
249  if (m_fMaxValue == 0)
250  return (value >= m_fMinValue && value <= m_fMaxValue);
251  else
252  return (value >= m_fMinValue && value < m_fMaxValue);
253  }
254 
255  //------------------------------------------------------------------------------------------------
257  {
258  if (m_fMinValue > m_fMaxValue)
259  {
260  Print("'SCR_DamageIntensityEntry': '" + typename.EnumToString(SCR_EDamageIntensityType, m_eDamageIntensityType) + "' has a min value that is greater than max value! Min value is set the same as max value", LogLevel.WARNING);
261  m_fMinValue = m_fMaxValue;
262  }
263  }
264 }
NO_DAMAGE
NO_DAMAGE
Definition: SCR_DamageIntensityHolder.c:2
SCR_EDamageIntensityType
SCR_EDamageIntensityType
Definition: SCR_DamageIntensityHolder.c:2
HitZone
Definition: HitZone.c:12
SCR_UIName
Definition: SCR_UIName.c:5
LOW
LOW
Definition: SCR_DamageIntensityHolder.c:3
SCR_BaseContainerCustomTitleEnum
class SCR_CampaignHintStorage SCR_BaseContainerCustomTitleEnum(EHint, "m_eHintId")
Definition: SCR_CampaignHintStorage.c:22
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
HIGH
HIGH
Definition: SCR_DamageIntensityHolder.c:5
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_DamageIntensityEntry
Definition: SCR_DamageIntensityHolder.c:214
MEDIUM
MEDIUM
Definition: SCR_DamageIntensityHolder.c:4
BaseContainerProps
enum SCR_EDamageIntensityType BaseContainerProps(configRoot:true)
Holds the localization strings as well as the logic to get the damage severity strings and enums.
Definition: SCR_DamageIntensityHolder.c:13
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
CRITICAL
CRITICAL
Definition: SCR_DamageIntensityHolder.c:6
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24