├── .clang-tidy ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ └── mod_support_request.yml └── workflows │ └── build-action.yml ├── .gitignore ├── .gitmodules ├── AMBuildScript ├── AMBuilder ├── BreakpadSymbols ├── LICENSE ├── PackageScript ├── README.md ├── configs ├── bms │ ├── player_models.ini │ └── weapons.cfg ├── bot_difficulty.cfg ├── bot_names.cfg ├── dod │ └── weapons.cfg ├── nav_places.cfg ├── settings.example.cfg └── tf │ ├── class_selection.cfg │ ├── mvm_upgrades.cfg │ └── weapons.cfg ├── configure.py ├── docs ├── BOT_DIFFICULTY_PROFILES.md ├── BOT_NAMES.md ├── CONVARS.md ├── INSTALL.md ├── MOD_SETTINGS.md ├── QAA.md ├── README.md ├── USAGE.md ├── WEAPONINFO_CONFIG.md ├── developers │ ├── README.md │ ├── extension │ │ ├── COMPILING.md │ │ ├── CREATING-BOTS.md │ │ ├── NEW-MOD.md │ │ ├── README.md │ │ └── VS_PROJECT.md │ └── sourcepawn │ │ ├── FORWARDS.md │ │ ├── NATIVES.md │ │ ├── PLUGIN_BOTS.md │ │ └── README.md └── navmesh │ ├── NAVMESH_AUTHOR_INFO.md │ ├── NAVMESH_BASIC_EDITING.md │ ├── NAVMESH_EDITING_TIPS.md │ ├── NAVMESH_ELEVATORS.md │ ├── NAVMESH_OFFMESHLINKS.md │ ├── NAVMESH_PLACES.md │ ├── NAVMESH_PREREQUISITES.md │ ├── NAVMESH_SCRIPTING.md │ ├── NAVMESH_VOLUMES.md │ ├── README.md │ ├── TF2_EDITING.md │ └── WAYPOINT_BASICS.md ├── extension ├── bot │ ├── basebot.cpp │ ├── basebot.h │ ├── basebot_behavior.cpp │ ├── basebot_behavior.h │ ├── basebot_debug.cpp │ ├── basebot_hooks.cpp │ ├── basebot_pathcost.cpp │ ├── basebot_pathcost.h │ ├── blackmesa │ │ ├── bmbot.cpp │ │ ├── bmbot.h │ │ ├── bmbot_behavior.cpp │ │ ├── bmbot_behavior.h │ │ ├── bmbot_inventory.cpp │ │ ├── bmbot_inventory.h │ │ ├── bmbot_movement.cpp │ │ ├── bmbot_movement.h │ │ ├── bmbot_sensor.cpp │ │ ├── bmbot_sensor.h │ │ └── tasks │ │ │ ├── bmbot_deploy_tripmines.cpp │ │ │ ├── bmbot_deploy_tripmines.h │ │ │ ├── bmbot_find_ammo_task.cpp │ │ │ ├── bmbot_find_ammo_task.h │ │ │ ├── bmbot_find_armor_task.cpp │ │ │ ├── bmbot_find_armor_task.h │ │ │ ├── bmbot_find_health_task.cpp │ │ │ ├── bmbot_find_health_task.h │ │ │ ├── bmbot_find_weapon_task.cpp │ │ │ ├── bmbot_find_weapon_task.h │ │ │ ├── bmbot_main_task.cpp │ │ │ ├── bmbot_main_task.h │ │ │ ├── bmbot_tactical_task.cpp │ │ │ ├── bmbot_tactical_task.h │ │ │ └── scenario │ │ │ ├── bmbot_roam_task.cpp │ │ │ ├── bmbot_roam_task.h │ │ │ ├── bmbot_scenario_deathmatch_task.cpp │ │ │ └── bmbot_scenario_deathmatch_task.h │ ├── bot_debug_shared.h │ ├── bot_shared_convars.cpp │ ├── bot_shared_convars.h │ ├── bot_shared_utils.cpp │ ├── bot_shared_utils.h │ ├── dods │ │ ├── dodsbot.cpp │ │ ├── dodsbot.h │ │ ├── dodsbot_behavior.cpp │ │ ├── dodsbot_behavior.h │ │ ├── dodsbot_inventory.cpp │ │ ├── dodsbot_inventory.h │ │ ├── dodsbot_movement.cpp │ │ ├── dodsbot_movement.h │ │ ├── dodsbot_sensor.cpp │ │ ├── dodsbot_sensor.h │ │ └── tasks │ │ │ ├── dodsbot_main_task.cpp │ │ │ ├── dodsbot_main_task.h │ │ │ ├── dodsbot_scenario_monitor_task.cpp │ │ │ ├── dodsbot_scenario_monitor_task.h │ │ │ ├── dodsbot_tactical_monitor_task.cpp │ │ │ ├── dodsbot_tactical_monitor_task.h │ │ │ └── scenario │ │ │ ├── dodsbot_attack_control_point_task.cpp │ │ │ ├── dodsbot_attack_control_point_task.h │ │ │ ├── dodsbot_defuse_bomb_task.cpp │ │ │ ├── dodsbot_defuse_bomb_task.h │ │ │ ├── dodsbot_deploy_bomb_task.cpp │ │ │ ├── dodsbot_deploy_bomb_task.h │ │ │ ├── dodsbot_fetch_bomb_task.cpp │ │ │ └── dodsbot_fetch_bomb_task.h │ ├── hl2dm │ │ ├── hl2dmbot.cpp │ │ └── hl2dmbot.h │ ├── interfaces │ │ ├── base_interface.cpp │ │ ├── base_interface.h │ │ ├── behavior.cpp │ │ ├── behavior.h │ │ ├── decisionquery.h │ │ ├── event_listener.h │ │ ├── inventory.cpp │ │ ├── inventory.h │ │ ├── knownentity.cpp │ │ ├── knownentity.h │ │ ├── movement.cpp │ │ ├── movement.h │ │ ├── path │ │ │ ├── basepath.cpp │ │ │ ├── basepath.h │ │ │ ├── chasenavigator.cpp │ │ │ ├── chasenavigator.h │ │ │ ├── meshnavigator.cpp │ │ │ ├── meshnavigator.h │ │ │ ├── path_shareddefs.h │ │ │ ├── pluginnavigator.cpp │ │ │ └── pluginnavigator.h │ │ ├── playercontrol.cpp │ │ ├── playercontrol.h │ │ ├── playerinput.h │ │ ├── profile.cpp │ │ ├── profile.h │ │ ├── sensor.cpp │ │ ├── sensor.h │ │ ├── sharedmemory.cpp │ │ ├── sharedmemory.h │ │ ├── squads.cpp │ │ ├── squads.h │ │ ├── tasks.h │ │ ├── weapon.cpp │ │ ├── weapon.h │ │ ├── weaponinfo.cpp │ │ └── weaponinfo.h │ ├── pluginbot │ │ ├── pluginbot.cpp │ │ ├── pluginbot.h │ │ ├── pluginbot_behavior.cpp │ │ ├── pluginbot_behavior.h │ │ ├── pluginbot_movement.cpp │ │ └── pluginbot_movement.h │ ├── tasks_shared │ │ ├── bot_shared_attack_enemy.h │ │ ├── bot_shared_attack_nearest_enemy.h │ │ ├── bot_shared_debug_move_to_origin.h │ │ ├── bot_shared_defend_spot.h │ │ ├── bot_shared_escort_entity.h │ │ ├── bot_shared_prereq_destroy_ent.h │ │ ├── bot_shared_prereq_move_to_pos.h │ │ ├── bot_shared_prereq_use_ent.h │ │ ├── bot_shared_prereq_wait.h │ │ ├── bot_shared_pursue_and_destroy.h │ │ ├── bot_shared_roam.h │ │ ├── bot_shared_snipe.h │ │ ├── bot_shared_squad_follow_leader.h │ │ ├── bot_shared_squad_member_monitor.h │ │ ├── bot_shared_take_cover_from_spot.h │ │ └── bot_shared_use_self_heal_item.h │ └── tf2 │ │ ├── tasks │ │ ├── engineer │ │ │ ├── tf2bot_engineer_build_object.cpp │ │ │ ├── tf2bot_engineer_build_object.h │ │ │ ├── tf2bot_engineer_dodge_sentry_buster.cpp │ │ │ ├── tf2bot_engineer_dodge_sentry_buster.h │ │ │ ├── tf2bot_engineer_main.cpp │ │ │ ├── tf2bot_engineer_main.h │ │ │ ├── tf2bot_engineer_move_object.cpp │ │ │ ├── tf2bot_engineer_move_object.h │ │ │ ├── tf2bot_engineer_nest.cpp │ │ │ ├── tf2bot_engineer_nest.h │ │ │ ├── tf2bot_engineer_repair_object.cpp │ │ │ ├── tf2bot_engineer_repair_object.h │ │ │ ├── tf2bot_engineer_speedup_object.cpp │ │ │ ├── tf2bot_engineer_speedup_object.h │ │ │ ├── tf2bot_engineer_upgrade_object.cpp │ │ │ └── tf2bot_engineer_upgrade_object.h │ │ ├── general │ │ │ ├── tf2bot_collect_item.cpp │ │ │ ├── tf2bot_collect_item.h │ │ │ ├── tf2bot_follow_entity.cpp │ │ │ └── tf2bot_follow_entity.h │ │ ├── medic │ │ │ ├── tf2bot_medic_heal_task.cpp │ │ │ ├── tf2bot_medic_heal_task.h │ │ │ ├── tf2bot_medic_main_task.cpp │ │ │ ├── tf2bot_medic_main_task.h │ │ │ ├── tf2bot_medic_mvm_build_uber_task.cpp │ │ │ ├── tf2bot_medic_mvm_build_uber_task.h │ │ │ ├── tf2bot_medic_retreat_task.cpp │ │ │ ├── tf2bot_medic_retreat_task.h │ │ │ ├── tf2bot_medic_revive_task.cpp │ │ │ └── tf2bot_medic_revive_task.h │ │ ├── scenario │ │ │ ├── controlpoints │ │ │ │ ├── tf2bot_attack_controlpoint.cpp │ │ │ │ ├── tf2bot_attack_controlpoint.h │ │ │ │ ├── tf2bot_controlpoints_monitor.cpp │ │ │ │ ├── tf2bot_controlpoints_monitor.h │ │ │ │ ├── tf2bot_defend_controlpoint.cpp │ │ │ │ └── tf2bot_defend_controlpoint.h │ │ │ ├── deathmatch │ │ │ │ ├── tf2bot_deathmatch.cpp │ │ │ │ └── tf2bot_deathmatch.h │ │ │ ├── mvm │ │ │ │ ├── tf2bot_mvm_defend.cpp │ │ │ │ ├── tf2bot_mvm_defend.h │ │ │ │ ├── tf2bot_mvm_guard_dropped_bomb_task.cpp │ │ │ │ ├── tf2bot_mvm_guard_dropped_bomb_task.h │ │ │ │ ├── tf2bot_mvm_idle.cpp │ │ │ │ ├── tf2bot_mvm_idle.h │ │ │ │ ├── tf2bot_mvm_monitor.cpp │ │ │ │ ├── tf2bot_mvm_monitor.h │ │ │ │ ├── tf2bot_mvm_tasks.cpp │ │ │ │ ├── tf2bot_mvm_tasks.h │ │ │ │ ├── tf2bot_mvm_upgrade.cpp │ │ │ │ └── tf2bot_mvm_upgrade.h │ │ │ ├── passtime │ │ │ │ ├── tf2bot_passtime_goal_task.cpp │ │ │ │ ├── tf2bot_passtime_goal_task.h │ │ │ │ ├── tf2bot_passtime_monitor_task.cpp │ │ │ │ ├── tf2bot_passtime_monitor_task.h │ │ │ │ ├── tf2bot_pick_jack_task.cpp │ │ │ │ ├── tf2bot_pick_jack_task.h │ │ │ │ ├── tf2bot_seek_and_destroy_jack_carrier_task.cpp │ │ │ │ ├── tf2bot_seek_and_destroy_jack_carrier_task.h │ │ │ │ ├── tf2bot_wait_for_jack_task.cpp │ │ │ │ └── tf2bot_wait_for_jack_task.h │ │ │ ├── payload │ │ │ │ ├── tf2bot_task_defend_payload.cpp │ │ │ │ ├── tf2bot_task_defend_payload.h │ │ │ │ ├── tf2bot_task_push_payload.cpp │ │ │ │ └── tf2bot_task_push_payload.h │ │ │ ├── pd │ │ │ │ ├── tf2bot_pd_collect_task.cpp │ │ │ │ ├── tf2bot_pd_collect_task.h │ │ │ │ ├── tf2bot_pd_monitor_task.cpp │ │ │ │ ├── tf2bot_pd_monitor_task.h │ │ │ │ ├── tf2bot_pd_move_to_capture_zone_task.cpp │ │ │ │ ├── tf2bot_pd_move_to_capture_zone_task.h │ │ │ │ ├── tf2bot_pd_search_and_destroy_task.cpp │ │ │ │ └── tf2bot_pd_search_and_destroy_task.h │ │ │ ├── rd │ │ │ │ ├── tf2bot_rd_collect_points_task.cpp │ │ │ │ ├── tf2bot_rd_collect_points_task.h │ │ │ │ ├── tf2bot_rd_defend_core_task.cpp │ │ │ │ ├── tf2bot_rd_defend_core_task.h │ │ │ │ ├── tf2bot_rd_destroy_robots_task.cpp │ │ │ │ ├── tf2bot_rd_destroy_robots_task.h │ │ │ │ ├── tf2bot_rd_monitor_task.cpp │ │ │ │ ├── tf2bot_rd_monitor_task.h │ │ │ │ ├── tf2bot_rd_steal_enemy_points_task.cpp │ │ │ │ └── tf2bot_rd_steal_enemy_points_task.h │ │ │ ├── specialdelivery │ │ │ │ ├── tf2bot_sd_deliver_flag.cpp │ │ │ │ ├── tf2bot_sd_deliver_flag.h │ │ │ │ ├── tf2bot_sd_wait_for_flag.cpp │ │ │ │ ├── tf2bot_sd_wait_for_flag.h │ │ │ │ ├── tf2bot_special_delivery_monitor_task.cpp │ │ │ │ └── tf2bot_special_delivery_monitor_task.h │ │ │ ├── tf2bot_destroy_halloween_boss_task.cpp │ │ │ ├── tf2bot_destroy_halloween_boss_task.h │ │ │ ├── tf2bot_map_ctf.cpp │ │ │ └── tf2bot_map_ctf.h │ │ ├── sniper │ │ │ ├── tf2bot_task_sniper_main.cpp │ │ │ ├── tf2bot_task_sniper_main.h │ │ │ ├── tf2bot_task_sniper_move_to_sniper_spot.cpp │ │ │ ├── tf2bot_task_sniper_move_to_sniper_spot.h │ │ │ ├── tf2bot_task_sniper_push.cpp │ │ │ ├── tf2bot_task_sniper_push.h │ │ │ ├── tf2bot_task_sniper_snipe_area.cpp │ │ │ └── tf2bot_task_sniper_snipe_area.h │ │ ├── spy │ │ │ ├── tf2bot_spy_main_task.cpp │ │ │ ├── tf2bot_spy_main_task.h │ │ │ ├── tf2bot_spy_mvm_tasks.cpp │ │ │ ├── tf2bot_spy_mvm_tasks.h │ │ │ ├── tf2bot_spy_tasks.cpp │ │ │ └── tf2bot_spy_tasks.h │ │ ├── tf2bot_attack.cpp │ │ ├── tf2bot_attack.h │ │ ├── tf2bot_dead.cpp │ │ ├── tf2bot_dead.h │ │ ├── tf2bot_find_ammo_task.cpp │ │ ├── tf2bot_find_ammo_task.h │ │ ├── tf2bot_find_health_task.cpp │ │ ├── tf2bot_find_health_task.h │ │ ├── tf2bot_maintask.cpp │ │ ├── tf2bot_maintask.h │ │ ├── tf2bot_roam.cpp │ │ ├── tf2bot_roam.h │ │ ├── tf2bot_scenario_task.cpp │ │ ├── tf2bot_scenario_task.h │ │ ├── tf2bot_setuptime.cpp │ │ ├── tf2bot_setuptime.h │ │ ├── tf2bot_tactical.cpp │ │ ├── tf2bot_tactical.h │ │ ├── tf2bot_taunting.cpp │ │ ├── tf2bot_taunting.h │ │ ├── tf2bot_use_teleporter.cpp │ │ └── tf2bot_use_teleporter.h │ │ ├── tf2bot.cpp │ │ ├── tf2bot.h │ │ ├── tf2bot_behavior.cpp │ │ ├── tf2bot_behavior.h │ │ ├── tf2bot_controller.cpp │ │ ├── tf2bot_controller.h │ │ ├── tf2bot_inventory.cpp │ │ ├── tf2bot_inventory.h │ │ ├── tf2bot_movement.cpp │ │ ├── tf2bot_movement.h │ │ ├── tf2bot_sensor.cpp │ │ ├── tf2bot_sensor.h │ │ ├── tf2bot_spymonitor.cpp │ │ ├── tf2bot_spymonitor.h │ │ ├── tf2bot_upgrades.cpp │ │ ├── tf2bot_upgrades.h │ │ ├── tf2bot_utils.cpp │ │ ├── tf2bot_utils.h │ │ ├── tf2bot_weaponinfo.cpp │ │ └── tf2bot_weaponinfo.h ├── concommands_bots.cpp ├── concommands_debug.cpp ├── concommands_tools.cpp ├── entities │ ├── basecombatchar.cpp │ ├── basecombatchar.h │ ├── basecombatweapon.cpp │ ├── basecombatweapon.h │ ├── baseentity.cpp │ ├── baseentity.h │ ├── tf2 │ │ ├── tf_entities.cpp │ │ └── tf_entities.h │ ├── worldspawn.cpp │ └── worldspawn.h ├── extension.cpp ├── extension.h ├── extplayer.cpp ├── extplayer.h ├── manager.cpp ├── manager.h ├── mods │ ├── basemod.cpp │ ├── basemod.h │ ├── blackmesa │ │ ├── blackmesa_shareddefs.h │ │ ├── blackmesadm_mod.cpp │ │ ├── blackmesadm_mod.h │ │ └── nav │ │ │ ├── bm_nav_mesh.cpp │ │ │ └── bm_nav_mesh.h │ ├── dods │ │ ├── dayofdefeatsourcemod.cpp │ │ ├── dayofdefeatsourcemod.h │ │ ├── dods_shareddefs.h │ │ ├── dodslib.cpp │ │ ├── dodslib.h │ │ └── nav │ │ │ ├── dods_nav_area.cpp │ │ │ ├── dods_nav_area.h │ │ │ ├── dods_nav_mesh.cpp │ │ │ └── dods_nav_mesh.h │ ├── gamemods_shared.h │ ├── hl2dm │ │ ├── hl2dm_mod.cpp │ │ └── hl2dm_mod.h │ ├── modsettings.cpp │ ├── modsettings.h │ └── tf2 │ │ ├── mvm_upgrade.h │ │ ├── mvm_upgrade_manager.cpp │ │ ├── mvm_upgrade_manager.h │ │ ├── nav │ │ ├── tfnav_edit.cpp │ │ ├── tfnav_waypoint.cpp │ │ ├── tfnav_waypoint.h │ │ ├── tfnav_waypoint_edit.cpp │ │ ├── tfnavarea.cpp │ │ ├── tfnavarea.h │ │ ├── tfnavmesh.cpp │ │ └── tfnavmesh.h │ │ ├── teamfortress2_shareddefs.h │ │ ├── teamfortress2mod.cpp │ │ ├── teamfortress2mod.h │ │ ├── tf2_class_selection.cpp │ │ ├── tf2_class_selection.h │ │ ├── tf2lib.cpp │ │ └── tf2lib.h ├── natives.cpp ├── natives.h ├── natives │ ├── bots.cpp │ ├── bots.h │ └── interfaces │ │ ├── path.cpp │ │ └── path.h ├── navbot.autoload ├── navmesh │ ├── nav.h │ ├── nav_area.cpp │ ├── nav_area.h │ ├── nav_colors.cpp │ ├── nav_colors.h │ ├── nav_consts.h │ ├── nav_edit.cpp │ ├── nav_elevator.cpp │ ├── nav_elevator.h │ ├── nav_elevator_edit.cpp │ ├── nav_entities.cpp │ ├── nav_entities.h │ ├── nav_file.cpp │ ├── nav_generate.cpp │ ├── nav_ladder.cpp │ ├── nav_ladder.h │ ├── nav_merge.cpp │ ├── nav_mesh.cpp │ ├── nav_mesh.h │ ├── nav_node.cpp │ ├── nav_node.h │ ├── nav_params.cpp │ ├── nav_pathfind.h │ ├── nav_place_loader.h │ ├── nav_prereq.cpp │ ├── nav_prereq.h │ ├── nav_prereq_edit.cpp │ ├── nav_scripting.cpp │ ├── nav_scripting.h │ ├── nav_simplify.cpp │ ├── nav_trace.cpp │ ├── nav_trace.h │ ├── nav_utils.h │ ├── nav_volume.cpp │ ├── nav_volume.h │ ├── nav_volume_edit.cpp │ ├── nav_waypoint.cpp │ ├── nav_waypoint.h │ └── nav_waypoint_edit.cpp ├── pawn_mem_manager.cpp ├── pawn_mem_manager.h ├── sdkports │ ├── debugoverlay_shared.cpp │ ├── debugoverlay_shared.h │ ├── eventlistenerhelper.h │ ├── gametrace_server.cpp │ ├── sdk_collisionutils.cpp │ ├── sdk_collisionutils.h │ ├── sdk_ehandle.cpp │ ├── sdk_ehandle.h │ ├── sdk_game_util.h │ ├── sdk_servernetworkproperty.cpp │ ├── sdk_servernetworkproperty.h │ ├── sdk_takedamageinfo.h │ ├── sdk_timedeventmgr.cpp │ ├── sdk_timedeventmgr.h │ ├── sdk_timers.cpp │ ├── sdk_timers.h │ ├── sdk_traces.cpp │ ├── sdk_traces.h │ ├── sdk_utils.h │ ├── studio.cpp │ ├── studio_csgo.cpp │ └── studio_episode1.cpp ├── smsdk_config.h └── util │ ├── commandargs_episode1.h │ ├── ehandle_edict.cpp │ ├── ehandle_edict.h │ ├── entprops.cpp │ ├── entprops.h │ ├── helpers.cpp │ ├── helpers.h │ ├── librandom.cpp │ ├── librandom.h │ ├── prediction.cpp │ ├── prediction.h │ ├── sdkcalls.cpp │ └── sdkcalls.h ├── gamedata └── navbot.games │ ├── common.games.txt │ ├── game.bms.txt │ ├── game.cstrike.txt │ ├── game.dod.txt │ ├── game.hl1mp.txt │ ├── game.hl2mp.txt │ ├── game.tf.txt │ └── master.games.txt ├── premake ├── bms.lua ├── common_sdk.lua ├── csgo.lua ├── css.lua ├── dods.lua ├── episode1.lua ├── hl2dm.lua ├── l4d.lua ├── l4d2.lua ├── orangebox.lua ├── sdk2013.lua ├── swarm.lua └── tf2.lua ├── premake5.lua └── scripting ├── include ├── navbot.inc └── navbot │ ├── bots.inc │ └── interfaces │ └── path.inc ├── navbot_admin.sp └── navbot_example.sp /.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: '-*,readability-delete-null-pointer,readability-implicit-bool-conversion,readability-redundant-inline-specifier,performance-noexcept-destructor,modernize-use-override,performance-inefficient-algorithm,performance-inefficient-vector-operation,bugprone-infinite-loop,readability-make-member-function-const,bugprone-suspicious-semicolon,bugprone-suspicious-memset-usage,performance-for-range-copy,performance-no-automatic-move,performance-move-const-arg,performance-unnecessary-copy-initialization,performance-unnecessary-value-param,readability-duplicate-include,readability-else-after-return,readability-redundant-casting,readability-redundant-smartptr-get,modernize-use-nullptr,readability-redundant-control-flow' 2 | CheckOptions: 3 | - key: readability-implicit-bool-conversion.AllowPointerConditions 4 | value: '1' -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Discord 4 | url: https://discord.gg/Qu5pAMvftj 5 | about: For quick questions, help with installation and posting nav mesh files. 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Generated paths 35 | build/ 36 | versioning/ 37 | output/ 38 | premake5_build/ 39 | 40 | # Visual Studio Code files and paths 41 | .vscode/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "hl2sdk-manifests"] 2 | path = hl2sdk-manifests 3 | url = https://github.com/alliedmodders/hl2sdk-manifests.git 4 | -------------------------------------------------------------------------------- /AMBuilder: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | import os, pathlib 3 | 4 | # Name of your extesion, this will also be it's file name. 5 | projectName = 'navbot' 6 | 7 | # smsdk_ext.cpp will be automatically added later 8 | sourceFiles = [ 9 | ] 10 | 11 | def AddSourceFiles(): 12 | p = pathlib.Path(os.path.join(builder.currentSourcePath, 'extension')) 13 | files = p.glob('**/*.cpp') 14 | 15 | for f in files: 16 | sourceFiles.append(str(f)) 17 | 18 | AddSourceFiles() 19 | 20 | includesDirs = [ 21 | os.path.join(builder.currentSourcePath, 'extension'), 22 | ] 23 | 24 | project = builder.LibraryProject(projectName) 25 | 26 | if os.path.isfile(os.path.join(builder.currentSourcePath, 'sdk', 'smsdk_ext.cpp')): 27 | # Use the copy included in the project 28 | project.sources += [os.path.join('sdk', 'smsdk_ext.cpp')] 29 | else: 30 | # Use the copy included with SM 1.6 and newer 31 | project.sources += [os.path.join(Extension.sm_root, 'public', 'smsdk_ext.cpp')] 32 | 33 | project.sources += sourceFiles 34 | 35 | for sdk_name in Extension.sdks: 36 | sdk = Extension.sdks[sdk_name] 37 | if sdk['name'] in ['mock']: 38 | continue 39 | 40 | for cxx in builder.targets: 41 | if not cxx.target.arch in sdk['platforms'][cxx.target.platform]: 42 | continue 43 | 44 | binary = Extension.HL2ExtConfig(project, builder, cxx, projectName + '.ext.' + sdk['extension'], sdk) 45 | binary.compiler.cxxincludes += includesDirs 46 | # fixes a compile error due to missing include 47 | binary.compiler.defines += [ 'RAD_TELEMETRY_DISABLED' ] 48 | 49 | 50 | Extension.extensions += builder.Add(project) 51 | -------------------------------------------------------------------------------- /BreakpadSymbols: -------------------------------------------------------------------------------- 1 | # vim: set ts=2 sw=2 tw=99 noet ft=python: 2 | import os, sys 3 | 4 | UPLOAD_SCRIPT = os.path.join(Extension.sm_root, 'tools', 'buildbot', 'upload_symbols.py') 5 | 6 | if 'BREAKPAD_SYMBOL_SERVER' in os.environ: 7 | symbolServer = os.environ['BREAKPAD_SYMBOL_SERVER'] 8 | builder.SetBuildFolder('breakpad-symbols') 9 | 10 | for cxx_task in Extension.extensions: 11 | if cxx_task.target.platform in ['windows']: 12 | debug_entry = cxx_task.debug 13 | else: 14 | debug_entry = cxx_task.binary 15 | 16 | debug_file = os.path.join(builder.buildPath, debug_entry.path) 17 | if cxx_task.target.platform == 'linux': 18 | argv = ['dump_syms', debug_file, os.path.dirname(debug_file)] 19 | elif cxx_task.target.platform == 'mac': 20 | # Required once dump_syms is updated on the slaves. 21 | #argv = ['dump_syms', '-g', debug_file + '.dSYM', debug_file] 22 | argv = ['dump_syms', debug_file + '.dSYM'] 23 | elif cxx_task.target.platform == 'windows': 24 | argv = ['dump_syms.exe', debug_file] 25 | 26 | plat_dir = os.path.dirname(debug_file) 27 | bin_dir = os.path.split(plat_dir)[0] 28 | 29 | symbol_file = '{}-{}-{}.breakpad'.format( 30 | os.path.split(bin_dir)[1], 31 | cxx_task.target.platform, 32 | cxx_task.target.arch) 33 | 34 | argv = [sys.executable, UPLOAD_SCRIPT, symbol_file] + argv 35 | builder.AddCommand( 36 | inputs = [UPLOAD_SCRIPT, debug_entry], 37 | argv = argv, 38 | outputs = [symbol_file] 39 | ) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Nav Bot 2 | ====== 3 | 4 | [SourceMod]: https://www.sourcemod.net/ 5 | [Nav Mesh VSP]: https://github.com/taiyungwang/valve_source_plugin_navmesh 6 | [Taiyungwang]: https://github.com/taiyungwang 7 | [Documentation]: docs/README.md 8 | [Discord]: https://discord.gg/bh9g8MebJn 9 | [Valve's NavMesh]: https://developer.valvesoftware.com/wiki/Nav_Mesh 10 | [Day of Defeat: Source]: https://store.steampowered.com/app/300/Day_of_Defeat_Source/ 11 | [Installing NavBot]: docs/INSTALL.md 12 | [Supported Games/Mods List]: docs/MODS.md 13 | 14 | Nav Bot is a [SourceMod] extension that provides a third-party player bot for Source Engine games and mods. 15 | 16 | It utilizes a modified version of [Valve's NavMesh] for navigation. 17 | 18 | The NavMesh is also standalone and can be used in games that doesn't already have one such as [Day of Defeat: Source]. 19 | 20 | ## Supported Games/Mods 21 | 22 | List of game/mods that NavBot supports. 23 | 24 | | Game/Mod Name | Support Status | 25 | |:---:|:---:| 26 | | Team Fortress 2 | Good | 27 | | Black Mesa | Good | 28 | | Day of Defeat: Source | Basic | 29 | 30 | ### Legend 31 | 32 | - Basic: Very basic support, missing major features. 33 | - Partial: Some features are implemented but still missing some significant ones. 34 | - Good: Overall good support for the game. 35 | 36 | ## Downloads 37 | 38 | See [Installing NavBot]. 39 | 40 | ## Links 41 | 42 | - [Documentation] 43 | - [Discord] 44 | 45 | ## Credits 46 | 47 | - [Taiyungwang]: For porting [Valve's NavMesh] as a Valve Server Plugin. The NavMesh used by this extension is based on that. -------------------------------------------------------------------------------- /configs/bms/player_models.ini: -------------------------------------------------------------------------------- 1 | ; NavBot Black Mesa player model configuration file 2 | ; 3 | ; This is a section name, it should be the model name without the .mdl extension 4 | [mp_scientist_hev] 5 | ; Number of skins this model contains 6 | skin_count = 1 7 | 8 | [mp_scientist] 9 | skin_count = 15 10 | 11 | [mp_scientist_02] 12 | skin_count = 8 13 | 14 | [mp_scientist_female] 15 | skin_count = 7 16 | 17 | [mp_guard] 18 | skin_count = 15 19 | 20 | [mp_guard_02] 21 | skin_count = 8 22 | 23 | [mp_marine] 24 | skin_count = 15 25 | 26 | [mp_marine_02] 27 | skin_count = 8 28 | 29 | [mp_zombie_sci] 30 | skin_count = 1 31 | 32 | [mp_zombie_marine] 33 | skin_count = 1 34 | 35 | [mp_gman] 36 | skin_count = 1 -------------------------------------------------------------------------------- /configs/nav_places.cfg: -------------------------------------------------------------------------------- 1 | NavPlaces 2 | { 3 | /** 4 | * NavBot Nav Mesh Place database. 5 | * Global database used for ALL mods. 6 | * 7 | * Format is: "KEY" "HUMAN READABLE NAME" 8 | * Example: "CTSpawn" "Counter-Terrorist Spawn" 9 | * "CTSpawn" is the key used when selecting the place in edit mode 10 | * "Counter-Terrorist Spawn" is the human readable name that bots will use when saying the place. 11 | * Example: if a bot wants to say something is in CTSpawn, they will say "enemy spotted in Counter-Terrorist Spawn" 12 | */ 13 | "Brige" "Bridge" 14 | "Middle" "Middle" 15 | "Sewers" "Sewers" 16 | "Tunnel" "Tunnel" 17 | "Ducts" "Ducts" 18 | "Village" "Village" 19 | "Roof" "Roof" 20 | "Upstairs" "Upstairs" 21 | "Downstairs" "Downstairs" 22 | "Basement" "Basement" 23 | "Inside" "Inside" 24 | "Outside" "Outside" 25 | "Garage" "Garage" 26 | "Courtyard" "Courtyard" 27 | "Water" "Water" 28 | "FrontDoor" "Front Door" 29 | "BackDoor" "Back Door" 30 | "SideDoor" "Side Door" 31 | "BackWay" "Back Way" 32 | "FrontYard" "Front Yard" 33 | "BackYard" "Back Yard" 34 | "SideYard" "Side Yard" 35 | "Elevator" "Elevator" 36 | "LongHall" "Long Hall" 37 | "SideHall" "Side Hall" 38 | "FrontHall" "Front Hall" 39 | "BackHall" "Back Hall" 40 | "MainHall" "Main Hall" 41 | "FarSide" "Far Side" 42 | "Underpass" "Underpass" 43 | "Overpass" "Overpass" 44 | "Stairs" "Stairs" 45 | "Ladder" "Ladder" 46 | "Gate" "Gate" 47 | "Balcony" "Balcony" 48 | "Alley" "Alley" 49 | "BackAlley" "Back Alley" 50 | "SideAlley" "Side Alley" 51 | "FrontRoom" "Front Room" 52 | "BackRoom" "Back Room" 53 | "SideRoom" "Side Room" 54 | "Crates" "Crates" 55 | "Truck" "Truck" 56 | "Bedroom" "Bedroom" 57 | "FamilyRoom" "Family Room" 58 | "Bathroom" "Bathroom" 59 | "LivingRoom" "Living Room" 60 | "Office" "Office" 61 | "Atrium" "Atrium" 62 | "Entryway" "Entryway" 63 | "Stairwell" "Stairwell" 64 | } -------------------------------------------------------------------------------- /configs/settings.example.cfg: -------------------------------------------------------------------------------- 1 | /** 2 | * NavBot Mod Settings example file. 3 | * To use this file, rename it to settings.cfg and move it to the mod folder (see below) 4 | * 5 | * This file should be moved to the mod subfolder. IE: configs/navbot/tf/settings.cfg 6 | * 7 | */ 8 | ModSettings 9 | { 10 | /* Add key value pairs here */ 11 | } -------------------------------------------------------------------------------- /docs/BOT_DIFFICULTY_PROFILES.md: -------------------------------------------------------------------------------- 1 | # Bot Difficulty Profiles 2 | 3 | The bot difficulty profile stores difficulty/skill level related variables. 4 | 5 | The ConVar `sm_navbot_skill_level` determines which skill group to use. 6 | 7 | These profiles are stored in the `addons/sourcemod/configs/navbot/` folder. 8 | 9 | ## Loading Files 10 | 11 | The parser supports mod specific profiles and custom overrides. 12 | 13 | Per mod files are stored in the mod folder. Example: `addons/sourcemod/configs/navbot/tf/bot_difficulty.cfg`. 14 | 15 | If that file doesn't exists, it loads the global configuration file located at: `addons/sourcemod/configs/navbot/bot_difficulty.cfg`. 16 | 17 | ### Overrides 18 | 19 | You can override the bot profile files by renaming it to `bot_difficulty.custom.cfg`. 20 | 21 | This allows you to customize the bot profiles without worrying about losing them when updating the extension. 22 | 23 | # Profile Format 24 | 25 | Example profile 26 | 27 | ``` 28 | "Easy" 29 | { 30 | "skill_level" "0" 31 | "aimspeed" "500" 32 | "fov" "60" 33 | "maxvisionrange" "1024" 34 | "maxhearingrange" "350" 35 | "minrecognitiontime" "1.0" 36 | } 37 | ``` 38 | 39 | | Key | Description | 40 | |:---:|:---:| 41 | | skill_level | Which skill level this profile part of. You can have multiple profiles with the same skill level. A random profile will be selected for the bot. | 42 | | game_awareness | The bot game awareness skill. Ranges from 0 to 100. | 43 | | aimspeed | The bot aim turn rate in degrees per second. | 44 | | fov | The bot field of view in degrees. | 45 | | maxvisionrange | The bot maximum vision range in hammer units. | 46 | | maxhearingrange | The bot maximum hearing range in hammer units. | 47 | | minrecognitiontime | The minimum amount of time in seconds an entity must be visible for the bot to it be recognized by the bot's systems. (Reaction time) | 48 | | aggressiveness | How aggressive this bot is. | 49 | | teamwork | How likely this bot will cooperate with teammates. | 50 | 51 | -------------------------------------------------------------------------------- /docs/BOT_NAMES.md: -------------------------------------------------------------------------------- 1 | # Bot Names 2 | 3 | Bot names are loaded from the following config file: `addons/navbot/configs/bot_names.cfg`. 4 | 5 | If `addons/navbot/configs/bot_names.custom.cfg` exists, it will prefer loading from that instead. 6 | 7 | ## Format 8 | 9 | One name per line, maximum of 30 characters. 10 | 11 | You can add comments by starting the line with `//`. -------------------------------------------------------------------------------- /docs/INSTALL.md: -------------------------------------------------------------------------------- 1 | # Requirements 2 | 3 | - Sourcemod 1.12 or better 4 | - Metamod: Source 1.12 or better 5 | 6 | # Downloading 7 | 8 | ## Development Builds 9 | 10 | The latest dev builds of NavBot are available as workflow artifacts. Check the [Actions] page. 11 | 12 | Sometimes dev builds are pushed as pre-releases. Check the [Releases] page for the latest pre-release. 13 | 14 | ## Stable Builds 15 | 16 | NavBot is currently in development and does not have stable releases. 17 | 18 | They will be available on the [Releases] in the future. 19 | 20 | # Installing 21 | 22 | Copy the extension files (extension, plugins, gamedata, translations and config) files into `addons/sourcemod/`. 23 | 24 | 25 | 26 | 27 | [Actions]: https://github.com/caxanga334/NavBot/actions 28 | [Releases]: https://github.com/caxanga334/NavBot/releases -------------------------------------------------------------------------------- /docs/MOD_SETTINGS.md: -------------------------------------------------------------------------------- 1 | # NavBot Mod Settings File 2 | 3 | Mod settings are loaded from `navbot/**GAME FOLDER**/configs/settings.cfg`. 4 | 5 | These are a collection of shared and mod specific settings used by the extension. 6 | 7 | ## File Format 8 | 9 | ``` 10 | ModSettings 11 | { 12 | "settings1_key" "settings1_value" 13 | "settings2_key" "settings2_value" 14 | "settings3_key" "settings3_value" 15 | ... 16 | "settingsN_key" "settingsN_value" 17 | } 18 | ``` 19 | 20 | ## Base Settings 21 | 22 | These settings are used by all mods. 23 | 24 | | Key | Description | Range | Default | 25 | |:---:|:---:|:---:|:---:| 26 | | update_rate | How frequently in seconds the bot internal state is updated. Lower values improves the bot responsiveness, higher values will decrease CPU usage. | 0.0 - 0.5 | 0.1 | 27 | | vision_npc_update_rate | How frequently in seconds the bot will scan for visible non player entities. Lower values improves the bot responsiveness to detecting NPC entities, higher values will decreate CPU usage. This value is capped by the primary `update_rate` value. | 0.0 - 2.0 | 0.250 | 28 | | vision_statistics_update | How frequently to update the number of visible enemies and allies. | 0.05 - 2.0 | 0.5 | 29 | | inventory_update_rate | How frequently in seconds the bot will update the weapon inventory. Lower values allows the bots to detect new weapons faster, higher values will decrease CPU usage. | 0.1 - 60.0 | 1.0 | 30 | | defend_rate | Used by bots to determine if they should defend or attack. | 0 - 100 | 33 | 31 | | stuck_suicide_threshold | If a bot gets this many stuck events on a roll, they will use the kill command. | 5 - 60 | 15 | 32 | | collect_item_max_distance | Maximum travel distance when collecting items (health, armor, weapons, ammo, ...) | 2048 - 16384 | 5000 | -------------------------------------------------------------------------------- /docs/QAA.md: -------------------------------------------------------------------------------- 1 | # Questions & Answers 2 | 3 | ## Why are the bots not moving? 4 | 5 | The primary cause for bots not moving is a lack of a navigation mesh for the current map. 6 | 7 | Run the following command: `sm_navbot_info` 8 | 9 | Check the console for the output, if it says that the Nav Mesh is `NOT Loaded` then the current map lacks one. 10 | 11 | The secondary cause is lack of support for the current mod or game mode. 12 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # NavBot Documentation 2 | 3 | Welcome to the NavBot extension documentation index. 4 | 5 | ## Docs 6 | 7 | - [Installing NavBot] 8 | - [For Developers] 9 | - [Bot Difficulty Configuration] 10 | - [Bot Names Configuration] 11 | - [Questions and Answers] 12 | - [Navigation Mesh Documentation] 13 | - [Weapon Info Config File] 14 | - [NavBot ConVars] 15 | 16 | 17 | [Installing NavBot]: INSTALL.md 18 | [Using NavBot]: USAGE.md 19 | [For Developers]: developers/README.md 20 | [Questions and Answers]: QAA.md 21 | [Bot Names Configuration]: BOT_NAMES.md 22 | [Bot Difficulty Configuration]: BOT_DIFFICULTY_PROFILES.md 23 | [Navigation Mesh Documentation]: navmesh/README.md 24 | [Weapon Info Config File]: WEAPONINFO_CONFIG.md 25 | [NavBot ConVars]: CONVARS.md -------------------------------------------------------------------------------- /docs/USAGE.md: -------------------------------------------------------------------------------- 1 | # Basic Usage 2 | 3 | The bot's difficulty can be selected with `sm_navbot_skill_level`. 4 | The bot comes with four difficulty presets by default: Easy, Normal, Hard and Expert. 5 | The default difficulty used is **Easy**. 6 | For more information, see [Bot Difficulty Configuration]. 7 | 8 | ## Adding Bots 9 | 10 | You can add a single bots with the `sm_navbot_add` command. The bot stays in-game until a level change. 11 | 12 | If you wants bots to join automatically, you can enabled the bot quota system. 13 | First you need to select which mode you want: Normal or Fill. 14 | On **normal** mode, an N number of bots is added to the game. 15 | On **fill** mode, NavBot will keep an N number of players in-game, adding and removing bots as human players joins and leaves the game. 16 | The mode is set via the `sm_navbot_quota_mode` ConVar. 17 | Either `sm_navbot_quota_mode normal` or `sm_navbot_quota_mode fill`. 18 | The target number of bots is set by `sm_navbot_quota_quantity`. Set this ConVar to **0** to disabled the bot quota system. 19 | 20 | 21 | 22 | [Bot Difficulty Configuration]: BOT_DIFFICULTY_PROFILES.md 23 | -------------------------------------------------------------------------------- /docs/developers/README.md: -------------------------------------------------------------------------------- 1 | # NavBot Developer Documention 2 | 3 | * [Extension Development (C++)] 4 | * [Plugin Development (SourcePawn)] 5 | 6 | 7 | 8 | [Extension Development (C++)]: extension/README.md 9 | [Plugin Development (SourcePawn)]: sourcepawn/README.md -------------------------------------------------------------------------------- /docs/developers/extension/README.md: -------------------------------------------------------------------------------- 1 | # Nav Bot Developer Documentation 2 | 3 | ## Compiling 4 | 5 | See [Compiling](COMPILING.md). 6 | 7 | ## Adding Support To a New Mod 8 | 9 | See [Adding support to a new mod](NEW-MOD.md). 10 | 11 | ## Creating Your New Bot 12 | 13 | See [Creating Bots](CREATING-BOTS.md). 14 | 15 | ## Setting Up A Visual Studio Solution 16 | 17 | See [Generating a Visual Studio Solution](VS_PROJECT.md). -------------------------------------------------------------------------------- /docs/developers/extension/VS_PROJECT.md: -------------------------------------------------------------------------------- 1 | # Visual Studio Solution Generation 2 | 3 | VS Solutions are generated with [Premake5](https://premake.github.io/). 4 | 5 | ## Generating The Solution 6 | 7 | Open the cloned NavBot folder (where `premake5.lua` is). 8 | 9 | Use the following command to generate a solution: `premake5.exe --hl2sdk-root="PATH" --mms-path="PATH" --sm-path="PATH" vs2022` 10 | 11 | You need to replace `"PATH"` with the actual paths to MMS, SM and HL2SDK root. 12 | 13 | Only Visual Studio 2022 is supported! -------------------------------------------------------------------------------- /docs/developers/sourcepawn/FORWARDS.md: -------------------------------------------------------------------------------- 1 | # NavBot Global Forwards 2 | 3 | ## On Bot Add 4 | 5 | `Action OnPreNavBotAdd()` is called when a bot is about to be added to the game. 6 | 7 | Returning anything higher than `Plugin_Continue` will block the bot from being added to the game. 8 | 9 | `void OnNavBotAdded(int bot)` is called after a bot has been added to the game. 10 | 11 | * `int bot`: Client index of the bot that was just added. 12 | 13 | ## On Create Plugin Bot 14 | 15 | `Action OnPrePluginBotAdd(int entity)` is called when a plugin has requested to attach a NavBot Plugin Bot instance on the given entity. 16 | 17 | Returning anything higher than `Plugin_Continue` will block the plugin bot from being created. 18 | 19 | * `int entity`: Client index that the plugin bot will attach to. 20 | 21 | `void OnPluginBotAdded(int entity)` is called after a plugin bot was created. 22 | 23 | * `int entity`: Client index that the plugin bot will attach to. -------------------------------------------------------------------------------- /docs/developers/sourcepawn/NATIVES.md: -------------------------------------------------------------------------------- 1 | # SourceMod Plugin Natives 2 | 3 | Documention for using NavBot's SourcePawn API. 4 | 5 | All functions are documented on the SourcePawn [include files]. 6 | 7 | ## Checking for NavBots 8 | 9 | Use `bool IsNavBot(int client)`. 10 | 11 | It will return true if there is a NavBot instance attached to the given client index. 12 | 13 | This returns true for all types of NavBots. 14 | 15 | ## Adding NavBots 16 | 17 | To add NavBots to the game, plugins can call the `bool AddNavBot(int& client, const char[] botName = NULL_STRING)` function. 18 | 19 | This will automatically create a new fake client and attach a NavBot instance to it. 20 | 21 | This function returns true when the bot was successfully created. Returns false on failure. 22 | 23 | * `int& client`: Client index of the bot that was just added (passed by reference). 24 | * `const char[] botName`: Optional, if set to `NULL_STRING`, NavBot will automatically choose a random name from it's list, otherwise it will use the name specified here. 25 | 26 | This native adds the game/mod bot implementation. To create a plugin bot, see the [Plugin Bots] documentation. 27 | 28 | ## Removing NavBots 29 | 30 | There is nothing special needed to remove NavBots. Just kick them from the game. 31 | 32 | ## Nav Mesh Status 33 | 34 | NavBot will thrown errors if trying to create a bot without having a nav mesh loaded. 35 | 36 | Use `bool IsNavMeshLoaded()` to check if a nav mesh is loaded for the current map. 37 | 38 | 39 | 40 | [include files]: https://github.com/caxanga334/NavBot/tree/main/scripting/include 41 | [Plugin Bots]: PLUGIN_BOTS.md -------------------------------------------------------------------------------- /docs/developers/sourcepawn/README.md: -------------------------------------------------------------------------------- 1 | # SourcePawn API 2 | 3 | * [Natives] 4 | * [Forwards] 5 | * [Plugin Bot] 6 | 7 | 8 | 9 | [Natives]: NATIVES.md 10 | [Forwards]: FORWARDS.md 11 | [Plugin Bot]: PLUGIN_BOTS.md -------------------------------------------------------------------------------- /docs/navmesh/NAVMESH_AUTHOR_INFO.md: -------------------------------------------------------------------------------- 1 | # Authors and Editors 2 | 3 | NavBot nav meshes stores information about who created and edited them. The name and SteamID64 are saved. 4 | 5 | The command `sm_nav_list_editors` will print the author and editors to the console. 6 | 7 | The first person to edit the nav mesh will be saved as the author, any other person who edit it will be saved as an editor. 8 | -------------------------------------------------------------------------------- /docs/navmesh/NAVMESH_EDITING_TIPS.md: -------------------------------------------------------------------------------- 1 | # `sm_nav_slope_limit` and Stairs 2 | 3 | On some stairs that level designers did not add an invisible slope to smooth player movement, the navigation mesh generation sometimes partially skips the stairs or doesn't fully connect it. 4 | 5 | Using `sm_nav_slope_limit 0.48` generally improves the mesh generation on these stairs. 6 | 7 | This hint is not exclusive to NavBot and helps a lot when making nav meshes for Garry's mod since a lot of level designers never heard of stair clipping. 8 | 9 | # Finding Entities Indexes 10 | 11 | With `sv_cheats 1` and `developer 1`, you can use `ent_text` command to get the entity index. 12 | 13 | This will show debug information about the entity you're aiming at. You can also pass a targetname or classname as the first parameter. 14 | 15 | # Disconnect Multiple Drop Down Areas 16 | 17 | You can disconnect multiple drop down areas with the `sm_nav_disconnect_dropdown_areas ` command. 18 | 19 | Add the areas you want to disconnect to the selected set, then run the command. Any nav areas with a height difference between them larger than the given limit will be disconnected. 20 | 21 | # Adjust Area Corner To Player's Z 22 | 23 | The command `sm_nav_corner_place_at_feet (adjust nearby)` can be used to adjust the vertical position of the currently select area corner. 24 | The command has one optional boolean parameter that determines if the vertical position of nearby areas should also be adjusted. 25 | 26 | # Testing Path Finding Without Bots 27 | 28 | The command `sm_navbot_tool_build_path ` can be used to build the shortest path to a given area. 29 | Use `sm_nav_mark` to mark the path **goal** area. The nearest area to you is used as the path start area. 30 | The command has one argument, the name of the path cost preset you want to use. 31 | -------------------------------------------------------------------------------- /docs/navmesh/NAVMESH_PLACES.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Nav Places 4 | 5 | Places allow nav areas to be given a region name, AKA callouts. 6 | 7 | It allows bots to communicate positions to human teammates. 8 | 9 | # Database Files 10 | 11 | NavBot's Navigation Mesh has three files to load place names from. 12 | 13 | * A global file. 14 | * A mod specific file. 15 | * A map specific file. 16 | 17 | # Creating Map Specific Place Database 18 | 19 | Create a new text file at `data/navbot/[mod]/[map]_places.cfg`. 20 | 21 | `[mod]` is the current mod gamefolder name. 22 | 23 | `[map]` is the current map name report by the command `sm_nav_print_map_name`. 24 | 25 | The file needs to follow this format: 26 | 27 | ``` 28 | NavPlaces 29 | { 30 | "PlaceKey1" "PlaceHumanReadableName1" 31 | "PlaceKey2" "PlaceHumanReadableName2" 32 | ... 33 | "PlaceKeyN" "PlaceHumanReadableNameN" 34 | } 35 | ``` 36 | 37 | `PlaceKeyN` is the place key name, this is the internal place name, used by the `sm_nav_use_place` command. 38 | 39 | `PlaceHumanReadableNameN` is the human readable name that bots will use when sending chat messages. 40 | 41 | -------------------------------------------------------------------------------- /docs/navmesh/NAVMESH_SCRIPTING.md: -------------------------------------------------------------------------------- 1 | # Toggle Condition 2 | 3 | Toggle conditions is a scripting features that allows certain nav mesh features to be togggled on/off when certain conditions are met. 4 | 5 | Toggle conditions are currently used by nav volumes and prerequisites. 6 | 7 | ## Condition Data 8 | 9 | Toggle conditions have four data types: 10 | 11 | * Integet 12 | * Floating point 13 | * Vector 14 | * Entity 15 | 16 | # Toggle Condition Types 17 | 18 | ## TYPE_NOT_SET 19 | 20 | No condition type set. Always returns true. 21 | 22 | ## TYPE_ENTITY_EXISTS 23 | 24 | Checks if the linked entity exists on the world. 25 | 26 | ## TYPE_ENTITY_ALIVE 27 | 28 | Checks if the linked entity is alive. 29 | 30 | ## TYPE_ENTITY_ENABLED 31 | 32 | Checks if the linked entity is enabled. Not compatible with every entity. 33 | 34 | ## TYPE_ENTITY_LOCKED 35 | 36 | Checks if the linked entity is locked. Not compatible with every entity. 37 | 38 | ## TYPE_ENTITY_TEAM 39 | 40 | Checks if the linked entity assigned team index is equal to the stored integer data. 41 | 42 | ## TYPE_ENTITY_TOGGLE_STATE 43 | 44 | Checks if the linked entity toggle state is equal to the stored integer data. 45 | 46 | Toggle state is used by doors to determine if they're open or closed. 47 | 48 | ## TYPE_ENTITY_DISTANCE 49 | 50 | Checks the distance between the linked entity world space center and the stored vector data is less than the stored float data. 51 | 52 | ## TYPE_ENTITY_VISIBLE 53 | 54 | Checks if the linked entity is visible or not by checking if the `EF_NODRAW` flag is set. 55 | 56 | ## TYPE_TRACEHULL_SOLIDWORLD 57 | 58 | Peforms a trace hull and check for colisions with the world. 59 | 60 | Vector data sets the hull origin, float data sets the hull size. -------------------------------------------------------------------------------- /docs/navmesh/NAVMESH_VOLUMES.md: -------------------------------------------------------------------------------- 1 | # Nav Volumes 2 | 3 | Nav Volumes controls a Nav Area blocked status. 4 | 5 | To edit volumes, set the ConVar `sm_nav_volume_edit` to **1**. 6 | 7 | ## Creating a New Volume 8 | 9 | The command `sm_nav_volume_create` will create a new nav volume at your current position. 10 | 11 | ## Selecting a Volume 12 | 13 | In order to make changes to a volume, you need to select it first. 14 | 15 | Use the command `sm_nav_volume_select` while aiming at a volume to select it. 16 | 17 | Alternatively you can select a specific volume by ID with `sm_nav_volume_select `. 18 | 19 | ## Clearing Selection 20 | 21 | Use `sm_nav_volume_select clear` or `sm_nav_volume_deselect` to clear the selected volume. 22 | 23 | ## Deleting a Volume 24 | 25 | Use the command `sm_nav_volume_delete` to delete the selected volume. 26 | 27 | ## Show Areas in Control 28 | 29 | To view which nav areas are being controlled by the selected volume, use the command `sm_nav_volume_draw_areas`. 30 | 31 | ## Editing The Origin 32 | 33 | To move the selected volume to a new position, use the command `sm_nav_volume_set_origin`. 34 | 35 | The volume will be moved to your current position. 36 | 37 | ## Editing Bounds 38 | 39 | To change the volume size, use the command `sm_nav_volume_set_bounds `. 40 | 41 | ## Assigning a Team 42 | 43 | Volumes can be assigned to a specific team with `sm_nav_volume_set_team `. 44 | 45 | Use `-2` to make the volume neutral. 46 | 47 | ## Volume Toggle Condition 48 | 49 | The volume's toggle condition can be updated using `sm_nav_volume_set_toggle_condition`. 50 | 51 | ## Visualize The Target Entity 52 | 53 | The command `sm_nav_volume_show_target_entity` will show where the target entity is for ten seconds. 54 | 55 | ## Conflicts 56 | 57 | Nav Areas can only be controlled by one volume. Use the command `sm_nav_volume_check_for_conflicts` to check for conflicts. 58 | -------------------------------------------------------------------------------- /docs/navmesh/README.md: -------------------------------------------------------------------------------- 1 | # Navigation Mesh Documentation 2 | 3 | ## Basics 4 | 5 | - [Nav Mesh Editing Basics] 6 | - [Nav Mesh Editing Tips] 7 | - [Waypoint Editing Basics] 8 | - [Nav Mesh Authors and Editors] 9 | 10 | 11 | ## Advanced 12 | 13 | - [Nav Mesh Off-Mesh Link Connections] 14 | - [Nav Mesh Elevators] 15 | - [Nav Mesh Prerequisites] 16 | - [Nav Mesh Volumes] 17 | - [Nav Mesh Places] 18 | - [Nav Mesh Scripting] 19 | 20 | ## Game Specific 21 | 22 | - [Team Fortress 2 Nav Mesh Editing] 23 | 24 | 25 | [Nav Mesh Editing Basics]: NAVMESH_BASIC_EDITING.md 26 | [Waypoint Editing Basics]: WAYPOINT_BASICS.md 27 | [Nav Mesh Places]: NAVMESH_PLACES.md 28 | [Nav Mesh Off-Mesh Link Connections]: NAVMESH_OFFMESHLINKS.md 29 | [Nav Mesh Editing Tips]: NAVMESH_EDITING_TIPS.md 30 | [Nav Mesh Volumes]: NAVMESH_VOLUMES.md 31 | [Nav Mesh Elevators]: NAVMESH_ELEVATORS.md 32 | [Nav Mesh Prerequisites]: NAVMESH_PREREQUISITES.md 33 | [Nav Mesh Scripting]: NAVMESH_SCRIPTING.md 34 | [Nav Mesh Authors and Editors]: NAVMESH_AUTHOR_INFO.md 35 | [Team Fortress 2 Nav Mesh Editing]: TF2_EDITING.md -------------------------------------------------------------------------------- /extension/bot/basebot_behavior.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BASEBOT_BEHAVIOR_H_ 2 | #define NAVBOT_BASEBOT_BEHAVIOR_H_ 3 | 4 | #include 5 | #include 6 | 7 | class CBaseBot; 8 | 9 | class CBaseBotBehavior : public IBehavior 10 | { 11 | public: 12 | CBaseBotBehavior(CBaseBot* bot); 13 | ~CBaseBotBehavior() override; 14 | 15 | void Reset() override; 16 | void Update() override; 17 | 18 | IDecisionQuery* GetDecisionQueryResponder() override { return m_manager.get(); } 19 | std::vector* GetListenerVector() override; 20 | 21 | private: 22 | std::unique_ptr> m_manager; 23 | std::vector m_listeners; 24 | }; 25 | 26 | #endif // !NAVBOT_BASEBOT_BEHAVIOR_H_ 27 | -------------------------------------------------------------------------------- /extension/bot/basebot_pathcost.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BASE_BOT_PATH_COST_H_ 2 | #define NAVBOT_BASE_BOT_PATH_COST_H_ 3 | 4 | #include "basebot.h" 5 | #include "interfaces/path/basepath.h" 6 | 7 | class CBaseBotPathCost : public IPathCost 8 | { 9 | public: 10 | CBaseBotPathCost(CBaseBot* bot); 11 | 12 | float operator()(CNavArea* toArea, CNavArea* fromArea, const CNavLadder* ladder, const NavOffMeshConnection* link, const CNavElevator* elevator, float length) const override; 13 | 14 | void SetRouteType(RouteType type) override; 15 | private: 16 | CBaseBot* m_me; 17 | float m_stepheight; 18 | float m_maxjumpheight; 19 | float m_maxdropheight; 20 | float m_maxgapjumpdistance; 21 | float m_maxdjheight; 22 | bool m_candoublejump; 23 | bool m_canblastjump; 24 | }; 25 | 26 | #endif // !NAVBOT_BASE_BOT_PATH_COST_H_ 27 | -------------------------------------------------------------------------------- /extension/bot/blackmesa/bmbot_behavior.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "bmbot.h" 3 | #include "bmbot_behavior.h" 4 | #include 5 | 6 | CBlackMesaBotBehavior::CBlackMesaBotBehavior(CBaseBot* bot) : 7 | IBehavior(bot) 8 | { 9 | m_manager = std::make_unique>(new CBlackMesaBotMainTask); 10 | m_listeners.reserve(2); 11 | } 12 | 13 | CBlackMesaBotBehavior::~CBlackMesaBotBehavior() 14 | { 15 | } 16 | 17 | void CBlackMesaBotBehavior::Reset() 18 | { 19 | m_manager = std::make_unique>(new CBlackMesaBotMainTask); 20 | m_listeners.clear(); 21 | } 22 | 23 | void CBlackMesaBotBehavior::Update() 24 | { 25 | m_manager->Update(GetBot()); 26 | } 27 | 28 | std::vector* CBlackMesaBotBehavior::GetListenerVector() 29 | { 30 | if (!m_manager) 31 | { 32 | return nullptr; 33 | } 34 | 35 | m_listeners.clear(); 36 | m_listeners.push_back(m_manager.get()); 37 | 38 | return &m_listeners; 39 | } 40 | 41 | IDecisionQuery* CBlackMesaBotBehavior::GetDecisionQueryResponder() 42 | { 43 | return m_manager.get(); 44 | } 45 | -------------------------------------------------------------------------------- /extension/bot/blackmesa/bmbot_behavior.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BLACK_MESA_BOT_BEHAVIOR_H_ 2 | #define NAVBOT_BLACK_MESA_BOT_BEHAVIOR_H_ 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | class CBlackMesaBot; 11 | 12 | class CBlackMesaBotBehavior : public IBehavior 13 | { 14 | public: 15 | CBlackMesaBotBehavior(CBaseBot* bot); 16 | ~CBlackMesaBotBehavior() override; 17 | 18 | void Reset() override; 19 | void Update() override; 20 | 21 | std::vector* GetListenerVector() override; 22 | IDecisionQuery* GetDecisionQueryResponder() override; 23 | private: 24 | std::unique_ptr> m_manager; 25 | std::vector m_listeners; 26 | }; 27 | 28 | #endif // !NAVBOT_BLACK_MESA_BOT_BEHAVIOR_H_ -------------------------------------------------------------------------------- /extension/bot/blackmesa/bmbot_inventory.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BLACK_MESA_BOT_INVENTORY_INTERFACE_H_ 2 | #define NAVBOT_BLACK_MESA_BOT_INVENTORY_INTERFACE_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class CBlackMesaBot; 9 | 10 | class CBlackMesaBotInventory : public IInventory 11 | { 12 | public: 13 | CBlackMesaBotInventory(CBlackMesaBot* bot); 14 | ~CBlackMesaBotInventory() override; 15 | 16 | /** 17 | * @brief Checks if the bot owns this item weapon (item_weapon_*) 18 | * @param itemname Item weapon classname. 19 | * @return true if the bot owns the weapon. false otherwise. 20 | */ 21 | bool OwnsThisWeapon(const std::string& itemname); 22 | 23 | /** 24 | * @brief This function loops the bot current weapons and checks if they're low on ammo. 25 | * 26 | * Then it selects a random ammo type that's low. 27 | * @return Index of an ammo the bot is low on or invalid if the bot has enough ammo for every weapon. 28 | */ 29 | blackmesa::BMAmmoIndex SelectRandomNeededAmmo() const; 30 | }; 31 | 32 | #endif // !NAVBOT_BLACK_MESA_BOT_INVENTORY_INTERFACE_H_ 33 | -------------------------------------------------------------------------------- /extension/bot/blackmesa/bmbot_movement.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "bmbot.h" 3 | #include "bmbot_movement.h" 4 | 5 | CBlackMesaBotMovement::CBlackMesaBotMovement(CBaseBot* bot) : 6 | IMovement(bot) 7 | { 8 | } 9 | 10 | CBlackMesaBotMovement::~CBlackMesaBotMovement() 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /extension/bot/blackmesa/bmbot_movement.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BLACK_MESA_BOT_MOVEMENT_H_ 2 | #define NAVBOT_BLACK_MESA_BOT_MOVEMENT_H_ 3 | 4 | #include 5 | 6 | class CBlackMesaBot; 7 | 8 | 9 | class CBlackMesaBotMovement : public IMovement 10 | { 11 | public: 12 | CBlackMesaBotMovement(CBaseBot* bot); 13 | ~CBlackMesaBotMovement() override; 14 | 15 | }; 16 | 17 | #endif // !NAVBOT_BLACK_MESA_BOT_MOVEMENT_H_ 18 | -------------------------------------------------------------------------------- /extension/bot/blackmesa/bmbot_sensor.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BLACK_MESA_BOT_SENSOR_H_ 2 | #define NAVBOT_BLACK_MESA_BOT_SENSOR_H_ 3 | 4 | #include 5 | 6 | class CBlackMesaBot; 7 | 8 | 9 | class CBlackMesaBotSensor: public ISensor 10 | { 11 | public: 12 | CBlackMesaBotSensor(CBaseBot* bot); 13 | ~CBlackMesaBotSensor() override; 14 | 15 | bool IsIgnored(CBaseEntity* entity) override; 16 | bool IsFriendly(CBaseEntity* entity) override; 17 | bool IsEnemy(CBaseEntity* entity) override; 18 | 19 | protected: 20 | void CollectPlayers(std::vector& visibleVec) override; 21 | void CollectNonPlayerEntities(std::vector& visibleVec) override; 22 | }; 23 | 24 | #endif // !NAVBOT_BLACK_MESA_BOT_SENSOR_H_ 25 | -------------------------------------------------------------------------------- /extension/bot/blackmesa/tasks/bmbot_deploy_tripmines.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BLACK_MESA_BOT_DEPLOY_TRIPMINES_TASK_H_ 2 | #define NAVBOT_BLACK_MESA_BOT_DEPLOY_TRIPMINES_TASK_H_ 3 | 4 | class CBlackMesaBot; 5 | 6 | class CBlackMesaBotDeployTripminesTask : public AITask 7 | { 8 | public: 9 | CBlackMesaBotDeployTripminesTask(const Vector& pos); 10 | 11 | static bool IsPossible(CBlackMesaBot* bot, Vector& wallPos); 12 | 13 | TaskResult OnTaskStart(CBlackMesaBot* bot, AITask* pastTask) override; 14 | TaskResult OnTaskUpdate(CBlackMesaBot* bot) override; 15 | 16 | QueryAnswerType ShouldAttack(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_NO; } 17 | QueryAnswerType ShouldSwitchToWeapon(CBaseBot* me, const CBotWeapon* weapon) override { return ANSWER_NO; } 18 | 19 | const char* GetName() const override { return "DeployTripmines"; } 20 | private: 21 | Vector m_wallPosition; 22 | float m_timeout; 23 | }; 24 | 25 | 26 | #endif // !NAVBOT_BLACK_MESA_BOT_DEPLOY_TRIPMINES_TASK_H_ 27 | -------------------------------------------------------------------------------- /extension/bot/blackmesa/tasks/bmbot_find_ammo_task.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BLACK_MESA_BOT_FIND_AMMO_TASK_H_ 2 | #define NAVBOT_BLACK_MESA_BOT_FIND_AMMO_TASK_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class CBlackMesaBot; 10 | 11 | class CBlackMesaBotFindAmmoTask : public AITask 12 | { 13 | public: 14 | CBlackMesaBotFindAmmoTask(blackmesa::BMAmmoIndex ammoType); 15 | 16 | static bool IsPossible(CBlackMesaBot* bot, blackmesa::BMAmmoIndex& ammoInNeed); 17 | 18 | TaskResult OnTaskStart(CBlackMesaBot* bot, AITask* pastTask) override; 19 | TaskResult OnTaskUpdate(CBlackMesaBot* bot) override; 20 | 21 | const char* GetName() const override { return "FindAmmo"; } 22 | private: 23 | blackmesa::BMAmmoIndex m_ammoIndex; 24 | int m_maxCarry; 25 | std::string m_classname; 26 | CHandle m_item; 27 | CountdownTimer m_repathtimer; 28 | CMeshNavigator m_nav; 29 | Vector m_goal; 30 | 31 | void SetGoalEntity(CBaseEntity* goalEnt); 32 | static bool IsItemValid(CBaseEntity* item); 33 | static bool FindAmmoToPickup(CBlackMesaBot* bot, CBaseEntity** ammo, const std::string& classname, const float maxRange = 2048.0f, const bool selectNearest = false); 34 | }; 35 | 36 | #endif // !NAVBOT_BLACK_MESA_BOT_FIND_AMMO_TASK_H_ 37 | -------------------------------------------------------------------------------- /extension/bot/blackmesa/tasks/bmbot_find_armor_task.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BLACK_MESA_BOT_FIND_ARMOR_TASK_H_ 2 | #define NAVBOT_BLACK_MESA_BOT_FIND_ARMOR_TASK_H_ 3 | 4 | #include 5 | #include 6 | 7 | class CBlackMesaBot; 8 | 9 | class CBlackMesaBotFindArmorTask : public AITask 10 | { 11 | public: 12 | 13 | static bool IsPossible(CBlackMesaBot* bot); 14 | 15 | TaskResult OnTaskStart(CBlackMesaBot* bot, AITask* pastTask) override; 16 | TaskResult OnTaskUpdate(CBlackMesaBot* bot) override; 17 | 18 | TaskEventResponseResult OnMoveToSuccess(CBlackMesaBot* bot, CPath* path) override; 19 | 20 | const char* GetName() const override { return "FindArmor"; } 21 | private: 22 | CHandle m_armorSource; 23 | CountdownTimer m_timeout; 24 | CountdownTimer m_repathtimer; 25 | CMeshNavigator m_nav; 26 | Vector m_goal; 27 | bool m_isCharger; 28 | 29 | void SetArmorSource(CBaseEntity* source, CBlackMesaBot* bot); 30 | bool IsArmorSourceValid(); 31 | 32 | static bool FindArmorSource(CBlackMesaBot* bot, CBaseEntity** armorSource, const float maxRange = 2048.0f, const bool filterByDistance = false); 33 | }; 34 | 35 | #endif // !NAVBOT_BLACK_MESA_BOT_FIND_ARMOR_TASK_H_ 36 | -------------------------------------------------------------------------------- /extension/bot/blackmesa/tasks/bmbot_find_health_task.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BLACK_MESA_BOT_FIND_HEALTH_TASK_H_ 2 | #define NAVBOT_BLACK_MESA_BOT_FIND_HEALTH_TASK_H_ 3 | 4 | #include 5 | #include 6 | 7 | class CBlackMesaBot; 8 | 9 | class CBlackMesaBotFindHealthTask : public AITask 10 | { 11 | public: 12 | 13 | static bool IsPossible(CBlackMesaBot* bot); 14 | 15 | TaskResult OnTaskStart(CBlackMesaBot* bot, AITask* pastTask) override; 16 | TaskResult OnTaskUpdate(CBlackMesaBot* bot) override; 17 | 18 | TaskEventResponseResult OnMoveToSuccess(CBlackMesaBot* bot, CPath* path) override; 19 | 20 | const char* GetName() const override { return "FindHealth"; } 21 | private: 22 | CHandle m_healthSource; 23 | CountdownTimer m_timeout; 24 | CountdownTimer m_repathtimer; 25 | CMeshNavigator m_nav; 26 | Vector m_goal; 27 | bool m_isCharger; 28 | 29 | void SetHealthSource(CBaseEntity* source, CBlackMesaBot* bot); 30 | bool IsHealthSourceValid(); 31 | 32 | static bool FindHealthSource(CBlackMesaBot* bot, CBaseEntity** healthSource, const float maxRange = 2048.0f, const bool filterByDistance = false); 33 | }; 34 | 35 | #endif // !NAVBOT_BLACK_MESA_BOT_FIND_HEALTH_TASK_H_ 36 | -------------------------------------------------------------------------------- /extension/bot/blackmesa/tasks/bmbot_find_weapon_task.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BLACK_MESA_BOT_FIND_WEAPON_TASK_H_ 2 | #define NAVBOT_BLACK_MESA_BOT_FIND_WEAPON_TASK_H_ 3 | 4 | #include 5 | #include 6 | 7 | class CBlackMesaBot; 8 | 9 | class CBlackMesaBotFindWeaponTask : public AITask 10 | { 11 | public: 12 | 13 | static bool IsPossible(CBlackMesaBot* bot); 14 | 15 | TaskResult OnTaskStart(CBlackMesaBot* bot, AITask* pastTask) override; 16 | TaskResult OnTaskUpdate(CBlackMesaBot* bot) override; 17 | void OnTaskEnd(CBlackMesaBot* bot, AITask* nextTask) override; 18 | 19 | TaskEventResponseResult OnMoveToSuccess(CBlackMesaBot* bot, CPath* path) override; 20 | TaskEventResponseResult OnWeaponEquip(CBlackMesaBot* bot, CBaseEntity* weapon) override; 21 | 22 | const char* GetName() const override { return "FindWeapon"; } 23 | private: 24 | CHandle m_weapon; 25 | CountdownTimer m_repathtimer; 26 | CMeshNavigator m_nav; 27 | Vector m_goal; 28 | 29 | bool IsWeaponValid(); 30 | 31 | static bool FindWeaponToPickup(CBlackMesaBot* bot, CBaseEntity** weapon, const float maxRange = 4096.0f); 32 | }; 33 | 34 | #endif // !NAVBOT_BLACK_MESA_BOT_FIND_WEAPON_TASK_H_ 35 | -------------------------------------------------------------------------------- /extension/bot/blackmesa/tasks/bmbot_main_task.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BLACK_MESA_BOT_MAIN_TASK_H_ 2 | #define NAVBOT_BLACK_MESA_BOT_MAIN_TASK_H_ 3 | 4 | class CBlackMesaBot; 5 | 6 | class CBlackMesaBotMainTask : public AITask 7 | { 8 | public: 9 | CBlackMesaBotMainTask(); 10 | 11 | AITask* InitialNextTask(CBlackMesaBot* bot) override; 12 | TaskResult OnTaskUpdate(CBlackMesaBot* bot) override; 13 | 14 | TaskEventResponseResult OnDebugMoveToHostCommand(CBlackMesaBot* bot) override; 15 | 16 | Vector GetTargetAimPos(CBaseBot* me, CBaseEntity* entity, DesiredAimSpot desiredAim = AIMSPOT_NONE) override; 17 | const CKnownEntity* SelectTargetThreat(CBaseBot* me, const CKnownEntity* threat1, const CKnownEntity* threat2) override; 18 | 19 | const char* GetName() const override { return "MainTask"; } 20 | private: 21 | 22 | bool AimAtEnemyPlayer(CBaseExtPlayer& them, CBlackMesaBot* me, Vector& out, const CBotWeapon* weapon, DesiredAimSpot desiredAim, bool isSecondaryAttack); 23 | }; 24 | 25 | #endif // !NAVBOT_BLACK_MESA_BOT_MAIN_TASK_H_ 26 | -------------------------------------------------------------------------------- /extension/bot/blackmesa/tasks/bmbot_tactical_task.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BLACK_MESA_BOT_TACTICAL_TASK_H_ 2 | #define NAVBOT_BLACK_MESA_BOT_TACTICAL_TASK_H_ 3 | 4 | #include 5 | 6 | class CBlackMesaBot; 7 | 8 | class CBlackMesaBotTacticalTask : public AITask 9 | { 10 | public: 11 | AITask* InitialNextTask(CBlackMesaBot* bot) override; 12 | 13 | TaskResult OnTaskStart(CBlackMesaBot* bot, AITask* pastTask) override; 14 | TaskResult OnTaskUpdate(CBlackMesaBot* bot) override; 15 | TaskResult OnTaskResume(CBlackMesaBot* bot, AITask* pastTask) override; 16 | 17 | QueryAnswerType ShouldSeekAndDestroy(CBaseBot* me, const CKnownEntity* them) override; 18 | 19 | TaskEventResponseResult OnNavAreaChanged(CBlackMesaBot* bot, CNavArea* oldArea, CNavArea* newArea) override; 20 | 21 | const char* GetName() const override { return "TacticalMonitor"; } 22 | private: 23 | CountdownTimer m_healthScanTimer; 24 | CountdownTimer m_deployTripminesTimer; 25 | }; 26 | 27 | #endif // !NAVBOT_BLACK_MESA_BOT_TACTICAL_TASK_H_ 28 | -------------------------------------------------------------------------------- /extension/bot/blackmesa/tasks/scenario/bmbot_roam_task.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BLACK_MESA_BOT_ROAM_TASK_H_ 2 | #define NAVBOT_BLACK_MESA_BOT_ROAM_TASK_H_ 3 | 4 | #include 5 | #include 6 | 7 | class CBlackMesaBot; 8 | 9 | class CBlackMesaBotRoamTask : public AITask 10 | { 11 | public: 12 | 13 | TaskResult OnTaskStart(CBlackMesaBot* bot, AITask* pastTask) override; 14 | TaskResult OnTaskUpdate(CBlackMesaBot* bot) override; 15 | 16 | TaskEventResponseResult OnMoveToFailure(CBlackMesaBot* bot, CPath* path, IEventListener::MovementFailureType reason) override; 17 | TaskEventResponseResult OnMoveToSuccess(CBlackMesaBot* bot, CPath* path) override; 18 | 19 | const char* GetName() const override { return "Roam"; } 20 | private: 21 | CMeshNavigator m_nav; 22 | CountdownTimer m_repathTimer; 23 | Vector m_goal; 24 | int m_failCount; 25 | 26 | bool SelectRandomGoal(const Vector& start); 27 | }; 28 | 29 | 30 | #endif // !NAVBOT_BLACK_MESA_BOT_ROAM_TASK_H_ 31 | -------------------------------------------------------------------------------- /extension/bot/blackmesa/tasks/scenario/bmbot_scenario_deathmatch_task.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "bmbot_roam_task.h" 7 | #include "bmbot_scenario_deathmatch_task.h" 8 | 9 | TaskResult CBlackMesaBotScenarioDeathmatchTask::OnTaskUpdate(CBlackMesaBot* bot) 10 | { 11 | int randomNumber = CBaseBot::s_botrng.GetRandomInt(1, 10); 12 | 13 | // small random chance to ignore weapons 14 | if (randomNumber > 3 && CBlackMesaBotFindWeaponTask::IsPossible(bot)) 15 | { 16 | // if find weapon took less than 5 seconds, it probably failed. 17 | if (!m_searchWeaponTimer.HasStarted() || m_searchWeaponTimer.IsGreaterThen(5.0f)) 18 | { 19 | m_searchWeaponTimer.Start(); 20 | return PauseFor(new CBlackMesaBotFindWeaponTask, "Searching for new weapons!"); 21 | } 22 | } 23 | 24 | blackmesa::BMAmmoIndex ammoInNeed; 25 | 26 | if (CBlackMesaBotFindAmmoTask::IsPossible(bot, ammoInNeed)) 27 | { 28 | return PauseFor(new CBlackMesaBotFindAmmoTask(ammoInNeed), "Searching for ammo!"); 29 | } 30 | 31 | // small random chance to ignore armor 32 | if (randomNumber < 9 && CBlackMesaBotFindArmorTask::IsPossible(bot)) 33 | { 34 | if (!m_searchArmorTimer.HasStarted() || m_searchArmorTimer.IsGreaterThen(5.0f)) 35 | { 36 | return PauseFor(new CBlackMesaBotFindArmorTask, "Searching for armor!"); 37 | } 38 | } 39 | 40 | return PauseFor(new CBlackMesaBotRoamTask, "Roaming!"); 41 | } 42 | -------------------------------------------------------------------------------- /extension/bot/blackmesa/tasks/scenario/bmbot_scenario_deathmatch_task.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BLACK_MESA_BOT_SCENARIO_DEATHMATCH_TASK_H_ 2 | #define NAVBOT_BLACK_MESA_BOT_SCENARIO_DEATHMATCH_TASK_H_ 3 | 4 | #include 5 | 6 | class CBlackMesaBot; 7 | 8 | class CBlackMesaBotScenarioDeathmatchTask : public AITask 9 | { 10 | public: 11 | TaskResult OnTaskUpdate(CBlackMesaBot* bot) override; 12 | 13 | const char* GetName() const override { return "DeathmatchScenario"; } 14 | private: 15 | IntervalTimer m_searchWeaponTimer; 16 | IntervalTimer m_searchArmorTimer; 17 | 18 | }; 19 | 20 | #endif // !NAVBOT_BLACK_MESA_BOT_SCENARIO_DEATHMATCH_TASK_H_ 21 | -------------------------------------------------------------------------------- /extension/bot/bot_debug_shared.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BOT_DEBUG_SHARED_H_ 2 | #define NAVBOT_BOT_DEBUG_SHARED_H_ 3 | #pragma once 4 | 5 | enum BotDebugModes 6 | { 7 | BOTDEBUG_NONE = 0, 8 | BOTDEBUG_SENSOR = (1 << 0), // bot sensors, vision & hearing 9 | BOTDEBUG_TASKS = (1 << 1), 10 | BOTDEBUG_LOOK = (1 << 2), 11 | BOTDEBUG_PATH = (1 << 3), 12 | BOTDEBUG_EVENTS = (1 << 4), 13 | BOTDEBUG_MOVEMENT = (1 << 5), 14 | BOTDEBUG_ERRORS = (1 << 6), 15 | BOTDEBUG_SQUADS = (1 << 7), 16 | }; 17 | 18 | #endif // !NAVBOT_BOT_DEBUG_SHARED_H_ 19 | 20 | 21 | -------------------------------------------------------------------------------- /extension/bot/bot_shared_convars.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "bot_shared_convars.h" 3 | 4 | ConVar sm_navbot_bot_low_health_ratio("sm_navbot_bot_low_health_ratio", "0.6", FCVAR_GAMEDLL, "The bot is considered to be low on health if their health percentage is lower than this.", true, -2.0f, true, 1.0f); 5 | 6 | ConVar sm_navbot_bot_no_ammo_check("sm_navbot_bot_no_ammo_check", "0", FCVAR_GAMEDLL, "If enabled, bots will not check for ammo."); -------------------------------------------------------------------------------- /extension/bot/bot_shared_convars.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_BOT_SHARED_CONVARS_H_ 2 | #define __NAVBOT_BOT_SHARED_CONVARS_H_ 3 | 4 | extern ConVar sm_navbot_bot_low_health_ratio; 5 | extern ConVar sm_navbot_bot_no_ammo_check; 6 | 7 | 8 | #endif // !__NAVBOT_BOT_SHARED_CONVARS_H_ 9 | -------------------------------------------------------------------------------- /extension/bot/dods/dodsbot_behavior.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dodsbot.h" 3 | #include "dodsbot_behavior.h" 4 | #include "tasks/dodsbot_main_task.h" 5 | 6 | CDoDSBotBehavior::CDoDSBotBehavior(CBaseBot* bot) : 7 | IBehavior(bot) 8 | { 9 | m_manager = new AITaskManager(new CDoDSBotMainTask); 10 | m_listeners.reserve(2); 11 | } 12 | 13 | CDoDSBotBehavior::~CDoDSBotBehavior() 14 | { 15 | m_listeners.clear(); 16 | delete m_manager; 17 | m_manager = nullptr; 18 | } 19 | 20 | void CDoDSBotBehavior::Reset() 21 | { 22 | m_listeners.clear(); 23 | delete m_manager; 24 | m_manager = new AITaskManager(new CDoDSBotMainTask); 25 | } 26 | 27 | void CDoDSBotBehavior::Update() 28 | { 29 | m_manager->Update(GetBot()); 30 | } 31 | 32 | std::vector* CDoDSBotBehavior::GetListenerVector() 33 | { 34 | if (m_manager == nullptr) 35 | { 36 | return nullptr; 37 | } 38 | 39 | m_listeners.clear(); 40 | m_listeners.push_back(m_manager); 41 | 42 | return &m_listeners; 43 | } 44 | 45 | IDecisionQuery* CDoDSBotBehavior::GetDecisionQueryResponder() 46 | { 47 | return m_manager; 48 | } 49 | -------------------------------------------------------------------------------- /extension/bot/dods/dodsbot_behavior.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_DODSBOT_BEHAVIOR_H_ 2 | #define __NAVBOT_DODSBOT_BEHAVIOR_H_ 3 | 4 | #include 5 | 6 | class CDoDSBot; 7 | 8 | class CDoDSBotBehavior : public IBehavior 9 | { 10 | public: 11 | CDoDSBotBehavior(CBaseBot* bot); 12 | ~CDoDSBotBehavior() override; 13 | 14 | void Reset() override; 15 | void Update() override; 16 | 17 | std::vector* GetListenerVector() override; 18 | IDecisionQuery* GetDecisionQueryResponder() override; 19 | private: 20 | AITaskManager* m_manager; 21 | std::vector m_listeners; 22 | }; 23 | 24 | #endif // !__NAVBOT_DODSBOT_BEHAVIOR_H_ 25 | -------------------------------------------------------------------------------- /extension/bot/dods/dodsbot_inventory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dodsbot.h" 3 | #include "dodsbot_inventory.h" 4 | 5 | CDoDSBotInventory::CDoDSBotInventory(CBaseBot* bot) : 6 | IInventory(bot) 7 | { 8 | } 9 | 10 | CDoDSBotInventory::~CDoDSBotInventory() 11 | { 12 | } 13 | 14 | bool CDoDSBotInventory::HasBomb() const 15 | { 16 | bool found = false; 17 | auto func = [&found](const CBotWeapon* weapon) { 18 | if (strcmp(weapon->GetClassname().c_str(), "weapon_basebomb") == 0) 19 | { 20 | found = true; 21 | } 22 | }; 23 | 24 | this->ForEveryWeapon(func); 25 | 26 | return found; 27 | } 28 | -------------------------------------------------------------------------------- /extension/bot/dods/dodsbot_inventory.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_DODSBOT_INVENTORY_INTERFACE_H_ 2 | #define __NAVBOT_DODSBOT_INVENTORY_INTERFACE_H_ 3 | 4 | #include 5 | 6 | class CDoDSBotInventory : public IInventory 7 | { 8 | public: 9 | CDoDSBotInventory(CBaseBot* bot); 10 | ~CDoDSBotInventory() override; 11 | 12 | bool HasBomb() const; 13 | 14 | private: 15 | 16 | }; 17 | 18 | 19 | #endif // !__NAVBOT_DODSBOT_INVENTORY_INTERFACE_H_ 20 | -------------------------------------------------------------------------------- /extension/bot/dods/dodsbot_movement.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "dodsbot.h" 4 | #include "dodsbot_movement.h" 5 | 6 | CDoDSBotMovement::CDoDSBotMovement(CBaseBot* bot) : 7 | IMovement(bot) 8 | { 9 | } 10 | 11 | CDoDSBotMovement::~CDoDSBotMovement() 12 | { 13 | } 14 | 15 | float CDoDSBotMovement::GetCrouchedHullHeigh() 16 | { 17 | return dayofdefeatsource::DOD_PLAYER_CROUCHING_HEIGHT * GetBot()->GetModelScale(); 18 | } 19 | 20 | float CDoDSBotMovement::GetProneHullHeigh() 21 | { 22 | return dayofdefeatsource::DOD_PLAYER_PRONE_HEIGHT * GetBot()->GetModelScale(); 23 | } 24 | -------------------------------------------------------------------------------- /extension/bot/dods/dodsbot_movement.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_DODSBOT_MOVEMENT_INTERFACE_H_ 2 | #define __NAVBOT_DODSBOT_MOVEMENT_INTERFACE_H_ 3 | 4 | #include 5 | 6 | class CDoDSBotMovement : public IMovement 7 | { 8 | public: 9 | CDoDSBotMovement(CBaseBot* bot); 10 | ~CDoDSBotMovement() override; 11 | 12 | // float GetHullWidth() override; 13 | // float GetStandingHullHeigh() override; 14 | float GetCrouchedHullHeigh() override; 15 | float GetProneHullHeigh() override; 16 | // Maximum gap jump distance without sprinting 17 | float GetMaxGapJumpDistance() const override { return 160.0f; } 18 | // this is the distance bots can drop without taking fall damage 19 | float GetMaxDropHeight() const { return 200.0f; } 20 | 21 | private: 22 | 23 | }; 24 | 25 | #endif // !__NAVBOT_DODSBOT_MOVEMENT_INTERFACE_H_ 26 | -------------------------------------------------------------------------------- /extension/bot/dods/dodsbot_sensor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "dodsbot.h" 5 | #include "dodsbot_sensor.h" 6 | 7 | CDoDSBotSensor::CDoDSBotSensor(CBaseBot* bot) : 8 | ISensor(bot) 9 | { 10 | } 11 | 12 | CDoDSBotSensor::~CDoDSBotSensor() 13 | { 14 | } 15 | 16 | bool CDoDSBotSensor::IsIgnored(CBaseEntity* entity) 17 | { 18 | // ignore everything but player entities 19 | return !(UtilHelpers::IsPlayer(entity)); 20 | } 21 | 22 | bool CDoDSBotSensor::IsFriendly(CBaseEntity* entity) 23 | { 24 | CDoDSBot* me = GetBot(); 25 | 26 | return dodslib::GetDoDTeam(entity) == me->GetMyDoDTeam(); 27 | } 28 | 29 | bool CDoDSBotSensor::IsEnemy(CBaseEntity* entity) 30 | { 31 | CDoDSBot* me = GetBot(); 32 | 33 | return dodslib::GetDoDTeam(entity) != me->GetMyDoDTeam(); 34 | } 35 | 36 | bool CDoDSBotSensor::IsEntityHidden(CBaseEntity* entity) 37 | { 38 | // TO-DO: Implement smoke grenades vision blocking 39 | 40 | return false; 41 | } 42 | 43 | bool CDoDSBotSensor::IsPositionObscured(const Vector& pos) 44 | { 45 | return false; 46 | } 47 | 48 | void CDoDSBotSensor::CollectNonPlayerEntities(std::vector& visibleVec) 49 | { 50 | // DoD bots don't need to care about non players, saves perf 51 | } 52 | -------------------------------------------------------------------------------- /extension/bot/dods/dodsbot_sensor.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_DODSBOT_SENSOR_INTERFACE_H_ 2 | #define __NAVBOT_DODSBOT_SENSOR_INTERFACE_H_ 3 | 4 | #include 5 | 6 | class CDoDSBotSensor : public ISensor 7 | { 8 | public: 9 | CDoDSBotSensor(CBaseBot* bot); 10 | ~CDoDSBotSensor() override; 11 | 12 | bool IsIgnored(CBaseEntity* entity) override; 13 | bool IsFriendly(CBaseEntity* entity) override; 14 | bool IsEnemy(CBaseEntity* entity) override; 15 | 16 | bool IsEntityHidden(CBaseEntity* entity) override; 17 | bool IsPositionObscured(const Vector& pos) override; 18 | 19 | private: 20 | void CollectNonPlayerEntities(std::vector& visibleVec) override; 21 | }; 22 | 23 | #endif // !__NAVBOT_DODSBOT_SENSOR_INTERFACE_H_ 24 | -------------------------------------------------------------------------------- /extension/bot/dods/tasks/dodsbot_main_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_DODSBOT_MAIN_TASK_H_ 2 | #define __NAVBOT_DODSBOT_MAIN_TASK_H_ 3 | 4 | class CDoDSBotMainTask : public AITask 5 | { 6 | public: 7 | 8 | AITask* InitialNextTask(CDoDSBot* bot) override; 9 | 10 | TaskResult OnTaskUpdate(CDoDSBot* bot) override; 11 | 12 | TaskEventResponseResult OnDebugMoveToHostCommand(CDoDSBot* bot); 13 | 14 | Vector GetTargetAimPos(CBaseBot* me, CBaseEntity* entity, DesiredAimSpot desiredAim = AIMSPOT_NONE) override; 15 | const CKnownEntity* SelectTargetThreat(CBaseBot* me, const CKnownEntity* threat1, const CKnownEntity* threat2) override; 16 | 17 | const char* GetName() const override { return "MainTask"; } 18 | }; 19 | 20 | 21 | #endif // !__NAVBOT_DODSBOT_MAIN_TASK_H_ 22 | -------------------------------------------------------------------------------- /extension/bot/dods/tasks/dodsbot_scenario_monitor_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_DODSBOT_SCENARIO_MONITOR_TASK_H_ 2 | #define __NAVBOT_DODSBOT_SCENARIO_MONITOR_TASK_H_ 3 | 4 | class CDoDSBotScenarioMonitorTask : public AITask 5 | { 6 | public: 7 | AITask* InitialNextTask(CDoDSBot* bot) override; 8 | 9 | TaskResult OnTaskUpdate(CDoDSBot* bot) override; 10 | 11 | TaskEventResponseResult OnRoundStateChanged(CDoDSBot* bot) override; 12 | 13 | const char* GetName() const override { return "ScenarioMonitor"; } 14 | private: 15 | 16 | void FindControlPointToDefend(CDoDSBot* bot, CBaseEntity** defuse, const CDayOfDefeatSourceMod::DoDControlPoint** defend); 17 | }; 18 | 19 | #endif // !__NAVBOT_DODSBOT_SCENARIO_MONITOR_TASK_H_ 20 | -------------------------------------------------------------------------------- /extension/bot/dods/tasks/dodsbot_tactical_monitor_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_DODSBOT_TACTICAL_MONITOR_TASK_H_ 2 | #define __NAVBOT_DODSBOT_TACTICAL_MONITOR_TASK_H_ 3 | 4 | class CDoDSBotTacticalMonitorTask : public AITask 5 | { 6 | public: 7 | 8 | AITask* InitialNextTask(CDoDSBot* bot) override; 9 | 10 | TaskResult OnTaskUpdate(CDoDSBot* bot) override; 11 | 12 | TaskEventResponseResult OnNavAreaChanged(CDoDSBot* bot, CNavArea* oldArea, CNavArea* newArea) override; 13 | TaskEventResponseResult OnInjured(CDoDSBot* bot, const CTakeDamageInfo& info) override; 14 | 15 | const char* GetName() const override { return "TacticalMonitor"; } 16 | private: 17 | 18 | }; 19 | 20 | #endif // !__NAVBOT_DODSBOT_TACTICAL_MONITOR_TASK_H_ 21 | -------------------------------------------------------------------------------- /extension/bot/dods/tasks/scenario/dodsbot_attack_control_point_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_DODSBOT_ATTACK_CONTROL_POINT_TASK_H_ 2 | #define __NAVBOT_DODSBOT_ATTACK_CONTROL_POINT_TASK_H_ 3 | 4 | class CDoDSBotAttackControlPointTask : public AITask 5 | { 6 | public: 7 | CDoDSBotAttackControlPointTask(const CDayOfDefeatSourceMod::DoDControlPoint* controlpoint); 8 | 9 | static bool IsPossible(CDoDSBot* bot, const CDayOfDefeatSourceMod::DoDControlPoint** controlpoint); 10 | TaskResult OnTaskStart(CDoDSBot* bot, AITask* pastTask) override; 11 | TaskResult OnTaskUpdate(CDoDSBot* bot) override; 12 | 13 | const char* GetName() const override { return "AttackControlPoint"; } 14 | private: 15 | const CDayOfDefeatSourceMod::DoDControlPoint* m_controlpoint; 16 | CMeshNavigator m_nav; 17 | CountdownTimer m_repathtimer; 18 | }; 19 | 20 | #endif // !__NAVBOT_DODSBOT_ATTACK_CONTROL_POINT_TASK_H_ 21 | -------------------------------------------------------------------------------- /extension/bot/dods/tasks/scenario/dodsbot_defuse_bomb_task.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "dodsbot_defuse_bomb_task.h" 11 | 12 | CDoDSBotDefuseBombTask::CDoDSBotDefuseBombTask(CBaseEntity* target) : 13 | m_target(target) 14 | { 15 | } 16 | 17 | TaskResult CDoDSBotDefuseBombTask::OnTaskStart(CDoDSBot* bot, AITask* pastTask) 18 | { 19 | return Continue(); 20 | } 21 | 22 | TaskResult CDoDSBotDefuseBombTask::OnTaskUpdate(CDoDSBot* bot) 23 | { 24 | CBaseEntity* target = m_target.Get(); 25 | 26 | if (!target) 27 | { 28 | return Done("Bomb target is NULL!"); 29 | } 30 | 31 | int state = 0; 32 | entprops->GetEntProp(m_target.GetEntryIndex(), Prop_Send, "m_iState", state); 33 | 34 | if (state != static_cast(dayofdefeatsource::DoDBombTargetState::BOMB_TARGET_ARMED)) 35 | { 36 | return Done("Bomb has been defused or exploded!"); 37 | } 38 | 39 | Vector eyePos = bot->GetEyeOrigin(); 40 | Vector center = UtilHelpers::getEntityOrigin(target); 41 | 42 | // In USE range of the bomb target 43 | if ((eyePos - center).Length() < CBaseExtPlayer::PLAYER_USE_RADIUS) 44 | { 45 | bot->GetControlInterface()->AimAt(center, IPlayerController::LOOK_CRITICAL, 0.5f, "Looking at bomb target to plant bomb!"); 46 | 47 | if (bot->IsLookingTowards(center, 0.84f)) 48 | { 49 | bot->GetControlInterface()->PressUseButton(); 50 | } 51 | } 52 | else 53 | { 54 | if (m_repathtimer.IsElapsed()) 55 | { 56 | m_repathtimer.Start(CBaseBot::s_botrng.GetRandomReal(1.0f, 2.1f)); 57 | CDoDSBotPathCost cost(bot); 58 | m_nav.ComputePathToPosition(bot, center, cost, 0.0f, true); 59 | } 60 | 61 | m_nav.Update(bot); 62 | } 63 | 64 | return Continue(); 65 | } 66 | -------------------------------------------------------------------------------- /extension/bot/dods/tasks/scenario/dodsbot_defuse_bomb_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_DODSBOT_DEFUSE_BOMB_TASK_H_ 2 | #define __NAVBOT_DODSBOT_DEFUSE_BOMB_TASK_H_ 3 | 4 | class CDoDSBotDefuseBombTask : public AITask 5 | { 6 | public: 7 | CDoDSBotDefuseBombTask(CBaseEntity* target); 8 | 9 | TaskResult OnTaskStart(CDoDSBot* bot, AITask* pastTask) override; 10 | TaskResult OnTaskUpdate(CDoDSBot* bot) override; 11 | 12 | const char* GetName() const override { return "DefuseBomb"; } 13 | private: 14 | CHandle m_target; 15 | CMeshNavigator m_nav; 16 | CountdownTimer m_repathtimer; 17 | }; 18 | 19 | 20 | #endif // !__NAVBOT_DODSBOT_DEFUSE_BOMB_TASK_H_ 21 | -------------------------------------------------------------------------------- /extension/bot/dods/tasks/scenario/dodsbot_deploy_bomb_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_DODSBOT_DEPLOY_BOMB_TASK_H_ 2 | #define __NAVBOT_DODSBOT_DEPLOY_BOMB_TASK_H_ 3 | 4 | class CDoDSBotDeployBombTask : public AITask 5 | { 6 | public: 7 | CDoDSBotDeployBombTask(CBaseEntity* target); 8 | 9 | TaskResult OnTaskStart(CDoDSBot* bot, AITask* pastTask) override; 10 | TaskResult OnTaskUpdate(CDoDSBot* bot) override; 11 | 12 | const char* GetName() const override { return "DeployBomb"; } 13 | private: 14 | CHandle m_target; 15 | CMeshNavigator m_nav; 16 | CountdownTimer m_repathtimer; 17 | }; 18 | 19 | 20 | #endif // !__NAVBOT_DODSBOT_DEPLOY_BOMB_TASK_H_ 21 | -------------------------------------------------------------------------------- /extension/bot/dods/tasks/scenario/dodsbot_fetch_bomb_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_DODSBOT_FETCH_BOMB_TASK_H_ 2 | #define __NAVBOT_DODSBOT_FETCH_BOMB_TASK_H_ 3 | 4 | class CDoDSBotFetchBombTask : public AITask 5 | { 6 | public: 7 | CDoDSBotFetchBombTask(AITask* exitTask = nullptr); 8 | ~CDoDSBotFetchBombTask() override; 9 | 10 | TaskResult OnTaskStart(CDoDSBot* bot, AITask* pastTask) override; 11 | TaskResult OnTaskUpdate(CDoDSBot* bot) override; 12 | 13 | TaskEventResponseResult OnMoveToSuccess(CDoDSBot* bot, CPath* path) override; 14 | 15 | const char* GetName() const override { return "FetchBomb"; } 16 | private: 17 | Vector m_goal; 18 | CMeshNavigator m_nav; 19 | CountdownTimer m_repathtimer; 20 | AITask* m_exittask; 21 | 22 | bool SelectNearestBombDispenser(CDoDSBot* bot); 23 | }; 24 | 25 | #endif // !__NAVBOT_DODSBOT_FETCH_BOMB_TASK_H_ 26 | -------------------------------------------------------------------------------- /extension/bot/hl2dm/hl2dmbot.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "hl2dmbot.h" 3 | 4 | CHL2DMBot::CHL2DMBot(edict_t* entity) : 5 | CBaseBot(entity) 6 | { 7 | } 8 | 9 | CHL2DMBot::~CHL2DMBot() 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /extension/bot/hl2dm/hl2dmbot.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_HL2DM_BOT_H_ 2 | #define NAVBOT_HL2DM_BOT_H_ 3 | 4 | #include 5 | 6 | class CHL2DMBot : public CBaseBot 7 | { 8 | public: 9 | CHL2DMBot(edict_t* entity); 10 | ~CHL2DMBot() override; 11 | 12 | float GetMaxSpeed() const override { return 390.0f; } // sprint speed, gamemovement should cap the speed for us. 13 | private: 14 | 15 | }; 16 | 17 | #endif // !NAVBOT_HL2DM_BOT_H_ 18 | -------------------------------------------------------------------------------- /extension/bot/interfaces/base_interface.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "base_interface.h" 4 | 5 | IBotInterface::IBotInterface(CBaseBot* bot) 6 | { 7 | m_bot = bot; 8 | 9 | bot->RegisterInterface(this); 10 | } -------------------------------------------------------------------------------- /extension/bot/interfaces/base_interface.h: -------------------------------------------------------------------------------- 1 | #ifndef SMNAV_BOT_BASE_INTERFACE_H_ 2 | #define SMNAV_BOT_BASE_INTERFACE_H_ 3 | #pragma once 4 | 5 | class CBaseBot; 6 | 7 | #include "event_listener.h" 8 | 9 | /** 10 | * @brief Base class for bot interfaces. A system that allows to expand the bot capabilities 11 | */ 12 | class IBotInterface : public IEventListener 13 | { 14 | public: 15 | IBotInterface(CBaseBot* bot); 16 | virtual ~IBotInterface(); 17 | 18 | template 19 | inline T* GetBot() const { return static_cast(m_bot); } 20 | 21 | virtual void OnDifficultyProfileChanged() {} 22 | 23 | // Reset the interface to it's initial state 24 | virtual void Reset() = 0; 25 | // Called at intervals 26 | virtual void Update() = 0; 27 | // Called every server frame 28 | virtual void Frame() = 0; 29 | 30 | private: 31 | CBaseBot* m_bot; // The bot that this interface belongs to 32 | }; 33 | 34 | inline IBotInterface::~IBotInterface() 35 | { 36 | } 37 | 38 | #endif // !SMNAV_BOT_BASE_INTERFACE_H_ 39 | -------------------------------------------------------------------------------- /extension/bot/interfaces/behavior.h: -------------------------------------------------------------------------------- 1 | #ifndef SMNAV_BOT_BEHAVIOR_H_ 2 | #define SMNAV_BOT_BEHAVIOR_H_ 3 | #pragma once 4 | 5 | #include "tasks.h" 6 | #include "base_interface.h" 7 | #include "decisionquery.h" 8 | 9 | // Interface responsible for the bot's behavior 10 | class IBehavior : public IBotInterface, public IDecisionQuery 11 | { 12 | public: 13 | IBehavior(CBaseBot* bot); 14 | ~IBehavior() override; 15 | 16 | // Reset the interface to it's initial state 17 | void Reset() override; 18 | // Called at intervals 19 | void Update() override; 20 | // Called every server frame 21 | void Frame() override; 22 | 23 | // Returns who will answer to decision queries 24 | virtual IDecisionQuery* GetDecisionQueryResponder() = 0; 25 | 26 | QueryAnswerType ShouldAttack(CBaseBot* me, const CKnownEntity* them) override; 27 | QueryAnswerType ShouldSeekAndDestroy(CBaseBot* me, const CKnownEntity* them) override; 28 | QueryAnswerType ShouldPickup(CBaseBot* me, edict_t* item) override; 29 | QueryAnswerType ShouldHurry(CBaseBot* me) override; 30 | QueryAnswerType ShouldRetreat(CBaseBot* me) override; 31 | QueryAnswerType IsIgnoringMapObjectives(CBaseBot* me) override; 32 | QueryAnswerType IsBlocker(CBaseBot* me, edict_t* blocker, const bool any = false) override; 33 | const CKnownEntity* SelectTargetThreat(CBaseBot* me, const CKnownEntity* threat1, const CKnownEntity* threat2) override; 34 | Vector GetTargetAimPos(CBaseBot* me, CBaseEntity* entity, DesiredAimSpot desiredAim = AIMSPOT_NONE) override; 35 | QueryAnswerType IsReady(CBaseBot* me) override; 36 | QueryAnswerType ShouldAssistTeammate(CBaseBot* me, CBaseEntity* teammate) override; 37 | QueryAnswerType ShouldSwitchToWeapon(CBaseBot* me, const CBotWeapon* weapon) override; 38 | 39 | private: 40 | 41 | }; 42 | 43 | #endif // !SMNAV_BOT_BEHAVIOR_H_ 44 | 45 | -------------------------------------------------------------------------------- /extension/bot/interfaces/path/basepath.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caxanga334/NavBot/c8c219aa9b2c84222480ff03004a46afa7d56390/extension/bot/interfaces/path/basepath.h -------------------------------------------------------------------------------- /extension/bot/interfaces/path/path_shareddefs.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_BOT_PATH_SHAREDDEFS_H_ 2 | #define __NAVBOT_BOT_PATH_SHAREDDEFS_H_ 3 | 4 | #include 5 | #include 6 | 7 | namespace AIPath 8 | { 9 | // Path segment type, tell bots how they should traverse the segment 10 | enum SegmentType 11 | { 12 | SEGMENT_GROUND = 0, // Walking over solid ground 13 | SEGMENT_DROP_FROM_LEDGE, // Dropping down from a ledge/cliff 14 | SEGMENT_CLIMB_UP, // Climbing over an obstacle 15 | SEGMENT_JUMP_OVER_GAP, // Jumping over a gap/hole on the ground 16 | SEGMENT_LADDER_UP, // Going up a ladder 17 | SEGMENT_LADDER_DOWN, // Going down a ladder 18 | SEGMENT_CLIMB_DOUBLE_JUMP, // Climbing over an obstacle that requires a double jump 19 | SEGMENT_BLAST_JUMP, // Blast/Rocket jump to the next segment 20 | SEGMENT_ELEVATOR,// Use an elevator 21 | SEGMENT_GRAPPLING_HOOK, // Use a grappling hook 22 | SEGMENT_CATAPULT, // Use a catapult 23 | 24 | MAX_SEGMENT_TYPES 25 | }; 26 | 27 | enum ResultType 28 | { 29 | COMPLETE_PATH = 0, // Full path from point A to B 30 | PARTIAL_PATH, // Partial path, doesn't reach the end goal 31 | NO_PATH // No path at all 32 | }; 33 | 34 | inline const char* SegmentTypeToString(SegmentType type) 35 | { 36 | using namespace std::literals::string_view_literals; 37 | 38 | constexpr std::array names = { 39 | "GROUND"sv, 40 | "DROP_FROM_LEDGE"sv, 41 | "CLIMB_UP"sv, 42 | "JUMP_OVER_GAP"sv, 43 | "LADDER_UP"sv, 44 | "LADDER_DOWN"sv, 45 | "CLIMB_DOUBLE_JUMP"sv, 46 | "BLAST_JUMP"sv, 47 | "ELEVATOR"sv, 48 | "GRAPPLING_HOOK"sv, 49 | "CATAPULT"sv, 50 | }; 51 | 52 | static_assert(names.size() == static_cast(SegmentType::MAX_SEGMENT_TYPES), "name array and SegmentType enum mismatch!"); 53 | 54 | return names[static_cast(type)].data(); 55 | } 56 | } 57 | 58 | #endif // !__NAVBOT_BOT_PATH_SHAREDDEFS_H_ 59 | -------------------------------------------------------------------------------- /extension/bot/interfaces/path/pluginnavigator.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_PLUGIN_NAVMESH_NAVIGATOR_H_ 2 | #define NAVBOT_PLUGIN_NAVMESH_NAVIGATOR_H_ 3 | 4 | #include "meshnavigator.h" 5 | 6 | class CPluginMeshNavigator : public CMeshNavigator 7 | { 8 | public: 9 | CPluginMeshNavigator(); 10 | ~CPluginMeshNavigator() override; 11 | 12 | void Update(CBaseBot* bot) override; 13 | 14 | const Vector& GetMoveGoal() const { return m_moveGoal; } 15 | 16 | private: 17 | Vector m_moveGoal; 18 | }; 19 | 20 | #endif // !NAVBOT_PLUGIN_NAVMESH_NAVIGATOR_H_ -------------------------------------------------------------------------------- /extension/bot/interfaces/sharedmemory.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_BOT_SHARED_MEMORY_INTERFACE_H_ 2 | #define __NAVBOT_BOT_SHARED_MEMORY_INTERFACE_H_ 3 | 4 | class CBaseEntity; 5 | class CBaseBot; 6 | class CNavArea; 7 | 8 | #include 9 | 10 | /** 11 | * @brief Interface for storing shared information between all bots. 12 | */ 13 | class ISharedBotMemory 14 | { 15 | public: 16 | ISharedBotMemory(); 17 | virtual ~ISharedBotMemory(); 18 | 19 | static constexpr auto ENTITY_INFO_EXPIRE_TIME = 60.0f; // Any entity information older than this is 'expired'. 20 | 21 | class EntityInfo 22 | { 23 | public: 24 | EntityInfo(CBaseEntity* pEntity); 25 | 26 | bool operator==(const EntityInfo& other); 27 | bool operator!=(const EntityInfo& other); 28 | 29 | bool IsObsolete(); 30 | 31 | void Update(); 32 | // Entity's last known position 33 | const Vector& GetLastKnownPosition() const { return m_lastknownposition; } 34 | // Entity's last known nav area 35 | const CNavArea* GetLastKnownNavArea() const { return m_lastknownarea; } 36 | // Time in seconds since this entity info instance was created. 37 | float GetTimeSinceCreation() const; 38 | // Time in seconds since this entity info instance was last updated. 39 | float GetTimeSinceLastUpdated() const; 40 | 41 | private: 42 | CHandle m_handle; 43 | Vector m_lastknownposition; 44 | CNavArea* m_lastknownarea; 45 | float m_timecreated; // time stamp when this entity info was created 46 | float m_timeupdated; // time stamp when this entity info was last updated 47 | }; 48 | 49 | virtual void Reset(); 50 | virtual void Update(); 51 | virtual void Frame(); 52 | virtual void OnRoundRestart(); 53 | 54 | protected: 55 | 56 | private: 57 | }; 58 | 59 | /** 60 | * @brief bsmu: Bot Shared Memory Utils. 61 | * 62 | * Namespace for utility function and classes for the bot shared memory interface 63 | */ 64 | namespace bsmu 65 | { 66 | 67 | } 68 | 69 | #endif // !__NAVBOT_BOT_SHARED_MEMORY_INTERFACE_H_ 70 | -------------------------------------------------------------------------------- /extension/bot/pluginbot/pluginbot.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pluginbot.h" 3 | 4 | CPluginBot::CPluginBot(edict_t* entity) : CBaseBot(entity) 5 | { 6 | m_pluginbehavior = std::make_unique(this); 7 | m_pluginmovement = std::make_unique(this); 8 | m_runplayercommands = false; 9 | } 10 | 11 | CPluginBot::~CPluginBot() 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /extension/bot/pluginbot/pluginbot.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_PLUGIN_BOT_H_ 2 | #define NAVBOT_PLUGIN_BOT_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "pluginbot_behavior.h" 9 | #include "pluginbot_movement.h" 10 | #include "pluginbot.h" 11 | 12 | struct edict_t; 13 | 14 | class CPluginBot : public CBaseBot 15 | { 16 | public: 17 | CPluginBot(edict_t* entity); 18 | ~CPluginBot() override; 19 | 20 | bool IsPluginBot() override final { return true; } 21 | bool RunPlayerCommands() override final { return m_runplayercommands; } 22 | 23 | CPluginBotMovement* GetMovementInterface() const override { return m_pluginmovement.get(); } 24 | CPluginBotBehavior* GetBehaviorInterface() const override { return m_pluginbehavior.get(); } 25 | 26 | void SetRunPlayerCommands(bool run) { m_runplayercommands = run; } 27 | 28 | private: 29 | std::unique_ptr m_pluginmovement; 30 | std::unique_ptr m_pluginbehavior; 31 | bool m_runplayercommands; 32 | }; 33 | 34 | #endif // !NAVBOT_PLUGIN_BOT_H_ 35 | -------------------------------------------------------------------------------- /extension/bot/pluginbot/pluginbot_behavior.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pluginbot.h" 3 | #include "pluginbot_behavior.h" 4 | 5 | class CPluginBotEmptyTask : public AITask 6 | { 7 | public: 8 | 9 | TaskResult OnTaskUpdate(CPluginBot* bot) override { return Continue(); } 10 | 11 | const char* GetName() const override { return "PluginBot"; } 12 | }; 13 | 14 | CPluginBotBehavior::CPluginBotBehavior(CBaseBot* bot) : IBehavior(bot) 15 | { 16 | m_manager = std::make_unique>(new CPluginBotEmptyTask); 17 | } 18 | 19 | CPluginBotBehavior::~CPluginBotBehavior() 20 | { 21 | } 22 | 23 | void CPluginBotBehavior::Reset() 24 | { 25 | m_listeners.clear(); 26 | m_manager = nullptr; 27 | m_manager = std::make_unique>(new CPluginBotEmptyTask); 28 | m_listeners.push_back(m_manager.get()); 29 | } 30 | 31 | void CPluginBotBehavior::Update() 32 | { 33 | m_manager->Update(static_cast(GetBot())); 34 | } 35 | 36 | std::vector* CPluginBotBehavior::GetListenerVector() 37 | { 38 | m_listeners.clear(); 39 | 40 | m_listeners.push_back(m_manager.get()); 41 | 42 | return &m_listeners; 43 | } 44 | 45 | IDecisionQuery* CPluginBotBehavior::GetDecisionQueryResponder() 46 | { 47 | return m_manager.get(); 48 | } 49 | -------------------------------------------------------------------------------- /extension/bot/pluginbot/pluginbot_behavior.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_PLUGIN_BOT_BEHAVIOR_H_ 2 | #define NAVBOT_PLUGIN_BOT_BEHAVIOR_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | class CPluginBot; 10 | 11 | class CPluginBotBehavior : public IBehavior 12 | { 13 | public: 14 | CPluginBotBehavior(CBaseBot* bot); 15 | ~CPluginBotBehavior() override; 16 | 17 | void Reset() override; 18 | void Update() override; 19 | 20 | std::vector* GetListenerVector() override; 21 | IDecisionQuery* GetDecisionQueryResponder() override; 22 | 23 | private: 24 | std::unique_ptr> m_manager; 25 | std::vector m_listeners; 26 | }; 27 | 28 | #endif // !NAVBOT_PLUGIN_BOT_BEHAVIOR_H_ 29 | -------------------------------------------------------------------------------- /extension/bot/pluginbot/pluginbot_movement.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pluginbot_movement.h" 3 | 4 | CPluginBotMovement::CPluginBotMovement(CBaseBot* bot) : IMovement(bot) 5 | { 6 | } 7 | 8 | CPluginBotMovement::~CPluginBotMovement() 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /extension/bot/pluginbot/pluginbot_movement.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_PLUGINBOT_MOVEMENT_INTERFACE_H_ 2 | #define NAVBOT_PLUGINBOT_MOVEMENT_INTERFACE_H_ 3 | 4 | #include 5 | 6 | // TO-DO: 7 | // - Implement plugin callbacks for the movement interface 8 | // - Allow plugins to override movement parameters (jump height, step height, etc...) 9 | 10 | class CPluginBot; 11 | 12 | class CPluginBotMovement : public IMovement 13 | { 14 | public: 15 | CPluginBotMovement(CBaseBot* bot); 16 | ~CPluginBotMovement() override; 17 | 18 | 19 | // let base handle these until the callbacks are implemented. 20 | //void Jump() override {} 21 | //void CrouchJump() override {} 22 | //void DoubleJump() override {} 23 | //void JumpAcrossGap(const Vector& landing, const Vector& forward) override {} 24 | //bool ClimbUpToLedge(const Vector& landingGoal, const Vector& landingForward, edict_t* obstacle) override { return false; } 25 | //void BlastJumpTo(const Vector& start, const Vector& landingGoal, const Vector& forward) override {} 26 | //bool DoubleJumpToLedge(const Vector& landingGoal, const Vector& landingForward, edict_t* obstacle) override { return false; } 27 | 28 | }; 29 | 30 | #endif // !NAVBOT_PLUGINBOT_MOVEMENT_INTERFACE_H_ 31 | -------------------------------------------------------------------------------- /extension/bot/tasks_shared/bot_shared_prereq_wait.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BOT_SHARED_PREREQUISITE_WAIT_TASK_H_ 2 | #define NAVBOT_BOT_SHARED_PREREQUISITE_WAIT_TASK_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | template 9 | class CBotSharedPrereqWaitTask : public AITask 10 | { 11 | public: 12 | CBotSharedPrereqWaitTask(float waitTime) : 13 | AITask() 14 | { 15 | m_waitTime = waitTime; 16 | } 17 | 18 | TaskResult OnTaskStart(BT* bot, AITask* pastTask) override; 19 | TaskResult OnTaskUpdate(BT* bot) override; 20 | 21 | const char* GetName() const override { return "Wait"; } 22 | 23 | private: 24 | float m_waitTime; 25 | CountdownTimer m_Timer; 26 | }; 27 | 28 | template 29 | inline TaskResult CBotSharedPrereqWaitTask::OnTaskStart(BT* bot, AITask* pastTask) 30 | { 31 | m_Timer.Start(m_waitTime); 32 | 33 | return AITask::Continue(); 34 | } 35 | 36 | template 37 | inline TaskResult CBotSharedPrereqWaitTask::OnTaskUpdate(BT* bot) 38 | { 39 | if (m_Timer.IsElapsed()) 40 | { 41 | return AITask::Done("Timer elapsed!"); 42 | } 43 | 44 | return AITask::Continue(); 45 | } 46 | 47 | #endif // !NAVBOT_BOT_SHARED_PREREQUISITE_WAIT_TASK_H_ -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/engineer/tf2bot_engineer_dodge_sentry_buster.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_ENGINEER_MVM_DODGE_SENTRY_BUSTER_H_ 2 | #define __NAVBOT_TF2BOT_ENGINEER_MVM_DODGE_SENTRY_BUSTER_H_ 3 | 4 | class CTF2BotEngineerMvMDodgeSentryBusterTask : public AITask 5 | { 6 | public: 7 | static bool IsPossible(CTF2Bot* bot, CBaseEntity** sentryBuster); 8 | 9 | CTF2BotEngineerMvMDodgeSentryBusterTask(CBaseEntity* sentryBuster); 10 | 11 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 12 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 13 | 14 | QueryAnswerType ShouldHurry(CBaseBot* me) override { return ANSWER_YES; } 15 | QueryAnswerType ShouldRetreat(CBaseBot* me) override { return ANSWER_NO; } 16 | QueryAnswerType ShouldAttack(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_NO; } 17 | QueryAnswerType ShouldSwitchToWeapon(CBaseBot* me, const CBotWeapon* weapon) override { return ANSWER_NO; } 18 | 19 | const char* GetName() const override { return "EngineerDodgeSentryBuster"; } 20 | private: 21 | CHandle m_sentryBuster; 22 | bool m_hasSentry; 23 | bool m_detonating; 24 | CountdownTimer m_repathTimer; 25 | CMeshNavigator m_nav; 26 | Vector m_goal; 27 | float m_detonationRange; 28 | 29 | // if a sentry buster is this close to a sentry, it's a problem 30 | static constexpr auto SENTRY_BUSTER_DANGER_RADIUS = 1500.0f; 31 | static constexpr auto SENTRY_BUSTER_MIN_COVER_RADIUS = 700.0f; 32 | static constexpr auto SENTRY_BUSTER_MAX_COVER_RADIUS = 2048.0f; 33 | static constexpr auto SENTRY_BUSTER_DEFAULT_DETONATION_RANGE = 100.0f; 34 | }; 35 | 36 | 37 | #endif // !__NAVBOT_TF2BOT_ENGINEER_MVM_DODGE_SENTRY_BUSTER_H_ 38 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/engineer/tf2bot_engineer_main.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_TASKS_ENGINEER_MAIN_H_ 2 | #define NAVBOT_TF2BOT_TASKS_ENGINEER_MAIN_H_ 3 | 4 | #include 5 | 6 | class CTF2Bot; 7 | 8 | /** 9 | * @brief Primary engineer behavior 10 | */ 11 | class CTF2BotEngineerMainTask : public AITask 12 | { 13 | public: 14 | CTF2BotEngineerMainTask(); 15 | 16 | AITask* InitialNextTask(CTF2Bot* bot) override; 17 | 18 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 19 | 20 | const char* GetName() const override { return "EngineerMain"; } 21 | 22 | static constexpr auto HELP_ALLY_BUILDING_MAX_RANGE_SQR = 1024.f * 1024.0f; 23 | private: 24 | CountdownTimer m_friendlyBuildingScan; 25 | 26 | CBaseEntity* ScanAllyBuildings(CTF2Bot* me, bool &is_upgrade); 27 | }; 28 | 29 | #endif // !NAVBOT_TF2BOT_TASKS_ENGINEER_MAIN_H_ 30 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/engineer/tf2bot_engineer_move_object.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2_BOT_ENGINEER_MOVE_OBJECT_TASK_H_ 2 | #define NAVBOT_TF2_BOT_ENGINEER_MOVE_OBJECT_TASK_H_ 3 | 4 | #include 5 | #include 6 | 7 | class CTF2Bot; 8 | class CTFWaypoint; 9 | 10 | class CTF2BotEngineerMoveObjectTask : public AITask 11 | { 12 | public: 13 | CTF2BotEngineerMoveObjectTask(CBaseEntity* object, const Vector& goal, const bool allowDestroying = false); 14 | CTF2BotEngineerMoveObjectTask(CBaseEntity* object, CTFWaypoint* goal, const bool allowDestroying = false); 15 | 16 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 17 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 18 | void OnTaskEnd(CTF2Bot* bot, AITask* nextTask) override; 19 | 20 | // Don't attack or switch weapons 21 | QueryAnswerType ShouldAttack(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_NO; } 22 | QueryAnswerType ShouldSwitchToWeapon(CBaseBot* me, const CBotWeapon* weapon) override { return ANSWER_NO; } 23 | 24 | const char* GetName() const override { return "MoveObject"; } 25 | private: 26 | CHandle m_building; 27 | Vector m_goal; 28 | CTFWaypoint* m_waypoint; 29 | QAngle m_angle; 30 | CMeshNavigatorAutoRepath m_nav; 31 | CountdownTimer m_changeAngleTimer; 32 | bool m_hasBuilding; 33 | bool m_canDestroy; 34 | }; 35 | 36 | 37 | #endif // !NAVBOT_TF2_BOT_ENGINEER_MOVE_OBJECT_TASK_H_ 38 | 39 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/engineer/tf2bot_engineer_repair_object.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_TASKS_ENGINEER_REPAIR_OBJECT_H_ 2 | #define NAVBOT_TF2BOT_TASKS_ENGINEER_REPAIR_OBJECT_H_ 3 | 4 | #include 5 | #include 6 | 7 | class CTF2Bot; 8 | 9 | class CTF2BotEngineerRepairObjectTask : public AITask 10 | { 11 | public: 12 | CTF2BotEngineerRepairObjectTask(CBaseEntity* object); 13 | 14 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 15 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 16 | 17 | QueryAnswerType ShouldSeekAndDestroy(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_NO; } 18 | QueryAnswerType ShouldAttack(CBaseBot* me, const CKnownEntity* them) override; 19 | 20 | const char* GetName() const override { return "RepairObject"; } 21 | 22 | private: 23 | CHandle m_object; 24 | CMeshNavigator m_nav; 25 | bool m_sentry; 26 | 27 | static constexpr auto get_object_melee_range() { return 64.0f; } 28 | }; 29 | 30 | #endif // !NAVBOT_TF2BOT_TASKS_ENGINEER_REPAIR_OBJECT_H_ 31 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/engineer/tf2bot_engineer_speedup_object.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_TASKS_ENGINEER_SPEEDUP_OBJECT_H_ 2 | #define NAVBOT_TF2BOT_TASKS_ENGINEER_SPEEDUP_OBJECT_H_ 3 | 4 | #include 5 | #include 6 | 7 | class CTF2Bot; 8 | 9 | class CTF2BotEngineerSpeedUpObjectTask : public AITask 10 | { 11 | public: 12 | CTF2BotEngineerSpeedUpObjectTask(CBaseEntity* object); 13 | 14 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 15 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 16 | 17 | const char* GetName() const override { return "SpeedUpConstruction"; } 18 | 19 | private: 20 | CHandle m_object; 21 | CMeshNavigator m_nav; 22 | 23 | static constexpr auto get_object_melee_range() { return 64.0f; } 24 | }; 25 | 26 | #endif // !NAVBOT_TF2BOT_TASKS_ENGINEER_SPEEDUP_OBJECT_H_ 27 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/engineer/tf2bot_engineer_upgrade_object.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_TASKS_ENGINEER_UPGRADE_OBJECT_H_ 2 | #define NAVBOT_TF2BOT_TASKS_ENGINEER_UPGRADE_OBJECT_H_ 3 | 4 | #include 5 | #include 6 | 7 | class CTF2BotEngineerUpgradeObjectTask : public AITask 8 | { 9 | public: 10 | CTF2BotEngineerUpgradeObjectTask(CBaseEntity* object); 11 | 12 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 13 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 14 | 15 | const char* GetName() const override { return "UpgradeObject"; } 16 | 17 | 18 | private: 19 | CHandle m_object; 20 | CMeshNavigator m_nav; 21 | 22 | static constexpr auto get_object_melee_range() { return 64.0f; } 23 | }; 24 | 25 | 26 | #endif // !NAVBOT_TF2BOT_TASKS_ENGINEER_UPGRADE_OBJECT_H_ 27 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/medic/tf2bot_medic_heal_task.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_MEDIC_HEAL_TASK_H_ 2 | #define NAVBOT_TF2BOT_MEDIC_HEAL_TASK_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class CTF2BotMedicHealTask : public AITask 9 | { 10 | public: 11 | CTF2BotMedicHealTask(); 12 | 13 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 14 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 15 | TaskResult OnTaskResume(CTF2Bot* bot, AITask* pastTask) override; 16 | 17 | // don't attack enemies if I healing my team 18 | QueryAnswerType ShouldAttack(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_NO; } 19 | QueryAnswerType ShouldSwitchToWeapon(CBaseBot* me, const CBotWeapon* weapon) override; 20 | 21 | TaskEventResponseResult OnVoiceCommand(CTF2Bot* bot, CBaseEntity* subject, int command) override; 22 | 23 | const char* GetName() const override { return "MedicHeal"; } 24 | private: 25 | CMeshNavigatorAutoRepath m_nav; 26 | CHandle m_followTarget; // Player I want to follow 27 | CHandle m_healTarget; // Player I am healing 28 | CountdownTimer m_patientScanTimer; // Time to scan for people to heal 29 | CountdownTimer m_respondToCallsTimer; 30 | CountdownTimer m_reviveMarkerScanTimer; 31 | Vector m_moveGoal; 32 | bool m_isMvM; 33 | 34 | void UpdateFollowTarget(CTF2Bot* bot); 35 | void UpdateHealTarget(CTF2Bot* bot); 36 | void UpdateMovePosition(CTF2Bot* bot, const CKnownEntity* threat); 37 | bool ScanForReviveMarkers(const Vector& center, CBaseEntity** marker); 38 | bool IsPatientStable(CTF2Bot* bot, CBaseEntity* patient); 39 | void EquipMedigun(CTF2Bot* me); 40 | float GetUbercharge(CTF2Bot* me); 41 | 42 | static constexpr float MEDIGUN_LETGO_RANGE = 400.0f; 43 | static constexpr float MEDIC_RESPOND_TO_CALL_RANGE = 600.0f; 44 | }; 45 | 46 | #endif // !NAVBOT_TF2BOT_MEDIC_HEAL_TASK_H_ 47 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/medic/tf2bot_medic_main_task.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "tf2bot_medic_retreat_task.h" 12 | #include "tf2bot_medic_revive_task.h" 13 | #include "tf2bot_medic_heal_task.h" 14 | #include "tf2bot_medic_main_task.h" 15 | 16 | #undef max 17 | #undef min 18 | #undef clamp 19 | 20 | AITask* CTF2BotMedicMainTask::InitialNextTask(CTF2Bot* bot) 21 | { 22 | return new CTF2BotMedicHealTask; 23 | } 24 | 25 | TaskResult CTF2BotMedicMainTask::OnTaskStart(CTF2Bot* bot, AITask* pastTask) 26 | { 27 | return Continue(); 28 | } 29 | 30 | TaskResult CTF2BotMedicMainTask::OnTaskUpdate(CTF2Bot* bot) 31 | { 32 | return Continue(); 33 | } 34 | 35 | TaskResult CTF2BotMedicMainTask::OnTaskResume(CTF2Bot* bot, AITask* pastTask) 36 | { 37 | return Continue(); 38 | } 39 | 40 | TaskEventResponseResult CTF2BotMedicMainTask::OnFlagTaken(CTF2Bot* bot, CBaseEntity* player) 41 | { 42 | if (bot->GetEntity() == player) 43 | { 44 | auto mod = CTeamFortress2Mod::GetTF2Mod(); 45 | 46 | if (mod->GetCurrentGameMode() == TeamFortress2::GameModeType::GM_CTF) 47 | { 48 | return TryPauseFor(new CTF2BotCTFDeliverFlagTask, PRIORITY_HIGH, "I got the flag, delivering it!"); 49 | } 50 | } 51 | 52 | return TryContinue(); 53 | } 54 | 55 | QueryAnswerType CTF2BotMedicMainTask::IsReady(CBaseBot* me) 56 | { 57 | CTF2Bot* tf2bot = static_cast(me); 58 | CBaseEntity* medigun = tf2bot->GetWeaponOfSlot(static_cast(TeamFortress2::TFWeaponSlot::TFWeaponSlot_Secondary)); 59 | 60 | if (medigun && tf2lib::GetMedigunUberchargePercentage(gamehelpers->EntityToBCompatRef(medigun)) > 0.99f) 61 | { 62 | return ANSWER_YES; 63 | } 64 | 65 | return ANSWER_NO; 66 | } 67 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/medic/tf2bot_medic_main_task.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_TASK_MEDIC_MAIN_H_ 2 | #define NAVBOT_TF2BOT_TASK_MEDIC_MAIN_H_ 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | class CTF2Bot; 10 | struct edict_t; 11 | 12 | class CTF2BotMedicMainTask : public AITask 13 | { 14 | public: 15 | AITask* InitialNextTask(CTF2Bot* bot) override; 16 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 17 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 18 | TaskResult OnTaskResume(CTF2Bot* bot, AITask* pastTask) override; 19 | 20 | TaskEventResponseResult OnFlagTaken(CTF2Bot* bot, CBaseEntity* player) override; 21 | 22 | QueryAnswerType IsReady(CBaseBot* me) override; 23 | // Don't chase enemies 24 | QueryAnswerType ShouldSeekAndDestroy(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_NO; } 25 | 26 | const char* GetName() const override { return "MedicMain"; } 27 | 28 | private: 29 | 30 | }; 31 | 32 | #endif // !NAVBOT_TF2BOT_TASK_MEDIC_MAIN_H_ 33 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/medic/tf2bot_medic_mvm_build_uber_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_MEDIC_MVM_BUILD_UBER_TASK_H_ 2 | #define __NAVBOT_TF2BOT_MEDIC_MVM_BUILD_UBER_TASK_H_ 3 | 4 | class CTF2BotMedicMvMBuildUberTask : public AITask 5 | { 6 | public: 7 | 8 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 9 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 10 | 11 | QueryAnswerType IsReady(CBaseBot* me) override { return ANSWER_NO; } 12 | QueryAnswerType ShouldSwitchToWeapon(CBaseBot* me, const CBotWeapon* weapon) override { return ANSWER_NO; } 13 | 14 | const char* GetName() const override { return "MedicMain"; } 15 | 16 | private: 17 | float* m_flChargeLevel; 18 | bool* m_bHealing; 19 | CHandle* m_hHealingTarget; // medigun's current heal target 20 | CHandle m_healTarget; // bot heal target 21 | CMeshNavigatorAutoRepath m_nav; 22 | 23 | bool FindPlayerToHeal(CTF2Bot* me); 24 | }; 25 | 26 | 27 | #endif // !__NAVBOT_TF2BOT_MEDIC_MVM_BUILD_UBER_TASK_H_ 28 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/medic/tf2bot_medic_retreat_task.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_MEDIC_RETREAT_TASK_H_ 2 | #define NAVBOT_TF2BOT_MEDIC_RETREAT_TASK_H_ 3 | #pragma once 4 | 5 | #include 6 | 7 | class CTF2Bot; 8 | 9 | class CTF2BotMedicRetreatTask : public AITask 10 | { 11 | public: 12 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 13 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 14 | 15 | TaskEventResponseResult OnVoiceCommand(CTF2Bot* bot, CBaseEntity* subject, int command) override; 16 | 17 | // Allow attacking and weapon switching 18 | QueryAnswerType ShouldAttack(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_YES; } 19 | QueryAnswerType ShouldSwitchToWeapon(CBaseBot* me, const CBotWeapon* weapon) override { return ANSWER_YES; } 20 | 21 | const char* GetName() const override { return "MedicRetreat"; } 22 | 23 | private: 24 | Vector m_goal; 25 | CMeshNavigator m_nav; 26 | CountdownTimer m_repathtimer; 27 | CountdownTimer m_atHomeTimer; 28 | 29 | static constexpr float home_range() { return 256.0f; } 30 | 31 | Vector GetRetreatPosition(CTF2Bot* me) const; 32 | }; 33 | 34 | 35 | #endif // !NAVBOT_TF2BOT_MEDIC_RETREAT_TASK_H_ 36 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/medic/tf2bot_medic_revive_task.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_TASK_MEDIC_REVIVE_H_ 2 | #define NAVBOT_TF2BOT_TASK_MEDIC_REVIVE_H_ 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | class CTF2Bot; 10 | struct edict_t; 11 | 12 | class CTF2BotMedicReviveTask : public AITask 13 | { 14 | public: 15 | CTF2BotMedicReviveTask(CBaseEntity* marker); 16 | 17 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 18 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 19 | 20 | // medics never attack 21 | QueryAnswerType ShouldAttack(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_NO; } 22 | QueryAnswerType ShouldSwitchToWeapon(CBaseBot* me, const CBotWeapon* weapon) override { return ANSWER_NO; } 23 | 24 | const char* GetName() const override { return "MedicRevive"; } 25 | 26 | private: 27 | CHandle m_marker; // revive marker 28 | CountdownTimer m_repathTimer; 29 | CMeshNavigator m_nav; 30 | Vector m_aimpos; 31 | Vector m_goal; 32 | 33 | static constexpr auto marker_aimpos_z_offset() { return 32.0f; } 34 | static constexpr auto marker_heal_range() { return 300.0f; } 35 | }; 36 | 37 | #endif // !NAVBOT_TF2BOT_TASK_MEDIC_REVIVE_H_ 38 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/controlpoints/tf2bot_attack_controlpoint.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_ATTACK_CONTROL_POINT_H_ 2 | #define NAVBOT_TF2BOT_ATTACK_CONTROL_POINT_H_ 3 | 4 | #include 5 | #include 6 | 7 | class CTF2BotAttackControlPointTask : public AITask 8 | { 9 | public: 10 | CTF2BotAttackControlPointTask(CBaseEntity* controlpoint); 11 | 12 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 13 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 14 | TaskResult OnTaskResume(CTF2Bot* bot, AITask* pastTask) override; 15 | 16 | QueryAnswerType ShouldHurry(CBaseBot* me) override; 17 | QueryAnswerType ShouldRetreat(CBaseBot* me) override; 18 | QueryAnswerType ShouldSeekAndDestroy(CBaseBot* me, const CKnownEntity* them) override; 19 | 20 | const char* GetName() const override { return "AttackControlPoint"; } 21 | 22 | private: 23 | CHandle m_controlpoint; // control point entity 24 | CMeshNavigatorAutoRepath m_nav; 25 | Vector m_capturePos; // position the bot should move to to capture the point 26 | CountdownTimer m_refreshPosTimer; 27 | RouteType m_routeType; 28 | 29 | void FindCaptureTrigger(CBaseEntity* controlpoint); 30 | 31 | static constexpr auto CRITICAL_ROUND_TIME = 60.0f; // if the round time remaining is less than this, rush 32 | }; 33 | 34 | #endif // !NAVBOT_TF2BOT_ATTACK_CONTROL_POINT_H_ 35 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/controlpoints/tf2bot_controlpoints_monitor.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_CONTROL_POINT_MONITOR_TASK_H_ 2 | #define NAVBOT_TF2BOT_CONTROL_POINT_MONITOR_TASK_H_ 3 | 4 | class CTF2BotControlPointMonitorTask : public AITask 5 | { 6 | public: 7 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 8 | 9 | 10 | 11 | const char* GetName() const override { return "ControlPointMonitor"; } 12 | 13 | }; 14 | 15 | 16 | #endif // !NAVBOT_TF2BOT_CONTROL_POINT_MONITOR_TASK_H_ 17 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/deathmatch/tf2bot_deathmatch.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "tf2bot_deathmatch.h" 6 | 7 | TaskResult CTF2BotDeathmatchScenarioTask::OnTaskUpdate(CTF2Bot* bot) 8 | { 9 | return PauseFor(new CTF2BotRoamTask(), "Going to a random destination!"); 10 | } 11 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/deathmatch/tf2bot_deathmatch.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2_DEATHMATCH_SCENARIO_TASK_H_ 2 | #define NAVBOT_TF2_DEATHMATCH_SCENARIO_TASK_H_ 3 | 4 | class CTF2BotDeathmatchScenarioTask : public AITask 5 | { 6 | public: 7 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 8 | 9 | const char* GetName() const override { return "Deathmatch"; } 10 | }; 11 | 12 | #endif //!NAVBOT_TF2_DEATHMATCH_SCENARIO_TASK_H_ -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/mvm/tf2bot_mvm_defend.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2_BOT_MVM_DEFEND_TASKS_H_ 2 | #define NAVBOT_TF2_BOT_MVM_DEFEND_TASKS_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class CTF2Bot; 9 | 10 | class CTF2BotMvMDefendTask : public AITask 11 | { 12 | public: 13 | CTF2BotMvMDefendTask(); 14 | 15 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 16 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 17 | 18 | const char* GetName() const override { return "MvMDefend"; } 19 | private: 20 | CHandle m_target; 21 | CMeshNavigator m_nav; 22 | CountdownTimer m_repathTimer; 23 | CountdownTimer m_updateTargetTimer; 24 | CountdownTimer m_lookAtTimer; 25 | Vector m_targetPos; 26 | 27 | void UpdateTarget(); 28 | }; 29 | 30 | #endif // !NAVBOT_TF2_BOT_MVM_DEFEND_TASKS_H_ -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/mvm/tf2bot_mvm_guard_dropped_bomb_task.h: -------------------------------------------------------------------------------- 1 | #ifndef TF2BOT_MVM_GUARD_BOMB_TASK_H_ 2 | #define TF2BOT_MVM_GUARD_BOMB_TASK_H_ 3 | 4 | class CTF2BotMvMGuardDroppedBombTask : public AITask 5 | { 6 | public: 7 | CTF2BotMvMGuardDroppedBombTask(CBaseEntity* bomb); 8 | 9 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 10 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 11 | 12 | TaskEventResponseResult OnMoveToSuccess(CTF2Bot* bot, CPath* path) override; 13 | 14 | const char* GetName() const override { return "GuardDroppedBomb"; } 15 | private: 16 | CHandle m_bomb; 17 | CMeshNavigator m_nav; 18 | CountdownTimer m_repathTimer; 19 | CountdownTimer m_scanTimer; 20 | Vector m_goal; 21 | bool m_reached; 22 | 23 | }; 24 | 25 | #endif // !TF2BOT_MVM_GUARD_BOMB_TASK_H_ -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/mvm/tf2bot_mvm_idle.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_TASK_MVM_IDLE_H_ 2 | #define NAVBOT_TF2BOT_TASK_MVM_IDLE_H_ 3 | #pragma once 4 | 5 | #include 6 | 7 | 8 | class CTF2Bot; 9 | 10 | class CTF2BotMvMIdleTask : public AITask 11 | { 12 | public: 13 | CTF2BotMvMIdleTask() 14 | { 15 | m_goal.Init(); 16 | m_upgradeDuringWave = false; 17 | } 18 | 19 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 20 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 21 | TaskResult OnTaskResume(CTF2Bot* bot, AITask* pastTask) override; 22 | 23 | TaskEventResponseResult OnMoveToFailure(CTF2Bot* bot, CPath* path, IEventListener::MovementFailureType reason) override; 24 | TaskEventResponseResult OnMoveToSuccess(CTF2Bot* bot, CPath* path) override; 25 | 26 | const char* GetName() const override { return "MvMIdle"; } 27 | 28 | QueryAnswerType IsReady(CBaseBot* me) override; 29 | private: 30 | CMeshNavigator m_nav; 31 | Vector m_goal; 32 | CountdownTimer m_repathtimer; 33 | CountdownTimer m_readyCheck; 34 | CountdownTimer m_currencyScanTimer; 35 | bool m_upgradeDuringWave; 36 | 37 | void FindIdlePosition(); 38 | 39 | static constexpr auto BUY_UPGRADE_DURING_WAVE_MIN_CURRENCY = 600; 40 | }; 41 | 42 | #endif // !NAVBOT_TF2BOT_TASK_MVM_IDLE_H_ 43 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/mvm/tf2bot_mvm_monitor.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2_BOT_MVM_MONITOR_TASK_H_ 2 | #define NAVBOT_TF2_BOT_MVM_MONITOR_TASK_H_ 3 | 4 | class CTF2Bot; 5 | 6 | class CTF2BotMvMMonitorTask : public AITask 7 | { 8 | public: 9 | CTF2BotMvMMonitorTask() 10 | { 11 | m_hasUpgradedInThisWave = false; 12 | m_myclass = static_cast(0); 13 | } 14 | 15 | AITask* InitialNextTask(CTF2Bot* bot) override; 16 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 17 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 18 | 19 | TaskEventResponseResult OnRoundStateChanged(CTF2Bot* bot) override; 20 | 21 | const char* GetName() const override { return "MvMMonitor"; } 22 | private: 23 | bool m_hasUpgradedInThisWave; 24 | TeamFortress2::TFClassType m_myclass; 25 | CountdownTimer m_currencyScan; 26 | CountdownTimer m_engineerSBTimer; // sentry buster timer 27 | }; 28 | 29 | #endif // !NAVBOT_TF2_BOT_MVM_MONITOR_TASK_H_ 30 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/mvm/tf2bot_mvm_tasks.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2_BOT_MVM_TASKS_H_ 2 | #define NAVBOT_TF2_BOT_MVM_TASKS_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class CTF2Bot; 10 | 11 | class CTF2BotCollectMvMCurrencyTask : public AITask 12 | { 13 | public: 14 | CTF2BotCollectMvMCurrencyTask(std::vector>& packs); 15 | 16 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 17 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 18 | 19 | QueryAnswerType ShouldAttack(CBaseBot* me, const CKnownEntity* them) override 20 | { 21 | if (m_allowattack) 22 | { 23 | return ANSWER_YES; 24 | } 25 | 26 | return ANSWER_NO; 27 | } 28 | 29 | static bool IsAllowedToCollectCurrency(); 30 | static void ScanForDroppedCurrency(std::vector>& currencyPacks); 31 | 32 | const char* GetName() const override { return "CollectMvMCurrency"; } 33 | private: 34 | CountdownTimer m_repathTimer; 35 | CMeshNavigator m_nav; 36 | std::vector> m_currencypacks; 37 | std::vector>::iterator m_it; 38 | bool m_allowattack; 39 | }; 40 | 41 | class CTF2BotMvMTankBusterTask : public AITask 42 | { 43 | public: 44 | CTF2BotMvMTankBusterTask(CBaseEntity* tank); 45 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 46 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 47 | 48 | const char* GetName() const override { return "TankBuster"; } 49 | private: 50 | CMeshNavigator m_nav; 51 | CountdownTimer m_repathTimer; 52 | CHandle m_tank; 53 | CountdownTimer m_rescanTimer; 54 | }; 55 | 56 | #endif // !NAVBOT_TF2_BOT_MVM_TASKS_H_ 57 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/mvm/tf2bot_mvm_upgrade.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_TASK_MVM_UPGRADE_H_ 2 | #define NAVBOT_TF2BOT_TASK_MVM_UPGRADE_H_ 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | class CTF2Bot; 9 | 10 | class CTF2BotMvMUpgradeTask : public AITask 11 | { 12 | public: 13 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 14 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 15 | 16 | TaskEventResponseResult OnMoveToFailure(CTF2Bot* bot, CPath* path, IEventListener::MovementFailureType reason) override; 17 | TaskEventResponseResult OnMoveToSuccess(CTF2Bot* bot, CPath* path) override; 18 | 19 | const char* GetName() const override { return "MvMUpgrade"; } 20 | private: 21 | CMeshNavigator m_nav; 22 | Vector m_goal; 23 | CountdownTimer m_repathtimer; 24 | CountdownTimer m_buydelay; 25 | CBaseHandle m_upgradestation; 26 | 27 | bool SelectNearestUpgradeStation(CTF2Bot* me); 28 | void SetGoalPosition(); 29 | }; 30 | 31 | #endif // !NAVBOT_TF2BOT_TASK_MVM_UPGRADE_H_ 32 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/passtime/tf2bot_passtime_goal_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_PASSTIME_GOAL_TASK_H_ 2 | #define __NAVBOT_TF2BOT_PASSTIME_GOAL_TASK_H_ 3 | 4 | class CTF2BotPassTimeGoalTask : public AITask 5 | { 6 | public: 7 | 8 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 9 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 10 | void OnTaskEnd(CTF2Bot* bot, AITask* nextTask) override; 11 | 12 | QueryAnswerType ShouldAttack(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_NO; } 13 | QueryAnswerType ShouldSeekAndDestroy(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_NO; } 14 | QueryAnswerType ShouldHurry(CBaseBot* me) override { return ANSWER_YES; } 15 | QueryAnswerType ShouldRetreat(CBaseBot* me) override { return ANSWER_NO; } 16 | QueryAnswerType ShouldAssistTeammate(CBaseBot* me, CBaseEntity* teammate) override { return ANSWER_NO; } 17 | QueryAnswerType ShouldSwitchToWeapon(CBaseBot* me, const CBotWeapon* weapon) override { return ANSWER_NO; } 18 | 19 | const char* GetName() const override { return "GoalJack"; } 20 | 21 | private: 22 | CHandle m_goalent; 23 | CMeshNavigator m_nav; 24 | CountdownTimer m_repathtimer; 25 | TeamFortress2::PassTimeGoalType m_goaltype; 26 | CountdownTimer m_holdattacktimer; 27 | 28 | static constexpr float MAX_RANGE_TO_LAUNCH_JACK = 512.0f; 29 | bool NeedsToFire() const; 30 | float GetZ(const Vector& origin, const Vector& center) const; 31 | }; 32 | 33 | #endif // !__NAVBOT_TF2BOT_PASSTIME_GOAL_TASK_H_ 34 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/passtime/tf2bot_passtime_monitor_task.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "tf2bot_wait_for_jack_task.h" 9 | #include "tf2bot_pick_jack_task.h" 10 | #include "tf2bot_passtime_goal_task.h" 11 | #include "tf2bot_seek_and_destroy_jack_carrier_task.h" 12 | #include 13 | #include 14 | #include "tf2bot_passtime_monitor_task.h" 15 | 16 | TaskResult CTF2BotPassTimeMonitorTask::OnTaskUpdate(CTF2Bot* bot) 17 | { 18 | if (bot->IsCarryingThePassTimeJack()) 19 | { 20 | return PauseFor(new CTF2BotPassTimeGoalTask, "I have the jack! Going to score it!"); 21 | } 22 | 23 | if (!tf2lib::passtime::IsJackActive()) 24 | { 25 | return PauseFor(new CTF2BotWaitForJackTask, "Moving to the jack spawn position!"); 26 | } 27 | 28 | CBaseEntity* jack = tf2lib::passtime::GetJack(); 29 | 30 | if (jack) 31 | { 32 | CBaseEntity* carrier = tf2lib::passtime::GetJackCarrier(jack); 33 | 34 | if (carrier) 35 | { 36 | if (tf2lib::GetEntityTFTeam(carrier) != bot->GetMyTFTeam()) 37 | { 38 | return PauseFor(new CTF2BotSeekAndDestroyJackCarrierTask, "Going after the jack carrier!"); 39 | } 40 | else if (bot->GetDifficultyProfile()->GetTeamwork() >= 25 && CBaseBot::s_botrng.GetRandomInt(0, 2) > 0) 41 | { 42 | return PauseFor(new CBotSharedEscortEntityTask(bot, carrier, 15.0f, 500.0f), "Escorting teammate carrying the jack!"); 43 | } 44 | } 45 | else 46 | { 47 | return PauseFor(new CTF2BotPickJackTask, "Going after the jack!"); 48 | } 49 | } 50 | 51 | return PauseFor(new CBotSharedRoamTask(bot, 10000.0f, true), "Nothing to do, roaming!"); 52 | } 53 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/passtime/tf2bot_passtime_monitor_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_PASS_TIME_MONITOR_TASK_H_ 2 | #define __NAVBOT_TF2BOT_PASS_TIME_MONITOR_TASK_H_ 3 | 4 | class CTF2BotPassTimeMonitorTask : public AITask 5 | { 6 | public: 7 | 8 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 9 | 10 | const char* GetName() const override { return "PassTimeMonitor"; } 11 | }; 12 | 13 | #endif // !__NAVBOT_TF2BOT_PASS_TIME_MONITOR_TASK_H_ 14 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/passtime/tf2bot_pick_jack_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_PICK_JACK_TASK_H_ 2 | #define __NAVBOT_TF2BOT_PICK_JACK_TASK_H_ 3 | 4 | class CTF2BotPickJackTask : public AITask 5 | { 6 | public: 7 | 8 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 9 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 10 | 11 | const char* GetName() const override { return "PickJack"; } 12 | 13 | private: 14 | CMeshNavigatorAutoRepath m_nav; 15 | CHandle m_jack; 16 | }; 17 | 18 | #endif // !__NAVBOT_TF2BOT_PICK_JACK_TASK_H_ 19 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/passtime/tf2bot_seek_and_destroy_jack_carrier_task.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "tf2bot_seek_and_destroy_jack_carrier_task.h" 9 | #include "tf2bot_pick_jack_task.h" 10 | 11 | CTF2BotSeekAndDestroyJackCarrierTask::CTF2BotSeekAndDestroyJackCarrierTask() : 12 | m_nav(CChaseNavigator::SubjectLeadType::DONT_LEAD_SUBJECT) 13 | { 14 | } 15 | 16 | TaskResult CTF2BotSeekAndDestroyJackCarrierTask::OnTaskStart(CTF2Bot* bot, AITask* pastTask) 17 | { 18 | m_jack = tf2lib::passtime::GetJack(); 19 | 20 | return Continue(); 21 | } 22 | 23 | TaskResult CTF2BotSeekAndDestroyJackCarrierTask::OnTaskUpdate(CTF2Bot* bot) 24 | { 25 | CBaseEntity* jack = m_jack.Get(); 26 | 27 | if (!jack) 28 | { 29 | return Done("Jack is NULL!"); 30 | } 31 | 32 | CBaseEntity* carrier = tf2lib::passtime::GetJackCarrier(jack); 33 | 34 | if (!carrier) 35 | { 36 | return SwitchTo(new CTF2BotPickJackTask, "Going after the jack!"); 37 | } 38 | 39 | if (tf2lib::GetEntityTFTeam(carrier) == bot->GetMyTFTeam()) 40 | { 41 | return Done("Teammate is carrying the jack!"); 42 | } 43 | 44 | CTF2BotPathCost cost(bot); 45 | m_nav.Update(bot, carrier, cost); 46 | 47 | return Continue(); 48 | } 49 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/passtime/tf2bot_seek_and_destroy_jack_carrier_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_SEEK_AND_DESTROY_JACK_CARRIER_H_ 2 | #define __NAVBOT_TF2BOT_SEEK_AND_DESTROY_JACK_CARRIER_H_ 3 | 4 | class CTF2BotSeekAndDestroyJackCarrierTask : public AITask 5 | { 6 | public: 7 | CTF2BotSeekAndDestroyJackCarrierTask(); 8 | 9 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 10 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 11 | 12 | const char* GetName() const override { return "SeekAndDestroyJackCarrier"; } 13 | 14 | private: 15 | CChaseNavigator m_nav; 16 | CHandle m_jack; 17 | }; 18 | 19 | #endif // !__NAVBOT_TF2BOT_SEEK_AND_DESTROY_JACK_CARRIER_H_ 20 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/passtime/tf2bot_wait_for_jack_task.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "tf2bot_pick_jack_task.h" 13 | #include "tf2bot_wait_for_jack_task.h" 14 | 15 | TaskResult CTF2BotWaitForJackTask::OnTaskStart(CTF2Bot* bot, AITask* pastTask) 16 | { 17 | if (!tf2lib::passtime::GetJackSpawnPosition(&m_goal)) 18 | { 19 | return SwitchTo(new CBotSharedRoamTask(bot, 10000.0f, true), "Failed to find jack spawn position, roaming!"); 20 | } 21 | 22 | m_goal = trace::getground(m_goal); 23 | 24 | return Continue(); 25 | } 26 | 27 | TaskResult CTF2BotWaitForJackTask::OnTaskUpdate(CTF2Bot* bot) 28 | { 29 | const CKnownEntity* threat = bot->GetSensorInterface()->GetPrimaryKnownThreat(true); 30 | 31 | if (threat) 32 | { 33 | return PauseFor(new CBotSharedAttackEnemyTask(bot), "Attacking visible enemy!"); 34 | } 35 | 36 | if (tf2lib::passtime::IsJackActive()) 37 | { 38 | return SwitchTo(new CTF2BotPickJackTask, "Going after the jack!"); 39 | } 40 | 41 | if (m_repathtimer.IsElapsed()) 42 | { 43 | m_repathtimer.Start(2.0f); 44 | CTF2BotPathCost cost(bot, SAFEST_ROUTE); 45 | m_nav.ComputePathToPosition(bot, m_goal, cost); 46 | } 47 | 48 | m_nav.Update(bot); 49 | 50 | return Continue(); 51 | } 52 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/passtime/tf2bot_wait_for_jack_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_WAIT_FOR_JACK_TASK_H_ 2 | #define __NAVBOT_TF2BOT_WAIT_FOR_JACK_TASK_H_ 3 | 4 | class CTF2BotWaitForJackTask : public AITask 5 | { 6 | public: 7 | 8 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 9 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 10 | 11 | const char* GetName() const override { return "WaitForJack"; } 12 | 13 | private: 14 | Vector m_goal; 15 | CMeshNavigator m_nav; 16 | CountdownTimer m_repathtimer; 17 | }; 18 | 19 | #endif // !__NAVBOT_TF2BOT_WAIT_FOR_JACK_TASK_H_ 20 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/payload/tf2bot_task_defend_payload.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2_BOT_TASKS_DEFEND_PAYLOAD_H_ 2 | #define NAVBOT_TF2_BOT_TASKS_DEFEND_PAYLOAD_H_ 3 | 4 | #include 5 | #include 6 | 7 | class CTF2Bot; 8 | 9 | class CTF2BotDefendPayloadTask : public AITask 10 | { 11 | public: 12 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 13 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 14 | TaskResult OnTaskResume(CTF2Bot* bot, AITask* pastTask) override; 15 | 16 | TaskEventResponseResult OnMoveToFailure(CTF2Bot* bot, CPath* path, IEventListener::MovementFailureType reason) override; 17 | TaskEventResponseResult OnMoveToSuccess(CTF2Bot* bot, CPath* path) override; 18 | 19 | const char* GetName() const override { return "DefendPayload"; } 20 | private: 21 | CMeshNavigator m_nav; 22 | Vector m_goal; 23 | CountdownTimer m_repathtimer; 24 | CountdownTimer m_updatePayloadTimer; 25 | CHandle m_payload; 26 | 27 | CBaseEntity* GetPayload(CTF2Bot* bot); 28 | }; 29 | 30 | 31 | #endif // !NAVBOT_TF2_BOT_TASKS_DEFEND_PAYLOAD_H_ 32 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/payload/tf2bot_task_push_payload.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_TASK_PUSH_PAYLOAD_H_ 2 | #define NAVBOT_TF2BOT_TASK_PUSH_PAYLOAD_H_ 3 | 4 | #include 5 | #include 6 | 7 | class CTF2Bot; 8 | 9 | class CTF2BotPushPayloadTask : public AITask 10 | { 11 | public: 12 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 13 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 14 | TaskResult OnTaskResume(CTF2Bot* bot, AITask* pastTask) override; 15 | 16 | TaskEventResponseResult OnMoveToFailure(CTF2Bot* bot, CPath* path, IEventListener::MovementFailureType reason) override; 17 | TaskEventResponseResult OnMoveToSuccess(CTF2Bot* bot, CPath* path) override; 18 | 19 | const char* GetName() const override { return "PushPayload"; } 20 | private: 21 | CMeshNavigator m_nav; 22 | Vector m_goal; 23 | CountdownTimer m_repathtimer; 24 | CountdownTimer m_updatePayloadTimer; 25 | CHandle m_payload; 26 | 27 | CBaseEntity* GetPayload(CTF2Bot* bot); 28 | }; 29 | 30 | #endif // !NAVBOT_TF2BOT_TASK_PUSH_PAYLOAD_H_ 31 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/pd/tf2bot_pd_collect_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_PD_COLLECT_TASK_H_ 2 | #define __NAVBOT_TF2BOT_PD_COLLECT_TASK_H_ 3 | 4 | class CTF2BotPDCollectTask : public AITask 5 | { 6 | public: 7 | CTF2BotPDCollectTask(std::vector>&& toCollect); 8 | 9 | static bool IsPossible(CTF2Bot* bot, std::vector>& points); 10 | 11 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 12 | 13 | QueryAnswerType ShouldSeekAndDestroy(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_NO; } 14 | QueryAnswerType ShouldHurry(CBaseBot* me) override { return ANSWER_YES; } 15 | QueryAnswerType ShouldRetreat(CBaseBot* me) override { return ANSWER_NO; } 16 | QueryAnswerType ShouldAssistTeammate(CBaseBot* me, CBaseEntity* teammate) override { return ANSWER_NO; } 17 | 18 | const char* GetName() const override { return "PDCollect"; } 19 | private: 20 | std::vector> m_points; 21 | std::size_t m_index; 22 | CountdownTimer m_repathtimer; 23 | CMeshNavigator m_nav; 24 | }; 25 | 26 | #endif // !__NAVBOT_TF2BOT_PD_COLLECT_TASK_H_ 27 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/pd/tf2bot_pd_monitor_task.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "tf2bot_pd_move_to_capture_zone_task.h" 11 | #include "tf2bot_pd_collect_task.h" 12 | #include "tf2bot_pd_search_and_destroy_task.h" 13 | #include "tf2bot_pd_monitor_task.h" 14 | 15 | TaskResult CTF2BotPDMonitorTask::OnTaskUpdate(CTF2Bot* bot) 16 | { 17 | CBaseEntity* capzone = nullptr; 18 | 19 | if (CTF2BotPDMoveToCaptureZoneTask::IsPossible(bot, &capzone)) 20 | { 21 | return PauseFor(new CTF2BotPDMoveToCaptureZoneTask(capzone), "Delivering my points!"); 22 | } 23 | 24 | std::vector> pointsToCollect; 25 | 26 | if (CTF2BotPDCollectTask::IsPossible(bot, pointsToCollect)) 27 | { 28 | return PauseFor(new CTF2BotPDCollectTask(std::move(pointsToCollect)), "Collecting nearby dropped points!"); 29 | } 30 | 31 | if (bot->GetItem() == nullptr) 32 | { 33 | const int teamwork = bot->GetDifficultyProfile()->GetTeamwork() - 20; 34 | 35 | if (teamwork > 0 && randomgen->GetRandomInt(1, 100) <= teamwork) 36 | { 37 | CBaseEntity* leader = tf2lib::pd::GetTeamLeader(bot->GetMyTFTeam()); 38 | 39 | if (leader) 40 | { 41 | return PauseFor(new CBotSharedEscortEntityTask(bot, leader, randomgen->GetRandomReal(30.0f, 90.0f), 400.0f), "Following my team's leader!"); 42 | } 43 | } 44 | } 45 | 46 | return PauseFor(new CTF2BotPDSearchAndDestroyTask, "Searching for enemy players to destroy!"); 47 | } 48 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/pd/tf2bot_pd_monitor_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_PD_MONITOR_TASK_H_ 2 | #define __NAVBOT_TF2BOT_PD_MONITOR_TASK_H_ 3 | 4 | class CTF2BotPDMonitorTask : public AITask 5 | { 6 | public: 7 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 8 | 9 | const char* GetName() const override { return "PlayerDestruction"; } 10 | }; 11 | 12 | #endif // !__NAVBOT_TF2BOT_PD_MONITOR_TASK_H_ 13 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/pd/tf2bot_pd_move_to_capture_zone_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_PD_MOVE_TO_CAPTURE_ZONE_TASK_H_ 2 | #define __NAVBOT_TF2BOT_PD_MOVE_TO_CAPTURE_ZONE_TASK_H_ 3 | 4 | class CTF2BotPDMoveToCaptureZoneTask : public AITask 5 | { 6 | public: 7 | CTF2BotPDMoveToCaptureZoneTask(CBaseEntity* captureZone); 8 | 9 | static bool IsPossible(CTF2Bot* bot, CBaseEntity** captureZone); 10 | 11 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 12 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 13 | 14 | TaskEventResponseResult OnMoveToFailure(CTF2Bot* bot, CPath* path, IEventListener::MovementFailureType reason) override; 15 | 16 | QueryAnswerType ShouldSeekAndDestroy(CBaseBot* me, const CKnownEntity* them) override; 17 | QueryAnswerType ShouldHurry(CBaseBot* me) override; 18 | QueryAnswerType ShouldRetreat(CBaseBot* me) override; 19 | QueryAnswerType ShouldAssistTeammate(CBaseBot* me, CBaseEntity* teammate) override; 20 | 21 | const char* GetName() const override { return "PDMoveToCap"; } 22 | private: 23 | CHandle m_capzone; 24 | CountdownTimer m_repathtimer; 25 | CountdownTimer m_timeout; 26 | CMeshNavigator m_nav; 27 | int m_pathfailures; 28 | }; 29 | 30 | #endif // !__NAVBOT_TF2BOT_PD_MOVE_TO_CAPTURE_ZONE_TASK_H_ 31 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/pd/tf2bot_pd_search_and_destroy_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_PD_SEARCH_AND_DESTROY_TASK_H_ 2 | #define __NAVBOT_TF2BOT_PD_SEARCH_AND_DESTROY_TASK_H_ 3 | 4 | class CTF2BotPDSearchAndDestroyTask : public AITask 5 | { 6 | public: 7 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 8 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 9 | 10 | TaskEventResponseResult OnMoveToSuccess(CTF2Bot* bot, CPath* path) override; 11 | 12 | const char* GetName() const override { return "PDSearchAndDestroy"; } 13 | private: 14 | Vector m_goal; 15 | CountdownTimer m_checkpointstimer; 16 | CountdownTimer m_checkdelivertimer; 17 | CountdownTimer m_repathtimer; 18 | CMeshNavigator m_nav; 19 | 20 | bool SelectRandomGoal(CTF2Bot* bot); 21 | }; 22 | 23 | #endif // !__NAVBOT_TF2BOT_PD_SEARCH_AND_DESTROY_TASK_H_ 24 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/rd/tf2bot_rd_collect_points_task.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "tf2bot_rd_collect_points_task.h" 11 | 12 | bool CTF2BotRDCollectPointsTask::IsPossible(CTF2Bot* bot, std::vector>& points) 13 | { 14 | using namespace std::literals::string_view_literals; 15 | 16 | constexpr auto POINT_ENTITY_CLASSNAME = "item_bonuspack"sv; 17 | 18 | UtilHelpers::CEntityEnumerator enumerator; 19 | UtilHelpers::EntitiesInSphere(bot->GetAbsOrigin(), 2048.0f, enumerator); 20 | 21 | auto myteam = bot->GetMyTFTeam(); 22 | auto functor = [&POINT_ENTITY_CLASSNAME, &points, &myteam](CBaseEntity* entity) -> bool { 23 | if (tf2lib::GetEntityTFTeam(entity) == myteam && UtilHelpers::FClassnameIs(entity, POINT_ENTITY_CLASSNAME.data())) 24 | { 25 | points.push_back(entity); 26 | } 27 | 28 | return true; 29 | }; 30 | enumerator.ForEach(functor); 31 | 32 | return !points.empty(); 33 | } 34 | 35 | CTF2BotRDCollectPointsTask::CTF2BotRDCollectPointsTask(std::vector>&& points) : 36 | m_points(points), m_nav(CChaseNavigator::SubjectLeadType::DONT_LEAD_SUBJECT), m_iter(0U) 37 | { 38 | } 39 | 40 | TaskResult CTF2BotRDCollectPointsTask::OnTaskUpdate(CTF2Bot* bot) 41 | { 42 | CBaseEntity* next = nullptr; 43 | 44 | while (true) 45 | { 46 | if (m_iter >= m_points.size()) 47 | { 48 | return Done("No more points to collect!"); 49 | } 50 | 51 | next = m_points[m_iter].Get(); 52 | 53 | if (!next) 54 | { 55 | m_iter++; 56 | continue; 57 | } 58 | 59 | break; 60 | } 61 | 62 | CTF2BotPathCost cost(bot); 63 | m_nav.Update(bot, next, cost); 64 | 65 | return Continue(); 66 | } 67 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/rd/tf2bot_rd_collect_points_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_RD_COLLECT_POINTS_TASK_H_ 2 | #define __NAVBOT_TF2BOT_RD_COLLECT_POINTS_TASK_H_ 3 | 4 | class CTF2BotRDCollectPointsTask : public AITask 5 | { 6 | public: 7 | static bool IsPossible(CTF2Bot* bot, std::vector>& points); 8 | CTF2BotRDCollectPointsTask(std::vector>&& points); 9 | 10 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 11 | 12 | const char* GetName() const override { return "RDCollectPoints"; } 13 | 14 | private: 15 | std::vector> m_points; 16 | CChaseNavigator m_nav; 17 | std::size_t m_iter; 18 | }; 19 | 20 | #endif // !__NAVBOT_TF2BOT_RD_COLLECT_POINTS_TASK_H_ 21 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/rd/tf2bot_rd_defend_core_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_RD_DEFEND_CORE_TASK_H_ 2 | #define __NAVBOT_TF2BOT_RD_DEFEND_CORE_TASK_H_ 3 | 4 | class CTF2BotRDDefendCoreTask : public AITask 5 | { 6 | public: 7 | static bool IsPossible(CTF2Bot* bot, CBaseEntity** core); 8 | CTF2BotRDDefendCoreTask(CBaseEntity* core); 9 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 10 | 11 | const char* GetName() const override { return "RDDefendReactorCore"; } 12 | 13 | private: 14 | CHandle m_flag; 15 | CMeshNavigator m_nav; 16 | CountdownTimer m_repathtimer; 17 | }; 18 | 19 | #endif // !__NAVBOT_TF2BOT_RD_DEFEND_CORE_TASK_H_ 20 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/rd/tf2bot_rd_destroy_robots_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_RD_DESTROY_ROBOTS_TASK_H_ 2 | #define __NAVBOT_TF2BOT_RD_DESTROY_ROBOTS_TASK_H_ 3 | 4 | class CTF2BotRDDestroyRobotsTask : public AITask 5 | { 6 | public: 7 | static bool IsPossible(CTF2Bot* bot, std::vector>& robots); 8 | CTF2BotRDDestroyRobotsTask(std::vector>&& robots); 9 | 10 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 11 | 12 | TaskEventResponseResult OnOtherKilled(CTF2Bot* bot, CBaseEntity* pVictim, const CTakeDamageInfo& info) override; 13 | 14 | const char* GetName() const override { return "RDDestroyEnemyRobots"; } 15 | 16 | private: 17 | std::vector> m_robots; 18 | CChaseNavigator m_nav; 19 | std::size_t m_iter; 20 | }; 21 | 22 | #endif // !__NAVBOT_TF2BOT_RD_DESTROY_ROBOTS_TASK_H_ 23 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/rd/tf2bot_rd_monitor_task.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "tf2bot_rd_collect_points_task.h" 9 | #include "tf2bot_rd_destroy_robots_task.h" 10 | #include "tf2bot_rd_defend_core_task.h" 11 | #include "tf2bot_rd_steal_enemy_points_task.h" 12 | #include 13 | #include "tf2bot_rd_monitor_task.h" 14 | 15 | TaskResult CTF2BotRobotDestructionMonitorTask::OnTaskUpdate(CTF2Bot* bot) 16 | { 17 | std::vector> handles; 18 | 19 | if (CTF2BotRDDestroyRobotsTask::IsPossible(bot, handles)) 20 | { 21 | return PauseFor(new CTF2BotRDDestroyRobotsTask(std::move(handles)), "Going to destroy enemy robots!"); 22 | } 23 | 24 | if (CTF2BotRDCollectPointsTask::IsPossible(bot, handles)) 25 | { 26 | return PauseFor(new CTF2BotRDCollectPointsTask(std::move(handles)), "Collecting dropped points!"); 27 | } 28 | 29 | CBaseEntity* mycore = nullptr; 30 | 31 | if (CTF2BotRDDefendCoreTask::IsPossible(bot, &mycore)) 32 | { 33 | return PauseFor(new CTF2BotRDDefendCoreTask(mycore), "Defending stolen core!"); 34 | } 35 | 36 | CBaseEntity* enemyCore = nullptr; 37 | 38 | if (CTF2BotRDStealEnemyPointsTask::IsPossible(bot, &enemyCore)) 39 | { 40 | return PauseFor(new CTF2BotRDStealEnemyPointsTask(enemyCore), "Going to steal points from the enemy."); 41 | } 42 | 43 | return PauseFor(new CBotSharedRoamTask(bot, 8192.0f), "Nothing to do, roaming!"); 44 | } 45 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/rd/tf2bot_rd_monitor_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_RD_MONITOR_TASK_H_ 2 | #define __NAVBOT_TF2BOT_RD_MONITOR_TASK_H_ 3 | 4 | class CTF2BotRobotDestructionMonitorTask : public AITask 5 | { 6 | public: 7 | 8 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 9 | 10 | const char* GetName() const override { return "RobotDestructionMonitor"; } 11 | 12 | private: 13 | 14 | }; 15 | 16 | #endif // !__NAVBOT_TF2BOT_RD_MONITOR_TASK_H_ 17 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/rd/tf2bot_rd_steal_enemy_points_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_RD_STEAL_ENEMY_POINTS_TASK_H_ 2 | #define __NAVBOT_TF2BOT_RD_STEAL_ENEMY_POINTS_TASK_H_ 3 | 4 | class CTF2BotRDStealEnemyPointsTask : public AITask 5 | { 6 | public: 7 | static bool IsPossible(CTF2Bot* bot, CBaseEntity** flag); 8 | 9 | CTF2BotRDStealEnemyPointsTask(CBaseEntity* flag); 10 | 11 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 12 | 13 | const char* GetName() const override { return "RDStealEnemyPoints"; } 14 | 15 | private: 16 | CHandle m_flag; 17 | CMeshNavigator m_nav; 18 | CountdownTimer m_repathtimer; 19 | Vector m_homepos; 20 | bool m_washome; 21 | }; 22 | 23 | #endif // !__NAVBOT_TF2BOT_RD_STEAL_ENEMY_POINTS_TASK_H_ 24 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/specialdelivery/tf2bot_sd_deliver_flag.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_SD_DELIVER_FLAG_TASK_H_ 2 | #define __NAVBOT_TF2BOT_SD_DELIVER_FLAG_TASK_H_ 3 | 4 | class CTF2BotSDDeliverFlag : public AITask 5 | { 6 | public: 7 | CTF2BotSDDeliverFlag() : 8 | m_goal(0.0f, 0.0f, 0.0f) 9 | { 10 | m_capwasdisabled = false; 11 | } 12 | 13 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 14 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 15 | 16 | // Don't retreat or seek enemies while delivering the australium 17 | QueryAnswerType ShouldSeekAndDestroy(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_NO; } 18 | QueryAnswerType ShouldHurry(CBaseBot* me) override { return ANSWER_YES; } 19 | QueryAnswerType ShouldRetreat(CBaseBot* me) override { return ANSWER_NO; } 20 | 21 | const char* GetName() const override { return "DeliverAustralium"; } 22 | 23 | private: 24 | Vector m_goal; 25 | CMeshNavigator m_nav; 26 | CountdownTimer m_repathTimer; 27 | CHandle m_capzone; 28 | CHandle m_flagzone; 29 | bool m_capwasdisabled; 30 | }; 31 | 32 | #endif // !__NAVBOT_TF2BOT_SD_DELIVER_FLAG_TASK_H_ 33 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/specialdelivery/tf2bot_sd_wait_for_flag.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_SD_WAIT_FOR_FLAG_TASK_H_ 2 | #define __NAVBOT_TF2BOT_SD_WAIT_FOR_FLAG_TASK_H_ 3 | 4 | class CTF2BotSDWaitForFlagTask : public AITask 5 | { 6 | public: 7 | CTF2BotSDWaitForFlagTask() : 8 | m_flag(nullptr) 9 | { 10 | } 11 | 12 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 13 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 14 | 15 | const char* GetName() const override { return "WaitForAustralium"; } 16 | 17 | private: 18 | CHandle m_flag; 19 | CMeshNavigator m_nav; 20 | CountdownTimer m_repathTimer; 21 | }; 22 | 23 | #endif // !__NAVBOT_TF2BOT_SD_WAIT_FOR_FLAG_TASK_H_ 24 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/specialdelivery/tf2bot_special_delivery_monitor_task.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "bot/tf2/tf2bot.h" 12 | #include "tf2bot_special_delivery_monitor_task.h" 13 | #include "tf2bot_sd_deliver_flag.h" 14 | #include "tf2bot_sd_wait_for_flag.h" 15 | 16 | TaskResult CTF2BotSDMonitorTask::OnTaskUpdate(CTF2Bot* bot) 17 | { 18 | edict_t* item = bot->GetItem(); 19 | 20 | if (item) 21 | { 22 | const char* classname = gamehelpers->GetEntityClassname(item); 23 | 24 | if (std::strcmp(classname, "item_teamflag") == 0) 25 | { 26 | return PauseFor(new CTF2BotSDDeliverFlag, "I have the australium, going to deliver it!"); 27 | } 28 | } 29 | 30 | return PauseFor(new CTF2BotSDWaitForFlagTask, "Fetching the australium!"); 31 | } 32 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/specialdelivery/tf2bot_special_delivery_monitor_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_SPECIAL_DELIVERY_MONITOR_TASK_H_ 2 | #define __NAVBOT_TF2BOT_SPECIAL_DELIVERY_MONITOR_TASK_H_ 3 | 4 | class CTF2BotSDMonitorTask : public AITask 5 | { 6 | public: 7 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 8 | 9 | const char* GetName() const override { return "SpecialDeliveryMonitor"; } 10 | }; 11 | 12 | #endif // !__NAVBOT_TF2BOT_SPECIAL_DELIVERY_MONITOR_TASK_H_ 13 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/scenario/tf2bot_destroy_halloween_boss_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_DESTROY_HALLOWEEN_BOSS_TASK_H_ 2 | #define __NAVBOT_TF2BOT_DESTROY_HALLOWEEN_BOSS_TASK_H_ 3 | 4 | class CTF2BotDestroyHalloweenBossTask : public AITask 5 | { 6 | public: 7 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 8 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 9 | 10 | const char* GetName() const override { return "DestroyHalloweenBoss"; } 11 | private: 12 | CHandle m_boss; 13 | Vector m_goal; 14 | CMeshNavigator m_nav; 15 | CountdownTimer m_repathTimer; 16 | 17 | bool FindHalloweenBoss(); 18 | void UpdateBossPosition(CBaseEntity* boss); 19 | }; 20 | 21 | #endif // !__NAVBOT_TF2BOT_DESTROY_HALLOWEEN_BOSS_TASK_H_ 22 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/sniper/tf2bot_task_sniper_main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "tf2bot_task_sniper_main.h" 8 | #include "tf2bot_task_sniper_move_to_sniper_spot.h" 9 | #include "tf2bot_task_sniper_push.h" 10 | 11 | CTF2BotSniperMainTask::CTF2BotSniperMainTask() 12 | { 13 | } 14 | 15 | TaskResult CTF2BotSniperMainTask::OnTaskStart(CTF2Bot* bot, AITask* pastTask) 16 | { 17 | return Continue(); 18 | } 19 | 20 | TaskResult CTF2BotSniperMainTask::OnTaskUpdate(CTF2Bot* bot) 21 | { 22 | // aggressive sniper bots have 50% to push towards the objective 23 | if (bot->GetDifficultyProfile()->GetAggressiveness() >= 50 && CBaseBot::s_botrng.GetRandomInt(0, 1) == 1) 24 | { 25 | return PauseFor(new CTF2BotSniperPushTask, "Pushing to the objective!"); 26 | } 27 | 28 | /* time to go sniping */ 29 | return PauseFor(new CTF2BotSniperMoveToSnipingSpotTask, "Sniping!"); 30 | } 31 | 32 | TaskEventResponseResult CTF2BotSniperMainTask::OnFlagTaken(CTF2Bot* bot, CBaseEntity* player) 33 | { 34 | if (bot->GetEntity() == player) 35 | { 36 | switch (CTeamFortress2Mod::GetTF2Mod()->GetCurrentGameMode()) 37 | { 38 | case TeamFortress2::GameModeType::GM_CTF: 39 | { 40 | return TryPauseFor(new CTF2BotCTFDeliverFlagTask, PRIORITY_HIGH, "I have the flag!"); 41 | } 42 | case TeamFortress2::GameModeType::GM_SD: 43 | { 44 | return TryPauseFor(new CTF2BotSDDeliverFlag, PRIORITY_HIGH, "I have the australium!"); 45 | } 46 | default: 47 | break; 48 | } 49 | } 50 | 51 | return TryContinue(); 52 | } 53 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/sniper/tf2bot_task_sniper_main.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_SNIPER_MAIN_TASK_H_ 2 | #define __NAVBOT_TF2BOT_SNIPER_MAIN_TASK_H_ 3 | 4 | class CTF2BotSniperMainTask : public AITask 5 | { 6 | public: 7 | CTF2BotSniperMainTask(); 8 | 9 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 10 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 11 | 12 | TaskEventResponseResult OnFlagTaken(CTF2Bot* bot, CBaseEntity* player) override; 13 | 14 | // Don't chase enemies 15 | QueryAnswerType ShouldSeekAndDestroy(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_NO; } 16 | 17 | const char* GetName() const override { return "SniperMain"; } 18 | private: 19 | 20 | }; 21 | 22 | 23 | #endif // !__NAVBOT_TF2BOT_SNIPER_MAIN_TASK_H_ 24 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/sniper/tf2bot_task_sniper_move_to_sniper_spot.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2_TASK_SNIPER_MOVE_TO_SPOT_H_ 2 | #define NAVBOT_TF2_TASK_SNIPER_MOVE_TO_SPOT_H_ 3 | 4 | #include 5 | 6 | class CTF2Bot; 7 | class CTFWaypoint; 8 | 9 | class CTF2BotSniperMoveToSnipingSpotTask : public AITask 10 | { 11 | public: 12 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 13 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 14 | TaskResult OnTaskResume(CTF2Bot* bot, AITask* pastTask) override; 15 | 16 | const char* GetName() const override { return "SniperGoToSpot"; } 17 | 18 | private: 19 | Vector m_goal; 20 | CMeshNavigator m_nav; 21 | CountdownTimer m_repathTimer; 22 | CTFWaypoint* m_waypoint; 23 | bool m_sniping; 24 | 25 | void FindSniperSpot(CTF2Bot* bot); 26 | void GetRandomSnipingSpot(CTF2Bot* bot); 27 | void FilterWaypoints(CTF2Bot* bot, std::vector& waypoints); 28 | Vector GetRandomSnipingPosition(CTF2Bot* bot); 29 | Vector GetSnipingSearchStartPosition(CTF2Bot* bot); 30 | }; 31 | 32 | #endif // !NAVBOT_TF2_TASK_SNIPER_MOVE_TO_SPOT_H_ 33 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/sniper/tf2bot_task_sniper_push.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_SNIPER_PUSH_TASK_H_ 2 | #define __NAVBOT_TF2BOT_SNIPER_PUSH_TASK_H_ 3 | 4 | /** 5 | * @brief Task for snipers to aggressively push towards the objective. 6 | */ 7 | class CTF2BotSniperPushTask : public AITask 8 | { 9 | public: 10 | CTF2BotSniperPushTask(); 11 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 12 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 13 | void OnTaskEnd(CTF2Bot* bot, AITask* nextTask) override; 14 | 15 | TaskEventResponseResult OnMoveToSuccess(CTF2Bot* bot, CPath* path) override; 16 | 17 | // Custom attack behavior 18 | QueryAnswerType ShouldAttack(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_NO; } 19 | // I'm busy 20 | QueryAnswerType ShouldAssistTeammate(CBaseBot* me, CBaseEntity* teammate) override { return ANSWER_NO; } 21 | 22 | const char* GetName() const override { return "SniperPush"; } 23 | 24 | private: 25 | CountdownTimer m_endpushtimer; 26 | CountdownTimer m_repathtimer; 27 | CountdownTimer m_firetimer; 28 | CMeshNavigator m_nav; 29 | Vector m_goal; 30 | 31 | void SelectPushGoal(CTF2Bot* bot); 32 | }; 33 | 34 | 35 | #endif // !__NAVBOT_TF2BOT_SNIPER_PUSH_TASK_H_ 36 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/sniper/tf2bot_task_sniper_snipe_area.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_TASK_SNIPE_AREA_H_ 2 | #define NAVBOT_TF2BOT_TASK_SNIPE_AREA_H_ 3 | 4 | #include 5 | #include 6 | 7 | class CTF2Bot; 8 | 9 | class CTF2BotSniperSnipeAreaTask : public AITask 10 | { 11 | public: 12 | CTF2BotSniperSnipeAreaTask(CTFWaypoint* waypoint) 13 | { 14 | m_waypoint = waypoint; 15 | m_lookPoints.reserve(4); 16 | } 17 | 18 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 19 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 20 | void OnTaskEnd(CTF2Bot* bot, AITask* nextTask) override; 21 | bool OnTaskPause(CTF2Bot* bot, AITask* nextTask) override; 22 | 23 | const char* GetName() const override { return "SnipeArea"; } 24 | 25 | QueryAnswerType ShouldAttack(CBaseBot* me, const CKnownEntity* them) override; 26 | QueryAnswerType ShouldSwitchToWeapon(CBaseBot* me, const CBotWeapon* weapon) override { return ANSWER_NO; } 27 | // I'm busy 28 | QueryAnswerType ShouldAssistTeammate(CBaseBot* me, CBaseEntity* teammate) override { return ANSWER_NO; } 29 | 30 | private: 31 | CTFWaypoint* m_waypoint; 32 | CountdownTimer m_boredTimer; 33 | CountdownTimer m_changeAnglesTimer; 34 | std::vector m_lookPoints; 35 | CountdownTimer m_fireWeaponDelay; 36 | 37 | void BuildLookPoints(CTF2Bot* me); 38 | void EquipAndScope(CTF2Bot* me); 39 | }; 40 | 41 | #endif // !NAVBOT_TF2BOT_TASK_SNIPE_AREA_H_ 42 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/spy/tf2bot_spy_main_task.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "tf2bot_spy_main_task.h" 7 | #include "tf2bot_spy_tasks.h" 8 | 9 | AITask* CTF2BotSpyMainTask::InitialNextTask(CTF2Bot* bot) 10 | { 11 | return new CTF2BotSpyInfiltrateTask; 12 | } 13 | 14 | TaskResult CTF2BotSpyMainTask::OnTaskUpdate(CTF2Bot* bot) 15 | { 16 | if (GetNextTask() == nullptr) 17 | { 18 | return SwitchTo(new CTF2BotSpyMainTask, "Restarting!"); 19 | } 20 | 21 | return Continue(); 22 | } 23 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/spy/tf2bot_spy_main_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_SPY_MAIN_TASK_H_ 2 | #define __NAVBOT_TF2BOT_SPY_MAIN_TASK_H_ 3 | 4 | class CTF2BotSpyMainTask : public AITask 5 | { 6 | public: 7 | AITask* InitialNextTask(CTF2Bot* bot) override; 8 | 9 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 10 | 11 | 12 | const char* GetName() const override { return "SpyMain"; } 13 | private: 14 | 15 | }; 16 | 17 | 18 | #endif // !__NAVBOT_TF2BOT_SPY_MAIN_TASK_H_ 19 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/spy/tf2bot_spy_mvm_tasks.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_SPY_MVM_TASKS_H_ 2 | #define __NAVBOT_TF2BOT_SPY_MVM_TASKS_H_ 3 | 4 | class CTF2BotSpySapMvMRobotTask : public AITask 5 | { 6 | public: 7 | static bool IsPossible(CTF2Bot* bot); 8 | 9 | CTF2BotSpySapMvMRobotTask(CBaseEntity* target); 10 | 11 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 12 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 13 | 14 | QueryAnswerType ShouldAttack(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_NO; } 15 | QueryAnswerType ShouldSwitchToWeapon(CBaseBot* me, const CBotWeapon* weapon) override { return ANSWER_NO; } 16 | 17 | const char* GetName() const override { return "SpySapMvMRobot"; } 18 | 19 | private: 20 | CHandle m_target; 21 | CChaseNavigator m_nav; 22 | float* m_flEffectBarRegenTime; 23 | }; 24 | 25 | #endif // !__NAVBOT_TF2BOT_SPY_MVM_TASKS_H_ 26 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/tf2bot_attack.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_ATTACK_TASK_H_ 2 | #define NAVBOT_TF2BOT_ATTACK_TASK_H_ 3 | 4 | #include 5 | 6 | class CTF2Bot; 7 | 8 | class CTF2BotAttackTask : public AITask 9 | { 10 | public: 11 | CTF2BotAttackTask(CBaseEntity* entity, const float escapeTime = 5.0f, const float maxChaseTime = 60.0f); 12 | 13 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 14 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 15 | TaskResult OnTaskResume(CTF2Bot* bot, AITask* pastTask) override; 16 | 17 | // Always allow weapon switches and attacking 18 | QueryAnswerType ShouldAttack(CBaseBot* me, const CKnownEntity* them) override { return ANSWER_YES; } 19 | QueryAnswerType ShouldSwitchToWeapon(CBaseBot* me, const CBotWeapon* weapon) override { return ANSWER_YES; } 20 | 21 | const char* GetName() const override { return "Attack"; } 22 | private: 23 | CHandle m_target; 24 | CChaseNavigator m_nav; 25 | CountdownTimer m_escapeTimer; // timer to give up if the bot doesn't have LOS 26 | CountdownTimer m_expireTimer; // timer to give up if this ends up taking too much time 27 | float m_escapeDuration; 28 | float m_chaseDuration; 29 | }; 30 | 31 | #endif // !NAVBOT_TF2BOT_ATTACK_TASK_H_ 32 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/tf2bot_dead.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "tf2bot_maintask.h" 4 | #include "tf2bot_dead.h" 5 | 6 | TaskResult CTF2BotDeadTask::OnTaskUpdate(CTF2Bot* bot) 7 | { 8 | if (bot->IsAlive()) 9 | { 10 | return SwitchTo(new CTF2BotMainTask, "I'm alive!"); 11 | } 12 | 13 | return Continue(); 14 | } 15 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/tf2bot_dead.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_DEAD_TASK_H_ 2 | #define NAVBOT_TF2BOT_DEAD_TASK_H_ 3 | 4 | class CTF2Bot; 5 | 6 | class CTF2BotDeadTask : public AITask 7 | { 8 | public: 9 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 10 | 11 | const char* GetName() const override { return "Dead"; } 12 | }; 13 | 14 | #endif // !NAVBOT_TF2BOT_DEAD_TASK_H_ 15 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/tf2bot_find_ammo_task.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_FIND_AMMO_TASK_H_ 2 | #define NAVBOT_TF2BOT_FIND_AMMO_TASK_H_ 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | class CTF2BotFindAmmoTask : public AITask 10 | { 11 | public: 12 | enum class AmmoSource : uint8_t 13 | { 14 | NONE = 0, // none found 15 | AMMOPACK, // item_ammo* 16 | RESUPPLY, // resupply cabinet 17 | DISPENSER // dispenser 18 | }; 19 | 20 | static bool IsPossible(CTF2Bot* bot, CBaseEntity** source); 21 | 22 | CTF2BotFindAmmoTask(CBaseEntity* entity); 23 | CTF2BotFindAmmoTask(CBaseEntity* entity, int maxmetal); 24 | 25 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 26 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 27 | 28 | TaskEventResponseResult OnMoveToFailure(CTF2Bot* bot, CPath* path, IEventListener::MovementFailureType reason) override; 29 | TaskEventResponseResult OnMoveToSuccess(CTF2Bot* bot, CPath* path) override; 30 | 31 | const char* GetName() const override { return "FindAmmo"; } 32 | 33 | private: 34 | CountdownTimer m_repathtimer; 35 | CountdownTimer m_failsafetimer; 36 | CMeshNavigator m_nav; 37 | AmmoSource m_type; 38 | CHandle m_sourceentity; 39 | int m_metalLimit; 40 | bool m_isDroppedAmmo; 41 | 42 | bool IsSourceStillValid(CTF2Bot* me); 43 | }; 44 | 45 | #endif // !NAVBOT_TF2BOT_FIND_AMMO_TASK_H_ 46 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/tf2bot_find_health_task.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_FIND_HEALTH_TASK_H_ 2 | #define NAVBOT_TF2BOT_FIND_HEALTH_TASK_H_ 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | class CTF2BotFindHealthTask : public AITask 10 | { 11 | public: 12 | enum class HealthSource : uint8_t 13 | { 14 | NONE = 0, // none found 15 | HEALTHPACK, // item_health* 16 | RESUPPLY, // resupply cabinet 17 | DISPENSER // dispenser 18 | }; 19 | 20 | CTF2BotFindHealthTask(CBaseEntity* source); 21 | 22 | static bool IsPossible(CTF2Bot* bot, CBaseEntity** source); 23 | 24 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 25 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 26 | 27 | TaskEventResponseResult OnMoveToSuccess(CTF2Bot* bot, CPath* path) override; 28 | 29 | const char* GetName() const override { return "FindHealth"; } 30 | 31 | private: 32 | CountdownTimer m_failsafetimer; 33 | CMeshNavigatorAutoRepath m_nav; 34 | HealthSource m_type; 35 | CHandle m_sourceentity; 36 | 37 | bool IsSourceStillValid(CTF2Bot* me); 38 | }; 39 | 40 | #endif // !NAVBOT_TF2BOT_FIND_HEALTH_TASK_H_ -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/tf2bot_roam.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2_ROAM_TASK_H_ 2 | #define NAVBOT_TF2_ROAM_TASK_H_ 3 | 4 | #include 5 | #include 6 | 7 | class CTF2Bot; 8 | 9 | class CTF2BotRoamTask : public AITask 10 | { 11 | public: 12 | CTF2BotRoamTask() : m_hasgoal(false), m_failcount(0), m_goal(0.0f, 0.0f, 0.0f) {} 13 | CTF2BotRoamTask(const Vector& goal); 14 | 15 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 16 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 17 | TaskResult OnTaskResume(CTF2Bot* bot, AITask* pastTask) override; 18 | 19 | TaskEventResponseResult OnMoveToFailure(CTF2Bot* bot, CPath* path, IEventListener::MovementFailureType reason) override; 20 | TaskEventResponseResult OnMoveToSuccess(CTF2Bot* bot, CPath* path) override; 21 | 22 | const char* GetName() const override { return "Roaming"; } 23 | private: 24 | CMeshNavigator m_nav; 25 | Vector m_goal; 26 | CountdownTimer m_repathtimer; 27 | bool m_hasgoal; 28 | uint8_t m_failcount; 29 | 30 | bool FindRandomGoalPosition(CTF2Bot* me); 31 | }; 32 | 33 | #endif // !NAVBOT_TF2_ROAM_TASK_H_ 34 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/tf2bot_scenario_task.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2BOT_SCENARIO_MONITOR_TASK_H_ 2 | #define __NAVBOT_TF2BOT_SCENARIO_MONITOR_TASK_H_ 3 | 4 | class CTF2BotScenarioTask : public AITask 5 | { 6 | public: 7 | AITask* InitialNextTask(CTF2Bot* bot) override; 8 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 9 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 10 | 11 | static AITask* SelectScenarioTask(CTF2Bot* me, const bool skipClassBehavior = false); 12 | static AITask* SelectClassTask(CTF2Bot* me); 13 | 14 | TaskEventResponseResult OnVoiceCommand(CTF2Bot* bot, CBaseEntity* subject, int command) override; 15 | TaskEventResponseResult OnTruceChanged(CTF2Bot* bot, const bool enabled) override; 16 | 17 | const char* GetName() const override { return "Scenario"; } 18 | private: 19 | CountdownTimer m_respondToTeamMatesTimer; 20 | 21 | }; 22 | 23 | 24 | #endif // !__NAVBOT_TF2BOT_SCENARIO_MONITOR_TASK_H_ 25 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/tf2bot_setuptime.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_SETUP_TIME_TASK_H_ 2 | #define NAVBOT_TF2BOT_SETUP_TIME_TASK_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class CTF2BotSetupTimeTask : public AITask 9 | { 10 | public: 11 | CTF2BotSetupTimeTask() 12 | { 13 | m_action = IDLE; 14 | } 15 | 16 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 17 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 18 | void OnTaskEnd(CTF2Bot* bot, AITask* nextTask) override; 19 | 20 | const char* GetName() const override { return "SetupTime"; } 21 | 22 | private: 23 | 24 | enum SetupActions 25 | { 26 | IDLE = 0, 27 | TAUNT, 28 | LOOK, 29 | STARE, 30 | MELEE, 31 | KILLBIND, 32 | 33 | MAX_ACTIONS 34 | }; 35 | 36 | void SelectRandomTarget(CTF2Bot* me); 37 | 38 | SetupActions m_action; 39 | CountdownTimer m_nextActionTimer; 40 | CHandle m_target; 41 | CChaseNavigator m_nav; 42 | }; 43 | 44 | #endif // !NAVBOT_TF2BOT_SETUP_TIME_TASK_H_ 45 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/tf2bot_tactical.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_TACTICAL_TASK_H_ 2 | #define NAVBOT_TF2BOT_TACTICAL_TASK_H_ 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | class CTF2Bot; 9 | 10 | class CTF2BotTacticalTask : public AITask 11 | { 12 | public: 13 | AITask* InitialNextTask(CTF2Bot* bot) override; 14 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 15 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 16 | TaskResult OnTaskResume(CTF2Bot* bot, AITask* pastTask) override; 17 | 18 | QueryAnswerType ShouldRetreat(CBaseBot* me) override; 19 | 20 | const char* GetName() const override { return "Tactical"; } 21 | 22 | TaskEventResponseResult OnInjured(CTF2Bot* bot, const CTakeDamageInfo& info) override; 23 | TaskEventResponseResult OnVoiceCommand(CTF2Bot* bot, CBaseEntity* subject, int command) override; 24 | 25 | private: 26 | CountdownTimer m_ammochecktimer; 27 | CountdownTimer m_healthchecktimer; 28 | CountdownTimer m_teleportertimer; 29 | }; 30 | 31 | 32 | #endif // !NAVBOT_TF2BOT_TACTICAL_TASK_H_ 33 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/tf2bot_taunting.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "tf2bot_taunting.h" 7 | 8 | TaskResult CTF2BotTauntingTask::OnTaskStart(CTF2Bot* bot, AITask* pastTask) 9 | { 10 | m_endTauntTimer.StartRandom(6.0f, 12.0f); 11 | return Continue(); 12 | } 13 | 14 | TaskResult CTF2BotTauntingTask::OnTaskUpdate(CTF2Bot* bot) 15 | { 16 | if (m_endTauntTimer.IsElapsed()) 17 | { 18 | bot->DelayedFakeClientCommand("stop_taunt"); 19 | } 20 | 21 | if (!tf2lib::IsPlayerInCondition(bot->GetIndex(), TeamFortress2::TFCond::TFCond_Taunting)) 22 | { 23 | return Done("No longer taunting!"); 24 | } 25 | 26 | return Continue(); 27 | } 28 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/tf2bot_taunting.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_TAUNTING_TASK_H_ 2 | #define NAVBOT_TF2BOT_TAUNTING_TASK_H_ 3 | 4 | #include 5 | 6 | class CTF2BotTauntingTask : public AITask 7 | { 8 | public: 9 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 10 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 11 | 12 | const char* GetName() const override { return "Taunting"; } 13 | 14 | private: 15 | CountdownTimer m_endTauntTimer; 16 | }; 17 | 18 | 19 | #endif // !NAVBOT_TF2BOT_TAUNTING_TASK_H_ 20 | -------------------------------------------------------------------------------- /extension/bot/tf2/tasks/tf2bot_use_teleporter.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_TF2_BOT_USE_TELEPORTER_TASK_H_ 2 | #define __NAVBOT_TF2_BOT_USE_TELEPORTER_TASK_H_ 3 | 4 | class CTF2BotUseTeleporterTask : public AITask 5 | { 6 | public: 7 | CTF2BotUseTeleporterTask(CBaseEntity* teleporter); 8 | 9 | static bool IsPossible(CTF2Bot* bot, CBaseEntity** teleporter); 10 | 11 | TaskResult OnTaskStart(CTF2Bot* bot, AITask* pastTask) override; 12 | TaskResult OnTaskUpdate(CTF2Bot* bot) override; 13 | 14 | const char* GetName() const override { return "UseTeleporter"; } 15 | private: 16 | CHandle m_teleporter; 17 | CMeshNavigator m_nav; 18 | CountdownTimer m_repathtimer; 19 | CountdownTimer m_timeout; 20 | }; 21 | 22 | #endif // !__NAVBOT_TF2_BOT_USE_TELEPORTER_TASK_H_ 23 | -------------------------------------------------------------------------------- /extension/bot/tf2/tf2bot_behavior.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "tf2bot_behavior.h" 6 | 7 | #ifdef EXT_VPROF_ENABLED 8 | #include 9 | #endif // EXT_VPROF_ENABLED 10 | 11 | CTF2BotBehavior::CTF2BotBehavior(CBaseBot* bot) : IBehavior(bot) 12 | { 13 | m_manager = new AITaskManager(new CTF2BotMainTask); 14 | m_listeners.reserve(2); 15 | } 16 | 17 | CTF2BotBehavior::~CTF2BotBehavior() 18 | { 19 | m_listeners.clear(); 20 | delete m_manager; 21 | m_manager = nullptr; 22 | } 23 | 24 | void CTF2BotBehavior::Reset() 25 | { 26 | delete m_manager; 27 | m_manager = new AITaskManager(new CTF2BotMainTask); 28 | m_listeners.clear(); 29 | } 30 | 31 | void CTF2BotBehavior::Update() 32 | { 33 | #ifdef EXT_VPROF_ENABLED 34 | VPROF_BUDGET("CTF2BotBehavior::Update", "NavBot"); 35 | #endif // EXT_VPROF_ENABLED 36 | 37 | m_manager->Update(GetBot()); 38 | } 39 | 40 | std::vector* CTF2BotBehavior::GetListenerVector() 41 | { 42 | if (m_manager == nullptr) 43 | { 44 | return nullptr; 45 | } 46 | 47 | m_listeners.clear(); 48 | m_listeners.push_back(m_manager); 49 | 50 | return &m_listeners; 51 | } 52 | 53 | IDecisionQuery* CTF2BotBehavior::GetDecisionQueryResponder() 54 | { 55 | return m_manager; 56 | } 57 | -------------------------------------------------------------------------------- /extension/bot/tf2/tf2bot_behavior.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_BEHAVIOR_H_ 2 | #define NAVBOT_TF2BOT_BEHAVIOR_H_ 3 | #pragma once 4 | 5 | #include 6 | 7 | #include 8 | 9 | class CTF2Bot; 10 | 11 | class CTF2BotBehavior : public IBehavior 12 | { 13 | public: 14 | CTF2BotBehavior(CBaseBot* bot); 15 | ~CTF2BotBehavior() override; 16 | 17 | void Reset() override; 18 | void Update() override; 19 | 20 | std::vector* GetListenerVector() override; 21 | IDecisionQuery* GetDecisionQueryResponder() override; 22 | private: 23 | AITaskManager* m_manager; 24 | std::vector m_listeners; 25 | }; 26 | 27 | #endif // !NAVBOT_TF2BOT_BEHAVIOR_H_ 28 | -------------------------------------------------------------------------------- /extension/bot/tf2/tf2bot_controller.cpp: -------------------------------------------------------------------------------- 1 | #include "tf2bot_controller.h" 2 | 3 | CTF2BotPlayerController::CTF2BotPlayerController(CBaseBot* bot) : IPlayerController(bot) 4 | { 5 | } 6 | 7 | CTF2BotPlayerController::~CTF2BotPlayerController() 8 | { 9 | } 10 | -------------------------------------------------------------------------------- /extension/bot/tf2/tf2bot_controller.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2_PLAYER_CONTROLLER_H_ 2 | #define NAVBOT_TF2_PLAYER_CONTROLLER_H_ 3 | #pragma once 4 | 5 | #include 6 | 7 | class CTF2BotPlayerController : public IPlayerController 8 | { 9 | public: 10 | CTF2BotPlayerController(CBaseBot* bot); 11 | virtual ~CTF2BotPlayerController(); 12 | }; 13 | 14 | #endif // !NAVBOT_TF2_PLAYER_CONTROLLER_H_ 15 | -------------------------------------------------------------------------------- /extension/bot/tf2/tf2bot_inventory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "tf2bot.h" 4 | #include "tf2bot_inventory.h" 5 | 6 | CTF2BotInventory::CTF2BotInventory(CTF2Bot* bot) : 7 | IInventory(bot) 8 | { 9 | } 10 | 11 | CTF2BotInventory::~CTF2BotInventory() 12 | { 13 | } 14 | 15 | bool CTF2BotInventory::IsAmmoLow(const bool heldOnly) 16 | { 17 | CTF2Bot* me = GetBot(); 18 | 19 | if (me->GetMyClassType() == TeamFortress2::TFClassType::TFClass_Engineer) 20 | { 21 | if (me->GetAmmoOfIndex(static_cast(TeamFortress2::TF_AMMO_METAL)) < TeamFortress2::TF_DEFAULT_MAX_METAL) 22 | { 23 | return true; 24 | } 25 | } 26 | 27 | return IInventory::IsAmmoLow(heldOnly); 28 | } 29 | -------------------------------------------------------------------------------- /extension/bot/tf2/tf2bot_inventory.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2BOT_INVENTORY_INTERFACE_H_ 2 | #define NAVBOT_TF2BOT_INVENTORY_INTERFACE_H_ 3 | 4 | #include 5 | #include "tf2bot_weaponinfo.h" 6 | 7 | class CTF2BotInventory : public IInventory 8 | { 9 | public: 10 | CTF2BotInventory(CTF2Bot* bot); 11 | ~CTF2BotInventory(); 12 | 13 | bool IsAmmoLow(const bool heldOnly = true) override; 14 | 15 | const CTF2BotWeapon* GetActiveTFWeapon() const { return static_cast(IInventory::GetActiveBotWeapon()); } 16 | 17 | protected: 18 | CBotWeapon* CreateBotWeapon(CBaseEntity* weapon) override { return new CTF2BotWeapon(weapon); } 19 | 20 | private: 21 | }; 22 | 23 | #endif // !NAVBOT_TF2BOT_INVENTORY_INTERFACE_H_ 24 | -------------------------------------------------------------------------------- /extension/bot/tf2/tf2bot_sensor.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF2_SENSOR_INTERFACE_H_ 2 | #define NAVBOT_TF2_SENSOR_INTERFACE_H_ 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | class CTF2BotSensor : public ISensor 11 | { 12 | public: 13 | CTF2BotSensor(CBaseBot* bot); 14 | virtual ~CTF2BotSensor(); 15 | 16 | bool IsIgnored(CBaseEntity* entity) override; 17 | bool IsFriendly(CBaseEntity* entity) override; 18 | bool IsEnemy(CBaseEntity* entity) override; 19 | int GetKnownEntityTeamIndex(CKnownEntity* known) override; 20 | void OnTruceChanged(const bool enabled) override; 21 | 22 | private: 23 | std::unordered_set m_classname_filter; 24 | 25 | bool IsPlayerIgnoredInternal(CBaseEntity* entity); 26 | bool IgnoredConditionsInternal(CBaseEntity* player); 27 | 28 | inline void AddClassnametoFilter(const char* classname) 29 | { 30 | m_classname_filter.emplace(classname); 31 | } 32 | 33 | bool IsClassnameIgnored(const char* classname); 34 | }; 35 | 36 | #endif // !NAVBOT_TF2_SENSOR_INTERFACE_H_ 37 | -------------------------------------------------------------------------------- /extension/concommands_bots.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | CON_COMMAND(sm_navbot_add, "Adds a Nav Bot to the game.") 10 | { 11 | if (!extmanager->AreBotsSupported()) 12 | { 13 | Msg("Bot support is disabled! Check SourceMod logs for more information. \n"); 14 | return; 15 | } 16 | 17 | if (!TheNavMesh->IsLoaded()) 18 | { 19 | Warning("Nav Mesh not loaded, bots will not be able to move! \n"); 20 | } 21 | 22 | if (args.ArgC() < 2) 23 | { 24 | extmanager->AddBot(nullptr, nullptr); 25 | } 26 | else 27 | { 28 | std::string botname(args[1]); 29 | extmanager->AddBot(&botname, nullptr); 30 | } 31 | } 32 | 33 | CON_COMMAND(sm_navbot_kick, "Removes a Nav Bot from the game.") 34 | { 35 | if (args.ArgC() < 2) 36 | { 37 | extmanager->RemoveRandomBot("Nav Bot: Kicked by admin command."); 38 | return; 39 | } 40 | 41 | if (strncasecmp(args[1], "all", 3) == 0) 42 | { 43 | extmanager->RemoveAllBots("Nav Bot: Kicked by admin command."); 44 | return; 45 | } 46 | 47 | std::string targetname(args[1]); 48 | auto functor = [&targetname](CBaseBot* bot) { 49 | auto gp = playerhelpers->GetGamePlayer(bot->GetIndex()); 50 | 51 | if (gp) 52 | { 53 | auto szname = gp->GetName(); 54 | 55 | if (szname) 56 | { 57 | std::string botname(szname); 58 | 59 | if (botname.find(targetname) != std::string::npos) // partial name search 60 | { 61 | gp->Kick("Nav Bot: Kicked by admin command."); 62 | } 63 | } 64 | } 65 | }; 66 | extmanager->ForEachBot(functor); 67 | } 68 | -------------------------------------------------------------------------------- /extension/entities/basecombatchar.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "basecombatchar.h" 4 | 5 | entities::HBaseCombatCharacter::HBaseCombatCharacter(edict_t* edict) : HBaseEntity(edict) 6 | { 7 | } 8 | 9 | entities::HBaseCombatCharacter::HBaseCombatCharacter(CBaseEntity* entity) : HBaseEntity(entity) 10 | { 11 | } 12 | 13 | edict_t* entities::HBaseCombatCharacter::GetActiveWeapon() const 14 | { 15 | int me = GetIndex(); 16 | int weapon; 17 | 18 | if (entprops->GetEntPropEnt(me, Prop_Send, "m_hActiveWeapon", weapon)) 19 | { 20 | return gamehelpers->EdictOfIndex(weapon); 21 | } 22 | 23 | return nullptr; 24 | } 25 | 26 | bool entities::HBaseCombatCharacter::HasWeapon(const char* classname) const 27 | { 28 | int me = GetIndex(); 29 | 30 | for (int i = 0; i < MAX_WEAPONS; i++) 31 | { 32 | int weapon; 33 | 34 | if (!entprops->GetEntPropEnt(me, Prop_Send, "m_hMyWeapons", weapon, i)) 35 | continue; 36 | 37 | edict_t* entity = gamehelpers->EdictOfIndex(weapon); 38 | 39 | if (!entity) 40 | continue; 41 | 42 | auto name = gamehelpers->GetEntityClassname(entity); 43 | 44 | if (!name) 45 | continue; 46 | 47 | if (strcasecmp(name, classname) == 0) 48 | { 49 | return true; 50 | } 51 | } 52 | 53 | return false; 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /extension/entities/basecombatchar.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_ENTITIES_BCC_H_ 2 | #define NAVBOT_ENTITIES_BCC_H_ 3 | #pragma once 4 | 5 | #include 6 | 7 | namespace entities 8 | { 9 | class HBaseCombatCharacter : public HBaseEntity 10 | { 11 | public: 12 | HBaseCombatCharacter(edict_t* edict); 13 | HBaseCombatCharacter(CBaseEntity* entity); 14 | 15 | edict_t* GetActiveWeapon() const; 16 | bool HasWeapon(const char* classname) const; 17 | }; 18 | } 19 | 20 | #endif // !NAVBOT_ENTITIES_BCC_H_ 21 | -------------------------------------------------------------------------------- /extension/entities/basecombatweapon.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_ENTITIES_BASE_COMBAT_WEAPON_H_ 2 | #define NAVBOT_ENTITIES_BASE_COMBAT_WEAPON_H_ 3 | 4 | #include 5 | 6 | struct edict_t; 7 | 8 | namespace entities 9 | { 10 | class HBaseCombatWeapon : public HBaseEntity 11 | { 12 | public: 13 | HBaseCombatWeapon(edict_t* entity); 14 | HBaseCombatWeapon(CBaseEntity* entity); 15 | 16 | int GetClip1() const; 17 | int GetClip2() const; 18 | int GetPrimaryAmmoType() const; 19 | int GetSecondaryAmmoType() const; 20 | int GetState() const; 21 | int GetOwnerIndex() const; 22 | edict_t* GetOwner() const; 23 | bool IsOnGround() const; 24 | bool IsCarried() const; 25 | bool IsActive() const; 26 | }; 27 | } 28 | 29 | 30 | #endif // !NAVBOT_ENTITIES_BASE_COMBAT_WEAPON_H_ 31 | 32 | -------------------------------------------------------------------------------- /extension/entities/worldspawn.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "worldspawn.h" 4 | 5 | Vector entities::HWorld::GetWorldMins() const 6 | { 7 | Vector result; 8 | entprops->GetEntPropVector(GetIndex(), Prop_Data, "m_WorldMins", result); 9 | return result; 10 | } 11 | 12 | Vector entities::HWorld::GetWorldMaxs() const 13 | { 14 | Vector result; 15 | entprops->GetEntPropVector(GetIndex(), Prop_Data, "m_WorldMaxs", result); 16 | return result; 17 | } 18 | -------------------------------------------------------------------------------- /extension/entities/worldspawn.h: -------------------------------------------------------------------------------- 1 | #ifndef SMNAV_ENTITIES_WORLD_SPAWN_H_ 2 | #define SMNAV_ENTITIES_WORLD_SPAWN_H_ 3 | 4 | #include "baseentity.h" 5 | 6 | namespace entities 7 | { 8 | class HWorld : public HBaseEntity 9 | { 10 | public: 11 | HWorld(edict_t* entity) : HBaseEntity(entity) {} 12 | HWorld(CBaseEntity* entity) : HBaseEntity(entity) {} 13 | 14 | Vector GetWorldMins() const; 15 | Vector GetWorldMaxs() const; 16 | }; 17 | } 18 | 19 | #endif // !SMNAV_ENTITIES_WORLD_SPAWN_H_ 20 | -------------------------------------------------------------------------------- /extension/mods/blackmesa/blackmesadm_mod.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BLACKMESA_DEATHMATCH_MOD_H_ 2 | #define NAVBOT_BLACKMESA_DEATHMATCH_MOD_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "blackmesa_shareddefs.h" 9 | 10 | class CBlackMesaDeathmatchMod : public CBaseMod 11 | { 12 | public: 13 | CBlackMesaDeathmatchMod(); 14 | ~CBlackMesaDeathmatchMod() override; 15 | 16 | static CBlackMesaDeathmatchMod* GetBMMod(); 17 | 18 | void FireGameEvent(IGameEvent* event) override; 19 | void PostCreation() override; 20 | // Mod name (IE: Team Fortress 2) 21 | const char* GetModName() override { return "Black Mesa Deathmatch"; } 22 | // Mod ID 23 | Mods::ModType GetModType() override { return Mods::ModType::MOD_BLACKMESA; } 24 | CBaseBot* AllocateBot(edict_t* edict) override; 25 | CNavMesh* NavMeshFactory() override; 26 | void OnMapStart() override; 27 | void OnRoundStart() override; 28 | bool IsTeamPlay() const { return m_isTeamPlay; } 29 | int GetMaxCarryForAmmoType(blackmesa::BMAmmoIndex index) const { return m_maxCarry[static_cast(index)]; } 30 | const std::pair* GetRandomPlayerModel() const; 31 | 32 | private: 33 | bool m_isTeamPlay; 34 | std::array m_maxCarry; 35 | std::vector> m_playermodels; // pair of model name and skin count 36 | 37 | void BuildMaxCarryArray(); 38 | void ParsePlayerModelsConfigFile(); 39 | }; 40 | 41 | #endif // !NAVBOT_BLACKMESA_DEATHMATCH_MOD_H_ 42 | -------------------------------------------------------------------------------- /extension/mods/blackmesa/nav/bm_nav_mesh.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "bm_nav_mesh.h" 4 | 5 | CBlackMesaNavMesh::CBlackMesaNavMesh() : 6 | CNavMesh() 7 | { 8 | AddWalkableEntity("info_player_deathmatch"); 9 | AddWalkableEntity("info_player_marine"); 10 | AddWalkableEntity("info_player_scientist"); 11 | 12 | navgenparams->half_human_width = 16.0f; 13 | navgenparams->half_human_height = 35.0f; 14 | navgenparams->human_height = 71.0f; 15 | navgenparams->human_crouch_height = 36.0f; 16 | navgenparams->human_eye_height = 72.0f; 17 | navgenparams->human_crouch_eye_height = 36.0f; 18 | navgenparams->jump_height = 49.0f; 19 | navgenparams->jump_crouch_height = 70.0f; 20 | navgenparams->climb_up_height = 70.0f; 21 | navgenparams->death_drop = 300.0f; // experimental 22 | } 23 | 24 | CBlackMesaNavMesh::~CBlackMesaNavMesh() 25 | { 26 | } 27 | 28 | unsigned int CBlackMesaNavMesh::GetGenerationTraceMask(void) const 29 | { 30 | return MASK_PLAYERSOLID_BRUSHONLY; 31 | } 32 | -------------------------------------------------------------------------------- /extension/mods/blackmesa/nav/bm_nav_mesh.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BLACK_MESA_NAV_MESH_H_ 2 | #define NAVBOT_BLACK_MESA_NAV_MESH_H_ 3 | 4 | #include 5 | 6 | class CBlackMesaNavMesh : public CNavMesh 7 | { 8 | public: 9 | CBlackMesaNavMesh(); 10 | ~CBlackMesaNavMesh() override; 11 | 12 | unsigned int GetGenerationTraceMask(void) const override; 13 | }; 14 | 15 | #endif // !NAVBOT_BLACK_MESA_NAV_MESH_H_ 16 | -------------------------------------------------------------------------------- /extension/mods/dods/dods_shareddefs.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_DODS_SHAREDDEFS_H_ 2 | #define __NAVBOT_DODS_SHAREDDEFS_H_ 3 | 4 | namespace dayofdefeatsource 5 | { 6 | enum DoDTeam : int 7 | { 8 | DODTEAM_UNASSIGNED = 0, 9 | DODTEAM_SPECTATOR, 10 | DODTEAM_ALLIES, 11 | DODTEAM_AXIS 12 | }; 13 | 14 | enum DoDClassType : int 15 | { 16 | DODCLASS_INVALID = -1, 17 | DODCLASS_RIFLEMAN = 0, 18 | DODCLASS_ASSAULT, 19 | DODCLASS_SUPPORT, 20 | DODCLASS_SNIPER, 21 | DODCLASS_MACHINEGUNNER, 22 | DODCLASS_ROCKET, 23 | 24 | NUM_DOD_CLASSES 25 | }; 26 | 27 | enum DoDBombTargetState : int 28 | { 29 | BOMB_TARGET_INACTIVE = 0, // disabled and invisible 30 | BOMB_TARGET_ACTIVE, // visible, bomb can be planted here 31 | BOMB_TARGET_ARMED, // visible, bomb is planted and ticking down 32 | 33 | NUM_BOMB_TARGET_STATES 34 | }; 35 | 36 | enum DoDRoundState : int 37 | { 38 | DODROUNDSTATE_INIT = 0, 39 | DODROUNDSTATE_PREGAME, 40 | DODROUNDSTATE_STARTGAME, 41 | DODROUNDSTATE_PREROUND, 42 | DODROUNDSTATE_ROUNDRUNNING, 43 | DODROUNDSTATE_ALLIES_WIN, 44 | DODROUNDSTATE_AXIS_WIN, 45 | DODROUNDSTATE_RESTART, 46 | DODROUNDSTATE_GAME_OVER, 47 | 48 | NUM_DOD_ROUND_STATES 49 | }; 50 | 51 | constexpr int INVALID_CONTROL_POINT = -1; 52 | constexpr float DOD_PLAYER_STANDING_HEIGHT = 72.0f; 53 | constexpr float DOD_PLAYER_CROUCHING_HEIGHT = 45.0f; 54 | constexpr float DOD_PLAYER_PRONE_HEIGHT = 24.0f; 55 | } 56 | 57 | #endif // !__NAVBOT_DODS_SHAREDDEFS_H_ 58 | -------------------------------------------------------------------------------- /extension/mods/dods/dodslib.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_DODS_LIB_H_ 2 | #define __NAVBOT_DODS_LIB_H_ 3 | 4 | #include "dods_shareddefs.h" 5 | 6 | namespace dodslib 7 | { 8 | dayofdefeatsource::DoDTeam GetDoDTeam(CBaseEntity* entity); 9 | dayofdefeatsource::DoDClassType GetPlayerClassType(CBaseEntity* player); 10 | /** 11 | * @brief Given a class type and team, return the client command to select it. 12 | * @param classtype Class to select. 13 | * @param team From which team. 14 | * @return Client command name to join the given class. 15 | */ 16 | const char* GetJoinClassCommand(dayofdefeatsource::DoDClassType classtype, dayofdefeatsource::DoDTeam team); 17 | /** 18 | * @brief Reads the control point index from the entity's memory. 19 | * @param entity Entity to read. Must be a dod_control_point. 20 | * @return Control point index. Returns -1 on failure. 21 | */ 22 | int GetControlPointIndex(CBaseEntity* entity); 23 | dayofdefeatsource::DoDRoundState GetRoundState(); 24 | 25 | inline const char* GetDoDTeamName(dayofdefeatsource::DoDTeam team) 26 | { 27 | switch (team) 28 | { 29 | case dayofdefeatsource::DODTEAM_SPECTATOR: 30 | return "SPECTATOR"; 31 | case dayofdefeatsource::DODTEAM_ALLIES: 32 | return "ALLIES"; 33 | case dayofdefeatsource::DODTEAM_AXIS: 34 | return "AXIS"; 35 | default: 36 | return "UNASSIGNED"; 37 | } 38 | } 39 | } 40 | 41 | 42 | #endif // !__NAVBOT_DODS_LIB_H_ 43 | -------------------------------------------------------------------------------- /extension/mods/dods/nav/dods_nav_area.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dods_nav_mesh.h" 3 | #include "dods_nav_area.h" 4 | 5 | CDODSNavArea::CDODSNavArea(unsigned int place) : 6 | CNavArea(place) 7 | { 8 | } 9 | 10 | CDODSNavArea::~CDODSNavArea() 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /extension/mods/dods/nav/dods_nav_area.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_DODS_NAV_AREA_H_ 2 | #define __NAVBOT_DODS_NAV_AREA_H_ 3 | 4 | #include 5 | 6 | class CDODSNavArea : public CNavArea 7 | { 8 | public: 9 | CDODSNavArea(unsigned int place); 10 | ~CDODSNavArea() override; 11 | 12 | 13 | private: 14 | 15 | }; 16 | 17 | #endif // !__NAVBOT_DODS_NAV_AREA_H_ 18 | -------------------------------------------------------------------------------- /extension/mods/dods/nav/dods_nav_mesh.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dods_nav_area.h" 3 | #include "dods_nav_mesh.h" 4 | 5 | CDODSNavMesh::CDODSNavMesh() : 6 | CNavMesh() 7 | { 8 | AddWalkableEntity("dod_bomb_dispenser", true); 9 | AddWalkableEntity("dod_bomb_target", false); 10 | AddWalkableEntity("dod_capture_area", true); 11 | AddWalkableEntity("dod_location", false); 12 | AddWalkableEntity("dod_control_point", false); 13 | AddWalkableEntity("info_player_allies", false); 14 | AddWalkableEntity("info_player_axis", false); 15 | AddWalkableEntity("func_team_wall", true); 16 | AddWalkableEntity("func_teamblocker", true); 17 | 18 | navgenparams->half_human_width = 16.0f; 19 | navgenparams->half_human_height = 35.0f; 20 | navgenparams->human_height = 71.0f; 21 | navgenparams->human_crouch_height = 45.0f; 22 | navgenparams->human_eye_height = 72.0f; 23 | navgenparams->human_crouch_eye_height = 34.0f; 24 | navgenparams->jump_height = 49.0f; 25 | navgenparams->jump_crouch_height = 70.0f; 26 | navgenparams->climb_up_height = 200.0f; 27 | navgenparams->death_drop = 250.0f; 28 | 29 | // no need to listen for round start events, mod notify us 30 | } 31 | 32 | CDODSNavMesh::~CDODSNavMesh() 33 | { 34 | } 35 | 36 | unsigned int CDODSNavMesh::GetGenerationTraceMask(void) const 37 | { 38 | return MASK_PLAYERSOLID_BRUSHONLY; 39 | } 40 | 41 | CNavArea* CDODSNavMesh::CreateArea(void) const 42 | { 43 | return new CDODSNavArea(GetNavPlace()); 44 | } 45 | -------------------------------------------------------------------------------- /extension/mods/dods/nav/dods_nav_mesh.h: -------------------------------------------------------------------------------- 1 | #ifndef __NAVBOT_DODS_NAV_MESH_H_ 2 | #define __NAVBOT_DODS_NAV_MESH_H_ 3 | 4 | #include 5 | 6 | class CDODSNavArea; 7 | 8 | class CDODSNavMesh : public CNavMesh 9 | { 10 | public: 11 | CDODSNavMesh(); 12 | ~CDODSNavMesh() override; 13 | 14 | unsigned int GetGenerationTraceMask(void) const override; 15 | CNavArea* CreateArea(void) const override; 16 | 17 | private: 18 | 19 | }; 20 | 21 | #endif // !__NAVBOT_DODS_NAV_MESH_H_ -------------------------------------------------------------------------------- /extension/mods/gamemods_shared.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_GAME_MODS_SHARED_H_ 2 | #define NAVBOT_GAME_MODS_SHARED_H_ 3 | #pragma once 4 | 5 | // Shared data between all mods 6 | 7 | namespace Mods 8 | { 9 | /* If you're adding a new mod and it doesn't exists, just add it to the bottom of the enum, before LAST_MOD_TYPE */ 10 | 11 | // Game/Mod IDs 12 | enum ModType : int 13 | { 14 | MOD_ALL = -2, // Indicate that something should apply for all mods 15 | MOD_INVALID_ID = -1, // Invalid/Unknown mod 16 | MOD_BASE = 0, // Generic mod 17 | MOD_TF2, // Team Fortress 2 18 | MOD_CSS, // Counter-Strike: Source 19 | MOD_DODS, // Day of Defeat: Source 20 | MOD_HL2DM, // Half-Life 2: Deathmatch 21 | MOD_HL1DM, // Half-Life Deathmatch Source 22 | MOD_BLACKMESA, // Black Mesa Deathmatch 23 | 24 | LAST_MOD_TYPE 25 | }; 26 | } 27 | 28 | 29 | #endif // !NAVBOT_GAME_MODS_SHARED_H_ -------------------------------------------------------------------------------- /extension/mods/hl2dm/hl2dm_mod.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "hl2dm_mod.h" 4 | 5 | CHalfLife2DeathMatchMod::CHalfLife2DeathMatchMod() : 6 | CBaseMod() 7 | { 8 | } 9 | 10 | CHalfLife2DeathMatchMod::~CHalfLife2DeathMatchMod() 11 | { 12 | } 13 | 14 | CBaseBot* CHalfLife2DeathMatchMod::AllocateBot(edict_t* edict) 15 | { 16 | return new CHL2DMBot(edict); 17 | } 18 | -------------------------------------------------------------------------------- /extension/mods/hl2dm/hl2dm_mod.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_HALFLIFE2DEATHMATCH_MOD_H_ 2 | #define NAVBOT_HALFLIFE2DEATHMATCH_MOD_H_ 3 | 4 | #include 5 | 6 | class CHalfLife2DeathMatchMod : public CBaseMod 7 | { 8 | public: 9 | CHalfLife2DeathMatchMod(); 10 | ~CHalfLife2DeathMatchMod() override; 11 | 12 | const char* GetModName() override { return "Half-Life 2: Deathmatch"; } 13 | Mods::ModType GetModType() override { return Mods::ModType::MOD_HL2DM; } 14 | 15 | CBaseBot* AllocateBot(edict_t* edict) override; 16 | 17 | private: 18 | 19 | }; 20 | 21 | 22 | #endif // !NAVBOT_HALFLIFE2DEATHMATCH_MOD_H_ 23 | -------------------------------------------------------------------------------- /extension/mods/tf2/nav/tfnav_waypoint.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_TF_NAV_MESH_H_ 2 | #define NAVBOT_TF_NAV_MESH_H_ 3 | 4 | #include 5 | 6 | class CTF2Bot; 7 | 8 | class CTFWaypoint : public CWaypoint 9 | { 10 | public: 11 | static constexpr int NO_CONTROL_POINT = -1; 12 | 13 | CTFWaypoint(); 14 | ~CTFWaypoint() override; 15 | 16 | enum TFHint : unsigned int 17 | { 18 | TFHINT_NONE = 0, 19 | TFHINT_GUARD, // Guard/Defend position 20 | TFHINT_SNIPER, // Sniper spot 21 | TFHINT_SENTRYGUN, // Sentry gun spot 22 | TFHINT_DISPENSER, // Dispenser spot 23 | TFHINT_TELE_ENTRANCE, // Tele entrance 24 | TFHINT_TELE_EXIT, // Tele exit 25 | 26 | MAX_TFHINT_TYPES 27 | }; 28 | 29 | static const char* TFHintToString(CTFWaypoint::TFHint hint); 30 | static bool IsValidTFHint(long long hint) 31 | { 32 | return hint >= TFHINT_NONE && hint < MAX_TFHINT_TYPES; 33 | } 34 | 35 | static CTFWaypoint::TFHint StringToTFHint(const char* szName); 36 | 37 | void Save(std::fstream& filestream, uint32_t version) override; 38 | NavErrorType Load(std::fstream& filestream, uint32_t version, uint32_t subVersion) override; 39 | 40 | bool IsAvailableToTeam(const int teamNum) const override; 41 | 42 | void SetControlPointIndex(int val = CTFWaypoint::NO_CONTROL_POINT) { m_cpindex = val; } 43 | int GetControlPointIndex() const { return m_cpindex; } 44 | 45 | void SetTFHint(CTFWaypoint::TFHint hint) { m_tfhint = hint; } 46 | CTFWaypoint::TFHint GetTFHint() const { return m_tfhint; } 47 | // Checks if the given bot can 48 | bool CanBuildHere(CTF2Bot* bot) const; 49 | 50 | private: 51 | int m_cpindex; // Control point index assigned to this waypoint 52 | TFHint m_tfhint; // TF2 hint assigned to this waypoint 53 | 54 | void DrawModText() const override; 55 | }; 56 | 57 | #endif // !NAVBOT_TF_NAV_MESH_H_ -------------------------------------------------------------------------------- /extension/mods/tf2/nav/tfnavmesh.h: -------------------------------------------------------------------------------- 1 | #ifndef SMNAV_TF_NAV_MESH_H_ 2 | #define SMNAV_TF_NAV_MESH_H_ 3 | #pragma once 4 | 5 | 6 | #include 7 | 8 | class CountdownTimer; 9 | class CTFWaypoint; 10 | class CTFNavArea; 11 | 12 | class CTFNavMesh : public CNavMesh 13 | { 14 | public: 15 | CTFNavMesh(); 16 | virtual ~CTFNavMesh(); 17 | 18 | void FireGameEvent(IGameEvent* event) override; 19 | virtual void OnRoundRestart(void) override; 20 | virtual CNavArea* CreateArea(void) const override; 21 | virtual uint32_t GetSubVersionNumber(void) const override; 22 | // Use nav mesh for climbing, players are limited when it comes to climbing 23 | virtual bool IsAuthoritative(void) const override { return true; } 24 | virtual unsigned int GetGenerationTraceMask(void) const override; 25 | 26 | virtual void Update() override; 27 | 28 | virtual bool Save(void) override; 29 | 30 | // Returns a random nav area marked with the frontline attribute for MvM 31 | CTFNavArea* GetRandomFrontLineArea() const; 32 | // Returns a random spawn room exit area of a given team 33 | CTFNavArea* GetRandomSpawnRoomExitArea(int team) const; 34 | protected: 35 | void PostCustomAnalysis(void) override; 36 | 37 | // Creates a new waypoint instance 38 | std::shared_ptr CreateWaypoint() const override; 39 | 40 | private: 41 | static constexpr auto NAV_SPAWNROOM_UPDATE_INTERVAL = 10.0f; 42 | CountdownTimer m_spawnroomupdatetimer; 43 | 44 | void UpdateDebugDraw(); 45 | }; 46 | 47 | inline uint32_t CTFNavMesh::GetSubVersionNumber(void) const 48 | { 49 | /* 50 | * Sub version 51 | * 1: Initial TF Nav Mesh implementation 52 | */ 53 | 54 | return 1; 55 | } 56 | 57 | inline CTFNavMesh* TheTFNavMesh() 58 | { 59 | return reinterpret_cast(TheNavMesh); 60 | } 61 | 62 | #endif // !SMNAV_TF_NAV_MESH_H_ 63 | 64 | -------------------------------------------------------------------------------- /extension/natives.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_NATIVES_H_ 2 | #define NAVBOT_NATIVES_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "natives/bots.h" 9 | #include "natives/interfaces/path.h" 10 | 11 | namespace natives 12 | { 13 | void setup(std::vector& nv); 14 | cell_t IsNavBot(IPluginContext* context, const cell_t* params); 15 | cell_t AddNavBot(IPluginContext* context, const cell_t* params); 16 | cell_t IsNavMeshLoaded(IPluginContext* context, const cell_t* params); 17 | cell_t FireNavBotSoundEvent(IPluginContext* context, const cell_t* params); 18 | } 19 | 20 | 21 | 22 | 23 | #endif // !NAVBOT_NATIVES_H_ 24 | -------------------------------------------------------------------------------- /extension/natives/bots.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BOTS_NATIVES_H_ 2 | #define NAVBOT_BOTS_NATIVES_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace natives::bots 9 | { 10 | void setup(std::vector& nv); 11 | cell_t AddNavBotMM(IPluginContext* context, const cell_t* params); 12 | cell_t AttachNavBot(IPluginContext* context, const cell_t* params); 13 | cell_t IsPluginBot(IPluginContext* context, const cell_t* params); 14 | cell_t SetSkillLevel(IPluginContext* context, const cell_t* params); 15 | cell_t GetNavBotByIndex(IPluginContext* context, const cell_t* params); 16 | cell_t SetRunPlayerCommands(IPluginContext* context, const cell_t* params); 17 | } 18 | 19 | #endif // !NAVBOT_BOTS_NATIVES_H_ 20 | -------------------------------------------------------------------------------- /extension/natives/interfaces/path.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_BOT_INTERFACE_PATH_NATIVES_H_ 2 | #define NAVBOT_BOT_INTERFACE_PATH_NATIVES_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace natives::bots::interfaces::path 9 | { 10 | void setup(std::vector& nv); 11 | cell_t CreateNewPath(IPluginContext* context, const cell_t* params); 12 | cell_t DestroyNavigator(IPluginContext* context, const cell_t* params); 13 | cell_t UpdateNavigator(IPluginContext* context, const cell_t* params); 14 | cell_t IsValid(IPluginContext* context, const cell_t* params); 15 | cell_t ComputeToPos(IPluginContext* context, const cell_t* params); 16 | cell_t GetMoveGoal(IPluginContext* context, const cell_t* params); 17 | } 18 | 19 | #endif // !NAVBOT_BOT_INTERFACE_PATH_NATIVES_H_ 20 | -------------------------------------------------------------------------------- /extension/navbot.autoload: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caxanga334/NavBot/c8c219aa9b2c84222480ff03004a46afa7d56390/extension/navbot.autoload -------------------------------------------------------------------------------- /extension/navmesh/nav_consts.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_NAV_MESH_CONSTS_H_ 2 | #define NAVBOT_NAV_MESH_CONSTS_H_ 3 | #pragma once 4 | 5 | constexpr int NAV_TEAM_ANY = -2; 6 | constexpr unsigned int NAV_TEAMS_ARRAY_SIZE = 8U; // array size for per team data, max teams is 32, until we see a mod use more than 5 teams, we will use 8. 7 | 8 | #endif // !NAVBOT_NAV_MESH_CONSTS_H_ 9 | 10 | -------------------------------------------------------------------------------- /extension/navmesh/nav_params.cpp: -------------------------------------------------------------------------------- 1 | #include "nav.h" 2 | 3 | // Default values goes here. 4 | // From: https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/game/server/nav.h 5 | // DO NOT IFDEF HERE! 6 | // Override these values at the mod's specific NavMesh constructor 7 | 8 | CNavMeshGeneratorParameters::CNavMeshGeneratorParameters() 9 | { 10 | generation_step_size = 25.0f; 11 | jump_height = 41.8f; 12 | jump_crouch_height = 64.0f; 13 | step_height = 18.0f; 14 | death_drop = 400.0f; 15 | climb_up_height = 64.0f; 16 | half_human_width = 16.0f; 17 | half_human_height = 35.5f; 18 | human_height = 71.0f; 19 | human_eye_height = 62.0f; 20 | human_crouch_height = 55.0f; 21 | human_crouch_eye_height = 37.0f; 22 | } 23 | 24 | static CNavMeshGeneratorParameters s_navgenparams; 25 | CNavMeshGeneratorParameters* navgenparams = &s_navgenparams; -------------------------------------------------------------------------------- /extension/navmesh/nav_trace.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "nav.h" 5 | #include "nav_mesh.h" 6 | #include "nav_trace.h" 7 | 8 | 9 | 10 | bool CTraceFilterWalkableEntities::ShouldHitEntity(IHandleEntity* pHandleEntity, int contentsMask) 11 | { 12 | if (trace::CTraceFilterNoNPCsOrPlayers::ShouldHitEntity(pHandleEntity, contentsMask)) 13 | { 14 | CBaseEntity* pEntity = trace::EntityFromEntityHandle(pHandleEntity); 15 | 16 | return !(TheNavMesh->IsEntityWalkable(pEntity, m_flags)); 17 | } 18 | 19 | return false; 20 | } 21 | 22 | bool CTraceFilterTransientAreas::ShouldHitEntity(IHandleEntity* pHandleEntity, int contentsMask) 23 | { 24 | if (trace::CTraceFilterNoNPCsOrPlayers::ShouldHitEntity(pHandleEntity, contentsMask)) 25 | { 26 | CBaseEntity* pEntity = trace::EntityFromEntityHandle(pHandleEntity); 27 | 28 | if (gamehelpers->EntityToBCompatRef(pEntity) == 0) 29 | { 30 | return true; // always hit worldspawn 31 | } 32 | 33 | // TO-DO: Allow derived nav mesh classes to customize this 34 | if (UtilHelpers::FClassnameIs(pEntity, "func_brush") || 35 | UtilHelpers::FClassnameIs(pEntity, "func_door") || 36 | UtilHelpers::FClassnameIs(pEntity, "func_door_rotating") || 37 | UtilHelpers::FClassnameIs(pEntity, "prop_dynamic*") || 38 | UtilHelpers::FClassnameIs(pEntity, "prop_static") || 39 | UtilHelpers::FClassnameIs(pEntity, "func_wall_toggle") || 40 | UtilHelpers::FClassnameIs(pEntity, "func_tracktrain")) 41 | { 42 | return true; 43 | } 44 | } 45 | 46 | return false; 47 | } 48 | -------------------------------------------------------------------------------- /extension/navmesh/nav_trace.h: -------------------------------------------------------------------------------- 1 | #ifndef NAV_TRACE_H_ 2 | #define NAV_TRACE_H_ 3 | 4 | #include 5 | 6 | constexpr auto WALK_THRU_PROP_DOORS = 0x01; 7 | constexpr auto WALK_THRU_FUNC_DOORS = 0x02; 8 | constexpr auto WALK_THRU_DOORS = (WALK_THRU_PROP_DOORS | WALK_THRU_FUNC_DOORS); 9 | constexpr auto WALK_THRU_BREAKABLES = 0x04; 10 | constexpr auto WALK_THRU_TOGGLE_BRUSHES = 0x08; 11 | constexpr auto WALK_THRU_EVERYTHING = (WALK_THRU_DOORS | WALK_THRU_BREAKABLES | WALK_THRU_TOGGLE_BRUSHES); 12 | 13 | class CTraceFilterWalkableEntities : public trace::CTraceFilterNoNPCsOrPlayers 14 | { 15 | public: 16 | CTraceFilterWalkableEntities(CBaseEntity* passEnt, int collisiongroup, unsigned int flags) : 17 | trace::CTraceFilterNoNPCsOrPlayers(passEnt, collisiongroup) 18 | { 19 | m_flags = flags; 20 | } 21 | 22 | bool ShouldHitEntity(IHandleEntity* pHandleEntity, int contentsMask) override; 23 | 24 | private: 25 | unsigned int m_flags; 26 | }; 27 | 28 | class CTraceFilterTransientAreas : public trace::CTraceFilterNoNPCsOrPlayers 29 | { 30 | public: 31 | CTraceFilterTransientAreas(CBaseEntity* passEnt, int collgroup) : 32 | trace::CTraceFilterNoNPCsOrPlayers(passEnt, collgroup) 33 | { 34 | } 35 | 36 | bool ShouldHitEntity(IHandleEntity* pHandleEntity, int contentsMask) override; 37 | }; 38 | 39 | #endif // !NAV_TRACE_H_ 40 | -------------------------------------------------------------------------------- /extension/navmesh/nav_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVMESH_UTILS_H_ 2 | #define NAVMESH_UTILS_H_ 3 | 4 | #include 5 | #include "nav_area.h" 6 | 7 | extern NavAreaVector TheNavAreas; 8 | 9 | // undef valve mathlib stuff so we can use std version 10 | #undef max 11 | #undef min 12 | #undef clamp 13 | 14 | namespace navutils 15 | { 16 | template 17 | void CollectNavAreasInRadius(const Vector& center, const float radius, F shouldCollectFunctor, std::vector& out) 18 | { 19 | FOR_EACH_VEC(TheNavAreas, it) 20 | { 21 | CNavArea* basearea = TheNavAreas[it]; 22 | 23 | if ((center - basearea->GetCenter()).Length() <= radius) 24 | { 25 | T* area = static_cast(basearea); 26 | if (shouldCollectFunctor(area)) 27 | { 28 | out.push_back(area); 29 | } 30 | } 31 | } 32 | } 33 | } 34 | 35 | #endif // !NAVMESH_UTILS_H_ 36 | -------------------------------------------------------------------------------- /extension/pawn_mem_manager.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pawn_mem_manager.h" 3 | 4 | void CSourcePawnMemoryManager::OnMapEnd() 5 | { 6 | m_navigatorIndex = 1; 7 | m_pluginnavigators.clear(); 8 | } 9 | 10 | cell_t CSourcePawnMemoryManager::AllocNewNavigator() 11 | { 12 | std::unique_ptr nav = std::make_unique(); 13 | 14 | cell_t index = m_navigatorIndex; 15 | m_pluginnavigators[index] = std::move(nav); 16 | m_navigatorIndex++; 17 | 18 | return index; 19 | } 20 | 21 | CPluginMeshNavigator* CSourcePawnMemoryManager::GetNavigatorByIndex(cell_t index) 22 | { 23 | auto it = m_pluginnavigators.find(index); 24 | 25 | if (it == m_pluginnavigators.end()) 26 | { 27 | return nullptr; 28 | } 29 | 30 | return it->second.get(); 31 | } 32 | 33 | void CSourcePawnMemoryManager::DeleteNavigator(cell_t index) 34 | { 35 | m_pluginnavigators.erase(index); 36 | } 37 | -------------------------------------------------------------------------------- /extension/pawn_mem_manager.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_SOURCEPAWN_MEMORY_MANAGER_H_ 2 | #define NAVBOT_SOURCEPAWN_MEMORY_MANAGER_H_ 3 | 4 | /** 5 | * Until Sourcepawn/Sourcemod gets better support for 64 bits pointer address. 6 | * We will use indexes for manaing pawn allocated objects. 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | class CSourcePawnMemoryManager 15 | { 16 | public: 17 | CSourcePawnMemoryManager() 18 | { 19 | m_navigatorIndex = 1; 20 | } 21 | 22 | ~CSourcePawnMemoryManager() 23 | { 24 | } 25 | 26 | void OnMapEnd(); 27 | 28 | // Creates a new plugin navigator, return it's storage index 29 | cell_t AllocNewNavigator(); 30 | 31 | CPluginMeshNavigator* GetNavigatorByIndex(cell_t index); 32 | void DeleteNavigator(cell_t index); 33 | 34 | private: 35 | std::unordered_map> m_pluginnavigators; 36 | cell_t m_navigatorIndex; 37 | }; 38 | 39 | 40 | #endif // !NAVBOT_SOURCEPAWN_MEMORY_MANAGER_H_ 41 | -------------------------------------------------------------------------------- /extension/sdkports/eventlistenerhelper.h: -------------------------------------------------------------------------------- 1 | #ifndef SMNAV_EXT_EVENT_LISTENER_H_ 2 | #define SMNAV_EXT_EVENT_LISTENER_H_ 3 | #pragma once 4 | 5 | #include 6 | 7 | extern IGameEventManager2* gameeventmanager; 8 | 9 | // Extension port of the game dll CGameEventListener 10 | 11 | // Derive from this class to listen for game events 12 | class CEventListenerHelper : public IGameEventListener2 13 | { 14 | public: 15 | CEventListenerHelper() : m_isListeningForEvents(false) {} 16 | virtual ~CEventListenerHelper() 17 | { 18 | StopListeningForAllEvents(); 19 | } 20 | 21 | inline void ListenForGameEvent(const char* name) 22 | { 23 | if (gameeventmanager->FindListener(this, name) == false) 24 | { 25 | if (gameeventmanager->AddListener(this, name, true) == true) 26 | { 27 | m_isListeningForEvents = true; 28 | } 29 | } 30 | } 31 | 32 | inline void StopListeningForAllEvents() 33 | { 34 | if (m_isListeningForEvents == true) 35 | { 36 | gameeventmanager->RemoveListener(this); 37 | m_isListeningForEvents = false; 38 | } 39 | } 40 | 41 | // Derived classes implement this to receive game events 42 | 43 | virtual void FireGameEvent(IGameEvent* event) = 0; 44 | 45 | #if SOURCE_ENGINE >= SE_LEFT4DEAD 46 | // declare it here, since it's not used 47 | virtual int GetEventDebugID(void) { return EVENT_DEBUG_ID_INIT; } 48 | #endif // SOURCE_ENGINE >= SE_LEFT4DEAD 49 | 50 | private: 51 | bool m_isListeningForEvents; 52 | }; 53 | 54 | #endif // !SMNAV_EXT_EVENT_LISTENER_H_ 55 | 56 | -------------------------------------------------------------------------------- /extension/sdkports/gametrace_server.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | bool CGameTrace::DidHitWorld() const 5 | { 6 | int index = gamehelpers->EntityToBCompatRef(m_pEnt); 7 | return index == 0; // World entity is edict index 0 8 | } 9 | 10 | bool CGameTrace::DidHitNonWorldEntity() const 11 | { 12 | return !DidHitWorld(); 13 | } 14 | 15 | int CGameTrace::GetEntityIndex() const 16 | { 17 | return gamehelpers->EntityToBCompatRef(m_pEnt); 18 | } -------------------------------------------------------------------------------- /extension/sdkports/sdk_ehandle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "sdk_ehandle.h" 3 | 4 | #ifdef EXT_VPROF_ENABLED 5 | #include 6 | #endif // EXT_VPROF_ENABLED 7 | 8 | IHandleEntity* CBaseHandle::Get() const 9 | { 10 | #ifdef EXT_VPROF_ENABLED 11 | VPROF_BUDGET("[NavBot] CBaseHandle::Get()", "NavBot"); 12 | #endif // EXT_VPROF_ENABLED 13 | 14 | return g_EntList->LookupEntity(*this); 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /extension/sdkports/sdk_game_util.h: -------------------------------------------------------------------------------- 1 | #ifndef SDKPORTS_GAME_UTIL_H_ 2 | #define SDKPORTS_GAME_UTIL_H_ 3 | 4 | #include 5 | 6 | // Ported from SDK2013 game/server/util.h 7 | 8 | abstract_class IEntityFactory 9 | { 10 | public: 11 | virtual IServerNetworkable * Create(const char* pClassName) = 0; 12 | virtual void Destroy(IServerNetworkable* pNetworkable) = 0; 13 | virtual size_t GetEntitySize() = 0; 14 | }; 15 | 16 | abstract_class IEntityFactoryDictionary 17 | { 18 | public: 19 | virtual void InstallFactory(IEntityFactory * pFactory, const char* pClassName) = 0; 20 | virtual IServerNetworkable* Create(const char* pClassName) = 0; 21 | virtual void Destroy(const char* pClassName, IServerNetworkable* pNetworkable) = 0; 22 | virtual IEntityFactory* FindFactory(const char* pClassName) = 0; 23 | virtual const char* GetCannonicalName(const char* pClassName) = 0; 24 | }; 25 | 26 | #endif // !SDKPORTS_GAME_UTIL_H_ 27 | -------------------------------------------------------------------------------- /extension/sdkports/sdk_takedamageinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_SDKPORTS_CTAKEDAMAGEINFO_H_ 2 | #define NAVBOT_SDKPORTS_CTAKEDAMAGEINFO_H_ 3 | #pragma once 4 | 5 | // Get def from SDK unless problematic 6 | #include "sdk_ehandle.h" 7 | #include "takedamageinfo.h" 8 | 9 | 10 | #endif // !NAVBOT_SDKPORTS_CTAKEDAMAGEINFO_H_ 11 | -------------------------------------------------------------------------------- /extension/sdkports/sdk_timers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "sdk_timers.h" 3 | 4 | // work-around since client header doesn't like inlined gpGlobals->curtime 5 | float IntervalTimer::Now(void) const 6 | { 7 | return gpGlobals->curtime; 8 | } 9 | 10 | // work-around since client header doesn't like inlined gpGlobals->curtime 11 | float CountdownTimer::Now(void) const 12 | { 13 | return gpGlobals->curtime; 14 | } -------------------------------------------------------------------------------- /extension/sdkports/sdk_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef SDK_PORT_UTILS_H_ 2 | #define SDK_PORT_UTILS_H_ 3 | #pragma once 4 | 5 | #include 6 | 7 | inline float UTIL_VecToYaw(const Vector& vec) 8 | { 9 | if (vec.y == 0 && vec.x == 0) 10 | return 0; 11 | 12 | float yaw = atan2(vec.y, vec.x); 13 | 14 | yaw = RAD2DEG(yaw); 15 | 16 | if (yaw < 0) 17 | yaw += 360; 18 | 19 | return yaw; 20 | } 21 | 22 | 23 | inline float UTIL_VecToPitch(const Vector& vec) 24 | { 25 | if (vec.y == 0 && vec.x == 0) 26 | { 27 | if (vec.z < 0) 28 | return 180.0; 29 | else 30 | return -180.0; 31 | } 32 | 33 | float dist = vec.Length2D(); 34 | float pitch = atan2(-vec.z, dist); 35 | 36 | pitch = RAD2DEG(pitch); 37 | 38 | return pitch; 39 | } 40 | 41 | inline Vector UTIL_YawToVector(float yaw) 42 | { 43 | Vector ret; 44 | 45 | ret.z = 0; 46 | float angle = DEG2RAD(yaw); 47 | SinCos(angle, &ret.y, &ret.x); 48 | 49 | return ret; 50 | } 51 | 52 | inline edict_t* UTIL_GetListenServerEnt() 53 | { 54 | return gamehelpers->EdictOfIndex(1); 55 | } 56 | 57 | inline edict_t* UTIL_GetListenServerHost() 58 | { 59 | return gamehelpers->EdictOfIndex(1); 60 | } 61 | 62 | #endif -------------------------------------------------------------------------------- /extension/util/ehandle_edict.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "helpers.h" 3 | #include "ehandle_edict.h" 4 | 5 | CHandleEdict::CHandleEdict() : 6 | CBaseHandle() 7 | { 8 | } 9 | 10 | CHandleEdict::CHandleEdict(int iEntry, int iSerialNumber) : 11 | CBaseHandle(iEntry, iSerialNumber) 12 | { 13 | } 14 | 15 | CHandleEdict::CHandleEdict(const CBaseHandle& handle) : 16 | CBaseHandle(handle) 17 | { 18 | } 19 | 20 | CHandleEdict::CHandleEdict(edict_t* entity) 21 | { 22 | Term(); 23 | Set(entity); 24 | } 25 | 26 | edict_t* CHandleEdict::Get() const 27 | { 28 | return UtilHelpers::GetEdictFromCBaseHandle(*this); 29 | } 30 | 31 | void CHandleEdict::Set(const edict_t* val) 32 | { 33 | if (val == nullptr) 34 | { 35 | Term(); 36 | return; 37 | } 38 | 39 | const IServerEntity* se = val->GetIServerEntity(); 40 | 41 | if (se != nullptr) 42 | { 43 | CBaseHandle::Set(se); 44 | return; 45 | } 46 | 47 | Term(); 48 | } 49 | 50 | bool CHandleEdict::operator==(edict_t* val) const 51 | { 52 | int theirindex, myindex; 53 | 54 | if (Get() == nullptr) 55 | { 56 | return false; 57 | } 58 | 59 | myindex = gamehelpers->IndexOfEdict(Get()); 60 | theirindex = gamehelpers->IndexOfEdict(val); 61 | 62 | return myindex == theirindex; 63 | } 64 | 65 | bool CHandleEdict::operator!=(edict_t* val) const 66 | { 67 | int theirindex, myindex; 68 | 69 | if (Get() == nullptr) 70 | { 71 | return false; 72 | } 73 | 74 | myindex = gamehelpers->IndexOfEdict(Get()); 75 | theirindex = gamehelpers->IndexOfEdict(val); 76 | 77 | return myindex != theirindex; 78 | } 79 | 80 | CBaseEntity* CHandleEdict::ToBaseEntity() const 81 | { 82 | return UtilHelpers::GetBaseEntityFromCBaseHandle(*this); 83 | } 84 | 85 | -------------------------------------------------------------------------------- /extension/util/ehandle_edict.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_UTIL_EHANDLE_EDICT_H_ 2 | #define NAVBOT_UTIL_EHANDLE_EDICT_H_ 3 | 4 | #include 5 | 6 | struct edict_t; 7 | class CBaseEntity; 8 | 9 | /** 10 | * @brief A version of CHandle that returns edict_t instead of CBaseEntity 11 | */ 12 | class CHandleEdict : public CBaseHandle 13 | { 14 | public: 15 | 16 | CHandleEdict(); 17 | CHandleEdict(int iEntry, int iSerialNumber); 18 | CHandleEdict(const CBaseHandle& handle); 19 | CHandleEdict(edict_t* entity); 20 | 21 | edict_t* Get() const; 22 | void Set(const edict_t* val); 23 | 24 | operator edict_t* () { return Get(); } 25 | operator edict_t* () const { return Get(); } 26 | 27 | bool operator !() const { return Get() != nullptr; } 28 | bool operator==(edict_t* val) const; 29 | bool operator!=(edict_t* val) const; 30 | const CBaseHandle& operator=(const edict_t* val) 31 | { 32 | Set(val); 33 | return *this; 34 | } 35 | 36 | edict_t* operator->() const { return Get(); } 37 | // Tries to get a CBaseEntity pointer 38 | CBaseEntity* ToBaseEntity() const; 39 | }; 40 | 41 | #endif // !NAVBOT_UTIL_EHANDLE_EDICT_H_ 42 | -------------------------------------------------------------------------------- /extension/util/librandom.cpp: -------------------------------------------------------------------------------- 1 | #include "librandom.h" 2 | 3 | static librandom::RandomNumberGenerator s_randomgen; 4 | librandom::RandomNumberGenerator* randomgen = &s_randomgen; 5 | 6 | int librandom::generate_random_int(int min, int max) 7 | { 8 | RandomNumberGenerator rng; 9 | rng.RandomReSeed(); 10 | 11 | return rng.GetRandomInt(min, max); 12 | } 13 | -------------------------------------------------------------------------------- /extension/util/prediction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "prediction.h" 10 | 11 | #undef min 12 | #undef max 13 | #undef clamp 14 | 15 | Vector pred::SimpleProjectileLead(const Vector& targetPosition, const Vector& targetVelocity, const float projectileSpeed, const float rangeBetween) 16 | { 17 | float time = GetProjectileTravelTime(projectileSpeed, rangeBetween); 18 | 19 | time = time + (gpGlobals->interval_per_tick * 2.0f); // add two ticks ahead 20 | 21 | Vector result = targetPosition + (targetVelocity * time); 22 | return result; 23 | } 24 | 25 | float pred::SimpleGravityCompensation(const float time, const float proj_gravity) 26 | { 27 | return (CExtManager::GetSvGravityValue() / 2.0f) * (time * time) * proj_gravity; 28 | } 29 | 30 | float pred::GetGrenadeZ(const float rangeBetween, const float projectileSpeed) 31 | { 32 | constexpr auto PROJECTILE_SPEED_CONST = 0.707f; 33 | 34 | const float time = GetProjectileTravelTime(projectileSpeed * PROJECTILE_SPEED_CONST, rangeBetween); 35 | return std::min(0.0f, ((powf(2.0f, time) - 1.0f) * (CExtManager::GetSvGravityValue() * 0.1f))); 36 | } 37 | 38 | float pred::GravityComp(const float rangeBetween, const float projGravity, const float elevationRate) 39 | { 40 | constexpr auto STEP_DIVIDER = 50.0f; 41 | float steps = rangeBetween / STEP_DIVIDER; 42 | float z = (CExtManager::GetSvGravityValue() * projGravity) * (elevationRate * steps); 43 | 44 | return z; 45 | } 46 | -------------------------------------------------------------------------------- /extension/util/prediction.h: -------------------------------------------------------------------------------- 1 | #ifndef NAVBOT_PREDICTION_LIB_H_ 2 | #define NAVBOT_PREDICTION_LIB_H_ 3 | #pragma once 4 | 5 | namespace pred 6 | { 7 | Vector SimpleProjectileLead(const Vector& targetPosition, const Vector& targetVelocity, const float projectileSpeed, const float rangeBetween); 8 | float SimpleGravityCompensation(const float time, const float proj_gravity); 9 | 10 | inline const float GetProjectileTravelTime(const float projectileSpeed, const float rangeBetween) 11 | { 12 | return rangeBetween / projectileSpeed; 13 | } 14 | 15 | float GetGrenadeZ(const float rangeBetween, const float projectileSpeed); 16 | 17 | float GravityComp(const float rangeBetween, const float projGravity, const float elevationRate); 18 | } 19 | 20 | #endif // !NAVBOT_PREDICTION_LIB_H_ 21 | -------------------------------------------------------------------------------- /gamedata/navbot.games/common.games.txt: -------------------------------------------------------------------------------- 1 | "Games" 2 | { 3 | 4 | "#default" 5 | { 6 | "Keys" 7 | { 8 | /* OnPlayerRunCMD Hook 9 | * If a mod needs to hook OnPlayerRunCMD, set this to 1 10 | */ 11 | "HookPlayerRunCMD" "0" 12 | 13 | /* Nav Mesh editing sounds 14 | * Default sounds are from HL2, should be compatible with most mods 15 | */ 16 | "NavEdit_GenericBlip" "buttons\blip1.wav" 17 | "NavEdit_GenericSuccess" "buttons\button3.wav" 18 | "NavEdit_GenericError" "buttons\button2.wav" 19 | "NavEdit_SwitchOn" "buttons\lightswitch2.wav" 20 | "NavEdit_SwitchOff" "buttons\combine_button7.wav" 21 | "NavEdit_GenericOff" "buttons\combine_button2.wav" 22 | "NavEdit_ConnectFail" "buttons\button10.wav" 23 | "NavEdit_WaypointAdd" "weapons\crossbow\hit1.wav" 24 | } 25 | "Offsets" 26 | { 27 | /* vtable offset for CGameRules::ShouldCollide(int, int) */ 28 | "CGameRules::ShouldCollide" 29 | { 30 | "windows" "29" 31 | "windows64" "29" 32 | "linux" "30" 33 | "linux64" "30" 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /gamedata/navbot.games/game.bms.txt: -------------------------------------------------------------------------------- 1 | "Games" 2 | { 3 | "bms" 4 | { 5 | "Offsets" 6 | { 7 | "Event_Killed" 8 | { 9 | "windows" "72" 10 | "linux" "73" 11 | } 12 | "Event_KilledOther" 13 | { 14 | "windows" "73" 15 | "linux" "74" 16 | } 17 | "PhysicsSimulate" 18 | { 19 | "windows" "113" 20 | "linux" "114" 21 | } 22 | "CBaseAnimating::GetBoneTransform" 23 | { 24 | "windows" "217" 25 | "linux" "218" 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /gamedata/navbot.games/game.cstrike.txt: -------------------------------------------------------------------------------- 1 | "Games" 2 | { 3 | "cstrike" 4 | { 5 | "Offsets" 6 | { 7 | /* CCSPlayer::Event_Killed */ 8 | "Event_Killed" 9 | { 10 | "windows" "68" 11 | "windows64" "68" 12 | "linux" "69" 13 | "linux64" "69" 14 | } 15 | /* CCSPlayer::Event_KilledOther */ 16 | "Event_KilledOther" 17 | { 18 | "windows" "69" 19 | "windows64" "69" 20 | "linux" "70" 21 | "linux64" "70" 22 | } 23 | /* CBasePlayer::PhysicsSimulate */ 24 | "PhysicsSimulate" 25 | { 26 | "windows" "106" 27 | "windows64" "106" 28 | "linux" "107" 29 | "linux64" "107" 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /gamedata/navbot.games/game.dod.txt: -------------------------------------------------------------------------------- 1 | "Games" 2 | { 3 | /* OnPlayerRunCMD Hook */ 4 | "dod" 5 | { 6 | "Keys" 7 | { 8 | // If a mod needs to hook OnPlayerRunCMD, set this to 1 9 | "HookPlayerRunCMD" "1" 10 | } 11 | 12 | "Offsets" 13 | { 14 | /* CDODPlayer::Event_Killed */ 15 | "Event_Killed" 16 | { 17 | "windows" "68" 18 | "windows64" "68" 19 | "linux" "69" 20 | "linux64" "69" 21 | } 22 | /* CBasePlayer::Event_KilledOther */ 23 | "Event_KilledOther" 24 | { 25 | "windows" "69" 26 | "windows64" "69" 27 | "linux" "70" 28 | "linux64" "70" 29 | } 30 | /* CBasePlayer::PhysicsSimulate */ 31 | "PhysicsSimulate" 32 | { 33 | "windows" "106" 34 | "windows64" "106" 35 | "linux" "107" 36 | "linux64" "107" 37 | } 38 | "CBaseAnimating::GetBoneTransform" 39 | { 40 | "windows" "205" 41 | "windows64" "205" 42 | "linux" "206" 43 | "linux64" "206" 44 | } 45 | 46 | /** 47 | * relative offset starting from m_iCPGroup to get to m_iPointIndex 48 | * https://github.com/lua9520/source-engine-2018-hl2_src/blob/3bf9df6b2785fa6d951086978a3e66f49427166a/game/server/dod/dod_control_point.h#L137 49 | */ 50 | "CControlPoint::m_iPointIndex" 51 | { 52 | "windows" "-4" 53 | "windows64" "-4" 54 | "linux" "-4" 55 | "linux64" "-4" 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /gamedata/navbot.games/game.hl1mp.txt: -------------------------------------------------------------------------------- 1 | "Games" 2 | { 3 | "hl1mp" 4 | { 5 | "Offsets" 6 | { 7 | /* CHL1_Player::Event_Killed */ 8 | "Event_Killed" 9 | { 10 | "windows" "68" 11 | "windows64" "68" 12 | "linux" "69" 13 | "linux64" "69" 14 | } 15 | /* CBasePlayer::Event_KilledOther */ 16 | "Event_KilledOther" 17 | { 18 | "windows" "69" 19 | "windows64" "69" 20 | "linux" "70" 21 | "linux64" "70" 22 | } 23 | /* CBasePlayer::PhysicsSimulate */ 24 | "PhysicsSimulate" 25 | { 26 | "windows" "106" 27 | "windows64" "106" 28 | "linux" "107" 29 | "linux64" "107" 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /gamedata/navbot.games/game.hl2mp.txt: -------------------------------------------------------------------------------- 1 | "Games" 2 | { 3 | "hl2mp" 4 | { 5 | "Offsets" 6 | { 7 | /* CDODPlayer::Event_Killed */ 8 | "Event_Killed" 9 | { 10 | "windows" "68" 11 | "windows64" "68" 12 | "linux" "69" 13 | "linux64" "69" 14 | } 15 | /* CBasePlayer::Event_KilledOther */ 16 | "Event_KilledOther" 17 | { 18 | "windows" "69" 19 | "windows64" "69" 20 | "linux" "70" 21 | "linux64" "70" 22 | } 23 | /* CBasePlayer::PhysicsSimulate */ 24 | "PhysicsSimulate" 25 | { 26 | "windows" "106" 27 | "windows64" "106" 28 | "linux" "107" 29 | "linux64" "107" 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /gamedata/navbot.games/master.games.txt: -------------------------------------------------------------------------------- 1 | "Game Master" 2 | { 3 | "common.games.txt" 4 | { 5 | } 6 | // Day of Defeat: Source 7 | "game.dod.txt" 8 | { 9 | "game" "dod" 10 | } 11 | // Team Fortress 2 12 | "game.tf.txt" 13 | { 14 | "game" "tf" 15 | } 16 | // Counter-Strike: Source 17 | "game.cstrike.txt" 18 | { 19 | "game" "cstrike" 20 | } 21 | // Half-Life 2: Deathmatch 22 | "game.hl2mp.txt" 23 | { 24 | "game" "hl2mp" 25 | } 26 | // Black Mesa (Steam) 27 | "game.bms.txt" 28 | { 29 | "game" "bms" 30 | } 31 | // Half-Life 1 Deathmatch Source 32 | "game.hl1mp.txt" 33 | { 34 | "game" "hl1mp" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /premake/common_sdk.lua: -------------------------------------------------------------------------------- 1 | defines { "RAD_TELEMETRY_DISABLED", "GAME_DLL", "SE_BLADE=19", "SE_BMS=11", "SE_CONTAGION=15", "SE_CS2=25", "SE_CSGO=23", "SE_CSS=6", "SE_DARKMESSIAH=2", "SE_DODS=8" } 2 | defines { "SE_ORANGEBOX=3", "SE_PORTAL2=18", "SE_PVKII=10", "SE_SDK2013=9", "SE_ALIENSWARM=17", "SE_TF2=12" } 3 | defines { "SE_DOI=21", "SE_DOTA=24", "SE_EPISODEONE=1", "SE_EYE=5", "SE_HL2DM=7", "SE_INSURGENCY=20", "SE_LEFT4DEAD=13" } 4 | defines { "SE_LEFT4DEAD2=16", "SE_MCV=22", "SE_MOCK=26", "SE_NUCLEARDAWN=14", "SE_DEADLOCK=27" } -------------------------------------------------------------------------------- /scripting/navbot_admin.sp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #pragma newdecls required 5 | #pragma semicolon 1 6 | 7 | #define PLUGIN_VERSION "1.0.0" 8 | 9 | public Plugin myinfo = 10 | { 11 | name = "NavBot Admin Plugin", 12 | author = "caxanga334", 13 | description = "Allow server admins to manage NavBots.", 14 | version = PLUGIN_VERSION, 15 | url = "https://github.com/caxanga334/NavBot" 16 | }; 17 | 18 | 19 | public void OnPluginStart() 20 | { 21 | RegAdminCmd("sm_navbotadmin_addbot", CMD_AddBot, ADMFLAG_CONFIG, "Adds a NavBot bot to the game."); 22 | } 23 | 24 | public void OnLibraryRemoved(const char[] name) 25 | { 26 | if (StrEqual(name, "navbot", false)) 27 | { 28 | SetFailState("NavBot extension was unloaded!"); 29 | } 30 | } 31 | 32 | Action CMD_AddBot(int client, int args) 33 | { 34 | if (!IsNavMeshLoaded()) 35 | { 36 | ReplyToCommand(client, "This map does not have a nav mesh loaded! Can't add bots."); 37 | return Plugin_Handled; 38 | } 39 | 40 | char botname[MAX_NAME_LENGTH]; 41 | bool custom_name = false; 42 | bool result = false; 43 | int bot_index; 44 | 45 | if (args >= 2) 46 | { 47 | GetCmdArg(1, botname, sizeof(botname)); 48 | 49 | if (strlen(botname) >= 3) 50 | { 51 | custom_name = true; 52 | } 53 | } 54 | 55 | if (custom_name) 56 | { 57 | result = AddNavBot(bot_index, botname); 58 | } 59 | else 60 | { 61 | result = AddNavBot(bot_index); 62 | } 63 | 64 | if (!result) 65 | { 66 | ReplyToCommand(client, "Failed to add a NavBot!"); 67 | return Plugin_Handled; 68 | } 69 | 70 | ShowActivity2(client, "[SM] ", "Added a NavBot to the game."); 71 | LogAction(client, -1, "%L added a NavBot to the game.", client); 72 | 73 | return Plugin_Handled; 74 | } --------------------------------------------------------------------------------