diff --git a/hook_lib/functions.cpp b/hook_lib/functions.cpp index 74cc9bb..06163fa 100644 --- a/hook_lib/functions.cpp +++ b/hook_lib/functions.cpp @@ -398,6 +398,11 @@ void Scr_AddString(scrContext_t* scrContext, const char* value) { func(scrContext, value); } +int SL_GetString(const char* value) { + auto func = reinterpret_cast(0x14131AE30_g); + return func(value); +} + unsigned int GScr_ExecEntThread(gentity_s* ent, int handle, unsigned int paramcount) { auto func = reinterpret_cast(0x141257D70_g); return func(ent, handle, paramcount); @@ -461,12 +466,22 @@ short* SV_ClientMP_AddTestClient() return SV_ClientMP_AddTestClient_func(); } +short* SV_ClientMP_AddBot() +{ + auto func = reinterpret_cast(0x14136E210_g); + return func("DONETSK", 0,0,0); +} + void GScr_AddEntity(short* entity) { auto GScr_AddEntity_func = reinterpret_cast(0x1412578a0_g); GScr_AddEntity_func(entity); } +void GScr_Notify(short* ent, unsigned int stringValue, unsigned int paramcount) { + reinterpret_cast(0x141259B30_g)(ent, stringValue, paramcount); +} + void SV_ClientMP_SpawnBotOrTestClient(short* entity) { auto SV_ClientMP_SpawnBotOrTestClient_func = reinterpret_cast(0x141373640_g); @@ -513,6 +528,7 @@ cmd_function_s set_pointer_f_VAR; cmd_function_s quit_f_VAR; cmd_function_s openmenu_f_VAR; cmd_function_s addbot_f_VAR; +cmd_function_s addTestClient_f_VAR; cmd_function_s ddldump_f_VAR; cmd_function_s weapondefdump_f_VAR; cmd_function_s view_vehicle_ents_f_VAR; diff --git a/hook_lib/functions.hpp b/hook_lib/functions.hpp index 0e0462d..f31ffc0 100644 --- a/hook_lib/functions.hpp +++ b/hook_lib/functions.hpp @@ -122,6 +122,7 @@ extern cmd_function_s set_pointer_f_VAR; extern cmd_function_s quit_f_VAR; extern cmd_function_s openmenu_f_VAR; extern cmd_function_s addbot_f_VAR; +extern cmd_function_s addTestClient_f_VAR; extern cmd_function_s ddldump_f_VAR; extern cmd_function_s weapondefdump_f_VAR; extern cmd_function_s view_vehicle_ents_f_VAR; @@ -240,6 +241,9 @@ void Com_SetErrorMessage(const char* errorMessage); void GamerProfile_SetDataByName(unsigned int controllerIndex, const char* settingName, float settingValue); short* SV_ClientMP_AddTestClient(); +short* SV_ClientMP_AddBot(); +void GScr_Notify(short* ent, unsigned int stringValue, unsigned int paramcount); +int SL_GetString(const char* value); void GScr_AddEntity(short* entity); diff --git a/hook_lib/g_cmds.cpp b/hook_lib/g_cmds.cpp index 285cd9d..acfa030 100644 --- a/hook_lib/g_cmds.cpp +++ b/hook_lib/g_cmds.cpp @@ -11,6 +11,7 @@ void addCustomCmds() Cmd_AddCommandInternal("quit", Cmd_Quit_f, &quit_f_VAR); Cmd_AddCommandInternal("openmenu", Cmd_OpenMenu_f, &openmenu_f_VAR); Cmd_AddCommandInternal("addbot", Cmd_AddBot_f, &addbot_f_VAR); + Cmd_AddCommandInternal("addtestclient", Cmd_AddTestClient_f, &addTestClient_f_VAR); Cmd_AddCommandInternal("ddldump", Cmd_DDLDump_f, &ddldump_f_VAR); Cmd_AddCommandInternal("weapondefdump", Cmd_WeaponDefDump_f, &weapondefdump_f_VAR); //Cmd_AddCommandInternal("view_vehicle_ents", Cmd_ViewVehicleEnts_f, &view_vehicle_ents_f_VAR); @@ -283,11 +284,76 @@ void Cmd_OpenMenu_f() } } +void Cmd_AddTestClient_f() +{ + auto max_clients = *(int*)0x14EEB0CE0_g; + auto client_count = *(int*)0x14E195070_g; + auto spawnable_bots = max_clients - client_count; + if (spawnable_bots <= 0) + return; + + int spawn_number = 1; + if (Cmd_Argc() == 2) + { + char command[100]{ 0 }; + Cmd_ArgvBuffer(1, command, sizeof(command)); + spawn_number = atoll(command); + } + + if (spawn_number > spawnable_bots) + spawn_number = spawnable_bots; + + std::vector ents{}; + for (int i{}; i < spawn_number; ++i) + { + auto ent = SV_ClientMP_AddTestClient(); + if (!ent) + continue; + + GScr_AddEntity(ent); + SV_ClientMP_SpawnBotOrTestClient(ent); + ents.push_back(ent); + } + + Sleep(100); + for (auto& ent : ents) { + auto scrContext = ScriptContext_Server(); + Scr_AddString(scrContext, "class1"); + Scr_AddString(scrContext, "class_select"); + GScr_Notify(ent, SL_GetString("loadout_class_selected"), 2); + } +} + void Cmd_AddBot_f() { - auto ent = SV_ClientMP_AddTestClient(); - GScr_AddEntity(ent); - SV_ClientMP_SpawnBotOrTestClient(ent); + auto max_clients = *(int*)0x14EEB0CE0_g; + auto client_count = *(int*)0x14E195070_g; + auto spawnable_bots = max_clients - client_count; + if (spawnable_bots <= 0) + return; + + int spawn_number = 1; + if (Cmd_Argc() == 2) + { + char command[100]{ 0 }; + Cmd_ArgvBuffer(1, command, sizeof(command)); + spawn_number = atoll(command); + } + + if (spawn_number > spawnable_bots) + spawn_number = spawnable_bots; + + + for (int i{}; i < spawn_number; ++i) + { + auto ent = SV_ClientMP_AddBot(); + if (!ent) + return; + + GScr_AddEntity(ent); + SV_ClientMP_SpawnBotOrTestClient(ent); + //Sleep(20); + } } void SV_CmdsMP_MapRestart_f() diff --git a/hook_lib/g_cmds.h b/hook_lib/g_cmds.h index c5566ed..44a5e99 100644 --- a/hook_lib/g_cmds.h +++ b/hook_lib/g_cmds.h @@ -22,6 +22,8 @@ void Cmd_OpenMenu_f(); void Cmd_AddBot_f(); +void Cmd_AddTestClient_f(); + void SV_CmdsMP_MapRestart_f(); void SV_CmdsMP_FastRestart_f();