Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
geyserarea.c
Go to the documentation of this file.
1
enum
EGeyserState
2
{
3
DORMANT
= 0,
4
ERUPTION_SOON
= 1,
// bubbling
5
ERUPTING_PRIMARY
= 2,
// main particle
6
ERUPTING_SECONDARY
= 4
// secondary tall particle
7
}
8
9
class
GeyserArea : EffectArea
10
{
11
protected
const
int
UPDATE_RATE
= 1000;
// ms
12
protected
const
float
PRE_ERUPTION_DURATION
= 10;
// delay before the geysier activates (sec)
13
protected
const
float
ERUPTION_TALL_DURATION
= 3;
// lenght of secondary eruption (sec)
14
protected
const
float
ERUPTION_TALL_DELAY
= 3;
// min delay between secondary eruptions (sec)
15
16
protected
bool
m_SecondaryActive
;
17
18
protected
int
m_TimeElapsed
;
// seconds
19
protected
int
m_TimeSecondaryElapsed
;
// seconds
20
protected
float
m_RandomizedInterval
;
// randomized interval to 80% - 120% of the set value
21
protected
float
m_RandomizedDuration
;
// randomized duration to 80% - 120% of the set value
22
protected
GeyserTrigger
m_GeyserTrigger
;
23
24
override
void
DeferredInit
()
25
{
26
super.DeferredInit();
27
28
InitZone
();
29
}
30
31
override
void
EEDelete
(
EntityAI
parent )
32
{
33
if
(
g_Game
.IsClient() &&
m_GeyserTrigger
)
34
m_GeyserTrigger
.StopEffects();
35
36
super.EEDelete( parent );
37
}
38
39
override
void
InitZoneServer
()
40
{
41
super.InitZoneServer();
42
43
if
( m_TriggerType !=
""
)
44
{
45
CreateTrigger
(m_PositionTrigger,
m_Radius
);
46
m_GeyserTrigger
=
GeyserTrigger
.Cast(m_Trigger);
47
}
48
49
g_Game
.GetCallQueue(
CALL_CATEGORY_SYSTEM
).CallLater(
TickState
,
UPDATE_RATE
,
true
);
50
51
RandomizeIntervals
();
52
}
53
54
void
TickState
()
55
{
56
m_TimeElapsed
+=
UPDATE_RATE
* 0.001;
57
58
if
(
m_GeyserTrigger
.CheckGeyserState(
EGeyserState
.DORMANT))
59
{
60
if
(
m_TimeElapsed
>
PRE_ERUPTION_DURATION
)
61
{
62
#ifdef ENABLE_LOGGING
63
Debug
.
Log
(
m_Name
+
": ERUPTION_SOON, interval: "
+
m_RandomizedInterval
+
" sec"
);
64
#endif
65
66
m_GeyserTrigger
.AddGeyserState(
EGeyserState
.ERUPTION_SOON);
67
68
m_TimeElapsed
= 0;
69
}
70
}
71
else
if
(
m_GeyserTrigger
.CheckGeyserState(
EGeyserState
.ERUPTION_SOON))
72
{
73
if
(
m_TimeElapsed
>
m_RandomizedInterval
)
74
{
75
#ifdef ENABLE_LOGGING
76
Debug
.
Log
(
m_Name
+
": ERUPTING_PRIMARY, interval: "
+
m_RandomizedDuration
+
" sec"
);
77
#endif
78
79
m_GeyserTrigger
.RemoveGeyserState(
EGeyserState
.ERUPTION_SOON);
80
m_GeyserTrigger
.AddGeyserState(
EGeyserState
.ERUPTING_PRIMARY);
81
82
KillEntitiesInArea
();
83
84
m_TimeSecondaryElapsed
= -1;
85
m_SecondaryActive
=
false
;
86
m_TimeElapsed
= 0;
87
}
88
}
89
else
if
(
m_GeyserTrigger
.CheckGeyserState(
EGeyserState
.ERUPTING_PRIMARY))
90
{
91
if
(
m_TimeElapsed
>
m_RandomizedDuration
)
92
{
93
RandomizeIntervals
();
94
95
#ifdef ENABLE_LOGGING
96
Debug
.
Log
(
m_Name
+
": ERUPTION_SOON, interval: "
+
m_RandomizedInterval
+
" sec"
);
97
#endif
98
99
m_GeyserTrigger
.RemoveGeyserState(
EGeyserState
.ERUPTING_PRIMARY);
100
m_GeyserTrigger
.RemoveGeyserState(
EGeyserState
.ERUPTING_SECONDARY);
101
m_GeyserTrigger
.AddGeyserState(
EGeyserState
.ERUPTION_SOON);
102
103
m_TimeElapsed
= 0;
104
}
105
else
if
(
Math
.
IsInRange
(
m_TimeElapsed
,
ERUPTION_TALL_DELAY
,
m_RandomizedDuration
-
ERUPTION_TALL_DURATION
))
// Ensure burst do not overlap with state transitions
106
{
107
if
(!
m_SecondaryActive
&&
m_TimeSecondaryElapsed
< 0)
108
{
109
if
(
Math
.
RandomBool
())
// 50% chance to start secondary eruption every update
110
{
111
m_GeyserTrigger
.AddGeyserState(
EGeyserState
.ERUPTING_SECONDARY);
112
113
m_TimeSecondaryElapsed
= 0;
114
m_SecondaryActive
=
true
;
115
}
116
}
117
else
if
(
m_TimeSecondaryElapsed
>= 0)
118
{
119
m_TimeSecondaryElapsed
+=
UPDATE_RATE
* 0.001;
120
121
if
(
m_SecondaryActive
&&
m_TimeSecondaryElapsed
>
ERUPTION_TALL_DURATION
)
122
{
123
m_GeyserTrigger
.RemoveGeyserState(
EGeyserState
.ERUPTING_SECONDARY);
124
m_SecondaryActive
=
false
;
125
}
126
else
if
(
m_TimeSecondaryElapsed
> (
ERUPTION_TALL_DURATION
+
ERUPTION_TALL_DELAY
))
127
{
128
m_TimeSecondaryElapsed
= -1;
129
}
130
}
131
}
132
}
133
}
134
135
private
void
RandomizeIntervals
()
136
{
137
m_RandomizedInterval
=
Math
.
RandomInt
(m_EffectInterval * 0.8, m_EffectInterval * 1.2);
138
m_RandomizedDuration
=
Math
.
RandomInt
(m_EffectDuration * 0.8, m_EffectDuration * 1.2);
139
}
140
141
void
KillEntitiesInArea
()
142
{
143
array<Object>
nearestObjects =
new
array<Object>
();
144
g_Game
.GetObjectsAtPosition(
m_Position
,
m_Radius
, nearestObjects, null);
145
146
foreach
(
Object
obj : nearestObjects)
147
{
148
EntityAI
entity =
EntityAI
.Cast(obj);
149
if
(entity)
150
entity.ProcessDirectDamage(
DamageType
.CUSTOM,
this
,
""
,
"HeatDamage"
,
"0 0 0"
, 1000);
151
}
152
}
153
}
m_Name
string m_Name
Definition
inventoryitemtype.c:34
m_Radius
float m_Radius
Definition
aigroupbehaviour.c:10
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
EntityAI
Definition
inventoryitem.c:2
GeyserTrigger
Definition
geysertrigger.c:2
Math
Definition
enmath.c:7
Object
Definition
objecttyped.c:2
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
DeferredInit
override void DeferredInit()
Definition
contaminatedarea.c:49
InitZoneServer
override void InitZoneServer()
Definition
contaminatedarea.c:56
EEDelete
override void EEDelete(EntityAI parent)
Definition
contaminatedarea.c:61
InitZone
override void InitZone()
Definition
contaminatedarea_dynamicbase.c:61
DamageType
DamageType
exposed from C++ (do not change)
Definition
damagesystem.c:11
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
m_Position
vector m_Position
Cached world position.
Definition
effect.c:43
m_SecondaryActive
bool m_SecondaryActive
Definition
geyserarea.c:16
m_GeyserTrigger
GeyserTrigger m_GeyserTrigger
Definition
geyserarea.c:22
RandomizeIntervals
void RandomizeIntervals()
Definition
geyserarea.c:135
m_TimeElapsed
int m_TimeElapsed
Definition
geyserarea.c:18
m_TimeSecondaryElapsed
int m_TimeSecondaryElapsed
Definition
geyserarea.c:19
KillEntitiesInArea
void KillEntitiesInArea()
Definition
geyserarea.c:141
m_RandomizedInterval
float m_RandomizedInterval
Definition
geyserarea.c:20
ERUPTION_TALL_DURATION
const float ERUPTION_TALL_DURATION
Definition
geyserarea.c:13
m_RandomizedDuration
float m_RandomizedDuration
Definition
geyserarea.c:21
ERUPTION_TALL_DELAY
const float ERUPTION_TALL_DELAY
Definition
geyserarea.c:14
PRE_ERUPTION_DURATION
const float PRE_ERUPTION_DURATION
Definition
geyserarea.c:12
TickState
void TickState()
Definition
geyserarea.c:54
UPDATE_RATE
enum EGeyserState UPDATE_RATE
EGeyserState
EGeyserState
Definition
geyserarea.c:2
ERUPTION_SOON
@ ERUPTION_SOON
Definition
geyserarea.c:4
DORMANT
@ DORMANT
Definition
geyserarea.c:3
ERUPTING_SECONDARY
@ ERUPTING_SECONDARY
Definition
geyserarea.c:6
ERUPTING_PRIMARY
@ ERUPTING_PRIMARY
Definition
geyserarea.c:5
Math::RandomInt
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
Math::IsInRange
static proto bool IsInRange(float v, float min, float max)
Returns if value is between min and max (inclusive).
Math::RandomBool
static bool RandomBool()
Returns a random bool .
Definition
enmath.c:73
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition
tools.c:8
CreateTrigger
void CreateTrigger()
Definition
trapbase.c:465
Games
Dayz
scripts
4_world
classes
contaminatedarea
geyserarea.c
Generated by
1.17.0