DayZ 1.24
Loading...
Searching...
No Matches
SpookyAreaMisc.c
Go to the documentation of this file.
1//-------------------------------------------------------------
3{
4 override protected void Init()
5 {
6 SetCoolDown(65);
7 m_SoundSet = "SpookyArea_WhistlingWind_SoundSet";
8 }
9
11 {
12 return player.IsSoundInsideBuilding();
13 }
14
15 override protected void Do(PlayerBase player)
16 {
17 //put additional code here
18 }
19}
20//-------------------------------------------------------------
22{
23 override protected void Init()
24 {
25 SetCoolDown(80);
26 m_SoundSet = "SpookyArea_Whispering_SoundSet";
27 }
28
29 override protected void Do(PlayerBase player)
30 {
31 //put additional code here
32 }
33
34}
35//-------------------------------------------------------------
37{
38 override protected void Init()
39 {
40 SetCoolDown(40);
41 m_SoundSet = "SpookyArea_RunOnConcrete_SoundSet";
42 m_Surfaces = {"stone", "gravel", "concrete", "wood", "asphalt", "tiles", "textile"};
43 }
44
45 override protected void Do(PlayerBase player)
46 {
47 //put additional code here
48 }
49}
50//-------------------------------------------------------------
52{
53 override protected void Init()
54 {
55 SetCoolDown(60);
56 m_SoundSet = "SpookyArea_IntenseFoliageRustle_SoundSet";
57 m_Surfaces = {"grass", "dirt", "forest", "soil"};
58 }
59
60 override protected bool CanDo(PlayerBase player, TStringVectorMap surfaceTypes)
61 {
62 return !player.IsSoundInsideBuilding();
63 }
64
65 override protected void Do(PlayerBase player)
66 {
67 vector soundPos = GetSoundPos(player);
68
69 string secondarySoundSet = "SpookyArea_Hedgehog_SoundSet";
70
71 if (Math.RandomBool())
72 secondarySoundSet = "SpookyArea_Badger_Voice_SoundSet";
73
75 sound.SetAutodestroy(true);
76 }
77}
78
79
80//-------------------------------------------------------------
81//-------------------------------------------------------------
82//-------------------------------------------------------------
83
85{
86 //internal params, do not set manually
87 protected float m_PerformedTimestamp;//internal, marks the time this event was last performed so that it can guruantee the cooldown period before playing it again
88 protected int m_Cooldown;//how much time needs to elapse between this event can be performed again in seconds
89 //the params bellow can be set in the 'Init' method
90 protected string m_SoundSet;//if set, will play this soundset when performing the event
91 protected ref TStringArray m_Surfaces;//if set, the player needs to detect this surface for the event to be considered valid
92 protected vector m_MatchingSurfacePos;//position of the first matching surface
93
95 {
96 Init();
97 }
98
99 protected void Init();
100
101
103 {
104 for (int i = 0; i < gatheredSurfaces.Count(); i++)
105 {
106 string currSurface = gatheredSurfaces.GetKey(i);
107 foreach (string s: surfaces)
108 {
109 if (currSurface.Contains(s))
110 return gatheredSurfaces.Get(currSurface);
111 }
112 }
113
114 return vector.Zero;
115 }
116
117 protected void SetCoolDown(float secs)
118 {
119 m_Cooldown = secs * 1000;
120 }
121
122 protected bool HasSurfaces()
123 {
124 return (m_Surfaces && m_Surfaces.Count() > 0);
125 }
126
128 {
129 return true;
130 }
131
132 protected void Do(PlayerBase player);
133
134 //internal, do not override, use 'CanDo' instead
148
149 //internal, do not override, use 'Do' instead
151 {
152#ifdef DIAG_DEVELOPER
153 if (DiagMenu.GetBool(DiagMenuIDs.TRIGGER_DEBUG))
154 Print("Performing " + this);
155#endif
157
158 if (m_SoundSet)
159 {
162 sound.SetAutodestroy(true);
163
164#ifdef DIAG_DEVELOPER
165 if (DiagMenu.GetBool(DiagMenuIDs.TRIGGER_DEBUG))
166 Debug.DrawSphere(soundPos, 0.15, Colors.YELLOW, ShapeFlags.NOZBUFFER);
167#endif
168 }
169
170 Do(player);
171 }
172
174 {
176
177 if (HasSurfaces())
179 else
180 {
181 float distance = Math.RandomFloatInclusive(5, 15);
183 vector playerPos = player.GetPosition();
185 }
186
187 return soundPos;
188 }
189}
190
191//----------------------------------------------------------------------------------------------------------
192
194{
197 protected float m_TimeAccu;
198 protected const float CONSECUTIVE_EVENTS_COOLDOWN = 20;//min delay in seconds before two events
199 protected const float EVENT_CHECK_FREQUENCY = 2;//when not in cooldown, the rate at which we query the events
200 protected const float FIRST_EVENT_CHECK_DELAY = 15;//the delay between the first event check when we first enter the contaminated area
201 protected const float SURFACE_CHECK_POINT_DISTANCE = 2;//additional checks for surface are performed at this distance from the player
203
214
219
220 protected void RegisterEvents()
221 {
222 m_SoundEvents.Insert(new SpookyEventWind());
223 m_SoundEvents.Insert(new SpookyEventWhisper());
224 m_SoundEvents.Insert(new SpookyEventSteps());
225 m_SoundEvents.Insert(new SpookyEventRustle());
226
227 }
228
229 void Update(float deltaTime)
230 {
233 {
234 if (SelectEvent())
236 else
238 m_TimeAccu = 0;
239 }
240 }
241
243 {
244 gatheredGurfaces.Clear();
245
246 vector playerPos = m_Player.GetPosition();
248
249 positions.Insert(playerPos);
251 positions.Insert(playerPos + ("0 0 -1" * SURFACE_CHECK_POINT_DISTANCE));
253 positions.Insert(playerPos + ("-1 0 0" * SURFACE_CHECK_POINT_DISTANCE));
254
255 foreach (vector pos : positions)
256 {
257 string surfaceType;
258 GetGame().SurfaceGetType3D(pos[0], pos[1], pos[2], surfaceType);
259
260 if (!gatheredGurfaces.Contains(surfaceType))
261 gatheredGurfaces.Insert(surfaceType, pos);
262 }
263
264#ifdef DIAG_DEVELOPER
265 if (DiagMenu.GetBool(DiagMenuIDs.TRIGGER_DEBUG))
266 {
267 foreach (vector p: positions)
268 Debug.DrawLine(p, p + "0 10 0", COLOR_BLUE, ShapeFlags.NOZBUFFER);
269 }
270#endif
271
272 }
273
274 protected bool SelectEvent()
275 {
277 GatherSurfaces(gatheredSurfaces);//this can be optimized by calling this on demand from an event, as none events might be eligible at this point, so we might be doing this in vain
278
279#ifdef DIAG_DEVELOPER
280 if (DiagMenu.GetBool(DiagMenuIDs.TRIGGER_DEBUG))
281 {
282 for (int i = 0; i < gatheredSurfaces.Count(); i++)
283 {
284 Print(gatheredSurfaces.GetKey(i));
286
287 }
288 Print("--------------------------------------------------------------------");
289 }
290#endif
291
293 float currentTime = GetGame().GetTime();
295 {
297 validEvents.Insert(spookyEvent);
298 }
299
300 //validEvents.Debug();
302
303 if (validEvents.Count() > 0)
304 {
305 int randIndex = Math.RandomIntInclusive(0, validEvents.Count() - 1);
307 }
308 if (selectedEvent)
309 {
311 return true;
312 }
313 return false;
314
315 }
316
317}
318
321{
322
326
327
328 override void EEInit()
329 {
330 super.EEInit();
331
332 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
333 {
335 m_UTSSettings.m_Updateable = true;
336 m_UTSSettings.m_UpdateInterval = 3;
337 m_UTSSettings.m_TemperatureMin = -20;
338 m_UTSSettings.m_TemperatureMax = -20;
339 m_UTSSettings.m_RangeFull = 2;
340 m_UTSSettings.m_RangeMax = 2;
341 m_UTSSettings.m_TemperatureCap = -20;
342 m_UTSSettings.m_ManualUpdate = false;
343
346 m_UTSource.SetActive(true);
347 }
348
349 }
350
351}
override Widget Init()
Definition DayZGame.c:120
DiagMenuIDs
Definition EDiagMenuIDs.c:2
DayZPlayer m_Player
Definition Hand_Events.c:42
const float SURFACE_CHECK_POINT_DISTANCE
const float FIRST_EVENT_CHECK_DELAY
const float EVENT_CHECK_FREQUENCY
void GatherSurfaces(notnull TStringVectorMap gatheredGurfaces)
bool CanDo(PlayerBase player, TStringVectorMap surfaceTypes)
bool SelectEvent()
void RegisterEvents()
void ~SpookyTriggerEventsHandler()
class SpookyEventBase m_SoundEvents
void Do(PlayerBase player)
float m_TimeAccu
float m_NextEventCheck
const float CONSECUTIVE_EVENTS_COOLDOWN
void SpookyTriggerEventsHandler(notnull PlayerBase player)
Definition Colors.c:4
const int YELLOW
Definition Colors.c:10
Definition Debug.c:14
static Shape DrawSphere(vector pos, float size=1, int color=0x1fff7f7f, ShapeFlags flags=ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE)
Definition Debug.c:434
static Shape DrawLine(vector from, vector to, int color=0xFFFFFFFF, int flags=0)
Definition Debug.c:489
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
Definition EnMath.c:7
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.
bool CanDo(PlayerBase player, TStringVectorMap surfaceTypes)
bool CanPerform(PlayerBase player, float currentTime, TStringVectorMap surfaceTypes)
void Do(PlayerBase player)
ref TStringArray m_Surfaces
vector GetSoundPos(PlayerBase player)
vector m_MatchingSurfacePos
vector GetMatchingSurfacePos(TStringArray surfaces, TStringVectorMap gatheredSurfaces)
void SetCoolDown(float secs)
void Perform(PlayerBase player, float currentTime, TStringVectorMap gatheredSurfaces)
void Do(PlayerBase player)
bool CanDo(PlayerBase player, TStringVectorMap surfaceTypes)
void Do(PlayerBase player)
this entity gets attached to each player while present in the spooky area
ref UniversalTemperatureSourceSettings m_UTSSettings
ref UniversalTemperatureSource m_UTSource
ref UniversalTemperatureSourceLambdaConstant m_UTSLConstant
override void EEInit()
original Timer deletes m_params which is unwanted
static const vector Zero
Definition EnConvert.c:110
static vector RandomDir2D()
Returns randomly generated XZ unit vector with the Y(up) axis set to 0.
Definition EnConvert.c:260
proto native CGame GetGame()
const int COLOR_BLUE
Definition constants.c:66
proto void Print(void var)
Prints content of variable to console/log.
ShapeFlags
Definition EnDebug.c:126
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
map< string, vector > TStringVectorMap
Definition EnScript.c:940
array< vector > TVectorArray
Definition EnScript.c:673
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Definition EnMath.c:106
static bool RandomBool()
Returns a random bool .
Definition EnMath.c:73
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Definition EnMath.c:54
proto native volatile void Update()