Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_FlammableHitZone.c
Go to the documentation of this file.
1 enum EFireState // Rename to SCR_EBurningState - we have conflict with gamecode
2 {
3  NONE,
8 }
9 
10 class SCR_FlammableHitZone : SCR_VehicleHitZone
11 {
12  protected static const float FIRE_TERRAIN_HEIGHT_TOLERANCE = 2.2; // Prevents spawning of ground fire effect if the vehicle is too high (in meters)
13  protected static const float LIGHT_EMISSIVITY_START = 5;
14 
17  protected float m_fFireRate;
18  protected float m_fLightSmokeReductionRate;
19  protected float m_fHeavySmokeReductionRate;
20  protected float m_fIgnitingSmokeStokeRate;
21  protected float m_fFireDamageRateMin;
22  protected float m_fFireDamageRateMax;
23  protected float m_fUpdateFireTime;
24  protected bool m_bIsUpdatingFire;
25  protected bool m_bIsFireRateLocked;
26 
27  protected ref array<LightEntity> m_aLightEntities;
28 
29  [Attribute("", desc: "Data for flame lighting that is visible when vehicle burns", UIWidgets.Object, "", category: "Flammability")]
30  protected ref array<ref SCR_BaseLightData> m_aLightData;
31 
32  // Burning configuration - amount of damage, burning rates etc.
33  [Attribute(defvalue: "1", desc: "Fire damage multiplier\n[x * 100%]", params: "0 1000 0.01", category: "Flammability")]
34  protected float m_fFireMultiplier;
35 
36  [Attribute(defvalue: "0", desc: "Fire damage applied to occupants of a burning vehicle each second (hp)", params: "0 100 0.01", category: "Flammability")]
37  protected float m_fIncendiaryReduction;
38 
39  [Attribute(defvalue: "0", desc: "Minimum incendiary damage\n[hp]", params: "0 100 0.01", category: "Flammability")]
40  protected float m_fIncendiaryThreshold;
41 
42  [Attribute(defvalue: "8", desc: "Fire damage applied to occupants of a burning vehicle each second\n[hp]", params: "0 100 0.01", category: "Flammability")]
43  protected float m_fFireDamageOccupants;
44 
45  [Attribute(defvalue: "600", desc: "Maximum time for light smoke to stop\n[s]", params: "0 10000 0.1", category: "Flammability")]
46  protected float m_fLightSmokeStopTime;
47 
48  [Attribute(defvalue: "1800", desc: "Maximum time for heavy smoke to become light smoke\n[s]", params: "0 10000 0.1", category: "Flammability")]
49  protected float m_fHeavySmokeStopTime;
50 
51  [Attribute(defvalue: "180", desc: "Maximum time for igniting smoke to become fire\n[s]", params: "0 10000 0.1", category: "Flammability")]
52  protected float m_fIgnitingSmokeStokeTime;
53 
54  [Attribute(defvalue: "60", desc: "Minimum time for burning hitzone down\nDetermines maximum fire rate\n[s]", params: "0 10000 0.1", category: "Flammability")]
55  protected float m_fMinFireBurningTime;
56 
57  [Attribute(defvalue: "240", desc: "Maximum time for burning hitzone down\nDetermines minimum fire rate\n[s]", params: "0 10000 0.1", category: "Flammability")]
58  protected float m_fMaxFireBurningTime;
59 
60  [Attribute(defvalue: "120", desc: "Burning time of the object after destruction\n[s]", params: "0 1000 1", category: "Effects")]
61  protected float m_fBurningTime;
62 
63  [Attribute(defvalue: "0.1", uiwidget: UIWidgets.Slider, desc: "Light smoke effect threshold\n[x * minimum fire rate]", params: "0 1 0.01", category: "Flammability")]
64  protected float m_fLightSmokeThreshold;
65 
66  [Attribute(defvalue: "0.5", uiwidget: UIWidgets.Slider, desc: "Heavy smoke effect threshold\n[x * minimum fire rate]", params: "0 1 0.01", category: "Flammability")]
67  protected float m_fHeavySmokeThreshold;
68 
69  [Attribute(defvalue: "0.8", uiwidget: UIWidgets.Slider, desc: "Igniting smoke effect threshold\n[x * minimum fire rate]", params: "0 1 0.01", category: "Flammability")]
70  protected float m_fIgnitingSmokeThreshold;
71 
72  // Particle effects
73  [Attribute(desc: "Particle effect for light smoke", params: "ptc", category: "Effects")]
74  protected ResourceName m_sDamagedParticle;
75 
76  [Attribute(desc: "Particle effect for heavy smoke", params: "ptc", category: "Effects")]
77  protected ResourceName m_sDamagedParticleHeavy;
78 
79  [Attribute(desc: "Particle effect for fire", params: "ptc", category: "Effects")]
80  protected ResourceName m_sBurningParticle;
81 
82  [Attribute(desc: "Particle effect for fire on ground under object after the wreck stops moving", params: "ptc", category: "Effects")]
83  protected ResourceName m_sBurningGroundParticle;
84 
85  [Attribute(defvalue: "1", desc: "Minimum water depth to stop the fire\n[m]", params: "0 100 0.1", category: "Flammability")]
86  protected float m_fWaterDepthThreshold;
87 
88  [Attribute(defvalue: "FireState", desc: "Fire state signal name", category: "Flammability")]
89  protected string m_sFireStateSignal;
90 
91  // Audio features
92  protected SignalsManagerComponent m_SignalsManager;
93  protected int m_iFireStateSignalIdx = -1; // Damage particles
94 
95  // Fire particles
96  protected ParticleEffectEntity m_DamagedParticleLight; // Lighter damage particle emitter
97  protected ParticleEffectEntity m_DamagedParticleHeavy; // Darker damage particle emitter
98  protected ParticleEffectEntity m_BurningParticle; // Rapid fire damage particle emitter
99  protected ParticleEffectEntity m_BurningGroundParticle; // Burning fuel on ground particle
100 
101  //------------------------------------------------------------------------------------------------
102  override void OnInit(IEntity pOwnerEntity, GenericComponent pManagerComponent)
103  {
104  super.OnInit(pOwnerEntity, pManagerComponent);
105 
106  InitFireRates();
107 
109  if (damageManager)
110  damageManager.RegisterFlammableHitZone(this);
111 
112  m_SignalsManager = SignalsManagerComponent.Cast(pOwnerEntity.FindComponent(SignalsManagerComponent));
113  if (m_SignalsManager && !m_sFireStateSignal.IsEmpty())
115  }
116 
117  //------------------------------------------------------------------------------------------------
118  override EHitZoneGroup GetHitZoneGroup()
119  {
120  return m_eHitZoneGroup;
121  }
122 
123  //------------------------------------------------------------------------------------------------
124  override void OnMaxHealthChanged()
125  {
126  super.OnMaxHealthChanged();
127 
128  InitFireRates();
129 
130  if (GetGame().GetWorld())
131  UpdateFireRate(true);
132  }
133 
134  //------------------------------------------------------------------------------------------------
137  {
138  float maxDamage = GetMaxHealth();
139 
140  if (m_fFireMultiplier <= 0)
141  return;
142 
143  if (m_fMinFireBurningTime > 0)
144  m_fFireDamageRateMax = maxDamage / (m_fMinFireBurningTime * m_fFireMultiplier);
145 
146  if (m_fMaxFireBurningTime > 0)
147  m_fFireDamageRateMin = maxDamage / (m_fMaxFireBurningTime * m_fFireMultiplier);
148 
149  if (m_fLightSmokeStopTime > 0)
150  m_fLightSmokeReductionRate = m_fFireDamageRateMin * (m_fHeavySmokeThreshold - m_fLightSmokeThreshold) / m_fLightSmokeStopTime;
151 
152  if (m_fHeavySmokeStopTime > 0)
153  m_fHeavySmokeReductionRate = m_fFireDamageRateMin * (m_fIgnitingSmokeThreshold - m_fHeavySmokeThreshold) / m_fHeavySmokeStopTime;
154 
155  if (m_fIgnitingSmokeStokeTime > 0)
156  m_fIgnitingSmokeStokeRate = m_fFireDamageRateMin * (1 - m_fIgnitingSmokeThreshold) / m_fIgnitingSmokeStokeTime;
157  }
158 
159  //------------------------------------------------------------------------------------------------
175  override float ComputeEffectiveDamage(notnull BaseDamageContext damageContext, bool isDOT)
176  {
177  // Incendiary damage has different thresholds
178  if (damageContext.damageType == EDamageType.INCENDIARY && !isDOT)
179  {
180  ComputeIncendiaryDamage(damageContext.damageValue, damageContext.instigator);
181  return 0;
182  }
183 
184  float damage = damageContext.damageValue;
185  if (damageContext.damageType == EDamageType.FIRE)
186  damage *= m_fFireMultiplier;
187 
188  BaseDamageContext hack = BaseDamageContext.Cast(damageContext.Clone());
189  hack.damageValue = damage;
190 
191  return super.ComputeEffectiveDamage(hack, isDOT);
192  }
193 
194  //------------------------------------------------------------------------------------------------
200  void ComputeIncendiaryDamage(float rawDamage, notnull Instigator instigator)
201  {
202  //apply base multiplier
203  float incendiaryDamage = rawDamage * GetBaseDamageMultiplier();
204  //apply damage multiplier for this specific damage type
205  incendiaryDamage *= GetDamageMultiplier(EDamageType.INCENDIARY);
206 
207  //Extinguishing does not receive reduction or thresholds
208  if (incendiaryDamage > 0)
209  {
210  //apply flat damage reduction
211  incendiaryDamage -= m_fIncendiaryReduction;
212 
213  //if its less than the damage threshold we discard the damage.
214  //if the damage to take becomes negative (healing) because of the flat damage reduction, this should reset it back to 0 dmg to take.
215  if (incendiaryDamage < m_fIncendiaryThreshold)
216  incendiaryDamage = 0;
217  }
218 
219  // Ignore insignificant incendiary rate change
220  float newFireRate = Math.Clamp(m_fFireRate + incendiaryDamage, 0, m_fFireDamageRateMax);
221  if (float.AlmostEqual(newFireRate, m_fFireRate))
222  return;
223 
224  SetFireRate(newFireRate);
225 
226  // Last shot that sets the vehicle on fire is going to be remembered as instigator of fire
227  if (m_eFireState == EFireState.SMOKING_IGNITING)
228  SetFireInstigator(instigator);
229  else if (m_eFireState == EFireState.BURNING && (!m_FireInstigator || m_FireInstigator.GetInstigatorType() == InstigatorType.INSTIGATOR_NONE))
230  SetFireInstigator(instigator);
231  }
232 
233  //------------------------------------------------------------------------------------------------
235  protected void SetFireInstigator(Instigator instigator)
236  {
237  m_FireInstigator = instigator;
238  }
239 
240  //------------------------------------------------------------------------------------------------
243  {
244  if (m_FireInstigator)
245  return m_FireInstigator;
246 
247  return Instigator.CreateInstigator(null);
248  }
249 
250  //------------------------------------------------------------------------------------------------
252  override void OnDamageStateChanged()
253  {
254  // Override instigator before destruction is requested
255  DamageManagerComponent damageManager = DamageManagerComponent.Cast(GetHitZoneContainer());
256  if (m_FireInstigator && damageManager.GetDefaultHitZone() == this && GetDamageState() == EDamageState.DESTROYED)
257  damageManager.SetInstigator(m_FireInstigator);
258 
259  super.OnDamageStateChanged();
260 
261  if (!GetGame().GetWorld())
262  return;
263 
264  if (GetDamageState() == EDamageState.DESTROYED)
266  else if (GetPreviousDamageState() == EDamageState.DESTROYED)
268  }
269 
270  //------------------------------------------------------------------------------------------------
272  float GetFireRate()
273  {
274  return m_fFireRate;
275  }
276 
277  //------------------------------------------------------------------------------------------------
279  void SetFireRate(float fireRate)
280  {
281  m_fFireRate = fireRate;
282  m_bIsFireRateLocked = false;
283  UpdateFireRate(true);
284  }
285 
286  //------------------------------------------------------------------------------------------------
292  float GetFireRateForState(EFireState fireState, float weight = -1)
293  {
294  if (weight < 0 || weight > 1)
295  weight = 0.5;
296 
297  float top;
298  float bottom;
299  switch (fireState)
300  {
301  case EFireState.BURNING:
302  {
303  top = m_fFireDamageRateMax;
304  bottom = m_fFireDamageRateMin;
305  break;
306  }
307  case EFireState.SMOKING_IGNITING:
308  {
309  top = m_fFireDamageRateMin;
310  bottom = m_fFireDamageRateMin * m_fIgnitingSmokeThreshold;
311  break;
312  }
313  case EFireState.SMOKING_HEAVY:
314  {
315  top = m_fFireDamageRateMin * m_fIgnitingSmokeThreshold;
316  bottom = m_fFireDamageRateMin * m_fHeavySmokeThreshold;
317  break;
318  }
319  case EFireState.SMOKING_LIGHT:
320  {
321  top = m_fFireDamageRateMin * m_fHeavySmokeThreshold;
322  bottom = m_fFireDamageRateMin * m_fLightSmokeThreshold;
323  break;
324  }
325  default:
326  {
327  top = m_fFireDamageRateMin * m_fLightSmokeThreshold;
328  bottom = 0;
329  }
330  }
331 
332  float fireRate = Math.Lerp(bottom, top, weight);
333  return fireRate;
334  }
335 
336  //------------------------------------------------------------------------------------------------
339  {
340  return m_eFireState;
341  }
342 
343  //------------------------------------------------------------------------------------------------
350  void SetFireState(EFireState fireState, float weight = -1, bool changeRate = true)
351  {
352  // Continue only if weight is defined or fir state is changed
353  bool stateChanged = fireState != m_eFireState;
354  m_eFireState = fireState;
355 
356  if (stateChanged)
357  UpdateFireEffects(fireState);
358  else if (weight < 0)
359  return;
360 
361  if (IsProxy())
362  return;
363 
364  // Update fire rate
365  if (changeRate)
366  SetFireRate(GetFireRateForState(fireState, weight));
367 
368  if (!stateChanged)
369  return;
370 
371  // Clean the fire instigator if the fire is extinguished
372  if (m_eFireState < EFireState.SMOKING_IGNITING)
373  SetFireInstigator(null);
374 
375  // Send update to remote clients
376  array<HitZone> hitZones = {};
377  SCR_DamageManagerComponent hitZoneContainer = SCR_DamageManagerComponent.Cast(GetHitZoneContainer());
378 
379  if (!hitZoneContainer)
380  return;
381 
382  hitZoneContainer.GetAllHitZones(hitZones);
383  int hitZoneIndex = hitZones.Find(this);
384  if (hitZoneIndex >= 0)
385  hitZoneContainer.Rpc(hitZoneContainer.RpcDo_SetFireState, hitZoneIndex, m_eFireState);
386  }
387 
388  //------------------------------------------------------------------------------------------------
395  {
396  EFireState fireState;
397  if (fireRate >= m_fFireDamageRateMin)
398  fireState = EFireState.BURNING;
399  else if (fireRate >= m_fFireDamageRateMin * m_fIgnitingSmokeThreshold)
400  fireState = EFireState.SMOKING_IGNITING;
401  else if (fireRate >= m_fFireDamageRateMin * m_fHeavySmokeThreshold)
402  fireState = EFireState.SMOKING_HEAVY;
403  else if (fireRate >= m_fFireDamageRateMin * m_fLightSmokeThreshold)
404  fireState = EFireState.SMOKING_LIGHT;
405  else
406  fireState = EFireState.NONE;
407 
408  return fireState;
409  }
410 
411  //------------------------------------------------------------------------------------------------
417  protected float CalculateNewFireRate(float fireRate, float deltaTime)
418  {
419  float depth;
420  if (fireRate > 0 && SCR_WorldTools.IsObjectUnderwater(GetOwner(), m_vParticleOffset, -1, depth) && depth > m_fWaterDepthThreshold)
421  {
422  fireRate = 0;
423  }
424  else if (deltaTime > 0 && fireRate > 0 && fireRate < m_fFireDamageRateMin)
425  {
426  // Update smoking virtual fire rate, that can get
427  if (fireRate < m_fHeavySmokeThreshold * m_fFireDamageRateMin)
428  fireRate -= deltaTime * m_fLightSmokeReductionRate;
429  else if (fireRate < m_fIgnitingSmokeThreshold * m_fFireDamageRateMin)
430  fireRate -= deltaTime * m_fHeavySmokeReductionRate;
431  else
432  fireRate += deltaTime * m_fIgnitingSmokeStokeRate;
433 
434  fireRate = Math.Clamp(fireRate, 0, m_fFireDamageRateMin);
435  }
436  else
437  {
438  // On fire
439  fireRate = Math.Clamp(fireRate, 0, m_fFireDamageRateMax);
440  }
441 
442  return fireRate;
443  }
444 
445  //------------------------------------------------------------------------------------------------
450  protected void ApplyFireDamage(float fireRate, float deltaTime)
451  {
452  if (fireRate < m_fFireDamageRateMin)
453  {
454  SetDamageOverTime(EDamageType.FIRE, 0);
455  return;
456  }
457 
458  SetDamageOverTime(EDamageType.FIRE, fireRate);
459 
460  Instigator instigator = m_FireInstigator;
461  if (!instigator)
462  instigator = Instigator.CreateInstigator(null);
463 
464  // Damage random physical hitzones
465  if (GetHitZoneContainer() == m_RootDamageManager && m_RootDamageManager.GetDefaultHitZone() == this)
466  m_RootDamageManager.DamageRandomHitZones(fireRate, EDamageType.FIRE, instigator);
467 
468  // Deal damage to crew depending on how much the fire is stoked
469  // TODO: Deal damage based on distance from fire
471  return;
472 
473  float damageOccupants = m_fFireDamageOccupants * deltaTime;
474  if (m_fFireDamageRateMin > 0)
475  damageOccupants *= fireRate / m_fFireDamageRateMin;
476 
477  if (damageOccupants > 0)
478  m_CompartmentManager.DamageOccupants(damageOccupants, EDamageType.FIRE, instigator, false, false);
479  }
480 
481  //------------------------------------------------------------------------------------------------
485  protected void UpdateFireRate(bool forceUpdate = false)
486  {
487  if (IsProxy())
488  return;
489 
490  BaseWorld world = GetGame().GetWorld();
491  if (!world)
492  return;
493 
494  IEntity owner = GetOwner();
495  if (!owner)
496  {
498  return;
499  }
500 
501  if (!forceUpdate && m_fUpdateFireTime == 0)
502  return;
503 
504  // Scale damage by time passed
505  float deltaTime;
506  float currentTime = world.GetWorldTime();
507 
508  if (m_fUpdateFireTime > 0)
509  deltaTime = (currentTime - m_fUpdateFireTime) * 0.001; // Convert to seconds
510 
511  float previousFireRate = m_fFireRate;
512  if (!m_bIsFireRateLocked)
513  m_fFireRate = CalculateNewFireRate(previousFireRate, deltaTime);
514 
515  // Extinguishing should also force RPC and removal of queued call so that clients stop updating fire rate
516  if (m_fFireRate == 0 && previousFireRate > 0)
517  forceUpdate = true;
518 
519  ApplyFireDamage(m_fFireRate, deltaTime);
520 
521  // Clear any scheduled call in the queue
522  if (forceUpdate)
524 
525  // Schedule future update
526  if (m_fFireRate > 0)
527  {
528  m_fUpdateFireTime = currentTime;
529 
530  if (!m_bIsUpdatingFire)
531  {
532  // Schedule delayed update every second
533  m_bIsUpdatingFire = true;
534  GetGame().GetCallqueue().CallLater(UpdateFireRate, 1000, true, false);
535  }
536  }
537  else
538  {
539  m_fUpdateFireTime = 0;
540  }
541 
542  // Update fire state
544  if (newFireState != m_eFireState)
545  SetFireState(newFireState, -1, false);
546  }
547 
548  //------------------------------------------------------------------------------------------------
551  {
552  m_bIsUpdatingFire = false;
553  GetGame().GetCallqueue().Remove(UpdateFireRate);
554  }
555 
556  //------------------------------------------------------------------------------------------------
558  void LockFireRate(bool locked = true)
559  {
560  m_bIsFireRateLocked = locked;
561  }
562 
563  //------------------------------------------------------------------------------------------------
565  {
566  IEntity owner = GetOwner();
567  if (!owner)
568  return;
569 
570  SCR_DamageManagerComponent hitZoneContainer = SCR_DamageManagerComponent.Cast(GetHitZoneContainer());
571 
572  if (!hitZoneContainer)
573  return;
574 
575  if (IsProxy() && !hitZoneContainer.IsRplReady())
576  return;
577 
578  float depth;
579  if (SCR_WorldTools.IsObjectUnderwater(owner, m_vParticleOffset, -1, depth) && depth > m_fWaterDepthThreshold)
580  {
582  return;
583  }
584 
585  SetFireState(EFireState.BURNING);
586 
587  ScriptCallQueue queue = GetGame().GetCallqueue();
588  queue.CallLater(StopDestructionFire, m_fBurningTime * 1000);
589  queue.CallLater(StartDestructionGroundFire, 1000, true);
590  }
591 
592  //------------------------------------------------------------------------------------------------
594  protected void StartDestructionGroundFire()
595  {
596  IEntity owner = GetOwner();
597  if (!owner)
598  return;
599 
600  float depth;
601  if (SCR_WorldTools.IsObjectUnderwater(owner, m_vParticleOffset, -1, depth) && depth > m_fWaterDepthThreshold)
602  {
604  return;
605  }
606  else if (SCR_WorldTools.IsObjectUnderwater(owner))
607  {
608  // Do not create surface fire effect
609  return;
610  }
611 
612  // Make sure the wreck is not moving
613  Physics physics = owner.GetPhysics();
614  if (physics && physics.GetVelocity().LengthSq() > 0.01)
615  return;
616 
617  // Measure the height difference between owner and the surface
618  vector position = owner.GetOrigin();
619  float surfaceY = GetGame().GetWorld().GetSurfaceY(position[0], position[2]);
620 
621  // If the difference is within tolerance then proceed to spawn fire effect and stop the loop
622  if (position[1] - surfaceY > FIRE_TERRAIN_HEIGHT_TOLERANCE)
623  return;
624 
625  // Stop the loop
626  GetGame().GetCallqueue().Remove(StartDestructionGroundFire);
627 
628  // No need to play particles on headless client
629  if (System.IsConsoleApp())
630  return;
631 
632  // Stop existing effect so that it gets removed and does not have to be tracked again
634  m_BurningGroundParticle.StopEmission();
635 
636  position[1] = surfaceY;
637 
638  if (m_sDestructionParticle.IsEmpty())
639  return;
640 
641  ParticleEffectEntitySpawnParams spawnParams();
642  spawnParams.Transform[3] = position;
643  spawnParams.UseFrameEvent = true;
644  m_BurningGroundParticle = ParticleEffectEntity.SpawnParticleEffect(m_sBurningGroundParticle, spawnParams);
645  }
646 
647  //------------------------------------------------------------------------------------------------
648  // Stops fire on vehicle and on the ground
650  {
651  SetFireState(EFireState.NONE);
652 
653  ScriptCallQueue queue = GetGame().GetCallqueue();
654  queue.Remove(StartDestructionGroundFire);
655  queue.Remove(StopDestructionFire);
656 
658  m_BurningGroundParticle.StopEmission();
659  }
660 
661  //------------------------------------------------------------------------------------------------
663  protected void UpdateFireEffects(EFireState fireState)
664  {
665  // No need to play particles on headless client
666  if (System.IsConsoleApp())
667  return;
668 
669  // Update sound effects
670  IEntity owner = GetOwner();
671  if (!owner)
672  return;
673 
675  m_SignalsManager.SetSignalValue(m_iFireStateSignalIdx, fireState);
676 
677  // Create particle emitters
679  {
680  ParticleEffectEntitySpawnParams spawnParams();
681  spawnParams.Transform[3] = m_vParticleOffset;
682  spawnParams.Parent = owner;
683  spawnParams.PlayOnSpawn = false;
684  spawnParams.UseFrameEvent = true;
685 
686  // Spawn particles on object
687  if (!m_DamagedParticleLight && !m_sDamagedParticle.IsEmpty())
688  m_DamagedParticleLight = ParticleEffectEntity.SpawnParticleEffect(m_sDamagedParticle, spawnParams);
689 
691  m_DamagedParticleHeavy = ParticleEffectEntity.SpawnParticleEffect(m_sDamagedParticleHeavy, spawnParams);
692 
693  if (!m_BurningParticle && !m_sBurningParticle.IsEmpty())
694  m_BurningParticle = ParticleEffectEntity.SpawnParticleEffect(m_sBurningParticle, spawnParams);
695  }
696 
697  // Fire light
698  if (fireState == EFireState.BURNING)
699  FireLightOn();
700  else
701  FireLightOff();
702 
703  // Fire
704  if (m_BurningParticle)
705  {
706  if (fireState == EFireState.BURNING)
707  m_BurningParticle.Play();
708  else
709  m_BurningParticle.StopEmission();
710  }
711 
712  // Dark smoke
714  {
715  if (fireState == EFireState.SMOKING_HEAVY || fireState == EFireState.SMOKING_IGNITING)
716  m_DamagedParticleHeavy.Play();
717  else
718  m_DamagedParticleHeavy.StopEmission();
719  }
720 
721  // Light smoke
723  {
724  if (fireState == EFireState.SMOKING_LIGHT)
725  m_DamagedParticleLight.Play();
726  else
727  m_DamagedParticleLight.StopEmission();
728  }
729  }
730 
731  //------------------------------------------------------------------------------------------------
732  protected void FireLightOn()
733  {
734  if (m_aLightEntities)
735  return;
736 
737  IEntity owner = GetOwner();
738  if (!owner)
739  return;
740 
741  vector ownerOrigin = owner.GetOrigin();
742 
743  m_aLightEntities = {};
744 
745  foreach (SCR_BaseLightData lightdata : m_aLightData)
746  {
747  LightEntity lightEntity = LightEntity.CreateLight(lightdata.GetLightType(), lightdata.GetLightFlag(), lightdata.GetEffectRadius(), Color.FromVector(lightdata.GetLightColor()), LIGHT_EMISSIVITY_START, ownerOrigin);
748  owner.AddChild(lightEntity, -1, EAddChildFlags.AUTO_TRANSFORM);
749 
750  // Calculate desired position
751  lightEntity.SetOrigin(ownerOrigin + lightdata.GetLightOffset());
752  lightEntity.SetLensFlareType(LightLensFlareType.Disabled);
753  lightEntity.SetIntensityEVClip(lightdata.GetIntensityClipEV());
754 
755  m_aLightEntities.Insert(lightEntity);
756  }
757  }
758 
759  //------------------------------------------------------------------------------------------------
760  protected void FireLightOff()
761  {
762  if (!m_aLightEntities)
763  return;
764 
765  foreach (LightEntity lightEntity : m_aLightEntities)
766  {
767  if (lightEntity)
768  delete lightEntity;
769  }
770 
771  m_aLightEntities = null;
772  }
773 
774  //------------------------------------------------------------------------------------------------
775  override float GetSecondaryExplosionScale()
776  {
777  return GetDamageOverTime(EDamageType.FIRE);
778  }
779 }
m_DamagedParticleHeavy
protected ParticleEffectEntity m_DamagedParticleHeavy
Definition: SCR_FlammableHitZone.c:97
GetFireStateForRate
EFireState GetFireStateForRate(float fireRate)
Definition: SCR_FlammableHitZone.c:394
m_fFireDamageRateMax
protected float m_fFireDamageRateMax
Definition: SCR_FlammableHitZone.c:22
BaseDamageContext
Definition: BaseDamageContext.c:12
InstigatorType
InstigatorType
Definition: InstigatorType.c:12
CalculateNewFireRate
protected float CalculateNewFireRate(float fireRate, float deltaTime)
Definition: SCR_FlammableHitZone.c:417
m_iFireStateSignalIdx
protected int m_iFireStateSignalIdx
Definition: SCR_FlammableHitZone.c:93
m_eHitZoneGroup
protected ECharacterHitZoneGroup m_eHitZoneGroup
Definition: SCR_InventoryHitZonePointUI.c:403
GetSecondaryExplosionScale
override float GetSecondaryExplosionScale()
Definition: SCR_FlammableHitZone.c:775
GetMaxHealth
float GetMaxHealth()
Definition: SCR_DestructibleEntity.c:122
GetFireRateForState
float GetFireRateForState(EFireState fireState, float weight=-1)
Definition: SCR_FlammableHitZone.c:292
m_DamagedParticleLight
protected ParticleEffectEntity m_DamagedParticleLight
Definition: SCR_FlammableHitZone.c:96
SetFireInstigator
protected void SetFireInstigator(Instigator instigator)
Inform damage manager about fire instigator.
Definition: SCR_FlammableHitZone.c:235
category
params category
Definition: SCR_FlammableHitZone.c:34
m_RootDamageManager
protected SCR_VehicleDamageManagerComponent m_RootDamageManager
Definition: SCR_RotorDamageManagerComponent.c:8
m_fIncendiaryReduction
protected float m_fIncendiaryReduction
Definition: SCR_FlammableHitZone.c:37
m_sFireStateSignal
protected string m_sFireStateSignal
Definition: SCR_FlammableHitZone.c:89
m_eFireState
protected EFireState m_eFireState
Definition: SCR_FlammableHitZone.c:16
SCR_BaseLightData
Light parameters.
Definition: SCR_BaseLightData.c:5
m_fLightSmokeReductionRate
protected float m_fLightSmokeReductionRate
Definition: SCR_FlammableHitZone.c:18
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
UpdateFireRate
protected void UpdateFireRate(bool forceUpdate=false)
Definition: SCR_FlammableHitZone.c:485
OnMaxHealthChanged
override void OnMaxHealthChanged()
Definition: SCR_FlammableHitZone.c:124
m_sBurningGroundParticle
protected ResourceName m_sBurningGroundParticle
Definition: SCR_FlammableHitZone.c:83
SCR_VehicleDamageManagerComponent
void SCR_VehicleDamageManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_VehicleDamageManagerComponent.c:1720
m_FireInstigator
protected Instigator m_FireInstigator
Definition: SCR_FlammableHitZone.c:15
GetFireState
EFireState GetFireState()
Returns current fire state.
Definition: SCR_FlammableHitZone.c:338
EDamageState
EDamageState
Definition: EDamageState.c:12
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_WorldTools
Definition: SCR_WorldTools.c:1
FIRE_TERRAIN_HEIGHT_TOLERANCE
enum EFireState FIRE_TERRAIN_HEIGHT_TOLERANCE
Instigator
Definition: Instigator.c:6
StartDestructionGroundFire
protected void StartDestructionGroundFire()
Attempts to spawn fire effect on the ground under the burning wreck.
Definition: SCR_FlammableHitZone.c:594
ApplyFireDamage
protected void ApplyFireDamage(float fireRate, float deltaTime)
Definition: SCR_FlammableHitZone.c:450
StartDestructionFire
void StartDestructionFire()
Definition: SCR_FlammableHitZone.c:564
GetHitZoneGroup
override EHitZoneGroup GetHitZoneGroup()
Definition: SCR_FlammableHitZone.c:118
NONE
@ NONE
Definition: SCR_FlammableHitZone.c:3
SetFireRate
void SetFireRate(float fireRate)
Set rate of fire (dps). If it is below fire damage threshold, no damage will be dealt.
Definition: SCR_FlammableHitZone.c:279
BURNING
@ BURNING
Definition: SCR_FlammableHitZone.c:7
m_aLightData
protected ref array< ref SCR_BaseLightData > m_aLightData
Definition: SCR_FlammableHitZone.c:30
m_fUpdateFireTime
protected float m_fUpdateFireTime
Definition: SCR_FlammableHitZone.c:23
IsProxy
protected bool IsProxy()
Definition: SCR_CampaignBuildingCompositionComponent.c:456
GetFireInstigator
Instigator GetFireInstigator()
Inform damage manager about fire instigator.
Definition: SCR_FlammableHitZone.c:242
StopFireRateUpdate
void StopFireRateUpdate()
Stop fire rate updates until requested again.
Definition: SCR_FlammableHitZone.c:550
InitFireRates
void InitFireRates()
Compute smoke and fire damage thresholds and rates.
Definition: SCR_FlammableHitZone.c:136
Attribute
typedef Attribute
Post-process effect of scripted camera.
SetFireState
void SetFireState(EFireState fireState, float weight=-1, bool changeRate=true)
Definition: SCR_FlammableHitZone.c:350
m_CompartmentManager
protected SCR_BaseCompartmentManagerComponent m_CompartmentManager
Definition: SCR_VehicleDamageManagerComponent.c:191
m_fFireDamageRateMin
protected float m_fFireDamageRateMin
Definition: SCR_FlammableHitZone.c:21
SCR_VehicleHitZone
Definition: SCR_VehicleHitZone.c:1
m_sBurningParticle
protected ResourceName m_sBurningParticle
Definition: SCR_FlammableHitZone.c:80
m_bIsUpdatingFire
protected bool m_bIsUpdatingFire
Definition: SCR_FlammableHitZone.c:24
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
m_SignalsManager
protected SignalsManagerComponent m_SignalsManager
Definition: SCR_FlammableHitZone.c:92
FireLightOn
protected void FireLightOn()
Definition: SCR_FlammableHitZone.c:732
m_fFireRate
protected float m_fFireRate
Definition: SCR_FlammableHitZone.c:17
FireLightOff
protected void FireLightOff()
Definition: SCR_FlammableHitZone.c:760
m_fHeavySmokeReductionRate
protected float m_fHeavySmokeReductionRate
Definition: SCR_FlammableHitZone.c:19
m_BurningParticle
protected ParticleEffectEntity m_BurningParticle
Definition: SCR_FlammableHitZone.c:98
LockFireRate
void LockFireRate(bool locked=true)
Temporarily stop fire rate changes until incendiary damage is received again.
Definition: SCR_FlammableHitZone.c:558
StopDestructionFire
void StopDestructionFire()
Definition: SCR_FlammableHitZone.c:649
EFireState
EFireState
Definition: SCR_FlammableHitZone.c:1
m_sDamagedParticle
protected ResourceName m_sDamagedParticle
Definition: SCR_FlammableHitZone.c:74
OnDamageStateChanged
override void OnDamageStateChanged()
Destruction logic.
Definition: SCR_FlammableHitZone.c:252
EDamageType
EDamageType
Definition: EDamageType.c:12
SMOKING_LIGHT
@ SMOKING_LIGHT
Definition: SCR_FlammableHitZone.c:4
SMOKING_HEAVY
@ SMOKING_HEAVY
Definition: SCR_FlammableHitZone.c:5
GetFireRate
float GetFireRate()
Get rate of fire (dps). If it is below fire damage threshold, no damage will be dealt.
Definition: SCR_FlammableHitZone.c:272
OnInit
override void OnInit(IEntity pOwnerEntity, GenericComponent pManagerComponent)
Definition: SCR_FlammableHitZone.c:102
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
UpdateFireEffects
protected void UpdateFireEffects(EFireState fireState)
Logic when vehicle is damaged.
Definition: SCR_FlammableHitZone.c:663
m_BurningGroundParticle
protected ParticleEffectEntity m_BurningGroundParticle
Definition: SCR_FlammableHitZone.c:99
m_sDamagedParticleHeavy
protected ResourceName m_sDamagedParticleHeavy
Definition: SCR_FlammableHitZone.c:77
DamageManagerComponent
Definition: DamageManagerComponent.c:12
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
m_bIsFireRateLocked
protected bool m_bIsFireRateLocked
Definition: SCR_FlammableHitZone.c:25
m_aLightEntities
protected ref array< LightEntity > m_aLightEntities
Definition: SCR_FlammableHitZone.c:27
ComputeIncendiaryDamage
void ComputeIncendiaryDamage(float rawDamage, notnull Instigator instigator)
Definition: SCR_FlammableHitZone.c:200
SMOKING_IGNITING
@ SMOKING_IGNITING
Definition: SCR_FlammableHitZone.c:6
ComputeEffectiveDamage
override float ComputeEffectiveDamage(notnull BaseDamageContext damageContext, bool isDOT)
Definition: SCR_FlammableHitZone.c:175
GetDamageMultiplier
float GetDamageMultiplier(EDamageType type)
Definition: SCR_DestructibleEntity.c:92
m_fIgnitingSmokeStokeRate
protected float m_fIgnitingSmokeStokeRate
Definition: SCR_FlammableHitZone.c:20