From f40b27946cfdb428998aa81116febb86f0aa1f3e Mon Sep 17 00:00:00 2001 From: quaK <38787176+Joelrau@users.noreply.github.com> Date: Sun, 9 May 2021 09:37:02 +0300 Subject: [PATCH] Add some commands --- src/component/command.cpp | 56 +++++++++++++++++++++++++++++++++++++++ src/game/structs.hpp | 6 ++++- src/game/symbols.hpp | 6 +++++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/src/component/command.cpp b/src/component/command.cpp index 371897e4..0b7fe9d0 100644 --- a/src/component/command.cpp +++ b/src/component/command.cpp @@ -154,6 +154,8 @@ namespace command { utils::hook::jump(game::base_address + 0x5A74F0, dvar_command_stub, true); + add("quit", game::Com_Quit_f); + add("startmap", [](const params& params) { const auto map = params.get(1); @@ -232,6 +234,60 @@ namespace command printf("======== End command dump =========\n"); }); + + add("god", []() + { + if (!game::SV_Loaded()) + { + return; + } + + game::g_entities[0].flags ^= 1; + game::CG_GameMessage(0, utils::string::va("godmode %s", + game::g_entities[0].flags & 1 + ? "^2on" + : "^1off")); + }); + + add("demigod", []() + { + if (!game::SV_Loaded()) + { + return; + } + + game::g_entities[0].flags ^= 2; + game::CG_GameMessage(0, utils::string::va("demigod mode %s", + game::g_entities[0].flags & 2 + ? "^2on" + : "^1off")); + }); + + add("noclip", []() + { + if (!game::SV_Loaded()) + { + return; + } + + game::g_entities[0].client->flags ^= 1; + game::CG_GameMessage(0, utils::string::va("noclip %s", + game::g_entities[0].client->flags & 1 + ? "^2on" + : "^1off")); + }); + + add("ufo", []() + { + if (!game::SV_Loaded()) + { + return; + } + + game::g_entities[0].client->flags ^= 2; + game::CG_GameMessage( + 0, utils::string::va("ufo %s", game::g_entities[0].client->flags & 2 ? "^2on" : "^1off")); + }); } }; } diff --git a/src/game/structs.hpp b/src/game/structs.hpp index 79752635..5dbefb9d 100644 --- a/src/game/structs.hpp +++ b/src/game/structs.hpp @@ -11,6 +11,8 @@ namespace game { char __pad0[0x8C]; vec3_t velocity; + char __pad1[59504]; + char flags; }; struct client_t @@ -29,7 +31,9 @@ namespace game vec3_t origin; char __pad1[0xF0]; gclient_s* client; - //char __pad3[480]; + char __pad2[0x4C]; + char flags; + //char __pad3[392]; }; // size = 760 struct Material diff --git a/src/game/symbols.hpp b/src/game/symbols.hpp index 8bde3471..66ee92b1 100644 --- a/src/game/symbols.hpp +++ b/src/game/symbols.hpp @@ -11,9 +11,13 @@ namespace game WEAK symbol Cbuf_AddText{0x59A050}; + WEAK symbol CG_GameMessage{0x37F450}; + WEAK symbol Cmd_AddCommandInternal{0x59A5F0}; WEAK symbol Cmd_ExecuteSingleCommand{0x59ABA0}; + WEAK symbol Com_Quit_f{0x5A50D0}; + WEAK symbol DB_EnumXAssets_Internal{0x4129F0}; WEAK symbol DB_GetXAssetName{0x3E4090}; @@ -66,6 +70,8 @@ namespace game WEAK symbol SL_ConvertToString{0x5BFBB0}; WEAK symbol SL_GetString{0x5C0170}; + WEAK symbol SV_Loaded{0x6B3860}; + WEAK symbol Sys_ShowConsole{0x633080}; WEAK symbol UI_SafeTranslateString{0x5A2930};