Weapon physcannon: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (→‎top: Unicodifying, replaced: {{language subpage → {{langsp)
(Replaced content with "{{multipage}} {{this is a|e0|name=weapon_physcannon|series=Half-Life 2}} Category:Half-Life 2 Entities P")
Tag: Replaced
Line 1: Line 1:
<!-- When this page is updated to {{langsp}} or {{langsp}} instead of {{lang}}, please move {{this is a}} to the base page, as it is automatically translated. -->{{lang}}[[File:weapon_physcannon.png|thumb|right|250px]]
{{multipage}}
{{this is a|e0|name=weapon_physcannon|series=Half-Life 2}} 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}}.
{{this is a|e0|name=weapon_physcannon|series=Half-Life 2}}
 
{{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 wire frame outline around objects when picked up(Default: 0)
 
=== physcannon_cone ===
;physcannon_cone <[[float]]>
: Changes how wide the pickup range is, lower numbers are wider (Default: 0.97)
 
=== physcannon_ball_cone ===
;physcannon_ball_cone <[[float]]>
: {{Todo|Add a description for this variable.}}(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]]>
: {{Todo|Add a description for this variable.}}(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 07:20, 19 January 2024

Template:Multipage weapon_physcannon is an e0 available in Half-Life 2 series Half-Life 2 series.