Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
corpsedata.c
Go to the documentation of this file.
2{
3 const int GET_LIFETIME_TRIES_MAX = 3;
4
11
12 float m_LifetimeAdjusted = float.MIN;
13 float m_LastLifetime = float.MIN;
15
16 void CorpseData(notnull PlayerBase player,int time_of_death)
17 {
18 m_bUpdate = true;
19 m_iLastUpdateTime = time_of_death;
20 m_iTimeOfDeath = time_of_death;
21 m_iMaxLifetime = -1;
23 m_Player = player;
25 }
26
27 void UpdateCorpseState(bool force_check = false)
28 {
29 if (m_iMaxLifetime <= 0 )
30 {
32 {
33 m_bUpdate = false;
34 return;
35 }
36 else
37 {
38 m_iMaxLifetime = m_Player.GetLifetime();
39 if (m_iMaxLifetime <= 0) //cleanup time not initialized yet!
40 {
42 m_iMaxLifetime = -1;
44 {
45 m_bUpdate = false;
46 }
47
48 return;
49 }
50 m_iMaxLifetime -= 30 * m_iTriesToGetLifetime; //adjusts for failed init attempts
51 m_Player.SetLifetime(m_iMaxLifetime);
52 }
53 }
54
55 if (m_LifetimeAdjusted == float.MIN)
57
58 if (m_LastLifetime == float.MIN)
60
61 float lifetime = m_Player.GetLifetime();
62
63 if (!CanProgressDecay())
64 {
65 m_LastLifetime = lifetime;
66 return;
67 }
68
69 int corpseStateOld = m_iCorpseState;
70 float delta = lifetime - m_LastLifetime;
71
72 #ifdef DIAG_DEVELOPER
73 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.FOOD_DECAY))
74 {
75 float timeAccel = 1;
76 timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
77 delta *= timeAccel;
78 }
79 #endif
80
81 m_LifetimeAdjusted += delta;
82
83 float corpseFreshness = 0.0;
84 if (m_iMaxLifetime != 0)
85 corpseFreshness = m_LifetimeAdjusted / m_iMaxLifetime;
86
87 if (corpseFreshness > PlayerConstants.CORPSE_THRESHOLD_MEDIUM)
88 {
90 }
91 else if (corpseFreshness <= PlayerConstants.CORPSE_THRESHOLD_MEDIUM && corpseFreshness > PlayerConstants.CORPSE_THRESHOLD_DECAYED)
92 {
94 }
95 else
96 {
98 m_bUpdate = false;
99 }
100
101 if (corpseStateOld != m_iCorpseState)
102 {
103 m_Player.m_CorpseState = m_iCorpseState;
104 m_Player.SetSynchDirty();
105 }
106
107 m_LastLifetime = lifetime;
108 }
109
110 protected bool CanProgressDecay()
111 {
112 return !m_Player.GetIsFrozen();
113 }
114}
int m_iTimeOfDeath
Definition corpsedata.c:7
PlayerBase m_Player
Definition corpsedata.c:14
int m_iTriesToGetLifetime
Definition corpsedata.c:10
void CorpseData(notnull PlayerBase player, int time_of_death)
Definition corpsedata.c:16
void UpdateCorpseState(bool force_check=false)
Definition corpsedata.c:27
const int GET_LIFETIME_TRIES_MAX
Definition corpsedata.c:3
float m_LastLifetime
Definition corpsedata.c:13
float m_LifetimeAdjusted
Definition corpsedata.c:12
bool m_bUpdate
Definition corpsedata.c:5
int m_iMaxLifetime
Definition corpsedata.c:8
int m_iLastUpdateTime
Definition corpsedata.c:6
int m_iCorpseState
Definition corpsedata.c:9
bool CanProgressDecay()
Definition corpsedata.c:110
static const float CORPSE_THRESHOLD_MEDIUM
static const int CORPSE_STATE_FRESH
static const int CORPSE_STATE_DECAYED
static const float CORPSE_THRESHOLD_DECAYED
static const int CORPSE_STATE_MEDIUM
const int MIN
Definition enconvert.c:28