Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
debugmonitorvalues.c
Go to the documentation of this file.
1
class
DebugMonitorValues
2
{
3
const
int
TYPE_HEALTH
= 1;
4
const
int
TYPE_BLOOD
= 2;
5
const
int
TYPE_BODY_TEMP
= 3;
6
const
int
TYPE_POSITION
= 4;
7
const
int
TYPE_LAST_DAMAGE
= 5;
8
9
const
int
LAST_DAMAGE_FALL
= 1;
10
const
int
LAST_DAMAGE_HIT
= 2;
11
12
const
float
VALUE_CHECK_INTERVAL
= 1;
13
const
float
SENSITIVTY_PERCENTAGE
= 1;
//how much the value needs to change up/down from previous update to trigger a new update(in percent)
14
15
PlayerBase
m_Player
;
16
float
m_TimeSinceLastTick
=
VALUE_CHECK_INTERVAL
+ 1;
17
18
string
m_CurrentLastDamage
;
19
20
float
m_LastHealthUpdate
;
21
float
m_LastBloodUpdate
;
22
string
m_lastDamageUpdate
;
23
24
float
m_HealthMaxValue
;
25
float
m_BloodMaxValue
;
26
27
float
m_BloodClient
;
28
float
m_HealthClient
;
29
string
m_LastDamageClient
;
30
31
void
DebugMonitorValues
(
PlayerBase
player)
32
{
33
m_Player
= player;
34
Init
();
35
}
36
37
void
Init
()
38
{
39
m_HealthMaxValue
=
m_Player
.GetMaxHealth(
""
,
"Health"
);
40
m_BloodMaxValue
=
m_Player
.GetMaxHealth(
""
,
"Blood"
);
41
}
42
43
void
OnScheduledTick
(
float
deltatime)
44
{
45
if
(
g_Game
.IsClient() )
return
;
46
if
( !
g_Game
.IsDebugMonitor() )
return
;
// turned off in server config
47
48
m_TimeSinceLastTick
+= deltatime;
49
50
if
(
m_TimeSinceLastTick
>
VALUE_CHECK_INTERVAL
)
51
{
52
m_TimeSinceLastTick
= 0;
53
CheckValues
();
54
}
55
}
56
57
void
CheckValues
()
58
{
59
CheckHealth
();
60
CheckBlood
();
61
CheckLastDamage
();
62
}
63
64
float
GetBlood
()
65
{
66
return
m_BloodClient
;
67
}
68
69
float
GetHealth
()
70
{
71
return
m_HealthClient
;
72
}
73
74
string
GetLastDamage
()
75
{
76
return
m_LastDamageClient
;
77
}
78
79
void
SetLastDamage
(
string
value)
80
{
81
m_CurrentLastDamage
= value;
82
}
83
84
void
CheckHealth
()
85
{
86
float
health_current =
m_Player
.GetHealth(
""
,
"Health"
);
87
float
health_normalized = health_current /
m_HealthMaxValue
;
88
float
difference_normalized = health_normalized -
m_LastHealthUpdate
;
89
float
diff_abs =
Math
.
AbsFloat
(difference_normalized);
90
91
if
( diff_abs > (
SENSITIVTY_PERCENTAGE
/100 ) )
92
{
93
Param1<float> param =
new
Param1<float>( health_current );
94
95
SendValue
(
TYPE_HEALTH
, param);
96
m_LastHealthUpdate
= health_normalized;
97
}
98
}
99
100
void
CheckBlood
()
101
{
102
float
blood_current =
m_Player
.GetHealth(
""
,
"Blood"
);
103
float
blood_normalized = blood_current /
m_BloodMaxValue
;
104
float
difference_normalized = blood_normalized -
m_LastBloodUpdate
;
105
float
diff_abs =
Math
.
AbsFloat
(difference_normalized);
106
107
if
( diff_abs > (
SENSITIVTY_PERCENTAGE
/100 ) )
108
{
109
Param1<float> param =
new
Param1<float>( blood_current );
110
111
SendValue
(
TYPE_BLOOD
, param);
112
m_LastBloodUpdate
= blood_normalized;
113
}
114
}
115
116
void
CheckLastDamage
()
117
{
118
if
(
m_CurrentLastDamage
!=
m_lastDamageUpdate
)
119
{
120
Param1<string> param =
new
Param1<string>(
m_CurrentLastDamage
);
121
SendValue
(
TYPE_LAST_DAMAGE
, param);
122
m_lastDamageUpdate
=
m_CurrentLastDamage
;
123
}
124
}
125
126
void
SendValue
(
int
value_type,
Param
param)
127
{
128
switch
(value_type)
129
{
130
case
DebugMonitorValues
.TYPE_HEALTH:
131
case
DebugMonitorValues
.TYPE_BLOOD:
132
{
133
Param1<float> value_float = Param1<float>.Cast( param );
134
135
CachedObjectsParams
.
PARAM2_INT_FLOAT
.param1 = value_type;
136
CachedObjectsParams
.
PARAM2_INT_FLOAT
.param2 = value_float.param1;
137
//Print("SendingValue type " + value_type.ToString() + " value " + value_float.ToString());
138
g_Game
.RPCSingleParam(
m_Player
,
ERPCs
.RPC_DEBUG_MONITOR_FLT,
CachedObjectsParams
.
PARAM2_INT_FLOAT
,
true
,
m_Player
.GetIdentity());
139
}
140
break
;
141
case
DebugMonitorValues
.TYPE_LAST_DAMAGE:
142
{
143
Param1<string> value_string = Param1<string>.Cast( param );
144
145
CachedObjectsParams
.
PARAM2_INT_STRING
.param1 = value_type;
146
CachedObjectsParams
.
PARAM2_INT_STRING
.param2 = value_string.param1;
147
//Print("SendingValue type " + value_type.ToString() + " value " + value_string);
148
g_Game
.RPCSingleParam(
m_Player
,
ERPCs
.RPC_DEBUG_MONITOR_STR,
CachedObjectsParams
.
PARAM2_INT_STRING
,
true
,
m_Player
.GetIdentity());
149
}
150
break
;
151
}
152
}
153
154
void
ReceiveValue
(
int
value_type,
Param
param)
155
{
156
g_Game
.GetMission().CreateDebugMonitor();
157
158
switch
(value_type)
159
{
160
case
DebugMonitorValues
.TYPE_HEALTH:
161
{
162
Param1<float> valueHealth = Param1<float>.Cast( param );
163
//Print("ReceivedValue health " + valueHealth.param1.ToString());
164
m_HealthClient
= valueHealth.param1;
165
}
166
break
;
167
case
DebugMonitorValues
.TYPE_BLOOD:
168
{
169
Param1<float> valueBlood = Param1<float>.Cast( param );
170
//Print("ReceivedValue blood " + valueBlood.param1.ToString());
171
m_BloodClient
= valueBlood.param1;
172
}
173
break
;
174
case
DebugMonitorValues
.TYPE_LAST_DAMAGE:
175
{
176
Param1<string> valueLastDamage = Param1<string>.Cast( param );
177
//Print("ReceivedValue lastdamage " + valueLastDamage.param1);
178
m_LastDamageClient
= valueLastDamage.param1;
179
}
180
break
;
181
}
182
}
183
184
void
OnRPCFloat
(
ParamsReadContext
ctx)
185
{
186
Param1<float> value =
new
Param1<float>(0);
187
188
ctx.
Read
(
CachedObjectsParams
.
PARAM2_INT_FLOAT
);
189
int
value_type =
CachedObjectsParams
.
PARAM2_INT_FLOAT
.param1;
190
value.param1 =
CachedObjectsParams
.
PARAM2_INT_FLOAT
.param2;
191
192
ReceiveValue
(value_type, value);
193
}
194
195
void
OnRPCString
(
ParamsReadContext
ctx)
196
{
197
Param1<string> value =
new
Param1<string>(
""
);
198
199
ctx.
Read
(
CachedObjectsParams
.
PARAM2_INT_STRING
);
200
int
value_type =
CachedObjectsParams
.
PARAM2_INT_STRING
.param1;
201
value.param1 =
CachedObjectsParams
.
PARAM2_INT_STRING
.param2;
202
203
ReceiveValue
(value_type, value);
204
}
205
};
CachedObjectsParams
Definition
utilityclasses.c:10
CachedObjectsParams::PARAM2_INT_STRING
static ref Param2< int, string > PARAM2_INT_STRING
Definition
utilityclasses.c:18
CachedObjectsParams::PARAM2_INT_FLOAT
static ref Param2< int, float > PARAM2_INT_FLOAT
Definition
utilityclasses.c:17
DebugMonitorValues::LAST_DAMAGE_HIT
const int LAST_DAMAGE_HIT
Definition
debugmonitorvalues.c:10
DebugMonitorValues::TYPE_POSITION
const int TYPE_POSITION
Definition
debugmonitorvalues.c:6
DebugMonitorValues::m_HealthClient
float m_HealthClient
Definition
debugmonitorvalues.c:28
DebugMonitorValues::TYPE_BLOOD
const int TYPE_BLOOD
Definition
debugmonitorvalues.c:4
DebugMonitorValues::Init
void Init()
Definition
debugmonitorvalues.c:37
DebugMonitorValues::GetBlood
float GetBlood()
Definition
debugmonitorvalues.c:64
DebugMonitorValues::DebugMonitorValues
void DebugMonitorValues(PlayerBase player)
Definition
debugmonitorvalues.c:31
DebugMonitorValues::TYPE_HEALTH
const int TYPE_HEALTH
Definition
debugmonitorvalues.c:3
DebugMonitorValues::SendValue
void SendValue(int value_type, Param param)
Definition
debugmonitorvalues.c:126
DebugMonitorValues::m_CurrentLastDamage
string m_CurrentLastDamage
Definition
debugmonitorvalues.c:18
DebugMonitorValues::m_BloodMaxValue
float m_BloodMaxValue
Definition
debugmonitorvalues.c:25
DebugMonitorValues::m_HealthMaxValue
float m_HealthMaxValue
Definition
debugmonitorvalues.c:24
DebugMonitorValues::m_Player
PlayerBase m_Player
Definition
debugmonitorvalues.c:15
DebugMonitorValues::SENSITIVTY_PERCENTAGE
const float SENSITIVTY_PERCENTAGE
Definition
debugmonitorvalues.c:13
DebugMonitorValues::GetLastDamage
string GetLastDamage()
Definition
debugmonitorvalues.c:74
DebugMonitorValues::GetHealth
float GetHealth()
Definition
debugmonitorvalues.c:69
DebugMonitorValues::SetLastDamage
void SetLastDamage(string value)
Definition
debugmonitorvalues.c:79
DebugMonitorValues::m_lastDamageUpdate
string m_lastDamageUpdate
Definition
debugmonitorvalues.c:22
DebugMonitorValues::CheckLastDamage
void CheckLastDamage()
Definition
debugmonitorvalues.c:116
DebugMonitorValues::ReceiveValue
void ReceiveValue(int value_type, Param param)
Definition
debugmonitorvalues.c:154
DebugMonitorValues::m_LastDamageClient
string m_LastDamageClient
Definition
debugmonitorvalues.c:29
DebugMonitorValues::m_LastHealthUpdate
float m_LastHealthUpdate
Definition
debugmonitorvalues.c:20
DebugMonitorValues::OnScheduledTick
void OnScheduledTick(float deltatime)
Definition
debugmonitorvalues.c:43
DebugMonitorValues::m_BloodClient
float m_BloodClient
Definition
debugmonitorvalues.c:27
DebugMonitorValues::CheckBlood
void CheckBlood()
Definition
debugmonitorvalues.c:100
DebugMonitorValues::m_LastBloodUpdate
float m_LastBloodUpdate
Definition
debugmonitorvalues.c:21
DebugMonitorValues::OnRPCString
void OnRPCString(ParamsReadContext ctx)
Definition
debugmonitorvalues.c:195
DebugMonitorValues::CheckHealth
void CheckHealth()
Definition
debugmonitorvalues.c:84
DebugMonitorValues::LAST_DAMAGE_FALL
const int LAST_DAMAGE_FALL
Definition
debugmonitorvalues.c:9
DebugMonitorValues::VALUE_CHECK_INTERVAL
const float VALUE_CHECK_INTERVAL
Definition
debugmonitorvalues.c:12
DebugMonitorValues::m_TimeSinceLastTick
float m_TimeSinceLastTick
Definition
debugmonitorvalues.c:16
DebugMonitorValues::CheckValues
void CheckValues()
Definition
debugmonitorvalues.c:57
DebugMonitorValues::TYPE_BODY_TEMP
const int TYPE_BODY_TEMP
Definition
debugmonitorvalues.c:5
DebugMonitorValues::OnRPCFloat
void OnRPCFloat(ParamsReadContext ctx)
Definition
debugmonitorvalues.c:184
DebugMonitorValues::TYPE_LAST_DAMAGE
const int TYPE_LAST_DAMAGE
Definition
debugmonitorvalues.c:7
Math
Definition
enmath.c:7
Param
Base Param Class with no parameters.
Definition
param.c:12
PlayerBase
Definition
playerbaseclient.c:2
Serializer::Read
proto bool Read(void value_in)
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
ERPCs
ERPCs
Definition
erpcs.c:2
ParamsReadContext
Serializer ParamsReadContext
Definition
gameplay.c:15
Math::AbsFloat
static proto float AbsFloat(float f)
Returns absolute value.
Games
Dayz
scripts
4_world
classes
debugmonitorvalues.c
Generated by
1.17.0