Weapon physcannon
weapon_physcannon
is a point entity available in the Half-Life 2 series. 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
.
env_global
entity to enable the global state super_phys_gun
. This does not work in Half-Life 2: Deathmatch or Portal.Contents
- 1 Games
- 2 Dedicated ConVars
- 2.1 g_debug_physcannon
- 2.2 physcannon_cone
- 2.3 physcannon_ball_cone
- 2.4 physcannon_punt_cone
- 2.5 physcannon_minforce
- 2.6 physcannon_maxforce
- 2.7 physcannon_maxmass
- 2.8 physcannon_pullforce
- 2.9 physcannon_tracelength
- 2.10 physcannon_mega_enabled
- 2.11 physcannon_mega_pullforce
- 2.12 physcannon_mega_tracelength
- 2.13 player_throwforce
- 3 KeyValues
- 4 Flags
- 5 Inputs
- 6 Outputs
- 7
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 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).
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
Base:
- Parent
(parentname)
<targetname> - Maintain the same initial offset to this entity. An attachment point can also be used if separated by a comma at the end. (
parentname [targetname],[attachment]
)Tip:Entities transition to the next map with their parentsTip:phys_constraint
can be used as a workaround if parenting fails.
- Origin (X Y Z)
(origin)
<coordinates> - The position of this entity's center in the world. Rotating entities typically rotate around their origin.Note:Hammer does not move the entities accordingly only in the editor.
- Pitch Yaw Roll (X Y Z)
(angles)
<angle> - This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.Note:This works on brush entities, although Hammer doesn't show the new angles.
- Classname
(classname)
<string> !FGD - Determines the characteristics of the entity before it spawns. Tip:Changing this on runtime still has use, like making matching an entry in S_PreserveEnts will persist the entity on new rounds!
- Spawnflags
(spawnflags)
<flags> !FGD - Toggles exclusive features of an entity, its specific number is determined by the combination of flags added.
- Effects
(effects)
<flags> !FGD - Combination of effect flags to use.
- Entity Scripts
(vscripts)
<scriptlist> (in all games since ) (also in ) - Space delimited list of VScript files (without file extension) that are executed after all entities have spawned. The scripts are all executed in the same script scope, later ones overwriting any identical variables and functions. Scripts executed on the worldspawn entity will be placed in root scope.
- Think function
(thinkfunction)
<string> (in all games since ) (also in ) - Name of the function within this entity's script that'll be called automatically every 100 milliseconds, or a user-defined interval if the function returns a number. Avoid expensive operations in this function, as it may cause performance problems.
- Lag Compensation
(LagCompensate)
<boolean> (in all games since ) !FGD - Set to Yes to lag compensate this entity. Should be used very sparingly!
- Is Automatic-Aim Target
(is_autoaim_target)
<boolean> (in all games since ) !FGD - If set to 1, this entity will slow down aiming movement for consoles and joystick controllers when the entity is under the crosshairs.
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
- [
1
] : Start Constrained
Prevents the model from moving. Off by default.
Inputs
Base:
AddContext
<string>- Adds to the entity's list of response contexts. See Context.
AddOutput
<string>- Assigns a new keyvalue/output on this entity. For keyvalues, some rely on extra necessary code to be ran and won't work if its simply just changed through this input. There is a strict format that must be followed:
// Format of changing KeyValues: "AddOutput [key] [value]"
//// Raw text:
"OnUser1" "!self,AddOutput,targetname new_name"
// Format of adding an Output: "AddOutput {targetname}:{inputname}:{parameter}:{delay}:{max times to fire, -1 means infinite}"
//// Raw text:
"OnUser1" "!self,AddOutput,OnUser1:SetParent:!activator:0.0:-1"
// Arguments can be left blank, but the empty blank should still be contained.
//// Raw text:
"OnUser1" "!self,AddOutput,OnUser1:ClearParent::0.0:-1"
|
ClearContext
- Removes all contexts from this entity's list.
ClearParent
- Removes this entity from the the movement hierarchy, leaving it free to move independently.
FireUser1
toFireUser4
- Fires the respective
OnUser
outputs; see User Inputs and Outputs.
Kill
- Removes this entity and any entities parented to it from the world.
KillHierarchy
- Functions the same as
Kill
, although this entity and any entities parented to it are killed on the same frame, being marginally faster thanKill
input.
RemoveContext
<string>- Remove a context from this entity's list. The name should match the key of an existing context.
SetParent
<string>- Move with this entity. See Entity Hierarchy (parenting).
SetParentAttachment
<string>- Change this entity to attach to a specific attachment point on its parent. The entity will teleport so that the position of its root bone matches that of the attachment. Entities must be parented before being sent this input.
SetParentAttachmentMaintainOffset
<string>- As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.
DispatchResponse
<string> !FGD- Dispatches a response to the entity. See Response and Concept.
DispatchEffect
<string> (removed since ) !FGD- Dispatches a special effect from the entity's origin; See also List of Client Effects. Replaced by the particle system since .
RunScriptFile
<script> (in all games since ) (also in )- Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.
RunScriptCode
<string> (in all games since ) (also in )- Execute a string of VScript source code in the scope of the entity receiving the input. String quotation may be needed when fired via console. Bug:In Hammer, using string arguments will corrupt the VMF file's structure, making the file unviewable for the next Hammer session.Fix:Remove the string argument manually with a text editor.
CallScriptFunction
<string> (in all games since ) (also in ) !FGD- Calls a VScript function defined in the scope of the receiving entity.
TerminateScriptScope
(only in ) !FGD- Destroys the script scope of the receving entity.
SetLocalOrigin
<coordinates> (in all games since ) !FGD- Send this entity to a spot in the map. If the entity is parented to something, it will be offset from the parent by this amount.
Outputs
Weapon:
OnNPCPickup
- Fires when an NPC picks up this weapon. (
!activator
is the NPC.)
OnPlayerUse
- Fires when the player +uses this weapon. (
!activator
is the player.)
OnPlayerPickup
- Fires when a player picks up this weapon. (
!activator
is the player.)
OnCacheInteraction
- Fires when the player 'proves' they've found this weapon. Fires on: Player Touch, +USE pickup, Physcannon pickup, Physcannon punt.
Base:
OnUser1
toOnUser4
- These outputs each fire in response to the firing of the like-numbered
FireUser1
toFireUser4
Input; see User Inputs and Outputs.
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.
weapon_physcannon
is a point entity available in the Half-Life 2 series.