99% non-plagiarised kill command implementation

This commit is contained in:
Diavolo 2022-05-27 12:30:43 +02:00
parent 9cb9f46663
commit b072815407
3 changed files with 22 additions and 0 deletions

View File

@ -245,6 +245,23 @@ namespace Components
assert(ent != nullptr);
ent->client->ps.stunTime = 1000 + Game::level->time; // 1000 is the default test stun time
});
ClientCommand::Add("kill", []([[maybe_unused]] Game::gentity_s* ent, [[maybe_unused]] Command::ServerParams* params)
{
assert(ent->client != nullptr);
assert(ent->client->connected != Game::clientConnected_t::CON_DISCONNECTED);
if (ent->client->sessionState != Game::sessionState_t::SESS_STATE_PLAYING || !ClientCommand::CheatsOk(ent))
return;
Scheduler::Once([ent]
{
ent->flags &= ~(Game::entityFlag::FL_GODMODE | Game::entityFlag::FL_DEMI_GODMODE);
ent->health = 0;
ent->client->ps.stats[0] = 0;
Game::player_die(ent, ent, ent, 100000, 12, 0, nullptr, Game::hitLocation_t::HITLOC_NONE, 0);
}, Scheduler::Pipeline::SERVER);
});
}
void ClientCommand::AddScriptFunctions()

View File

@ -431,6 +431,8 @@ namespace Game
IN_Init_t IN_Init = IN_Init_t(0x45D620);
IN_Shutdown_t IN_Shutdown = IN_Shutdown_t(0x426360);
player_die_t player_die = player_die_t(0x42BC70);
XAssetHeader* DB_XAssetPool = reinterpret_cast<XAssetHeader*>(0x7998A8);
unsigned int* g_poolSize = reinterpret_cast<unsigned int*>(0x7995E8);

View File

@ -1029,6 +1029,9 @@ namespace Game
typedef void(__cdecl * IN_Shutdown_t)();
extern IN_Shutdown_t IN_Shutdown;
typedef void(__cdecl * player_die_t)(gentity_s* self, const gentity_s* inflictor, gentity_s* attacker, int damage, int meansOfDeath, int iWeapon, const float* vDir, const hitLocation_t hitLoc, int psTimeOffset);
extern player_die_t player_die;
extern XAssetHeader* DB_XAssetPool;
extern unsigned int* g_poolSize;