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

Go to the source code of this file.

Enumerations

enum  EUndergroundPresence { NONE , OUTER , TRANSITIONING , FULL }
 

Functions

void UndergroundHandlerClient (PlayerBase player)
 
void ~UndergroundHandlerClient ()
 
PPERUndergroundAcco GetRequester ()
 
void OnTriggerEnter (UndergroundTrigger trigger)
 
void OnTriggerLeave (UndergroundTrigger trigger)
 
void CalculateEyeAccoTarget ()
 
void ProcessEyeAcco (float timeSlice)
 
void ProcessLighting (float timeSlice)
 
void ProcessSound (float timeSlice)
 
void Tick (float timeSlice)
 
void ApplyEyeAcco ()
 
void UpdateNVGRequester (float value)
 
bool CalculateEyeAcco (float timeSlice)
 
void OnTriggerInsiderUpdate ()
 
void SetUndergroundPresence (UndergroundTrigger trigger)
 
void EnableLights (bool enable)
 
void OnUpdateTimerEnd ()
 
void OnUpdateTimerIn ()
 
void OnUpdateTimerOut ()
 
void OnUndergroundPresenceUpdate (EUndergroundPresence newPresence, EUndergroundPresence oldPresence)
 

Variables

enum EUndergroundPresence LIGHT_BLEND_SPEED_IN = 5
 
const float LIGHT_BLEND_SPEED_OUT = 1.75
 
const float MAX_RATIO = 0.9
 
const float RATIO_CUTOFF = 0
 
const float DISTANCE_CUTOFF = 5
 
const float ACCO_MODIFIER = 1
 
const float DEFAULT_INTERPOLATION_SPEED = 7
 
const string UNDERGROUND_LIGHTING = "dz\\data\\lighting\\lighting_underground.txt"
 
ref AnimationTimer m_AnimTimerLightBlend
 
PlayerBase m_Player
 
PPERUndergroundAcco m_Requester
 
PPERequester_CameraNV m_NVRequester
 
ref set< UndergroundTriggerm_InsideTriggers = new set<UndergroundTrigger>()
 
float m_EyeAccoTarget = 1
 
float m_AccoInterpolationSpeed
 
float m_EyeAcco = 1
 
float m_LightingLerpTarget
 
float m_LightingLerp
 
EffectSound m_AmbientSound
 
UndergroundTrigger m_TransitionalTrigger
 

Enumeration Type Documentation

◆ EUndergroundPresence

Enumerator
NONE 
OUTER 
TRANSITIONING 
FULL 

Definition at line 1 of file UndergroundHandlerClient.c.

2{
3 NONE,//player is not interacting with underground at any level
4 OUTER,//player is on the outskirts of the underdound, some effects are already in effect, while others might not be
5 TRANSITIONING,//player has entered underground and is in the process of screen darkening transition
6 FULL//the player is now fully entered underground
7}

Function Documentation

◆ ApplyEyeAcco()

void ApplyEyeAcco ( )
protected

Definition at line 220 of file UndergroundHandlerClient.c.

221 {
222#ifdef DIAG_DEVELOPER
223 if (!DiagMenu.GetBool(DiagMenuIDs.UNDERGROUND_DISABLE_DARKENING))
224 GetRequester().SetEyeAccommodation(m_EyeAcco);
225 else
226 GetRequester().SetEyeAccommodation(1);
227#else
228 GetRequester().SetEyeAccommodation(m_EyeAcco);
229#endif
230
232 if (m_LightingLerp >= 1.0 || GetDayZGame().GetWorld().IsNight())
234 //m_NVRequester.SetUndergroundExposureCoef(undergrounNVExposureCoef);
236 }
DayZGame GetDayZGame()
Definition DayZGame.c:3530
DiagMenuIDs
Definition EDiagMenuIDs.c:2
void UpdateNVGRequester(float value)
PPERUndergroundAcco GetRequester()
float m_EyeAcco
float m_LightingLerp
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.

References DiagMenu::GetBool(), GetDayZGame(), GetRequester(), m_EyeAcco, m_LightingLerp, and UpdateNVGRequester().

Referenced by ProcessEyeAcco().

◆ CalculateEyeAcco()

bool CalculateEyeAcco ( float timeSlice)
protected

Definition at line 243 of file UndergroundHandlerClient.c.

244 {
245 if (m_TransitionalTrigger || !m_Player.m_UndergroundPresence || (m_EyeAccoTarget == 1))
246 {
250 if (Math.AbsFloat(accoDiff) < 0.01)
251 {
253 return true;
254 }
255 }
256 else
258 return false;
259 }
UndergroundTrigger m_TransitionalTrigger
PlayerBase m_Player
float m_EyeAccoTarget
float m_AccoInterpolationSpeed
Definition EnMath.c:7
static proto float AbsFloat(float f)
Returns absolute value.

References Math::AbsFloat(), m_AccoInterpolationSpeed, m_EyeAcco, m_EyeAccoTarget, m_Player, and m_TransitionalTrigger.

Referenced by ProcessEyeAcco().

◆ CalculateEyeAccoTarget()

void CalculateEyeAccoTarget ( )
protected

Definition at line 79 of file UndergroundHandlerClient.c.

80 {
81 if (m_TransitionalTrigger && m_TransitionalTrigger.m_Data.Breadcrumbs.Count() >= 2)
82 {
83 float closestDist = float.MAX;
84 float acco;
87
88
89 int excludeMask = 0;
90 foreach (int indx, auto crumb: m_TransitionalTrigger.m_Data.Breadcrumbs)
91 {
92 if (indx > 32)//error handling for exceeding this limit is handled elsewhere
93 break;
94
95 float dist = vector.Distance(m_Player.GetPosition(), crumb.GetPosition());
96 float crumbRadius = m_TransitionalTrigger.m_Data.Breadcrumbs[indx].Radius;
98
99 if (crumbRadius != -1)
102 excludeMask = (excludeMask | (1 << indx));
103 else if (m_TransitionalTrigger.m_Data.Breadcrumbs[indx].UseRaycast)
104 {
105 int idx = m_Player.GetBoneIndexByName("Head");
106 vector rayStart = m_Player.GetBonePositionWS(idx);
107 vector rayEnd = crumb.GetPosition();
109 float hitFraction;
111
113 excludeMask = (excludeMask | (1 << indx));
114 }
115
116 distances.Insert(dist);
117
118#ifdef DIAG_DEVELOPER
119 if (DiagMenu.GetBool(DiagMenuIDs.UNDERGROUND_SHOW_BREADCRUMB))
120 Debug.DrawSphere(crumb.GetPosition(), 0.1, COLOR_RED, ShapeFlags.ONCE);
121#endif
122 }
123 float baseDst = distances[0];
124 float sum = 0;
125 //Print(excludeMask);
126 foreach (float dst: distances)
127 {
128 if (dst == 0)
129 dst = 0.1;
130 float dstInv = (baseDst / dst) * baseDst;
131 sum += dstInv;
133 }
134 float sumCheck = 0;
135 float eyeAcco = 0;
136 foreach (int i, float dstInvert: distancesInverted)
137 {
138 /*
139 //Print(m_TransitionalTrigger.m_Data.Breadcrumbs[i].EyeAccommodation);
140 //Print(m_TransitionalTrigger.m_Data.Breadcrumbs.Count());
141 */
142 if ((1 << i) & excludeMask)
143 continue;
144 float ratio = dstInvert / sum;
145 if (ratio > MAX_RATIO)
147 if (ratio > RATIO_CUTOFF)
148 {
149#ifdef DIAG_DEVELOPER
150 if (DiagMenu.GetBool(DiagMenuIDs.UNDERGROUND_SHOW_BREADCRUMB))
151 {
152 float intensity = (1 - ratio) * 255;
153 Debug.DrawLine(GetGame().GetPlayer().GetPosition() + "0 1 0", m_TransitionalTrigger.m_Data.Breadcrumbs[i].GetPosition(), ARGB(0, 255, intensity, intensity), ShapeFlags.ONCE);
154 }
155#endif
156 eyeAcco += ratio * m_TransitionalTrigger.m_Data.Breadcrumbs[i].EyeAccommodation;
157
158 }
159
160 }
162 }
163 }
PhxInteractionLayers
Definition DayZPhysics.c:2
const float DISTANCE_CUTOFF
const float ACCO_MODIFIER
const float RATIO_CUTOFF
const float MAX_RATIO
static proto bool RayCastBullet(vector begPos, vector endPos, PhxInteractionLayers layerMask, Object ignoreObj, out Object hitObject, out vector hitPosition, out vector hitNormal, out float hitFraction)
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
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto native CGame GetGame()
const int COLOR_RED
Definition constants.c:64
ShapeFlags
Definition EnDebug.c:126
int ARGB(int a, int r, int g, int b)
Definition proto.c:322

References ACCO_MODIFIER, ARGB(), COLOR_RED, vector::Distance(), DISTANCE_CUTOFF, Debug::DrawLine(), Debug::DrawSphere(), DiagMenu::GetBool(), GetGame(), m_EyeAccoTarget, m_Player, m_TransitionalTrigger, MAX_RATIO, RATIO_CUTOFF, and DayZPhysics::RayCastBullet().

Referenced by ProcessEyeAcco().

◆ EnableLights()

void EnableLights ( bool enable)
protected

Definition at line 317 of file UndergroundHandlerClient.c.

318 {
319 foreach (ScriptedLightBase light: ScriptedLightBase.m_NightTimeOnlyLights)
320 light.SetVisibleDuringDaylight(enable);
321 }

Referenced by OnUndergroundPresenceUpdate().

◆ GetRequester()

PPERUndergroundAcco GetRequester ( )
protected

Definition at line 54 of file UndergroundHandlerClient.c.

55 {
56 if (!m_Requester)
57 {
58 m_Requester = PPERUndergroundAcco.Cast(PPERequesterBank.GetRequester(PPERequesterBank.REQ_UNDERGROUND));
59 m_Requester.Start();
60 }
61 return m_Requester;
62 }
PPERUndergroundAcco m_Requester

References m_Requester.

Referenced by ApplyEyeAcco(), ProcessEyeAcco(), and Managed::RegisterRequester().

◆ OnTriggerEnter()

void OnTriggerEnter ( UndergroundTrigger trigger)
protected

Definition at line 64 of file UndergroundHandlerClient.c.

65 {
68
69 }
ref set< UndergroundTrigger > m_InsideTriggers
void OnTriggerInsiderUpdate()

References m_InsideTriggers, and OnTriggerInsiderUpdate().

◆ OnTriggerInsiderUpdate()

void OnTriggerInsiderUpdate ( )
protected

Definition at line 262 of file UndergroundHandlerClient.c.

263 {
267 m_EyeAccoTarget = 1;
269
270 foreach (auto t: m_InsideTriggers)
271 {
272 if (t.m_Type > bestType)
273 {
274 bestTrigger = t;
275 bestType = t.m_Type;
276 }
277 }
278 //Print(m_InsideTriggers.Count());
279 //Print(bestType);
280 if (bestTrigger)
281 {
282 if (bestTrigger.m_Type == EUndergroundTriggerType.TRANSITIONING)
284 m_EyeAccoTarget = bestTrigger.m_Accommodation;
285 if (bestTrigger.m_InterpolationSpeed != -1 && bestTrigger.m_InterpolationSpeed != 0)
286 m_AccoInterpolationSpeed = bestTrigger.m_InterpolationSpeed;
287 }
288
290 }
const float DEFAULT_INTERPOLATION_SPEED
void SetUndergroundPresence(UndergroundTrigger trigger)

References DEFAULT_INTERPOLATION_SPEED, m_AccoInterpolationSpeed, m_EyeAccoTarget, m_InsideTriggers, m_TransitionalTrigger, and SetUndergroundPresence().

Referenced by OnTriggerEnter(), and OnTriggerLeave().

◆ OnTriggerLeave()

void OnTriggerLeave ( UndergroundTrigger trigger)
protected

Definition at line 71 of file UndergroundHandlerClient.c.

72 {
73 int index = m_InsideTriggers.Find(trigger);
74 if (index != -1)
75 m_InsideTriggers.Remove(index);
77 }

References m_InsideTriggers, and OnTriggerInsiderUpdate().

◆ OnUndergroundPresenceUpdate()

void OnUndergroundPresenceUpdate ( EUndergroundPresence newPresence,
EUndergroundPresence oldPresence )
protected

Definition at line 345 of file UndergroundHandlerClient.c.

346 {
347 //Print("-----> On Undeground Presence update " + EnumTools.EnumToString(EUndergroundPresence, newPresence) + " " + EnumTools.EnumToString(EUndergroundPresence, oldPresence));
349 {
351 EnableLights(true);
353 {
354 GetGame().GetWeather().SuppressLightningSimulation(true);
355 m_Player.PlaySoundSetLoop(m_AmbientSound, "Underground_SoundSet", 3, 3);
356 }
358 {
360 m_AnimTimerLightBlend.Run(1, this, "OnUpdateTimerIn", "OnUpdateTimerEnd", 0, false, LIGHT_BLEND_SPEED_IN);
361 }
362 }
364 {
366 m_AnimTimerLightBlend.Run(0, this, "OnUpdateTimerOut", "OnUpdateTimerEnd", m_LightingLerp, false, LIGHT_BLEND_SPEED_OUT);
367 }
369 {
370 GetGame().GetWeather().SuppressLightningSimulation(false);
371 if (m_AmbientSound)
372 m_Player.StopSoundSet(m_AmbientSound);
373 }
375 {
376 GetGame().GetWorld().SetUserLightingLerp(0);
377 EnableLights(false);
378 }
379 }
ref AnimationTimer m_AnimTimerLightBlend
enum EUndergroundPresence LIGHT_BLEND_SPEED_IN
EffectSound m_AmbientSound
void EnableLights(bool enable)
const float LIGHT_BLEND_SPEED_OUT
AnimationTimer class. This timer is for animating float value. usage:
Definition tools.c:618

References EnableLights(), GetGame(), LIGHT_BLEND_SPEED_IN, LIGHT_BLEND_SPEED_OUT, m_AmbientSound, m_AnimTimerLightBlend, m_LightingLerp, and m_Player.

Referenced by SetUndergroundPresence().

◆ OnUpdateTimerEnd()

void OnUpdateTimerEnd ( )
protected

◆ OnUpdateTimerIn()

void OnUpdateTimerIn ( )
protected

Definition at line 325 of file UndergroundHandlerClient.c.

326 {
328 return;
329 float value01 = m_AnimTimerLightBlend.GetValue();
332
333 }
Input value between 0 and 1, returns value adjusted by easing, no automatic clamping of input(do your...
Definition Easing.c:3
static float EaseInQuint(float t)
Definition Easing.c:78

References Easing::EaseInQuint(), m_AnimTimerLightBlend, and m_LightingLerp.

◆ OnUpdateTimerOut()

void OnUpdateTimerOut ( )
protected

Definition at line 335 of file UndergroundHandlerClient.c.

336 {
338 return;
339 float value01 = m_AnimTimerLightBlend.GetValue();
342 }
static float EaseOutCubic(float t)
Definition Easing.c:42

References Easing::EaseOutCubic(), m_AnimTimerLightBlend, and m_LightingLerp.

◆ ProcessEyeAcco()

void ProcessEyeAcco ( float timeSlice)
protected

Definition at line 165 of file UndergroundHandlerClient.c.

166 {
169 ApplyEyeAcco();
170 if (reachedTarget && !m_Player.m_UndergroundPresence)
171 {
172 GetRequester().Stop();
174 //m_NVRequester.SetUndergroundExposureCoef(1.0);
175 m_Player.KillUndergroundHandler();
176 }
177
178 }
bool CalculateEyeAcco(float timeSlice)
void ApplyEyeAcco()
void CalculateEyeAccoTarget()

References ApplyEyeAcco(), CalculateEyeAcco(), CalculateEyeAccoTarget(), GetRequester(), m_Player, and UpdateNVGRequester().

Referenced by Tick().

◆ ProcessLighting()

void ProcessLighting ( float timeSlice)
protected

Definition at line 180 of file UndergroundHandlerClient.c.

181 {
182#ifdef DEVELOPER
183 if (!DiagMenu.GetBool(DiagMenuIDs.UNDERGROUND_DISABLE_DARKENING))
184 GetGame().GetWorld().SetUserLightingLerp(m_LightingLerp);
185 else
186 GetGame().GetWorld().SetUserLightingLerp(0);
187#else
188 GetGame().GetWorld().SetUserLightingLerp(m_LightingLerp);
189#endif
190 }

References DiagMenu::GetBool(), GetGame(), and m_LightingLerp.

Referenced by Tick().

◆ ProcessSound()

void ProcessSound ( float timeSlice)
protected

Definition at line 192 of file UndergroundHandlerClient.c.

193 {
194 GetGame().GetWorld().SetExplicitVolumeFactor_EnvSounds2D(m_EyeAcco, 0);
195 if (m_AmbientSound)
196 {
198 //Print(m_AmbientSound.GetSoundVolume());
199 }
200 else
201 m_Player.PlaySoundSetLoop(m_AmbientSound, "Underground_SoundSet", 3, 3);
202 }
void SetSoundVolume(float volume)
Set the RELATIVE volume for the sound.

References GetGame(), m_AmbientSound, m_EyeAcco, m_Player, and EffectSound::SetSoundVolume().

◆ SetUndergroundPresence()

void SetUndergroundPresence ( UndergroundTrigger trigger)
protected

Definition at line 293 of file UndergroundHandlerClient.c.

294 {
296 EUndergroundPresence oldPresence = m_Player.m_UndergroundPresence;
297
298 if (trigger)
299 {
300 if (trigger.m_Type == EUndergroundTriggerType.OUTER)
302 else if (trigger.m_Type == EUndergroundTriggerType.TRANSITIONING)
303 newPresence = EUndergroundPresence.TRANSITIONING;
304 else if (trigger.m_Type == EUndergroundTriggerType.INNER)
306 }
307
308 if (newPresence != oldPresence)//was there a change ?
309 {
311 m_Player.SetUnderground(newPresence);
312 }
313
314
315 }
void OnUndergroundPresenceUpdate(EUndergroundPresence newPresence, EUndergroundPresence oldPresence)

References m_Player, and OnUndergroundPresenceUpdate().

Referenced by OnTriggerInsiderUpdate().

◆ Tick()

void Tick ( float timeSlice)
protected

Definition at line 204 of file UndergroundHandlerClient.c.

205 {
206 if (!m_Player.IsAlive())
207 return;
208
212
213#ifdef DIAG_DEVELOPER
214 if (DiagMenu.GetBool(DiagMenuIDs.UNDERGROUND_SHOW_BREADCRUMB))
215 DisplayDebugInfo(GetGame().GetWorld().GetEyeAccom(), m_LightingLerp);
216#endif
217
218 }
void ProcessSound()
void ProcessLighting(float timeSlice)
void ProcessEyeAcco(float timeSlice)

References DiagMenu::GetBool(), GetGame(), m_LightingLerp, m_Player, ProcessEyeAcco(), ProcessLighting(), and ProcessSound().

◆ UndergroundHandlerClient()

void UndergroundHandlerClient ( PlayerBase player)
protected

Definition at line 35 of file UndergroundHandlerClient.c.

36 {
37 GetGame().GetWorld().LoadUserLightingCfg(UNDERGROUND_LIGHTING, "Underground");
40 }
PPERequester_CameraNV m_NVRequester
const string UNDERGROUND_LIGHTING

References GetGame(), m_NVRequester, m_Player, and UNDERGROUND_LIGHTING.

Referenced by ManBase::GetUndergroundHandler(), OnEnterClientEvent(), and OnLeaveClientEvent().

◆ UpdateNVGRequester()

void UpdateNVGRequester ( float value)
protected

Definition at line 238 of file UndergroundHandlerClient.c.

239 {
240 m_NVRequester.SetUndergroundExposureCoef(value);
241 }

References m_NVRequester.

Referenced by ApplyEyeAcco(), and ProcessEyeAcco().

◆ ~UndergroundHandlerClient()

Definition at line 42 of file UndergroundHandlerClient.c.

43 {
44 if (GetGame())
45 {
46 GetGame().GetWorld().SetExplicitVolumeFactor_EnvSounds2D(1, 0.5);
47 GetGame().GetWeather().SuppressLightningSimulation(false);
48 GetGame().GetWorld().SetUserLightingLerp(0);
51 }
52 }
override void Stop()
Stops sound.

References GetGame(), m_AmbientSound, and EffectSound::Stop().

Variable Documentation

◆ ACCO_MODIFIER

const float ACCO_MODIFIER = 1

Definition at line 16 of file UndergroundHandlerClient.c.

Referenced by CalculateEyeAccoTarget().

◆ DEFAULT_INTERPOLATION_SPEED

const float DEFAULT_INTERPOLATION_SPEED = 7

Definition at line 17 of file UndergroundHandlerClient.c.

Referenced by OnTriggerInsiderUpdate().

◆ DISTANCE_CUTOFF

const float DISTANCE_CUTOFF = 5

Definition at line 15 of file UndergroundHandlerClient.c.

Referenced by CalculateEyeAccoTarget().

◆ LIGHT_BLEND_SPEED_IN

enum EUndergroundPresence LIGHT_BLEND_SPEED_IN = 5

◆ LIGHT_BLEND_SPEED_OUT

const float LIGHT_BLEND_SPEED_OUT = 1.75

Definition at line 12 of file UndergroundHandlerClient.c.

Referenced by OnUndergroundPresenceUpdate().

◆ m_AccoInterpolationSpeed

float m_AccoInterpolationSpeed
protected

Definition at line 27 of file UndergroundHandlerClient.c.

Referenced by CalculateEyeAcco(), and OnTriggerInsiderUpdate().

◆ m_AmbientSound

EffectSound m_AmbientSound
protected

◆ m_AnimTimerLightBlend

ref AnimationTimer m_AnimTimerLightBlend
protected

◆ m_EyeAcco

float m_EyeAcco = 1
protected

Definition at line 28 of file UndergroundHandlerClient.c.

Referenced by ApplyEyeAcco(), CalculateEyeAcco(), and ProcessSound().

◆ m_EyeAccoTarget

float m_EyeAccoTarget = 1
protected

◆ m_InsideTriggers

ref set<UndergroundTrigger> m_InsideTriggers = new set<UndergroundTrigger>()
protected

◆ m_LightingLerp

◆ m_LightingLerpTarget

float m_LightingLerpTarget
protected

Definition at line 29 of file UndergroundHandlerClient.c.

◆ m_NVRequester

PPERequester_CameraNV m_NVRequester
protected

Definition at line 23 of file UndergroundHandlerClient.c.

Referenced by UndergroundHandlerClient(), and UpdateNVGRequester().

◆ m_Player

PlayerBase m_Player
protected

Definition at line 21 of file UndergroundHandlerClient.c.

◆ m_Requester

◆ m_TransitionalTrigger

UndergroundTrigger m_TransitionalTrigger
protected

◆ MAX_RATIO

const float MAX_RATIO = 0.9

Definition at line 13 of file UndergroundHandlerClient.c.

Referenced by CalculateEyeAccoTarget().

◆ RATIO_CUTOFF

const float RATIO_CUTOFF = 0

Definition at line 14 of file UndergroundHandlerClient.c.

Referenced by CalculateEyeAccoTarget().

◆ UNDERGROUND_LIGHTING

const string UNDERGROUND_LIGHTING = "dz\\data\\lighting\\lighting_underground.txt"

Definition at line 18 of file UndergroundHandlerClient.c.

Referenced by UndergroundHandlerClient().