Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
geysertrigger.c
Go to the documentation of this file.
2{
3 const float MOUTH_ADJUST_RADIUS = 0.2; // maxium radius geyser effect can move when using randomized position adjustment
4 const string SOUND_BUBBLING = "Geyser_bubbling_loop_SoundSet";
5 const string SOUND_ERUPTION = "Geyser_eruption_loop_SoundSet";
6 const string SOUND_ERUPTION_START = "Geyser_eruption_start_SoundSet";
7 const string SOUND_ERUPTION_TALL = "Geyser_eruption_tall_loop_SoundSet";
8 const string SOUND_ERUPTION_TALL_START = "Geyser_eruption_tall_start_SoundSet";
9 const string SOUND_ERUPTION_TALL_END = "Geyser_eruption_tall_splash_SoundSet";
10
11 protected bool m_bIsDormant;
12 protected bool m_bIsEruptingSoon;
13 protected bool m_bIsErupting;
14 protected bool m_bIsEruptingTall;
15 protected float m_AdjustedX; //deprecated
16 protected float m_AdjustedY; //deprecated
18 protected EGeyserState m_GeyserState = EGeyserState.DORMANT; // synchronized state
19
30
32 {
33 RegisterNetSyncVariableInt("m_GeyserState", 0, 32);
34 }
35
36 override void DeferredInit()
37 {
38 super.DeferredInit();
39
41
42 if (IsSubmerged())
44
45 if (!GetGame().IsDedicatedServer())
47 }
48
49 override string GetDisplayName()
50 {
51 return "#STR_geyser";
52 }
53
54 override void EEDelete( EntityAI parent )
55 {
57
58 super.EEDelete(parent);
59 }
60
61 override void OnEnterServerEvent( TriggerInsider insider )
62 {
63 super.OnEnterServerEvent(insider);
64
65 if (insider && (m_GeyserState & EGeyserState.ERUPTING_PRIMARY))
66 {
67 EntityAI entity = EntityAI.Cast(insider.GetObject());
68 if (entity)
69 entity.ProcessDirectDamage(DamageType.CUSTOM, this, "", "HeatDamage", "0 0 0", 1000);
70 }
71 }
72
73 override void OnLeaveServerEvent( TriggerInsider insider )
74 {
75 super.OnLeaveServerEvent(insider);
76 }
77
78 override void OnEnterClientEvent( TriggerInsider insider )
79 {
80 super.OnEnterClientEvent(insider);
81 }
82
83 override void OnLeaveClientEvent( TriggerInsider insider )
84 {
85 super.OnLeaveClientEvent(insider);
86 }
87
89 {
90 super.OnVariablesSynchronized();
91
92 if (IsInitialized())
94 }
95
96 // Updated from OnVariablesSynchronized
97 protected void UpdateGeyserState()
98 {
99 // Debug.Log("UpdateGeyserState, state: " + m_GeyserState);
100
102 {
103 m_bIsDormant = true;
104 }
105 else if (!CheckGeyserState(EGeyserState.DORMANT) && m_bIsDormant)
106 {
107 m_bIsDormant = false;
108 }
109
110 if (CheckGeyserState(EGeyserState.ERUPTION_SOON) && !m_bIsEruptingSoon)
111 {
113 m_SoundBubbling = SEffectManager.PlaySound(SOUND_BUBBLING, m_DefaultPosition, 2, 2, true);
114
115 m_bIsEruptingSoon = true;
116 }
117 else if (!CheckGeyserState(EGeyserState.ERUPTION_SOON) && m_bIsEruptingSoon)
118 {
119 m_GeyserBubblesParticle.StopParticle();
121
122 m_bIsEruptingSoon = false;
123 }
124
125 if (CheckGeyserState(EGeyserState.ERUPTING_PRIMARY) && !m_bIsErupting)
126 {
128
129 m_SoundEruptionStart = SEffectManager.PlaySound(SOUND_ERUPTION_START, m_DefaultPosition, 0, 0, false);
130 m_SoundEruption = SEffectManager.PlaySound(SOUND_ERUPTION, m_DefaultPosition, 2, 2, true);
131
132 m_bIsErupting = true;
133 }
134 else if (!CheckGeyserState(EGeyserState.ERUPTING_PRIMARY) && m_bIsErupting)
135 {
136 m_GeyserParticle.StopParticle();
137
140
141 m_bIsErupting = false;
142 }
143
144 if (CheckGeyserState(EGeyserState.ERUPTING_SECONDARY) && !m_bIsEruptingTall)
145 {
147
148 m_SoundEruptionSecondaryStart = SEffectManager.PlaySound(SOUND_ERUPTION_TALL_START, m_DefaultPosition, 0, 0, false);
149 m_SoundEruptionSecondary = SEffectManager.PlaySound(SOUND_ERUPTION_TALL, m_DefaultPosition, 0, 0, false);
150
151 m_bIsEruptingTall = true;
152 }
153 else if (!CheckGeyserState(EGeyserState.ERUPTING_SECONDARY) && m_bIsEruptingTall)
154 {
156 m_SoundEruptionSecondaryEnd = SEffectManager.PlaySound(SOUND_ERUPTION_TALL_END, m_DefaultPosition, 0, 0, false);
157
158 m_GeyserTallParticle.StopParticle();
161
162 m_bIsEruptingTall = false;
163 }
164 }
165
166 // Slightly adjust position of geyser particles
167 protected void RandomizeMouthPos()
168 {
169 m_DefaultPosition[0] = m_DefaultPosition[0] + Math.RandomFloat( -MOUTH_ADJUST_RADIUS, MOUTH_ADJUST_RADIUS);
170 m_DefaultPosition[2] = m_DefaultPosition[2] + Math.RandomFloat( -MOUTH_ADJUST_RADIUS, MOUTH_ADJUST_RADIUS);
171
172 //for backwards compatibility
174 m_AdjustedY = m_DefaultPosition[2]; //typo, should be Z
175 }
176
177 // Get position on surface of water volume or terrain, add height offset
178 protected vector GetAdjustedPosition(float height = 0)
179 {
180 vector pos = GetPosition();
181 pos[1] = GetGame().SurfaceRoadY(pos[0], pos[2], RoadSurfaceDetection.UNDER) + height;
182
183 return pos;
184 }
185
187 {
189 {
190 m_GeyserBubblesParticle.StopParticle();
192 m_bIsEruptingSoon = false;
193 }
194
195 if (m_bIsErupting)
196 {
197 m_GeyserParticle.StopParticle();
199 m_bIsErupting = false;
200 }
201
203 {
204 m_GeyserTallParticle.StopParticle();
206 m_bIsEruptingTall = false;
207 }
208 }
209
211 {
212 m_GeyserState |= state;
213 SetSynchDirty();
214 }
215
217 {
218 m_GeyserState &= ~state;
219 SetSynchDirty();
220 }
221
223 {
224 if (state == EGeyserState.DORMANT)
225 return (m_GeyserState == state);
226 else
227 return (m_GeyserState & state);
228 }
229
231 {
232 return m_GeyserState;
233 }
234
235 // override for differences in logic between land & submerged geysers
237 {
238 return true;
239 }
240
241
242}
proto native float SurfaceRoadY(float x, float z, RoadSurfaceDetection rsd=RoadSurfaceDetection.LEGACY)
Wrapper class for managing sound through SEffectManager.
Definition effectsound.c:5
override void Stop()
Stops sound.
override void OnVariablesSynchronized()
EffectSound m_SoundEruptionSecondary
ParticleSource m_GeyserParticle
ParticleSource m_GeyserTallParticle
override void OnLeaveServerEvent(TriggerInsider insider)
void RemoveGeyserState(EGeyserState state)
EffectSound m_SoundBubbling
override void OnLeaveClientEvent(TriggerInsider insider)
EGeyserState GetGeyserState()
vector GetAdjustedPosition(float height=0)
bool CheckGeyserState(EGeyserState state)
EffectSound m_SoundEruptionSecondaryStart
override void OnEnterClientEvent(TriggerInsider insider)
override void EEDelete(EntityAI parent)
void UpdateGeyserState()
ParticleSource m_GeyserSplashParticle
vector m_DefaultPosition
EffectSound m_SoundEruption
void AddGeyserState(EGeyserState state)
override void DeferredInit()
override void OnEnterServerEvent(TriggerInsider insider)
void RandomizeMouthPos()
EffectSound m_SoundEruptionStart
ParticleSource m_GeyserBubblesParticle
EffectSound m_SoundEruptionSecondaryEnd
void GeyserTrigger()
EGeyserState m_GeyserState
override string GetDisplayName()
Definition enmath.c:7
Entity which has the particle instance as an ObjectComponent.
static override Particle PlayInWorld(int particle_id, vector global_pos)
Creates a particle emitter on the given position and activates it.
Manager class for managing Effect (EffectParticle, EffectSound)
static EffectSound PlaySound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
The object which is in a trigger and its metadata.
override bool IsInitialized()
DamageType
exposed from C++ (do not change)
proto native CGame GetGame()
EGeyserState
Definition geyserarea.c:2
class JsonUndergroundAreaTriggerData GetPosition
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)