- reimplemented cheats based on ZDoom's cheat parser.

This commit is contained in:
Christoph Oelckers 2020-07-04 15:51:02 +02:00
parent dbd3202433
commit 39185300e7
14 changed files with 602 additions and 963 deletions

View file

@ -41,6 +41,7 @@
#include "utf8.h"
#include "m_joy.h"
#include "vm.h"
#include "cheathandler.h"
bool G_Responder(event_t* ev);
@ -73,6 +74,8 @@ void D_ProcessEvents (void)
continue; // console ate the event
if (M_Responder (ev))
continue; // menu ate the event
if (Cheat_Responder(ev))
continue;
G_Responder (ev);
}
}

View file

@ -27,6 +27,8 @@
#include "c_dispatch.h"
#include "d_event.h"
#include "cheathandler.h"
#include "printf.h"
#include "gamestruct.h"
static cheatseq_t *cheats;
static int numcheats;
@ -54,7 +56,7 @@ static bool CheatAddKey (cheatseq_t *cheat, uint8_t key, bool *eat)
cheat->Pos = cheat->Sequence;
cheat->CurrentArg = 0;
}
if (*cheat->Pos == '#')
if (*cheat->Pos == '#' && key >= '0' && key <= '9')
{
*eat = true;
cheat->Args[cheat->CurrentArg++] = key;
@ -108,8 +110,7 @@ bool Cheat_Responder (event_t *ev)
}
else if (cheats->Pos - cheats->Sequence > 2)
{ // If more than two characters into the sequence,
// eat the keypress, just so that the Hexen cheats
// with T in them will work without unbinding T.
// eat the keypress.
eat = true;
}
}
@ -117,3 +118,22 @@ bool Cheat_Responder (event_t *ev)
return eat;
}
void PlaybackCheat(const char *p)
{
if (!gi->CheatAllowed(false))
{
event_t ev = { EV_KeyDown, 0, 0, -1 };
Cheat_Responder(&ev); // Reset the parser by passing a non-existent key.
for (; *p; p++)
{
// just play the cheat command through the event parser
ev.data2 = *p;
Cheat_Responder(&ev);
}
ev.data2 = -1;
Cheat_Responder(&ev);
}
else
Printf("activatecheat: Cheats not allowed.\n");
}

View file

@ -3,15 +3,15 @@
struct cheatseq_t
{
const char *Sequence;
const char *Pos;
bool (*Handler)(cheatseq_t *);
uint8_t DontCheck;
// This is working data for processing the cheat
uint8_t CurrentArg;
uint8_t Args[6];
const char *Pos;
};
struct event_t;
bool Cheat_Responder(event_t* ev);
void SetCheats(cheatseq_t *cht, int count);
void PlaybackCheat(const char* p);

View file

@ -1097,7 +1097,7 @@ CCMD (togglemsg)
// Just a placeholder for now.
bool CheckCheatmode(bool printmsg)
{
return false;
return gi->CheatAllowed(printmsg);
}
void updatePauseStatus()

View file

@ -4,6 +4,7 @@ bool System_WantGuiCapture(); // During playing this tells us whether the game m
#include <stdint.h>
#include "print.h"
#include "vectors.h"
struct GameStats
{
@ -82,7 +83,7 @@ struct GameInterface
virtual void SetAmbience(bool on) {}
virtual FString GetCoordString() { return "'stat coord' not implemented"; }
virtual int GetStringTile(int font, const char* t, int f) { return -1; }
virtual int CheckCheat(const char* cheat, const char* args) { return 0; }
virtual bool CheatAllowed(bool printmsg) { return true; }
};

View file

@ -10,6 +10,7 @@ set( PCH_SOURCES
src/animatesprites_r.cpp
src/animatesprites_d.cpp
src/bowling.cpp
src/cheats.cpp
src/d_menu.cpp
src/dispatch.cpp
src/flags_d.cpp
@ -39,7 +40,6 @@ set( PCH_SOURCES
src/spawn.cpp
src/spawn_d.cpp
src/spawn_r.cpp
src/zz_cheats.cpp
src/zz_common.cpp
src/zz_demo.cpp
src/zz_game.cpp

View file

@ -0,0 +1,541 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 1996, 2003 - 3D Realms Entertainment
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
Copyright (C) 2017-2019 Nuke.YKT
Copyright (C) 2020 Christoph Oelckers
This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition
Duke Nukem 3D is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Original Source: 1996 - Todd Replogle
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
EDuke enhancements integrated: 04/13/2003 - Matt Saettler
Note: EDuke source was in transition. Changes are in-progress in the
source as it is released.
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "duke3d.h"
#include "c_cvars.h"
#include "mapinfo.h"
#include "cheathandler.h"
EXTERN_CVAR(Int, developer)
BEGIN_DUKE_NS
bool GameInterface::CheatAllowed(bool printmsg)
{
if (ud.player_skill == 4 || (isRR() && ud.player_skill > 3) || (isRRRA() && ps[myconnectindex].nocheat))
{
if (printmsg) FTA(22, &ps[myconnectindex]);
return false;
}
return true;
}
bool cheatWeapons(cheatseq_t *s)
{
int weaponLimit = (VOLUMEONE) ? SHRINKER_WEAPON : MAX_WEAPONS;
for (int weapon = PISTOL_WEAPON; weapon < weaponLimit; weapon++ )
{
addammo( weapon, &ps[myconnectindex], max_ammo_amount[weapon] );
ps[myconnectindex].gotweapon.Set(weapon);
}
if (isRRRA())
ps[myconnectindex].ammo_amount[SLINGBLADE_WEAPON] = 1;
if (s) FTA(119,&ps[myconnectindex]);
return true;
}
bool cheatInventory(cheatseq_t *s)
{
auto invGet = [](int defvalue, int evtype, int16_t &dest)
{
SetGameVarID(g_iReturnVarID, defvalue, -1, myconnectindex);
OnEvent(evtype, -1, myconnectindex, -1);
if (GetGameVarID(g_iReturnVarID, -1, myconnectindex) >= 0)
{
dest = GetGameVarID(g_iReturnVarID, -1, myconnectindex);
}
};
invGet(400, EVENT_CHEATGETSTEROIDS, ps[myconnectindex].steroids_amount);
if (!isRR()) invGet(1200, EVENT_CHEATGETHEAT, ps[myconnectindex].heat_amount);
invGet(isRR() ? 2000 : 200, EVENT_CHEATGETBOOT, ps[myconnectindex].boot_amount);
invGet(100, EVENT_CHEATGETSHIELD, ps[myconnectindex].shield_amount);
invGet(6400, EVENT_CHEATGETSCUBA, ps[myconnectindex].scuba_amount);
invGet(2400, EVENT_CHEATGETHOLODUKE, ps[myconnectindex].holoduke_amount);
invGet(isRR() ? 600 : 1600, EVENT_CHEATGETJETPACK, ps[myconnectindex].jetpack_amount);
invGet(max_player_health, EVENT_CHEATGETFIRSTAID, ps[myconnectindex].firstaid_amount);
if (s) FTA(120,&ps[myconnectindex]);
return true;
}
bool cheatKeys(cheatseq_t *s)
{
ps[myconnectindex].got_access = 7;
if (isRR()) for (int ikey = 0; ikey < 5; ikey++)
ps[myconnectindex].keys[ikey] = 1;
if (s) FTA(121,&ps[myconnectindex]);
return true;
}
static bool cheatDebug(cheatseq_t *)
{
// Let's do something useful with this.
if (developer == 0) developer = 3;
else developer = 0;
return true;
}
bool cheatClip(cheatseq_t *)
{
ud.clipping = 1-ud.clipping;
FTA(112+ud.clipping,&ps[myconnectindex]);
return true;
}
static bool cheatAllen(cheatseq_t *)
{
FTA(79,&ps[myconnectindex]);
return true;
}
bool cheatGod(cheatseq_t *)
{
ud.god = 1-ud.god;
if(ud.god)
{
if (isRRRA()) S_PlaySound(218, CHAN_AUTO, CHANF_UI);
sprite[ps[myconnectindex].i].cstat = 257;
hittype[ps[myconnectindex].i].temp_data[0] = 0;
hittype[ps[myconnectindex].i].temp_data[1] = 0;
hittype[ps[myconnectindex].i].temp_data[2] = 0;
hittype[ps[myconnectindex].i].temp_data[3] = 0;
hittype[ps[myconnectindex].i].temp_data[4] = 0;
hittype[ps[myconnectindex].i].temp_data[5] = 0;
sprite[ps[myconnectindex].i].hitag = 0;
sprite[ps[myconnectindex].i].lotag = 0;
sprite[ps[myconnectindex].i].pal =
ps[myconnectindex].palookup;
FTA(17,&ps[myconnectindex]);
}
else
{
ud.god = 0;
sprite[ps[myconnectindex].i].extra = max_player_health;
hittype[ps[myconnectindex].i].extra = -1;
ps[myconnectindex].last_extra = max_player_health;
FTA(18,&ps[myconnectindex]);
}
sprite[ps[myconnectindex].i].extra = max_player_health;
hittype[ps[myconnectindex].i].extra = 0;
return true;
}
bool cheatStuff(cheatseq_t *)
{
cheatWeapons(nullptr);
cheatInventory(nullptr);
if (!isNamWW2GI()) cheatKeys(nullptr);
FTA(5,&ps[myconnectindex]);
return true;
}
static bool cheatLevel(cheatseq_t *s)
{
// Fixme: This should be broadcast as a net event once things are up again.
g_lastLevel = 0;
int volnume,levnume;
volnume = s->Args[0] - '0' - 1;
levnume = (s->Args[1] - '0')*10+(s->Args[2]-'0') - 1;
// Instead of hard coded range checks on volume and level, let's just check if the level is defined.
if (mapList[volnume*MAXLEVELS + levnume].fileName.IsNotEmpty())
{
FX_StopAllSounds();
FX_SetReverb(0);
ud.m_volume_number = ud.volume_number = volnume;
ud.m_level_number = ud.level_number = levnume;
ps[myconnectindex].gm |= MODE_RESTART;
}
return true;
}
static bool cheatCoord(cheatseq_t *)
{
C_DoCommand("stat coord");
return true;
}
static bool cheatTime(cheatseq_t *)
{
C_DoCommand("stat fps");
return true;
}
static bool cheatRate(cheatseq_t *)
{
C_DoCommand("toggle vid_fps");
return true;
}
static bool cheatItems(cheatseq_t *)
{
cheatInventory(nullptr);
if (!isNamWW2GI()) cheatKeys(nullptr);
FTA(5,&ps[myconnectindex]);
return true;
}
static bool cheatView(cheatseq_t *)
{
if (ps[myconnectindex].OnMotorcycle == 0 && ps[myconnectindex].OnBoat == 0)
{
if( ps[myconnectindex].over_shoulder_on )
ps[myconnectindex].over_shoulder_on = 0;
else
{
ps[myconnectindex].over_shoulder_on = 1;
cameradist = 0;
cameraclock = (int)totalclock;
}
//FTA(22,&ps[myconnectindex]); this message makes no sense.
}
return true;
}
static bool cheatUnlock(cheatseq_t *)
{
if (VOLUMEONE) return false;
for(int i=numsectors-1;i>=0;i--) //Unlock
{
int j = sector[i].lotag;
if(j == -1 || j == 32767) continue;
if( (j & 0x7fff) > 2 )
{
if( j&(0xffff-16384) )
sector[i].lotag &= (0xffff-16384);
operatesectors(i,ps[myconnectindex].i);
}
}
fi.operateforcefields(ps[myconnectindex].i,-1);
FTA(100,&ps[myconnectindex]);
return true;
}
static bool cheatCashman(cheatseq_t *)
{
ud.cashman = 1-ud.cashman;
return true;
}
static bool cheatSkill(cheatseq_t *s)
{
g_lastLevel = 0;
ud.m_player_skill = ud.player_skill = s->Args[0] - '1';
ps[myconnectindex].gm |= MODE_RESTART;
FX_StopAllSounds();
FX_SetReverb(0);
return true;
}
static bool cheatBeta(cheatseq_t *)
{
FTA(105,&ps[myconnectindex]);
return true;
}
static bool cheatTodd(cheatseq_t *)
{
FTA(99,&ps[myconnectindex]);
return true;
}
static bool cheatHyper(cheatseq_t *)
{
ps[myconnectindex].steroids_amount = 399;
FTA(37,&ps[myconnectindex]);
return true;
}
static bool cheatMonsters(cheatseq_t *)
{
if(actor_tog == 3) actor_tog = 0;
actor_tog++;
static const char *s [] = { "OPTVAL_ON", "OPTVAL_OFF", "$TXT_ON2" };
Printf(PRINT_NOTIFY, "%s: %s", GStrings("NETMNU_MONSTERS"), s[actor_tog]);
return true;
}
static bool cheatMap(cheatseq_t *)
{
gFullMap = !gFullMap;
FTA(gFullMap? 111 : 1, &ps[myconnectindex]);
return true;
}
static bool cheatKill(cheatseq_t *)
{
quickkill(&ps[myconnectindex]);
FTA(127,&ps[myconnectindex]);
return true;
}
// RRRA only cheats
static bool cheatMotorcycle(cheatseq_t *)
{
OnMotorcycle(&ps[myconnectindex],0);
ps[myconnectindex].ammo_amount[MOTORCYCLE_WEAPON] = max_ammo_amount[MOTORCYCLE_WEAPON];
FTA(126,&ps[myconnectindex]);
return true;
}
static bool cheatBoat(cheatseq_t *)
{
OnBoat(&ps[myconnectindex],0);
ps[myconnectindex].ammo_amount[BOAT_WEAPON] = max_ammo_amount[BOAT_WEAPON];
FTA(136,&ps[myconnectindex]);
return true;
}
static bool cheatTony(cheatseq_t *)
{
enemysizecheat = 2;
return true;
}
static bool cheatVan(cheatseq_t *)
{
enemysizecheat = 3;
return true;
}
static bool cheatGary(cheatseq_t *)
{
S_PlayRRMusic(10);
return true;
}
static bool cheatRhett(cheatseq_t *)
{
ud.god = 0;
ps[myconnectindex].gotweapon.Zero();
ps[myconnectindex].curr_weapon = KNEE_WEAPON;
ps[myconnectindex].nocheat = 1;
sprite[ps[myconnectindex].i].extra = 1;
FTA(128,&ps[myconnectindex]);
return true;
}
static bool cheatAaron(cheatseq_t *)
{
if (ps[myconnectindex].DrugMode)
ps[myconnectindex].DrugMode = 0;
else
ps[myconnectindex].DrugMode = 5;
return true;
}
static bool cheatNocheat(cheatseq_t *)
{
ps[myconnectindex].nocheat = 1;
FTA(130,&ps[myconnectindex]);
return true;
}
static bool cheatDrink(cheatseq_t *)
{
if (ps[myconnectindex].drink_amt)
{
ps[myconnectindex].drink_amt = 0;
FTA(132,&ps[myconnectindex]);
}
else
{
ps[myconnectindex].drink_amt = 90;
FTA(131,&ps[myconnectindex]);
}
return true;
}
static bool cheatSeasick(cheatseq_t *)
{
if (ps[myconnectindex].sea_sick_stat)
{
ps[myconnectindex].sea_sick_stat = 0;
FTA(129,&ps[myconnectindex]);
}
else
{
ps[myconnectindex].sea_sick_stat = 1;
FTA(137, &ps[myconnectindex]);
}
return true;
}
static bool cheatKfc(cheatseq_t *)
{
for (int i = 0; i < 7; i++)
{
int spr = fi.spawn(ps[screenpeek].i,TILE_HEN);
sprite[spr].pal = 1;
sprite[spr].xrepeat = sprite[spr].xrepeat<<2;
sprite[spr].yrepeat = sprite[spr].yrepeat<<2;
}
FTA(139,&ps[myconnectindex]);
return true;
}
static cheatseq_t dukecheats[] = {
{ "dncornholio", cheatGod },
{ "dnstuff", cheatStuff },
{ "dnscotty###", cheatLevel },
{ "dncoords", cheatCoord, 1 },
{ "dnview", cheatView, 1 },
{ "dntime", cheatTime, 1 },
{ "dnunlock", cheatUnlock },
{ "dncashman", cheatCashman },
{ "dnitems", cheatItems },
{ "dnrate", cheatRate, 1 },
{ "dnskill#", cheatSkill },
{ "dnbeta", cheatBeta },
{ "dnhyper", cheatHyper },
{ "dnmonsters", cheatMonsters },
{ "dntodd", cheatTodd },
{ "dnshowmap", cheatMap },
{ "dnkroz", cheatGod },
{ "dnallen", cheatAllen },
{ "dnclip", cheatClip },
{ "dnweapons", cheatWeapons },
{ "dninventory", cheatInventory },
{ "dnkeys", cheatKeys },
{ "dndebug", cheatDebug, 1 },
{ "dncgs", cheatKill },
};
static cheatseq_t ww2cheats[] =
{
// Use the same code prefix as EDuke because 'ww' is not usable here. Since the cheat parser eats input after the second key, this could easily cause interference for WASD users.
{ "gi2god", cheatGod },
{ "gi2blood", cheatStuff },
{ "gi2level###", cheatLevel },
{ "gi2coords", cheatCoord, 1 },
{ "gi2view", cheatView, 1 },
{ "gi2time", cheatTime, 1 },
{ "gi2rate", cheatRate, 1 },
{ "gi2skill", cheatSkill },
{ "gi2enemies", cheatMonsters },
{ "gi2matt", cheatTodd },
{ "gi2showmap", cheatMap },
{ "gi2ryan", cheatGod },
{ "gi2clip", cheatClip },
{ "gi2weapons", cheatWeapons },
{ "gi2inventory", cheatInventory },
{ "gi2debug", cheatDebug, 1 },
{ "gi2cgs", cheatKill },
};
static cheatseq_t namcheats[] = {
{ "nvacaleb", cheatGod },
{ "nvablood", cheatStuff },
{ "nvalevel###", cheatLevel },
{ "nvacoords", cheatCoord, 1 },
{ "nvaview", cheatView, 1 },
{ "nvatime", cheatTime, 1 },
{ "nvarate", cheatRate, 1 },
{ "nvaskill", cheatSkill },
{ "nvahyper", cheatHyper },
{ "nvaenemies", cheatMonsters },
{ "nvamatt", cheatTodd },
{ "nvashowmap", cheatMap },
{ "nvagod", cheatGod },
{ "nvaclip", cheatClip },
{ "nvaweapons", cheatWeapons },
{ "nvainventory", cheatInventory },
{ "nvadebug", cheatDebug, 1 },
{ "nvacgs", cheatKill },
};
static cheatseq_t rrcheats[] = {
{ "rdhounddog", cheatGod },
{ "rdall", cheatStuff },
{ "rdmeadow###", cheatLevel },
{ "rdyerat", cheatCoord, 1 },
{ "rdview", cheatView, 1 },
{ "rdtime", cheatTime, 1 },
{ "rdunlock", cheatUnlock },
{ "rdcluck", cheatCashman },
{ "rditems", cheatItems },
{ "rdrate", cheatRate, 1 },
{ "rdskill#", cheatSkill },
{ "rdteachers", cheatBeta },
{ "rdmoonshine", cheatHyper },
{ "rdcritters", cheatMonsters },
{ "rdrafael", cheatTodd },
{ "rdshowmap", cheatMap },
{ "rdelvis", cheatGod },
{ "rdclip", cheatClip },
{ "rdguns", cheatWeapons },
{ "rdinventory", cheatInventory },
{ "rdkeys", cheatKeys },
{ "rddebug", cheatDebug, 1 },
{ "rdcgs", cheatKill }, // 23 for RR
// RRRA only!
{ "rdjoseph", cheatMotorcycle },
{ "rdmrbill", cheatKill },
{ "rdtony", cheatTony },
{ "rdgary", cheatGary },
{ "rdrhett", cheatRhett },
{ "rdaaron", cheatAaron },
{ "rdnocheat", cheatNocheat },
{ "rdwoleslagle", cheatDrink },
{ "rdmikael", cheatStuff },
{ "rdgreg", cheatSeasick },
//"rdnoah", // no-op
{ "rdarijit", cheatBoat },
{ "rddonut", cheatBoat },
{ "rdkfc", cheatKfc },
{ "rdvan", cheatVan },
};
void InitCheats()
{
if (isRRRA()) SetCheats(rrcheats, countof(rrcheats));
else if (isRR()) SetCheats(rrcheats, 23);
else if (isWW2GI()) SetCheats(ww2cheats, countof(ww2cheats));
else if (isNam()) SetCheats(namcheats, countof(namcheats));
else SetCheats(dukecheats, countof(dukecheats));
}
END_DUKE_NS

View file

@ -272,8 +272,8 @@ void GameInterface::MenuClosed()
{
ready2send = 1;
totalclock = ototalclock;
g_cameraClock = (int32_t)totalclock;
g_cameraDistance = 65536;
cameraclock = (int32_t)totalclock;
cameradist = 65536;
}
updateviewport();

View file

@ -217,6 +217,7 @@ struct GameInterface : ::GameInterface
bool LoadGame(FSaveGameNode*) override;
void QuitToTitle() override;
FString GetCoordString() override;
bool CheatAllowed(bool printmsg) override;
};
END_DUKE_NS

View file

@ -105,8 +105,8 @@ enum {
# define CAMERA(Membname) (ud.camera ## Membname)
# define CAMERADIST g_cameraDistance
# define CAMERACLOCK g_cameraClock
# define CAMERADIST cameradist
# define CAMERACLOCK cameraclock
#endif
@ -196,8 +196,8 @@ extern const char *G_DefaultRtsFile(void);
extern int32_t g_Debug;
extern int32_t g_Shareware;
extern int32_t g_cameraClock;
extern int32_t g_cameraDistance;
extern int32_t cameraclock;
extern int32_t cameradist;
extern int32_t g_crosshairSum;
extern int32_t g_doQuickSave;
extern int32_t g_levelTextTime;

View file

@ -26,7 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "gamevar.h"
#include "zz_actors.h"
#include "build.h" // hashtable_t
#include "cheats.h"
#include "common.h" // tokenlist
#include "player.h" // projectile_t

View file

@ -1,920 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2016 EDuke32 developers and contributors
This file is part of EDuke32.
EDuke32 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" // Must come before everything else!
#include "duke3d.h"
#include "osdcmds.h"
#include "cheats.h"
#include "mapinfo.h"
#include "c_dispatch.h"
BEGIN_DUKE_NS
// KEEPINSYNC game.h: enum cheatindex_t
char CheatStrings [NUMCHEATS][MAXCHEATLEN] =
{
"cornholio", // 0
"stuff", // 1
"scotty###", // 2
"coords", // 3
"view", // 4
"time", // 5
"unlock", // 6
"cashman", // 7
"items", // 8
"rate", // 9
"skill#", // 10
"beta", // 11
"hyper", // 12
"monsters", // 13
"<RESERVED>", // 14
"<RESERVED>", // 15
"todd", // 16
"showmap", // 17
"kroz", // 18
"allen", // 19
"clip", // 20
"weapons", // 21
"inventory", // 22
"keys", // 23
"debug", // 24
"<RESERVED>", // 25
"<RESERVED>", // 26
"<RESERVED>", // 27
"<RESERVED>", // 28
"<RESERVED>", // 29
"<RESERVED>", // 30
"<RESERVED>", // 31
"<RESERVED>", // 32
"<RESERVED>", // 33
"<RESERVED>", // 34
"<RESERVED>", // 35
"<RESERVED>", // 36
"<RESERVED>", // 37
"<RESERVED>", // 38
"<RESERVED>", // 39
};
const uint32_t CheatFunctionFlags [NUMCHEATS] =
{
1 << CHEATFUNC_GOD,
1 << CHEATFUNC_GIVEEVERYTHING,
1 << CHEATFUNC_WARP,
1 << CHEATFUNC_COORDS,
1 << CHEATFUNC_VIEW,
0,
1 << CHEATFUNC_UNLOCK,
1 << CHEATFUNC_CASHMAN,
1 << CHEATFUNC_GIVEALLITEMS,
1 << CHEATFUNC_FRAMERATE,
1 << CHEATFUNC_SKILL,
1 << CHEATFUNC_QUOTEBETA,
1 << CHEATFUNC_HYPER,
1 << CHEATFUNC_MONSTERS,
0,
0,
1 << CHEATFUNC_QUOTETODD,
1 << CHEATFUNC_SHOWMAP,
1 << CHEATFUNC_GOD,
1 << CHEATFUNC_QUOTEALLEN,
1 << CHEATFUNC_CLIP,
1 << CHEATFUNC_GIVEWEAPONS,
1 << CHEATFUNC_GIVEINVENTORY,
1 << CHEATFUNC_GIVEKEYS,
1 << CHEATFUNC_DEBUG,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
};
// KEEPINSYNC game.h: enum CheatCodeFunctions
// KEEPINSYNC menus.c: MenuEntry_t ME_CheatCodes[]
const uint8_t CheatFunctionIDs[NUMCHEATS] =
{
CHEAT_CASHMAN,
CHEAT_CORNHOLIO,
CHEAT_STUFF,
CHEAT_WEAPONS,
CHEAT_ITEMS,
CHEAT_INVENTORY,
CHEAT_KEYS,
CHEAT_HYPER,
CHEAT_VIEW,
CHEAT_SHOWMAP,
CHEAT_UNLOCK,
CHEAT_CLIP,
CHEAT_SCOTTY,
CHEAT_SKILL,
CHEAT_MONSTERS,
CHEAT_RATE,
CHEAT_BETA,
CHEAT_TODD,
CHEAT_ALLEN,
CHEAT_COORDS,
CHEAT_DEBUG,
};
char const * const g_NAMMattCheatQuote = "Matt Saettler. matts@seanet.com";
void G_SetupCheats(void)
{
if (RR)
{
CheatKeys[0] = sc_R;
CheatKeys[1] = sc_D;
Bstrcpy(CheatStrings[0], "hounddog");
Bstrcpy(CheatStrings[1], "all");
Bstrcpy(CheatStrings[2], "meadow###");
Bstrcpy(CheatStrings[3], "yerat");
Bstrcpy(CheatStrings[7], "cluck");
Bstrcpy(CheatStrings[11], "teachers");
Bstrcpy(CheatStrings[12], "moonshine");
Bstrcpy(CheatStrings[13], "critters");
Bstrcpy(CheatStrings[16], "rafael");
Bstrcpy(CheatStrings[18], "elvis");
Bstrcpy(CheatStrings[19], "<RESERVED>");
Bstrcpy(CheatStrings[21], "guns");
if (RRRA)
{
Bstrcpy(CheatStrings[25], "joseph");
Bstrcpy(CheatStrings[26], "mrbill");
Bstrcpy(CheatStrings[27], "tony");
Bstrcpy(CheatStrings[28], "gary");
Bstrcpy(CheatStrings[29], "rhett");
Bstrcpy(CheatStrings[30], "aaron");
Bstrcpy(CheatStrings[31], "nocheat");
Bstrcpy(CheatStrings[32], "woleslagle");
Bstrcpy(CheatStrings[33], "mikael");
Bstrcpy(CheatStrings[34], "greg");
Bstrcpy(CheatStrings[35], "noah");
Bstrcpy(CheatStrings[36], "arijit");
Bstrcpy(CheatStrings[37], "donut");
Bstrcpy(CheatStrings[38], "kfc");
Bstrcpy(CheatStrings[39], "van");
}
}
if (WW2GI)
{
#if 0
// WWII GI's original cheat prefix temporarily disabled because W conflicts with WSAD movement
CheatKeys[0] = CheatKeys[1] = sc_W;
#else
CheatKeys[0] = sc_G;
CheatKeys[1] = sc_I;
#endif
Bstrcpy(CheatStrings[0], "2god");
Bstrcpy(CheatStrings[1], "2blood");
Bstrcpy(CheatStrings[2], "2level###");
Bstrcpy(CheatStrings[3], "2coords");
Bstrcpy(CheatStrings[4], "2view");
Bstrcpy(CheatStrings[5], "<RESERVED>");
Bstrcpy(CheatStrings[7], "<RESERVED>");
Bstrcpy(CheatStrings[8], "<RESERVED>");
Bstrcpy(CheatStrings[9], "2rate");
Bstrcpy(CheatStrings[10], "2skill");
Bstrcpy(CheatStrings[11], "<RESERVED>");
Bstrcpy(CheatStrings[12], "<RESERVED>");
Bstrcpy(CheatStrings[13], "<RESERVED>");
Bstrcpy(CheatStrings[16], "2matt");
Bstrcpy(CheatStrings[17], "2showmap");
Bstrcpy(CheatStrings[18], "2ryan");
Bstrcpy(CheatStrings[19], "<RESERVED>");
Bstrcpy(CheatStrings[20], "2clip");
Bstrcpy(CheatStrings[21], "2weapons");
Bstrcpy(CheatStrings[22], "2inventory");
Bstrcpy(CheatStrings[23], "<RESERVED>");
Bstrcpy(CheatStrings[24], "2debug");
Bstrcpy(CheatStrings[26], "2cgs");
Bstrcpy(g_gametypeNames[0], "GI Match (Spawn)");
Bstrcpy(g_gametypeNames[2], "GI Match (No Spawn)");
}
else if (NAM)
{
CheatKeys[0] = sc_N;
CheatKeys[1] = sc_V;
Bstrcpy(CheatStrings[0], "acaleb");
Bstrcpy(CheatStrings[1], "ablood");
Bstrcpy(CheatStrings[2], "alevel###");
Bstrcpy(CheatStrings[3], "acoords");
Bstrcpy(CheatStrings[4], "aview");
Bstrcpy(CheatStrings[5], "<RESERVED>");
Bstrcpy(CheatStrings[7], "<RESERVED>");
Bstrcpy(CheatStrings[8], "<RESERVED>");
Bstrcpy(CheatStrings[9], "arate");
Bstrcpy(CheatStrings[10], "askill");
Bstrcpy(CheatStrings[11], "<RESERVED>");
Bstrcpy(CheatStrings[12], "ahyper");
Bstrcpy(CheatStrings[13], "<RESERVED>");
Bstrcpy(CheatStrings[16], "amatt");
Bstrcpy(CheatStrings[17], "ashowmap");
Bstrcpy(CheatStrings[18], "agod");
Bstrcpy(CheatStrings[19], "<RESERVED>");
Bstrcpy(CheatStrings[20], "aclip");
Bstrcpy(CheatStrings[21], "aweapons");
Bstrcpy(CheatStrings[22], "ainventory");
Bstrcpy(CheatStrings[23], "<RESERVED>");
Bstrcpy(CheatStrings[24], "adebug");
Bstrcpy(CheatStrings[26], "acgs");
}
}
static void doinvcheat(DukePlayer_t * const pPlayer, int32_t invidx, int32_t defaultnum, int event)
{
defaultnum = VM_OnEventWithReturn(event, pPlayer->i, myconnectindex, defaultnum);
if (defaultnum >= 0)
pPlayer->inv_amount[invidx] = defaultnum;
}
static void G_CheatGetInv(DukePlayer_t *pPlayer)
{
doinvcheat(pPlayer, GET_STEROIDS, 400, EVENT_CHEATGETSTEROIDS);
if (!RR) doinvcheat(pPlayer, GET_HEATS, 1200, EVENT_CHEATGETHEAT);
doinvcheat(pPlayer, GET_BOOTS, RR ? 2000 : 200, EVENT_CHEATGETBOOT);
doinvcheat(pPlayer, GET_SHIELD, 100, EVENT_CHEATGETSHIELD);
doinvcheat(pPlayer, GET_SCUBA, 6400, EVENT_CHEATGETSCUBA);
doinvcheat(pPlayer, GET_HOLODUKE, 2400, EVENT_CHEATGETHOLODUKE);
doinvcheat(pPlayer, GET_JETPACK, RR ? 600 : 1600, EVENT_CHEATGETJETPACK);
doinvcheat(pPlayer, GET_FIRSTAID, max_player_health, EVENT_CHEATGETFIRSTAID);
}
static void end_cheat(DukePlayer_t * const pPlayer)
{
pPlayer->cheat_phase = 0;
inputState.keyFlushChars();
}
static int32_t cheatbuflen;
static int8_t cheatbuf[MAXCHEATLEN];
void G_DoCheats(void)
{
DukePlayer_t * const pPlayer = g_player[myconnectindex].ps;
int consoleCheat = 0;
int cheatNum;
if (osdcmd_cheatsinfo_stat.cheatnum != -1)
{
cheatNum = osdcmd_cheatsinfo_stat.cheatnum;
if (ud.player_skill == 4 || (RR && ud.player_skill > 3) || (RRRA && pPlayer->nocheat))
{
switch (cheatNum)
{
case CHEAT_DEBUG:
case CHEAT_COORDS:
case CHEAT_RATE:
case CHEAT_RESERVED:
case CHEAT_RESERVED2:
//case CHEAT_RESERVED3:
break;
default:
FTA(QUOTE_CHEATS_DISABLED, pPlayer);
osdcmd_cheatsinfo_stat.cheatnum = -1;
return;
}
}
// JBF 20030914
osdcmd_cheatsinfo_stat.cheatnum = -1;
consoleCheat = 1;
}
static int volumeOne = 0;
if (VOLUMEONE && !volumeOne)
{
// change "scotty###" to "scotty##"
uint32_t const warpend = Bstrlen(CheatStrings[2]);
if (strcmp(&CheatStrings[2][warpend-3], "###") == 0)
CheatStrings[2][warpend-1] = '\0';
Bstrcpy(CheatStrings[6], "<RESERVED>");
volumeOne = 1;
}
if (consoleCheat && numplayers < 2 && ud.recstat == 0)
goto FOUNDCHEAT;
if ((RR && ud.player_skill > 3) || (RRRA && pPlayer->nocheat))
return;
if (pPlayer->gm & (MODE_TYPE|MODE_MENU))
return;
if (pPlayer->cheat_phase == 1)
{
int ch;
while (inputState.keyBufferWaiting())
{
ch = Btolower(inputState.keyGetChar());
if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9')))
{
pPlayer->cheat_phase = 0;
// FTA(QUOTE_46,pPlayer);
return;
}
cheatbuf[cheatbuflen++] = (int8_t) ch;
// This assertion is not obvious, but it should hold because of the
// cheat string matching logic below.
Bassert(cheatbuflen < (signed)sizeof(cheatbuf));
cheatbuf[cheatbuflen] = 0;
// inputState.ClearAllInput();
for (cheatNum=0; cheatNum < NUMCHEATCODES; cheatNum++)
{
for (bssize_t j = 0; j<cheatbuflen; j++)
{
if (cheatbuf[j] == CheatStrings[cheatNum][j] || (CheatStrings[cheatNum][j] == '#' && ch >= '0' && ch <= '9'))
{
if (CheatStrings[cheatNum][j+1] == 0) goto FOUNDCHEAT;
if (j == cheatbuflen-1) return;
}
else break;
}
}
pPlayer->cheat_phase = 0;
return;
FOUNDCHEAT:;
if (cheatNum == CHEAT_SCOTTY)
{
size_t const i = Bstrlen(CheatStrings[cheatNum])-3+VOLUMEONE;
if (!consoleCheat)
{
// JBF 20030914
int32_t volnume, levnume;
if (VOLUMEALL)
{
volnume = cheatbuf[i] - '0';
levnume = (cheatbuf[i+1] - '0')*10+(cheatbuf[i+2]-'0');
}
else
{
volnume = cheatbuf[i] - '0';
levnume = cheatbuf[i+1] - '0';
}
volnume--;
levnume--;
ud.m_volume_number = volnume;
m_level_number = levnume;
}
else
{
// JBF 20030914
ud.m_volume_number = osdcmd_cheatsinfo_stat.volume;
m_level_number = osdcmd_cheatsinfo_stat.level;
}
}
else if (cheatNum == CHEAT_SKILL)
{
if (!consoleCheat)
{
size_t const i = Bstrlen(CheatStrings[cheatNum])-1;
ud.m_player_skill = cheatbuf[i] - '1';
}
else
{
ud.m_player_skill = osdcmd_cheatsinfo_stat.volume;
}
}
{
switch (cheatNum)
{
case CHEAT_WEAPONS:
{
int const weaponLimit = (VOLUMEONE) ? SHRINKER_WEAPON : MAX_WEAPONS;
for (bssize_t weaponNum = PISTOL_WEAPON; weaponNum < weaponLimit; weaponNum++)
{
P_AddAmmo(pPlayer, weaponNum, max_ammo_amount[weaponNum]);
pPlayer->gotweapon.Set(weaponNum);
}
if (RRRA) pPlayer->ammo_amount[SLINGBLADE_WEAPON] = 1;
FTA(QUOTE_CHEAT_ALL_WEAPONS, pPlayer);
end_cheat(pPlayer);
}
return;
case CHEAT_INVENTORY:
G_CheatGetInv(pPlayer);
FTA(QUOTE_CHEAT_ALL_INV, pPlayer);
end_cheat(pPlayer);
return;
case CHEAT_KEYS:
pPlayer->got_access = 7;
if (RR)
for (int key = 0; key < 5; key++)
pPlayer->keys[key] = 1;
inputState.keyFlushChars();
FTA(QUOTE_CHEAT_ALL_KEYS, pPlayer);
end_cheat(pPlayer);
return;
case CHEAT_DEBUG:
g_Debug = 1-g_Debug;
end_cheat(pPlayer);
break;
case CHEAT_CLIP:
ud.clipping = !ud.clipping;
FTA(QUOTE_CHEAT_NOCLIP-!ud.clipping, pPlayer);
end_cheat(pPlayer);
return;
case CHEAT_RESERVED2:
if (RR)
{
FTA(QUOTE_JETPACK_ON, pPlayer);
inputState.keyFlushChars();
}
else
{
pPlayer->player_par = 0;
pPlayer->gm = MODE_EOL;
}
end_cheat(pPlayer);
return;
case CHEAT_ALLEN:
FTA(QUOTE_CHEAT_ALLEN, pPlayer);
pPlayer->cheat_phase = 0;
inputState.ClearKeyStatus(sc_N);
return;
case CHEAT_CORNHOLIO:
case CHEAT_KROZ:
//case CHEAT_COMEGETSOME:
{
const int32_t pi = pPlayer->i;
ud.god = 1-ud.god;
if (ud.god)
{
if (RRRA)
S_PlaySound(218);
pus = 1;
pub = 1;
sprite[pi].cstat = 257;
actor[pi].t_data[0] = 0;
actor[pi].t_data[1] = 0;
actor[pi].t_data[2] = 0;
actor[pi].t_data[3] = 0;
actor[pi].t_data[4] = 0;
actor[pi].t_data[5] = 0;
sprite[pi].hitag = 0;
sprite[pi].lotag = 0;
sprite[pi].pal = pPlayer->palookup;
//if (cheatNum != CHEAT_COMEGETSOME)
//{
FTA(QUOTE_CHEAT_GODMODE_ON, pPlayer);
//}
//else
//{
// Bstrcpy(pStrings[QUOTE_RESERVED4], "Come Get Some!");
//
// S_PlaySound(DUKE_GETWEAPON2);
// FTA(QUOTE_RESERVED4, pPlayer);
// G_CheatGetInv(pPlayer);
//
// for (bssize_t weaponNum = PISTOL_WEAPON; weaponNum < MAX_WEAPONS; weaponNum++)
// pPlayer->gotweapon |= (1<<weaponNum);
//
// for (bssize_t weaponNum = PISTOL_WEAPON; weaponNum < MAX_WEAPONS; weaponNum++)
// P_AddAmmo(pPlayer, weaponNum, max_ammo_amount[weaponNum]);
//
// pPlayer->got_access = 7;
//}
}
else
{
sprite[pi].extra = max_player_health;
actor[pi].extra = -1;
pPlayer->last_extra = max_player_health;
FTA(QUOTE_CHEAT_GODMODE_OFF, pPlayer);
}
sprite[pi].extra = max_player_health;
actor[pi].extra = 0;
//if (cheatNum != CHEAT_COMEGETSOME)
pPlayer->dead_flag = 0;
end_cheat(pPlayer);
return;
}
case CHEAT_STUFF:
{
int const weaponLimit = (VOLUMEONE) ? SHRINKER_WEAPON : MAX_WEAPONS;
for (bssize_t weaponNum = PISTOL_WEAPON; weaponNum < weaponLimit; weaponNum++)
pPlayer->gotweapon.Set(weaponNum);
for (bssize_t weaponNum = PISTOL_WEAPON; weaponNum < weaponLimit; weaponNum++)
P_AddAmmo(pPlayer, weaponNum, max_ammo_amount[weaponNum]);
if (RRRA)
pPlayer->ammo_amount[SLINGBLADE_WEAPON] = 1;
G_CheatGetInv(pPlayer);
pPlayer->got_access = 7;
if (RR)
for (int key = 0; key < 5; key++)
pPlayer->keys[key] = 1;
FTA(QUOTE_CHEAT_EVERYTHING, pPlayer);
// FTA(QUOTE_21,pPlayer);
pPlayer->inven_icon = ICON_FIRSTAID;
end_cheat(pPlayer);
return;
}
case CHEAT_SCOTTY:
{
if (RR)
g_lastLevel = 0;
int32_t const volnume = ud.m_volume_number, levnume = m_level_number;
if ((!VOLUMEONE || volnume == 0) && (unsigned)volnume < (unsigned)g_volumeCnt &&
(unsigned)levnume < MAXLEVELS && mapList[volnume*MAXLEVELS + levnume].fileName.IsNotEmpty())
{
ud.volume_number = volnume;
ud.level_number = levnume;
pPlayer->gm |= MODE_RESTART;
}
end_cheat(pPlayer);
return;
}
case CHEAT_SKILL:
if (RR)
g_lastLevel = 0;
ud.player_skill = ud.m_player_skill;
pPlayer->gm |= MODE_RESTART;
end_cheat(pPlayer);
return;
case CHEAT_COORDS:
C_DoCommand("stat coord");
end_cheat(pPlayer);
return;
case CHEAT_VIEW:
if (!RRRA || (!pPlayer->OnMotorcycle && !pPlayer->OnBoat))
{
pPlayer->over_shoulder_on ^= 1;
CAMERADIST = 0;
CAMERACLOCK = (int32_t) totalclock;
// FTA(QUOTE_CHEATS_DISABLED,pPlayer);
}
end_cheat(pPlayer);
return;
case CHEAT_TIME:
// FTA(QUOTE_21,pPlayer);
end_cheat(pPlayer);
return;
case CHEAT_UNLOCK:
if (VOLUMEONE) return;
for (bssize_t i=numsectors-1; i>=0; i--) //Unlock
{
int const lotag = sector[i].lotag;
if (lotag == -1 || lotag == 32767) continue;
if ((lotag & 0x7fff) > 2)
{
if (lotag & (uint16_t)~16384u)
sector[i].lotag &= (uint16_t)~16384u;
operatesectors(i, pPlayer->i);
}
}
fi.operateforcefields(pPlayer->i, -1);
FTA(QUOTE_CHEAT_UNLOCK, pPlayer);
end_cheat(pPlayer);
return;
case CHEAT_CASHMAN:
ud.cashman = 1-ud.cashman;
inputState.ClearKeyStatus(sc_N);
pPlayer->cheat_phase = 0;
return;
case CHEAT_ITEMS:
G_CheatGetInv(pPlayer);
pPlayer->got_access = 7;
if (RR)
for(int key = 0; key < 5; key++)
pPlayer->keys[key] = 1;
FTA(QUOTE_CHEAT_EVERYTHING, pPlayer);
end_cheat(pPlayer);
return;
case CHEAT_SHOWMAP: // SHOW ALL OF THE MAP TOGGLE;
gFullMap = !gFullMap;
FTA(gFullMap ? QUOTE_SHOW_MAP_ON : QUOTE_SHOW_MAP_OFF,
pPlayer);
end_cheat(pPlayer);
return;
case CHEAT_TODD:
if (NAM_WW2GI)
{
quoteMgr.InitializeQuote(QUOTE_RESERVED4, g_NAMMattCheatQuote);
FTA(QUOTE_RESERVED4, pPlayer);
}
else
{
FTA(QUOTE_CHEAT_TODD, pPlayer);
}
end_cheat(pPlayer);
return;
case CHEAT_RATE:
r_showfps = clamp(*r_showfps+1, 0, 3);
end_cheat(pPlayer);
return;
case CHEAT_BETA:
FTA(QUOTE_CHEAT_BETA, pPlayer);
inputState.ClearKeyStatus(sc_H);
end_cheat(pPlayer);
return;
case CHEAT_HYPER:
pPlayer->inv_amount[GET_STEROIDS] = 399;
if (!RR)
pPlayer->inv_amount[GET_HEATS] = 1200;
FTA(QUOTE_CHEAT_STEROIDS, pPlayer);
end_cheat(pPlayer);
return;
case CHEAT_MONSTERS:
{
const char *s [] = { "OPTVAL_ON", "OPTVAL_OFF", "$TXT_ON2" };
if (++g_noEnemies == 3)
g_noEnemies = 0;
quoteMgr.FormatQuote(QUOTE_RESERVED4, "%s: %s", GStrings("NETMNU_MONSTERS"), s[g_noEnemies]);
FTA(QUOTE_RESERVED4, pPlayer);
end_cheat(pPlayer);
return;
}
case CHEAT_RESERVED:
//case CHEAT_RESERVED3:
if (RR)
{
FTA(51, pPlayer);
end_cheat(pPlayer);
}
else
{
ud.eog = 1;
pPlayer->player_par = 0;
pPlayer->gm |= MODE_EOL;
}
inputState.keyFlushChars();
return;
case CHEAT_RAJOSEPH:
OnMotorcycle(pPlayer, 0);
pPlayer->ammo_amount[MOTORCYCLE_WEAPON] = max_ammo_amount[MOTORCYCLE_WEAPON];
FTA(126, pPlayer);
end_cheat(pPlayer);
inputState.keyFlushChars();
return;
case CHEAT_RAMRBILL:
quickkill(pPlayer);
FTA(127, pPlayer);
end_cheat(pPlayer);
inputState.keyFlushChars();
return;
case CHEAT_RAGARY:
S_PlayRRMusic(10);
end_cheat(pPlayer);
inputState.keyFlushChars();
return;
case CHEAT_RANOAH:
end_cheat(pPlayer);
inputState.keyFlushChars();
return;
case CHEAT_RARHETT:
ud.god = 0;
pPlayer->gotweapon.Set(KNEE_WEAPON);
pPlayer->curr_weapon = KNEE_WEAPON;
pPlayer->nocheat = 1;
sprite[pPlayer->i].extra = 1;
FTA(128, pPlayer);
end_cheat(pPlayer);
inputState.keyFlushChars();
return;
case CHEAT_RAAARON:
pPlayer->DrugMode = pPlayer->DrugMode ? 0 : 5;
pPlayer->drug_timer = (int32_t) totalclock;
end_cheat(pPlayer);
inputState.keyFlushChars();
return;
case CHEAT_RANOCHEAT:
pPlayer->nocheat = 1;
FTA(130, pPlayer);
end_cheat(pPlayer);
inputState.keyFlushChars();
return;
case CHEAT_RATONY:
enemysizecheat = 2;
end_cheat(pPlayer);
inputState.keyFlushChars();
return;
case CHEAT_RAVAN:
enemysizecheat = 3;
end_cheat(pPlayer);
inputState.keyFlushChars();
return;
case CHEAT_RAKFC:
for (int i = 0; i < 7; i++)
{
int const newSprite = fi.spawn(pPlayer->i, TILE_HEN);
sprite[newSprite].pal = 1;
sprite[newSprite].xrepeat <<= 2;
sprite[newSprite].yrepeat <<= 2;
}
FTA(139, pPlayer);
end_cheat(pPlayer);
inputState.keyFlushChars();
return;
case CHEAT_RAWOLESLAGLE:
if (pPlayer->drink_amt)
{
pPlayer->drink_amt = 0;
FTA(132, pPlayer);
}
else
{
pPlayer->drink_amt = 90;
FTA(131, pPlayer);
}
end_cheat(pPlayer);
inputState.keyFlushChars();
return;
case CHEAT_RAMIKAEL:
for (bssize_t weaponNum = PISTOL_WEAPON; weaponNum < MAX_WEAPONS; weaponNum++)
{
pPlayer->gotweapon.Set(weaponNum);
pPlayer->ammo_amount[weaponNum] = 66;
}
pPlayer->ammo_amount[SLINGBLADE_WEAPON] = 1;
G_CheatGetInv(pPlayer);
pPlayer->got_access = 7;
for (int key = 0; key < 5; key++)
pPlayer->keys[key] = 1;
FTA(5, pPlayer);
end_cheat(pPlayer);
inputState.keyFlushChars();
return;
case CHEAT_RAGREG:
if (pPlayer->sea_sick_stat)
{
pPlayer->sea_sick_stat = 0;
FTA(129, pPlayer);
}
else
{
pPlayer->sea_sick_stat = 1;
FTA(137, pPlayer);
}
end_cheat(pPlayer);
inputState.keyFlushChars();
return;
case CHEAT_RAARIJIT:
case CHEAT_RADONUT:
OnBoat(pPlayer, 0);
pPlayer->ammo_amount[BOAT_WEAPON] = max_ammo_amount[BOAT_WEAPON];
FTA(136, pPlayer);
end_cheat(pPlayer);
inputState.keyFlushChars();
return;
default:
end_cheat(pPlayer);
return;
}
}
}
}
else
{
if (inputState.GetKeyStatus((uint8_t) CheatKeys[0]))
{
if (pPlayer->cheat_phase >= 0 && numplayers < 2 && ud.recstat == 0)
{
if (CheatKeys[0] == CheatKeys[1])
inputState.ClearKeyStatus((uint8_t) CheatKeys[0]);
pPlayer->cheat_phase = -1;
}
}
if (inputState.GetKeyStatus((uint8_t) CheatKeys[1]))
{
if (pPlayer->cheat_phase == -1)
{
if (ud.player_skill == 4)
{
FTA(QUOTE_CHEATS_DISABLED, pPlayer);
pPlayer->cheat_phase = 0;
}
else
{
pPlayer->cheat_phase = 1;
// FTA(QUOTE_25,pPlayer);
cheatbuflen = 0;
}
inputState.keyFlushChars();
}
else if (pPlayer->cheat_phase != 0)
{
pPlayer->cheat_phase = 0;
inputState.ClearKeyStatus((uint8_t) CheatKeys[0]);
inputState.ClearKeyStatus((uint8_t) CheatKeys[1]);
}
}
}
}
END_DUKE_NS

View file

@ -31,7 +31,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "net.h"
#include "savegame.h"
#include "cheats.h"
#include "sbar.h"
#include "screens.h"
#include "palette.h"
@ -58,6 +57,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_DUKE_NS
void SetDispatcher();
void InitCheats();
void checkcommandline();
int16_t max_ammo_amount[MAX_WEAPONS];
@ -67,7 +67,7 @@ uint8_t shadedsector[MAXSECTORS];
int32_t g_fakeMultiMode = 0;
int32_t g_quitDeadline = 0;
int32_t g_cameraDistance = 0, g_cameraClock = 0;
int32_t cameradist = 0, cameraclock = 0;
static int32_t g_quickExit;
char boardfilename[BMAX_PATH] = {0};
@ -1698,7 +1698,7 @@ int GameInterface::app_main()
g_cdTrack = -1;
}
G_SetupCheats();
InitCheats();
if (SHAREWARE)
g_Shareware = 1;
@ -1930,8 +1930,6 @@ MAIN_LOOP_RESTART:
gameUpdate = true;
gameupdatetime.Unclock();
G_DoCheats();
if (g_player[myconnectindex].ps->gm & (MODE_EOL|MODE_RESTART))
{
switch (G_EndOfLevel())

View file

@ -23,16 +23,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ns.h" // Must come before everything else!
#include "cheats.h"
#include "duke3d.h"
#include "osdcmds.h"
#include "savegame.h"
#include "sbar.h"
#include "mapinfo.h"
#include "cheathandler.h"
BEGIN_DUKE_NS
struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat = { -1, 0, 0 };
bool cheatGod(cheatseq_t*);
bool cheatClip(cheatseq_t*);
bool cheatWeapons(cheatseq_t* s);
bool cheatStuff(cheatseq_t* s);
bool cheatKeys(cheatseq_t* s);
bool cheatInventory(cheatseq_t* s);
static int osdcmd_levelwarp(CCmdFuncPtr parm)
{
@ -46,7 +51,6 @@ static int osdcmd_levelwarp(CCmdFuncPtr parm)
return OSDCMD_OK;
}
osdcmd_cheatsinfo_stat.cheatnum = -1;
ud.m_volume_number = e - 1;
m_level_number = m - 1;
@ -109,7 +113,6 @@ foundone:
return OSDCMD_OK;
}
osdcmd_cheatsinfo_stat.cheatnum = -1;
ud.m_monsters_off = ud.monsters_off = 0;
ud.m_respawn_items = 0;
@ -133,32 +136,25 @@ static int osdcmd_activatecheat(CCmdFuncPtr parm)
if (parm->numparms != 1)
return OSDCMD_SHOWHELP;
if (numplayers == 1 && g_player[myconnectindex].ps->gm & MODE_GAME)
osdcmd_cheatsinfo_stat.cheatnum = Batoi(parm->parms[0]);
else
Printf("activatecheat: Not in a single-player game.\n");
PlaybackCheat(parm->parms[0]);
return OSDCMD_OK;
}
static int osdcmd_god(CCmdFuncPtr UNUSED(parm))
static int osdcmd_god(CCmdFuncPtr)
{
UNREFERENCED_CONST_PARAMETER(parm);
if (numplayers == 1 && g_player[myconnectindex].ps->gm & MODE_GAME)
osdcmd_cheatsinfo_stat.cheatnum = CHEAT_CORNHOLIO;
if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME)
cheatGod(nullptr);
else
Printf("god: Not in a single-player game.\n");
return OSDCMD_OK;
}
static int osdcmd_noclip(CCmdFuncPtr UNUSED(parm))
static int osdcmd_noclip(CCmdFuncPtr)
{
UNREFERENCED_CONST_PARAMETER(parm);
if (numplayers == 1 && g_player[myconnectindex].ps->gm & MODE_GAME)
if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME)
{
osdcmd_cheatsinfo_stat.cheatnum = CHEAT_CLIP;
cheatClip(nullptr);
}
else
{
@ -272,7 +268,6 @@ static int osdcmd_spawn(CCmdFuncPtr parm)
return OSDCMD_OK;
}
static int osdcmd_give(CCmdFuncPtr parm)
{
int32_t i;
@ -286,9 +281,10 @@ static int osdcmd_give(CCmdFuncPtr parm)
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
cheatseq_t* cs = (cheatseq_t*)(intptr_t)1;
if (!Bstrcasecmp(parm->parms[0], "all"))
{
osdcmd_cheatsinfo_stat.cheatnum = CHEAT_STUFF;
cheatStuff(cs);
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->parms[0], "health"))
@ -298,7 +294,7 @@ static int osdcmd_give(CCmdFuncPtr parm)
}
else if (!Bstrcasecmp(parm->parms[0], "weapons"))
{
osdcmd_cheatsinfo_stat.cheatnum = CHEAT_WEAPONS;
cheatWeapons(cs);
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->parms[0], "ammo"))
@ -314,12 +310,12 @@ static int osdcmd_give(CCmdFuncPtr parm)
}
else if (!Bstrcasecmp(parm->parms[0], "keys"))
{
osdcmd_cheatsinfo_stat.cheatnum = CHEAT_KEYS;
cheatKeys(cs);
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->parms[0], "inventory"))
{
osdcmd_cheatsinfo_stat.cheatnum = CHEAT_INVENTORY;
cheatInventory(cs);
return OSDCMD_OK;
}
return OSDCMD_SHOWHELP;