Noclip, ufo, etc... commands

This commit is contained in:
Federico Cecchetto 2022-05-29 23:16:10 +02:00
parent 9637e9b6bf
commit 16af5a0d0b
4 changed files with 73 additions and 13 deletions

View File

@ -635,7 +635,7 @@ namespace command
static void add_commands_sp()
{
/*add("god", []()
add("god", []()
{
if (!game::SV_Loaded())
{
@ -723,14 +723,14 @@ namespace command
}
cmd_give_weapon(0, params.get_all());
});*/
});
}
static void add_commands_mp()
{
client_command_hook.create(0x4132E0_b, &client_command);
/*add_sv("god", [](const int client_num, const params_sv&)
add_sv("god", [](const int client_num, const params_sv&)
{
if (!check_cheats(client_num))
{
@ -777,8 +777,8 @@ namespace command
return;
}
toggle_client_flag(client_num, 2, "noclip");
});*/
toggle_client_flag(client_num, 2, "ufo");
});
add_sv("give", [](const int client_num, const params_sv& params)
{

View File

@ -21,6 +21,10 @@ namespace gameplay
utils::hook::detour stuck_in_client_hook;
utils::hook::detour cm_transformed_capsule_trace_hook;
utils::hook::detour client_end_frame_hook;
utils::hook::detour g_damage_client_hook;
utils::hook::detour g_damage_hook;
game::dvar_t* jump_slowDownEnable;
game::dvar_t* jump_enableFallDamage;
@ -168,6 +172,52 @@ namespace gameplay
a.bind(allsolid);
a.jmp(0x2C9F9F_b);
};
void client_end_frame_stub2(game::mp::gentity_s* entity)
{
client_end_frame_hook.invoke<void>(entity);
if ((entity->client->flags & 1)) // noclip
{
entity->client->pm_type = 2;
}
else if ((entity->client->flags & 2)) // ufo
{
entity->client->pm_type = 3;
}
}
void g_damage_client_stub(game::mp::gentity_s* targ, const game::mp::gentity_s* inflictor, game::mp::gentity_s* attacker,
const float* dir, const float* point, int damage, int dflags, int mod,
const unsigned int weapon, bool is_alternate, unsigned int hit_loc, int time_offset)
{
if ((targ->client->flags & 1) || (targ->client->flags & 2)) // noclip, ufo
{
return;
}
g_damage_client_hook.invoke<void>(targ, inflictor, attacker, dir, point, damage, dflags, mod,
weapon, is_alternate, hit_loc, time_offset);
}
void g_damage_stub(game::mp::gentity_s* targ, const game::mp::gentity_s* inflictor, game::mp::gentity_s* attacker,
const float* dir, const float* point, int damage, int dflags, int mod,
const unsigned int weapon, bool is_alternate, unsigned int hit_loc,
unsigned int model_index, unsigned int part_name, int time_offset)
{
if (targ->flags & 1) // godmode
{
return;
}
if (targ->flags & 2) // demigod
{
damage = 1;
}
g_damage_hook.invoke<void>(targ, inflictor, attacker, dir, point, damage, dflags, mod, weapon,
is_alternate, hit_loc, model_index, part_name, time_offset);
}
}
class component final : public component_interface
@ -230,6 +280,11 @@ namespace gameplay
dvars::g_playerCollision = dvars::register_bool("g_playerCollision", true, game::DVAR_FLAG_REPLICATED,
"Flag whether player collision is on or off");
cm_transformed_capsule_trace_hook.create(0x4D63C0_b, cm_transformed_capsule_trace_stub);
// Make noclip work
client_end_frame_hook.create(0x3FF7D0_b, client_end_frame_stub2);
g_damage_client_hook.create(0x414F10_b, g_damage_client_stub);
g_damage_hook.create(0x414A10_b, g_damage_stub);
}
};
}

View File

@ -1501,12 +1501,17 @@ namespace game
struct gclient_s
{
char __pad0[18834];
char name[32]; // 18720
char __pad1[622];
char __pad0[2];
char pm_type; // 2
char __pad1[18831];
char name[32]; // 18834
char __pad2[622];
int flags; // 19488
}; // size = ?
static_assert(offsetof(gclient_s, name) == 18834);
static_assert(offsetof(gclient_s, flags) == 19488);
struct EntityState
{
uint16_t entityNum;

View File

@ -59,8 +59,8 @@ namespace game
WEAK symbol<void()> Quit{0x3A5A20, 0x17CF50};
WEAK symbol<void(int localClientNum, const char* message)> CG_GameMessage{0x0, 0x316210};
WEAK symbol<void(int localClientNum, const char* message)> CG_GameMessageBold{0x0, 0x3122F0};
WEAK symbol<void(int localClientNum, const char* message)> CG_GameMessage{0x15B3B0, 0x316210};
WEAK symbol<void(int localClientNum, const char* message)> CG_GameMessageBold{0x15B110, 0x3122F0};
WEAK symbol<void(int localClientNum, /*mp::cg_s**/void* cg,
const char* dvar, const char* value)> CG_SetClientDvarFromServer{0x0, 0x0};
WEAK symbol<char*(const unsigned int weapon,
@ -112,8 +112,8 @@ namespace game
WEAK symbol<unsigned int(const char* name)> G_GetWeaponForName{0x2F20F0, 0x461180};
WEAK symbol<int(playerState_s* ps, unsigned int weapon, int dualWield,
int startInAltMode, int, int, int, char, ...)> G_GivePlayerWeapon{0x2F24F0, 0x461600};
WEAK symbol<void(playerState_s* ps, unsigned int weapon, int hadWeapon)> G_InitializeAmmo{0x0, 0x41C170};
WEAK symbol<void(int clientNum, unsigned int weapon)> G_SelectWeapon{0x0, 0x462560};
WEAK symbol<void(playerState_s* ps, unsigned int weapon, int hadWeapon)> G_InitializeAmmo{0x29D9E0, 0x41C170};
WEAK symbol<void(int clientNum, unsigned int weapon)> G_SelectWeapon{0x2F2EA0, 0x462560};
WEAK symbol<int(playerState_s* ps, unsigned int weapon)> G_TakePlayerWeapon{0x2F3050, 0x462770};
WEAK symbol<char*(char* string)> I_CleanStr{0x4293E0, 0x5AF2E0};
@ -196,7 +196,7 @@ namespace game
WEAK symbol<const char*(int clientNum)> SV_GetGuid{0x0, 0x551D90};
WEAK symbol<int(int clientNum)> SV_GetClientPing{0x0, 0x551D70};
WEAK symbol<playerState_s* (int num)> SV_GetPlayerstateForClientNum{0x0, 0x551E10};
WEAK symbol<playerState_s* (int num)> SV_GetPlayerstateForClientNum{0x4C3F10, 0x551E10};
WEAK symbol<void(int index, const char* string)> SV_SetConfigstring{0x0, 0x553E60};
WEAK symbol<bool()> SV_Loaded{0x4C4810, 0x553970};
WEAK symbol<void(int clientNum, const char* reason)> SV_KickClientNum{0x0, 0x54C060};