User:Orinuse/sandbox/TFBot Technicialities

From Valve Developer Community
Jump to navigation Jump to search
Todo: The information here is recently moved from another page, and needs to be reviewed.
Note.pngNote:This entity cannot use Teleporters and Dispensers in MvM.
Icon-Bug.pngBug:This entity will not move in Capture The Flag (and by proxy MvM) modes if there is no flag for that entity's team.  [todo tested in ?]

Skill / Difficulty

Bots behave based on the skill value (or difficulty) they have, which can be set through tf_bot_difficulty or with tf_bot_add. Skills are defined in game as follows:

  • Easy (0)
  • Normal (1)
  • Hard (2)
  • Expert (3)
Todo: Summarize behaviors based on skill value.

General

Bots may change classes in spawn if tf_bot_reevaluate_class_in_spawnroom is set, and will change classes upon death if tf_bot_keep_class_after_death is set.

Scout

Info
Preferred Weapon Primary
Threat Value 0.6
Medic Bot Priority None

Soldier

Info
Preferred Weapon Primary
Threat Value 0.8
Medic Bot Priority 2nd

Soldier bots prefer their primary weapon in combat, but will switch to their secondary if they are out of primary weapon ammo and the threat is closer than 500hu.

Pyro

Info
Preferred Weapon Primary
Threat Value 1
Medic Bot Priority 3rd

Pyro bots are normally offensive and will attack enemies with their primary weapon. However if the enemy is further than 750hu, the bot Pyro will equip its secondary weapon.

They airblast enemies that are closer than tf_bot_pyro_shove_away_range hammer units to the bot pyro, and projectiles if they are visible to the pyro bot and are within tf_bot_pyro_deflect_tolerance angles (in radians) relative to the Pyro bot's FOV. The chance that they will airblast a projectile depends on their skill level.

Skill Level Chance to Airblast
Easy 0% chance
Normal 50% chance
Hard 90% chance
Expert 100% chance

Demoman

Info
Preferred Weapon Primary and Secondary
Threat Value 0.6
Medic Bot Priority 4th

Demoman bots fire their primary weapon in an arc. The angle they fire grenades is tf_bot_ballistic_elevation_rate * the distance to the target (as a normalized vector); they will not fire with their primary above 45° or 0.79π.

When they encounter Sentries, Demoman bots prefer their secondary over their primary and stack stickybombs on the Sentry to then detonate them.

They will sometimes set up sticky-bomb traps on nav areas where they predict the enemy will pass through. The amount of stickybombs they place is

  tf_bot_stickybomb_density * the area of the target nav area

which will always be ≥1. Demoman bots will stop setting up their trap if an enemy is less than 500hu away.

Heavy

Info
Preferred Weapon Primary
Threat Value 0.8
Medic Bot Priority 1st

Heavy bots prefer to use their primary weapon when in combat. They will "rev" (hold right click) for at least three seconds if they see an enemy.

They are the most preferred patient to be healed by Medic bots, out of the other classes.

Engineer

Info
Preferred Weapon Melee and Primary (for combat)
Threat Value 0.4
Medic Bot Priority None

Engineer bots focus on building near sentry spots (func_tfbot_hints with hint KV set to 1). Engineer bots normally just stay around their sentry and constantly hit it with their wrench. If the engineer bot get attacked however, they will attack with their weapon and flee.

Note.pngNote:Engineer bots will not switch to another class if their Sentry or Teleporter Exit is up, regardless if tf_bot_reevaluate_class_in_spawnroom or tf_bot_keep_class_after_death is set.

In Mann Vs. Machine Engineer bots will not attack, unless if they're marked as a squad. They can only build Sentry Guns and Teleporters, and they build around groups of bot_hint_engineer_nests, bot_hint_sentryguns, and bot_hint_teleporter_exits, rather than func_tfbot_hint's.

Teleporters

Non-Medic bots will normally prefer to take active teleporters over walking to the destination, but they will only take them when their incursion distance is less than 350hu + the teleporter area's nav mesh. However Medic bots will only take the teleporter if it's patient also goes through the teleporter; otherwise they ignore them.

Medic

Info
Preferred Weapon Secondary
Threat Value 0.2
Medic Bot Priority None

Medic bots passively heal patients that are in their current viscinity, and will follow their patient when they are between tf_bot_medic_stop_follow_range and tf_bot_medic_start_follow_range from them. They will respond to call for medic from human players that are within tf_bot_medic_max_call_response_range units from the medic bots.

They prefer to heal ally heavies, soldiers, pyros, and demomen over the other classes. If the medic bot is in a squad, they will only heal the squad leader. In the training gamemode, medic bots will always stay on the human player.

If Medic bots have the vaccinator equipped, they will use their über when they or their patient have taken damage. Otherwise medic bots will use their über when:

  • The patient's health ratio is less than 0.5.
  • The patient is not already übered.
  • The medic bot's health is less than 25, 50, or bot_medic_uber_health_threshold attribute.
Icon-Bug.pngBug:Due to an oversight where CTFBotMedicHeal::IsGoodUberTarget( CTFPlayer who* ) always returns false, non-übered medic bots will not stick to their current patient regardless if they have über ready.
Confirm:Does this still happen in game?
  [todo tested in ?]

In MvM medic bots will not attack, unless if marked to be part of a squad in the popfile.

Sniper

Info
Preferred Weapon Primary
Threat Value 0.4
Medic Bot Priority None

Sniper bots typically look around for up to tf_bot_sniper_spot_max_count Sniper Spots (func_tfbot_hints with hint KV set to 0)[confirm] (or the Vantage point) that are atleast tf_bot_sniper_spot_epsilon units away from adjacent sniper spots and attack from those areas. They search for tf_bot_sniper_spot_search_count sniper spots per update frame. However if an enemy gets close to them, the Sniper bot will fight them and then try to retreat to their goal. If the threat is closer than 750hu, then Sniper bots will use their secondary weapon.

When aiming through their primary, Sniper bots choose a target part to hit based on their skill level and take 0.5 to 1.5 seconds to adjust their aim. Expert and Hard bots will aim for the head, normal bots will aim between the head and body, and easy bots will just aim for the body. If Sniper bots have the Huntsman equipped, then they will fire in an arc effected by tf_bot_arrow_elevation_rate, and aim for the same body parts.

Todo: Explain error angle and radius.

Sniper bots will stay tf_bot_sniper_spot_point_tolerance units away from an enemy capture point, while they'll stay within this range in an ally capture point.

Spy

Info
Preferred Weapon Primary and Melee
Threat Value 0.6
Medic Bot Priority None

Spy bots typically lurk around hiding spots[confirm]. They prefer to use their melee weapon if the target is closer than tf_bot_spy_knife_range units to the spy. If their target is further than tf_bot_spy_change_target_range_threshold units away, Spy bots will choose another target that is closer than that distance.

They are suspected by enemies if they collide with an enemy for more than tf_bot_suspect_spy_touch_interval seconds.

Combat

If they kill a victim, a bot has tf_bot_taunt_victim_chance chance to perform a taunt.

Bots will stay in combat until:

  • They have less than 20% max ammo left.
  • They need to do a full reload and they are Hard or Expert bots.
  • Their friend score is lower than the foe score.
  • Their health percentage is lower than tf_bot_health_critical_ratio.

Bots will search for health kits and dispensers when their health is lower than tf_bot_health_ok_ratio or they are on fire, they are not in combat, and a healer is not healing them already. The range that bots will hunt for health in is

   searchRange = tf_bot_health_search_far_range + (current health / max health) * (tf_bot_health_search_near_range - tf_bot_health_search_far_range );

Bots won't try to get health in the Mann Vs. Machine gamemode.

Threat Level

Confirm:Does this mechanic still exist?

Threat levels are scores used to determine how dangerous something is. This value is between 0 (no danger) and 1 (immediate danger). The following actions give a certain threat level:

Threat Value
Enemy (Class) Varied
Übered enemies 1
Level 3 Sentry 1
Level 2 Sentry 0.8
Level 1 Sentry 0.6
Enemies further than tf_bot_sniper_personal_space_range units from a Sniper 0

Typically the threat level is stored in two variables: the friend score and the foe score. These scores are determined through accumulating the threat level of every visible known ally and enemy respectively. Bots will try to retreat if the friend score is lower than the foe score.


Bot Names

The following bot names are what the game uses to randomly set a bot name when creating a bot.


Unused Bot Names

The following bot names were found in a leaked source code version of TF2, containing bot names that were never put into production for unknown reasons.


ConVars/ConCommands

Todo: We should move this to a new page