From f4a4a95674e6549517ca66471e806aa2f16f8445 Mon Sep 17 00:00:00 2001 From: Maurice Heumann Date: Sat, 31 Dec 2022 12:18:09 +0100 Subject: [PATCH] Add spawnBot command This fixes issue #69 --- src/client/component/bots.cpp | 26 ++++++++++++++++++++++++++ src/client/game/symbols.hpp | 6 +++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/client/component/bots.cpp b/src/client/component/bots.cpp index d3db86f3..10a5b9a7 100644 --- a/src/client/component/bots.cpp +++ b/src/client/component/bots.cpp @@ -1,6 +1,8 @@ #include #include "loader/component_loader.hpp" +#include "command.hpp" + #include #include @@ -46,6 +48,30 @@ namespace bots { utils::hook::jump(0x141653B70_g, get_bot_name); utils::hook::jump(0x141654280_g, get_bot_name); + + command::add("spawnBot", [](const command::params& params) + { + size_t count = 1; + if (params.size() > 1) + { + if (params[1] == "all"s) + { + count = 18; + } + else + { + count = atoi(params[1]); + } + } + + for (size_t i = 0; i < count; ++i) + { + if (!game::SV_AddTestClient()) + { + break; + } + } + }); } }; } diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index e7d2b3a2..27971fbf 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -25,7 +25,8 @@ namespace game WEAK symbol Cmd_AddCommandInternal{ 0x1420ED530 }; - WEAK symbol Cmd_ExecuteSingleCommand{ + WEAK symbol Cmd_ExecuteSingleCommand{ 0x1420EDC20 }; WEAK symbol Con_GetTextCopy{0x14133A7D0}; @@ -67,6 +68,9 @@ namespace game 0x141CD98D0 }; + // Rendering + WEAK symbol SV_AddTestClient{0x1422499A0}; + // Variables WEAK symbol cmd_functions{0x15689FF58};