Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
playerstatbase.c
Go to the documentation of this file.
1
class
PlayerStatBase
2
{
3
protected
Man
m_Player
;
4
5
int
m_Type
;
6
void
OnStoreSave
(
ParamsWriteContext
ctx );
7
bool
OnStoreLoad
(
ParamsReadContext
ctx);
8
void
OnRPC
(
ParamsReadContext
ctx);
9
void
OnAfterStoreLoad
();
10
float
Get
();
11
string
GetLabel
();
12
void
SetByFloat
(
float
value);
13
void
SetByFloatEx
(
float
value,
string
system =
""
);
14
bool
IsSynced
();
15
array<PlayerStatRecord>
GetRecords
();
16
void
Init
(
int
id
);
17
void
SerializeValue
(
array<ref StatDebugObject>
objects,
int
flags);
18
float
GetNormalized
();
19
float
GetMax
();
20
float
GetMin
();
21
int
GetType
()
22
{
23
return
m_Type
;
24
}
25
26
void
SetPlayer
(Man player)
27
{
28
m_Player
= player;
29
}
30
}
31
32
class
PlayerStat
<
Class
T>
extends
PlayerStatBase
33
{
34
protected
T
m_MinValue
;
35
protected
T
m_MaxValue
;
36
protected
T
m_Value
;
37
protected
T
m_ValueLastSynced
;
38
protected
string
m_ValueLabel
;
39
protected
int
m_Flags
;
40
41
ref
array<PlayerStatRecord>
m_Records
;
42
43
void
PlayerStat
(T min, T max, T
init
,
string
label,
int
flags)
44
{
45
m_MinValue
= min;
46
m_MaxValue
= max;
47
m_Value
=
init
;
48
m_ValueLabel
= label;
49
m_Flags
= flags;
50
51
m_Records
=
new
array<PlayerStatRecord>
;
52
}
53
54
override
void
Init
(
int
id
)
55
{
56
m_Type
= id;
57
}
58
59
override
void
SerializeValue
(
array<ref StatDebugObject>
objects,
int
flags)
60
{
61
objects.Insert(
new
StatDebugObject
(
GetLabel
(),
Get
(),
eRemoteStatType
.PLAYER_STATS));
62
}
63
64
override
bool
IsSynced
()
65
{
66
return
m_Flags
&
EPSstatsFlags
.SYNCED;
67
}
68
69
override
void
OnRPC
(
ParamsReadContext
ctx)
70
{
71
super.OnRPC(ctx);
72
73
if
(
IsSynced
())
74
{
75
ctx.
Read
(
CachedObjectsParams
.
PARAM2_INT_FLOAT
);
76
77
int
type =
CachedObjectsParams
.
PARAM2_INT_FLOAT
.param1;
78
T value =
CachedObjectsParams
.
PARAM2_INT_FLOAT
.param2;
79
80
if
(
m_Type
== type)
81
Set
(value);
82
}
83
}
84
85
void
Set
(T value,
string
system =
""
)
86
{
87
if
(value >
m_MaxValue
)
88
{
89
m_Value
=
m_MaxValue
;
90
}
91
else
if
(value <
m_MinValue
)
92
{
93
m_Value
=
m_MinValue
;
94
}
95
else
96
{
97
m_Value
= value;
98
}
99
100
#ifdef SERVER
101
if
(
IsSynced
())
102
{
103
if
(
m_ValueLastSynced
!=
m_Value
)
104
{
106
if
(T ==
float
&&
Math
.
AbsFloat
(
m_ValueLastSynced
-
m_Value
) < 0.05)
107
return
;
108
109
CachedObjectsParams
.
PARAM2_INT_FLOAT
.param1 =
m_Type
;
110
CachedObjectsParams
.
PARAM2_INT_FLOAT
.param2 =
m_Value
;
111
m_Player
.RPCSingleParam(
ERPCs
.RPC_PLAYER_STAT,
CachedObjectsParams
.
PARAM2_INT_FLOAT
,
true
,
m_Player
.GetIdentity());
112
m_ValueLastSynced
=
m_Value
;
113
}
114
}
115
#endif
116
}
117
118
void
SetByFloat
(
float
value,
string
system =
""
)
119
{
120
T f = value;
121
Set
(f, system);
122
}
123
124
override
void
SetByFloatEx
(
float
value,
string
system =
""
)
125
{
126
SetByFloat
(value, system);
127
}
128
129
void
Add
( T value,
string
system =
""
)
130
{
131
Set
(
m_Value
+value, system);
132
}
133
134
override
float
Get
()
135
{
136
return
m_Value
;
137
}
138
139
override
string
GetLabel
()
140
{
141
return
m_ValueLabel
;
142
}
143
144
override
float
GetMax
()
145
{
146
return
m_MaxValue
;
147
}
148
149
override
float
GetMin
()
150
{
151
return
m_MinValue
;
152
}
153
154
override
float
GetNormalized
()
155
{
156
return
Math
.
InverseLerp
(
GetMin
(),
GetMax
(),
Get
());
157
}
158
159
override
array<PlayerStatRecord>
GetRecords
()
160
{
161
return
m_Records
;
162
}
163
164
void
CreateRecord
(
float
value,
string
system)
165
{
166
m_Records
.Insert(
new
PlayerStatRecord
(value,
g_Game
.GetTime(), system ) );
167
}
168
169
override
void
OnStoreSave
(
ParamsWriteContext
ctx)
170
{
171
ctx.
Write
(
m_Value
);
172
}
173
174
override
bool
OnStoreLoad
(
ParamsReadContext
ctx)
175
{
176
T value;
177
if
(ctx.
Read
(value))
178
{
179
m_Value
= value;
180
}
181
else
182
{
183
return
false
;
184
}
185
186
return
true
;
187
}
188
189
override
void
OnAfterStoreLoad
()
190
{
191
// forces the sync
192
Set
(
Get
());
193
}
194
196
PlayerStats
m_Manager
;
197
198
PlayerStats
GetManager
()
199
{
200
return
m_Manager
;
201
}
202
}
m_Type
eBleedingSourceType m_Type
Definition
bleedingsource.c:25
m_Player
map m_Player
CachedObjectsParams
Definition
utilityclasses.c:10
CachedObjectsParams::PARAM2_INT_FLOAT
static ref Param2< int, float > PARAM2_INT_FLOAT
Definition
utilityclasses.c:17
Class
Super root of all classes in Enforce script.
Definition
enscript.c:11
Math
Definition
enmath.c:7
PlayerStatBase
Definition
playerstatbase.c:2
PlayerStatBase::GetType
int GetType()
Definition
playerstatbase.c:21
PlayerStatBase::GetMax
float GetMax()
PlayerStatBase::SetByFloat
void SetByFloat(float value)
PlayerStatBase::SetByFloatEx
void SetByFloatEx(float value, string system="")
PlayerStatBase::m_Type
int m_Type
Definition
playerstatbase.c:5
PlayerStatBase::GetNormalized
float GetNormalized()
PlayerStatBase::OnStoreLoad
bool OnStoreLoad(ParamsReadContext ctx)
PlayerStatBase::OnAfterStoreLoad
void OnAfterStoreLoad()
PlayerStatBase::SetPlayer
void SetPlayer(Man player)
Definition
playerstatbase.c:26
PlayerStatBase::IsSynced
bool IsSynced()
PlayerStatBase::GetMin
float GetMin()
PlayerStatBase::Init
void Init(int id)
PlayerStatBase::OnRPC
void OnRPC(ParamsReadContext ctx)
PlayerStatBase::GetLabel
string GetLabel()
PlayerStatBase::OnStoreSave
void OnStoreSave(ParamsWriteContext ctx)
PlayerStatBase::Get
float Get()
PlayerStatBase::m_Player
Man m_Player
Definition
playerstatbase.c:3
PlayerStatBase::GetRecords
array< PlayerStatRecord > GetRecords()
PlayerStatBase::SerializeValue
void SerializeValue(array< ref StatDebugObject > objects, int flags)
PlayerStatRecord
Definition
playerstatrecord.c:2
Serializer::Write
proto bool Write(void value_out)
Serializer::Read
proto bool Read(void value_in)
StatDebugObject
Definition
statdebugobject.c:2
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
Init
override Widget Init()
Definition
dayzgame.c:127
ERPCs
ERPCs
Definition
erpcs.c:2
ParamsReadContext
Serializer ParamsReadContext
Definition
gameplay.c:15
ParamsWriteContext
Serializer ParamsWriteContext
Definition
gameplay.c:16
m_Value
string m_Value
Definition
enentity.c:808
Math::InverseLerp
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
Math::AbsFloat
static proto float AbsFloat(float f)
Returns absolute value.
init
enum MagnumStableStateID init
m_Manager
ModifiersManager m_Manager
Definition
modifierbase.c:11
m_MinValue
class PlayerStatBase m_MinValue
GetManager
PlayerStats GetManager()
Definition
playerstatbase.c:198
Add
void Add(T value, string system="")
Definition
playerstatbase.c:129
Set
void Set(T value, string system="")
Definition
playerstatbase.c:85
PlayerStat
void PlayerStat(T min, T max, T init, string label, int flags)
Definition
playerstatbase.c:43
CreateRecord
void CreateRecord(float value, string system)
Definition
playerstatbase.c:164
m_Flags
int m_Flags
Definition
playerstatbase.c:39
m_ValueLastSynced
T m_ValueLastSynced
Definition
playerstatbase.c:37
m_ValueLabel
string m_ValueLabel
Definition
playerstatbase.c:38
m_MaxValue
T m_MaxValue
Definition
playerstatbase.c:35
m_Records
ref array< PlayerStatRecord > m_Records
Definition
playerstatbase.c:41
PlayerStats
void PlayerStats(Man player)
Definition
playerstats.c:19
EPSstatsFlags
EPSstatsFlags
Definition
playerstats.c:2
eRemoteStatType
eRemoteStatType
Definition
remoteplayerstatdebug.c:2
Games
Dayz
scripts
4_world
classes
playerstats
playerstatbase.c
Generated by
1.17.0