From f17577c7d18841d7c6e6dc085a2a57a06876f070 Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Fri, 30 Jul 2021 04:13:43 +0200 Subject: [PATCH] Add give command --- src/component/command.cpp | 25 +++++++++++++++++++++++++ src/game/symbols.hpp | 6 ++++++ 2 files changed, 31 insertions(+) diff --git a/src/component/command.cpp b/src/component/command.cpp index 0b7fe9d0..c784bf60 100644 --- a/src/component/command.cpp +++ b/src/component/command.cpp @@ -288,6 +288,31 @@ namespace command game::CG_GameMessage( 0, utils::string::va("ufo %s", game::g_entities[0].client->flags & 2 ? "^2on" : "^1off")); }); + + add("give", [](const params& params) + { + if (!game::SV_Loaded()) + { + return; + } + + if (params.size() < 2) + { + game::CG_GameMessage(0, "You did not specify a weapon name"); + return; + } + + auto ps = game::g_entities[0].client; + const auto wp = game::G_GetWeaponForName(params.get(1)); + if (wp) + { + if (game::G_GivePlayerWeapon(ps, wp, 0, 0, 0, 0)) + { + game::G_InitializeAmmo(ps, wp, 0); + game::G_SelectWeapon(0, wp); + } + } + }); } }; } diff --git a/src/game/symbols.hpp b/src/game/symbols.hpp index 66ee92b1..77569c50 100644 --- a/src/game/symbols.hpp +++ b/src/game/symbols.hpp @@ -43,6 +43,12 @@ namespace game WEAK symbol FindEntityId{0x5C1C50}; WEAK symbol GetEntityFieldValue{0x5C6100}; + WEAK symbol G_GetWeaponForName{0x51B260}; + WEAK symbol + G_GivePlayerWeapon{0x51B660}; + WEAK symbol G_InitializeAmmo{0x4C4110}; + WEAK symbol G_SelectWeapon{0x51C0D0}; + WEAK symbol I_CleanStr{0x620660}; WEAK symbol LUI_OpenMenu{0x5F0EE0};