sp setviewpos
This commit is contained in:
parent
dc0ef1c813
commit
c7c27a1fa0
@ -51,8 +51,6 @@ namespace game
|
||||
SV_ClientEnterWorld_t SV_ClientEnterWorld;
|
||||
SV_Cmd_TokenizeString_t SV_Cmd_TokenizeString;
|
||||
SV_Cmd_EndTokenizedString_t SV_Cmd_EndTokenizedString;
|
||||
SV_GameSendServerCommand_t SV_GameSendServerCommand;
|
||||
SV_SendServerCommand_t SV_SendServerCommand;
|
||||
|
||||
XUIDToString_t XUIDToString;
|
||||
|
||||
@ -127,6 +125,7 @@ namespace game
|
||||
namespace mp
|
||||
{
|
||||
SV_GetGuid_t SV_GetGuid;
|
||||
SV_GameSendServerCommand_t SV_GameSendServerCommand;
|
||||
|
||||
client_t* svs_clients;
|
||||
}
|
||||
@ -139,6 +138,9 @@ namespace game
|
||||
namespace sp
|
||||
{
|
||||
IsServerRunning_t IsServerRunning;
|
||||
SV_GameSendServerCommand_t SV_GameSendServerCommand;
|
||||
|
||||
TeleportPlayer_t TeleportPlayer;
|
||||
|
||||
gentity_s* g_entities;
|
||||
|
||||
@ -658,18 +660,21 @@ namespace game
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) void teleport_player_dedicated(gentity_s* player, float* origin, float* angles)
|
||||
void teleport_player_dedicated(gentity_s* player, float* origin, float* angles)
|
||||
{
|
||||
static DWORD func = 0x48B840;
|
||||
|
||||
__asm
|
||||
{
|
||||
pushad
|
||||
|
||||
mov eax, player
|
||||
mov ecx, origin
|
||||
push angles
|
||||
call func
|
||||
add esp, 4h
|
||||
retn
|
||||
|
||||
popad
|
||||
}
|
||||
}
|
||||
|
||||
@ -1014,11 +1019,13 @@ namespace game
|
||||
native::SV_ClientEnterWorld = native::SV_ClientEnterWorld_t(SELECT_VALUE(0x0, 0x571100, 0x0));
|
||||
native::SV_Cmd_TokenizeString = native::SV_Cmd_TokenizeString_t(SELECT_VALUE(0x0, 0x545D40, 0x0));
|
||||
native::SV_Cmd_EndTokenizedString = native::SV_Cmd_EndTokenizedString_t(SELECT_VALUE(0x0, 0x545D70, 0x0));
|
||||
native::SV_GameSendServerCommand = native::SV_GameSendServerCommand_t(SELECT_VALUE(0x402130, 0x573220, 0x0));
|
||||
native::SV_SendServerCommand = native::SV_SendServerCommand_t(SELECT_VALUE(0x4F6990, 0x575DE0, 0x4FD5A0));
|
||||
native::mp::SV_GameSendServerCommand = native::mp::SV_GameSendServerCommand_t(0x573220);
|
||||
native::mp::SV_GetGuid = native::mp::SV_GetGuid_t(0x573990);
|
||||
|
||||
native::sp::IsServerRunning = native::sp::IsServerRunning_t(0x45D310);
|
||||
native::sp::SV_GameSendServerCommand = native::sp::SV_GameSendServerCommand_t(0x402130);
|
||||
|
||||
native::sp::TeleportPlayer = native::sp::TeleportPlayer_t(0x4CCEE0);
|
||||
|
||||
native::XUIDToString = native::XUIDToString_t(SELECT_VALUE(0x4FAA30, 0x55CC20, 0x0));
|
||||
|
||||
|
@ -106,12 +106,6 @@ namespace game
|
||||
typedef void (*SV_Cmd_EndTokenizedString_t)();
|
||||
extern SV_Cmd_EndTokenizedString_t SV_Cmd_EndTokenizedString;
|
||||
|
||||
typedef void (*SV_GameSendServerCommand_t)(int clientNum, svscmd_type type, const char* text);
|
||||
extern SV_GameSendServerCommand_t SV_GameSendServerCommand;
|
||||
|
||||
typedef void (*SV_SendServerCommand_t)(dedi::client_t* cl, svscmd_type type, const char* fmt, ...);
|
||||
extern SV_SendServerCommand_t SV_SendServerCommand;
|
||||
|
||||
typedef void (*XUIDToString_t)(const unsigned __int64* xuid, char* str);
|
||||
extern XUIDToString_t XUIDToString;
|
||||
|
||||
@ -214,6 +208,9 @@ namespace game
|
||||
typedef char* (*SV_GetGuid_t)(int clientNum);
|
||||
extern SV_GetGuid_t SV_GetGuid;
|
||||
|
||||
typedef void (*SV_GameSendServerCommand_t)(int clientNum, svscmd_type type, const char* text);
|
||||
extern SV_GameSendServerCommand_t SV_GameSendServerCommand;
|
||||
|
||||
extern client_t* svs_clients;
|
||||
}
|
||||
|
||||
@ -227,6 +224,12 @@ namespace game
|
||||
typedef bool (*IsServerRunning_t)();
|
||||
extern IsServerRunning_t IsServerRunning;
|
||||
|
||||
typedef void (*SV_GameSendServerCommand_t)(int clientNum, const char* text);
|
||||
extern SV_GameSendServerCommand_t SV_GameSendServerCommand;
|
||||
|
||||
typedef void (*TeleportPlayer_t)(gentity_s* player, float* origin, float* angles);
|
||||
extern TeleportPlayer_t TeleportPlayer;
|
||||
|
||||
extern gentity_s* g_entities;
|
||||
|
||||
extern gclient_s* g_clients;
|
||||
|
@ -964,7 +964,7 @@ namespace game
|
||||
|
||||
static_assert(sizeof(gclient_s) == 0x3980);
|
||||
|
||||
enum entityFlag
|
||||
enum
|
||||
{
|
||||
FL_GODMODE = 0x1,
|
||||
FL_DEMI_GODMODE = 0x2,
|
||||
|
@ -18,25 +18,12 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static void send_msg_to_client(int client_num, game::native::svscmd_type type, const char* string)
|
||||
{
|
||||
if (game::is_dedi())
|
||||
{
|
||||
game::native::SV_SendServerCommand(&game::native::dedi::svs_clients[client_num],
|
||||
type, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
game::native::SV_GameSendServerCommand(client_num, type, string);
|
||||
}
|
||||
}
|
||||
|
||||
// I know this is supposed to check sv_cheats but it's not even a registered dvar so why bother
|
||||
static bool cheats_ok(game::native::gentity_s* ent)
|
||||
{
|
||||
if (ent->health < 1)
|
||||
{
|
||||
send_msg_to_client(ent->s.number, game::native::SV_CMD_CAN_IGNORE,
|
||||
game::native::mp::SV_GameSendServerCommand(ent->s.number, game::native::SV_CMD_CAN_IGNORE,
|
||||
utils::string::va("%c \"GAME_MUSTBEALIVECOMMAND\"", 0x65));
|
||||
return false;
|
||||
}
|
||||
@ -44,6 +31,17 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cheats_ok_internal(game::native::sp::gentity_s* ent)
|
||||
{
|
||||
if (ent->health < 1)
|
||||
{
|
||||
game::native::sp::SV_GameSendServerCommand(ent->s.number, "print \"GAME_MUSTBEALIVECOMMAND\"");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void add_mp_client_commands()
|
||||
{
|
||||
command::add_sv("noclip", [](game::native::gentity_s* ent, [[maybe_unused]] const command::params_sv& params)
|
||||
@ -53,7 +51,7 @@ private:
|
||||
|
||||
ent->client->flags ^= 1;
|
||||
|
||||
send_msg_to_client(ent->s.number, game::native::SV_CMD_CAN_IGNORE,
|
||||
game::native::mp::SV_GameSendServerCommand(ent->s.number, game::native::SV_CMD_CAN_IGNORE,
|
||||
utils::string::va("%c \"%s\"", 0x65, (ent->client->flags & 1) ? "GAME_NOCLIPON" : "GAME_NOCLIPOFF"));
|
||||
});
|
||||
|
||||
@ -64,7 +62,7 @@ private:
|
||||
|
||||
ent->client->flags ^= 2;
|
||||
|
||||
send_msg_to_client(ent->s.number, game::native::SV_CMD_CAN_IGNORE,
|
||||
game::native::mp::SV_GameSendServerCommand(ent->s.number, game::native::SV_CMD_CAN_IGNORE,
|
||||
utils::string::va("%c \"%s\"", 0x65, (ent->client->flags & 2) ? "GAME_UFOON" : "GAME_UFOOFF"));
|
||||
});
|
||||
|
||||
@ -75,9 +73,8 @@ private:
|
||||
|
||||
ent->flags ^= game::native::FL_GODMODE;
|
||||
|
||||
send_msg_to_client(ent->s.number, game::native::SV_CMD_CAN_IGNORE,
|
||||
utils::string::va("%c \"%s\"", 0x65, (ent->flags & game::native::FL_GODMODE)
|
||||
? "GAME_GODMODE_ON" : "GAME_GODMODE_OFF"));
|
||||
game::native::mp::SV_GameSendServerCommand(ent->s.number, game::native::SV_CMD_CAN_IGNORE,
|
||||
utils::string::va("%c \"%s\"", 0x65, (ent->flags & game::native::FL_GODMODE) ? "GAME_GODMODE_ON" : "GAME_GODMODE_OFF"));
|
||||
});
|
||||
|
||||
command::add_sv("demigod", [](game::native::gentity_s* ent, [[maybe_unused]] const command::params_sv& params)
|
||||
@ -87,9 +84,8 @@ private:
|
||||
|
||||
ent->flags ^= game::native::FL_DEMI_GODMODE;
|
||||
|
||||
send_msg_to_client(ent->s.number, game::native::SV_CMD_CAN_IGNORE,
|
||||
utils::string::va("%c \"%s\"", 0x65, (ent->flags & game::native::FL_DEMI_GODMODE)
|
||||
? "GAME_DEMI_GODMODE_ON" : "GAME_DEMI_GODMODE_OFF"));
|
||||
game::native::mp::SV_GameSendServerCommand(ent->s.number, game::native::SV_CMD_CAN_IGNORE,
|
||||
utils::string::va("%c \"%s\"", 0x65, (ent->flags & game::native::FL_DEMI_GODMODE) ? "GAME_DEMI_GODMODE_ON" : "GAME_DEMI_GODMODE_OFF"));
|
||||
});
|
||||
|
||||
command::add_sv("notarget", [](game::native::gentity_s* ent, [[maybe_unused]] const command::params_sv& params)
|
||||
@ -99,9 +95,8 @@ private:
|
||||
|
||||
ent->flags ^= game::native::FL_NOTARGET;
|
||||
|
||||
send_msg_to_client(ent->s.number, game::native::SV_CMD_CAN_IGNORE,
|
||||
utils::string::va("%c \"%s\"", 0x65, (ent->flags & game::native::FL_NOTARGET)
|
||||
? "GAME_NOTARGETON" : "GAME_NOTARGETOFF"));
|
||||
game::native::mp::SV_GameSendServerCommand(ent->s.number, game::native::SV_CMD_CAN_IGNORE,
|
||||
utils::string::va("%c \"%s\"", 0x65, (ent->flags & game::native::FL_NOTARGET) ? "GAME_NOTARGETON" : "GAME_NOTARGETOFF"));
|
||||
});
|
||||
|
||||
command::add_sv("setviewpos", [](game::native::gentity_s* ent, [[maybe_unused]] const command::params_sv& params)
|
||||
@ -113,7 +108,7 @@ private:
|
||||
|
||||
if (params.size() < 4 || params.size() > 6)
|
||||
{
|
||||
send_msg_to_client(ent->s.number, game::native::SV_CMD_CAN_IGNORE,
|
||||
game::native::mp::SV_GameSendServerCommand(ent->s.number, game::native::SV_CMD_CAN_IGNORE,
|
||||
utils::string::va("%c \"GAME_USAGE\x15: setviewpos x y z [yaw] [pitch]\"", 0x65));
|
||||
return;
|
||||
}
|
||||
@ -145,7 +140,7 @@ private:
|
||||
|
||||
scheduler::once([ent]
|
||||
{
|
||||
ent->flags &= ~(game::native::entityFlag::FL_GODMODE | game::native::entityFlag::FL_DEMI_GODMODE);
|
||||
ent->flags &= ~(game::native::FL_GODMODE | game::native::FL_DEMI_GODMODE);
|
||||
ent->health = 0;
|
||||
game::native::player_die(ent, ent, ent, 100000, 12, nullptr, false, nullptr, game::native::hitLocation_t::HITLOC_NONE, 0);
|
||||
}, scheduler::pipeline::server);
|
||||
|
@ -89,7 +89,7 @@ void command::add(const char* name, const std::function<void(const command::para
|
||||
{
|
||||
const auto command = utils::string::to_lower(name);
|
||||
|
||||
if (handlers.find(command) == handlers.end())
|
||||
if (!handlers.contains(command))
|
||||
{
|
||||
add_raw(name, main_handler);
|
||||
}
|
||||
@ -99,7 +99,7 @@ void command::add(const char* name, const std::function<void(const command::para
|
||||
|
||||
void command::add(const char* name, const std::function<void()>& callback)
|
||||
{
|
||||
add(name, [callback](const command::params&)
|
||||
add(name, [callback]([[maybe_unused]] const params& params)
|
||||
{
|
||||
callback();
|
||||
});
|
||||
@ -110,7 +110,7 @@ void command::add_sv(const char* name, std::function<void(game::native::gentity_
|
||||
// Since the game console is not usable there is no point in calling add_raw
|
||||
const auto command = utils::string::to_lower(name);
|
||||
|
||||
if (handlers_sv.find(command) == handlers_sv.end())
|
||||
if (!handlers_sv.contains(command))
|
||||
{
|
||||
handlers_sv[command] = callback;
|
||||
}
|
||||
@ -120,7 +120,7 @@ void command::add_sp_sv(const char* name, std::function<void(game::native::sp::g
|
||||
{
|
||||
const auto command = utils::string::to_lower(name);
|
||||
|
||||
if (handlers_sp_sv.find(command) == handlers_sp_sv.end())
|
||||
if (!handlers_sp_sv.contains(command))
|
||||
{
|
||||
handlers_sp_sv[command] = callback;
|
||||
}
|
||||
@ -145,8 +145,8 @@ void command::main_handler()
|
||||
params params;
|
||||
|
||||
const auto command = utils::string::to_lower(params[0]);
|
||||
const auto got = command::handlers.find(command);
|
||||
|
||||
const auto got = command::handlers.find(command);
|
||||
if (got != handlers.end())
|
||||
{
|
||||
got->second(params);
|
||||
@ -165,8 +165,8 @@ void command::client_command_stub(int client_num)
|
||||
params_sv params;
|
||||
|
||||
const auto command = utils::string::to_lower(params[0]);
|
||||
const auto got = command::handlers_sv.find(command);
|
||||
|
||||
const auto got = command::handlers_sv.find(command);
|
||||
if (got != handlers_sv.end())
|
||||
{
|
||||
got->second(entity, params);
|
||||
@ -180,13 +180,13 @@ void command::client_command_sp(int client_num, const char* s)
|
||||
{
|
||||
auto* entity = &game::native::sp::g_entities[client_num];
|
||||
|
||||
assert(entity->client != nullptr); // On sp it should only be an assertion
|
||||
assert(entity->client); // On sp it should only be an assertion
|
||||
|
||||
params_sv params;
|
||||
|
||||
const auto command = utils::string::to_lower(params[0]);
|
||||
const auto got = command::handlers_sp_sv.find(command);
|
||||
|
||||
const auto got = command::handlers_sp_sv.find(command);
|
||||
if (got != handlers_sp_sv.end())
|
||||
{
|
||||
got->second(entity, params);
|
||||
@ -239,7 +239,6 @@ void command::add_sp_commands()
|
||||
return;
|
||||
|
||||
const auto* ent = &game::native::sp::g_entities[0];
|
||||
|
||||
if (ent->health < 1)
|
||||
return;
|
||||
|
||||
@ -257,7 +256,6 @@ void command::add_sp_commands()
|
||||
return;
|
||||
|
||||
const auto* ent = &game::native::sp::g_entities[0];
|
||||
|
||||
if (ent->health < 1)
|
||||
return;
|
||||
|
||||
@ -275,7 +273,6 @@ void command::add_sp_commands()
|
||||
return;
|
||||
|
||||
auto* ent = &game::native::sp::g_entities[0];
|
||||
|
||||
if (ent->health < 1)
|
||||
return;
|
||||
|
||||
@ -293,7 +290,6 @@ void command::add_sp_commands()
|
||||
return;
|
||||
|
||||
auto* ent = &game::native::sp::g_entities[0];
|
||||
|
||||
if (ent->health < 1)
|
||||
return;
|
||||
|
||||
@ -311,7 +307,6 @@ void command::add_sp_commands()
|
||||
return;
|
||||
|
||||
auto* ent = &game::native::sp::g_entities[0];
|
||||
|
||||
if (ent->health < 1)
|
||||
return;
|
||||
|
||||
@ -322,6 +317,44 @@ void command::add_sp_commands()
|
||||
const auto* msg = (ent->flags & game::native::FL_NOTARGET) ? "GAME_NOTARGETON" : "GAME_NOTARGETOFF";
|
||||
printf("%s\n", game::native::SEH_LocalizeTextMessage(msg, "notarget print", game::native::LOCMSG_SAFE));
|
||||
});
|
||||
|
||||
add("setviewpos", [](const params& params)
|
||||
{
|
||||
if (!game::native::sp::IsServerRunning())
|
||||
return;
|
||||
|
||||
auto* ent = &game::native::sp::g_entities[0];
|
||||
if (ent->health < 1)
|
||||
return;
|
||||
|
||||
assert(ent->s.eType == game::native::ET_PLAYER);
|
||||
assert(ent->client);
|
||||
|
||||
game::native::vec3_t origin, angles{ 0.f, 0.f, 0.f };
|
||||
|
||||
if (params.size() < 4 || params.size() > 6)
|
||||
{
|
||||
printf("setviewpos x y z [yaw] [pitch]\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto i = 0; i < 3; i++)
|
||||
{
|
||||
origin[i] = std::strtof(params.get(i + 1), nullptr);
|
||||
}
|
||||
|
||||
if (params.size() > 4)
|
||||
{
|
||||
angles[1] = std::strtof(params.get(4), nullptr); // Yaw
|
||||
}
|
||||
|
||||
if (params.size() == 6)
|
||||
{
|
||||
angles[0] = std::strtof(params.get(5), nullptr); // Pitch
|
||||
}
|
||||
|
||||
game::native::sp::TeleportPlayer(ent, origin, angles);
|
||||
});
|
||||
}
|
||||
|
||||
void command::post_load()
|
||||
|
Loading…
x
Reference in New Issue
Block a user