Half-Life 2: Deathmatch Zero Point Energy Field Manipulator fix

From Valve Developer Community
Jump to navigation Jump to search
weapon_physcannon
Wiki Note:This article was written before the 2025 multiplayer SDK update, therefore it might not point to the correct lines/files or might not work anymore.

In Half-Life 2: Deathmatch Half-Life 2: Deathmatch the Zero-Point Energy Field Manipulator (AKA Gravity Gun) won't go into supercharged mode. There is a fix for this, if you edit 🖿shared\hl2mp\weapon_physcannon.cpp

Note.pngNote:I'm going to update this to work with the correct file.

At line 50 or near add:

extern ConVar physcannon_mega_enabled;

Now find:

// Do we have the super-phys gun?
inline bool	PlayerHasMegaPhysCannon()
{
return false;
}

and replace it with:

inline bool	PlayerHasMegaPhysCannon()
{
	if ( physcannon_mega_enabled.GetBool() || GlobalEntity_GetState("super_phys_gun") )
	{
		return true;
	}
	else
	{
		return false;
	}
}

Now at line 2047 or near replace:

m_grabController.AttachEntity( pOwner, pObject, pPhysics, false, vPosition, false );

With:

m_grabController.AttachEntity( pOwner, pObject, pPhysics, IsMegaPhysCannon(), vPosition, false);

Now at line 2473 or near replace:

GetGrabController().AttachEntity( ToBasePlayer( GetOwner() ), pAttachedObject, pPhysics, false, vec3_origin, false);

With:

GetGrabController().AttachEntity( ToBasePlayer( GetOwner() ), pAttachedObject, pPhysics, IsMegaPhysCannon(), vec3_origin, false);

Now near line 3102 after:

void CWeaponPhysCannon::CloseElements( void )
{

Add:

// The mega cannon cannot be closed!
if (IsMegaPhysCannon())
{
	OpenElements();
	return;
}

Now Near line 2041 replace:

float CWeaponPhysCannon::TraceLength()
{
	return physcannon_tracelength.GetFloat();
}

With:

float CWeaponPhysCannon::TraceLength()
{
	if(!IsMegaPhysCannon())
	return physcannon_tracelength.GetFloat();
	else
	return physcannon_mega_tracelength.GetFloat();
}

The effects are not ready.

This is not the finished code. Writing it down will take a while and I still have some other things to do with the code. I'll go post the finished parts of the code on Github. There is some extra code for allowing one Gravity Gun to be Mega/Upgraded and one Normal. (https://github.com/TheVogels/Source-SDK-2013-Multiplayer-physcannon-mega-fix)

Now compile the project and it should work.