mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Game: add method for calculating zoom FOV interp
This commit is contained in:
parent
bfdf601d0d
commit
f9eb989b3b
@ -153,6 +153,7 @@ add_sources( SOURCE_GROUP "Player"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Weapon"
|
||||
"server/r1/weapon_x.cpp"
|
||||
"server/r1/weapon_x.h"
|
||||
)
|
||||
|
||||
@ -219,6 +220,7 @@ add_sources( SOURCE_GROUP "Player"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Weapon"
|
||||
"client/r1/c_weapon_x.cpp"
|
||||
"client/r1/c_weapon_x.h"
|
||||
)
|
||||
|
||||
|
6
src/game/client/r1/c_weapon_x.cpp
Normal file
6
src/game/client/r1/c_weapon_x.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "c_weapon_x.h"
|
||||
|
||||
float C_WeaponX::GetZoomFOVInterpAmount(const float curTime) const
|
||||
{
|
||||
return m_playerData.GetZoomFOVInterpAmount(curTime);
|
||||
}
|
@ -8,6 +8,11 @@
|
||||
|
||||
class C_WeaponX : C_BaseAnimating
|
||||
{
|
||||
public:
|
||||
float GetZoomFOVInterpAmount(const float curTime) const;
|
||||
inline bool HasTargetZoomFOV() { return m_playerData.GetTargetZoomFOV() == *(float*)&m_modVars[3120]; }
|
||||
|
||||
private:
|
||||
EHANDLE m_weaponOwner;
|
||||
float m_lastPrimaryAttack;
|
||||
float m_nextReadyTime;
|
||||
|
6
src/game/server/r1/weapon_x.cpp
Normal file
6
src/game/server/r1/weapon_x.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "weapon_x.h"
|
||||
|
||||
float CWeaponX::GetZoomFOVInterpAmount(const float curTime) const
|
||||
{
|
||||
return m_playerData.GetZoomFOVInterpAmount(curTime);
|
||||
}
|
@ -14,6 +14,10 @@
|
||||
|
||||
class CWeaponX : CBaseAnimating
|
||||
{
|
||||
public:
|
||||
float GetZoomFOVInterpAmount(const float curTime) const;
|
||||
|
||||
private:
|
||||
EHANDLE m_weaponOwner;
|
||||
float m_lastPrimaryAttack;
|
||||
float m_nextReadyTime;
|
||||
|
@ -3,6 +3,11 @@
|
||||
|
||||
class WeaponPlayerData
|
||||
{
|
||||
public:
|
||||
inline float GetZoomFOVInterpAmount(const float curTime) const;
|
||||
inline float GetTargetZoomFOV() const { return m_targetZoomFOV; }
|
||||
|
||||
private:
|
||||
void* __vftable;
|
||||
float m_moveSpread;
|
||||
float m_spreadStartTime;
|
||||
@ -70,8 +75,21 @@ class WeaponPlayerData
|
||||
int m_charmAttachment;
|
||||
int m_charmScriptIndex;
|
||||
};
|
||||
|
||||
// Client's class is identical.
|
||||
typedef WeaponPlayerData WeaponPlayerData_Client;
|
||||
|
||||
|
||||
float WeaponPlayerData::GetZoomFOVInterpAmount(const float curTime) const
|
||||
{
|
||||
const float zoomLerpTime = m_zoomFOVLerpTime;
|
||||
|
||||
if (zoomLerpTime <= 0.0f)
|
||||
return 1.0f;
|
||||
|
||||
const float endLerptime = m_zoomFOVLerpEndTime;
|
||||
const float finalLerpTime = Min(Max((curTime - (endLerptime - zoomLerpTime)) / zoomLerpTime, 0.0f), 1.0f);
|
||||
|
||||
return (3.0f - (finalLerpTime + finalLerpTime)) * (finalLerpTime * finalLerpTime);
|
||||
}
|
||||
|
||||
#endif // SHARED_WEAPON_PLAYERDATA_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user