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

Go to the source code of this file.

Classes

class  DayZPlayerCameraBase
 this is main camera class More...
 

Functions

void DayZPlayerCameraOptics (DayZPlayer pPlayer, HumanInputController pInput)
 
override void Init ()
 Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)
 
override EntityAI GetCurrentSightEntity ()
 
override bool GetCurrentSightInfo (out vector camPos, out vector camDir)
 
override void OnActivate (DayZPlayerCamera pPrevCamera, DayZPlayerCameraResult pPrevCameraResult)
 
override void AdjustCameraParameters (float pDt, inout DayZPlayerCameraResult pOutResult)
 
override float HoldBreathFOVEffect (float pDt)
 
override void SetCameraPP (bool state, DayZPlayerCamera launchedFrom)
 
override string GetCameraName ()
 
override void SetCameraPPDelay (DayZPlayerCamera pPrevCamera)
 
override void SendRecoilOffsetZ (float offset)
 

Variables

class DayZPlayerCameraIronsights extends DayZPlayerCameraBase CONST_NEARPLANE_OPTICS = 0.06
 
float m_RecoilOffsetZ = 0.0
 

Function Documentation

◆ AdjustCameraParameters()

override void AdjustCameraParameters ( float pDt,
inout DayZPlayerCameraResult pOutResult )
protected

Definition at line 377 of file DayZPlayerCameraIronsights.c.

378 {
379 pOutResult.m_iDirectBone = m_iBoneIndex;
380 pOutResult.m_iDirectBoneMode = 4;
381
382 pOutResult.m_fFovAbsolute = HoldBreathFOVEffect(pDt);
383
384 pOutResult.m_bUpdateWhenBlendOut = false;
385 pOutResult.m_fDistance = 0;
386 pOutResult.m_fUseHeading = 0;
387 pOutResult.m_fInsideCamera = 1.0;
388 pOutResult.m_fShootFromCamera = m_fShootFromCamera;
389
390 if (!m_opticsUsed)
392 else
393 pOutResult.m_fNearPlane = Math.Clamp(m_opticsUsed.GetNearPlaneValue() - m_RecoilOffsetZ, CONST_NEARPLANE_OPTICS, 10.0); //some sufficiently nonsensical max
394 }
int m_iBoneIndex
main bone
ItemOptics m_opticsUsed
override float HoldBreathFOVEffect(float pDt)
float m_RecoilOffsetZ
class DayZPlayerCameraIronsights extends DayZPlayerCameraBase CONST_NEARPLANE_OPTICS
float GetNearPlaneValue()
Definition ItemOptics.c:468
Definition EnMath.c:7
float m_fShootFromCamera
1(default) - uses shoot from camera (+aiming sway), 0 pure weapon shoot (ironsights == 0)
Definition dayzplayer.c:71
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.

References Math::Clamp(), CONST_NEARPLANE_OPTICS, ItemOptics::GetNearPlaneValue(), HoldBreathFOVEffect(), m_fShootFromCamera, m_iBoneIndex, m_opticsUsed, and m_RecoilOffsetZ.

◆ DayZPlayerCameraOptics()

void DayZPlayerCameraOptics ( DayZPlayer pPlayer,
HumanInputController pInput )
protected

Definition at line 337 of file DayZPlayerCameraIronsights.c.

338 {
339 if (!temp_array)
340 temp_array = new array<float>;
342 }

References m_fShootFromCamera.

Referenced by ManBase::HideClothing(), ItemOptics::InitCameraOverrideProperties(), OnActivate(), and DayZPlayerCameras::RegisterCameras().

◆ GetCameraName()

override string GetCameraName ( )
protected

Definition at line 520 of file DayZPlayerCameraIronsights.c.

521 {
522 return "DayZPlayerCameraOptics";
523 }

◆ GetCurrentSightEntity()

override EntityAI GetCurrentSightEntity ( )
protected

Definition at line 352 of file DayZPlayerCameraIronsights.c.

353 {
354 return m_opticsUsed;
355 }

References m_opticsUsed.

Referenced by HoldBreathFOVEffect().

◆ GetCurrentSightInfo()

override bool GetCurrentSightInfo ( out vector camPos,
out vector camDir )
protected

Definition at line 357 of file DayZPlayerCameraIronsights.c.

358 {
359 if (m_opticsUsed)
360 {
363 return true;
364 }
365 return false;
366 }
proto native bool UseWeaponIronsightsOverride(bool state)
switches into ironsights override settings
proto native void GetCameraPoint(out vector pos, out vector dir)
gets camera position & direction in model space of optics entity

References ItemOptics::GetCameraPoint(), m_opticsUsed, and ItemOptics::UseWeaponIronsightsOverride().

◆ HoldBreathFOVEffect()

override float HoldBreathFOVEffect ( float pDt)
protected

Definition at line 396 of file DayZPlayerCameraIronsights.c.

397 {
398 //hotfix; two cameras exist and update simultaneously during transition, even if optics/weapons is no longer present!
399 /*PlayerBase player = PlayerBase.Cast(m_pPlayer);
400 if (player && player.GetCurrentCamera() != this)
401 return 0.6;*/
402
404 if (optics)
405 {
406 if (optics.GetCurrentStepFOV() >= GameConstants.DZPLAYER_CAMERA_FOV_EYEZOOM && (m_pPlayer.IsHoldingBreath() || m_pPlayer.GetEyeZoomLevel()))
408 else if (m_isEntering) //sets FOV immediatelly to avoid "floating camera" effect
409 {
410 m_fFovAbsolute = optics.GetCurrentStepFOV();
411 m_isEntering = false;
412 }
413 else
414 {
415 m_fFovAbsolute = Math.SmoothCD(m_fFovAbsolute, optics.GetCurrentStepFOV(), m_fFovAbsVel, 0.1, 1000, pDt);
416 //m_fFovAbsolute = optics.GetCurrentStepFOV();
417 }
418 return m_fFovAbsolute;
419 }
420 else
421 {
422 //Error("optic camera, but there is no optic item or optic on weapon"); //camera update ticks on transitions as well, caused problems
423 return 0.6; //TODO figure some other way to get original FOV here!
424 }
425 }
float m_fFovAbsVel[1]
override EntityAI GetCurrentSightEntity()
override int GetEyeZoomLevel()
DayZPlayer m_pPlayer
data
Definition dayzplayer.c:135
float m_fFovAbsolute
fov absolute value override - -1.0 default, if set - overrides absolute fov setting
Definition dayzplayer.c:60
const float DZPLAYER_CAMERA_FOV_EYEZOOM
FOV (vertical angle/2) in radians. Take care to modify also in "basicDefines.hpp".
Definition constants.c:834
static proto float SmoothCD(float val, float target, inout float velocity[], float smoothTime, float maxVelocity, float dt)
Does the CD smoothing function - easy in | easy out / S shaped smoothing.

References GameConstants::DZPLAYER_CAMERA_FOV_EYEZOOM, GetCurrentSightEntity(), DayZPlayer::GetEyeZoomLevel(), m_fFovAbsolute, m_fFovAbsVel, m_pPlayer, and Math::SmoothCD().

Referenced by AdjustCameraParameters().

◆ Init()

override void Init ( )
protected

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

pre-init arrays

Definition at line 344 of file DayZPlayerCameraIronsights.c.

345 {
347 SetCameraNV(true);
348 else
349 SetCameraNV(false);
350 }
void SetCameraNV(bool nightvision)
bool IsWorking()
Definition ItemOptics.c:188
bool IsNVOptic()
Definition ItemOptics.c:399

References ItemOptics::IsNVOptic(), ItemOptics::IsWorking(), m_opticsUsed, and SetCameraNV().

Referenced by DayZPlayerCameraBase(), and DayZPlayerCameraBase::DayZPlayerCameraIronsights().

◆ OnActivate()

override void OnActivate ( DayZPlayerCamera pPrevCamera,
DayZPlayerCameraResult pPrevCameraResult )
protected

Definition at line 368 of file DayZPlayerCameraIronsights.c.

369 {
371
373 if (player && m_opticsUsed)
374 GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(player.HideClothing, m_CameraPPDelay * 1000, false, m_opticsUsed, true);
375 }
float m_CameraPPDelay
proto native CGame GetGame()
const int CALL_CATEGORY_GUI
Definition tools.c:9

References CALL_CATEGORY_GUI, GetGame(), m_CameraPPDelay, m_opticsUsed, and m_pPlayer.

◆ SendRecoilOffsetZ()

override void SendRecoilOffsetZ ( float offset)
protected

Definition at line 539 of file DayZPlayerCameraIronsights.c.

540 {
542 }

References m_RecoilOffsetZ.

◆ SetCameraPP()

override void SetCameraPP ( bool state,
DayZPlayerCamera launchedFrom )
protected

Definition at line 427 of file DayZPlayerCameraIronsights.c.

428 {
429 //Print("SetCameraPP - optics");
430 if (PlayerBase.Cast(m_pPlayer) && launchedFrom.Type() != PlayerBase.Cast(m_pPlayer).GetCurrentPlayerCamera().Type())
431 {
432 //Print("DayZPlayerCameraOptics | SetCameraPP | skipping, wrong camera type active!");
433 return;
434 }
435
436 if (!state || !m_opticsUsed)
437 {
438 m_RequesterADS.Stop();
439
440 if (IsCameraNV())
442 else
444
445 if (m_weaponUsed)
446 m_weaponUsed.HideWeaponBarrel(false);
447 }
448 else
449 {
452 float gauss = 0.0;
453 temp_array = {false, 0.0, 0.0, 0.0, 0.0, 1.0};
454
455 // 1x scopes only
456 if (m_opticsUsed.AllowsDOF() && !NVGoggles.Cast(m_opticsUsed))
457 {
458 if (m_weaponUsed)
459 {
460 if (m_opticsUsed.GetOpticsDOF().Count() == 6)
461 temp_array = m_opticsUsed.GetOpticsDOF();
462 else
463 {
464 temp_array = m_weaponUsed.GetWeaponDOF(); //TODO should some optics have own DOF settings (different eye point)?
465 }
466
467 if (temp_array.Count() != 6)
468 temp_array = {false, 0.0, 0.0, 0.0, 0.0, 1.0};
469 }
470
471 m_RequesterADS.SetValuesIronsights(temp_array); //DOF only
472
473 // optics NV mode
475 {
476 SetCameraNV(true);
478 }
479 else
480 {
481 if (IsCameraNV())
483 else
485 }
486 }
487 else //magnifying scopes
488 {
489 // optics mask
492
493 //optics lens
496
497 //optics blur
498 if (m_opticsUsed.GetOpticsPPBlur() != 0)
500
501 m_RequesterADS.SetValuesOptics(mask_values, lens_values, gauss);
502
503 // optics NV mode
505 {
506 SetCameraNV(true);
508 }
509 else
510 {
511 SetNVPostprocess(NVTypes.NONE); //magnifying optics do not combine with other NV sources (would render NV optics obsolete)
512 }
513 }
514
515 if (m_weaponUsed)
516 m_weaponUsed.HideWeaponBarrel(true);
517 }
518 }
Weapon_Base m_weaponUsed
bool IsCameraNV()
void SetNVPostprocess(int NVtype)
DayZPlayerCameraOptics handles this separately, otherwise it takes active NVType from PlayerBase::Get...
int GetCameraNVType()
ref array< float > GetOpticsPPLens()
Definition ItemOptics.c:459
bool AllowsDOF()
returns 'true' for non-magnifying optics
Definition ItemOptics.c:394
int GetCurrentNVType()
Definition ItemOptics.c:404
ref array< float > GetOpticsPPMask()
Definition ItemOptics.c:455
float GetOpticsPPBlur()
Definition ItemOptics.c:463
ref array< float > GetOpticsDOF()
Definition ItemOptics.c:451

References ItemOptics::AllowsDOF(), GetCameraNVType(), ItemOptics::GetCurrentNVType(), ItemOptics::GetOpticsDOF(), ItemOptics::GetOpticsPPBlur(), ItemOptics::GetOpticsPPLens(), ItemOptics::GetOpticsPPMask(), IsCameraNV(), ItemOptics::IsNVOptic(), m_opticsUsed, m_pPlayer, m_weaponUsed, SetCameraNV(), and SetNVPostprocess().

◆ SetCameraPPDelay()

override void SetCameraPPDelay ( DayZPlayerCamera pPrevCamera)
protected

Definition at line 525 of file DayZPlayerCameraIronsights.c.

526 {
527 if (pPrevCamera.GetCameraName() == "DayZPlayerCameraIronsights")
529 else if (pPrevCamera.GetCameraName() == "DayZPlayerCamera1stPerson")
530 {
531 m_CameraPPDelay = DayZPlayerCameras.TIME_CAMERACHANGE_02 - 0.05; //changed to accomodate handheld optics, had to be changed here also
532 }
533 else if (!pPrevCamera.IsCamera3rdRaised())
535 else
537 }
static const float TIME_CAMERACHANGE_03
static const float TIME_CAMERACHANGE_02

References m_CameraPPDelay, DayZPlayerCameras::TIME_CAMERACHANGE_02, and DayZPlayerCameras::TIME_CAMERACHANGE_03.

Variable Documentation

◆ CONST_NEARPLANE_OPTICS

class DayZPlayerCameraIronsights extends DayZPlayerCameraBase CONST_NEARPLANE_OPTICS = 0.06

Referenced by AdjustCameraParameters().

◆ m_RecoilOffsetZ

float m_RecoilOffsetZ = 0.0
protected

Definition at line 335 of file DayZPlayerCameraIronsights.c.

Referenced by AdjustCameraParameters(), and SendRecoilOffsetZ().