Func bomb target: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(moved bug from csgo page)
mNo edit summary
 
(27 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{lang|Func bomb target}}
{{subpage|[[Creating a Bomb Defusal Map]]}}
[[File:Func_bomb_target_de_dust2_css.jpg|thumb|right|500px|The use of func_bomb_target on ''de_dust2'' in CS:S.]]
{{TabsBar|main=gs2|base=func_bomb_target}}
{{back|Creating a Bomb Defusal Map}}
[[File:Func_bomb_target_de_dust2_css.jpg|thumb|right|384px|{{css}} The use of func_bomb_target on ''de_dust2''.]]
<br>
{{CD|CBombTarget|file1=cstrike/func_bomb_target.cpp|file2=cstrike15/func_bomb_target.cpp|base=CBaseTrigger}}
{{base brush multi|func_bomb_target|game1=Counter-Strike: Source|game2=Counter-Strike: Global Offensive}}
{{Preserved entity|all}}
{{Note | The <code>Heist Mode bomb Target</code> keyvalue (<code>heistbomb</code>) is an unused value and should be ignored.}}
{{This is a|brush entity|name=func_bomb_target|series=Counter-Strike}}
{{Note | This entity's trigger properties are {{not in FGD}} but can be used, such as the <code>StartDisabled</code> keyvalue and the <code>Enable/Disable/Toggle</code> inputs. To use this entity's inherited trigger I/O (<code>OnStartTouch</code>, ...), set its <code>spawnflags</code> keyvalue appropriately (default is 4097). To add all of this in [[Hammer]], see [[#FGD Code|below]].}}
It is the area inside which players can plant the bomb.
{{ModernBug|Dynamically created bomb targets may not be properly recognized by bots.{{Confirm}} [https://www.youtube.com/watch?v&#61;urlvnXlRmoI&t&#61;94s See YouTube video for the issue]. }}
The existence of this entity makes a map a [[Bomb Defusal]] scenario.
{{preservedEnt|0}}
{{Tip|This entity enherits functionalities from CBaseTrigger that are {{not in FGD}} but they can be used, such as the <code>StartDisabled</code> keyvalue and the <code>Enable/Disable/Toggle</code> inputs. To use this entity's inherited trigger I/O (<code>OnStartTouch</code>, ...), set its <code>spawnflags</code> keyvalue appropriately (default is 4097). To add all of this in [[Hammer]], see [[#FGD Code|below]].}}


{{code class|CBombTarget|func_bomb_target.cpp}}


==Entity Description==
==Entity Description==


The existence of this entity makes a map a [[Bomb Defusal]] scenario.
[[Player]]s can plant a [[weapon_c4|bomb]] if they touch this entity.
It marks where [[weapon_c4|C4 entities]] can be planted.
:{{csgo}} But at most once: Doing so "consumes" a <tt>func_bomb_target</tt>, meaning that it allows no more planting inside it. The input <tt>BombPlanted</tt> consumes it, too.
 
The outputs <tt>BombPlanted</tt>, <tt>BombDefused</tt> and/or <tt>BombExplode</tt> are fired either in conjunction with a C4 entity that was planted inside it, or in response to the inputs of the same name.
:{{csgo}} When planting outside any <tt>func_bomb_target</tt> with {{ent|mp_plant_c4_anywhere|1}}, there is still a <tt>func_bomb_target</tt> chosen that is consumed and that fires outputs, even if all existing <tt>func_bomb_target</tt>s are already consumed.
{{Bug|The <tt>BombDefused</tt> output is '''not''' fired when a bomb is defused.}}


* [[Player]]s must touch the volume of any [[func_bomb_target]] in order to plant a [[weapon_c4|C4 entity]].
[[Bot]]s read the bomb plant locations from the [[Nav Mesh]] and not from the actual position of <tt>func_bomb_target</tt>s in the world. Since this information is set in the analysis phase of the nav mesh generation, there is no way that bots recognize the position of a <tt>func_bomb_target</tt> if it has moved. <sup>[https://www.youtube.com/watch?v&#61;urlvnXlRmoI&t&#61;94s video]</sup>.
* {{csgo}} As soon as a C4 entity is planted inside this entity's volume or as soon as it receives the input '''<code>BombPlanted</code>''', 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 '''<code>BombPlanted</code>''', '''<code>BombDefused</code>''' and/or '''<code>BombExplode</code>''' in response to this specific C4 entity.
** {{Bug | The '''<code>BombDefused</code>''' output is '''NOT''' fired when a bomb is defused.}}
** {{csgo}} When planting outside any [[func_bomb_target]] with {{ent|mp_plant_c4_anywhere|1}}, there is still a [[func_bomb_target]] entity chosen that does the above, even if all existing [[func_bomb_target]]s are already consumed.


=== Bombsite A and B ===
=== Bombsite A and B ===
If the [[Nav Mesh]] exists and if the closest nav area to the this entity's center has a [[Nav Mesh Editing#Place Names|place name]], then this bombsite will be '''A''' if that place name is one of <code>BombsiteA</code> or <code>Bombsite</code>, otherwise it is '''B'''.<sup>[https://github.com/perilouswithadollarsign/cstrike15_src/blob/f82112a2388b841d72cb62ca48ab1846dfcc11c8/game/server/cstrike15/cs_player_resource.cpp#L316-L339 code]</sup><br>
Generally, the game assigns the label '''A''' to the <tt>func_bomb_target</tt> with the lowest [[entity index]] and '''B''' to the highest. This, however, is overridden if the closest [[Nav Mesh|nav area]] to a <tt>func_bomb_target</tt> has a [[Nav_Mesh_Editing#Place_names_.28callouts.29|place name]]: If that place name is one of <tt>Bombsite</tt> or <tt>BombsiteA</tt>, it will be '''A'''; Any other place name yields '''B'''.
To swap '''A''' and '''B''', change the place names accordingly: The closest nav area to the center of '''A''' must get the place name <code>Bombsite</code> or <code>BombsiteA</code> 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!<br>
Therefore, the mapper can set the labelling either by adding appropriate place names to crucial areas in-game, or &ndash; if no place names interfere! &ndash; by ordering their entity IDs in the [[VMF]] (and thus the entity index in-game) using Hammer: Move all <tt>func_bomb_target</tt>s to the world using {{key|Ctrl|shift|W}} and then tie them to an entity with {{key|Ctrl|T}} in the desired order.
To swap '''A''' and '''B''', you can
* move the corresponding brushes of the [[func_bomb_target]]s manually.
* move both [[func_bomb_target]]s to the world by selecting them and pressing {{Key|Crtl}}+{{Key|Shift}}+{{Key|W}}. Then, tie the brush(es) for '''A''' to an entity using {{Key|Ctrl}}+{{Key|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 [[s_PreserveEnts|preserved]] classes is used for the radar, so if there are more than two [[func_bomb_target]]s, at most one of them will be '''A''' and at most one will be '''B''' on the radar. Other labels don't exist.
When a map loads, the game creates at most one <tt>info_bomb_target_hint_A</tt> and at most one <tt>info_bomb_target_hint_B</tt> entity near the center of the corresponding <tt>func_bomb_target</tt>, if any. These [[s_PreserveEnts|preserved]] entities are used for the radar. It can happen that a label is missing, which is when two bombsites would get the same label due to inappropriate place names. There ''will'' be at most two labels and it can only be '''A''' or '''B''' even though there is the place name {{code|BombsiteC}} and radio voicelines naming "bombsite C". Still, any number of bombsites should work technically but there may be minor bugs such as missing text since the game is programmed to assume that there are at most two.


==Keyvalues==
==Keyvalues==
{{KV|Heist Mode bomb Target|bool|intn=heistbomb|Tells the bomb target that it's designed for the Heist game mode.}}
{{KV Targetname}}
{{KV|Bomb Mount Target|targetname|intn=bomb_mount_target|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 {{ent|info_target}}. {{Bug | In [[Hammer]], this value's type is a string by default. See [[#FGD Code|below]] for a fix.}} }}
{{KV|Bomb Mount Target|targetname|intn=bomb_mount_target|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 {{ent|info_target}}. {{Bug|hidetested=y| In the default FGDs, this value's type is a string by default, preventing the editor from autofilling it. See [[#FGD Code|below]] for a fix.}} }}
{{KV|Heist Mode bomb Target|deprecated=1|bool|intn=heistbomb|Marks the bomb target as designated for the heist game mode. Support for heist mode was never fully implemented, so this KV doesn't do anything.}}
{{KV BaseTrigger}}
{{KV BaseTrigger}}
{{KV BaseEntity}}
:{{note|Filter Name does not work.}}


==Inputs==
==Inputs==
{{IO|BombExplode|nofgd=1|Fires the <code>BombExplode</code> output.}}
{{I|BombExplode|nofgd=1|Fires the <code>BombExplode</code> output.}}
{{IO|BombDefused|nofgd=1|Fires the <code>BombDefused</code> output.}}
{{I|BombDefused|nofgd=1|Fires the <code>BombDefused</code> output.}}
{{IO|BombPlanted|nofgd=1|Fires the <code>BombPlanted</code> output and removes this entity's volume from the planting zones until next round.}}
{{I|BombPlanted|nofgd=1|Fires the <code>BombPlanted</code> output and removes this entity's volume from the planting zones until next round.}}
{{I BaseTrigger|notf2=1}}
{{I BaseTrigger|notf2=1}}
{{I BaseEntity}}


==Outputs==
==Outputs==
{{IO|BombExplode|Fires when the bomb explodes or if the <code>BombExplode</code> input is received.}}
{{O|BombExplode|ac-is-self=1|Fires when the bomb explodes or if the <code>BombExplode</code> input is received.}}
{{IO|BombDefused|Fires when the bomb is defused or if the <code>BombDefused</code> input is received. {{Bug | Is not fired by normal gameplay, only with the '''<code>BombDefused</code>''' input.}} }}
{{O|BombDefused|ac-is-self=1|Fires when the bomb is defused or if the <code>BombDefused</code> input is received. {{Bug | Is not fired by normal gameplay, only with the '''<code>BombDefused</code>''' input.}} }}
{{IO|BombPlanted|Fires when the bomb is planted or if the <code>BombPlanted</code> input is received.}}
{{O|BombPlanted|ac-is-self=1|Fires when the bomb is planted or if the <code>BombPlanted</code> input is received.}}
{{O BaseTrigger}}
{{O BaseTrigger}}
{{O BaseEntity}}


==[[FGD]] Code==
==[[FGD]] Code==
Replace the corresponding lines of {{ent|cstrike.fgd}} or {{ent|csgo.fgd}} near <code>func_bomb_target</code> with this.
This code
This code
* replaces its base classes with <code>Trigger</code> which effectively adds trigger properties such as the keyvalue <code>StartDisabled</code>, the inputs <code>Enable/Disable/Toggle/OnStartTouch/...</code> and the [[Trigger_once#Flags|trigger flags]] (1: Clients, ...).
* replaces its base classes with <code>Trigger</code> which effectively adds trigger properties such as the keyvalue <code>StartDisabled</code>, the inputs <code>Enable/Disable/Toggle/OnStartTouch/...</code> and the [[Trigger_once#Flags|trigger flags]] (1: Clients, ...).
Line 59: Line 54:
* adds the inputs <code>BombExplode/BombDefused/BombPlanted</code> with the above description.
* adds the inputs <code>BombExplode/BombDefused/BombPlanted</code> with the above description.
* corrects the type of <code>bomb_mount_target</code> from <code>string</code> to <code>target_destination</code>.
* corrects the type of <code>bomb_mount_target</code> from <code>string</code> to <code>target_destination</code>.
Replace the corresponding lines of {{ent|cstrike.fgd}} or {{ent|csgo.fgd}} near <code>func_bomb_target</code> with this.
{{pre|1=
{{pre|
@SolidClass base(Trigger) = func_bomb_target:   
@SolidClass base(Trigger) {{=}} func_bomb_target:   
"Bomb Target. The terrorists can place C4 explosives while standing in this zone.\n\n" +
"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 " +
"When the bomb is planted and explodes inside this area, the BombExplode outputs are fired. The game handles " +
Line 77: Line 71:
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."
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."
heistbomb(choices) : "Heist Mode bomb target" : 0 : "This is a Bomb Target designed for the Heist game mode." =
[
0 : "No"
1 : "Yes"
]


bomb_mount_target(target_destination) : "Bomb Mount Target"  
bomb_mount_target(target_destination) : "Bomb Mount Target"  
]
]
}}
}}

Latest revision as of 08:21, 12 May 2025

Counter-Strike: Source The use of func_bomb_target on de_dust2.
C++ Class hierarchy
CBombTarget
CBaseTrigger
CBaseToggle
CBaseEntity
C++ cstrike/func_bomb_target.cpp
Recycle-warning.png
This is a preserved entity.
If the game has round restart mechanics this entity may not behave as expected.

func_bomb_target is a brush entity available in Counter-Strike seriesCounter-Strike series Counter-Strike series. It is the area inside which players can plant the bomb. The existence of this entity makes a map a Bomb Defusal scenario.

Tip.pngTip: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.


Entity Description

Players can plant a bomb if they touch this entity.

Counter-Strike: Global Offensive But at most once: Doing so "consumes" a func_bomb_target, meaning that it allows no more planting inside it. The input BombPlanted consumes it, too.

The outputs BombPlanted, BombDefused and/or BombExplode are fired either in conjunction with a C4 entity that was planted inside it, or in response to the inputs of the same name.

Counter-Strike: Global Offensive When planting outside any func_bomb_target with mp_plant_c4_anywhere 1, there is still a func_bomb_target chosen that is consumed and that fires outputs, even if all existing func_bomb_targets are already consumed.
Icon-Bug.pngBug:The BombDefused output is not fired when a bomb is defused.  [todo tested in ?]

Bots read the bomb plant locations from the Nav Mesh and not from the actual position of func_bomb_targets in the world. Since this information is set in the analysis phase of the nav mesh generation, there is no way that bots recognize the position of a func_bomb_target if it has moved. video.

Bombsite A and B

Generally, the game assigns the label A to the func_bomb_target with the lowest entity index and B to the highest. This, however, is overridden if the closest nav area to a func_bomb_target has a place name: If that place name is one of Bombsite or BombsiteA, it will be A; Any other place name yields B.

Therefore, the mapper can set the labelling either by adding appropriate place names to crucial areas in-game, or – if no place names interfere! – by ordering their entity IDs in the VMF (and thus the entity index in-game) using Hammer: Move all func_bomb_targets to the world using Ctrl+ Shift+W and then tie them to an entity with Ctrl+T in the desired order.

When a map loads, the game creates at most one info_bomb_target_hint_A and at most one info_bomb_target_hint_B entity near the center of the corresponding func_bomb_target, if any. These preserved entities are used for the radar. It can happen that a label is missing, which is when two bombsites would get the same label due to inappropriate place names. There will be at most two labels and it can only be A or B even though there is the place name BombsiteC and radio voicelines naming "bombsite C". Still, any number of bombsites should work technically but there may be minor bugs such as missing text since the game is programmed to assume that there are at most two.

Keyvalues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

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 the default FGDs, this value's type is a string by default, preventing the editor from autofilling it. See below for a fix.
Heist Mode bomb Target (heistbomb) <boolean> Obsolete
Deprecated.
Marks the bomb target as designated for the heist game mode. Support for heist mode was never fully implemented, so this KV doesn't do anything.
BaseTrigger
Filter Name (filtername) <filter>
A filter entity to test potential activators against.
Start Disabled (StartDisabled) <boolean>
Stay dormant until activated (with theEnableinput).
Note.pngNote:Filter Name does not work.

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.
Icon-Bug.pngBug:Sleeping prop_physics will never fire "OnTouching". Also applies to entities using prop_physics as base.  (tested in: Half-Life 2)
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 MultiplayerTeam Fortress 2 branch)
Disables this trigger and calls EndTouch on all currently-touching entities.

Outputs

BombExplode
!activator = !caller = this entity
Fires when the bomb explodes or if the BombExplode input is received.
BombDefused
!activator = !caller = this entity
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.  [todo tested in ?]
BombPlanted
!activator = !caller = this entity
Fires when the bomb is planted or if the BombPlanted input is received.
BaseTrigger
OnStartTouch
!activator = entity that caused this output
!caller = this entity
Fired when a valid entity starts touching this trigger.
OnStartTouchAll
!activator = entity that caused this output
!caller = this entity
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
!activator = entity that caused this output
!caller = this entity
Fired when a valid entity stops touching this trigger.
Note.pngNote:Will also fire for entities touching it when trigger is disabled via Disable input
Warning.pngWarning:This includes entities which are deleted while inside the trigger. In this case !activator will be invalid.
Warning.pngWarning:OnEndTouch can fire before OnStartTouch under certain circumstances[How?] where both are fired on the same tick and each have the same delay.
Note.pngFix:Add a slight delay to OnEndTouch.
OnEndTouchAll
!activator = entity that caused this output
!caller = this entity
Fired when all valid entities stop touching this trigger.
OnTouching  (in all games since Source 2007)
!activator = !caller = this entity
Fired if something is currently touching this trigger when TouchTest is fired.
OnNotTouching  (in all games since Source 2007)
!activator = !caller = this entity
Fired if nothing is currently touching this trigger when TouchTest is fired.

FGD Code

Replace the corresponding lines of cstrike.fgd or csgo.fgd near func_bomb_target with this. 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.
@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(choices) : "Heist Mode bomb target" : 0 : "This is a Bomb Target designed for the Heist game mode." =
	[
		0 : "No"
		1 : "Yes"
	]

	bomb_mount_target(target_destination) : "Bomb Mount Target" 
]