diff --git a/README.md b/README.md index d5a23ac..d5fdf19 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Credits - libcod Team - https://github.com/M-itch/libcod - - CoD4x Team - https://github.com/callofduty4x/CoD4x_Server + - T4M Team - https://github.com/iAmThatMichael/T4M - IW4x Team - https://github.com/XLabsProject/iw4x-client + - CoD4x Team - https://github.com/callofduty4x/CoD4x_Server diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index c353691..44d857c 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -3,6 +3,50 @@ namespace Components { + Bots::botMovements Bots::g_botai[MAX_G_BOTAI_ENTRIES]; + + const Bots::BotAction_t Bots::bot_actions[] = + { + { "fire", KEY_FIRE }, + { "attack", KEY_FIRE }, + { "sprint", KEY_SPRINT }, + { "melee", KEY_MELEE }, + { "activate", KEY_USE }, + { "use", KEY_USE | KEY_USERELOAD }, + { "usereload", KEY_USERELOAD }, + { "reload", KEY_RELOAD }, + { "leanleft", KEY_LEANLEFT }, + { "leanright", KEY_LEANRIGHT }, + { "goprone", KEY_PRONE }, + { "gocrouch", KEY_CROUCH }, + { "gostand", KEY_GOSTAND }, + { "ads", KEY_ADSMODE | KEY_ADS }, + { "toggleads_throw", KEY_ADSMODE }, + { "speed_throw", KEY_ADS }, + { "temp", KEY_TEMP }, + { "holdbreath", KEY_HOLDBREATH }, + { "frag", KEY_FRAG }, + { "smoke", KEY_SMOKE }, + { "unk", KEY_UNK }, + { "unk2", KEY_UNK2 }, + { "nightvision", KEY_NIGHTVISION }, + { "unk3", KEY_UNK3 }, + { "unk4", KEY_UNK4 }, + { "menu", KEY_MENU }, + { "unk5", KEY_UNK5 }, + { "unk6", KEY_UNK6 }, + { "unk7", KEY_UNK7 }, + { "unk8", KEY_UNK8 }, + { "unk9", KEY_UNK9 }, + { "unk10", KEY_UNK10 }, + { "unk11", KEY_UNK11 }, + { "unk12", KEY_UNK12 }, + { "unk13", KEY_UNK13 }, + { "unk14", KEY_UNK14 } + }; + + std::vector Bots::bot_names; + const char* Bots::ConnectString = "connect \"\\cg_predictItems\\1\\cl_punkbuster\\0\\cl_anonymous\\0\\color\\4\\head\\default\\model\\multi\\snaps\\20\\" "rate\\5000\\name\\%s\\protocol\\%d\""; @@ -25,8 +69,13 @@ namespace Components Game::usercmd_t cmd = {}; cmd.serverTime = Game::svs->time; + cmd.weapon = g_botai[cl_num].weapon; + cmd.forwardmove = g_botai[cl_num].forward; + cmd.rightmove = g_botai[cl_num].right; + cmd.buttons = g_botai[cl_num].buttons; cl->deltaMessage = cl->netchan.outgoingSequence - 1; + cl->ping = g_botai[cl_num].ping; Game::SV_ClientThink(&cmd, cl); } @@ -43,6 +92,8 @@ namespace Components void Bots::G_SelectWeaponIndex_Func(int wpIdx, int clNum) { + g_botai[clNum].weapon = static_cast(wpIdx); + Game::G_SelectWeaponIndex(wpIdx, clNum); } @@ -60,10 +111,7 @@ namespace Components void __cdecl Bots::PlayerCmd_setSpawnWeapon_Func(Game::gentity_t* ent, int wpIdx) { - if (Game::svs->clients[ent->s.number].bot) - { - - } + g_botai[ent->s.number].weapon = static_cast(wpIdx); } __declspec(naked) void Bots::PlayerCmd_setSpawnWeapon_Stub() @@ -85,6 +133,13 @@ namespace Components Bots::Bots() { + // init the bot commands + for (int i = 0; i < MAX_G_BOTAI_ENTRIES; i++) + { + g_botai[i] = { 0 }; + g_botai[i].weapon = 1; + } + // intercept the sprintf when creating the bot connect string Utils::Hook(0x45655B, BuildConnectString, HOOK_CALL).install()->quick(); diff --git a/src/Components/Modules/Bots.hpp b/src/Components/Modules/Bots.hpp index 4a90c10..e151914 100644 --- a/src/Components/Modules/Bots.hpp +++ b/src/Components/Modules/Bots.hpp @@ -1,4 +1,5 @@ #pragma once +#define MAX_G_BOTAI_ENTRIES 64 namespace Components { @@ -8,6 +9,63 @@ namespace Components Bots(); ~Bots(); private: + typedef enum button_mask : unsigned int + { + KEY_FIRE = 1 << 0, + KEY_SPRINT = 1 << 1, + KEY_MELEE = 1 << 2, + KEY_USE = 1 << 3, + KEY_RELOAD = 1 << 4, + KEY_USERELOAD = 1 << 5, + KEY_LEANLEFT = 1 << 6, + KEY_LEANRIGHT = 1 << 7, + KEY_PRONE = 1 << 8, + KEY_CROUCH = 1 << 9, + KEY_GOSTAND = 1 << 10, + KEY_ADSMODE = 1 << 11, + KEY_TEMP = 1 << 12, + KEY_HOLDBREATH = 1 << 13, + KEY_FRAG = 1 << 14, + KEY_SMOKE = 1 << 15, + KEY_UNK = 1 << 16, + KEY_UNK2 = 1 << 17, + KEY_NIGHTVISION = 1 << 18, + KEY_ADS = 1 << 19, + KEY_UNK3 = 1 << 20, + KEY_UNK4 = 1 << 21, + KEY_MENU = 1 << 22, + KEY_UNK5 = 1 << 23, + KEY_UNK6 = 1 << 24, + KEY_UNK7 = 1 << 25, + KEY_UNK8 = 1 << 25, + KEY_UNK9 = 1 << 26, + KEY_UNK10 = 1 << 27, + KEY_UNK11 = 1 << 28, + KEY_UNK12 = 1 << 29, + KEY_UNK13 = 1 << 30, + KEY_UNK14 = 2147483648 + } button_mask; + + struct BotAction_t + { + const char* action; + unsigned int key; + }; + + struct botMovements + { + unsigned int buttons; + int ping; + char weapon; + char forward; + char right; + }; + + static botMovements g_botai[]; + static const BotAction_t bot_actions[]; + + static std::vector bot_names; + static const char* ConnectString; static int BuildConnectString(char*, const char*, int, int);