DayZ 1.24
Loading...
Searching...
No Matches
RecoilBase Class Reference
Inheritance diagram for RecoilBase:
[legend]
Collaboration diagram for RecoilBase:
[legend]

Protected Member Functions

void RecoilBase (Weapon_Base weapon)
 
void Init ()
 
Weapon_Base GetWeapon ()
 
void PostInit (Weapon_Base weapon)
 
void Destroy ()
 Destroys this object next update tick.
 
void Update (SDayZPlayerAimingModel pModel, out float axis_mouse_x, out float axis_mouse_y, out float axis_hands_x, out float axis_hands_y, float pDt)
 
void ApplyCamOffset (SDayZPlayerAimingModel pModel)
 
void ApplyHandsOffset (float pDt, out float pRecResultX, out float pRecResultY)
 
void ApplyMouseOffset (float pDt, out float pRecResultX, out float pRecResultY)
 
vector GetRecoilModifier (Weapon_Base weapon)
 
vector GetPositionOnCurve (array< vector > points, float time)
 

Protected Attributes

bool m_DeleteRequested
 
float m_Time
 
float m_ReloadTime
 
vector m_RecoilModifier
 
bool m_IsClient
 
float m_MouseOffsetRangeMin
 
float m_MouseOffsetRangeMax
 
float m_MouseOffsetRelativeTime = 1
 
float m_HandsOffsetRelativeTime = 1
 
float m_CamOffsetRelativeTime = 1
 
float m_CamOffsetDistance = 0.05
 
float m_MouseOffsetDistance
 
float m_TimeNormalized
 
vector m_MouseOffsetTarget
 
vector m_MouseOffsetTargetAccum
 
float m_Angle
 
ref array< vectorm_HandsCurvePoints
 

Private Attributes

bool m_DebugMode
 
Weapon_Base m_Weapon
 
PlayerBase m_Player
 

Detailed Description

Definition at line 1 of file RecoilBase.c.

Constructor & Destructor Documentation

◆ RecoilBase()

void RecoilBase::RecoilBase ( Weapon_Base weapon)
inlineprotected

Definition at line 29 of file RecoilBase.c.

30 {
32 //m_DebugMode = false;
33 m_DebugMode = GetDayZGame().IsAimLogEnabled();
34 m_Player = PlayerBase.Cast(weapon.GetHierarchyRootPlayer());
36 Init();
38 }
DayZGame GetDayZGame()
Definition DayZGame.c:3530
PlayerBase m_Player
Definition RecoilBase.c:6
void PostInit(Weapon_Base weapon)
Definition RecoilBase.c:47
Weapon_Base m_Weapon
Definition RecoilBase.c:5
void Init()
ref array< vector > m_HandsCurvePoints
Definition RecoilBase.c:27
bool m_DebugMode
Definition RecoilBase.c:3

References GetDayZGame(), Init(), m_DebugMode, m_HandsCurvePoints, m_Player, m_Weapon, and PostInit().

Member Function Documentation

◆ ApplyCamOffset()

void RecoilBase::ApplyCamOffset ( SDayZPlayerAimingModel pModel)
inlineprotected

Definition at line 100 of file RecoilBase.c.

101 {
103 float offset = 0;
105 if (time == 1)
106 offset = 0;
107 else
109
110 pModel.m_fCamPosOffsetZ = offset;
111
112 m_Player.GetCurrentCamera().SendRecoilOffsetZ(offset);
113 }
Input value between 0 and 1, returns value adjusted by easing, no automatic clamping of input(do your...
Definition Easing.c:3
static float EaseOutBack(float t, float magnitude=1.70158)
Definition Easing.c:160
Definition EnMath.c:7
float m_CamOffsetRelativeTime
Definition RecoilBase.c:17
float m_CamOffsetDistance
Definition RecoilBase.c:18
float m_TimeNormalized
Definition RecoilBase.c:20
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
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'.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...

References Math::Clamp(), Easing::EaseOutBack(), Math::InverseLerp(), Math::Lerp(), m_CamOffsetDistance, m_CamOffsetRelativeTime, m_Player, and m_TimeNormalized.

Referenced by Update().

◆ ApplyHandsOffset()

void RecoilBase::ApplyHandsOffset ( float pDt,
out float pRecResultX,
out float pRecResultY )
inlineprotected

Definition at line 115 of file RecoilBase.c.

116 {
119
120 /*if(m_DebugMode)
121 {
122 PrintString("pos_on_curve: " + pos_on_curve.ToString());
123 PrintString("normalized time: " + m_TimeNormalized.ToString());
124 PrintString("elapsed time: " + m_Time.ToString());
125 PrintString("curve pos x: " + pos_on_curve[0].ToString());
126 PrintString("curve pos y: " + pos_on_curve[1].ToString());
127 PrintString("relative_time: " + relative_time.ToString());
128 }*/
129
132 }
vector GetPositionOnCurve(array< vector > points, float time)
Definition RecoilBase.c:188
float m_HandsOffsetRelativeTime
Definition RecoilBase.c:16

References Math::Clamp(), GetPositionOnCurve(), m_HandsCurvePoints, m_HandsOffsetRelativeTime, and m_TimeNormalized.

Referenced by Update().

◆ ApplyMouseOffset()

void RecoilBase::ApplyMouseOffset ( float pDt,
out float pRecResultX,
out float pRecResultY )
inlineprotected

Definition at line 134 of file RecoilBase.c.

135 {
136#ifdef DEVELOPER
137 if (m_DebugMode)
138 {
140 PrintString("RecoilBase | ApplyMouseOffset processing: " + b1);
141 PrintString("RecoilBase | m_MouseOffsetTargetAccum : " + m_MouseOffsetTargetAccum.ToString());
142 PrintString("RecoilBase | m_MouseOffsetTarget : " + m_MouseOffsetTarget.ToString());
143 }
144#endif
145
147 {
149
152
154 {
157 }
158
161
164
165 /*if(m_DebugMode)
166 {
167 PrintString( "delta x: "+ delta_mouse_offset_x );
168 PrintString( "delta y: "+ delta_mouse_offset_y );
169 PrintString( "target x: "+ m_MouseOffsetTarget[0] );
170 PrintString( "target y: "+ m_MouseOffsetTarget[1] );
171 PrintString( "accum x: "+ m_MouseOffsetTargetAccum[0] );
172 PrintString( "accum y: "+ m_MouseOffsetTargetAccum[1] );
173 }*/
174 }
175#ifdef DEVELOPER
176 if (m_DebugMode)
177 PrintString("RecoilBase | pRecResultY: " + pRecResultY);
178#endif
179 }
float m_ReloadTime
Definition RecoilBase.c:9
vector m_MouseOffsetTargetAccum
Definition RecoilBase.c:23
float m_MouseOffsetRelativeTime
Definition RecoilBase.c:15
vector m_MouseOffsetTarget
Definition RecoilBase.c:22
proto string ToString(bool beautify=true)
Vector to string.
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
Definition EnScript.c:344

References Math::Clamp(), m_DebugMode, m_MouseOffsetRelativeTime, m_MouseOffsetTarget, m_MouseOffsetTargetAccum, m_ReloadTime, PrintString(), and vector::ToString().

Referenced by Update().

◆ Destroy()

void RecoilBase::Destroy ( )
inlineprotected

Destroys this object next update tick.

Definition at line 62 of file RecoilBase.c.

63 {
64 m_DeleteRequested = true;
65 }
bool m_DeleteRequested
Definition RecoilBase.c:7

References m_DeleteRequested.

Referenced by Update().

◆ GetPositionOnCurve()

vector RecoilBase::GetPositionOnCurve ( array< vector > points,
float time )
inlineprotected

Definition at line 188 of file RecoilBase.c.

189 {
190 return Math3D.Curve(ECurveType.CatmullRom, time, points);
191 }
ECurveType
Definition EnMath3D.c:21
static proto native vector Curve(ECurveType type, float param, notnull array< vector > points)
Computes curve.

References Math3D::Curve().

Referenced by ApplyHandsOffset().

◆ GetRecoilModifier()

vector RecoilBase::GetRecoilModifier ( Weapon_Base weapon)
inlineprotected

Definition at line 181 of file RecoilBase.c.

182 {
183 if (weapon)
184 return weapon.GetPropertyModifierObject().m_RecoilModifiers;
185 else return "1 1 1";
186 }

Referenced by PostInit().

◆ GetWeapon()

Weapon_Base RecoilBase::GetWeapon ( )
inlineprotected

Definition at line 42 of file RecoilBase.c.

43 {
44 return m_Weapon;
45 }

References m_Weapon.

Referenced by PostInit().

◆ Init()

void RecoilBase::Init ( )
protected

Referenced by RecoilBase().

◆ PostInit()

void RecoilBase::PostInit ( Weapon_Base weapon)
inlineprotected

Definition at line 47 of file RecoilBase.c.

48 {
49 int muzzleIndex = weapon.GetCurrentMuzzle();
50 m_Angle = m_Player.GetRandomGeneratorSyncManager().GetRandomInRange(RandomGeneratorSyncUsage.RGSRecoil, m_MouseOffsetRangeMin, m_MouseOffsetRangeMax);
53
54 m_ReloadTime = weapon.GetReloadTime(muzzleIndex);
57 m_IsClient = !GetGame().IsDedicatedServer();
59 }
bool m_IsClient
Definition RecoilBase.c:11
vector GetRecoilModifier(Weapon_Base weapon)
Definition RecoilBase.c:181
float m_MouseOffsetDistance
Definition RecoilBase.c:19
float m_MouseOffsetRangeMax
Definition RecoilBase.c:14
float m_Angle
Definition RecoilBase.c:24
vector m_RecoilModifier
Definition RecoilBase.c:10
float m_MouseOffsetRangeMin
Definition RecoilBase.c:13
Weapon_Base GetWeapon()
Definition RecoilBase.c:42
proto static native vector YawToVector(float yaw)
Returns vector of yaw.
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.

References GetGame(), GetRecoilModifier(), GetWeapon(), m_Angle, m_CamOffsetDistance, m_DebugMode, m_IsClient, m_MouseOffsetDistance, m_MouseOffsetRangeMax, m_MouseOffsetRangeMin, m_MouseOffsetTarget, m_Player, m_RecoilModifier, m_ReloadTime, Print(), and vector::YawToVector().

Referenced by RecoilBase().

◆ Update()

void RecoilBase::Update ( SDayZPlayerAimingModel pModel,
out float axis_mouse_x,
out float axis_mouse_y,
out float axis_hands_x,
out float axis_hands_y,
float pDt )
inlineprotected

Definition at line 68 of file RecoilBase.c.

69 {
71 delete this;
72
75
78 if (m_IsClient)
80#ifdef DEVELOPER
81 if (m_DebugMode)
82 PrintString("RecoilBase | BEFORE | axis_mouse_y: " + axis_mouse_y.ToString());
83#endif
86
89
90#ifdef DEVELOPER
91 if (m_DebugMode)
92 PrintString("RecoilBase | AFTER | axis_mouse_y: " + axis_mouse_y.ToString());
93#endif
94 m_Time += pDt;
95
96 if (m_Time >= m_ReloadTime)
97 Destroy();
98 }
void Destroy()
Destroys this object next update tick.
Definition RecoilBase.c:62
void ApplyMouseOffset(float pDt, out float pRecResultX, out float pRecResultY)
Definition RecoilBase.c:134
void ApplyHandsOffset(float pDt, out float pRecResultX, out float pRecResultY)
Definition RecoilBase.c:115
float m_Time
Definition RecoilBase.c:8
void ApplyCamOffset(SDayZPlayerAimingModel pModel)
Definition RecoilBase.c:100

References ApplyCamOffset(), ApplyHandsOffset(), ApplyMouseOffset(), Math::Clamp(), Destroy(), Math::InverseLerp(), m_DebugMode, m_DeleteRequested, m_IsClient, m_RecoilModifier, m_ReloadTime, m_Time, m_TimeNormalized, and PrintString().

Member Data Documentation

◆ m_Angle

float RecoilBase::m_Angle
protected

Definition at line 24 of file RecoilBase.c.

Referenced by PostInit().

◆ m_CamOffsetDistance

◆ m_CamOffsetRelativeTime

◆ m_DebugMode

bool RecoilBase::m_DebugMode
private

Definition at line 3 of file RecoilBase.c.

Referenced by ApplyMouseOffset(), PostInit(), RecoilBase(), and Update().

◆ m_DeleteRequested

bool RecoilBase::m_DeleteRequested
protected

Definition at line 7 of file RecoilBase.c.

Referenced by Destroy(), and Update().

◆ m_HandsCurvePoints

◆ m_HandsOffsetRelativeTime

◆ m_IsClient

bool RecoilBase::m_IsClient
protected

Definition at line 11 of file RecoilBase.c.

Referenced by PostInit(), and Update().

◆ m_MouseOffsetDistance

◆ m_MouseOffsetRangeMax

◆ m_MouseOffsetRangeMin

◆ m_MouseOffsetRelativeTime

◆ m_MouseOffsetTarget

vector RecoilBase::m_MouseOffsetTarget
protected

Definition at line 22 of file RecoilBase.c.

Referenced by ApplyMouseOffset(), and PostInit().

◆ m_MouseOffsetTargetAccum

vector RecoilBase::m_MouseOffsetTargetAccum
protected

Definition at line 23 of file RecoilBase.c.

Referenced by ApplyMouseOffset().

◆ m_Player

◆ m_RecoilModifier

vector RecoilBase::m_RecoilModifier
protected

Definition at line 10 of file RecoilBase.c.

Referenced by PostInit(), and Update().

◆ m_ReloadTime

float RecoilBase::m_ReloadTime
protected

Definition at line 9 of file RecoilBase.c.

Referenced by ApplyMouseOffset(), PostInit(), and Update().

◆ m_Time

float RecoilBase::m_Time
protected

Definition at line 8 of file RecoilBase.c.

Referenced by Update().

◆ m_TimeNormalized

float RecoilBase::m_TimeNormalized
protected

Definition at line 20 of file RecoilBase.c.

Referenced by ApplyCamOffset(), ApplyHandsOffset(), and Update().

◆ m_Weapon

Weapon_Base RecoilBase::m_Weapon
private

Definition at line 5 of file RecoilBase.c.

Referenced by GetWeapon(), and RecoilBase().


The documentation for this class was generated from the following file: