CFuncTank

From Source Entities
Jump to navigation Jump to search

Present in:
Hl2.pngHL2
Hl2-episodes.pngEp1&2
Hl2dm-custom.pngHL2:DM
P1.pngPortal
P2.pngPortal 2
Csgo.pngCS:GO

Code classes:

CFuncTank is a code class in some Source games. Mounted gun entities inherit it. These "tank" entities were never used for tanks in Source, but the original one, func_tank, was used for some in Half-Life. Can be controlled by NPCs, the player, or by itself via inputs.

Tip: Moving the brush origin will change the barrel's position and the spot at which the gun pivots around. To offset the gun's barrel without changing the pivoting point, see Barrel Length, Barrel Horizontal, and Barrel Vertical. Offsets will affect aim!

Note: Many bugs are present in P2.pngCsgo-small.png. See below for an alternative mounted gun/tank.

Flags[edit | edit source]

  • 1: Active - Sets if the tank is allowed to fire via inputs. Affects nothing else.[Confirmed]
  • 16: Only Direct - Needed to allow the tank to fire via inputs if using func_tank.
  • 32: Controllable - Allows the player to control the tank.
  • 64: Damage Kick - Allows the tank to be damaged. The tank is supposed to visibly recoil from the damage, but it doesn't seem to happen.
  • 256: Aiming Assistance (Player Only) - Adjusts aim somewhat to help players.
  • 1024: NPC Controllable - Allows NPCs to control the tank.
  • 2048: NPC Set Controller - To do: Description.
  • 4096: Allow friendlies to hit player
  • 8192: Ignore range when making viewcone checks - No effect. The range keyvalues can be ignored by setting them to 0.
  • 32768: Non-solid
  • 131072: Perfect accuracy every 3rd shot at player (when NPC controlling)

Keyvalues[edit | edit source]

Control Volume (control_volume) <target_destination>
Name of a CBaseTrigger a player must stand in to use the gun.
NPC Man Point (npc_man_point) <target_destination>
Spot NPCs will stand at while manning the gun.
Rate of Fire (firerate) <float>
How many bullets fire in one second. Does not apply when being fired by an NPC.
Damage Per Bullet (bullet_damage) <integer>
How much a single shot damages things. If left at 0, uses default damage based on what type of bullet is shot.
Damage Per Bullet Vs Player (bullet_damage_vs_player) <integer>
How much a shot damages a player. If left at 0, defers to Damage Per Bullet.
Pitch range (pitchrange) <float>
Degree range the gun can tilt up and down in.
Pitch rate (pitchrate) <float>
How fast the gun can move up and down.
Pitch tolerance (pitchtolerance) <float>
Extension to Pitch range. When the gun hits range + tolerance, it moves back to the edge of the range.
Yaw range (yawrange) <float>
Degree range the gun can swivel left or right in.
Yaw rate (yawrate) <float>
How fast the gun can move left and right.
Yaw tolerance (yawtolerance) <float>
Extension to Yaw range. When the gun hits range + tolerance, it moves back to the edge of the range.
Effect Handling (effecthandling) <choices>
What bullet effects to show.
  • 0: Use Individual Settings - See Bullets or Ammo Type.
  • 1: AR2
  • 2: Combine Cannon
Bullets (Not in FGD) (bullet) <choices> (only available in Hl2.png&DM P2.pngCsgo-small.png)
What kind of bullets to shoot.
  • 0: None
  • 1: Pistol
  • 2: SMG1
  • 3: AR2
  • 4: Laser - Doesn't work.
Ammo type (ammotype) <choices> (only available in Hl2.pngEpisodicP1.png)
What kind of bullets to shoot. Note: Most don't look or sound how they should due to short-sightedness from Valve. This keyvalue basically does nothing except modify the damage amounts. See the bottom of the page for a tutorial on shooting anything out of a tank.
Gun Base Attachment (gun_base_attach) <string>
If the gun has a Parent, which attachment point to aim from. Tip: Attachment points can be viewed ingame with ent_attachments.
Gun Barrel Attachment (gun_barrel_attach) <string>
Attachment point on the Parent to fire from. If you specify this, you'll want to specify the Gun Base Attachment too. To do: Does it look wrong when these two are different points?
Gun Yaw Pose Param (gun_yaw_pose_param) <string>
If this and Gun Pitch Pose Param are set, the specified pose parameter will be set to the tank's yaw.
Gun Yaw Pose Center (gun_yaw_pose_center) <float>
To do: Description.
Gun Pitch Pose Param (gun_pitch_pose_param) <string>
If this and 'Gun Yaw Pose Param are set, the specified pose parameter will be set to the tank's pitch.
Gun Pitch Pose Center (gun_pitch_pose_center) <float>
To do: Description.
Barrel Length (barrel) <float>
Offsets the end of the barrel to be closer to or farther out from the origin. Note: Players will have to manually adjust aim to account for offsets! Manual tank fire and NPCs don't know how to offset aim.
Barrel Horizontal (barrely) <float>
Offsets the end of the barrel to the left or right of the origin.
Barrel Vertical (barrelz) <float>
Offsets the end of the barrel above or below the origin.
Smoke Sprite (spritesmoke) <sprite>
Smoke sprite to spawn when the gun is fired.
Flash Sprite (spriteflash) <sprite>
Flash sprite to spawn when the gun is fired.
Sprite scale (spritescale) <float>
Scales the size of spawned sprites.
Rotate Start Sound (rotatestartsound) <sound>
Sound that plays when the gun starts to rotate.
Rotate Loop Sound (rotatesound) <sound>
Sound that plays as the gun moves. Intended to be looped; needs loop markers or it only plays once!
Rotate Stop Sound (rotatestopsound) <sound>
Sound that plays when the gun finishes rotating.
Firing persistence (persistence) <float>
When the tank is firing unmanned, how long it will continue to shoot at the last spot it saw a target.
Firing persistence2 (persistence2) <float>
Doesn't work.
Bullet accuracy (firespread) <choices>
How accurate the gun is.
  • 0: Perfect Shot
  • 1: Small cone
  • 2: Medium cone
  • 3: Large cone
  • 4: Extra-large cone
Minimum target range (minRange) <float>
When the tank is firing unmanned, targets must be at least this far away for the gun to fire at them. Targets closer than this are instantly forgotten about.
Maximum target range (maxRange) <float>
When the tank is firing unmanned, targets must be within this distance to the tank for the gun to fire at them. Targets farther away than this are instantly forgotten about.
Ammunition Count (ammo_count) <integer>
How much ammo the tank has when fired by NPCs and players. -1 = infinite.
Lead Target (LeadTarget) <boolean>
To do: Makes the gun do some extra trajectory math, but to no effect?
Post-NPC Attack Grace Period (playergraceperiod) <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 (ignoregraceupto) <float>
The player grace period is ignored if the player's under this distance from the tank.
Player Lock Time (playerlocktimebeforefire) <float>
The NPC manning the tank must have the player as a target for this amount of time before it's allowed to fire.
(Team) Master (master) <target_destination>
Outdated. Replaced by Activate/Deactivate inputs.
Shadows (Not in FGD) (vrad_brush_cast_shadows) <choices>
Determines if this entity will cast lightmap shadows.
  • 0: No shadows
  • 1: Cast shadows
Render Mode (rendermode) <choices>
A special rendering mode to use on this entity.
Render Amount/Transparency (renderamt) <integer>
Transparency amount, requires a Render Mode (rendermode) other than Normal. 0 is invisible, 255 is fully visible.
Render Color (R G B) (rendercolor) <color255>
Color channel filter to add to this entity's texture(s). Bug: P2.pngCsgo-small.pngBroken for brush entities.
Render FX (renderfx) <choices>
Preset appearance effects. Partially supported in Asw.png, completely non-functional in P2.pngCsgo-small.png. Bug: Sometimes functions incorrectly if changed with AddOutput, but is the only way to change effects other than making multiple versions of the object.
Minimum Light (_minlight) <float>
Minimum amount of light to hit this brush. 0 is none, 1 is "fullbright". Useful because the lightmaps will not update as the entity moves.
Render in Fast Reflections (drawinfastreflection) <boolean> (available in all games since P2.png)
Makes the entity be rendered in reflections from water materials using $reflectonlymarkedentities.

Inputs[edit | edit source]

FindNPCToManTank <target_destination>
Tells the specified NPC to man the tank.
SetTargetEntityName <target_destination>
Tells the tank to shoot at the specified entity.
Activate
Sets the Active flag.
Deactivate
Unsets the Active flag.
SetFireRate <float>
Sets Rate of Fire.
SetDamage <integer>
Sets Damage Per Bullet.
SetTargetPosition <origin>
Tells the tank to aim at this position in the world. Warning: Known to cause crashes.
SetTargetDir <vector>
Tells the tank to aim in this direction. Warning: Known to cause crashes.
SetTargetEntity <target_destination>
Slightly different version of SetTargetEntityName. Works the same, but cannot recognize !activator.
ClearTargetEntity
Tells the tank to forget about its target entity.
StartFindingNPCs
Continuously searches for NPCs to man the tank. NPCs must not be busy with anything else.
StopFindingNPCs
Stops searching for NPCs.
ForceNPCOff
Forces the manning NPC off the gun.
SetMaxRange <float>
Sets Maximum target range.
Alpha <integer>
Sets Render Amount/Transparency (renderamt).
Color <color255>
Sets the Render Color (rendercolor).
EnableDrawInFastReflection  (available in all games since P2.png)
Sets Render in Fast Reflections to true.
DisableDrawInFastReflection  (available in all games since P2.png)
Sets Render in Fast Reflections to false.

Outputs[edit | edit source]

OnFire
Fires every time the tank fires a shot.
OnLoseTarget
Fires when the tank loses a target.
OnAquireTarget
Fires when the tank finds a target.
OnAmmoDepleted
Does not fire.
OnGotController
Fires when an NPC takes control of the gun.
OnLostController
Fires when an NPC is no longer on the gun.
OnGotPlayerController
Fires when a player takes control of the gun.
OnLostPlayerController
Fires when a player is no longer on the gun.
OnReadyToFire
Fires when the tank is no longer being fired. Also fires on spawn if Active is checked.

See Also[edit | edit source]