[ClientCommand] Add kill

This commit is contained in:
FutureRave 2022-05-12 14:14:59 +01:00
parent 8b9004472b
commit 949d6ad9d5
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955
5 changed files with 93 additions and 10 deletions

View File

@ -81,6 +81,8 @@ namespace game
Com_Quit_f_t Com_Quit_f;
player_die_t player_die;
decltype(longjmp)* _longjmp;
CmdArgs* sv_cmd_args;
@ -701,6 +703,8 @@ namespace game
native::Com_Quit_f = native::Com_Quit_f_t(SELECT_VALUE(0x4F48B0, 0x5556B0, 0x4D95B0));
native::player_die = native::player_die_t(SELECT_VALUE(0x0, 0x503460, 0x47F4D0));
native::_longjmp = reinterpret_cast<decltype(longjmp)*>(SELECT_VALUE(0x73AC20, 0x7363BC, 0x655558));
native::sv_cmd_args = reinterpret_cast<native::CmdArgs*>(SELECT_VALUE(0x1757218, 0x1CAA998, 0x1B5E7D8));

View File

@ -133,6 +133,9 @@ namespace game
typedef void (*Com_Quit_f_t)();
extern Com_Quit_f_t Com_Quit_f;
typedef void (*player_die_t)(gentity_s* self, const gentity_s* inflictor, gentity_s* attacker, int damage, int meansOfDeath, const Weapon* iWeapon, bool isAlternate, const float* vDir, const hitLocation_t hitLoc, int psTimeOffset);
extern player_die_t player_die;
extern decltype(longjmp)* _longjmp;
constexpr auto CMD_MAX_NESTING = 8;

View File

@ -736,6 +736,32 @@ namespace game
static_assert(sizeof(weaponParms) == 0x4C);
enum hitLocation_t
{
HITLOC_NONE = 0x0,
HITLOC_HELMET = 0x1,
HITLOC_HEAD = 0x2,
HITLOC_NECK = 0x3,
HITLOC_TORSO_UPR = 0x4,
HITLOC_TORSO_LWR = 0x5,
HITLOC_R_ARM_UPR = 0x6,
HITLOC_L_ARM_UPR = 0x7,
HITLOC_R_ARM_LWR = 0x8,
HITLOC_L_ARM_LWR = 0x9,
HITLOC_R_HAND = 0xA,
HITLOC_L_HAND = 0xB,
HITLOC_R_LEG_UPR = 0xC,
HITLOC_L_LEG_UPR = 0xD,
HITLOC_R_LEG_LWR = 0xE,
HITLOC_L_LEG_LWR = 0xF,
HITLOC_R_FOOT = 0x10,
HITLOC_L_FOOT = 0x11,
HITLOC_GUN = 0x12,
HITLOC_SHIELD = 0x13,
HITLOC_NUM = 0x14,
};
enum ViewLockTypes
{
PLAYERVIEWLOCK_NONE = 0x0,
@ -800,10 +826,10 @@ namespace game
unsigned char __pad0[0x470];
unsigned int perks[0x2];
unsigned int perkSlots[0x9];
unsigned char __pad1[0x2DE8];
unsigned char __pad1[0x2DF4];
};
static_assert(sizeof(playerState_s) == 0x3300);
static_assert(sizeof(playerState_s) == 0x330C);
struct pmove_t
{
@ -831,12 +857,46 @@ namespace game
static_assert(sizeof(pmove_t) == 0x138);
enum sessionState_t
{
SESS_STATE_PLAYING = 0x0,
SESS_STATE_DEAD = 0x1,
SESS_STATE_SPECTATOR = 0x2,
SESS_STATE_INTERMISSION = 0x3,
};
enum clientConnected_t
{
CON_DISCONNECTED = 0x0,
CON_CONNECTING = 0x1,
CON_CONNECTED = 0x2,
};
struct clientSession_t
{
sessionState_t sessionState;
int forceSpectatorClient;
int killCamEntity;
int killCamLookAtEntity;
int status_icon;
int archiveTime;
int score;
int deaths;
int kills;
int assists;
unsigned __int16 scriptPersId;
clientConnected_t connected;
unsigned char __pad0[0x290];
};
static_assert(sizeof(clientSession_t) == 0x2C0);
struct gclient_s
{
playerState_s ps;
unsigned char __pad0[0x2CC];
clientSession_t sess;
int flags;
unsigned char __pad1[0x3B0];
unsigned char __pad0[0x3B0];
};
static_assert(sizeof(gclient_s) == 0x3980);

View File

@ -4,6 +4,7 @@
#include "game/game.hpp"
#include "command.hpp"
#include "scheduler.hpp"
class client_command final : public module
{
@ -127,13 +128,28 @@ private:
angles[1] = std::strtof(params.get(4), nullptr); // Yaw
}
if (params.size() == 6u)
if (params.size() == 6)
{
angles[0] = std::strtof(params.get(5), nullptr); // Pitch
}
game::native::TeleportPlayer(ent, origin, angles);
});
command::add_sv("kill", [](game::native::gentity_s* ent, [[maybe_unused]] const command::params_sv& params)
{
assert(ent->client->sess.connected != game::native::CON_DISCONNECTED);
if (ent->client->sess.sessionState != game::native::SESS_STATE_PLAYING || !cheats_ok(ent))
return;
scheduler::once([ent]
{
ent->flags &= ~(game::native::entityFlag::FL_GODMODE | game::native::entityFlag::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);
});
}
};

View File

@ -18,12 +18,12 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mshtml.h>
#include <mshtmhst.h>
#include <Windows.h>
#include <MsHTML.h>
#include <MsHtmHst.h>
#include <ExDisp.h>
#include <WinSock2.h>
#include <Ws2tcpip.h>
#include <WS2tcpip.h>
#include <corecrt_io.h>
#include <fcntl.h>
#include <shellapi.h>