Weapon physcannon: Difference between revisions
m (Changed parameters of {{this is a}} to comply with the updated version. This action was performed by a bot.) |
(badly moved multipage rest of history at Archived Page History/Weapon physcannon/en) |
||
Line 1: | Line 1: | ||
{{ | {{LanguageBar}} | ||
{{this is a|point entity|name=weapon_physcannon|game=Half-Life 2|game1=Half-Life 2: Episode One|game2=Half-Life 2: Episode Two|game3=Half-Life 2: Deathmatch}} | [[File:weapon_physcannon.png|thumb|right|250px]] | ||
{{this is a|point entity|name=weapon_physcannon|game=Half-Life 2|game1=Half-Life 2: Episode One|game2=Half-Life 2: Episode Two|game3=Half-Life 2: Deathmatch|game4=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 {{ent|prop_physics}}. | |||
{{tip|To supercharge the Gravity Gun, use an {{ent|env_global}} entity to enable the global state <code>super_phys_gun</code>. This does not work in {{hl2dm|3}} or {{portal|3}}.}} | |||
{{bug|Sometimes the game may crash when the player is holding something at the moment they pick up the gravity gun.}} | |||
== Games == | |||
{{todo}} | |||
=== {{hl2dm|4}} === | |||
[[Player]]s spawn with a gravity gun by default. | |||
==[[Dedicated]] [[ConVar]]s== | |||
<!--{{ScrollBox|title=Dedicated Console Variables|--> | |||
=== g_debug_physcannon === | |||
;g_debug_physcannon <[[bool]]> | |||
: Enables Gravity Gun debugging, which shows a wireframe outline around objects when picked up (default: 0) | |||
=== physcannon_cone === | |||
;physcannon_cone <[[float]]> | |||
: Changes how wide the pickup range is, lower numbers are wider. This is a [[dot product]] value (default: 0.97) | |||
=== physcannon_ball_cone === | |||
;physcannon_ball_cone <[[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 (default: 0.997) | |||
=== physcannon_punt_cone === | |||
;physcannon_punt_cone <[[float]]> | |||
: {{Todo|Add a description for this variable.}} (default: 0.997) | |||
=== physcannon_minforce === | |||
;physcannon_minforce <[[float]]> | |||
: {{Todo|Add a description for this variable.}} (default: 700.0) | |||
=== physcannon_maxforce === | |||
;physcannon_maxforce <[[float]]> | |||
: {{Todo|Add a description for this variable.}} (default: 1500.0) | |||
=== physcannon_maxmass === | |||
;physcannon_maxmass <[[float]]> | |||
: Sets the maximum mass at which an object can be picked up by the gravity gun (default: 250.0) | |||
=== physcannon_pullforce === | |||
;physcannon_pullforce <[[float]]> | |||
: How much force to be used when pulling objects to the player (default: 4000.0) | |||
=== physcannon_tracelength === | |||
;physcannon_tracelength <[[float]]> | |||
: How far an object can be pulled from (default: 250.0) | |||
=== physcannon_mega_enabled === | |||
;physcannon_mega_enabled <[[bool]]> | |||
: Enables Dark Energy Field Manipulator(default: 0). | |||
:{{Fix|[[#Half-Life_2:_Deathmatch_Dark_Energy_Field_Manipulator_fix|Half-Life 2 Deathmatch Dark Energy Field Manipulator fix]].|code}} | |||
=== physcannon_mega_pullforce === | |||
;physcannon_mega_pullforce <[[float]]> | |||
: How much force the Dark Energy Field Manipulator (default: 8000.0) | |||
=== physcannon_mega_tracelength === | |||
;physcannon_mega_tracelength <[[float]]> | |||
: The distance at which the Dark Energy Field Manipulator will be able to pull an object (default: 850.0) | |||
=== player_throwforce === | |||
;player_throwforce <[[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. (default: 1000.0) | |||
==KeyValues== | |||
{{KV BaseEntity|noscroll=1}} | |||
{{KV NewFade}} | |||
==Flags== | |||
{{fl|1|Start Constrained|Prevents the model from moving. Off by default.}} | |||
{{fl|2|Start without grab functionality.|Obsolete {{ep1|since}}}} | |||
{{fl|2|Deny player pickup (reserve for NPC)|since=EP1}} | |||
{{fl|4|Not puntable by Gravity Gun|since=EP1}} | |||
==Inputs== | |||
{{IO|EnableGrab|Enable the grab functionality. {{EP1 add|Obsolete}}}} | |||
{{I Targetname}} | |||
==Outputs== | |||
{{O Weapon}} | |||
== == | |||
[[Category:C++]] | |||
=== {{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 03:51, 13 July 2024


weapon_physcannon
is a point entity available in Half-Life 2,
Half-Life 2: Episode One,
Half-Life 2: Episode Two,
Half-Life 2: Deathmatch, and
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.

super_phys_gun
. This does not work in Half-Life 2: Deathmatch or Portal.
Games
[Todo]
Half-Life 2: Deathmatch
Players spawn with a gravity gun by default.
Dedicated ConVars
g_debug_physcannon
- g_debug_physcannon <bool>
- Enables Gravity Gun debugging, which shows a wireframe outline around objects when picked up (default: 0)
physcannon_cone
- physcannon_cone <float>
- Changes how wide the pickup range is, lower numbers are wider. This is a dot product value (default: 0.97)
physcannon_ball_cone
- physcannon_ball_cone <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 (default: 0.997)
physcannon_punt_cone
- physcannon_punt_cone <float>
- Todo: Add a description for this variable.(default: 0.997)
physcannon_minforce
- physcannon_minforce <float>
- Todo: Add a description for this variable.(default: 700.0)
physcannon_maxforce
- physcannon_maxforce <float>
- Todo: Add a description for this variable.(default: 1500.0)
physcannon_maxmass
- physcannon_maxmass <float>
- Sets the maximum mass at which an object can be picked up by the gravity gun (default: 250.0)
physcannon_pullforce
- physcannon_pullforce <float>
- How much force to be used when pulling objects to the player (default: 4000.0)
physcannon_tracelength
- physcannon_tracelength <float>
- How far an object can be pulled from (default: 250.0)
physcannon_mega_enabled
- physcannon_mega_enabled <bool>
- Enables Dark Energy Field Manipulator(default: 0).
physcannon_mega_pullforce
- physcannon_mega_pullforce <float>
- How much force the Dark Energy Field Manipulator (default: 8000.0)
physcannon_mega_tracelength
- physcannon_mega_tracelength <float>
- The distance at which the Dark Energy Field Manipulator will be able to pull an object (default: 850.0)
player_throwforce
- player_throwforce <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. (default: 1000.0)
KeyValues
BaseFadeProp:
- Start Fade Dist (fademindist) <float>
- Distance at which the entity starts to fade.
- End Fade Dist (fademaxdist) <float>
- Max fade distance at which the entity is visible.
- If start fade is <0, the entity will disappear instantly when end fade is hit.
- If end fade is <0, the entity won't disappear at all. (This is the default behavior.)
- The values will scale appropriately if the entity is in a 3D Skybox.
- Fade Scale (fadescale) <float>
- If you specify so in worldspawn, or if the engine is running below DirectX 8 (DX7 in
), props will fade out even if the fade distances above aren't specified. This value gives you some control over when this happens: numbers smaller than 1 cause the prop to fade out at further distances, while those greater than 1 cause it to fade out at closer distances. Using 0 turns off the forced fade altogether. See also the QC command $noforcedfade.
Flags
- Start Constrained : [1]
- Prevents the model from moving. Off by default.
- Start without grab functionality. : [2]
- Obsolete (in all games since
)
- Deny player pickup (reserve for NPC) : [2] (in all games since
)
- Not puntable by Gravity Gun : [4] (in all games since
)
Inputs
- EnableGrab
- Enable the grab functionality. Obsolete (in all games since
)
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.
Half-Life 2: Deathmatch Dark Energy Field Manipulator fix
In Half-Life 2: Deathmatch 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:
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.
- Point entities
- Non-internal Half-Life 2 entities
- Half-Life 2 entities
- Half-Life 2 point entities
- Non-internal Half-Life 2: Episode One entities
- Half-Life 2: Episode One entities
- Half-Life 2: Episode One point entities
- Non-internal Half-Life 2: Episode Two entities
- Half-Life 2: Episode Two entities
- Half-Life 2: Episode Two point entities
- Non-internal Half-Life 2: Deathmatch entities
- Half-Life 2: Deathmatch entities
- Half-Life 2: Deathmatch point entities
- Non-internal Half-Life 2: Lost Coast entities
- Half-Life 2: Lost Coast entities
- Half-Life 2: Lost Coast point entities
- Pages with uncategorized bugs
- Weapons
- C++
- Half-Life 2 Entities
- Half-Life 2 Weapons