DayZ 1.24
Loading...
Searching...
No Matches
RecoilBase.c
Go to the documentation of this file.
2{
4
7 protected bool m_DeleteRequested;
8 protected float m_Time;//how much time has elapsed since first update
9 protected float m_ReloadTime;//reload time config parameter of the weapon
11 protected bool m_IsClient;
12 // for mouse offset
13 float m_MouseOffsetRangeMin;//in degrees min
14 float m_MouseOffsetRangeMax;//in degrees max
15 float m_MouseOffsetRelativeTime = 1;//[0..1] a time it takes to move the mouse the required distance relative to the reload time of the weapon(firing mode)
16 float m_HandsOffsetRelativeTime = 1;//[0..1] a time it takes to move the hands the required distance given by the curve relative to the reload time of the weapon(firing mode)
17 float m_CamOffsetRelativeTime = 1;//[0..1] a time it takes to move the camera the required distance relative to the reload time of the weapon(firing mode)
18 float m_CamOffsetDistance = 0.05;//how far the camera will travel along the z-axis in cm
19 float m_MouseOffsetDistance;//how far should the mouse travel
21 //protected float m_MouseOffsetResult;//in degrees max
22 protected vector m_MouseOffsetTarget;//move the mouse towards this point
23 protected vector m_MouseOffsetTargetAccum;//the overall mouse offset so far(all deltas accumulated)
24 protected float m_Angle;//result between the min and max
25 // mouse end
26
28
30 {
32 //m_DebugMode = false;
33 m_DebugMode = GetDayZGame().IsAimLogEnabled();
34 m_Player = PlayerBase.Cast(weapon.GetHierarchyRootPlayer());
36 Init();
38 }
39
40 void Init();
41
43 {
44 return m_Weapon;
45 }
46
60
62 void Destroy()
63 {
64 m_DeleteRequested = true;
65 }
66
67 // called externally per update, not to be overriden in children
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 }
99
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 }
114
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 }
133
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 }
180
182 {
183 if (weapon)
184 return weapon.GetPropertyModifierObject().m_RecoilModifiers;
185 else return "1 1 1";
186 }
187
189 {
190 return Math3D.Curve(ECurveType.CatmullRom, time, points);
191 }
192}
DayZGame GetDayZGame()
Definition DayZGame.c:3530
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_ReloadTime
Definition RecoilBase.c:9
bool m_IsClient
Definition RecoilBase.c:11
void RecoilBase(Weapon_Base weapon)
Definition RecoilBase.c:29
void Destroy()
Destroys this object next update tick.
Definition RecoilBase.c:62
vector GetRecoilModifier(Weapon_Base weapon)
Definition RecoilBase.c:181
float m_CamOffsetRelativeTime
Definition RecoilBase.c:17
float m_CamOffsetDistance
Definition RecoilBase.c:18
float m_MouseOffsetDistance
Definition RecoilBase.c:19
PlayerBase m_Player
Definition RecoilBase.c:6
float m_MouseOffsetRangeMax
Definition RecoilBase.c:14
vector GetPositionOnCurve(array< vector > points, float time)
Definition RecoilBase.c:188
bool m_DeleteRequested
Definition RecoilBase.c:7
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)
Definition RecoilBase.c:68
void PostInit(Weapon_Base weapon)
Definition RecoilBase.c:47
vector m_MouseOffsetTargetAccum
Definition RecoilBase.c:23
float m_TimeNormalized
Definition RecoilBase.c:20
void ApplyMouseOffset(float pDt, out float pRecResultX, out float pRecResultY)
Definition RecoilBase.c:134
float m_Angle
Definition RecoilBase.c:24
void ApplyHandsOffset(float pDt, out float pRecResultX, out float pRecResultY)
Definition RecoilBase.c:115
float m_MouseOffsetRelativeTime
Definition RecoilBase.c:15
float m_HandsOffsetRelativeTime
Definition RecoilBase.c:16
vector m_MouseOffsetTarget
Definition RecoilBase.c:22
float m_Time
Definition RecoilBase.c:8
Weapon_Base m_Weapon
Definition RecoilBase.c:5
void ApplyCamOffset(SDayZPlayerAimingModel pModel)
Definition RecoilBase.c:100
vector m_RecoilModifier
Definition RecoilBase.c:10
void Init()
float m_MouseOffsetRangeMin
Definition RecoilBase.c:13
Weapon_Base GetWeapon()
Definition RecoilBase.c:42
ref array< vector > m_HandsCurvePoints
Definition RecoilBase.c:27
bool m_DebugMode
Definition RecoilBase.c:3
proto string ToString(bool beautify=true)
Vector to string.
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.
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
Definition EnScript.c:344
ECurveType
Definition EnMath3D.c:21
static proto native vector Curve(ECurveType type, float param, notnull array< vector > points)
Computes curve.
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,...