Weapon physcannon: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(-added class hierarchy, cleanup)
No edit summary
Line 14: Line 14:
==KeyValues==
==KeyValues==
{{KV Targetname}}
{{KV Targetname}}
{{KV NewFade}}


==Flags==
==Flags==
Line 45: Line 44:
{{varcom|end}}
{{varcom|end}}


== ==
== See Also ==
[[Category:C++]]
* [[Half-Life 2: Deathmatch Zero Point Energy Field Manipulator fix]]
=== {{hl2dm|4}} Dark Energy Field Manipulator fix ===
In {{hl2dm|4}} the Zero-Point Energy Field Manipulator (AKA Gravity Gun) won't go into supercharged mode. There is a fix to this.
First open shared\hl2mp\weapon_physcannon.cpp
 
NOTICE: I'm going to update this to work with the correct file.
 
At line 50 or near add:
<pre>
extern ConVar physcannon_mega_enabled;
</pre>
Now find:
<pre>
// Do we have the super-phys gun?
inline bool PlayerHasMegaPhysCannon()
{
return false;
}
</pre>
and replace it with:
<pre>
inline bool PlayerHasMegaPhysCannon()
{
if ( physcannon_mega_enabled.GetBool() || GlobalEntity_GetState("super_phys_gun") )
{
return true;
}
else
{
return false;
}
}
</pre>
Now at line 2047 or near replace:
<pre>
m_grabController.AttachEntity( pOwner, pObject, pPhysics, false, vPosition, false );
</pre>
With:
<pre>
m_grabController.AttachEntity( pOwner, pObject, pPhysics, IsMegaPhysCannon(), vPosition, false);
</pre>
 
Now at line 2473 or near replace:
<pre>
GetGrabController().AttachEntity( ToBasePlayer( GetOwner() ), pAttachedObject, pPhysics, false, vec3_origin, false);
</pre>
With:
<pre>
GetGrabController().AttachEntity( ToBasePlayer( GetOwner() ), pAttachedObject, pPhysics, IsMegaPhysCannon(), vec3_origin, false);
</pre>
Now near line 3102 after:
<pre>
void CWeaponPhysCannon::CloseElements( void )
{
</pre>
Add:
<pre>
// The mega cannon cannot be closed!
if (IsMegaPhysCannon())
{
OpenElements();
return;
}
</pre>
Now Near line 2041 replace:
<pre>
float CWeaponPhysCannon::TraceLength()
{
return physcannon_tracelength.GetFloat();
}
</pre>
With:
<pre>
float CWeaponPhysCannon::TraceLength()
{
if(!IsMegaPhysCannon())
return physcannon_tracelength.GetFloat();
else
return physcannon_mega_tracelength.GetFloat();
}
</pre>
 
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.


[[Category:Half-Life 2 Entities]]
[[Category:Half-Life 2 Entities]]
[[Category:Half-Life 2 Weapons|P]]
[[Category:Half-Life 2 Weapons|P]]

Revision as of 14:58, 26 July 2024

English (en)Translate (Translate)
C++ class hierarchy
CWeaponPhysCannon defined in C++ weapon_physcannon.cpp
CBaseHL2MPCombatWeapon
CWeaponHL2MPBase
CBaseCombatWeapon
CBaseAnimating
CBaseEntity
Weapon physcannon.png

weapon_physcannon is a point entity available in Half-Life 2 Half-Life 2, Half-Life 2: Episode One Half-Life 2: Episode One, Half-Life 2: Episode Two Half-Life 2: Episode Two, Half-Life 2: Deathmatch Half-Life 2: Deathmatch, and Half-Life 2: Lost Coast Half-Life 2: Lost Coast. It's the Zero-Point Energy Field Manipulator (AKA Gravity Gun), used to manipulate physics objects in the game world. Before it is picked up, the gravity gun also follows all physics rules as if it were a prop_physics.

Tip.pngTip:To supercharge the Gravity Gun, use an env_global entity to enable the global state super_phys_gun. This does not work in Half-Life 2: Deathmatch or Portal.
Icon-Bug.pngBug:Sometimes the game may crash when the player is holding something at the moment they pick up the gravity gun.  [todo tested in ?]

Games

[Todo]

Half-Life 2: Deathmatch Half-Life 2: Deathmatch

Players spawn with a gravity gun by default.

KeyValues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Flags

Start Constrained : [1]
Prevents the model from moving. Off by default.
Start without grab functionality. : [2]
Obsolete (in all games since Half-Life 2: Episode One)
Deny player pickup (reserve for NPC) : [2] (in all games since Half-Life 2: Episode One)
Not puntable by Gravity Gun : [4] (in all games since Half-Life 2: Episode One)

Inputs

EnableGrab
Enable the grab functionality. Obsolete (in all games since Half-Life 2: Episode One)

Outputs

Weapon:

OnNPCPickup
!activator = NPC
!caller = this entity
Fires when an NPC picks up this weapon.
OnPlayerUse
!activator = player
!caller = this entity
Fires when the player +uses this weapon.
OnPlayerPickup
!activator = player
!caller = this entity
Fires when a player picks up this weapon.
OnCacheInteraction
Fires when the player 'proves' they've found this weapon. Fires on: Player Touch, +USE pickup, Physcannon pickup, Physcannon punt.

Dedicated ConVars

Cvar/Command Parameters or default value Descriptor Effect
g_debug_physcannon 0 bool Enables Gravity Gun debugging, which shows a wireframe outline around objects when picked up
physcannon_cone 0.97 float Changes how wide the pickup range is, lower numbers are wider. This is a dot product value
physcannon_ball_cone 0.997 float The dot product of the search cone when using the charged Gravity Gun; if it detects a Prop combine ball within this cone, it'll prioritize picking it up
physcannon_punt_cone 0.997 float
Todo: Add a description for this variable.
physcannon_minforce 700.0 float
Todo: Add a description for this variable.
physcannon_maxforce 1500.0 float
Todo: Add a description for this variable.
physcannon_maxmass 250.0 float Sets the maximum mass at which an object can be picked up by the gravity gun
physcannon_pullforce 4000.0 float How much force to be used when pulling objects to the player
physcannon_tracelength 250.0 float How far an object can be pulled from
physcannon_mega_enabled 0 bool Enables Dark Energy Field Manipulator
physcannon_mega_pullforce 8000.0 float How much force the Dark Energy Field Manipulator
physcannon_mega_tracelength 850.0 float The distance at which the Dark Energy Field Manipulator will be able to pull an object
player_throwforce 1000.0 float The force applied to throwing objects held without the gravity gun. The force is scaled by the object's mass, to avoid lightweight objects from getting too much force.

See Also