Merge pull request #221 from diamante0018/bots-req-changes

[Bots] Make requested changes by ineedbots
This commit is contained in:
Dss0 2022-04-14 18:43:30 +02:00 committed by GitHub
commit d3da21bd2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View File

@ -149,7 +149,7 @@ namespace Components
g_botai[entref.entnum] = {0}; g_botai[entref.entnum] = {0};
g_botai[entref.entnum].weapon = 1; 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: <bot> BotWeapon(<str>); Script::AddMethod("BotWeapon", [](Game::scr_entref_t entref) // Usage: <bot> BotWeapon(<str>);
@ -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<void(int)>(0x4AA430)(clientNum);
}
Bots::Bots() Bots::Bots()
{ {
// Replace connect string // Replace connect string
@ -326,6 +338,9 @@ namespace Components
Utils::Hook(0x441B80, Bots::G_SelectWeaponIndex_Hk, HOOK_JUMP).install()->quick(); 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 // Zero the bot command array
for (auto i = 0u; i < std::extent_v<decltype(g_botai)>; i++) for (auto i = 0u; i < std::extent_v<decltype(g_botai)>; i++)
{ {

View File

@ -21,5 +21,7 @@ namespace Components
static void G_SelectWeaponIndex(int clientNum, int iWeaponIndex); static void G_SelectWeaponIndex(int clientNum, int iWeaponIndex);
static void G_SelectWeaponIndex_Hk(); static void G_SelectWeaponIndex_Hk();
static void ClientDisconnect_Hk(int clientNum);
}; };
} }

View File

@ -1763,7 +1763,7 @@ namespace Components
void Gamepad::CG_RegisterDvars_Hk() void Gamepad::CG_RegisterDvars_Hk()
{ {
// Call original method // Call original function
Utils::Hook::Call<void()>(0x4F8DC0)(); Utils::Hook::Call<void()>(0x4F8DC0)();
InitDvars(); InitDvars();