Hook switching weapons

This commit is contained in:
ineedbots 2021-06-28 21:35:05 -06:00
parent 94f0869ad4
commit 38adae2c75
4 changed files with 64 additions and 0 deletions

View File

@ -41,6 +41,44 @@ namespace Components
}
}
void Bots::G_SelectWeaponIndex_Func(int wpIdx, int clNum)
{
Game::G_SelectWeaponIndex(wpIdx, clNum);
}
__declspec(naked) void Bots::G_SelectWeaponIndex_Stub()
{
__asm
{
push esi;
push eax;
call G_SelectWeaponIndex_Func;
add esp, 8;
retn;
}
}
void Bots::PlayerCmd_setSpawnWeapon_Func(Game::gentity_t* ent, int wpIdx)
{
}
__declspec(naked) void Bots::PlayerCmd_setSpawnWeapon_Stub()
{
__asm
{
push edx;
push esi;
call PlayerCmd_setSpawnWeapon_Func;
add esp, 8;
// go back
mov eax, [esi + 0x158];
push 0x52B16C;
retn;
}
}
Bots::Bots()
{
// intercept the sprintf when creating the bot connect string
@ -51,6 +89,13 @@ namespace Components
// stop the ping spam
Utils::Hook::Nop(0x45BF59, 5);
// fix bots switching weapons
Utils::Hook(0x52A1C2, G_SelectWeaponIndex_Stub, HOOK_CALL).install()->quick();
Utils::Hook(0x51E2DC, G_SelectWeaponIndex_Stub, HOOK_CALL).install()->quick();
Utils::Hook(0x501E0D, G_SelectWeaponIndex_Stub, HOOK_CALL).install()->quick();
Utils::Hook(0x52B166, PlayerCmd_setSpawnWeapon_Stub, HOOK_JUMP).install()->quick();
}
Bots::~Bots()

View File

@ -13,5 +13,11 @@ namespace Components
static int BuildConnectString(char*, const char*, int, int);
static void SV_BotUserMove_Func(Game::client_t*);
static void SV_BotUserMove_Stub();
static void G_SelectWeaponIndex_Func(int, int);
static void G_SelectWeaponIndex_Stub();
static void PlayerCmd_setSpawnWeapon_Func(Game::gentity_t*, int);
static void PlayerCmd_setSpawnWeapon_Stub();
};
}

View File

@ -65,6 +65,18 @@ namespace Game
bgs_ptr = ASSIGN(bgs_s**, 0x19A1C78);
}
void G_SelectWeaponIndex(int wpIdx, int clNum)
{
int func_loc = 0x5282E0;
__asm
{
mov esi, clNum;
mov eax, wpIdx;
call func_loc;
}
}
void SV_ClientThink(Game::usercmd_s* cmd, Game::client_t* client)
{
int func_loc = 0x456010;

View File

@ -39,6 +39,7 @@ namespace Game
typedef Game::xfunction_t* (Scr_GetFunction_t)(const char**, int*);
extern Scr_GetFunction_t* Scr_GetFunction;
extern void G_SelectWeaponIndex(int, int);
extern void SV_ClientThink(Game::usercmd_s*, Game::client_t*);
extern void SV_DropClient(Game::client_t*, const char*);
}