Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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")]
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")]
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")]
13 [Attribute(defvalue: "0", desc: "Amount of unflipping force that this support station provides when a player tries to unflip a vehicle near it", params: "0 inf 0.01")]
14 protected float m_fUnflippingPower;
15
16 protected ref SCR_AudioSourceConfiguration m_OnExtinguishUpdateAudioSourceConfiguration;
17 protected ref SCR_AudioSourceConfiguration m_OnExtinguishDoneAudioSourceConfiguration;
18
19 //------------------------------------------------------------------------------------------------
25
26 //------------------------------------------------------------------------------------------------
36
37 //------------------------------------------------------------------------------------------------
39 SCR_AudioSourceConfiguration GetOnExtinguishDoneAudioConfig()
40 {
41 //~ Create Audio source if it does not yet exist
44
46 }
47
48 //------------------------------------------------------------------------------------------------
50 {
51 return m_fUnflippingPower;
52 }
53}
54
55class SCR_RepairSupportStationComponent : SCR_BaseDamageHealSupportStationComponent
56{
57 [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")]
58 protected float m_fFireRateReductionEachExecute;
59
60 [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")]
62
63 protected static ref ScriptInvokerEntity s_OnFireExtinguished;
64
65 //------------------------------------------------------------------------------------------------
67 {
68 return ESupportStationType.REPAIR;
69 }
70
71 //------------------------------------------------------------------------------------------------
72 float GetUnflippingPower()
73 {
74 SCR_RepairSupportStationComponentClass data = SCR_RepairSupportStationComponentClass.Cast(GetComponentData(GetOwner()));
75 if (data)
76 return data.GetUnflippingPower();
77
78 return 0;
79 }
80
81 //------------------------------------------------------------------------------------------------
82 protected override float GetDamageOrStateToHeal(IEntity actionOwner, IEntity actionUser, notnull SCR_BaseDamageHealSupportStationAction action, out EDamageType activeDoT, out notnull array<HitZone> hitZones)
83 {
84 if (!m_aDoTTypesHealed.Contains(EDamageType.FIRE))
85 return super.GetDamageOrStateToHeal(actionOwner, actionUser, action, activeDoT, hitZones);
86
87 hitZones.Clear();
88 action.GetHitZonesToHeal(hitZones);
89 SCR_DamageManagerComponent dmgManager = action.GetActionDamageManager();
90 if (!dmgManager)
91 return 0;
92
93 float fireRateHealAmount;
94
95 SCR_FlammableHitZone flammableHitZone;
96 foreach (HitZone hitZone : hitZones)
97 {
98 flammableHitZone = SCR_FlammableHitZone.Cast(hitZone);
99 if (!flammableHitZone)
100 continue;
101
102 if (!dmgManager.IsOnFire(flammableHitZone))
103 continue;
104
105 activeDoT = EDamageType.FIRE;
106
107 fireRateHealAmount += Math.Max(1, flammableHitZone.GetFireRate());
108
109 if (fireRateHealAmount >= m_fFireRateReductionEachExecute)
110 return m_fFireRateReductionEachExecute;
111 }
112
113 if (activeDoT == EDamageType.FIRE && fireRateHealAmount > 0)
114 return fireRateHealAmount;
115
116 //~ Not on fire so return the normal logic
117 return super.GetDamageOrStateToHeal(actionOwner, actionUser, action, activeDoT, hitZones);
118 }
119
120 //------------------------------------------------------------------------------------------------
121 protected override int GetSupplyAmountAction(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action)
122 {
123 if (!AreSuppliesEnabled())
124 return 0;
125
126 if (!m_aDoTTypesHealed.Contains(EDamageType.FIRE))
127 return super.GetSupplyAmountAction(actionOwner, actionUser, action);
128
129 EDamageType activeDoT;
130 array<HitZone> hitZones = {};
131
132 float damageToHeal = GetDamageOrStateToHeal(actionOwner, actionUser, SCR_BaseDamageHealSupportStationAction.Cast(action), activeDoT, hitZones);
133
134 //~ On fire so use fire supply cost
135 if (activeDoT == EDamageType.FIRE)
137
138 //~ Not on fire so return normal supply cost action
139 return super.GetSupplyAmountAction(actionOwner, actionUser, action);
140 }
141
142 //------------------------------------------------------------------------------------------------
143 override void OnExecutedServer(notnull IEntity actionOwner, notnull IEntity actionUser, notnull SCR_BaseUseSupportStationAction action)
144 {
145 EDamageType activeDoT;
146 array<HitZone> hitZones = {};
147 float damageToHeal = GetDamageOrStateToHeal(actionOwner, actionUser, SCR_BaseDamageHealSupportStationAction.Cast(action), activeDoT, hitZones);
148
149 if (activeDoT == EDamageType.FIRE)
150 {
151 //~ Consume supplies
152 if (AreSuppliesEnabled())
153 {
154 //~ Failed to consume supplies, meaning there weren't enough supplies for the action
155 if (!OnConsumeSuppliesServer(GetSupplyAmountAction(actionOwner, actionUser, action)))
156 return;
157 }
158
159 SCR_FlammableHitZone flammableHitZone;
160
161 float removeFireAmount = m_fFireRateReductionEachExecute;
162 float fireRate;
163 bool stillBurning = false;
164
165 foreach (HitZone hitZone : hitZones)
166 {
167 flammableHitZone = SCR_FlammableHitZone.Cast(hitZone);
168 if (!flammableHitZone)
169 continue;
170
171 //~ Get fire rate of hitzone
172 fireRate = flammableHitZone.GetFireRate();
173 if (fireRate <= 0)
174 continue;
175
176 //~ Can no longer remove fire rate this execute but the hitzones are still burning
177 if (removeFireAmount <= 0)
178 {
179 stillBurning = true;
180 break;
181 }
182
183 if (fireRate > removeFireAmount)
184 {
185 stillBurning = true;
186 flammableHitZone.SetFireRate(fireRate - removeFireAmount);
187 break;
188 }
189 else
190 {
191 flammableHitZone.SetFireRate(0);
192 removeFireAmount -= fireRate;
193 }
194
195 //~ Make sure it doesn't ignite again
196 if (flammableHitZone.GetFireRate() <= 0 && flammableHitZone.GetFireState() == SCR_EBurningState.SMOKING_IGNITING)
197 flammableHitZone.SetFireState(SCR_EBurningState.SMOKING_HEAVY);
198 }
199
201 if (stillBurning)
202 healState = SCR_EDamageSupportStationHealState.FIRE_EXTINGUISH_UPDATE;
203 else
204 healState = SCR_EDamageSupportStationHealState.FIRE_EXTINGUISH_DONE;
205
206 //~ Get broadcast ids
207 RplId ownerId;
208 RplId userId;
209 int playerId;
210
211 FindEntityIds(actionOwner, actionUser, ownerId, userId, playerId);
212 OnExecuteDamageSystem(actionOwner, actionUser, healState, SCR_BaseDamageHealSupportStationAction.Cast(action), 0);
213 Rpc(OnExecuteDamageSystemBroadcast, ownerId, userId, healState, action.GetActionID(), 0);
214 return;
215 }
216
217 //~ Execute default logics if not on fire
218 super.OnExecutedServer(actionOwner, actionUser, action);
219 }
220
221 //------------------------------------------------------------------------------------------------
222 protected override void OnExecuteDamageSystem(IEntity actionOwner, IEntity actionUser, SCR_EDamageSupportStationHealState healState, SCR_BaseDamageHealSupportStationAction action, float healthScaled)
223 {
224 if (!actionOwner)
225 {
226 //~ Action was still succesfully executed
227 OnSuccessfullyExecuted(actionOwner, actionUser, action);
228 return;
229 }
230
231 bool isFireStateHealed = false;
232
233 //~ Play sound effect
235 if (classData)
236 {
237 switch (healState)
238 {
239 case SCR_EDamageSupportStationHealState.FIRE_EXTINGUISH_UPDATE :
240 {
241 PlaySoundEffect(classData.GetOnExtinguishUpdateAudioConfig(), actionOwner, action);
242 isFireStateHealed = true;
243 break;
244 }
245 case SCR_EDamageSupportStationHealState.FIRE_EXTINGUISH_DONE :
246 {
247 PlaySoundEffect(classData.GetOnExtinguishDoneAudioConfig(), actionOwner, action);
248 isFireStateHealed = true;
249 if (s_OnFireExtinguished)
250 s_OnFireExtinguished.Invoke(actionUser);
251 break;
252 }
253 }
254 }
255
256 //~ Fire state not healed, use default logic
257 if (!isFireStateHealed)
258 {
259 super.OnExecuteDamageSystem(actionOwner, actionUser, healState, action, healthScaled);
260 return;
261 }
262
263 //~ On succesfully executed
264 OnSuccessfullyExecuted(actionOwner, actionUser, action);
265
266 //~ Do not send notification
268 return;
269
270 SendDamageSupportStationNotification(actionOwner, actionUser, action, healState, healthScaled);
271 }
272
273 //------------------------------------------------------------------------------------------------
274 protected override void SendDamageSupportStationNotification(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action, SCR_EDamageSupportStationHealState healState, float healthScaled)
275 {
276 //~ Editable entity not found
278 if (!userEditableEntity)
279 return;
280
281 ENotification inVehicleNotification = ENotification.UNKNOWN;
282
283 //~ Get correct notitfication
284 switch (healState)
285 {
286 case SCR_EDamageSupportStationHealState.HEAL_UPDATE :
287 {
288 inVehicleNotification = ENotification.SUPPORTSTATION_REPAIRED_BY_OTHER_UPDATE;
289 break;
290 }
291 case SCR_EDamageSupportStationHealState.HEAL_DONE_NOT_FULL_HEAL :
292 {
294 if (!classData)
295 return;
296
297 inVehicleNotification = classData.GetHealDoneNotFullInVehicleNotification();
298 break;
299 }
301 {
302 inVehicleNotification = ENotification.SUPPORTSTATION_REPAIRED_BY_OTHER_DONE;
303 break;
304 }
305 case SCR_EDamageSupportStationHealState.FIRE_EXTINGUISH_UPDATE :
306 {
307 inVehicleNotification = ENotification.SUPPORTSTATION_FIRE_EXTINGUISHED_VEHICLE_BY_OTHER_UPDATE;
308 break;
309 }
310 case SCR_EDamageSupportStationHealState.FIRE_EXTINGUISH_DONE :
311 {
312 inVehicleNotification = ENotification.SUPPORTSTATION_FIRE_EXTINGUISHED_VEHICLE_BY_OTHER_DONE;
313 break;
314 }
315 }
316
317 //~ No in vehicle notification
318 if (inVehicleNotification == ENotification.UNKNOWN)
319 return;
320
321 RplId userRplId = Replication.FindItemId(userEditableEntity);
322
323 //~ Get players in vehicle
324 array<int> playersInVehicle = {};
325 GetPlayerIdsInVehicle(actionOwner, playersInVehicle);
326
327 if (!playersInVehicle.Contains(SCR_PlayerController.GetLocalPlayerId()))
328 return;
329
330 EVehicleHitZoneGroup notificationHitZoneGroup = EVehicleHitZoneGroup.VIRTUAL;
331 if (healState != ENotification.SUPPORTSTATION_FIRE_EXTINGUISHED_VEHICLE_BY_OTHER_UPDATE && healState != ENotification.SUPPORTSTATION_FIRE_EXTINGUISHED_VEHICLE_BY_OTHER_DONE)
332 {
334 if (repairAction)
335 {
336 array<EVehicleHitZoneGroup> hitZoneGroup = {};
337 repairAction.GetHitZoneGroups(hitZoneGroup);
338
339 if (!hitZoneGroup.IsEmpty())
340 notificationHitZoneGroup = hitZoneGroup[0];
341 }
342 }
343
344 //~ Send in vehicle notification if player is in vehicle
345 SCR_NotificationsComponent.SendLocal(inVehicleNotification, userRplId, notificationHitZoneGroup, healthScaled * 1000);
346 }
347
348 //------------------------------------------------------------------------------------------------
352 static ScriptInvokerEntity GetOnFireExtinguished()
353 {
354 if (!s_OnFireExtinguished)
355 s_OnFireExtinguished = new ScriptInvokerEntity();
356
357 return s_OnFireExtinguished;
358 }
359}
360
ENotification
ESupportStationType
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
override int GetSupplyAmountAction(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action)
float GetDamageOrStateToHeal(IEntity actionOwner, IEntity actionUser, notnull SCR_BaseDamageHealSupportStationAction action, out EDamageType activeDoT, out notnull array< HitZone > hitZones)
void OnExecuteDamageSystemBroadcast(RplId ownerId, RplId userId, SCR_EDamageSupportStationHealState healState, int actionId, float healthScaled)
void OnExecuteDamageSystem(IEntity actionOwner, IEntity actionUser, SCR_EDamageSupportStationHealState healState, SCR_BaseDamageHealSupportStationAction action, float healthScaled)
void SendDamageSupportStationNotification(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action, SCR_EDamageSupportStationHealState healState, float healthScaled)
override void OnExecutedServer(notnull IEntity actionOwner, notnull IEntity actionUser, notnull SCR_BaseUseSupportStationAction action)
bool GetSendNotificationOnUse()
void GetPlayerIdsInVehicle(IEntity vehicle, out notnull array< int > playerIds)
ESupportStationType GetSupportStationType()
bool OnConsumeSuppliesServer(int amount)
void FindEntityIds(IEntity owner, IEntity user, out RplId ownerId, out RplId userId, out int playerId)
void OnSuccessfullyExecuted(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action)
void PlaySoundEffect(SCR_AudioSourceConfiguration audioConfig, notnull IEntity soundOwner, SCR_BaseUseSupportStationAction action)
SCR_CharacterSoundComponentClass GetComponentData()
Get all prefabs that have the spawner data
SCR_EBurningState
ref SCR_AudioSourceConfiguration m_OnExtinguishDoneAudioSourceConfiguration
float m_iSupplyCostPerFireRateReduction
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
ScriptInvokerBase< ScriptInvokerEntityMethod > ScriptInvokerEntity
proto external Managed FindComponent(typename typeName)
Definition Math.c:13
Main replication API.
Definition Replication.c:14
Replication item identifier.
Definition RplId.c:14
SCR_AudioSourceConfiguration CreateSoundAudioConfig(string soundEventName)
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
int GetHitZoneGroups(out notnull array< EVehicleHitZoneGroup > hitZoneGroup)
SCR_AudioSourceConfiguration GetOnExtinguishDoneAudioConfig()
ref SCR_AudioSourceConfiguration m_OnExtinguishDoneAudioSourceConfiguration
SCR_AudioSourceConfiguration GetOnExtinguishUpdateAudioConfig()
ref SCR_AudioSourceConfiguration m_OnExtinguishUpdateAudioSourceConfiguration
IEntity GetOwner()
Owner entity of the fuel tank.
SCR_FieldOfViewSettings Attribute
EDamageType
Definition EDamageType.c:13