Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
bleedingindicator.c
Go to the documentation of this file.
1
3
class
BleedingIndicator
extends
Managed
4
{
5
protected
bool
m_Initialized
;
6
protected
bool
m_Terminating
=
false
;
//doesn't spawn more drops and ends when the last one does
7
protected
bool
m_EndNow
=
false
;
8
protected
bool
m_IsRunning
=
false
;
9
protected
int
m_DropSpawnsQueued
;
10
protected
int
m_ActiveDropsCount
;
11
protected
int
m_Severity
;
12
protected
int
m_SourceID
;
//pairs this with the 'BleedingSource' bit/ID
13
protected
GameplayEffectsDataBleeding
m_ParentMetaData
;
14
protected
array<float>
m_DropProbabilityArray
;
15
16
protected
float
m_AverageFrequency
;
//average drops per interval. NOT changeable on the fly, just a helper value!
17
protected
float
m_SequenceTick
;
18
protected
float
m_SequenceDuration
;
19
protected
float
m_TimeElapsedTotal
;
20
protected
float
m_TimeElapsedSequence
;
21
protected
float
m_LastDropSpawnTime
;
//relative to the TOTAL time, not the sequence!
22
protected
float
m_DropSpawnMinDelay
;
23
protected
float
m_DropSpawnMaxDelay
;
24
protected
int
m_CurrentDropProbabilityStep
;
25
protected
int
m_DropProbabilityRollsCount
;
26
protected
vector
m_BasePosition
;
27
28
ref set<ref BleedingIndicatorDropData>
m_ActiveDrops
;
29
ref set<int>
m_CleanupQueue
;
30
31
void
BleedingIndicator
(
int
source_ID,
int
severity, GameplayEffectsDataBleeding parent)
32
{
33
m_Initialized
=
false
;
34
m_SourceID
= source_ID;
35
m_Severity
= severity;
36
m_ParentMetaData
= parent;
37
m_CurrentDropProbabilityStep
= 0;
38
m_ActiveDrops
=
new
set<ref BleedingIndicatorDropData>;
39
m_CleanupQueue
=
new
set<int>;
40
m_DropProbabilityArray
=
m_ParentMetaData
.GetProbabilities(
m_Severity
);
41
m_DropProbabilityRollsCount
=
m_DropProbabilityArray
.Count();
42
43
switch
(
m_Severity
)
44
{
45
case
BleedingIndicationConstants
.
INDICATOR_SEVERITY_LOW
:
46
{
47
m_SequenceDuration
=
BleedingIndicationConstants
.
SEQUENCE_DURATION_LOW
;
48
m_AverageFrequency
=
BleedingIndicationConstants
.
SEQUENCE_DROP_AVERAGE_LOW
;
49
m_DropSpawnMinDelay
=
BleedingIndicationConstants
.
SEQUENCE_DROP_DELAY_MIN_LOW
;
50
m_DropSpawnMaxDelay
=
BleedingIndicationConstants
.
SEQUENCE_DROP_DELAY_MAX_LOW
;
51
break
;
52
}
53
case
BleedingIndicationConstants
.
INDICATOR_SEVERITY_MEDIUM
:
54
{
55
m_SequenceDuration
=
BleedingIndicationConstants
.
SEQUENCE_DURATION_MEDIUM
;
56
m_AverageFrequency
=
BleedingIndicationConstants
.
SEQUENCE_DROP_AVERAGE_MEDIUM
;
57
m_DropSpawnMinDelay
=
BleedingIndicationConstants
.
SEQUENCE_DROP_DELAY_MIN_MEDIUM
;
58
m_DropSpawnMaxDelay
=
BleedingIndicationConstants
.
SEQUENCE_DROP_DELAY_MAX_MEDIUM
;
59
break
;
60
}
61
case
BleedingIndicationConstants
.
INDICATOR_SEVERITY_HIGH
:
62
{
63
m_SequenceDuration
=
BleedingIndicationConstants
.
SEQUENCE_DURATION_HIGH
;
64
m_AverageFrequency
=
BleedingIndicationConstants
.
SEQUENCE_DROP_AVERAGE_HIGH
;
65
m_DropSpawnMinDelay
=
BleedingIndicationConstants
.
SEQUENCE_DROP_DELAY_MIN_HIGH
;
66
m_DropSpawnMaxDelay
=
BleedingIndicationConstants
.
SEQUENCE_DROP_DELAY_MAX_HIGH
;
67
break
;
68
}
69
70
default
:
71
{
72
m_AverageFrequency
=
BleedingIndicationConstants
.
SEQUENCE_DROP_AVERAGE_LOW
;
73
m_DropSpawnMinDelay
=
BleedingIndicationConstants
.
SEQUENCE_DROP_DELAY_MIN_LOW
;
74
m_DropSpawnMaxDelay
=
BleedingIndicationConstants
.
SEQUENCE_DROP_DELAY_MAX_LOW
;
75
Debug
.
Log
(
"Unknown severity value!"
);
76
}
77
#ifdef DIAG_DEVELOPER
78
if
(
DbgBleedingIndicationStaticInfo
.
m_DbgUseOverrideValues
)
79
{
80
m_SequenceDuration
=
DbgBleedingIndicationStaticInfo
.
m_DbgSequenceDuration
;
81
m_DropSpawnMinDelay
=
DbgBleedingIndicationStaticInfo
.
m_DbgDropMinDelay
;
82
m_DropSpawnMaxDelay
=
DbgBleedingIndicationStaticInfo
.
m_DbgDropMaxDelay
;
83
}
84
#endif
85
}
86
87
m_TimeElapsedTotal
= 0;
88
m_TimeElapsedSequence
= 0;
89
}
90
91
void
InitIndicator
(
vector
position)
92
{
93
m_BasePosition
= position;
94
ResetIndicator
();
95
m_Initialized
=
true
;
96
}
97
98
void
StopIndicator
(
bool
instant =
false
)
99
{
100
if
(!
m_Terminating
)
101
{
102
m_IsRunning
=
false
;
103
104
if
(instant)
105
{
106
m_EndNow
=
true
;
107
}
108
m_Terminating
=
true
;
109
}
110
}
111
112
protected
void
StartRunningDrops
()
113
{
114
m_ActiveDropsCount
= 0;
115
m_IsRunning
=
true
;
116
TrySpawnNextDrop
();
117
m_DropSpawnsQueued
= 0;
118
119
m_CurrentDropProbabilityStep
= (
int
)(
m_DropProbabilityRollsCount
- (
m_DropProbabilityRollsCount
/
m_AverageFrequency
));
120
}
121
123
protected
bool
IsRunningDrops
()
124
{
125
return
m_ActiveDropsCount
> 0;
126
}
127
128
void
TrySpawnNextDrop
()
129
{
130
ImageWidget dropImage;
131
if
(
Class
.
CastTo
(dropImage,
m_ParentMetaData
.GetNextDropImage()) && !dropImage.IsVisible())
//IsVisible false means the drop is free to be used
132
{
133
BleedingIndicatorDropData
data =
new
BleedingIndicatorDropData
(dropImage,
m_Severity
);
134
data.
SetBasePosition
(
m_BasePosition
);
135
data.
StartDrop
();
136
137
m_ActiveDrops
.Insert(data);
138
m_ActiveDropsCount
++;
139
}
140
141
m_LastDropSpawnTime
=
m_TimeElapsedTotal
;
142
m_DropSpawnsQueued
--;
143
}
144
145
protected
void
ResetSequence
()
146
{
147
m_CurrentDropProbabilityStep
= 0;
148
m_TimeElapsedSequence
= 0;
149
m_DropSpawnsQueued
= 0;
150
}
151
152
void
ResetIndicator
()
153
{
154
m_Terminating
=
false
;
155
m_EndNow
=
false
;
156
m_TimeElapsedTotal
= 0;
157
m_CurrentDropProbabilityStep
= 0;
158
m_TimeElapsedSequence
= 0;
159
m_LastDropSpawnTime
= 0;
160
m_DropSpawnsQueued
= 0;
161
}
162
163
void
Update
(
float
timeSlice)
164
{
165
if
( !
m_Initialized
)
166
{
167
return
;
168
}
169
170
#ifdef DIAG_DEVELOPER
171
if
(
DbgBleedingIndicationStaticInfo
.
m_DbgUseOverrideValues
)
172
{
173
m_SequenceDuration
=
DbgBleedingIndicationStaticInfo
.
m_DbgSequenceDuration
;
174
}
175
#endif
176
m_SequenceTick
=
m_SequenceDuration
/
m_DropProbabilityRollsCount
;
177
178
//run drops, if possible
179
if
(!
m_Terminating
)
180
{
181
if
(
m_IsRunning
)
182
{
183
if
(
m_TimeElapsedSequence
> (
m_SequenceTick
*
m_CurrentDropProbabilityStep
))
184
{
185
if
(
m_CurrentDropProbabilityStep
<
m_DropProbabilityRollsCount
)
186
{
187
float
rnd =
Math
.
RandomFloat01
();
188
if
(rnd <
m_DropProbabilityArray
[
m_CurrentDropProbabilityStep
])
189
{
190
m_DropSpawnsQueued
++;
191
}
192
193
m_CurrentDropProbabilityStep
++;
194
}
195
}
196
197
float
sinceLastDrop =
m_TimeElapsedTotal
-
m_LastDropSpawnTime
;
198
if
(
m_TimeElapsedSequence
>
m_SequenceDuration
)
199
{
200
ResetSequence
();
201
}
202
else
if
(
m_DropSpawnsQueued
> 0)
//spawn queued drop
203
{
204
if
(sinceLastDrop >=
m_DropSpawnMinDelay
)
205
{
206
TrySpawnNextDrop
();
207
}
208
}
209
else
if
(sinceLastDrop >
m_DropSpawnMaxDelay
)
210
{
211
TrySpawnNextDrop
();
//guaranteed drop
212
m_CurrentDropProbabilityStep
++;
//substitutes a regular roll..
213
}
214
}
215
else
//1st drop ignores delay
216
{
217
StartRunningDrops
();
218
}
219
}
220
221
for
(
int
i = 0; i <
m_ActiveDropsCount
; i++)
222
{
223
if
(!
m_EndNow
)
224
{
225
//Simulate drops
226
m_ActiveDrops
[i].Update(timeSlice);
227
}
228
else
229
{
230
m_ActiveDrops
[i].StopDrop();
231
}
232
233
if
(!
m_ActiveDrops
[i].
IsRunning
())
234
{
235
m_CleanupQueue
.Insert(i);
236
}
237
}
238
239
//Cleanup drops
240
for
(i =
m_CleanupQueue
.Count() - 1; i >= 0; i--)
241
{
242
m_ActiveDrops
.Remove(
m_CleanupQueue
[i]);
243
m_ActiveDropsCount
--;
244
}
245
m_CleanupQueue
.Clear();
246
247
if
(
m_Terminating
&& !
IsRunningDrops
())
248
{
249
m_EndNow
=
true
;
250
}
251
252
m_TimeElapsedTotal
+= timeSlice;
253
m_TimeElapsedSequence
+= timeSlice;
254
}
255
256
bool
GetEndNow
()
257
{
258
return
m_EndNow
;
259
}
260
261
int
GetSeverity
()
262
{
263
return
m_Severity
;
264
}
265
}
int
Param3 int
BleedingIndicationConstants
Definition
bleedingindicationconstants.c:2
BleedingIndicationConstants::SEQUENCE_DURATION_MEDIUM
static const float SEQUENCE_DURATION_MEDIUM
Definition
bleedingindicationconstants.c:37
BleedingIndicationConstants::INDICATOR_SEVERITY_MEDIUM
static const int INDICATOR_SEVERITY_MEDIUM
Definition
bleedingindicationconstants.c:6
BleedingIndicationConstants::SEQUENCE_DROP_DELAY_MIN_LOW
static const float SEQUENCE_DROP_DELAY_MIN_LOW
Definition
bleedingindicationconstants.c:27
BleedingIndicationConstants::SEQUENCE_DROP_DELAY_MIN_HIGH
static const float SEQUENCE_DROP_DELAY_MIN_HIGH
Definition
bleedingindicationconstants.c:53
BleedingIndicationConstants::SEQUENCE_DURATION_LOW
static const float SEQUENCE_DURATION_LOW
Definition
bleedingindicationconstants.c:24
BleedingIndicationConstants::SEQUENCE_DROP_AVERAGE_MEDIUM
static const float SEQUENCE_DROP_AVERAGE_MEDIUM
Definition
bleedingindicationconstants.c:38
BleedingIndicationConstants::SEQUENCE_DROP_DELAY_MAX_MEDIUM
static const float SEQUENCE_DROP_DELAY_MAX_MEDIUM
Definition
bleedingindicationconstants.c:41
BleedingIndicationConstants::SEQUENCE_DROP_AVERAGE_LOW
static const float SEQUENCE_DROP_AVERAGE_LOW
Definition
bleedingindicationconstants.c:25
BleedingIndicationConstants::SEQUENCE_DROP_DELAY_MIN_MEDIUM
static const float SEQUENCE_DROP_DELAY_MIN_MEDIUM
Definition
bleedingindicationconstants.c:40
BleedingIndicationConstants::INDICATOR_SEVERITY_HIGH
static const int INDICATOR_SEVERITY_HIGH
Definition
bleedingindicationconstants.c:7
BleedingIndicationConstants::SEQUENCE_DROP_DELAY_MAX_LOW
static const float SEQUENCE_DROP_DELAY_MAX_LOW
Definition
bleedingindicationconstants.c:28
BleedingIndicationConstants::SEQUENCE_DROP_AVERAGE_HIGH
static const float SEQUENCE_DROP_AVERAGE_HIGH
Definition
bleedingindicationconstants.c:51
BleedingIndicationConstants::SEQUENCE_DROP_DELAY_MAX_HIGH
static const float SEQUENCE_DROP_DELAY_MAX_HIGH
Definition
bleedingindicationconstants.c:54
BleedingIndicationConstants::SEQUENCE_DURATION_HIGH
static const float SEQUENCE_DURATION_HIGH
Definition
bleedingindicationconstants.c:50
BleedingIndicationConstants::INDICATOR_SEVERITY_LOW
static const int INDICATOR_SEVERITY_LOW
Definition
bleedingindicationconstants.c:5
BleedingIndicatorDropData
Definition
bleedingdrop.c:3
BleedingIndicatorDropData::SetBasePosition
void SetBasePosition(vector pos)
Definition
bleedingdrop.c:182
BleedingIndicatorDropData::StartDrop
void StartDrop()
Definition
bleedingdrop.c:154
Class
Super root of all classes in Enforce script.
Definition
enscript.c:11
DbgBleedingIndicationStaticInfo
static info (non-constants)
Definition
bleedingindicationstaticinfo.c:3
DbgBleedingIndicationStaticInfo::m_DbgSequenceDuration
static float m_DbgSequenceDuration
Definition
bleedingindicationstaticinfo.c:7
DbgBleedingIndicationStaticInfo::m_DbgDropMinDelay
static float m_DbgDropMinDelay
Definition
bleedingindicationstaticinfo.c:9
DbgBleedingIndicationStaticInfo::m_DbgDropMaxDelay
static float m_DbgDropMaxDelay
Definition
bleedingindicationstaticinfo.c:10
DbgBleedingIndicationStaticInfo::m_DbgUseOverrideValues
static bool m_DbgUseOverrideValues
Definition
bleedingindicationstaticinfo.c:5
Debug
Definition
debug.c:2
Debug::Log
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition
debug.c:182
Managed
TODO doc.
Definition
enscript.c:118
Managed::ResetIndicator
void ResetIndicator()
Definition
bleedingindicator.c:152
Managed::m_IsRunning
bool m_IsRunning
Definition
bleedingindicator.c:8
Managed::GetEndNow
bool GetEndNow()
Definition
bleedingindicator.c:256
Managed::m_AverageFrequency
float m_AverageFrequency
Definition
bleedingindicator.c:16
Managed::m_BasePosition
vector m_BasePosition
Definition
bleedingindicator.c:26
Managed::Update
void Update(float timeSlice)
Definition
bleedingindicator.c:163
Managed::m_DropSpawnMinDelay
float m_DropSpawnMinDelay
Definition
bleedingindicator.c:22
Managed::m_DropProbabilityRollsCount
int m_DropProbabilityRollsCount
Definition
bleedingindicator.c:25
Managed::m_LastDropSpawnTime
float m_LastDropSpawnTime
Definition
bleedingindicator.c:21
Managed::m_Terminating
bool m_Terminating
Definition
bleedingindicator.c:6
Managed::GetSeverity
int GetSeverity()
Definition
bleedingindicator.c:261
Managed::m_CleanupQueue
ref set< int > m_CleanupQueue
Definition
bleedingindicator.c:29
Managed::m_ActiveDrops
ref set< ref BleedingIndicatorDropData > m_ActiveDrops
Definition
bleedingindicator.c:28
Managed::m_DropSpawnsQueued
int m_DropSpawnsQueued
Definition
bleedingindicator.c:9
Managed::m_CurrentDropProbabilityStep
int m_CurrentDropProbabilityStep
Definition
bleedingindicator.c:24
Managed::IsRunningDrops
bool IsRunningDrops()
Are any drops currently being animated?
Definition
bleedingindicator.c:123
Managed::m_Initialized
static bool m_Initialized
Definition
pperequesterbank.c:7
Managed::m_DropProbabilityArray
array< float > m_DropProbabilityArray
Definition
bleedingindicator.c:14
Managed::BleedingIndicator
void BleedingIndicator(int source_ID, int severity, GameplayEffectsDataBleeding parent)
Definition
bleedingindicator.c:31
Managed::m_SequenceTick
float m_SequenceTick
Definition
bleedingindicator.c:17
Managed::m_DropSpawnMaxDelay
float m_DropSpawnMaxDelay
Definition
bleedingindicator.c:23
Managed::m_ActiveDropsCount
int m_ActiveDropsCount
Definition
bleedingindicator.c:10
Managed::ResetSequence
void ResetSequence()
Definition
bleedingindicator.c:145
Managed::m_SourceID
int m_SourceID
Definition
bleedingindicator.c:12
Managed::m_TimeElapsedTotal
float m_TimeElapsedTotal
Definition
bleedingindicator.c:19
Managed::m_Severity
int m_Severity
Definition
bleedingindicator.c:11
Managed::m_TimeElapsedSequence
float m_TimeElapsedSequence
Definition
bleedingindicator.c:20
Managed::StartRunningDrops
void StartRunningDrops()
Definition
bleedingindicator.c:112
Managed::m_EndNow
bool m_EndNow
Definition
bleedingindicator.c:7
Managed::m_ParentMetaData
GameplayEffectsDataBleeding m_ParentMetaData
Definition
bleedingindicator.c:13
Managed::InitIndicator
void InitIndicator(vector position)
Definition
bleedingindicator.c:91
Managed::TrySpawnNextDrop
void TrySpawnNextDrop()
Definition
bleedingindicator.c:128
Managed::StopIndicator
void StopIndicator(bool instant=false)
Definition
bleedingindicator.c:98
Managed::m_SequenceDuration
float m_SequenceDuration
Definition
bleedingindicator.c:18
Math
Definition
enmath.c:7
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
vector
Definition
enconvert.c:119
Class::CastTo
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
Math::RandomFloat01
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Definition
enmath.c:126
IsRunning
bool IsRunning()
Definition
tools.c:264
Games
Dayz
scripts
5_mission
mission
gameplayeffectwidgets
bleedingindicators
bleedingindicator.c
Generated by
1.17.0