func_bomb_target

From Valve Developer Community
Jump to: navigation, search
Counter-Strike: Source The use of func_bomb_target on de_dust2.
class hierarchy
CBombTarget
CBaseTrigger
CBaseToggle
CBaseEntity

func_bomb_target is a brush entity available in the Counter-Strike series.

Note.pngNote:This entity enherits functionalities from CBaseTrigger that are !FGD but they can be used, such as the StartDisabled keyvalue and the Enable/Disable/Toggle inputs. To use this entity's inherited trigger I/O (OnStartTouch, ...), set its spawnflags keyvalue appropriately (default is 4097). To add all of this in Hammer, see below.
Note.pngNote:This is a preserved entity in .
  • On a new round, its properties including its position will intentionally not reset. You can use logic_auto to emulate resetting it.
  • Killing it removes it forever, as it is not respawned on a new round.
  • It cannot be spawned with a point_template.
  • Parenting this with non preserved entities may have undesirable effects.


In code, it is represented by theCBombTargetclass, defined in thefunc_bomb_target.cppfile.

Entity Description

The existence of this entity makes a map a Bomb Defusal scenario. It marks where C4 entities can be planted.

  • Players must touch the volume of any func_bomb_target in order to plant a C4 entity.
  • Counter-Strike: Global Offensive As soon as a C4 entity is planted inside this entity's volume or as soon as it receives the input BombPlanted, this entity will no longer allow players to plant a C4 entity inside it.
  • If a C4 entity is planted inside this entity's volume, this entity fires the outputs BombPlanted, BombDefused and/or BombExplode in response to this specific C4 entity.
Confirm.pngConfirm: Bots read the bomb plant locations from the Nav Mesh and not from func_bomb_target entities. Since this information is set in the analysis phase of the nav mesh generation, there is no way that bots will recognize the new position of a func_bomb_target if it has been moved. Dynamically created bomb targets may not be properly recognized by bots. See YouTube video for the issue.

Bombsite A and B

If the Nav Mesh exists and if the closest nav area to the this entity's center has a place name, then this bombsite will be A if that place name is one of BombsiteA or Bombsite, otherwise it is B.code
To swap A and B, change the place names accordingly: The closest nav area to the center of A must get the place name Bombsite or BombsiteA and the closest nav area to the center of B must have no name or any name but the previous two.

Otherwise, the bombsites are assigned A and B in the order in which their brush(es) were tied to an entity (!). The order in which their classname is changed to func_bomb_target does not affect the labelling!
To swap A and B, you can

  • move the corresponding brushes of the func_bomb_targets manually.
  • move both func_bomb_targets to the world by selecting them and pressing Crtl+ Shift+W. Then, tie the brush(es) for A to an entity using Ctrl+T and after that, do the same for B. Finally, change the entity classnames.

When a map loads, the game creates either an info_bomb_target_hint_A or an info_bomb_target_hint_B entity near the center of this entity. At most one instance of each of these two preserved classes is used for the radar, so if there are more than two func_bomb_targets, at most one of them will be A and at most one will be B on the radar. Other labels don't exist.

Confirm.pngConfirm: There can only be bombsite A or bombsite B even though the existence of the place name BombsiteC or radio command voiceline files naming "bombsite C" may suggest the opposite. Still, maps can have more than two bombsites that work, it's just that there may be minor bugs such as missing text since the game assumes that there are at most two.

Keyvalues

Heist Mode bomb Target (heistbomb) <boolean>
Marks the bomb target as designated for the heist game mode.
Note.pngNote:Support for heist mode was never fully implemented, so this KV should usually be set to false.
Bomb Mount Target (bomb_mount_target) <targetname>
Optionally, have the bomb be forced to a specific position and orientation after being planted. The position and angles are determined by the ones of a specified info_target.
Icon-Bug.pngBug:In Hammer, this value's type is a string by default. See below for a fix.

BaseTrigger:

Filter Name (filtername) <filter>
A filter entity to test potential activators against.
Start Disabled (StartDisabled) <boolean>
Stay dormant until activated (with theEnableinput).

Base:
Name (targetname) <string>
The name that other entities use to refer to this entity.
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.pngTip:Entities transition to the next map with their parents
Tip.pngTip: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.pngNote: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.pngNote: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.pngTip: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 Left 4 Dead 2) (also in Team Fortress 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. Scripts executed on the worldspawn entity will be placed in root scope.
Think function (thinkfunction) <string> (in all games since Left 4 Dead 2) (also in Team Fortress 2)
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 Left 4 Dead 2) !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 Counter-Strike: Global Offensive) !FGD
If set to 1, this entity will slow down aiming movement for consoles and joystick controllers when the entity is under the crosshairs.

Inputs

BombExplode  !FGD
Fires the BombExplode output.
BombDefused  !FGD
Fires the BombDefused output.
BombPlanted  !FGD
Fires the BombPlanted output and removes this entity's volume from the planting zones until next round.

BaseTrigger:
Toggle
Toggles this trigger between enabled and disabled states.
Enable
Enable trigger
Disable
Disable trigger
TouchTest  (in all games since Source 2007)
Triggers either the OnTouching or OnNotTouching outputs for whether anything is touching this entity.
StartTouch  (in all games since Source 2007) !FGD
Behave as if the !caller entity had just entered the trigger volume. Accepts non-physical entities.
EndTouch  (in all games since Source 2007) !FGD
Behave as if !caller had just exited the trigger volume.
DisableAndEndTouch  (only in Source 2013 Multiplayer(Team Fortress 2))
Disables this trigger and calls EndTouch on all currently-touching entities.

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 to FireUser4
Fires the respectiveOnUseroutputs; 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 thanKillinput.
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.
Use  !FGD
Same as a player invoking +use; no effect in most cases.
DispatchResponse <string> !FGD
Dispatches a response to the entity. See Response and Concept.
DispatchEffect <string> (removed since Left 4 Dead) !FGD
Dispatches a special effect from the entity's origin; See also List of Client Effects. Replaced by the particle system since Left 4 Dead.
RunScriptFile <script> (in all games since Left 4 Dead 2) (also in Team Fortress 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> (in all games since Left 4 Dead 2) (also in Team Fortress 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.
Icon-Bug.pngBug:In Hammer, using string arguments will corrupt the VMF file's structure, making the file unviewable for the next Hammer session.
Note.pngFix:Remove the string argument manually with a text editor.
Note.pngNote:Team Fortress 2 Backtick characters ` are replaced with quotation marks at runtime, allowing quotation marks to be used when normally not possible.
CallScriptFunction <string> (in all games since Left 4 Dead 2) (also in Team Fortress 2) !FGD
Calls a VScript function defined in the scope of the receiving entity.
TerminateScriptScope  (only in Team Fortress 2) !FGD
Destroys the script scope of the receving entity.
SetLocalOrigin <coordinates> (in all games since Alien Swarm) !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.
SetLocalAngles <angles> (in all games since Alien Swarm) !FGD
Set this entity's angles.

Outputs

BombExplode
Fires when the bomb explodes or if the BombExplode input is received.
BombDefused
Fires when the bomb is defused or if the BombDefused input is received.
Icon-Bug.pngBug:Is not fired by normal gameplay, only with the BombDefused input.
BombPlanted
Fires when the bomb is planted or if the BombPlanted input is received.

BaseTrigger:

OnStartTouch
Fired when a valid entity starts touching this trigger. !activator is whatever touches the trigger.
OnStartTouchAll
Fired when a valid entity starts touching this trigger, and no other entities are touching it. If there are any other entities touching the trigger when a new one begins to touch, only OnStartTouch will fire.
OnEndTouch
Fired when a valid entity stops touching this trigger.
Warning.pngWarning:This includes entities which are deleted while inside the trigger. In this case !activator will be invalid.
OnEndTouchAll
Fired when all valid entities stop touching this trigger.
OnTouching  (in all games since Source 2007)
Fired if something is currently touching this trigger when TouchTest is fired.
OnNotTouching  (in all games since Source 2007)
Fired if nothing is currently touching this trigger when TouchTest is fired.

Base:

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.

FGD Code

This code

  • replaces its base classes with Trigger which effectively adds trigger properties such as the keyvalue StartDisabled, the inputs Enable/Disable/Toggle/OnStartTouch/... and the trigger flags (1: Clients, ...).
  • adds the input TouchTest and the outputs OnTouching/OnNotTouching as seen in trigger_multiple of base.fgd.
  • adds the inputs BombExplode/BombDefused/BombPlanted with the above description.
  • corrects the type of bomb_mount_target from string to target_destination.

Replace the corresponding lines of cstrike.fgd or csgo.fgd near func_bomb_target with this.

@SolidClass base(Trigger) = func_bomb_target:  
	"Bomb Target. The terrorists can place C4 explosives while standing in this zone.\n\n" +
	"When the bomb is planted and explodes inside this area, the BombExplode outputs are fired. The game handles " +
	"all of the bomb planting and scoring logic – the BombExplode outputs are provided to add visual and damage effects."
[
	input TouchTest(void) : "Tests if the trigger is being touched and fires an output based on whether the value is true or false." 
	input BombExplode(void): "Fires the BombExplode output"
	input BombPlanted(void): "Fires the BombPlanted output and removes this entity's volume from the planting zones until next round"
	input BombDefused(void): "Fires the BombDefused output"
	
	output OnTouching(void) : "Fired when the TestTouch input is true (something is touching the trigger.)"
	output OnNotTouching(void) : "Fired when the TestTouch input is not true (nothing is touching the trigger.)"
	output BombExplode(void): "Fires when C4 explodes or if the BombExplode input is received"
	output BombPlanted(void): "Fires when a C4 is planted or if the BombPlanted input is received"
	output BombDefused(void): "Fires when a C4 is defused or if the BombDefused input is received; Bug: Is not fired by normal gameplay, only with the BombDefused input."

	heistbomb(boolean) : "Heist Mode bomb target" : 0 : "This is a Bomb Target designed for the Heist game mode."

	bomb_mount_target(target_destination) : "Bomb Mount Target" 
]