DayZ
1.24
Loading...
Searching...
No Matches
CorpseData.c
Go to the documentation of this file.
1
class
CorpseData
2
{
3
const
int
GET_LIFETIME_TRIES_MAX
= 3;
4
5
bool
m_bUpdate
;
6
int
m_iLastUpdateTime
;
7
int
m_iTimeOfDeath
;
8
int
m_iMaxLifetime
;
9
int
m_iCorpseState
;
10
int
m_iTriesToGetLifetime
;
11
PlayerBase
m_Player
;
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();
20
m_iCorpseState
=
PlayerConstants
.
CORPSE_STATE_FRESH
;
21
m_Player
=
player
;
22
m_iTriesToGetLifetime
= 0;
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
{
37
if
(
m_iCorpseState
==
PlayerConstants
.
CORPSE_STATE_DECAYED
&& !
force_check
)
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
{
47
m_iTriesToGetLifetime
++;
48
m_iMaxLifetime
= -1;
49
if
(
m_iTriesToGetLifetime
>=
GET_LIFETIME_TRIES_MAX
)
50
m_bUpdate
=
false
;
51
52
return
;
53
}
54
m_iMaxLifetime
-= 30 *
m_iTriesToGetLifetime
;
//adjusts for failed init attempts
55
m_Player
.SetLifetime(
m_iMaxLifetime
);
56
}
57
}
58
59
int
ioriginal_state
=
m_iCorpseState
;
60
float
fremaining_lifetime
=
m_Player
.GetLifetime();
61
float
fdecay_percentage
=
fremaining_lifetime
/
m_iMaxLifetime
;
62
63
#ifdef DIAG_DEVELOPER
64
float
timeAccel
= 1;
65
if
(
FeatureTimeAccel
.GetFeatureTimeAccelEnabled(
ETimeAccelCategories
.FOOD_DECAY))
66
{
67
timeAccel
=
FeatureTimeAccel
.GetFeatureTimeAccelValue();
68
float
percetElapsed
= 1 -
fdecay_percentage
;
69
fdecay_percentage
=
Math
.
Clamp
(1 -
percetElapsed
*
timeAccel
, 0, 1);
70
}
71
#endif
72
73
//int current_time = GetGame().GetTime();
74
//float fdecay_percentage_by_game_time = 1 - ((current_time - m_iTimeOfDeath) / 1000 )/m_iMaxLifetime;
75
//Print("fdecay_percentage_by_game_time - " + fdecay_percentage_by_game_time);
76
77
if
(
fdecay_percentage
>
PlayerConstants
.
CORPSE_THRESHOLD_MEDIUM
)
78
m_iCorpseState
=
PlayerConstants
.
CORPSE_STATE_FRESH
;
79
else
if
(
fdecay_percentage <= PlayerConstants.CORPSE_THRESHOLD_MEDIUM && fdecay_percentage >
PlayerConstants
.
CORPSE_THRESHOLD_DECAYED
)
80
m_iCorpseState
=
PlayerConstants
.
CORPSE_STATE_MEDIUM
;
81
else
82
{
83
m_iCorpseState
=
PlayerConstants
.
CORPSE_STATE_DECAYED
;
84
m_bUpdate
=
false
;
85
}
86
87
if
(
ioriginal_state
!=
m_iCorpseState
)
88
{
89
m_Player
.m_CorpseState =
m_iCorpseState
;
90
m_Player
.SetSynchDirty();
91
/*
92
Print("Corpse Syncing | player - " + m_Player);
93
Print("Corpse Syncing | state - " + m_iCorpseState);
94
*/
95
}
96
}
97
}
CorpseData
Definition
CorpseData.c:2
CorpseData::m_iTriesToGetLifetime
int m_iTriesToGetLifetime
Definition
CorpseData.c:10
CorpseData::m_iMaxLifetime
int m_iMaxLifetime
Definition
CorpseData.c:8
CorpseData::CorpseData
void CorpseData(notnull PlayerBase player, int time_of_death)
Definition
CorpseData.c:13
CorpseData::m_iTimeOfDeath
int m_iTimeOfDeath
Definition
CorpseData.c:7
CorpseData::m_Player
PlayerBase m_Player
Definition
CorpseData.c:11
CorpseData::GET_LIFETIME_TRIES_MAX
const int GET_LIFETIME_TRIES_MAX
Definition
CorpseData.c:3
CorpseData::m_iLastUpdateTime
int m_iLastUpdateTime
Definition
CorpseData.c:6
CorpseData::m_bUpdate
bool m_bUpdate
Definition
CorpseData.c:5
CorpseData::UpdateCorpseState
void UpdateCorpseState(bool force_check=false)
Definition
CorpseData.c:29
CorpseData::m_iCorpseState
int m_iCorpseState
Definition
CorpseData.c:9
Math
Definition
EnMath.c:7
Param3
Definition
EntityAI.c:95
PlayerBase
Definition
PlayerBaseClient.c:2
PlayerConstants
Definition
PlayerConstants.c:2
PlayerConstants::CORPSE_STATE_MEDIUM
static const int CORPSE_STATE_MEDIUM
Definition
PlayerConstants.c:200
PlayerConstants::CORPSE_STATE_DECAYED
static const int CORPSE_STATE_DECAYED
Definition
PlayerConstants.c:201
PlayerConstants::CORPSE_THRESHOLD_MEDIUM
static const float CORPSE_THRESHOLD_MEDIUM
Definition
PlayerConstants.c:196
PlayerConstants::CORPSE_STATE_FRESH
static const int CORPSE_STATE_FRESH
Definition
PlayerConstants.c:199
PlayerConstants::CORPSE_THRESHOLD_DECAYED
static const float CORPSE_THRESHOLD_DECAYED
Definition
PlayerConstants.c:197
Math::Clamp
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'.
scripts
4_World
Classes
CorpseData.c
Generated by
1.10.0