Task 3 - CS2 Bot behavior trees
Task assignment
Implement a custom bot behavior using KeyValues3 (KV3), and the behavior must contain the following requirements:
- look at the enemy player if nearby
- run to the enemy player's position right after spawn
This behavior should prevent the enemy T team from going to plant the bomb.
Steps to setup
- Read the documentation of Bot Behavior Trees
- Scripts has to be placed in steamapps/common/Counter-Strike Global Offensive/game/csgo
- Create a folder structure if does not exists scripts/ai/task3
- In task3 folder create a KV3 file named follow.kv3 and add all of the logic here
- To run the file use a CS2 console with following commands:
- run map - game_alias custom; game_mode 0; game_type 3;
map de_dust2; mp_roundtime 60; mp_round_restart_delay 0; mp_freezetime 0; mp_team_intro_time 0; mp_warmuptime 0; bot_join_team T;
- clear cache - mp_bot_ai_bt_clear_cache
- apply the script - mp_bot_ai_bt "scripts/ai/task3/follow.kv3"
- kill all bots to apply the AI script - bot_kill
Useful commands
- sv_cheats 1 - activate cheats so useful commands can be used
- noclip - can go through walls and applies immortality
- mp_respawn_on_death_t 1 - respawn T players on death
- mp_respawn_on_death_ct 1 - respawn CT players on death
- bot_add_t - add bot to T team
- bot_add_ct - add bot to CT team
More commands can be found here.
A hint
Focus on the following:
- decorator_repeat
- decorator_sensor (sensor_shape_sphere)
File structure
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
config = "scripts/ai/deathmatch/bt_config.kv3"
root =
{
// Your code …
}
}