7 protected bool m_DeleteRequested;
8 protected float m_Time;
9 protected float m_ReloadTime;
10 protected vector m_RecoilModifier;
11 protected bool m_IsClient;
13 float m_MouseOffsetRangeMin;
14 float m_MouseOffsetRangeMax;
15 float m_MouseOffsetRelativeTime = 1;
16 float m_HandsOffsetRelativeTime = 1;
17 float m_CamOffsetRelativeTime = 1;
18 float m_CamOffsetDistance = 0.05;
19 float m_MouseOffsetDistance;
20 float m_TimeNormalized;
22 protected vector m_MouseOffsetTarget;
23 protected vector m_MouseOffsetTargetAccum;
24 protected float m_Angle;
49 int muzzleIndex = weapon.GetCurrentMuzzle();
51 m_RecoilModifier = GetRecoilModifier( GetWeapon() );
52 if(m_DebugMode)
Print(m_Angle);
54 m_ReloadTime = weapon.GetReloadTime(muzzleIndex);
55 m_MouseOffsetTarget =
vector.YawToVector(m_Angle);
56 m_MouseOffsetTarget = m_MouseOffsetTarget * m_MouseOffsetDistance;
57 m_IsClient = !
GetGame().IsDedicatedServer();
58 m_CamOffsetDistance *= m_RecoilModifier[2];
68 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 )
75 m_TimeNormalized =
Math.InverseLerp(0, m_ReloadTime,
m_Time);
76 m_TimeNormalized =
Math.Clamp(m_TimeNormalized, 0,0.99);
78 ApplyMouseOffset(pDt, axis_mouse_x, axis_mouse_y);
79 ApplyHandsOffset(pDt, axis_hands_x, axis_hands_y);
81 ApplyCamOffset(pModel);
84 PrintString(
"RecoilBase | BEFORE | axis_mouse_y: " + axis_mouse_y.ToString());
86 axis_mouse_x = axis_mouse_x * m_RecoilModifier[0];
87 axis_mouse_y = axis_mouse_y * m_RecoilModifier[1];
89 axis_hands_x = axis_hands_x * m_RecoilModifier[0];
90 axis_hands_y = axis_hands_y * m_RecoilModifier[1];
95 PrintString(
"RecoilBase | AFTER | axis_mouse_y: " + axis_mouse_y.ToString());
100 if(
m_Time >= m_ReloadTime )
108 float time_rel =
Math.Clamp(
Math.InverseLerp(0, m_CamOffsetRelativeTime, m_TimeNormalized), 0, 1);
110 float time =
Easing.EaseOutBack(time_rel);
117 offset =
Math.Lerp(0,m_CamOffsetDistance,time);
120 pModel.m_fCamPosOffsetZ = offset;
122 m_Player.GetCurrentCamera().SendRecoilOffsetZ(offset);
125 void ApplyHandsOffset(
float pDt, out
float pRecResultX, out
float pRecResultY)
127 float relative_time = m_TimeNormalized /
Math.Clamp(m_HandsOffsetRelativeTime, 0.001,1);
128 vector pos_on_curve = GetPositionOnCurve(m_HandsCurvePoints, relative_time);
140 pRecResultX = pos_on_curve[0];
141 pRecResultY = pos_on_curve[1];
144 void ApplyMouseOffset(
float pDt, out
float pRecResultX, out
float pRecResultY)
149 bool b1 = m_MouseOffsetTargetAccum[1] < m_MouseOffsetTarget[1];
150 PrintString(
"RecoilBase | ApplyMouseOffset processing: " + b1 );
151 PrintString(
"RecoilBase | m_MouseOffsetTargetAccum : " + m_MouseOffsetTargetAccum.ToString() );
152 PrintString(
"RecoilBase | m_MouseOffsetTarget : " + m_MouseOffsetTarget.ToString() );
156 if( m_MouseOffsetTargetAccum[1] < m_MouseOffsetTarget[1] )
158 float relative_delta = pDt / m_ReloadTime /
Math.Clamp(m_MouseOffsetRelativeTime, 0.001,1);
160 float delta_mouse_offset_x = m_MouseOffsetTarget[0] * relative_delta;
161 float delta_mouse_offset_y = m_MouseOffsetTarget[1] * relative_delta;
163 if( ( m_MouseOffsetTargetAccum[1] + delta_mouse_offset_y) > m_MouseOffsetTarget[1] )
165 delta_mouse_offset_x = m_MouseOffsetTarget[0] - m_MouseOffsetTargetAccum[0];
166 delta_mouse_offset_y = m_MouseOffsetTarget[1] - m_MouseOffsetTargetAccum[1];
169 m_MouseOffsetTargetAccum[0] = m_MouseOffsetTargetAccum[0] + delta_mouse_offset_x;
170 m_MouseOffsetTargetAccum[1] = m_MouseOffsetTargetAccum[1] + delta_mouse_offset_y;
172 pRecResultX = delta_mouse_offset_x;
173 pRecResultY = delta_mouse_offset_y;
188 PrintString(
"RecoilBase | pRecResultY: " + pRecResultY );
197 return weapon.GetPropertyModifierObject().m_RecoilModifiers;