Importing CSS Weapons Into HL2

From Valve Developer Community
Revision as of 01:39, 9 January 2014 by Joshy1002 (talk | contribs)
Jump to navigation Jump to search
Broom icon.png
This article or section needs to be cleaned up to conform to a higher standard of quality.
For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.
Broom icon.png
This article or section should be converted to third person to conform to wiki standards.

Update 9th Jan 14: Okay so I wrote this original monstrosity nearly 10 years ago (holy hell) and it is now very much so out of date and horribly untidy, I've gone through and removed anything that is no longer useful and had a general tidy up. This now conforms with the latest 2013 SDK.


SECTION 1 - MODEL EDITING


EDIT: SNIPPED THIS SECTION OUT (The 2013 SDK will work with any existing CSS model without model editing, just a little bit of coding is required to remove one or two bugs)


SECTION 2 - FINE TUNING THE MODEL


Once you have your v_model.mdl and w_model.mdl set up you will need to assign the models to a weapon using its weapon script file. Locate your new weapons script file eg. weapon_357.txt inside the 'scripts' folder (C:\Program Files\Steam\SteamApps\sourcemods\MODNAME\scripts).

Now to fix the issue of CSS weapons only displaying on the left side of the screen we can do the following.

Inside the weapon script file, add these two lines:

"BuiltRightHanded" "0" 
"AllowFlipping" "1"  

This will send information to the client regarding cl_righthand command, which we will enable next; go to your Mods Src folder (C:\MODNAME\src\cl_dll) and open 'c_baseviewmodel.cpp' and scroll down to line 25 and find the line that looks like this:

#ifdef CSTRIKE_DLL 
ConVar cl_righthand( "cl_righthand", "1", FCVAR_ARCHIVE, "Use right-handed view models." ); 
#endif  

And simply comment out the top and bottom lines like so:

// #ifdef CSTRIKE_DLL 
ConVar cl_righthand( "cl_righthand", "1", FCVAR_ARCHIVE, "Use right-handed view models." ); 
// #endif  

And go to line 173 and comment out these lines as follows:


// #ifdef CSTRIKE_DLL
	// If cl_righthand is set, then we want them all right-handed.
	CBaseCombatWeapon *pWeapon = m_hWeapon.Get();
	if ( pWeapon )
	{
		const FileWeaponInfo_t *pInfo = &pWeapon->GetWpnData();
		return pInfo->m_bAllowFlipping && pInfo->m_bBuiltRightHanded != cl_righthand.GetBool();
	}
// #endif

This will enable the cl_righthand cvar to be activated and your weapon model will no display on the correct side of the screen. Now just save and compile.


SECTION 3 - OPTIONAL TWEAKS


If you aren't using particle muzzle flashes (which you really should be, they're very pretty!) you may have some issues with the old style muzzle flashes when using CSS weapons. In that case there is a fix in the Snippets section of the Programming page on the VDC Wiki.

Enjoy!

Ferrety (ferrety6012@gmail.com)