mirror of
https://github.com/ineedbots/cod2m.git
synced 2025-04-19 16:02:53 +00:00
Some bot cmd stuff
This commit is contained in:
parent
d270e08a22
commit
aa485079de
@ -1,4 +1,5 @@
|
|||||||
# Credits
|
# Credits
|
||||||
- libcod Team - https://github.com/M-itch/libcod
|
- 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
|
- IW4x Team - https://github.com/XLabsProject/iw4x-client
|
||||||
|
- CoD4x Team - https://github.com/callofduty4x/CoD4x_Server
|
||||||
|
@ -3,6 +3,50 @@
|
|||||||
|
|
||||||
namespace Components
|
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<std::string> 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\\"
|
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\"";
|
"rate\\5000\\name\\%s\\protocol\\%d\"";
|
||||||
|
|
||||||
@ -25,8 +69,13 @@ namespace Components
|
|||||||
|
|
||||||
Game::usercmd_t cmd = {};
|
Game::usercmd_t cmd = {};
|
||||||
cmd.serverTime = Game::svs->time;
|
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->deltaMessage = cl->netchan.outgoingSequence - 1;
|
||||||
|
cl->ping = g_botai[cl_num].ping;
|
||||||
Game::SV_ClientThink(&cmd, cl);
|
Game::SV_ClientThink(&cmd, cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +92,8 @@ namespace Components
|
|||||||
|
|
||||||
void Bots::G_SelectWeaponIndex_Func(int wpIdx, int clNum)
|
void Bots::G_SelectWeaponIndex_Func(int wpIdx, int clNum)
|
||||||
{
|
{
|
||||||
|
g_botai[clNum].weapon = static_cast<char>(wpIdx);
|
||||||
|
|
||||||
Game::G_SelectWeaponIndex(wpIdx, clNum);
|
Game::G_SelectWeaponIndex(wpIdx, clNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,10 +111,7 @@ namespace Components
|
|||||||
|
|
||||||
void __cdecl Bots::PlayerCmd_setSpawnWeapon_Func(Game::gentity_t* ent, int wpIdx)
|
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<char>(wpIdx);
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(naked) void Bots::PlayerCmd_setSpawnWeapon_Stub()
|
__declspec(naked) void Bots::PlayerCmd_setSpawnWeapon_Stub()
|
||||||
@ -85,6 +133,13 @@ namespace Components
|
|||||||
|
|
||||||
Bots::Bots()
|
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
|
// intercept the sprintf when creating the bot connect string
|
||||||
Utils::Hook(0x45655B, BuildConnectString, HOOK_CALL).install()->quick();
|
Utils::Hook(0x45655B, BuildConnectString, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#define MAX_G_BOTAI_ENTRIES 64
|
||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
@ -8,6 +9,63 @@ namespace Components
|
|||||||
Bots();
|
Bots();
|
||||||
~Bots();
|
~Bots();
|
||||||
private:
|
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<std::string> bot_names;
|
||||||
|
|
||||||
static const char* ConnectString;
|
static const char* ConnectString;
|
||||||
|
|
||||||
static int BuildConnectString(char*, const char*, int, int);
|
static int BuildConnectString(char*, const char*, int, int);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user