Creating simple pickup: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
(fixed basically everything)
 
Line 1: Line 1:
What:
{{Note|This was made for Orange Box version}}
I will explain how you can add a simple pickup like you have in the singleplayer
Version: Orange Box SDK.
-------
-------
Update: 2015-8-15
First open "hl2mp_player.cpp" and search for "CHL2MP_Player::PickupObject".<br>
 
Now replace it with the following code:
First open "hl2mp_player.cpp" and search for "CHL2MP_Player::PickupObject".
 
replace the function:
 
<source lang=cpp>
void CHL2MP_Player::PickupObject( CBaseEntity *pObject, bool bLimitMassAndSize )
{
}
</source>
 
Note: For some reason this system has a bug and is the object that pulling the gun is fired so to fix this problem replaces the code above with this
 
<source lang=cpp>
<source lang=cpp>
void CHL2MP_Player::PickupObject( CBaseEntity *pObject, bool bLimitMassAndSize )
void CHL2MP_Player::PickupObject( CBaseEntity *pObject, bool bLimitMassAndSize )
Line 26: Line 11:
BaseClass::PickupObject(pObject,bLimitMassAndSize);
BaseClass::PickupObject(pObject, bLimitMassAndSize);
// Can't be picked up if NPCs are on me
// Can't be picked up if NPCs are on me
Line 35: Line 20:
ClearActiveWeapon();
ClearActiveWeapon();
Weapon_Switch( Weapon_OwnsThisType( "nameofyourweaponentitygotohere" ) );
Weapon_Switch( Weapon_OwnsThisType( "nameofyourweaponentity" ) );
PlayerPickupObject( this, pObject );
PlayerPickupObject( this, pObject );
Line 41: Line 26:
</source>
</source>


Tanks For SecobMod Team For The Update Code
{{Special thanks|SecobMod Team|Updating the code}}


[[Category:Programming]]
[[Category:Programming]]

Latest revision as of 06:05, 11 September 2022

Note.pngNote:This was made for Orange Box version

First open "hl2mp_player.cpp" and search for "CHL2MP_Player::PickupObject".
Now replace it with the following code:

void CHL2MP_Player::PickupObject( CBaseEntity *pObject, bool bLimitMassAndSize )
{
	// can't pick up what you're standing on
	if ( GetGroundEntity() == pObject )
		return;
	
	
	BaseClass::PickupObject(pObject, bLimitMassAndSize);
	
	// Can't be picked up if NPCs are on me
	if ( pObject->HasNPCsOnIt() )
		return;	
	
	HideViewModels();
	ClearActiveWeapon();
	
	Weapon_Switch( Weapon_OwnsThisType( "nameofyourweaponentity" ) );
	
	PlayerPickupObject( this, pObject );
}
Special thanks to SecobMod Team Updating the code