DayZ 1.24
Loading...
Searching...
No Matches
AreaDamageLooped Class Reference
Inheritance diagram for AreaDamageLooped:
[legend]
Collaboration diagram for AreaDamageLooped:
[legend]

Protected Member Functions

void AreaDamageLooped (EntityAI parent, bool loopByObject=true)
 
override void OnTriggerCreated ()
 Gets called when the trigger is spawned, so is the start and also a reset.
 
override void SetLoopInterval (float time)
 
override void OnEnterServerEvent (TriggerInsider insider)
 
override void OnStayStartServerEvent (int nrOfInsiders)
 
override void OnStayServerEvent (TriggerInsider insider, float deltaTime)
 
override void OnStayFinishServerEvent ()
 
float CalculateDamageScale (TriggerInsider insider, float deltaTime)
 

Protected Attributes

float m_CurrentTime = 0.0
 Current start time in seconds.
 
float m_PreviousTime = 0.0
 Previous start time in seconds.
 
float m_AccumulatedTime = 0.0
 How much time has accumulated.
 
float m_LoopInterval = 1.0
 Loop interval in seconds.
 
int m_AmountOfLoops = 0
 Caching of the amount of loops that will be performed in this frame.
 
bool m_LoopByObject = true
 Decides if the looping will be using the Object as reference or the time since last update loop.
 

Detailed Description

Definition at line 1 of file AreaDamageLooped.c.

Constructor & Destructor Documentation

◆ AreaDamageLooped()

void AreaDamageLooped::AreaDamageLooped ( EntityAI parent,
bool loopByObject = true )
inlineprotected

Definition at line 18 of file AreaDamageLooped.c.

19 {
21 }
bool m_LoopByObject
Decides if the looping will be using the Object as reference or the time since last update loop.

References m_LoopByObject.

Member Function Documentation

◆ CalculateDamageScale()

float AreaDamageLooped::CalculateDamageScale ( TriggerInsider insider,
float deltaTime )
inlineprotected

Definition at line 74 of file AreaDamageLooped.c.

75 {
76 // If we want the LoopInterval to be dependant on the Object, we will need their lastDamaged time
78 {
79 float lastDamaged = 0;
80
82 if (CastTo(dInsider, insider))
83 lastDamaged = dInsider.lastDamaged;
84
85 // First time it is damaged, do full damage
86 if (lastDamaged == 0)
87 return 1;
88
89 // This way, in case the server lags, it will scale the damage to catch up if necessary
90 // We want to wait until it is at least above 1, to not spam the network with hit messages
91 float damageCoeff = (m_CurrentTime - lastDamaged) / m_LoopInterval;
92 if (damageCoeff >= 1)
93 return damageCoeff;
94
95 return 0;
96 }
97 else
98 return m_AmountOfLoops;
99 }
float m_CurrentTime
Current start time in seconds.
int m_AmountOfLoops
Caching of the amount of loops that will be performed in this frame.
float m_LoopInterval
Loop interval in seconds.
Extended TriggerInsider for AreaDamageTriggerBase.

References m_AmountOfLoops, m_CurrentTime, m_LoopByObject, and m_LoopInterval.

◆ OnEnterServerEvent()

override void AreaDamageLooped::OnEnterServerEvent ( TriggerInsider insider)
inlineprotected

Definition at line 37 of file AreaDamageLooped.c.

38 {
39 super.OnEnterServerEvent(insider);
40
41 // Do direct damaging first time on entering
43 OnEvaluateDamageEx(insider, 1);
44 }
bool OnEvaluateDamageEx(TriggerInsider insider, float deltaTime)

References m_LoopByObject, and OnEvaluateDamageEx().

◆ OnStayFinishServerEvent()

override void AreaDamageLooped::OnStayFinishServerEvent ( )
inlineprotected

Definition at line 65 of file AreaDamageLooped.c.

66 {
67 super.OnStayFinishServerEvent();
68
70 }
float m_AccumulatedTime
How much time has accumulated.

References m_AccumulatedTime, m_AmountOfLoops, and m_LoopInterval.

◆ OnStayServerEvent()

override void AreaDamageLooped::OnStayServerEvent ( TriggerInsider insider,
float deltaTime )
inlineprotected

Definition at line 57 of file AreaDamageLooped.c.

58 {
59 super.OnStayServerEvent(insider, deltaTime);
60
61 // As we are using the Ex variant, we can put the logic in CalculateDamageScale
63 }

References OnEvaluateDamageEx().

◆ OnStayStartServerEvent()

override void AreaDamageLooped::OnStayStartServerEvent ( int nrOfInsiders)
inlineprotected

Definition at line 46 of file AreaDamageLooped.c.

47 {
48 super.OnStayStartServerEvent(nrOfInsiders);
49
50 m_CurrentTime = g_Game.GetTickTime();
53
55 }
DayZGame g_Game
Definition DayZGame.c:3528
float m_PreviousTime
Previous start time in seconds.

References g_Game, m_AccumulatedTime, m_AmountOfLoops, m_CurrentTime, m_LoopInterval, and m_PreviousTime.

◆ OnTriggerCreated()

override void AreaDamageLooped::OnTriggerCreated ( )
inlineprotected

Gets called when the trigger is spawned, so is the start and also a reset.

Definition at line 24 of file AreaDamageLooped.c.

25 {
26 super.OnTriggerCreated();
27
28 m_PreviousTime = g_Game.GetTickTime();
30 }

References g_Game, m_AccumulatedTime, and m_PreviousTime.

◆ SetLoopInterval()

override void AreaDamageLooped::SetLoopInterval ( float time)
inlineprotected

Definition at line 32 of file AreaDamageLooped.c.

33 {
35 }

References m_LoopInterval.

Member Data Documentation

◆ m_AccumulatedTime

float AreaDamageLooped::m_AccumulatedTime = 0.0
protected

How much time has accumulated.

Definition at line 8 of file AreaDamageLooped.c.

Referenced by OnStayFinishServerEvent(), OnStayStartServerEvent(), and OnTriggerCreated().

◆ m_AmountOfLoops

int AreaDamageLooped::m_AmountOfLoops = 0
protected

Caching of the amount of loops that will be performed in this frame.

Definition at line 13 of file AreaDamageLooped.c.

Referenced by CalculateDamageScale(), OnStayFinishServerEvent(), and OnStayStartServerEvent().

◆ m_CurrentTime

float AreaDamageLooped::m_CurrentTime = 0.0
protected

Current start time in seconds.

Definition at line 4 of file AreaDamageLooped.c.

Referenced by CalculateDamageScale(), and OnStayStartServerEvent().

◆ m_LoopByObject

bool AreaDamageLooped::m_LoopByObject = true
protected

Decides if the looping will be using the Object as reference or the time since last update loop.

Definition at line 16 of file AreaDamageLooped.c.

Referenced by AreaDamageLooped(), CalculateDamageScale(), and OnEnterServerEvent().

◆ m_LoopInterval

float AreaDamageLooped::m_LoopInterval = 1.0
protected

Loop interval in seconds.

Definition at line 10 of file AreaDamageLooped.c.

Referenced by CalculateDamageScale(), OnStayFinishServerEvent(), OnStayStartServerEvent(), and SetLoopInterval().

◆ m_PreviousTime

float AreaDamageLooped::m_PreviousTime = 0.0
protected

Previous start time in seconds.

Definition at line 6 of file AreaDamageLooped.c.

Referenced by OnStayStartServerEvent(), and OnTriggerCreated().


The documentation for this class was generated from the following file: