func_tank

From Valve Developer Community
Jump to: navigation, search

<Half-Life 2>  func_tank is a brush entity available in the Half-Life 2 series.

Entity description

A brush entity that functions as a gun turret.

In code it is represented by class CFuncTank, defined in hl2_dll\func_tank.cpp.

www.editlife.net used to have a tutorial on making npc and player usable turrets, which you can read in the Internet Archive here.

Keyvalues

BaseTank:

Control Volume <targetname>
Name of a trigger the specifies the volume in which a player must be to control this tank.
(Team) Master <string>
(Team) Master
Yaw rate <string>
Yaw rate
Yaw range <string>
Yaw range
Yaw tolerance <string>
Yaw tolerance
Pitch rate <string>
Pitch rate
Pitch range <string>
Pitch range
Pitch tolerance <string>
Pitch tolerance
Barrel Length <string>
Barrel Length
Barrel Horizontal <string>
Barrel Horizontal
Barrel Vertical <string>
Barrel Vertical
Smoke Sprite <sprite>
Smoke Sprite
Flash Sprite <sprite>
Flash Sprite
Sprite scale <string>
Sprite scale
Rotate Start Sound <sound>
Rotate Start Sound
Rotate Loop Sound <sound>
Rotate Loop Sound
Rotate Stop Sound <sound>
Rotate Stop Sound
Rate of Fire <string>
Rate of Fire
Damage Per Bullet <string>
If set to 0, it'll use the base weapon bullet's damage.
Damage Per Bullet Vs Player <string>
If set to 0, it'll use the Damage Per Bullet value.
Firing persistence <string>
(Seconds) How long to keep firing at last known position after lose sight of target
Firing persistence2 <string>
(Seconds) After lost enemy and persistence time has passed, how long to occasionally fire at enemy's last known position
Bullet accuracy <choices>
To do: add description
  • 0 : Perfect Shot
  • 1 : Small cone
  • 2 : Medium cone
  • 3 : Large cone
  • 4 : Extra-large cone
Minmum target range <string>
To do: add description
Maximum target range <string>
To do: add description
Minimum light level <string>
To do: add description
Gun Base Attachment <string>
If Parent is specified, this is the attachment point on the parent to aim from.
Gun Barrel Attachment <string>
If Parent is specified, this is the attachment point on the parent to fire from. If you specify this, you'll want to specify the Gun Base Attachment too.
Gun Yaw Pose Param <string>
If Parent + the Gun Pitch Pose Param is specified, then the gun itself will be invisible and the func_tank will steer a gun on the parent using the pose parameters.
Gun Yaw Pose Center <float>
The center yaw pose parameter of the gun on the parent
Gun Pitch Pose Param <string>
If Parent + the Gun Yaw Pose Param is specified, then the gun itself will be invisible and the func_tank will steer a gun on the parent using the pose parameters.
Gun Pitch Pose Center <float>
The center pitch pose parameter of the gun on the parent
Ammunition Count <integer>
Only applies to player use. -1 = unlimited ammo.
Lead Target <boolean>
To do: add description
NPC Man Point <targetname>
Point where NPC must stand to man this func_tank.
Post-NPC Attack Grace Period <float>
If specified, NPC's manning this func tank won't fire at the player, after firing at a non-player, for this amount of time.
Ignore Grace Upto <float>
The player grace period is ignored if the player's under this distance from the func_tank.
Player Lock Time <float>
The tank must have the player as a target for this amount of time before it's allowed to fire.
Effect Handling <choices>
To do: add description
  • 0 : Use Individual Settings.
  • 1 : AR2
  • 2 : Combine Cannon

Targetname:

Name <string>
The targetname that other entities refer to this entity by.
Entity Scripts <scriptlist> (New with Left 4 Dead 2)
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.
Script think function <string> (New with Left 4 Dead 2)
Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call.
Note:Try to avoid expensive operations in this function, as it may cause performance problems.

Parentname:

Parent <targetname>
Specifies a movement parent. An entity will maintain its initial offset from its parent. An attachment point can be added to the end of the name, separated by a comma.

Origin:

Origin (X Y Z) <origin>
The position of this entity's center in the world. Rotating entities typically rotate around their origin.

Angles:

Pitch Yaw Roll (Y Z X) <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.

RenderFields:

Render Mode <choices>
Set a non-standard rendering mode on this entity. See Render Modes for details.
FX Amount (0 - 255) <int>
Intensity of the selected render mode.
FX Color (R G B) <color255>
Color used by the selected render mode (if applicable).
Disable Receiving Shadows <bool>
Prevents the entity from receiving shadows.

RenderFXChoices:

Render FX <choices>
Several GoldSrc-era visibility modes which change the way the entity is rendered, typically by fading it in and out.

Global:

Global Entity Name <string>
Name by which this entity is linked to another entity in a different map. When the player transitions to a new map, entities in the new map with globalnames matching entities in the previous map will have the previous map's state copied over their state.

Shadow:

Disable shadows <boolean>
Prevent the entity from creating cheap render-to-texture shadows. Does not affect shadow mapping.
Disable ShadowDepth <boolean> (New with Portal 2)
Used to disable rendering into shadow depth (for projected textures) for this entity.
Projected Texture Cache <choices> (New with Portal 2)
Used to hint projected texture system whether it is sufficient to cache shadow volume of this entity or to force render it every frame instead.
  • 0 : Default
  • 1 : No cache - render every frame
  • 2 : Cache it - render only once
Disable flashlight <boolean> (New with Portal 2)
Used to disable projected texture lighting and shadows on this entity.
Bullet type <choices>
Obsolete. If you are mapping for HL2, and don't see this keyvalue, it's probably because you updated hammer for Episode 1. Simply add in a keyvalue named "bullet" without SmartEdit. This keyvalue must be used with HL2. This is also the case for Portal 2.
Literal value Description
0 None
1 Pistol
2 SMG1
3 AR2
4 Laser
Ammo type <choices>
Ammo type. Cannot be used with HL2 or Portal 2 (see above).
Value Description
None
Pistol Pistol
SMG1 SMG1
AR2 AR2
CombineHeavyCannon Combine Heavy Cannon

Flags

BaseTank:

  • 1 : Active
  • 16 : Only Direct: The tank will only fire if it's target is in direct line of sight.
  • 32 : Controllable
  • 64 : Damage Kick
  • 1024 : NPC Controllable
  • 2048 : NPC Set Controller
  • 4096 : Allow friendlies to hit player
  • 32768 : Non-solid.
  • 131072 : Perfect accuracy every 3rd shot at player
  • 8192 : Ignore range when making viewcone checks
  • 256 : Aiming Assistance (Player Only)

Inputs

BaseTank:

Activate
Turn the tank on
Deactivate
Turn the tank off (go dormant)
SetFireRate  <string>
How fast to fire (0 = don't fire)
SetDamage  <string>
Set the Damage Per Bullet
SetTargetPosition  <string>
World position that I should aim at
SetTargetDir  <vector>
Direction to aim at.
SetTargetEntityName  <string>
Name of entity I should follow/attack
SetTargetEntity  <string>
Entity I should follow/attack (output from other entity only To do: really?)
ClearTargetEntity
Clear the entity I should be attacking.
FindNPCToManTank  <string>
Find a nearby NPC to man this func_tank.
StartFindingNPCs
Start searching for NPCs to man this func_tank.
StopFindingNPCs
Stop searching for NPCs to man this func_tank.
ForceNPCOff
Force the NPC manning this func_tank (if any) to leave.
SetMaxRange  <float>
Set the max range of the func_tank.

Targetname:

Kill
Removes this entity from the world.
KillHierarchy
Removes this entity and all its children from the world.
AddOutput  <string>
Evaluates a keyvalue/output on this entity. It can be potentially very dangerous, use with care.
Format: <key> <value>
Format: <output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire, -1 means infinite>
FireUser1 to FireUser4
Fire the OnUser outputs; see User Inputs and Outputs.
Use  !FGD
Same as a player invoking +use; may not do anything. Can also be invoked by creating an output that does not specify an input.
This input is not included in Valve's FGDs.
RunScriptFile  <script> (New with Left 4 Dead 2)
Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.
RunScriptCode  <string> (New with Left 4 Dead 2)
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 <Left 4 Dead 2>, the code is executed in the script scope of the entity that fires the output, not the one receiving the input.
Warning:Never try to pass string parameters to a script function with this input. It will corrupt the VMF structure because of the nested quotation marks, which then must be removed manually with a text editor.
CallScriptFunction  <string> (New with Left 4 Dead 2) !FGD
Execute a VScript function in the scope of the receiving entity.
Note:This input is missing from some games FGD files.
SetLocalOrigin  <origin> (New with Alien Swarm) !FGD
Set this entity's origin in the map.
Note:This input is missing from some games FGD files.
SetLocalAngles  <angles> (New with Alien Swarm) !FGD
Set this entity's angles in the map.
Note:This input is missing from some games FGD files.

Parentname:

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.
ClearParent
Removes this entity from the the movement hierarchy, leaving it free to move independently.

RenderFields:

Alpha  <integer>
Set the sprite's alpha (0 - 255).
Color  <color255>
Set the sprite's color (R G B).

Shadow:

DisableShadow
Turn shadow off.
EnableShadow
Turn shadow on.
DisableReceivingFlashlight  (New with Portal 2)
This object will not receive light or shadows from projected textures.
EnableReceivingFlashlight  (New with Portal 2)
This object may receive light or shadows from projected textures.

Outputs

BaseTank:

OnFire
Fires when the tank fires its bullets
OnAquireTarget
Fires when target is newly in range and can be shot
OnLoseTarget
Fires when when target goes out of range
OnAmmoDepleted
Fires when tank runs out of ammo
OnGotController
Fires when an NPC starts to control this tank. Players do NOT fire this input.
OnLostController
Fires when the NPC controller of the tank stops controlling it. Players do NOT fire this input.
OnGotPlayerController
Fires when a Player starts to control this tank. NPCs do NOT fire this input.
OnLostPlayerController
Fires when the Player controller of the tank stops controlling it. NPCs do NOT fire this input.
OnReadyToFire
Fires once when the tank is done waiting to fire between rounds

Targetname:

OnUser1 to OnUser4
These Outputs each fire in response to the firing of the like-numbered FireUser1 to FireUser4 Input; see User Inputs and Outputs.
OnKilled  

(New with Left 4 Dead)

This Output fires when the entity is killed and removed from the game.