6 protected float m_fProgress;
7 protected float m_fVelocity;
10 protected float m_fImpulseTime;
11 protected float m_fLastImpulseTime;
13 protected vector m_vImpulseAngular;
15 override bool IsRunning()
22 BaseWeaponManagerComponent weaponManager =
null;
24 if (character.IsInVehicle())
26 CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
28 if (!compartmentAccess || !compartmentAccess.IsInCompartment() || compartmentAccess.IsGettingOut() || compartmentAccess.IsGettingIn())
31 BaseCompartmentSlot compartment = compartmentAccess.GetCompartment();
36 if (!turretController)
39 weaponManager = turretController.GetWeaponManager();
43 weaponManager = character.GetCharacterController().GetWeaponManagerComponent();
53 IEntity weaponEntity = weapon.GetOwner();
64 override void Update(IEntity owner,
float timeSlice)
66 ChimeraCharacter ownerCharacter = ChimeraCharacter.Cast(owner);
77 vector recoilTranslation;
78 if (ownerCharacter.IsInVehicle())
80 CompartmentAccessComponent compartmentAccess = ownerCharacter.GetCompartmentAccessComponent();
81 if (compartmentAccess && compartmentAccess.IsInCompartment() && !compartmentAccess.IsGettingOut() && !compartmentAccess.IsGettingIn())
83 BaseCompartmentSlot compartment = compartmentAccess.GetCompartment();
89 TurretComponent turretComponent = turretController.GetTurretComponent();
91 recoilTranslation = turretComponent.GetCurrentRecoilTranslation();
98 AimingComponent aimingComponent = ownerCharacter.GetWeaponAimingComponent();
100 recoilTranslation = aimingComponent.GetCurrentRecoilTranslation();
107 float recoilTarget = 0.0;
108 float maxPercentage = 1.0;
109 float blendIn = 0.01;
110 float blendOut = 0.2;
111 float maxVelocity = 10.0;
113 float minThreshold = 0.1;
114 float impulseStanceMagnitude = 1.0;
115 float continuousStanceMagnitude = 1.0;
119 recoilTarget =
params.m_fRecoilTarget;
120 maxPercentage =
params.m_fMaximumPercentage;
121 blendIn =
params.m_fBlendInTime;
122 blendOut =
params.m_fBlendOutTime;
123 maxVelocity =
params.m_fMaxVelocity;
124 minRate =
params.m_fMinImpulseRate;
125 minThreshold =
params.m_fMinImpulseThreshold;
126 float dynStance = ownerCharacter.GetCharacterController().GetDynamicStance();
127 impulseStanceMagnitude =
params.GetStanceImpulseMagnitude(dynStance);
128 continuousStanceMagnitude =
params.GetStanceMagnitude(dynStance);
133 if (recoilTarget > 0.0)
134 recoil01 = Math.AbsFloat(recoilTranslation[2] / recoilTarget);
138 float target = Math.Clamp(Math.Pow(recoil01, 2), 0.0, maxPercentage);
140 if (target >= m_fProgress)
141 smoothTime = blendIn;
143 smoothTime = blendOut;
146 m_fProgress = Math.SmoothCD(m_fProgress, target, m_fVelocity, smoothTime, maxVelocity, timeSlice);
150 m_fImpulseTime += timeSlice;
151 if (m_fProgress - minThreshold > target && m_fImpulseTime > m_fLastImpulseTime + minRate)
153 m_fLastImpulseTime = m_fImpulseTime;
154 m_vImpulseAngular = vector.Zero;
157 m_vImpulseAngular =
params.GetRandomYawPitchRollImpulse();
164 float impulseTime = Math.Clamp((m_fImpulseTime - m_fLastImpulseTime) * 0.25, 0, 1);
165 m_vImpulseAngular = vector.Lerp(m_vImpulseAngular, vector.Zero, impulseTime);
169 m_vTranslation = m_fProgress * continuousStanceMagnitude *
params.GetRandomTranslation();
170 m_vRotation = m_fProgress * impulseStanceMagnitude * m_vImpulseAngular;
173 else if (m_fProgress > 0.0)
175 m_vImpulseAngular = vector.Lerp(m_vImpulseAngular, vector.Zero, m_fProgress);
176 m_vTranslation = vector.Lerp(m_vTranslation, vector.Zero, m_fProgress);
177 m_vRotation = vector.Lerp(m_vRotation, vector.Zero, m_fProgress);