diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index 27c44409..3d32d7ce 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -149,7 +149,7 @@ namespace Components g_botai[entref.entnum] = {0}; g_botai[entref.entnum].weapon = 1; - g_botai[entref.entnum].active = false; + g_botai[entref.entnum].active = true; }); Script::AddMethod("BotWeapon", [](Game::scr_entref_t entref) // Usage: BotWeapon(); @@ -313,6 +313,18 @@ namespace Components } } + /* + * Should be called when a client drops from the server + * but not "between levels" (Quake-III-Arena) + */ + void Bots::ClientDisconnect_Hk(int clientNum) + { + g_botai[clientNum].active = false; + + // Call original function + Utils::Hook::Call(0x4AA430)(clientNum); + } + Bots::Bots() { // Replace connect string @@ -326,6 +338,9 @@ namespace Components Utils::Hook(0x441B80, Bots::G_SelectWeaponIndex_Hk, HOOK_JUMP).install()->quick(); + // Reset BotMovementInfo.active when client is dropped + Utils::Hook(0x625235, Bots::ClientDisconnect_Hk, HOOK_CALL).install()->quick(); + // Zero the bot command array for (auto i = 0u; i < std::extent_v; i++) { diff --git a/src/Components/Modules/Bots.hpp b/src/Components/Modules/Bots.hpp index 94b25c9a..910bacfa 100644 --- a/src/Components/Modules/Bots.hpp +++ b/src/Components/Modules/Bots.hpp @@ -21,5 +21,7 @@ namespace Components static void G_SelectWeaponIndex(int clientNum, int iWeaponIndex); static void G_SelectWeaponIndex_Hk(); + + static void ClientDisconnect_Hk(int clientNum); }; } diff --git a/src/Components/Modules/Gamepad.cpp b/src/Components/Modules/Gamepad.cpp index f6fc1aef..0d102b23 100644 --- a/src/Components/Modules/Gamepad.cpp +++ b/src/Components/Modules/Gamepad.cpp @@ -1763,7 +1763,7 @@ namespace Components void Gamepad::CG_RegisterDvars_Hk() { - // Call original method + // Call original function Utils::Hook::Call(0x4F8DC0)(); InitDvars();