mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- transitioned Blood's give command and changed SW's not to call the cheat handler.
This commit is contained in:
parent
3e5e956b72
commit
fb334e7f1a
8 changed files with 141 additions and 84 deletions
|
@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "gstrings.h"
|
||||
#include "cheathandler.h"
|
||||
#include "d_protocol.h"
|
||||
#include "gamestate.h"
|
||||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
|
@ -288,10 +289,14 @@ static int parseArgs(char *pzArgs, int *nArg1, int *nArg2)
|
|||
const char* GameInterface::GenericCheat(int player, int cheat)
|
||||
{
|
||||
// message processing is not perfect because many cheats output multiple messages.
|
||||
if (gGameOptions.nGameType != 0) // sp only for now.
|
||||
return nullptr;
|
||||
int nEpisode, nLevel;
|
||||
|
||||
if (gGameOptions.nGameType != 0 || numplayers > 1) // sp only for now.
|
||||
return nullptr;
|
||||
|
||||
if (gamestate != GS_LEVEL || gMe->pXSprite->health == 0) // must be alive and in a level to cheat.
|
||||
return nullptr;
|
||||
|
||||
bPlayerCheated = true;
|
||||
switch (cheat)
|
||||
{
|
||||
case CHT_GOD:
|
||||
|
@ -479,7 +484,6 @@ static cheatseq_t s_CheatInfo[] = {
|
|||
//{"SPIELBERG", nullptr, doCheat<kCheatSpielberg, 1 }, // SPIELBERG (Disables all cheats. If number values corresponding to a level and episode number are entered after the cheat word (i.e. "spielberg 1 3" for Phantom Express), you will be spawned to said level and the game will begin recording a demo from your actions.)
|
||||
};
|
||||
|
||||
|
||||
void cheatReset(void)
|
||||
{
|
||||
bPlayerCheated = 0;
|
||||
|
@ -490,6 +494,65 @@ void cheatReset(void)
|
|||
gFullMap = 0;
|
||||
}
|
||||
|
||||
|
||||
static void cmd_Give(int player, uint8_t **stream, bool skip)
|
||||
{
|
||||
int type = ReadByte(stream);
|
||||
if (skip) return;
|
||||
|
||||
if (numplayers != 1 || gamestate != GS_LEVEL || gMe->pXSprite->health == 0)
|
||||
{
|
||||
Printf("give: Cannot give while dead or not in a single-player game.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GIVE_ALL:
|
||||
SetWeapons(true);
|
||||
SetAmmo(true);
|
||||
SetToys(true);
|
||||
SetArmor(true);
|
||||
SetKeys(true);
|
||||
bPlayerCheated = true;
|
||||
break;
|
||||
|
||||
case GIVE_HEALTH:
|
||||
actHealDude(gMe->pXSprite, 200, 200);
|
||||
bPlayerCheated = true;
|
||||
break;
|
||||
|
||||
case GIVE_WEAPONS:
|
||||
SetWeapons(true);
|
||||
bPlayerCheated = true;
|
||||
break;
|
||||
|
||||
case GIVE_AMMO:
|
||||
SetAmmo(true);
|
||||
bPlayerCheated = true;
|
||||
break;
|
||||
|
||||
case GIVE_ARMOR:
|
||||
SetArmor(true);
|
||||
bPlayerCheated = true;
|
||||
break;
|
||||
|
||||
case GIVE_KEYS:
|
||||
SetKeys(true);
|
||||
bPlayerCheated = true;
|
||||
break;
|
||||
|
||||
case GIVE_INVENTORY:
|
||||
SetToys(true);
|
||||
bPlayerCheated = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MessagesLoadSave : public LoadSave
|
||||
{
|
||||
public:
|
||||
|
@ -517,6 +580,7 @@ void MessagesLoadSaveConstruct(void)
|
|||
void InitCheats()
|
||||
{
|
||||
SetCheats(s_CheatInfo, countof(s_CheatInfo));
|
||||
Net_SetCommandHandler(DEM_GIVE, cmd_Give);
|
||||
}
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -70,65 +70,6 @@ static int osdcmd_map(CCmdFuncPtr parm)
|
|||
}
|
||||
|
||||
|
||||
static int osdcmd_give(CCmdFuncPtr parm)
|
||||
{
|
||||
if (numplayers != 1 || gamestate != GS_LEVEL|| gMe->pXSprite->health == 0)
|
||||
{
|
||||
Printf("give: Cannot give while dead or not in a single-player game.\n");
|
||||
return CCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms != 1) return CCMD_SHOWHELP;
|
||||
|
||||
if (!Bstrcasecmp(parm->parms[0], "all"))
|
||||
{
|
||||
SetWeapons(true);
|
||||
SetAmmo(true);
|
||||
SetToys(true);
|
||||
SetArmor(true);
|
||||
SetKeys(true);
|
||||
bPlayerCheated = true;
|
||||
return CCMD_OK;
|
||||
}
|
||||
else if (!Bstrcasecmp(parm->parms[0], "health"))
|
||||
{
|
||||
actHealDude(gMe->pXSprite, 200, 200);
|
||||
bPlayerCheated = true;
|
||||
return CCMD_OK;
|
||||
}
|
||||
else if (!Bstrcasecmp(parm->parms[0], "weapons"))
|
||||
{
|
||||
SetWeapons(true);
|
||||
bPlayerCheated = true;
|
||||
return CCMD_OK;
|
||||
}
|
||||
else if (!Bstrcasecmp(parm->parms[0], "ammo"))
|
||||
{
|
||||
SetAmmo(true);
|
||||
bPlayerCheated = true;
|
||||
return CCMD_OK;
|
||||
}
|
||||
else if (!Bstrcasecmp(parm->parms[0], "armor"))
|
||||
{
|
||||
SetArmor(true);
|
||||
bPlayerCheated = true;
|
||||
return CCMD_OK;
|
||||
}
|
||||
else if (!Bstrcasecmp(parm->parms[0], "keys"))
|
||||
{
|
||||
SetKeys(true);
|
||||
bPlayerCheated = true;
|
||||
return CCMD_OK;
|
||||
}
|
||||
else if (!Bstrcasecmp(parm->parms[0], "inventory"))
|
||||
{
|
||||
SetToys(true);
|
||||
bPlayerCheated = true;
|
||||
return CCMD_OK;
|
||||
}
|
||||
return CCMD_SHOWHELP;
|
||||
}
|
||||
|
||||
static int osdcmd_levelwarp(CCmdFuncPtr parm)
|
||||
{
|
||||
if (parm->numparms != 2)
|
||||
|
@ -220,7 +161,6 @@ static int osdcmd_show_weapon(CCmdFuncPtr parm)
|
|||
int32_t registerosdcommands(void)
|
||||
{
|
||||
C_RegisterFunction("map","map <mapname>: loads the given map", osdcmd_map);
|
||||
C_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
|
||||
C_RegisterFunction("levelwarp","levelwarp <e> <m>: warp to episode 'e' and map 'm'", osdcmd_levelwarp);
|
||||
C_RegisterFunction("warptocoords","warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates",osdcmd_warptocoords);
|
||||
C_RegisterFunction("third_person_view", "Switch to third person view", osdcmd_third_person_view);
|
||||
|
|
|
@ -138,4 +138,32 @@ CCMD(allmap)
|
|||
gFullMap = !gFullMap;
|
||||
Printf("%s\n", GStrings(gFullMap ? "SHOW MAP: ON" : "SHOW MAP: OFF"));
|
||||
}
|
||||
}
|
||||
|
||||
CCMD(give)
|
||||
{
|
||||
static const char* type[] = { "ALL","AMMO","ARMOR","HEALTH","INVENTORY","ITEMS","KEYS","WEAPONS",nullptr };
|
||||
if (argv.argc() < 2)
|
||||
{
|
||||
Printf("give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item\n");
|
||||
return;
|
||||
}
|
||||
size_t found = -1;
|
||||
for (size_t i = 0; i < countof(type); i++)
|
||||
{
|
||||
if (!stricmp(argv[1], type[i]))
|
||||
{
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == -1)
|
||||
{
|
||||
Printf("Unable to give %s\n", argv[1]);
|
||||
}
|
||||
if (!CheckCheatmode(true, true))
|
||||
{
|
||||
Net_WriteByte(DEM_GIVE);
|
||||
Net_WriteByte(found);
|
||||
}
|
||||
}
|
|
@ -89,6 +89,8 @@ enum EDemoCommand
|
|||
DEM_USERCMD,
|
||||
DEM_EMPTYUSERCMD,
|
||||
DEM_GENERICCHEAT,
|
||||
DEM_GIVE,
|
||||
DEM_CHANGEMAP,
|
||||
|
||||
DEM_MAX
|
||||
};
|
||||
|
@ -150,6 +152,18 @@ enum ECheat
|
|||
CHT_MAX
|
||||
};
|
||||
|
||||
enum EGiveType
|
||||
{
|
||||
GIVE_ALL,
|
||||
GIVE_AMMO,
|
||||
GIVE_ARMOR,
|
||||
GIVE_HEALTH,
|
||||
GIVE_INVENTORY,
|
||||
GIVE_ITEMS,
|
||||
GIVE_KEYS,
|
||||
GIVE_WEAPONS
|
||||
};
|
||||
|
||||
typedef void(*NetCommandHandler)(int player, uint8_t **stream, bool skip);
|
||||
|
||||
void Net_SetCommandHandler(EDemoCommand cmd, NetCommandHandler handler) noexcept;
|
||||
|
|
|
@ -243,7 +243,7 @@ int32_t registerosdcommands(void)
|
|||
C_RegisterFunction("third_person_view", "Switch to third person view", osdcmd_third_person_view);
|
||||
C_RegisterFunction("coop_view", "Switch player to view from in coop", osdcmd_noop);
|
||||
C_RegisterFunction("show_weapon", "Show opponents' weapons", osdcmd_noop);
|
||||
C_RegisterFunction("give", "give <all|health|weapons|keys|inventory>: gives requested item", ccmd_give);
|
||||
//C_RegisterFunction("give", "give <all|health|weapons|keys|inventory>: gives requested item", ccmd_give);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -312,7 +312,7 @@ int registerosdcommands(void)
|
|||
{
|
||||
C_RegisterFunction("map","map <mapname>: warp to the given map, identified by its name", ccmd_map);
|
||||
C_RegisterFunction("levelwarp","levelwarp <e> <m>: warp to episode 'e' and map 'm'", ccmd_levelwarp);
|
||||
C_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", ccmd_give);
|
||||
//C_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", ccmd_give);
|
||||
C_RegisterFunction("restartmap", "restartmap: restarts the current map", ccmd_restartmap);
|
||||
C_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",ccmd_spawn);
|
||||
C_RegisterFunction("warptocoords","warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates",osdcmd_warptocoords);
|
||||
|
|
|
@ -56,7 +56,7 @@ static PLAYERp checkCheat(cheatseq_t* c)
|
|||
if (CommEnabled)
|
||||
return nullptr;
|
||||
|
||||
if (Skill >= 3 && !c->DontCheck && !sv_cheats)
|
||||
if (Skill >= 3 && (!c || !c->DontCheck) && !sv_cheats)
|
||||
{
|
||||
PutStringInfo(&Player[screenpeek], GStrings("TXTS_TOOSKILLFUL"));
|
||||
return nullptr;
|
||||
|
@ -409,28 +409,30 @@ bool EveryCheatToggle(cheatseq_t* c)
|
|||
{
|
||||
EveryCheat ^= 1;
|
||||
C_DoCommand("god");
|
||||
return WeaponCheat(c) && ItemCheat(c);
|
||||
C_DoCommand("give weapons");
|
||||
C_DoCommand("give items");
|
||||
return true;
|
||||
}
|
||||
|
||||
// The prefix was changed from 'sw' to 'lw' so that it doesn't contain two keys of the WASD control scheme, which interferes with input control.
|
||||
static cheatseq_t swcheats[] = {
|
||||
{"lwgod", "god" },
|
||||
{"lwchan", "god" },
|
||||
{"lwgimme", nullptr, ItemCheat, 0},
|
||||
{"lwmedic", nullptr, HealCheat, 0},
|
||||
{"lwgimme", "give all" },
|
||||
{"lwmedic", "give health" },
|
||||
{"lwkey#", nullptr, KeyCheat, 0},
|
||||
{"lwkeys", nullptr, KeysCheat, 0},
|
||||
{"lwammo", nullptr, AmmoCheat, 0},
|
||||
{"lwarmor", nullptr, ArmorCheat, 0},
|
||||
{"lwitems", nullptr, ItemCheat, 0},
|
||||
{"lwguns", nullptr, WeaponCheat, 0},
|
||||
{"lwkeys", "give keys" },
|
||||
{"lwammo", "give ammo" },
|
||||
{"lwarmor", "give armor" },
|
||||
{"lwitems", "give items" },
|
||||
{"lwguns", "give weapons" },
|
||||
{"lwtrek##", nullptr, WarpCheat, 0},
|
||||
{"lwgreed", nullptr, EveryCheatToggle, 0},
|
||||
{"lwghost", "noclip" },
|
||||
{"lwstart", nullptr, RestartCheat, 0},
|
||||
{"lwloc", "stat coord", nullptr, true},
|
||||
{"lwmap", nullptr, MapCheat, 0},
|
||||
{"lwroom", nullptr, RoomCheat, true}, // Room above room dbug
|
||||
{"lwroom", nullptr, RoomCheat, true}, // Room above room debug
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -114,6 +114,15 @@ int osdcmd_levelwarp(CCmdFuncPtr parm)
|
|||
return CCMD_OK;
|
||||
}
|
||||
|
||||
struct cheatseq_t;
|
||||
bool WeaponCheat(cheatseq_t* c);
|
||||
bool AmmoCheat(cheatseq_t* c);
|
||||
bool ItemCheat(cheatseq_t* c);
|
||||
bool InventoryCheat(cheatseq_t* c);
|
||||
bool ArmorCheat(cheatseq_t* c);
|
||||
bool HealCheat(cheatseq_t* c);
|
||||
bool KeysCheat(cheatseq_t* c);
|
||||
|
||||
|
||||
static int osdcmd_give(CCmdFuncPtr parm)
|
||||
{
|
||||
|
@ -123,37 +132,37 @@ static int osdcmd_give(CCmdFuncPtr parm)
|
|||
|
||||
if (!stricmp(parm->parms[0], "all"))
|
||||
{
|
||||
C_DoCommand("activatecheat lwgimme");
|
||||
ItemCheat(nullptr);
|
||||
return CCMD_OK;
|
||||
}
|
||||
else if (!stricmp(parm->parms[0], "health"))
|
||||
{
|
||||
C_DoCommand("activatecheat lwmedic");
|
||||
HealCheat(nullptr);
|
||||
return CCMD_OK;
|
||||
}
|
||||
else if (!stricmp(parm->parms[0], "weapons"))
|
||||
{
|
||||
C_DoCommand("activatecheat lwguns");
|
||||
WeaponCheat(nullptr);
|
||||
return CCMD_OK;
|
||||
}
|
||||
else if (!stricmp(parm->parms[0], "ammo"))
|
||||
{
|
||||
C_DoCommand("activatecheat lwammo");
|
||||
AmmoCheat(nullptr);
|
||||
return CCMD_OK;
|
||||
}
|
||||
else if (!stricmp(parm->parms[0], "armor"))
|
||||
{
|
||||
C_DoCommand("activatecheat lwarmor");
|
||||
ArmorCheat(nullptr);
|
||||
return CCMD_OK;
|
||||
}
|
||||
else if (!stricmp(parm->parms[0], "keys"))
|
||||
{
|
||||
C_DoCommand("activatecheat lwkeys");
|
||||
KeysCheat(nullptr);
|
||||
return CCMD_OK;
|
||||
}
|
||||
else if (!stricmp(parm->parms[0], "inventory"))
|
||||
{
|
||||
C_DoCommand("activatecheat lwitems");
|
||||
InventoryCheat(nullptr);
|
||||
return CCMD_OK;
|
||||
}
|
||||
return CCMD_SHOWHELP;
|
||||
|
@ -271,7 +280,7 @@ static int osdcmd_noop(CCmdFuncPtr parm)
|
|||
int32_t registerosdcommands(void)
|
||||
{
|
||||
C_RegisterFunction("map","map <mapfile>: loads the given map", osdcmd_map);
|
||||
C_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
|
||||
//C_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
|
||||
C_RegisterFunction("mirror_debug", "mirror [mirrornum]: print mirror debug info", osdcmd_mirror);
|
||||
C_RegisterFunction("levelwarp", "levelwarp <num>: warp to level", osdcmd_levelwarp);
|
||||
C_RegisterFunction("restartmap", "restartmap: restarts the current map", osdcmd_restartmap);
|
||||
|
|
Loading…
Reference in a new issue