Noclip etc

This commit is contained in:
Joelrau 2021-01-13 02:48:57 +02:00
parent 7f0feed3ee
commit 116f921709
4 changed files with 154 additions and 12 deletions

View File

@ -295,6 +295,60 @@ namespace command
static void add_commands_sp()
{
add("god", []()
{
if (!game::SV_Loaded())
{
return;
}
game::sp::g_entities[0].flags ^= 1;
game::CG_GameMessage(0, utils::string::va("godmode %s",
game::sp::g_entities[0].flags & 1
? "^2on"
: "^1off"));
});
add("demigod", []()
{
if (!game::SV_Loaded())
{
return;
}
game::sp::g_entities[0].flags ^= 2;
game::CG_GameMessage(0, utils::string::va("demigod mode %s",
game::sp::g_entities[0].flags & 2
? "^2on"
: "^1off"));
});
add("noclip", []()
{
if (!game::SV_Loaded())
{
return;
}
game::sp::g_entities[0].client->flags ^= 1;
game::CG_GameMessage(0, utils::string::va("noclip %s",
game::sp::g_entities[0].client->flags & 1
? "^2on"
: "^1off"));
});
add("ufo", []()
{
if (!game::SV_Loaded())
{
return;
}
game::sp::g_entities[0].client->flags ^= 2;
game::CG_GameMessage(
0, utils::string::va("ufo %s", game::sp::g_entities[0].client->flags & 2 ? "^2on" : "^1off"));
});
add("give", [](const params& params)
{
if (!game::SV_Loaded())
@ -346,6 +400,70 @@ namespace command
{
client_command_hook.create(0x1402E98F0, &client_command);
add_sv("god", [&](const int client_num, const params_sv&)
{
if (!game::Dvar_FindVar("sv_cheats")->current.enabled)
{
game::SV_GameSendServerCommand(client_num, 1, "f \"Cheats are not enabled on this server\"");
return;
}
game::mp::g_entities[client_num].flags ^= 1;
game::SV_GameSendServerCommand(client_num, 1,
utils::string::va("f \"godmode %s\"",
game::mp::g_entities[client_num].flags & 1
? "^2on"
: "^1off"));
});
add_sv("demigod", [&](const int client_num, const params_sv&)
{
if (!game::Dvar_FindVar("sv_cheats")->current.enabled)
{
game::SV_GameSendServerCommand(client_num, 1, "f \"Cheats are not enabled on this server\"");
return;
}
game::mp::g_entities[client_num].flags ^= 2;
game::SV_GameSendServerCommand(client_num, 2,
utils::string::va("f \"demigod mode %s\"",
game::mp::g_entities[client_num].flags & 1
? "^2on"
: "^1off"));
});
add_sv("noclip", [&](const int client_num, const params_sv&)
{
if (!game::Dvar_FindVar("sv_cheats")->current.enabled)
{
game::SV_GameSendServerCommand(client_num, 1, "f \"Cheats are not enabled on this server\"");
return;
}
game::mp::g_entities[client_num].client->flags ^= 1;
game::SV_GameSendServerCommand(client_num, 1,
utils::string::va("f \"noclip %s\"",
game::mp::g_entities[client_num].client->flags & 1
? "^2on"
: "^1off"));
});
add_sv("ufo", [&](const int client_num, const params_sv&)
{
if (!game::Dvar_FindVar("sv_cheats")->current.enabled)
{
game::SV_GameSendServerCommand(client_num, 1, "f \"Cheats are not enabled on this server\"");
return;
}
game::mp::g_entities[client_num].client->flags ^= 2;
game::SV_GameSendServerCommand(client_num, 1,
utils::string::va("f \"ufo %s\"",
game::mp::g_entities[client_num].client->flags & 2
? "^2on"
: "^1off"));
});
add_sv("give", [](const int client_num, const params_sv& params)
{
if (!game::Dvar_FindVar("sv_cheats")->current.enabled)

View File

@ -112,7 +112,7 @@ namespace party
auto count = 0;
for (auto i = 0; i < *game::mp::svs_numclients; ++i)
{
if (game::mp::svs_clients[i].header.state >= 3)
if (game::mp::svs_clients[i].header.state >= 1)
{
++count;
}
@ -126,7 +126,7 @@ namespace party
auto count = 0;
for (auto i = 0; i < *game::mp::svs_numclients; ++i)
{
if (game::mp::svs_clients[i].header.state >= 3 &&
if (game::mp::svs_clients[i].header.state >= 1 &&
game::SV_BotIsBot(i))
{
++count;

View File

@ -209,10 +209,13 @@ namespace patches
// Patch SV_KickClientNum
sv_kick_client_num_hook.create(0x1404377A0, &sv_kick_client_num);
// block changing name in-game
utils::hook::set<uint8_t>(0x140438850, 0xC3);
// patch "Couldn't find the bsp for this map." error to not be fatal in mp
utils::hook::call(0x14026E63B, bsp_sys_error_stub);
//client side aim assist dvar
// client side aim assist dvar
dvars::aimassist_enabled = game::Dvar_RegisterBool("aimassist_enabled", true,
game::DvarFlags::DVAR_FLAG_SAVED,
"Enables aim assist for controllers");

View File

@ -902,23 +902,36 @@ namespace game
Material* material;
};
enum TestClientType
{
TC_NONE = 0x0,
TC_TEST_CLIENT = 0x1,
TC_BOT = 0x2,
TC_COUNT = 0x3,
};
namespace mp
{
struct gclient_s
{
};
char __pad0[21407];
int flags;
}; // size = ?
struct EntityState
{
int entityNum;
char entityNum;
}; // size = ?
struct gentity_s
{
EntityState s;
char __pad[88];
}; // size = 92
char __pad0[343];
gclient_s* client;
char __pad1[80];
int flags;
char __pad2[300];
}; // size = 736
struct playerState_s
{
@ -928,12 +941,16 @@ namespace game
struct clientHeader_t
{
int state;
}; // /size = ?
}; // size = ?
struct client_t
{
clientHeader_t header;
char __pad[661300];
char __pad0[268972];
gentity_s* gentity;
char __pad1[616];
TestClientType testClient;
char __pad2[391700];
}; // size = 661304
}
@ -941,12 +958,16 @@ namespace game
{
struct gclient_s
{
char __pad[56135];
int flags; // 56136
};
struct gentity_s
{
char __pad0[280];
gclient_s* client; // 280
char __pad1[76];
int flags; // 364
};
struct playerState_s