mirror of
https://github.com/ineedbots/cod2m.git
synced 2025-04-20 00:12:52 +00:00
Hook switching weapons
This commit is contained in:
parent
94f0869ad4
commit
38adae2c75
@ -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()
|
Bots::Bots()
|
||||||
{
|
{
|
||||||
// intercept the sprintf when creating the bot connect string
|
// intercept the sprintf when creating the bot connect string
|
||||||
@ -51,6 +89,13 @@ namespace Components
|
|||||||
|
|
||||||
// stop the ping spam
|
// stop the ping spam
|
||||||
Utils::Hook::Nop(0x45BF59, 5);
|
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()
|
Bots::~Bots()
|
||||||
|
@ -13,5 +13,11 @@ namespace Components
|
|||||||
static int BuildConnectString(char*, const char*, int, int);
|
static int BuildConnectString(char*, const char*, int, int);
|
||||||
static void SV_BotUserMove_Func(Game::client_t*);
|
static void SV_BotUserMove_Func(Game::client_t*);
|
||||||
static void SV_BotUserMove_Stub();
|
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();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,18 @@ namespace Game
|
|||||||
bgs_ptr = ASSIGN(bgs_s**, 0x19A1C78);
|
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)
|
void SV_ClientThink(Game::usercmd_s* cmd, Game::client_t* client)
|
||||||
{
|
{
|
||||||
int func_loc = 0x456010;
|
int func_loc = 0x456010;
|
||||||
|
@ -39,6 +39,7 @@ namespace Game
|
|||||||
typedef Game::xfunction_t* (Scr_GetFunction_t)(const char**, int*);
|
typedef Game::xfunction_t* (Scr_GetFunction_t)(const char**, int*);
|
||||||
extern Scr_GetFunction_t* Scr_GetFunction;
|
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_ClientThink(Game::usercmd_s*, Game::client_t*);
|
||||||
extern void SV_DropClient(Game::client_t*, const char*);
|
extern void SV_DropClient(Game::client_t*, const char*);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user