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. It simulates a gun turret that can aim and shoot things.

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

Keyvalues

BaseTank:

Control Volume <targetname>
Name of a trigger the player must be inside to control the tank.
(Team) Master <string>
(Team) Master
Yaw rate <string>
How fast tank can look left or right.
Yaw range <string>
How far tank can turn left or right.
Yaw tolerance <string>
Additional left-right range. If the gun tries to turn beyond Yaw range + Yaw tolerance, the gun will snap back to the maximum Yaw range.
Pitch rate <string>
How fast tank can look up or down
Pitch range <string>
How far tank can turn up or down
Pitch tolerance <string>
Additional up-down range. If the gun tries to turn beyond Pitch range + Pitch tolerance, the gun will snap back to the maximum Pitch range.
Barrel Length <string>
Solid length of the tank barrel. Any part of the barrel beyond this length may clip through objects.
Barrel Horizontal <string>
How wide the barrel is, horizontally.}
Barrel Vertical <string>
How wide the barrel is, vertically.
Smoke Sprite <sprite>
Smoke sprite to emit when gun fires.
Bug:
Transparency may not work.
Flash Sprite <sprite>
Flash sprite to emit when gun fires.
Sprite scale <string>
Sprite scale for both sprites above.
Rotate Start Sound <sound>
Sound to play when tank starts to turn.
Rotate Loop Sound <sound>
Sound to play when tank is turning.
Rotate Stop Sound <sound>
Sound to play when tank stops turning.
Rate of Fire <string>
Number of bullets to fire in a second.
Damage Per Bullet <string>
How much a single bullet hurts everything except the player. If 0, takes amount from the type of bullet/damage.
Damage Per Bullet Vs Player <string>
How much a single bullet hurts the player only. If 0, takes amount from the type of bullet/damage.
Firing persistence <string>
How many seconds to keep firing at target's last known position after losing LOS (for NPCs).
Firing persistence2 <string>
After Firing persistence is over, how many seconds to periodically fire at target's last known position (for NPCs).
Bullet accuracy <choices>
How accurately the gun can fire.
  • 0 : Perfect Shot
  • 1 : Small cone
  • 2 : Medium cone
  • 3 : Large cone
  • 4 : Extra-large cone
Minimum target range <string>
Minimum range to target something (for NPCs). If a target is closer than this amount, the NPC will probably switch to any weapon they have on them.
Maximum target range <string>
Maximum range to target something (for NPCs).
Confirm:This may actually be the distance for aim assistance instead?
Minimum light level <string>
Minimum amount of light this entity should receive.
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 and Gun Pitch Pose Param are specified, then the gun itself will be invisible and the 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 and Gun Yaw Pose Param are specified, then the gun itself will be invisible and the 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>
Amount of ammo when player is using. -1 = unlimited ammo.
Lead Target <boolean>
Aim ahead to hit moving targets (for NPCs).
NPC Man Point <targetname>
Point where NPC must stand to use.
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 is under this distance from the tank.
Player Lock Time <float>
The tank must be aiming right on the player for this amount of time before it's allowed to fire.
Effect Handling <choices>
Produce these sound and particle effects when firing.
  • 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>
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 with SmartEdit turned off. 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 and any entities parented to it from the world.
KillHierarchy
Functions the same as Kill, although entities with a large number of children are killed marginally faster.
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.


External Links

Lessons created by Project-S