DayZ 1.24
Loading...
Searching...
No Matches
InjuryHandler.c File Reference

Go to the source code of this file.

Classes

class  InjuryHandlerThresholds
 
class  InjuryAnimValues
 

Enumerations

enum  eInjuryHandlerLevels {
  PRISTINE , WORN , DAMAGED , BADLY_DAMAGED ,
  RUINED
}
 

Functions

void InjuryAnimationHandler (PlayerBase player)
 
bool IsInjuryAnimEnabled ()
 
float GetInjuryAnimValue ()
 
ScriptInvoker GetInvoker ()
 
void Update (float deltaT)
 
eInjuryHandlerLevels GetOverrideLevel (eInjuryHandlerLevels unchanged_level)
 
void CheckValue (bool forceUpdate=false)
 
void Synchronize (eInjuryHandlerLevels level)
 
void SendValue (eInjuryHandlerLevels level)
 
void SetInjuryCommandParams (bool enable, eInjuryHandlerLevels level)
 
eInjuryHandlerLevels GetInjuryLevel (float health)
 
float GetInjuryValue (eInjuryHandlerLevels level)
 

Variables

enum eInjuryHandlerLevels NONE = 0
 MUST BE POW2.
 
enum eInjuryHandlerLevels MORPHINE = 1
 
enum eInjuryHandlerLevels PAIN_KILLERS_LVL0 = 2
 
enum eInjuryHandlerLevels PAIN_KILLERS_LVL1 = 4
 
enum eInjuryHandlerLevels BROKEN_LEGS = 8
 
enum eInjuryHandlerLevels BROKEN_LEGS_SPLINT = 16
 
enum eInjuryHandlerLevels PRONE_ANIM_OVERRIDE = 32
 
enum eInjuryHandlerLevels VALUE_CHECK_INTERVAL = 5
 
const float SENSITIVTY_PERCENTAGE = 1
 
ref ScriptInvoker m_ChangedStateInvoker = new ScriptInvoker()
 
float m_TimeSinceLastTick = VALUE_CHECK_INTERVAL + 1
 
float m_LastUpdate
 
eInjuryHandlerLevels m_LastHealthUpdate
 
float m_HealthMaxValue
 
PlayerBase m_Player
 
bool m_AnimationChange = false
 owner
 
bool m_InjuryAnimEnabled = false
 
float m_InjuryAnimDamageValue = 0
 
int m_ForceInjuryAnimMask
 

Enumeration Type Documentation

◆ eInjuryHandlerLevels

Enumerator
PRISTINE 
WORN 
DAMAGED 
BADLY_DAMAGED 
RUINED 

Definition at line 18 of file InjuryHandler.c.

19{
21 WORN,
22 DAMAGED,
24 RUINED,
25}
@ RUINED
@ BADLY_DAMAGED
@ DAMAGED
@ PRISTINE
@ WORN

Function Documentation

◆ CheckValue()

void CheckValue ( bool forceUpdate = false)
private

Definition at line 144 of file InjuryHandler.c.

145 {
146 float health_current_normalized = m_Player.GetHealth("", "Health") / m_HealthMaxValue;
148
151
153 {
158 }
159 }
void Synchronize()
ref ScriptInvoker m_ChangedStateInvoker
eInjuryHandlerLevels GetOverrideLevel(eInjuryHandlerLevels unchanged_level)
eInjuryHandlerLevels m_LastHealthUpdate
float m_HealthMaxValue
PlayerBase m_Player
eInjuryHandlerLevels
int m_ForceInjuryAnimMask
eInjuryHandlerLevels GetInjuryLevel(float health)
void SendValue(eInjuryHandlerLevels level)

References GetInjuryLevel(), GetOverrideLevel(), m_ChangedStateInvoker, m_ForceInjuryAnimMask, m_HealthMaxValue, m_LastHealthUpdate, m_Player, SendValue(), and Synchronize().

Referenced by Update().

◆ GetInjuryAnimValue()

float GetInjuryAnimValue ( )
private

Definition at line 70 of file InjuryHandler.c.

71 {
73 }
float m_InjuryAnimDamageValue

References m_InjuryAnimDamageValue.

◆ GetInjuryLevel()

◆ GetInjuryValue()

float GetInjuryValue ( eInjuryHandlerLevels level)
private

Definition at line 198 of file InjuryHandler.c.

199 {
200 switch (level)
201 {
202 case eInjuryHandlerLevels.RUINED:
203 {
204 return InjuryAnimValues.LVL4;
205 }
206 case eInjuryHandlerLevels.BADLY_DAMAGED:
207 {
208 return InjuryAnimValues.LVL3;
209 }
210 case eInjuryHandlerLevels.DAMAGED:
211 {
212 return InjuryAnimValues.LVL2;
213 }
214 case eInjuryHandlerLevels.WORN:
215 {
216 return InjuryAnimValues.LVL1;
217 }
218 case eInjuryHandlerLevels.PRISTINE:
219 {
220 return InjuryAnimValues.LVL0;
221 }
222 default:
223 Error("Undefined Injury level");
224 }
225 return 0;
226 }
const float LVL4
const float LVL1
const float LVL0
const float LVL2
const float LVL3
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

References Error(), InjuryAnimValues::LVL0, InjuryAnimValues::LVL1, InjuryAnimValues::LVL2, InjuryAnimValues::LVL3, and InjuryAnimValues::LVL4.

Referenced by SetInjuryCommandParams().

◆ GetInvoker()

ScriptInvoker GetInvoker ( )
private

Definition at line 75 of file InjuryHandler.c.

76 {
78 }

References m_ChangedStateInvoker.

◆ GetOverrideLevel()

eInjuryHandlerLevels GetOverrideLevel ( eInjuryHandlerLevels unchanged_level)
private

Definition at line 100 of file InjuryHandler.c.

101 {
103
104 //Whatever the case, prone will always use PRISTINE anim level as alternative anim level(s) are not interesting gameplaywise
105 if (m_ForceInjuryAnimMask & eInjuryOverrides.PRONE_ANIM_OVERRIDE && override_level > eInjuryHandlerLevels.PRISTINE)
106 {
108 return override_level;
109 }
110
113
116
119
122
123 //Broken leg overrides
126
128 {
129 //Average leg health used to determine which animation to use
130 float avgLegHealth = m_Player.GetHealth("RightLeg", "") + m_Player.GetHealth("LeftLeg", "") + m_Player.GetHealth("RightFoot", "") + m_Player.GetHealth("LeftFoot", "");
131 avgLegHealth *= 0.25; //divide by 4 to make the average leg health;
136 else
138 }
139
140 return override_level;
141
142 }
static const float BROKEN_LEGS_HIGH_HEALTH_THRESHOLD
static const float BROKEN_LEGS_LOW_HEALTH_THRESHOLD

References PlayerConstants::BROKEN_LEGS_HIGH_HEALTH_THRESHOLD, PlayerConstants::BROKEN_LEGS_LOW_HEALTH_THRESHOLD, m_ForceInjuryAnimMask, and m_Player.

Referenced by CheckValue().

◆ InjuryAnimationHandler()

void InjuryAnimationHandler ( PlayerBase player)
private

Definition at line 59 of file InjuryHandler.c.

60 {
62 m_HealthMaxValue = m_Player.GetMaxHealth("", "Health");
63 }

References m_HealthMaxValue, and m_Player.

Referenced by ManBase::Init().

◆ IsInjuryAnimEnabled()

bool IsInjuryAnimEnabled ( )
private

Definition at line 65 of file InjuryHandler.c.

66 {
68 }
bool m_InjuryAnimEnabled

References m_InjuryAnimEnabled.

◆ SendValue()

void SendValue ( eInjuryHandlerLevels level)
private

Definition at line 168 of file InjuryHandler.c.

169 {
171 }
static void SendInjury(DayZPlayer pPlayer, bool pEnable, eInjuryHandlerLevels level)

References m_Player, and DayZPlayerSyncJunctures::SendInjury().

Referenced by CheckValue().

◆ SetInjuryCommandParams()

void SetInjuryCommandParams ( bool enable,
eInjuryHandlerLevels level )
private

Definition at line 173 of file InjuryHandler.c.

174 {
175 m_AnimationChange = true;
178 }
float GetInjuryValue(eInjuryHandlerLevels level)
bool m_AnimationChange
owner

References GetInjuryValue(), m_AnimationChange, m_InjuryAnimDamageValue, and m_InjuryAnimEnabled.

◆ Synchronize()

void Synchronize ( eInjuryHandlerLevels level)
private

Definition at line 161 of file InjuryHandler.c.

162 {
163 m_Player.m_HealthLevel = level;
164 //Print("m_Player.m_HealthLevel:" + m_Player.m_HealthLevel);
165 m_Player.SetSynchDirty();
166 }

References m_Player.

◆ Update()

void Update ( float deltaT)
private

Definition at line 80 of file InjuryHandler.c.

81 {
83 {
84 m_Player.GetCommandModifier_Additives().SetInjured(m_InjuryAnimDamageValue, m_InjuryAnimEnabled);
85 m_AnimationChange = false;
86 }
87
88 if (GetGame().IsClient())
89 return;
90
92
94 {
95 CheckValue();
97 }
98 }
void CheckValue(bool forceUpdate=false)
enum eInjuryHandlerLevels VALUE_CHECK_INTERVAL
float m_TimeSinceLastTick
proto native CGame GetGame()

References CheckValue(), GetGame(), m_AnimationChange, m_InjuryAnimDamageValue, m_InjuryAnimEnabled, m_Player, m_TimeSinceLastTick, and VALUE_CHECK_INTERVAL.

Variable Documentation

◆ BROKEN_LEGS

enum eInjuryHandlerLevels BROKEN_LEGS = 8

◆ BROKEN_LEGS_SPLINT

enum eInjuryHandlerLevels BROKEN_LEGS_SPLINT = 16

◆ m_AnimationChange

bool m_AnimationChange = false
private

owner

Definition at line 54 of file InjuryHandler.c.

Referenced by SetInjuryCommandParams(), and Update().

◆ m_ChangedStateInvoker

ref ScriptInvoker m_ChangedStateInvoker = new ScriptInvoker()

Definition at line 45 of file InjuryHandler.c.

Referenced by CheckValue(), and GetInvoker().

◆ m_ForceInjuryAnimMask

int m_ForceInjuryAnimMask
private

Definition at line 57 of file InjuryHandler.c.

Referenced by CheckValue(), and GetOverrideLevel().

◆ m_HealthMaxValue

float m_HealthMaxValue

Definition at line 50 of file InjuryHandler.c.

Referenced by CheckValue(), Managed::Init(), and InjuryAnimationHandler().

◆ m_InjuryAnimDamageValue

float m_InjuryAnimDamageValue = 0
private

Definition at line 56 of file InjuryHandler.c.

Referenced by GetInjuryAnimValue(), SetInjuryCommandParams(), and Update().

◆ m_InjuryAnimEnabled

bool m_InjuryAnimEnabled = false
private

Definition at line 55 of file InjuryHandler.c.

Referenced by IsInjuryAnimEnabled(), SetInjuryCommandParams(), and Update().

◆ m_LastHealthUpdate

eInjuryHandlerLevels m_LastHealthUpdate

◆ m_LastUpdate

float m_LastUpdate

Definition at line 48 of file InjuryHandler.c.

◆ m_Player

PlayerBase m_Player
private

Definition at line 53 of file InjuryHandler.c.

◆ m_TimeSinceLastTick

float m_TimeSinceLastTick = VALUE_CHECK_INTERVAL + 1

Definition at line 47 of file InjuryHandler.c.

Referenced by Managed::OnScheduledTick(), and Update().

◆ MORPHINE

enum eInjuryHandlerLevels MORPHINE = 1

◆ NONE

MUST BE POW2.

◆ PAIN_KILLERS_LVL0

enum eInjuryHandlerLevels PAIN_KILLERS_LVL0 = 2

◆ PAIN_KILLERS_LVL1

enum eInjuryHandlerLevels PAIN_KILLERS_LVL1 = 4

◆ PRONE_ANIM_OVERRIDE

enum eInjuryHandlerLevels PRONE_ANIM_OVERRIDE = 32

◆ SENSITIVTY_PERCENTAGE

const float SENSITIVTY_PERCENTAGE = 1

Definition at line 43 of file InjuryHandler.c.

Referenced by Managed::CheckBlood(), and Managed::CheckHealth().

◆ VALUE_CHECK_INTERVAL

enum eInjuryHandlerLevels VALUE_CHECK_INTERVAL = 5

Referenced by Managed::OnScheduledTick(), and Update().