Dynamic Viewmodel FOVs: Difference between revisions
Jump to navigation
Jump to search
Tip:CS:S weapons normally look good with an FOV of 74, and HL2 weapons normally look good with an FOV of 54.
~TwoTails~ (talk | contribs) No edit summary |
mNo edit summary |
||
(5 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
This is a very simple copy-and-paste tutorial for | {{Multiple issues| | ||
{{Dead end|date=January 2024}} | |||
{{Orphan|date=January 2024}} | |||
}} | |||
This is a very simple copy-and-paste tutorial for setting a weapon's viewmodel FOV in its script. | |||
Lets get started! | Lets get started! | ||
Line 20: | Line 25: | ||
float ClientModeShared::GetViewModelFOV(void) | float ClientModeShared::GetViewModelFOV(void) | ||
{ | { | ||
float flFov = | float flFov = 54.0f; | ||
if (r_viewmodelfov.GetFloat() > 0) | if (r_viewmodelfov.GetFloat() > 0) | ||
Line 40: | Line 45: | ||
}</syntaxhighlight> | }</syntaxhighlight> | ||
Now, | Now, due to this, the command "viewmodel_fov" will no longer work, but you will be able to set the FOVs of weapons in their script file! | ||
Just add: | Just add: | ||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
"ViewModelFOV" "NaN"</syntaxhighlight> | "ViewModelFOV" "NaN"</syntaxhighlight> | ||
To the weaponscript file and replace NaN with your FOV or choice. If it doesn't find the ViewModelFOV string in the weaponscript file, it will assume the FOV is 54. | To the weaponscript file and replace NaN with your FOV or choice. If it doesn't find the ViewModelFOV string in the weaponscript file, it will assume the FOV is 54. | ||
{{tip| | {{tip|CS:S weapons normally look good with an FOV of 74, and HL2 weapons normally look good with an FOV of 54.}} | ||
[[Category:Weapons programming]] | [[Category:Weapons programming]] | ||
[[Category:Tutorials]] | [[Category:Tutorials]] |
Latest revision as of 00:19, 25 February 2025

This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)

This article has no
links to other VDC articles. Please help improve this article by adding links
that are relevant to the context within the existing text.
January 2024


January 2024

This article is an orphan, meaning that few or no articles link to it.
You can help by
adding links to this article from other relevant articles.
January 2024
You can help by

January 2024
This is a very simple copy-and-paste tutorial for setting a weapon's viewmodel FOV in its script. Lets get started!
Add this to weapon_parse.h in the shared gamefolder:
float m_flViewModelFOV; // Dynamic Viewmodel FOV
Put this under:
char szAmmo2[MAX_WEAPON_AMMO_NAME]; // "secondary" ammo type
Next Add this string to weapon_parse.cpp in FileWeaponInfo_t::Parse:
m_flViewModelFOV = pKeyValuesData->GetFloat("ViewModelFOV", 54.0f);
and then change ClientModeShared::GetViewModelFOV in clientmode_shared.cpp to say:
ConVar r_viewmodelfov("r_viewmodelfov", "0", FCVAR_CHEAT);
float ClientModeShared::GetViewModelFOV(void)
{
float flFov = 54.0f;
if (r_viewmodelfov.GetFloat() > 0)
return r_viewmodelfov.GetFloat();
CBasePlayer *pPlayer = CBasePlayer::GetLocalPlayer();
if (!pPlayer)
return flFov;
C_BaseCombatWeapon *pWpn = pPlayer->GetActiveWeapon();
if (pWpn)
{
flFov = pWpn->GetWpnData().m_flViewModelFOV;
}
return flFov;
}
Now, due to this, the command "viewmodel_fov" will no longer work, but you will be able to set the FOVs of weapons in their script file! Just add:
"ViewModelFOV" "NaN"
To the weaponscript file and replace NaN with your FOV or choice. If it doesn't find the ViewModelFOV string in the weaponscript file, it will assume the FOV is 54.
