DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
Land_Underground_Entrance.c
Go to the documentation of this file.
2{
4 CLOSED,//fully closed
5 //opening
10 OPENING_E,//fully open
13 //closing
21}
22
23enum EUndegroundDoorType
24{
27}
28
29class AlarmLight : SpotlightLight
30{
31 void AlarmLight()
32 {
33 SetVisibleDuringDaylight(true);
34 SetRadiusTo(15);
35 SetBrightnessTo(10);
36 SetFlareVisible(false);
37 SetAmbientColor(1.0, 0.0, 0.0);
38 SetDiffuseColor(1.0, 0.0, 0.0);
39 SetLifetime(1000);
40 SetDisableShadowsWithinRadius(-1);
41 SetFadeOutTime(1);
42 SetCastShadow(false);
43 m_FadeInTime = 0.25;
44 }
47//---------------------------------------------------------------------------------------------------------
48//------------------------------------ Land_Underground_EntranceBase --------------------------------------
49//---------------------------------------------------------------------------------------------------------
50
52{
59 EUndegroundDoorType m_DoorType;
60
64
66 {
67 m_DoorType = EUndegroundDoorType.MAIN;
68 Land_Underground_Panel.RegisterEntrance(this);
69 RegisterNetSyncVariableFloat("m_AnimPhase", 0,1,5);
70 RegisterNetSyncVariableInt("m_DoorState", 0, EnumTools.GetLastEnumValue(EUndegroundEntranceState));
71
72 #ifndef SERVER
74 #endif
75 }
76
78
80 {
81 Land_Underground_Panel.UnregisterEntrance(this);
82 #ifndef SERVER
84 #endif
85 }
86 //---------------------
87
88
90 {
91 //anything we might have started playing when the door was activated
93 }
94
95
97
98 bool CanManipulate(Param param = null)
99 {
100 return m_DoorState == EUndegroundEntranceState.CLOSED;
101 }
102
103 void Manipulate(Param param = null)
104 {
105 OpenServer();
106 }
107
109 {
111 }
112
113 void OnUpdateClient(float timeSlice);
114
115 override void EOnPostSimulate(IEntity other, float timeSlice)
116 {
117 #ifndef SERVER
118 OnUpdateClient(timeSlice);
119 #endif
120 }
121
123 {
125 SetAnimationPhaseNow("EntranceDoor",m_AnimPhase);
126 SetSynchDirty();
127 }
128
130 {
131 if (!Land_Underground_Panel.m_Panels)
132 {
133 return;
134 }
136 {
137 if (p.GetClosestDoor() == this)
138 {
139 panels.Insert(p);
140 }
141 }
142 }
143
144 // checks whether we want to play this effect even when we are at a different(more advanced) state, as this effect is supposed to be playing over multiple states and was supposed to start during some earlier state switch
145 // param 'state' is the state this effect is supposed to be played in, and 'lastValidState' is the latests state where we still want to play this effect provided previous state for the client is UNINITIALIZED
146 // meaning the client just connected in/the item entered their multiplayer bubble
148 {
149 return m_DoorState == state || ( IsInitDoorStateSync() && m_DoorState > state && m_DoorState <= lastValidState);
150 }
151
152 float AdjustTime(float originalTime, float adjustedTime = -1)
153 {
154 #ifdef DIAG_DEVELOPER
155 float timeAccel = 1;
156
157 if (adjustedTime != -1)
158 {
159 return adjustedTime;
160 }
161 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.UNDERGROUND_ENTRANCE))
162 {
163 timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
164 return originalTime / timeAccel;
165 }
166 #endif
167 return originalTime;
168 }
169
171 {
172 return 30;
173 }
174
176 {
177 if (targetState == EUndegroundEntranceState.UNINITIALIZED)
178 {
179 targetState = m_DoorState + 1;
180 }
181 GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( SetDoorStateServer, time * 1000, false, targetState);
182 }
183
185 {
186 m_DoorState = newState;
187 OnDoorStateChangedServer(newState);
188 SetSynchDirty();
189 }
190
192
194 {
195 if (newState > EUndegroundEntranceState.CLOSED)
196 {
197 SetEventMask(EntityEvent.POSTSIMULATE);
198 }
199 else
200 {
201 ClearEventMask(EntityEvent.POSTSIMULATE);
203 }
204
205 HandleAudioPlayback(newState, prevState);
206 HandleVisualPlayback(newState, prevState);
207
209 {
212 }
214 {
215 p.OnDoorStateChangedClient(newState, prevState);
216 }
217 }
218
219 void OpenServer(bool force = false)
220 {
222 if (m_DoorState == EUndegroundEntranceState.CLOSED || force)
223 {
225 }
226 }
227
230
232
234 {
235 super.OnVariablesSynchronized();
236
238 {
241 }
242 }
243
245 {
246 return m_DoorStatePrev == EUndegroundEntranceState.UNINITIALIZED;
247 }
248
249
250 #ifdef DEVELOPER
251 override string GetDebugText()
252 {
253 string debug_output;
254
255 if (GetGame().IsDedicatedServer())
256 {
257 debug_output += "current state: " + typename.EnumToString(EUndegroundEntranceState, m_DoorState) + "\n";
258 /*
259 if(GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ))
260 debug_output += "next stage timer: " + GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).GetRemainingTimeByName(this, "SetDoorStateServer").ToString();
261 */
262 }
263 else
264 {
265 debug_output += "current state: " + typename.EnumToString(EUndegroundEntranceState, m_DoorState) + "\n";
266 }
267 return debug_output;
268 }
269
270 override void OnDebugButtonPressServer(int button_index)
271 {
272 if (button_index == 1)
273 {
275 OpenServer(true);
276 }
277
278 if (button_index == 2)
279 {
280 // just for debug controls
283
284 if (m_DoorState == EUndegroundEntranceState.OPENING_G)
285 {
288 }
289 }
290 }
291
292 override void GetDebugButtonNames(out string button1, out string button2, out string button3, out string button4)
293 {
294 button1 = "Open";
295 button2 = "Close";
296 }
297 #endif
298}
299
300
301//---------------------------------------------------------------------------------------------------------
302//-------------------------------------- Land_Underground_Entrance ----------------------------------------
303//---------------------------------------------------------------------------------------------------------
304
305class Land_Underground_Entrance : Land_Underground_EntranceBase
306{
315
316
318
319 const string SIREN_SOUNDSET = "UndergroundDoor_Alarm_Loop_SoundSet";
320 const string ENGINE_SOUNDSET_LOOP_IN = "UndergroundDoor_ElectricMotor_Start_SoundSet";
321 const string ENGINE_SOUNDSET_LOOP = "UndergroundDoor_ElectricMotor_Loop_SoundSet";
322 const string ENGINE_SOUNDSET_LOOP_OUT = "UndergroundDoor_ElectricMotor_End_SoundSet";
323 const string LOCKING_SOUNDSET = "UndergroundDoor_Lock_SoundSet";
324 const string DOORMOVING_SOUNDSET_LOOP = "UndergroundDoor_DoorOpen_Loop_SoundSet";
325 const string DOORMOVING_SOUNDSET_LOOP_OUT = "UndergroundDoor_DoorOpen_End_SoundSet";
326 const string DOORMOVING_SOUNDSET_LOOP_IN = "UndergroundDoor_DoorOpen_Start_SoundSet";
327
328 const float LIGHT_ROT_SPEED = -400;
329
330 override void CreateLights()
331 {
332 m_InteriorLight1 = EntranceLight.Cast(ScriptedLightBase.CreateLightAtObjMemoryPoint(EntranceLightMain1, this, "InteriorLightPos1"));
333 m_InteriorLight2 = EntranceLight.Cast(ScriptedLightBase.CreateLightAtObjMemoryPoint(EntranceLightMain2, this, "InteriorLightPos2"));
334 }
335
336 override void CleanUpOnClosedClient()
337 {
346
347 if (m_AlarmLight && GetGame())
348 {
349 m_AlarmLight.Destroy();
350 }
351 }
352
354 {
355 switch (newState)
356 {
357 case EUndegroundEntranceState.OPENING_A:
359 break;
360 case EUndegroundEntranceState.OPENING_B:
362 break;
363 case EUndegroundEntranceState.OPENING_C:
365 break;
366 case EUndegroundEntranceState.OPENING_D:
367 m_AnimTimerDoorServer = new AnimationTimer();
368 m_AnimTimerDoorServer.Run(AdjustTime(GetOpeningTime()), this, "OnUpdateServer", "OnFinishedTimerServer",0, false,/*1/ AdjustTime(1)*/ 1);
369 m_NavmeshTimer = new Timer();
370 m_NavmeshTimer.Run(3, this, "NavmeshUpdate", NULL, true);
372 break;
373 case EUndegroundEntranceState.OPENING_E:
374 m_AnimTimerDoorServer.Stop();
376 m_NavmeshTimer = null;
378 break;
379 case EUndegroundEntranceState.OPENING_F:
381 break;
382 case EUndegroundEntranceState.OPENING_G:
384 break;
385 case EUndegroundEntranceState.CLOSING_A:
387 break;
388 case EUndegroundEntranceState.CLOSING_B:
390 break;
391 case EUndegroundEntranceState.CLOSING_C:
392 m_NavmeshTimer = new Timer();
393 m_NavmeshTimer.Run(3, this, "NavmeshUpdate", NULL, true);
394 m_AnimTimerDoorServer.Run(0, this, "OnUpdateServer", "OnFinishedTimerServer", AdjustTime(GetOpeningTime()),false, /*1/ AdjustTime(1)*/ 1);
396 break;
397 case EUndegroundEntranceState.CLOSING_D:
399 m_NavmeshTimer = null;
401 break;
402 case EUndegroundEntranceState.CLOSING_E:
404 break;
405 case EUndegroundEntranceState.CLOSING_F:
407 break;
408 case EUndegroundEntranceState.CLOSING_G:
410 break;
411 }
412 }
413
415 {
416 vector pos;
417 if (MemoryPointExists("SirenLightPos"))
418 {
419 pos = GetMemoryPointPos("SirenLightPos");
420 pos = ModelToWorld(pos);
421 }
422 else
423 {
424 ErrorEx("GetLightPosition could not locate memory point 'SirenLightPos'");
425 }
426 return pos;
427 }
428
430 {
431 if (eff == m_DoorMovementSoundIn)
432 {
433 PlaySoundSetAtMemoryPointLooped(m_DoorMovementSoundLoop, DOORMOVING_SOUNDSET_LOOP, "DoorEngineSoundPos");
435 }
436 else if (eff == m_DoorEngineSoundIn)
437 {
438 PlaySoundSetAtMemoryPointLooped(m_DoorEngineSoundLoop, ENGINE_SOUNDSET_LOOP, "DoorEngineSoundPos");
439 m_DoorEngineSoundIn = null;
440 }
441 }
442
443 //do note that one-time effects are played even if the client connects and misses the state switch, ie. they are not connected the exact moment when the effect is supposed to be played(just after a state switch), but connect sometime later
444 //we can prevent such effects from playing by checking for IsInitDoorStateSync(), but that seems unnecessary as the issue is really small
446 {
447 //Print("HandleAudioVisualPlayback " + newState + ", " + prevState);
448 //opening
450 {
451 PlaySoundSetAtMemoryPointLooped(m_SirenSound, SIREN_SOUNDSET, "SirenSoundPos",0.5,0.5);
452 }
453 if (newState == EUndegroundEntranceState.OPENING_B)
454 {
455 if (prevState == EUndegroundEntranceState.OPENING_A)//if they connected already during B, do not play the in
456 {
457 PlaySoundSetAtMemoryPoint(m_DoorEngineSoundIn, ENGINE_SOUNDSET_LOOP_IN, "DoorEngineSoundPos");
459 m_DoorEngineSoundIn.Event_OnEffectEnded.Insert(SoundEnded);
460 }
461 }
462
464 {
465 if (!m_DoorEngineSoundLoop && !m_DoorEngineSoundIn)//missed playing of the IN soundset which automatically triggers playing of the loop(connected after ?)
466 {
467 PlaySoundSetAtMemoryPointLooped(m_DoorEngineSoundLoop, ENGINE_SOUNDSET_LOOP, "DoorEngineSoundPos");
468 }
469 }
470 if (newState == EUndegroundEntranceState.OPENING_C)
471 {
472 PlaySoundSetAtMemoryPoint(m_LockingSound, LOCKING_SOUNDSET, "DoorEngineSoundPos");
473 }
474 if (newState == EUndegroundEntranceState.OPENING_D)
475 {
476 if (prevState == EUndegroundEntranceState.OPENING_C)//if they connected already during C, do not play the in
477 {
478 PlaySoundSetAtMemoryPoint(m_DoorMovementSoundIn, DOORMOVING_SOUNDSET_LOOP_IN, "DoorEngineSoundPos");
480 m_DoorMovementSoundIn.Event_OnEffectEnded.Insert(SoundEnded);
481 }
482 else if (!m_DoorMovementSoundIn && !m_DoorMovementSoundLoop)//missed playing of the IN soundset which automatically triggers playing of the loop(connected after ?)
483 {
484 PlaySoundSetAtMemoryPointLooped(m_DoorMovementSoundLoop, DOORMOVING_SOUNDSET_LOOP, "DoorEngineSoundPos");
485 }
486 }
487
488 if (newState == EUndegroundEntranceState.OPENING_E)
489 {
490 StopSoundSet(m_DoorMovementSoundLoop);
491 PlaySoundSetAtMemoryPoint(m_DoorMovementSoundOut, DOORMOVING_SOUNDSET_LOOP_OUT, "DoorEngineSoundPos");
492 }
493 if (newState == EUndegroundEntranceState.OPENING_F)
494 {
495 StopSoundSet(m_DoorEngineSoundLoop);
496 PlaySoundSetAtMemoryPoint(m_DoorEngineSoundOut, ENGINE_SOUNDSET_LOOP_OUT, "DoorEngineSoundPos");
497 }
498 if (newState == EUndegroundEntranceState.OPENING_G)
499 {
500 StopSoundSet(m_SirenSound);
501 }
502
503 //closing
505 {
506 PlaySoundSetAtMemoryPointLooped(m_SirenSound, SIREN_SOUNDSET, "SirenSoundPos",0.5,0.5);
507 }
509 {
510 if (prevState == EUndegroundEntranceState.CLOSING_A)//if they connected already during B, do not play the in
511 {
512 PlaySoundSetAtMemoryPoint(m_DoorEngineSoundIn, ENGINE_SOUNDSET_LOOP_IN, "DoorEngineSoundPos");
514 m_DoorEngineSoundIn.Event_OnEffectEnded.Insert(SoundEnded);
515 }
516 }
517 if ( newState == EUndegroundEntranceState.CLOSING_C)
518 {
519 if (prevState == EUndegroundEntranceState.CLOSING_B)//if they connected already during C, do not play the in
520 {
521 PlaySoundSetAtMemoryPoint(m_DoorMovementSoundIn, DOORMOVING_SOUNDSET_LOOP_IN, "DoorEngineSoundPos");
523 m_DoorMovementSoundIn.Event_OnEffectEnded.Insert(SoundEnded);
524 }
525 else if (!m_DoorMovementSoundIn && !m_DoorMovementSoundLoop)//missed playing of the IN soundset which automatically triggers playing of the loop(connected after ?)
526 {
527 PlaySoundSetAtMemoryPointLooped(m_DoorMovementSoundLoop, DOORMOVING_SOUNDSET_LOOP, "DoorEngineSoundPos");
528 }
529 }
530 if (newState == EUndegroundEntranceState.CLOSING_D)
531 {
532 StopSoundSet(m_DoorMovementSoundLoop);
533 PlaySoundSetAtMemoryPoint(m_DoorMovementSoundOut, DOORMOVING_SOUNDSET_LOOP_OUT, "DoorEngineSoundPos");
534 }
535 if (newState == EUndegroundEntranceState.CLOSING_E)
536 {
537 PlaySoundSetAtMemoryPoint(m_LockingSound, LOCKING_SOUNDSET, "DoorEngineSoundPos");
538 }
539 if (newState == EUndegroundEntranceState.CLOSING_F)
540 {
541 StopSoundSet(m_DoorEngineSoundLoop);
542 PlaySoundSetAtMemoryPoint(m_DoorEngineSoundOut, ENGINE_SOUNDSET_LOOP_OUT, "DoorEngineSoundPos");
543 }
544 if (newState == EUndegroundEntranceState.CLOSING_G || newState == EUndegroundEntranceState.CLOSED)
545 {
546 StopSoundSet(m_SirenSound);
547 }
548 }
549
550 override void OnUpdateClient(float timeSlice)
551 {
552 SetAnimationPhaseNow("EntranceDoor",m_AnimPhase);
553 if (m_AlarmLight)
554 {
555 vector newOri = m_AlarmLight.GetOrientation() + Vector(timeSlice * LIGHT_ROT_SPEED,0,0);
556 m_AlarmLight.SetOrientation(newOri);
557 }
558 }
559
561 {
562 if ( CheckShouldPlayPersistent(EUndegroundEntranceState.OPENING_A, EUndegroundEntranceState.OPENING_F) || CheckShouldPlayPersistent(EUndegroundEntranceState.CLOSING_A, EUndegroundEntranceState.CLOSING_F))
563 {
565 }
566 if ( newState == EUndegroundEntranceState.CLOSING_G || newState == EUndegroundEntranceState.CLOSED || newState == EUndegroundEntranceState.OPENING_G )
567 {
568 if (m_AlarmLight)
569 {
570 m_AlarmLight.Destroy();
571 }
572 }
573 }
574
575}
void Effect()
ctor
Definition Effect.c:70
void EntranceLight()
override void OnDebugButtonPressServer(int button_index)
override void GetDebugButtonNames(out string button1, out string button2, out string button3, out string button4)
enum EUndegroundEntranceState AlarmLight()
const string ENGINE_SOUNDSET_LOOP_IN
const string LOCKING_SOUNDSET
vector GetLightPosition()
AlarmLight m_AlarmLight
enum EUndegroundEntranceState MAIN
Land_Underground_EntranceBase m_SirenSound
EffectSound m_DoorEngineSoundIn
const string DOORMOVING_SOUNDSET_LOOP
EffectSound m_DoorMovementSoundLoop
const string DOORMOVING_SOUNDSET_LOOP_OUT
void SoundEnded(Effect eff)
enum EUndegroundEntranceState SMALL
EffectSound m_DoorEngineSoundOut
const float LIGHT_ROT_SPEED
EffectSound m_DoorEngineSoundLoop
const string DOORMOVING_SOUNDSET_LOOP_IN
EffectSound m_LockingSound
EffectSound m_DoorMovementSoundOut
EffectSound m_DoorMovementSoundIn
const string ENGINE_SOUNDSET_LOOP_OUT
const string ENGINE_SOUNDSET_LOOP
const string SIREN_SOUNDSET
void Land_Underground_Panel()
string GetDebugText()
AnimationTimer class. This timer is for animating float value. usage:
Definition tools.c:640
float GetValue()
Returns actual animated value.
Definition tools.c:678
proto native bool RegisterNetworkStaticObject(Object object)
Static objects cannot be replicated by default (there are too many objects on the map)....
override ScriptCallQueue GetCallQueue(int call_category)
Definition DayZGame.c:1153
void UpdatePathgraphRegionByObject(Object object)
Definition Game.c:1098
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
static int GetLastEnumValue(typename e)
Return amount of values in enum.
Definition EnConvert.c:647
void OnDoorStateChangedServer(EUndegroundEntranceState newState)
void RequestLatentTransition(float time, EUndegroundEntranceState targetState=EUndegroundEntranceState.UNINITIALIZED)
override void EOnPostSimulate(IEntity other, float timeSlice)
ref array< Land_Underground_Panel > m_ConnectedPanels
float AdjustTime(float originalTime, float adjustedTime=-1)
void HandleVisualPlayback(EUndegroundEntranceState newState, EUndegroundEntranceState prevState)
void OnDoorStateChangedClient(EUndegroundEntranceState newState, EUndegroundEntranceState prevState)
void OnUpdateClient(float timeSlice)
bool CheckShouldPlayPersistent(EUndegroundEntranceState state, EUndegroundEntranceState lastValidState)
EUndegroundEntranceState m_DoorStatePrev
void SetDoorStateServer(EUndegroundEntranceState newState)
void GetConnectedPanels(array< Land_Underground_Panel > panels)
void HandleAudioPlayback(EUndegroundEntranceState newState, EUndegroundEntranceState prevState)
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
Manager class for managing Effect (EffectParticle, EffectSound)
static bool DestroySound(EffectSound sound_effect)
Legacy, backwards compatibility.
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto void Remove(func fn)
remove specific call from queue
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
enum ShapeType ErrorEx
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition EnEntity.c:45
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8