mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-02-05 02:00:34 +03:00
Added new weapon script values for viewmodel FOV override, bob scale, sway scale, and sway speed scale
This commit is contained in:
parent
c25053d1d2
commit
c1eae4a4f9
@ -111,6 +111,7 @@ static ConVar v_centerspeed( "v_centerspeed","500" );
|
|||||||
// 54 degrees approximates a 35mm camera - we determined that this makes the viewmodels
|
// 54 degrees approximates a 35mm camera - we determined that this makes the viewmodels
|
||||||
// and motions look the most natural.
|
// and motions look the most natural.
|
||||||
ConVar v_viewmodel_fov( "viewmodel_fov", "54", FCVAR_ARCHIVE );
|
ConVar v_viewmodel_fov( "viewmodel_fov", "54", FCVAR_ARCHIVE );
|
||||||
|
ConVar v_viewmodel_fov_script_override( "viewmodel_fov_script_override", "0", FCVAR_NONE, "If nonzero, overrides the viewmodel FOV of weapon scripts which override the viewmodel FOV." );
|
||||||
#else
|
#else
|
||||||
ConVar v_viewmodel_fov( "viewmodel_fov", "54", FCVAR_CHEAT );
|
ConVar v_viewmodel_fov( "viewmodel_fov", "54", FCVAR_CHEAT );
|
||||||
#endif
|
#endif
|
||||||
@ -675,6 +676,10 @@ void CViewRender::SetUpViews()
|
|||||||
Vector ViewModelOrigin;
|
Vector ViewModelOrigin;
|
||||||
QAngle ViewModelAngles;
|
QAngle ViewModelAngles;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
view.fovViewmodel = g_pClientMode->GetViewModelFOV();
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( engine->IsHLTV() )
|
if ( engine->IsHLTV() )
|
||||||
{
|
{
|
||||||
HLTVCamera()->CalcView( view.origin, view.angles, view.fov );
|
HLTVCamera()->CalcView( view.origin, view.angles, view.fov );
|
||||||
@ -710,6 +715,18 @@ void CViewRender::SetUpViews()
|
|||||||
bCalcViewModelView = true;
|
bCalcViewModelView = true;
|
||||||
ViewModelOrigin = view.origin;
|
ViewModelOrigin = view.origin;
|
||||||
ViewModelAngles = view.angles;
|
ViewModelAngles = view.angles;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Allow weapons to override viewmodel FOV
|
||||||
|
C_BaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();
|
||||||
|
if (pWeapon && pWeapon->GetViewmodelFOVOverride() != 0.0f)
|
||||||
|
{
|
||||||
|
if (v_viewmodel_fov_script_override.GetFloat() > 0.0f)
|
||||||
|
view.fovViewmodel = v_viewmodel_fov_script_override.GetFloat();
|
||||||
|
else
|
||||||
|
view.fovViewmodel = pWeapon->GetViewmodelFOVOverride();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -745,7 +762,7 @@ void CViewRender::SetUpViews()
|
|||||||
|
|
||||||
//Adjust the viewmodel's FOV to move with any FOV offsets on the viewer's end
|
//Adjust the viewmodel's FOV to move with any FOV offsets on the viewer's end
|
||||||
#ifdef MAPBASE
|
#ifdef MAPBASE
|
||||||
view.fovViewmodel = max(0.001f, g_pClientMode->GetViewModelFOV() - flFOVOffset);
|
view.fovViewmodel = max(0.001f, view.fovViewmodel - flFOVOffset);
|
||||||
#else
|
#else
|
||||||
view.fovViewmodel = g_pClientMode->GetViewModelFOV() - flFOVOffset;
|
view.fovViewmodel = g_pClientMode->GetViewModelFOV() - flFOVOffset;
|
||||||
#endif
|
#endif
|
||||||
|
@ -461,6 +461,28 @@ bool CBaseCombatWeapon::IsMeleeWeapon() const
|
|||||||
return GetWpnData().m_bMeleeWeapon;
|
return GetWpnData().m_bMeleeWeapon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
float CBaseCombatWeapon::GetViewmodelFOVOverride() const
|
||||||
|
{
|
||||||
|
return GetWpnData().m_flViewmodelFOV;
|
||||||
|
}
|
||||||
|
|
||||||
|
float CBaseCombatWeapon::GetBobScale() const
|
||||||
|
{
|
||||||
|
return GetWpnData().m_flBobScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
float CBaseCombatWeapon::GetSwayScale() const
|
||||||
|
{
|
||||||
|
return GetWpnData().m_flSwayScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
float CBaseCombatWeapon::GetSwaySpeedScale() const
|
||||||
|
{
|
||||||
|
return GetWpnData().m_flSwaySpeedScale;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -417,6 +417,12 @@ public:
|
|||||||
virtual bool UsesClipsForAmmo1( void ) const;
|
virtual bool UsesClipsForAmmo1( void ) const;
|
||||||
virtual bool UsesClipsForAmmo2( void ) const;
|
virtual bool UsesClipsForAmmo2( void ) const;
|
||||||
bool IsMeleeWeapon() const;
|
bool IsMeleeWeapon() const;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
float GetViewmodelFOVOverride() const;
|
||||||
|
float GetBobScale() const;
|
||||||
|
float GetSwayScale() const;
|
||||||
|
float GetSwaySpeedScale() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
// derive this function if you mod uses encrypted weapon info files
|
// derive this function if you mod uses encrypted weapon info files
|
||||||
virtual const unsigned char *GetEncryptionKey( void );
|
virtual const unsigned char *GetEncryptionKey( void );
|
||||||
|
@ -513,6 +513,23 @@ void CBaseViewModel::CalcViewModelLag( Vector& origin, QAngle& angles, QAngle& o
|
|||||||
|
|
||||||
float flSpeed = 5.0f;
|
float flSpeed = 5.0f;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
CBaseCombatWeapon *pWeapon = m_hWeapon.Get();
|
||||||
|
if (pWeapon)
|
||||||
|
{
|
||||||
|
const FileWeaponInfo_t *pInfo = &pWeapon->GetWpnData();
|
||||||
|
if (pInfo->m_flSwayScale != 1.0f)
|
||||||
|
{
|
||||||
|
vDifference *= pInfo->m_flSwayScale;
|
||||||
|
pInfo->m_flSwayScale != 0.0f ? flSpeed /= pInfo->m_flSwayScale : flSpeed = 0.0f;
|
||||||
|
}
|
||||||
|
if (pInfo->m_flSwaySpeedScale != 1.0f)
|
||||||
|
{
|
||||||
|
flSpeed *= pInfo->m_flSwaySpeedScale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// If we start to lag too far behind, we'll increase the "catch up" speed. Solves the problem with fast cl_yawspeed, m_yaw or joysticks
|
// If we start to lag too far behind, we'll increase the "catch up" speed. Solves the problem with fast cl_yawspeed, m_yaw or joysticks
|
||||||
// rotating quickly. The old code would slam lastfacing with origin causing the viewmodel to pop to a new position
|
// rotating quickly. The old code would slam lastfacing with origin causing the viewmodel to pop to a new position
|
||||||
float flDiff = vDifference.Length();
|
float flDiff = vDifference.Length();
|
||||||
|
@ -318,6 +318,14 @@ float CBaseHLCombatWeapon::CalcViewmodelBob( void )
|
|||||||
g_lateralBob = g_lateralBob*0.3 + g_lateralBob*0.7*sin(cycle);
|
g_lateralBob = g_lateralBob*0.3 + g_lateralBob*0.7*sin(cycle);
|
||||||
g_lateralBob = clamp( g_lateralBob, -7.0f, 4.0f );
|
g_lateralBob = clamp( g_lateralBob, -7.0f, 4.0f );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if (GetBobScale() != 1.0f)
|
||||||
|
{
|
||||||
|
//g_verticalBob *= GetBobScale();
|
||||||
|
g_lateralBob *= GetBobScale();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//NOTENOTE: We don't use this return value in our case (need to restructure the calculation function setup!)
|
//NOTENOTE: We don't use this return value in our case (need to restructure the calculation function setup!)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
@ -401,6 +401,12 @@ FileWeaponInfo_t::FileWeaponInfo_t()
|
|||||||
bShowUsageHint = false;
|
bShowUsageHint = false;
|
||||||
m_bAllowFlipping = true;
|
m_bAllowFlipping = true;
|
||||||
m_bBuiltRightHanded = true;
|
m_bBuiltRightHanded = true;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
m_flViewmodelFOV = 0.0f;
|
||||||
|
m_flBobScale = 1.0f;
|
||||||
|
m_flSwayScale = 1.0f;
|
||||||
|
m_flSwaySpeedScale = 1.0f;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CLIENT_DLL
|
#ifdef CLIENT_DLL
|
||||||
@ -466,6 +472,13 @@ void FileWeaponInfo_t::Parse( KeyValues *pKeyValuesData, const char *szWeaponNam
|
|||||||
m_bAllowFlipping = ( pKeyValuesData->GetInt( "AllowFlipping", 1 ) != 0 ) ? true : false;
|
m_bAllowFlipping = ( pKeyValuesData->GetInt( "AllowFlipping", 1 ) != 0 ) ? true : false;
|
||||||
m_bMeleeWeapon = ( pKeyValuesData->GetInt( "MeleeWeapon", 0 ) != 0 ) ? true : false;
|
m_bMeleeWeapon = ( pKeyValuesData->GetInt( "MeleeWeapon", 0 ) != 0 ) ? true : false;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
m_flViewmodelFOV = pKeyValuesData->GetFloat( "viewmodel_fov", 0.0f );
|
||||||
|
m_flBobScale = pKeyValuesData->GetFloat( "bob_scale", 1.0f );
|
||||||
|
m_flSwayScale = pKeyValuesData->GetFloat( "sway_scale", 1.0f );
|
||||||
|
m_flSwaySpeedScale = pKeyValuesData->GetFloat( "sway_speed_scale", 1.0f );
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MAPBASE // Mapbase makes weapons in the same slot & position swap each other out, which is a feature mods can intentionally use.
|
#ifndef MAPBASE // Mapbase makes weapons in the same slot & position swap each other out, which is a feature mods can intentionally use.
|
||||||
#if defined(_DEBUG) && defined(HL2_CLIENT_DLL)
|
#if defined(_DEBUG) && defined(HL2_CLIENT_DLL)
|
||||||
// make sure two weapons aren't in the same slot & position
|
// make sure two weapons aren't in the same slot & position
|
||||||
|
@ -116,6 +116,13 @@ public:
|
|||||||
bool m_bAllowFlipping; // False to disallow flipping the model, regardless of whether
|
bool m_bAllowFlipping; // False to disallow flipping the model, regardless of whether
|
||||||
// it is built left or right handed.
|
// it is built left or right handed.
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
float m_flViewmodelFOV;
|
||||||
|
float m_flBobScale;
|
||||||
|
float m_flSwayScale;
|
||||||
|
float m_flSwaySpeedScale;
|
||||||
|
#endif
|
||||||
|
|
||||||
// CLIENT DLL
|
// CLIENT DLL
|
||||||
// Sprite data, read from the data file
|
// Sprite data, read from the data file
|
||||||
int iSpriteCount;
|
int iSpriteCount;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user