DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
CorpseData.c
Go to the documentation of this file.
2{
3 const int GET_LIFETIME_TRIES_MAX = 3;
4
12
13 void CorpseData(notnull PlayerBase player,int time_of_death)
14 {
15 m_bUpdate = true;
16 m_iLastUpdateTime = time_of_death;
17 m_iTimeOfDeath = time_of_death;
18 m_iMaxLifetime = -1;
19 //m_iMaxLifetime = player.GetLifetime(); //player.GetEconomyProfile().GetLifetime();
21 m_Player = player;
23
24 /*Print("CorpseData init value | player.GetLifetime(): " + player.GetLifetime() );
25 Print("CorpseData init value | player.GetEconomyProfile().GetLifetime(): " + player.GetEconomyProfile().GetLifetime() );
26 Print("---------------------");*/
27 }
28
29 void UpdateCorpseState(bool force_check = false)
30 {
31 /*Print("CorpseData update value | player.GetLifetime(): " + m_Player.GetLifetime() );
32 Print("CorpseData update value | player.GetEconomyProfile().GetLifetime(): " + m_Player.GetEconomyProfile().GetLifetime() );
33 Print("---------------------");*/
34
35 if (m_iMaxLifetime <= 0 )
36 {
38 {
39 m_bUpdate = false;
40 return;
41 }
42 else
43 {
44 m_iMaxLifetime = m_Player.GetLifetime();
45 if (m_iMaxLifetime <= 0) //cleanup time not initialized yet!
46 {
48 m_iMaxLifetime = -1;
50 {
51 m_bUpdate = false;
52 }
53
54 return;
55 }
56 m_iMaxLifetime -= 30 * m_iTriesToGetLifetime; //adjusts for failed init attempts
57 m_Player.SetLifetime(m_iMaxLifetime);
58 }
59 }
60
61 int ioriginal_state = m_iCorpseState;
62 float fremaining_lifetime = m_Player.GetLifetime();
63 float fdecay_percentage = fremaining_lifetime/m_iMaxLifetime;
64
65 #ifdef DIAG_DEVELOPER
66 float timeAccel = 1;
67 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.FOOD_DECAY))
68 {
69 timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
70 float percetElapsed = 1-fdecay_percentage;
71 fdecay_percentage = Math.Clamp(1 - percetElapsed * timeAccel,0,1);
72 }
73 #endif
74
75 //int current_time = GetGame().GetTime();
76 //float fdecay_percentage_by_game_time = 1 - ((current_time - m_iTimeOfDeath) / 1000 )/m_iMaxLifetime;
77 //Print("fdecay_percentage_by_game_time - " + fdecay_percentage_by_game_time);
78
79 if (fdecay_percentage > PlayerConstants.CORPSE_THRESHOLD_MEDIUM)
80 {
82 }
83 else if (fdecay_percentage <= PlayerConstants.CORPSE_THRESHOLD_MEDIUM && fdecay_percentage > PlayerConstants.CORPSE_THRESHOLD_DECAYED)
84 {
86 }
87 else
88 {
90 m_bUpdate = false;
91 }
92
93 if (ioriginal_state != m_iCorpseState)
94 {
95 m_Player.m_CorpseState = m_iCorpseState;
96 m_Player.SetSynchDirty();
97/*
98 Print("Corpse Syncing | player - " + m_Player);
99 Print("Corpse Syncing | state - " + m_iCorpseState);
100*/
101 }
102 }
103}
int m_iTimeOfDeath
Definition CorpseData.c:7
PlayerBase m_Player
Definition CorpseData.c:11
int m_iTriesToGetLifetime
Definition CorpseData.c:10
void CorpseData(notnull PlayerBase player, int time_of_death)
Definition CorpseData.c:13
void UpdateCorpseState(bool force_check=false)
Definition CorpseData.c:29
const int GET_LIFETIME_TRIES_MAX
Definition CorpseData.c:3
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
Definition EnMath.c:7
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
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.