From 5bd62f666ef8bd3d87483678162f48602db6b3fc Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 29 Jan 2020 11:36:09 +0000 Subject: [PATCH] Add "maxhealth" console command to set the player's maximum health git-svn-id: https://svn.eduke32.com/eduke32@8542 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/osdcmds.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/duke3d/src/osdcmds.cpp b/source/duke3d/src/osdcmds.cpp index 0ed4fa039..2a2300366 100644 --- a/source/duke3d/src/osdcmds.cpp +++ b/source/duke3d/src/osdcmds.cpp @@ -200,6 +200,25 @@ static int osdcmd_god(osdcmdptr_t UNUSED(parm)) return OSDCMD_OK; } +static int osdcmd_maxhealth(osdcmdptr_t parm) +{ + if (parm->numparms != 1) + return OSDCMD_SHOWHELP; + + auto pPlayer = g_player[myconnectindex].ps; + + if (numplayers == 1 && pPlayer->gm & MODE_GAME) + { + int const newHealth = Batoi(parm->parms[0]); + pPlayer->max_player_health = newHealth; + sprite[pPlayer->i].extra = newHealth; + } + else + OSD_Printf("maxhealth: Not in a single-player game.\n"); + + return OSDCMD_OK; +} + static int osdcmd_noclip(osdcmdptr_t UNUSED(parm)) { UNREFERENCED_CONST_PARAMETER(parm); @@ -732,6 +751,7 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("give","give : gives requested item", osdcmd_give); OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god); OSD_RegisterFunction("activatecheat","activatecheat : activates a cheat code", osdcmd_activatecheat); + OSD_RegisterFunction("maxhealth", "maxhealth : sets the player's maximum health", osdcmd_maxhealth); OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);