DayZ 1.24
Loading...
Searching...
No Matches
SpookyAreaMisc.c File Reference

Go to the source code of this file.

Classes

class  SpookyEventWind
 
class  SpookyEventSteps
 
class  SpookyEventBase
 
class  SpookyPlayerStalker
 this entity gets attached to each player while present in the spooky area More...
 

Functions

SpookyEventWind SpookyEventBase Init ()
 Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)
 
bool CanDo (PlayerBase player, TStringVectorMap surfaceTypes)
 
void Do (PlayerBase player)
 
void SpookyTriggerEventsHandler (notnull PlayerBase player)
 
void ~SpookyTriggerEventsHandler ()
 
void RegisterEvents ()
 
void Update (float deltaTime)
 
void GatherSurfaces (notnull TStringVectorMap gatheredGurfaces)
 
bool SelectEvent ()
 

Variables

class SpookyEventBase m_SoundEvents
 
PlayerBase m_Player
 
float m_TimeAccu
 
const float CONSECUTIVE_EVENTS_COOLDOWN = 20
 
const float EVENT_CHECK_FREQUENCY = 2
 
const float FIRST_EVENT_CHECK_DELAY = 15
 
const float SURFACE_CHECK_POINT_DISTANCE = 2
 
float m_NextEventCheck = FIRST_EVENT_CHECK_DELAY
 

Function Documentation

◆ CanDo()

bool CanDo ( PlayerBase player,
TStringVectorMap surfaceTypes )
protected

Definition at line 30 of file SpookyAreaMisc.c.

30 {
31 //put additional code here
32 }
33

◆ Do()

void Do ( PlayerBase player)
protected

Definition at line 35 of file SpookyAreaMisc.c.

37{
38 override protected void Init()
SpookyEventWind SpookyEventBase Init()
Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside o...

◆ GatherSurfaces()

void GatherSurfaces ( notnull TStringVectorMap gatheredGurfaces)
protected

Definition at line 242 of file SpookyAreaMisc.c.

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 }
DiagMenuIDs
Definition EDiagMenuIDs.c:2
const float SURFACE_CHECK_POINT_DISTANCE
PlayerBase m_Player
Definition Debug.c:14
proto native CGame GetGame()
const int COLOR_BLUE
Definition constants.c:66
ShapeFlags
Definition EnDebug.c:126
@ NOZBUFFER
Definition EnDebug.c:127
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
array< vector > TVectorArray
Definition EnScript.c:673

References COLOR_BLUE, Debug::DrawLine(), DiagMenu::GetBool(), GetGame(), m_Player, and SURFACE_CHECK_POINT_DISTANCE.

Referenced by SelectEvent().

◆ Init()

Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)

Definition at line 1 of file SpookyAreaMisc.c.

24 {
25 SetCoolDown(80);
26 m_SoundSet = "SpookyArea_Whispering_SoundSet";
27 }

◆ RegisterEvents()

void RegisterEvents ( )
protected

Definition at line 220 of file SpookyAreaMisc.c.

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 }
class SpookyEventBase m_SoundEvents

References m_SoundEvents.

Referenced by SpookyTriggerEventsHandler().

◆ SelectEvent()

bool SelectEvent ( )
protected

Definition at line 274 of file SpookyAreaMisc.c.

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 }
void GatherSurfaces(notnull TStringVectorMap gatheredGurfaces)
Definition EnMath.c:7
proto void Print(void var)
Prints content of variable to console/log.
map< string, vector > TStringVectorMap
Definition EnScript.c:940
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Definition EnMath.c:54

References GatherSurfaces(), DiagMenu::GetBool(), GetGame(), m_Player, m_SoundEvents, Print(), and Math::RandomIntInclusive().

Referenced by Update().

◆ SpookyTriggerEventsHandler()

void SpookyTriggerEventsHandler ( notnull PlayerBase player)
protected

Definition at line 204 of file SpookyAreaMisc.c.

205 {
206 if (!m_SoundEvents)
207 {
210 }
211
213 }
void RegisterEvents()

References m_Player, m_SoundEvents, and RegisterEvents().

Referenced by OnEnterClientEvent().

◆ Update()

void Update ( float deltaTime)
protected

Definition at line 229 of file SpookyAreaMisc.c.

230 {
233 {
234 if (SelectEvent())
236 else
238 m_TimeAccu = 0;
239 }
240 }
const float EVENT_CHECK_FREQUENCY
bool SelectEvent()
float m_TimeAccu
float m_NextEventCheck
const float CONSECUTIVE_EVENTS_COOLDOWN

References CONSECUTIVE_EVENTS_COOLDOWN, EVENT_CHECK_FREQUENCY, m_NextEventCheck, m_TimeAccu, and SelectEvent().

◆ ~SpookyTriggerEventsHandler()

Definition at line 215 of file SpookyAreaMisc.c.

216 {
218 }

References m_SoundEvents.

Variable Documentation

◆ CONSECUTIVE_EVENTS_COOLDOWN

const float CONSECUTIVE_EVENTS_COOLDOWN = 20
protected

Definition at line 198 of file SpookyAreaMisc.c.

Referenced by Update().

◆ EVENT_CHECK_FREQUENCY

const float EVENT_CHECK_FREQUENCY = 2
protected

Definition at line 199 of file SpookyAreaMisc.c.

Referenced by Update().

◆ FIRST_EVENT_CHECK_DELAY

const float FIRST_EVENT_CHECK_DELAY = 15
protected

Definition at line 200 of file SpookyAreaMisc.c.

◆ m_NextEventCheck

float m_NextEventCheck = FIRST_EVENT_CHECK_DELAY
protected

Definition at line 202 of file SpookyAreaMisc.c.

Referenced by Update().

◆ m_Player

PlayerBase m_Player
protected

Definition at line 196 of file SpookyAreaMisc.c.

◆ m_SoundEvents

◆ m_TimeAccu

float m_TimeAccu
protected

Definition at line 197 of file SpookyAreaMisc.c.

Referenced by Update().

◆ SURFACE_CHECK_POINT_DISTANCE

const float SURFACE_CHECK_POINT_DISTANCE = 2
protected

Definition at line 201 of file SpookyAreaMisc.c.

Referenced by GatherSurfaces().