2020-09-02 22:41:32 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 sirlemonhead, Nuke.YKT
|
|
|
|
This file is part of PCExhumed.
|
|
|
|
PCExhumed is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
#include "ns.h"
|
2020-09-06 10:44:58 +00:00
|
|
|
#include "automap.h"
|
2020-09-02 22:41:32 +00:00
|
|
|
#include "compat.h"
|
|
|
|
#include "engine.h"
|
|
|
|
#include "exhumed.h"
|
|
|
|
#include "sequence.h"
|
|
|
|
#include "names.h"
|
|
|
|
#include "player.h"
|
2021-01-01 22:38:15 +00:00
|
|
|
#include "input.h"
|
2020-09-02 22:41:32 +00:00
|
|
|
#include "sound.h"
|
|
|
|
#include "view.h"
|
|
|
|
#include "status.h"
|
|
|
|
#include "version.h"
|
|
|
|
#include "gamecvars.h"
|
|
|
|
#include "savegamehelp.h"
|
|
|
|
#include "c_dispatch.h"
|
|
|
|
#include "raze_sound.h"
|
|
|
|
#include "gamestate.h"
|
|
|
|
#include "c_console.h"
|
|
|
|
#include "cheathandler.h"
|
|
|
|
#include "inputstate.h"
|
|
|
|
#include "d_protocol.h"
|
|
|
|
#include "gstrings.h"
|
2020-09-03 15:39:41 +00:00
|
|
|
#include "aistuff.h"
|
|
|
|
#include "mmulti.h"
|
2020-09-02 22:41:32 +00:00
|
|
|
|
|
|
|
BEGIN_PS_NS
|
|
|
|
|
|
|
|
|
|
|
|
static const char* GodCheat(int nPlayer, int state)
|
|
|
|
{
|
|
|
|
if (state == -1)
|
|
|
|
{
|
|
|
|
if (PlayerList[nPlayer].invincibility >= 0)
|
|
|
|
PlayerList[nPlayer].invincibility = -1;
|
|
|
|
else
|
|
|
|
PlayerList[nPlayer].invincibility = 0;
|
|
|
|
}
|
|
|
|
else PlayerList[nPlayer].invincibility = -state;
|
|
|
|
|
|
|
|
return GStrings(PlayerList[nPlayer].invincibility ? "TXT_EX_DEITYON" : "TXT_EX_DEITYOFF");
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* SlipCheat()
|
|
|
|
{
|
|
|
|
if (bSlipMode == false)
|
|
|
|
{
|
|
|
|
bSlipMode = true;
|
|
|
|
return GStrings("TXT_EX_SLIPON");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bSlipMode = false;
|
|
|
|
return GStrings("TXT_EX_SLIPOFF");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char* GameInterface::GenericCheat(int player, int cheat)
|
|
|
|
{
|
|
|
|
switch (cheat)
|
|
|
|
{
|
|
|
|
case CHT_GOD:
|
|
|
|
return GodCheat(player, -1);
|
|
|
|
|
|
|
|
case CHT_GODOFF:
|
|
|
|
return GodCheat(player, 0);
|
|
|
|
|
|
|
|
case CHT_GODON:
|
|
|
|
return GodCheat(player, 1);
|
|
|
|
|
|
|
|
case CHT_NOCLIP:
|
|
|
|
return SlipCheat();
|
|
|
|
|
|
|
|
default:
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool HollyCheat(cheatseq_t* c)
|
|
|
|
{
|
|
|
|
// Do the closest thing to this cheat that's available.
|
|
|
|
C_ToggleConsole();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool KimberlyCheat(cheatseq_t* c)
|
|
|
|
{
|
|
|
|
Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_SWEETIE"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool LiteCheat(cheatseq_t* c)
|
|
|
|
{
|
|
|
|
Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_FLASHES"));
|
|
|
|
bDoFlashes = !bDoFlashes;
|
2020-12-06 19:25:23 +00:00
|
|
|
g_visibility = 1024 + 512 - g_visibility; // let there be light - for real!
|
2020-09-02 22:41:32 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool SnakeCheat(cheatseq_t* c)
|
|
|
|
{
|
|
|
|
if (!nNetPlayerCount)
|
|
|
|
{
|
|
|
|
if (bSnakeCam == false)
|
|
|
|
{
|
|
|
|
bSnakeCam = true;
|
|
|
|
Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_SNAKEON"));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bSnakeCam = false;
|
|
|
|
Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_SNAKEOFF"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool SphereCheat(cheatseq_t* c)
|
|
|
|
{
|
|
|
|
Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_FULLMAP"));
|
2020-09-06 08:42:39 +00:00
|
|
|
gFullMap = !gFullMap; // only set the cheat flag so it can be toggled.
|
|
|
|
bShowTowers = gFullMap;
|
2020-09-02 22:41:32 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static cheatseq_t excheats[] = {
|
|
|
|
{"holly", nullptr, HollyCheat, 0},
|
|
|
|
{"kimberly", nullptr, KimberlyCheat, 0},
|
2020-09-02 23:32:51 +00:00
|
|
|
{"lobocop", "give weapons" },
|
2020-09-02 22:41:32 +00:00
|
|
|
{"lobodeity", "god" },
|
|
|
|
{"lobolite", nullptr, LiteCheat, 0},
|
2020-09-02 23:32:51 +00:00
|
|
|
{"lobopick", "give keys" },
|
2020-09-02 22:41:32 +00:00
|
|
|
{"loboslip", "noclip" },
|
2020-09-02 23:32:51 +00:00
|
|
|
{"lobosnake", nullptr, SnakeCheat },
|
2020-09-02 22:41:32 +00:00
|
|
|
{"lobosphere", nullptr, SphereCheat, 0},
|
2020-09-02 23:32:51 +00:00
|
|
|
{"loboswag", "give inventory" },
|
2020-09-02 22:41:32 +00:00
|
|
|
{"loboxy", "stat printcoords", nullptr, true},
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-09-03 15:39:41 +00:00
|
|
|
static void cmd_Give(int player, uint8_t** stream, bool skip)
|
|
|
|
{
|
|
|
|
int type = ReadByte(stream);
|
|
|
|
if (skip) return;
|
|
|
|
|
|
|
|
if (PlayerList[player].nHealth <= 0 || nNetPlayerCount || gamestate != GS_LEVEL)
|
|
|
|
{
|
|
|
|
Printf("give: Cannot give while dead or not in a single-player game.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int buttons = 0;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case GIVE_ALL:
|
|
|
|
buttons |= kButtonCheatGuns | kButtonCheatItems | kButtonCheatKeys;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIVE_HEALTH:
|
|
|
|
PlayerList[player].nHealth = 800;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case GIVE_WEAPONS:
|
|
|
|
case GIVE_AMMO:
|
|
|
|
buttons |= kButtonCheatGuns;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIVE_ARMOR:
|
|
|
|
// not implemented
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIVE_KEYS:
|
|
|
|
buttons |= kButtonCheatKeys;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIVE_INVENTORY:
|
|
|
|
buttons |= kButtonCheatItems;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIVE_ITEMS:
|
|
|
|
buttons |= kButtonCheatItems | kButtonCheatKeys;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buttons & kButtonCheatGuns) // LOBOCOP cheat
|
|
|
|
{
|
|
|
|
FillWeapons(player);
|
|
|
|
if (player == myconnectindex) StatusMessage(150, GStrings("TXT_EX_WEAPONS"));
|
|
|
|
}
|
|
|
|
if (buttons & kButtonCheatKeys) // LOBOPICK cheat
|
|
|
|
{
|
|
|
|
PlayerList[player].keys = 0xFFFF;
|
|
|
|
if (player == myconnectindex) StatusMessage(150, GStrings("TXT_EX_KEYS"));
|
|
|
|
RefreshStatus();
|
|
|
|
}
|
|
|
|
if (buttons & kButtonCheatItems) // LOBOSWAG cheat
|
|
|
|
{
|
|
|
|
FillItems(player);
|
|
|
|
if (player == myconnectindex) StatusMessage(150, GStrings("TXT_EX_ITEMS"));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-02 22:41:32 +00:00
|
|
|
void InitCheats()
|
|
|
|
{
|
|
|
|
SetCheats(excheats, countof(excheats));
|
2020-09-03 15:39:41 +00:00
|
|
|
Net_SetCommandHandler(DEM_GIVE, cmd_Give);
|
2020-09-02 22:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
END_PS_NS
|