Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_RepairSupportStationComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/SupportStation", description: "")]
3 {
4  [Attribute(ENotification.SUPPORTSTATION_REPAIRED_BY_OTHER_DONE_NOT_FULL.ToString(), desc: "Leave UNKNOWN to not send notification when healing is done but vehicle is not full heal but not done (for players in vehicle that is being repaired)", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(ENotification), category: "Heal/Repair Support Station")]
5  protected ENotification m_eHealDoneNotFullNotificationInVehicle;
6 
7  [Attribute("SOUND_VEHICLE_EXTINGUISH_PARTIAL", desc: "Sound effect played when Extinguish is updated and not done. Broadcast to players. Leave empty if no sfx", category: "Heal/Repair Support Station")]
8  protected string m_sOnExtinguishUpdateSoundEffectEventName;
9 
10  [Attribute("SOUND_VEHICLE_EXTINGUISH_DONE", desc: "Sound effect played when Extinguish is done. Broadcast to players. Leave empty if no sfx", category: "Heal/Repair Support Station")]
11  protected string m_sOnExtinguishDoneSoundEffectEventName;
12 
13  protected ref SCR_AudioSourceConfiguration m_OnExtinguishUpdateAudioSourceConfiguration;
14  protected ref SCR_AudioSourceConfiguration m_OnExtinguishDoneAudioSourceConfiguration;
15 
16  //------------------------------------------------------------------------------------------------
18  ENotification GetHealDoneNotFullInVehicleNotification()
19  {
21  }
22 
23  //------------------------------------------------------------------------------------------------
25  SCR_AudioSourceConfiguration GetOnExtinguishUpdateAudioConfig()
26  {
27  //~ Create Audio source if it does not yet exist
30 
32  }
33 
34  //------------------------------------------------------------------------------------------------
36  SCR_AudioSourceConfiguration GetOnExtinguishDoneAudioConfig()
37  {
38  //~ Create Audio source if it does not yet exist
41 
43  }
44 }
45 
46 class SCR_RepairSupportStationComponent : SCR_BaseDamageHealSupportStationComponent
47 {
48  [Attribute("40", desc: "Only valid if m_aDoTTypesHealed includes FIRE, Each Execute the fire rate is reduced with a set amount. If fire rate is 0 it will be extinguished", category: "Heal/Repair Support Station")]
49  protected float m_fFireRateReductionEachExecute;
50 
51  [Attribute("1", desc: "Only valid if m_aDoTTypesHealed includes FIRE. The supply cost each time fire rate is reduced (no matter the reduction amount as fire rate is not replicated)", category: "Heal/Repair Support Station")]
53 
54  [Attribute("0.75", desc: "Heavy smoke (which will never lead to fire) is removed when vehicle rough health is this or higher", category: "Heal/Repair Support Station")]
56 
57  [Attribute("0.95", desc: "Light smoke (which will never lead to fire) is removed when vehicle rough health is this or higher", category: "Heal/Repair Support Station")]
59 
60  //------------------------------------------------------------------------------------------------
62  {
63  return ESupportStationType.REPAIR;
64  }
65 
66  //------------------------------------------------------------------------------------------------
67  protected override float GetDamageOrStateToHeal(IEntity actionOwner, IEntity actionUser, notnull SCR_BaseDamageHealSupportStationAction action, out EDamageType activeDoT, out notnull array<HitZone> hitZones)
68  {
69  if (!m_aDoTTypesHealed.Contains(EDamageType.FIRE))
70  return super.GetDamageOrStateToHeal(actionOwner, actionUser, action, activeDoT, hitZones);
71 
72  hitZones.Clear();
73  action.GetHitZonesToHeal(hitZones);
74 
75  float fireRateHealAmount;
76 
77  SCR_FlammableHitZone flammableHitZone;
78  foreach (HitZone hitZone : hitZones)
79  {
80  flammableHitZone = SCR_FlammableHitZone.Cast(hitZone);
81  if (!flammableHitZone)
82  continue;
83 
84  if (flammableHitZone.GetFireState() != EFireState.BURNING)// && flammableHitZone.GetFireState() != EFireState.SMOKING_IGNITING)
85  continue;
86 
87  activeDoT = EDamageType.FIRE;
88 
89  fireRateHealAmount += flammableHitZone.GetFireRate();
90 
91  if (fireRateHealAmount >= m_fFireRateReductionEachExecute)
92  return m_fFireRateReductionEachExecute;
93  }
94 
95  if (activeDoT == EDamageType.FIRE && fireRateHealAmount > 0)
96  return fireRateHealAmount;
97 
98  //~ Not on fire so return the normal logic
99  return super.GetDamageOrStateToHeal(actionOwner, actionUser, action, activeDoT, hitZones);
100  }
101 
102  //------------------------------------------------------------------------------------------------
103  protected override int GetSupplyCostAction(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action)
104  {
105  if (!AreSuppliesEnabled())
106  return 0;
107 
108  if (!m_aDoTTypesHealed.Contains(EDamageType.FIRE))
109  return super.GetSupplyCostAction(actionOwner, actionUser, action);
110 
111  EDamageType activeDoT;
112  array<HitZone> hitZones = {};
113 
114  float damageToHeal = GetDamageOrStateToHeal(actionOwner, actionUser, SCR_BaseDamageHealSupportStationAction.Cast(action), activeDoT, hitZones);
115 
116  //~ On fire so use fire supply cost
117  if (activeDoT == EDamageType.FIRE)
119 
120  //~ Not on fire so return normal supply cost action
121  return super.GetSupplyCostAction(actionOwner, actionUser, action);
122  }
123 
124  //------------------------------------------------------------------------------------------------
125  override void OnExecutedServer(notnull IEntity actionOwner, notnull IEntity actionUser, notnull SCR_BaseUseSupportStationAction action)
126  {
127  EDamageType activeDoT;
128  array<HitZone> hitZones = {};
129  float damageToHeal = GetDamageOrStateToHeal(actionOwner, actionUser, SCR_BaseDamageHealSupportStationAction.Cast(action), activeDoT, hitZones);
130 
131  if (activeDoT == EDamageType.FIRE)
132  {
133  //~ Consume supplies
134  if (AreSuppliesEnabled())
135  {
136  //~ Failed to consume supplies, meaning there weren't enough supplies for the action
137  if (!OnConsumeSuppliesServer(GetSupplyCostAction(actionOwner, actionUser, action)))
138  return;
139  }
140 
141  SCR_FlammableHitZone flammableHitZone;
142 
143  float removeFireAmount = m_fFireRateReductionEachExecute;
144  float fireRate;
145  bool stillBurning = false;
146 
147  foreach (HitZone hitZone : hitZones)
148  {
149  flammableHitZone = SCR_FlammableHitZone.Cast(hitZone);
150  if (!flammableHitZone)
151  continue;
152 
153  //~ Get fire rate of hitzone
154  fireRate = flammableHitZone.GetFireRate();
155  if (fireRate <= 0)
156  continue;
157 
158  //~ Can no longer remove fire rate this execute but the hitzones are still burning
159  if (removeFireAmount <= 0)
160  {
161  stillBurning = true;
162  break;
163  }
164 
165  if (fireRate > removeFireAmount)
166  {
167  stillBurning = true;
168  flammableHitZone.SetFireRate(fireRate - removeFireAmount);
169  break;
170  }
171  else
172  {
173  flammableHitZone.SetFireRate(0);
174  removeFireAmount -= fireRate;
175  }
176 
177  //~ Make sure it doesn't ignite again
178  if (flammableHitZone.GetFireRate() <= 0 && flammableHitZone.GetFireState() == EFireState.SMOKING_IGNITING)
179  flammableHitZone.SetFireState(EFireState.SMOKING_HEAVY);
180  }
181 
183  if (stillBurning)
184  healState = SCR_EDamageSupportStationHealState.FIRE_EXTINGUISH_UPDATE;
185  else
186  healState = SCR_EDamageSupportStationHealState.FIRE_EXTINGUISH_DONE;
187 
188  //~ Get broadcast ids
189  RplId ownerId;
190  RplId userId;
191  int playerId;
192 
193  FindEntityIds(actionOwner, actionUser, ownerId, userId, playerId);
194  OnExecuteDamageSystem(actionOwner, actionUser, healState, SCR_BaseDamageHealSupportStationAction.Cast(action), 0);
195  Rpc(OnExecuteDamageSystemBroadcast, ownerId, userId, healState, action.GetActionID(), 0);
196  return;
197  }
198 
199  //~ Execute default logics if not on fire
200  super.OnExecutedServer(actionOwner, actionUser, action);
201 
202  //~ Remove smoke states if condition met
203  RemoveSmokeFromHitZone(actionOwner, actionUser, SCR_BaseDamageHealSupportStationAction.Cast(action), hitZones);
204  }
205 
206  //------------------------------------------------------------------------------------------------
207  protected override void OnExecuteDamageSystem(IEntity actionOwner, IEntity actionUser, SCR_EDamageSupportStationHealState healState, SCR_BaseDamageHealSupportStationAction action, float healthScaled)
208  {
209  if (!actionOwner)
210  {
211  //~ Action was still succesfully executed
212  OnSuccessfullyExecuted(actionOwner, actionUser, action);
213  return;
214  }
215 
216  bool isFireStateHealed = false;
217 
218  //~ Play sound effect
220  if (classData)
221  {
222  switch (healState)
223  {
224  case SCR_EDamageSupportStationHealState.FIRE_EXTINGUISH_UPDATE :
225  {
226  PlaySoundEffect(classData.GetOnExtinguishUpdateAudioConfig(), actionOwner, action);
227  isFireStateHealed = true;
228  break;
229  }
230  case SCR_EDamageSupportStationHealState.FIRE_EXTINGUISH_DONE :
231  {
232  PlaySoundEffect(classData.GetOnExtinguishDoneAudioConfig(), actionOwner, action);
233  isFireStateHealed = true;
234  break;
235  }
236  }
237  }
238 
239  //~ Fire state not healed, use default logic
240  if (!isFireStateHealed)
241  {
242  super.OnExecuteDamageSystem(actionOwner, actionUser, healState, action, healthScaled);
243  return;
244  }
245 
246  //~ On succesfully executed
247  OnSuccessfullyExecuted(actionOwner, actionUser, action);
248 
249  //~ Do not send notification
251  return;
252 
253  SendDamageSupportStationNotification(actionOwner, actionUser, action, healState, healthScaled);
254  }
255 
256  //------------------------------------------------------------------------------------------------
257  protected override void SendDamageSupportStationNotification(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action, SCR_EDamageSupportStationHealState healState, float healthScaled)
258  {
259  //~ Editable entity not found
260  SCR_EditableEntityComponent userEditableEntity = SCR_EditableEntityComponent.Cast(actionUser.FindComponent(SCR_EditableEntityComponent));
261  if (!userEditableEntity)
262  return;
263 
264  ENotification inVehicleNotification = ENotification.UNKNOWN;
265  bool usePercentage;
266 
267  //~ Get correct notitfication
268  switch (healState)
269  {
270  case SCR_EDamageSupportStationHealState.HEAL_UPDATE :
271  {
272  inVehicleNotification = ENotification.SUPPORTSTATION_REPAIRED_BY_OTHER_UPDATE;
273  break;
274  }
275  case SCR_EDamageSupportStationHealState.HEAL_DONE_NOT_FULL_HEAL :
276  {
278  if (!classData)
279  return;
280 
281  inVehicleNotification = classData.GetHealDoneNotFullInVehicleNotification();
282  break;
283  }
284  case SCR_EDamageSupportStationHealState.HEAL_DONE :
285  {
286  inVehicleNotification = ENotification.SUPPORTSTATION_REPAIRED_BY_OTHER_DONE;
287  break;
288  }
289  case SCR_EDamageSupportStationHealState.FIRE_EXTINGUISH_UPDATE :
290  {
291  inVehicleNotification = ENotification.SUPPORTSTATION_FIRE_EXTINGUISHED_VEHICLE_BY_OTHER_UPDATE;
292  break;
293  }
294  case SCR_EDamageSupportStationHealState.FIRE_EXTINGUISH_DONE :
295  {
296  inVehicleNotification = ENotification.SUPPORTSTATION_FIRE_EXTINGUISHED_VEHICLE_BY_OTHER_DONE;
297  break;
298  }
299  }
300 
301  //~ No in vehicle notification
302  if (inVehicleNotification == ENotification.UNKNOWN)
303  return;
304 
305  RplId userRplId = Replication.FindId(userEditableEntity);
306 
307  //~ Get players in vehicle
308  array<int> playersInVehicle = {};
309  GetPlayerIdsInVehicle(actionOwner, playersInVehicle);
310 
311  if (!playersInVehicle.Contains(SCR_PlayerController.GetLocalPlayerId()))
312  return;
313 
314  EVehicleHitZoneGroup notificationHitZoneGroup = EVehicleHitZoneGroup.VIRTUAL;
315  if (healState != ENotification.SUPPORTSTATION_FIRE_EXTINGUISHED_VEHICLE_BY_OTHER_UPDATE && healState != ENotification.SUPPORTSTATION_FIRE_EXTINGUISHED_VEHICLE_BY_OTHER_DONE)
316  {
318  if (repairAction)
319  {
320  array<EVehicleHitZoneGroup> hitZoneGroup = {};
321  repairAction.GetHitZoneGroups(hitZoneGroup);
322 
323  if (!hitZoneGroup.IsEmpty())
324  notificationHitZoneGroup = hitZoneGroup[0];
325  }
326  }
327 
328  //~ Send in vehicle notification if player is in vehicle
329  SCR_NotificationsComponent.SendLocal(inVehicleNotification, userRplId, notificationHitZoneGroup, healthScaled * 1000);
330  }
331 
332  //------------------------------------------------------------------------------------------------
333  //~ Removes the smoke state depending on the roughHeal m_fMaxHealScaled
334  protected void RemoveSmokeFromHitZone(notnull IEntity actionOwner, notnull IEntity actionUser, SCR_BaseDamageHealSupportStationAction action, notnull array<HitZone> hitZones)
335  {
336  bool allHitZonesMaxHealth;
337  float healthPercentage;
338 
339  //~ Get the current percentage of healing and if all hitZones are healed to the max
340  SCR_SupportStationManagerComponent.GetCombinedHitZonesStateForDamageSupportStation(action.GetActionDamageManager(), hitZones, GetMaxHealScaled(), healthPercentage, allHitZonesMaxHealth);
341  SCR_FlammableHitZone flammableHitZone;
342  EFireState fireState;
343 
344  foreach (HitZone hitZone : hitZones)
345  {
346  flammableHitZone = SCR_FlammableHitZone.Cast(hitZone);
347  if (!flammableHitZone)
348  continue;
349 
350  fireState = flammableHitZone.GetFireState();
351 
352  if (healthPercentage >= m_fLightSmokeRemoveHealthPercentage && (fireState == EFireState.SMOKING_LIGHT || fireState == EFireState.SMOKING_HEAVY || fireState == EFireState.SMOKING_IGNITING))
353  flammableHitZone.SetFireState(EFireState.NONE);
354  else if (healthPercentage >= m_fHeavySmokeRemoveHealthPercentage && (fireState == EFireState.SMOKING_HEAVY || fireState == EFireState.SMOKING_IGNITING))
355  flammableHitZone.SetFireState(EFireState.SMOKING_LIGHT);
356  else if (fireState == EFireState.SMOKING_IGNITING)
357  flammableHitZone.SetFireState(EFireState.SMOKING_HEAVY);
358  }
359  }
360 }
361 
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
GetSupportStationType
override ESupportStationType GetSupportStationType()
Definition: SCR_RepairSupportStationComponent.c:61
SendDamageSupportStationNotification
protected override void SendDamageSupportStationNotification(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action, SCR_EDamageSupportStationHealState healState, float healthScaled)
Definition: SCR_RepairSupportStationComponent.c:257
SCR_PlayerController
Definition: SCR_PlayerController.c:31
m_iBaseSupplyCostOnUse
protected int m_iBaseSupplyCostOnUse
Definition: SCR_BaseSupportStationComponent.c:100
m_iSupplyCostPerFireRateReduction
protected float m_iSupplyCostPerFireRateReduction
Definition: SCR_RepairSupportStationComponent.c:52
m_OnExtinguishDoneAudioSourceConfiguration
protected ref SCR_AudioSourceConfiguration m_OnExtinguishDoneAudioSourceConfiguration
Definition: SCR_RepairSupportStationComponent.c:12
FindEntityIds
protected void FindEntityIds(IEntity owner, IEntity user, out RplId ownerId, out RplId userId, out int playerId)
Definition: SCR_BaseSupportStationComponent.c:148
HitZone
Definition: HitZone.c:12
m_sOnExtinguishDoneSoundEffectEventName
protected string m_sOnExtinguishDoneSoundEffectEventName
Definition: SCR_RepairSupportStationComponent.c:9
OnExecuteDamageSystem
protected override void OnExecuteDamageSystem(IEntity actionOwner, IEntity actionUser, SCR_EDamageSupportStationHealState healState, SCR_BaseDamageHealSupportStationAction action, float healthScaled)
Definition: SCR_RepairSupportStationComponent.c:207
m_sOnExtinguishUpdateSoundEffectEventName
protected string m_sOnExtinguishUpdateSoundEffectEventName
Definition: SCR_RepairSupportStationComponent.c:6
m_OnExtinguishUpdateAudioSourceConfiguration
protected ref SCR_AudioSourceConfiguration m_OnExtinguishUpdateAudioSourceConfiguration
Definition: SCR_RepairSupportStationComponent.c:11
OnSuccessfullyExecuted
protected void OnSuccessfullyExecuted(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action)
Definition: SCR_BaseSupportStationComponent.c:214
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
PlaySoundEffect
protected void PlaySoundEffect(SCR_AudioSourceConfiguration audioConfig, notnull IEntity soundOwner, SCR_BaseUseSupportStationAction action)
Definition: SCR_BaseSupportStationComponent.c:222
ENotification
ENotification
Definition: ENotification.c:4
SCR_SupportStationManagerComponent
Definition: SCR_SupportStationManagerComponent.c:10
OnExecutedServer
override void OnExecutedServer(notnull IEntity actionOwner, notnull IEntity actionUser, notnull SCR_BaseUseSupportStationAction action)
Definition: SCR_RepairSupportStationComponent.c:125
GetSendNotificationOnUse
bool GetSendNotificationOnUse()
Definition: SCR_BaseSupportStationComponent.c:28
OnConsumeSuppliesServer
protected bool OnConsumeSuppliesServer(int amount)
Definition: SCR_BaseSupportStationComponent.c:630
ESupportStationType
ESupportStationType
Definition: ESupportStationType.c:2
m_fLightSmokeRemoveHealthPercentage
protected float m_fLightSmokeRemoveHealthPercentage
Definition: SCR_RepairSupportStationComponent.c:58
OnExecuteDamageSystemBroadcast
protected void OnExecuteDamageSystemBroadcast(RplId ownerId, RplId userId, SCR_EDamageSupportStationHealState healState, int actionId, float healthScaled)
Definition: SCR_BaseDamageHealSupportStationComponent.c:288
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
m_eHealDoneNotFullNotificationInVehicle
protected ENotification m_eHealDoneNotFullNotificationInVehicle
Definition: SCR_RepairSupportStationComponent.c:3
Attribute
SCR_RepairSupportStationComponentClass SCR_BaseDamageHealSupportStationComponentClass Attribute("40", desc:"Only valid if m_aDoTTypesHealed includes FIRE, Each Execute the fire rate is reduced with a set amount. If fire rate is 0 it will be extinguished", category:"Heal/Repair Support Station")] protected float m_fFireRateReductionEachExecute
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
m_fHeavySmokeRemoveHealthPercentage
protected float m_fHeavySmokeRemoveHealthPercentage
Definition: SCR_RepairSupportStationComponent.c:55
GetPlayerIdsInVehicle
protected void GetPlayerIdsInVehicle(IEntity vehicle, out notnull array< int > playerIds)
Definition: SCR_BaseSupportStationComponent.c:743
EFireState
EFireState
Definition: SCR_FlammableHitZone.c:1
GetSupplyCostAction
protected override int GetSupplyCostAction(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action)
Definition: SCR_RepairSupportStationComponent.c:103
SCR_BaseDamageHealSupportStationAction
Allows healing of action owner (not user)
Definition: SCR_BaseDamageHealSupportStationAction.c:2
EDamageType
EDamageType
Definition: EDamageType.c:12
SCR_BaseDamageHealSupportStationComponentClass
Definition: SCR_BaseDamageHealSupportStationComponent.c:2
EVehicleHitZoneGroup
EVehicleHitZoneGroup
Definition: SCR_VehicleDamageManagerComponent.c:1
SCR_RepairSupportStationComponentClass
Definition: SCR_RepairSupportStationComponent.c:2
AreSuppliesEnabled
bool AreSuppliesEnabled()
Definition: SCR_BaseSupportStationComponent.c:644
SCR_EDamageSupportStationHealState
SCR_EDamageSupportStationHealState
Definition: SCR_BaseDamageHealSupportStationComponent.c:366
RemoveSmokeFromHitZone
protected void RemoveSmokeFromHitZone(notnull IEntity actionOwner, notnull IEntity actionUser, SCR_BaseDamageHealSupportStationAction action, notnull array< HitZone > hitZones)
Definition: SCR_RepairSupportStationComponent.c:334
SCR_BaseUseSupportStationAction
Definition: SCR_BaseUseSupportStationAction.c:1
CreateSoundAudioConfig
SCR_AudioSourceConfiguration CreateSoundAudioConfig(string soundEventName)
Definition: SCR_BaseDamageHealSupportStationComponent.c:16
SCR_RepairAtSupportStationAction
Definition: SCR_RepairAtSupportStationAction.c:1
GetDamageOrStateToHeal
protected override float GetDamageOrStateToHeal(IEntity actionOwner, IEntity actionUser, notnull SCR_BaseDamageHealSupportStationAction action, out EDamageType activeDoT, out notnull array< HitZone > hitZones)
Definition: SCR_RepairSupportStationComponent.c:67
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180