Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
geyserarea.c
Go to the documentation of this file.
2{
3 DORMANT = 0,
4 ERUPTION_SOON = 1, // bubbling
5 ERUPTING_PRIMARY = 2, // main particle
6 ERUPTING_SECONDARY = 4 // secondary tall particle
8
9class 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
23
24 override void DeferredInit()
25 {
26 super.DeferredInit();
27
28 InitZone();
29 }
30
31 override void EEDelete( EntityAI parent )
32 {
33 if (GetGame().IsClient() && m_GeyserTrigger)
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 GetGame().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
59 {
61 {
62 #ifdef ENABLE_LOGGING
63 Debug.Log(m_Name + ": ERUPTION_SOON, interval: " + m_RandomizedInterval + " sec");
64 #endif
65
67
68 m_TimeElapsed = 0;
69 }
70 }
71 else if (m_GeyserTrigger.CheckGeyserState(EGeyserState.ERUPTION_SOON))
72 {
74 {
75 #ifdef ENABLE_LOGGING
76 Debug.Log(m_Name + ": ERUPTING_PRIMARY, interval: " + m_RandomizedDuration + " sec");
77 #endif
78
81
82 KillEntitiesInArea();
83
85 m_SecondaryActive = false;
86 m_TimeElapsed = 0;
87 }
88 }
89 else if (m_GeyserTrigger.CheckGeyserState(EGeyserState.ERUPTING_PRIMARY))
90 {
92 {
93 RandomizeIntervals();
94
95 #ifdef ENABLE_LOGGING
96 Debug.Log(m_Name + ": ERUPTION_SOON, interval: " + m_RandomizedInterval + " sec");
97 #endif
98
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 {
108 {
109 if (Math.RandomBool()) // 50% chance to start secondary eruption every update
110 {
111 m_GeyserTrigger.AddGeyserState(EGeyserState.ERUPTING_SECONDARY);
112
114 m_SecondaryActive = true;
115 }
116 }
117 else if (m_TimeSecondaryElapsed >= 0)
118 {
120
122 {
124 m_SecondaryActive = false;
125 }
127 {
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 GetGame().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}
float m_Radius
Definition debug.c:2
void RemoveGeyserState(EGeyserState state)
bool CheckGeyserState(EGeyserState state)
void AddGeyserState(EGeyserState state)
override void DeferredInit()
Definition enmath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
override void DeferredInit()
override void InitZoneServer()
override void EEDelete(EntityAI parent)
override void InitZone()
DamageType
exposed from C++ (do not change)
vector m_Position
Cached world position.
Definition effect.c:43
proto native CGame GetGame()
bool m_SecondaryActive
Definition geyserarea.c:16
GeyserTrigger m_GeyserTrigger
Definition geyserarea.c:22
int m_TimeElapsed
Definition geyserarea.c:18
int m_TimeSecondaryElapsed
Definition geyserarea.c:19
float m_RandomizedInterval
Definition geyserarea.c:20
const float ERUPTION_TALL_DURATION
Definition geyserarea.c:13
float m_RandomizedDuration
Definition geyserarea.c:21
const float ERUPTION_TALL_DELAY
Definition geyserarea.c:14
const float PRE_ERUPTION_DURATION
Definition geyserarea.c:12
void TickState()
Definition geyserarea.c:54
enum EGeyserState UPDATE_RATE
EGeyserState
Definition geyserarea.c:2
@ ERUPTION_SOON
Definition geyserarea.c:4
@ DORMANT
Definition geyserarea.c:3
@ ERUPTING_SECONDARY
Definition geyserarea.c:6
@ ERUPTING_PRIMARY
Definition geyserarea.c:5
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
class SyncedValue m_Name
void CreateTrigger()
Definition trapbase.c:475