From d97dad0fc1f781759d4a36ab36b7abd2ee13db76 Mon Sep 17 00:00:00 2001 From: ineed bots Date: Thu, 2 May 2024 11:24:06 -0600 Subject: [PATCH 1/2] Add BotRemoteAngles and BotAngles, fixes ads bot button not throwing, adds remote bot button, BotStop assigns current weapon --- src/Components/Modules/Bots.cpp | 55 ++++++++++++++++++++++++++++++--- src/Game/Structs.hpp | 1 + 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index 576bcdc8..ec63221e 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -30,6 +30,8 @@ namespace Components std::uint16_t lastAltWeapon; std::uint8_t meleeDist; float meleeYaw; + std::int8_t remoteAngles[2]; + float angles[3]; bool active; }; @@ -54,10 +56,11 @@ namespace Components { "sprint", Game::CMD_BUTTON_SPRINT }, { "leanleft", Game::CMD_BUTTON_LEAN_LEFT }, { "leanright", Game::CMD_BUTTON_LEAN_RIGHT }, - { "ads", Game::CMD_BUTTON_ADS }, + { "ads", Game::CMD_BUTTON_ADS | Game::CMD_BUTTON_THROW }, { "holdbreath", Game::CMD_BUTTON_BREATH }, { "usereload", Game::CMD_BUTTON_USE_RELOAD }, { "activate", Game::CMD_BUTTON_ACTIVATE }, + { "remote", Game::CMD_BUTTON_REMOTE }, }; void Bots::UpdateBotNames() @@ -214,7 +217,10 @@ namespace Components } ZeroMemory(&g_botai[entref.entnum], sizeof(BotMovementInfo)); - g_botai[entref.entnum].weapon = 1; + g_botai[entref.entnum].weapon = ent->client->ps.weapCommon.weapon; + g_botai[entref.entnum].angles[0] = ent->client->ps.viewangles[0]; + g_botai[entref.entnum].angles[1] = ent->client->ps.viewangles[1]; + g_botai[entref.entnum].angles[2] = ent->client->ps.viewangles[2]; g_botai[entref.entnum].active = true; }); @@ -311,6 +317,43 @@ namespace Components g_botai[entref.entnum].meleeDist = static_cast(dist); g_botai[entref.entnum].active = true; }); + + GSC::Script::AddMethod("BotRemoteAngles", [](const Game::scr_entref_t entref) // Usage: BotRemoteAngles(, ); + { + const auto* ent = GSC::Script::Scr_GetPlayerEntity(entref); + if (!Game::SV_IsTestClient(ent->s.number)) + { + Game::Scr_Error("BotRemoteAngles: Can only call on a bot!"); + return; + } + + const auto pitch = std::clamp(Game::Scr_GetInt(0), std::numeric_limits::min(), std::numeric_limits::max()); + const auto yaw = std::clamp(Game::Scr_GetInt(1), std::numeric_limits::min(), std::numeric_limits::max()); + + g_botai[entref.entnum].remoteAngles[0] = static_cast(pitch); + g_botai[entref.entnum].remoteAngles[1] = static_cast(yaw); + g_botai[entref.entnum].active = true; + }); + + GSC::Script::AddMethod("BotAngles", [](const Game::scr_entref_t entref) // Usage: BotAngles(, , ); + { + const auto* ent = GSC::Script::Scr_GetPlayerEntity(entref); + if (!Game::SV_IsTestClient(ent->s.number)) + { + Game::Scr_Error("BotAngles: Can only call on a bot!"); + return; + } + + const auto pitch = Game::Scr_GetFloat(0); + const auto yaw = Game::Scr_GetFloat(1); + const auto roll = Game::Scr_GetFloat(2); + + g_botai[entref.entnum].angles[0] = pitch; + g_botai[entref.entnum].angles[1] = yaw; + g_botai[entref.entnum].angles[2] = roll; + + g_botai[entref.entnum].active = true; + }); } void Bots::BotAiAction(Game::client_s* cl) @@ -341,10 +384,12 @@ namespace Components userCmd.primaryWeaponForAltMode = g_botai[clientNum].lastAltWeapon; userCmd.meleeChargeYaw = g_botai[clientNum].meleeYaw; userCmd.meleeChargeDist = g_botai[clientNum].meleeDist; + userCmd.remoteControlAngles[0] = g_botai[clientNum].remoteAngles[0]; + userCmd.remoteControlAngles[1] = g_botai[clientNum].remoteAngles[1]; - userCmd.angles[0] = ANGLE2SHORT((cl->gentity->client->ps.viewangles[0] - cl->gentity->client->ps.delta_angles[0])); - userCmd.angles[1] = ANGLE2SHORT((cl->gentity->client->ps.viewangles[1] - cl->gentity->client->ps.delta_angles[1])); - userCmd.angles[2] = ANGLE2SHORT((cl->gentity->client->ps.viewangles[2] - cl->gentity->client->ps.delta_angles[2])); + userCmd.angles[0] = ANGLE2SHORT(g_botai[clientNum].angles[0] - cl->gentity->client->ps.delta_angles[0]); + userCmd.angles[1] = ANGLE2SHORT(g_botai[clientNum].angles[1] - cl->gentity->client->ps.delta_angles[1]); + userCmd.angles[2] = ANGLE2SHORT(g_botai[clientNum].angles[2] - cl->gentity->client->ps.delta_angles[2]); Game::SV_ClientThink(cl, &userCmd); } diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index d2c2e9b1..6778b88b 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -1978,6 +1978,7 @@ namespace Game CMD_BUTTON_FRAG = 1 << 14, CMD_BUTTON_OFFHAND_SECONDARY = 1 << 15, CMD_BUTTON_THROW = 1 << 19, + CMD_BUTTON_REMOTE = 1 << 20, }; struct usercmd_s From c249947390c13677bbd7c5191380b146799c722b Mon Sep 17 00:00:00 2001 From: ineed bots Date: Thu, 2 May 2024 11:38:09 -0600 Subject: [PATCH 2/2] fix warning --- src/Components/Modules/Bots.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index ec63221e..974f849e 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -217,7 +217,7 @@ namespace Components } ZeroMemory(&g_botai[entref.entnum], sizeof(BotMovementInfo)); - g_botai[entref.entnum].weapon = ent->client->ps.weapCommon.weapon; + g_botai[entref.entnum].weapon = static_cast(ent->client->ps.weapCommon.weapon); g_botai[entref.entnum].angles[0] = ent->client->ps.viewangles[0]; g_botai[entref.entnum].angles[1] = ent->client->ps.viewangles[1]; g_botai[entref.entnum].angles[2] = ent->client->ps.viewangles[2];