mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
- complete the "give" commands for Shadow Warrior
- add a "levelwarp" cheat for Shadow Warrior
This commit is contained in:
parent
7a5efde1c9
commit
52897c0cbb
3 changed files with 99 additions and 268 deletions
|
@ -175,6 +175,35 @@ void WeaponCheat(PLAYERp pp, const char *)
|
|||
p->WpnAmmo[i] = DamageData[i].max_ammo;
|
||||
}
|
||||
|
||||
p->WpnShotgunAuto = 50;
|
||||
p->WpnRocketHeat = 5;
|
||||
p->WpnRocketNuke = 1;
|
||||
|
||||
PlayerUpdateWeapon(p, u->WeaponNum);
|
||||
}
|
||||
}
|
||||
|
||||
void AmmoCheat(PLAYERp pp, const char *)
|
||||
{
|
||||
PLAYERp p;
|
||||
short pnum;
|
||||
unsigned int i;
|
||||
USERp u;
|
||||
|
||||
TRAVERSE_CONNECT(pnum)
|
||||
{
|
||||
p = &Player[pnum];
|
||||
u = User[p->PlayerSprite];
|
||||
|
||||
p->WpnShotgunAuto = 50;
|
||||
p->WpnRocketHeat = 5;
|
||||
p->WpnRocketNuke = 1;
|
||||
|
||||
for (i = 0; i < SIZ(p->WpnAmmo); i++)
|
||||
{
|
||||
p->WpnAmmo[i] = DamageData[i].max_ammo;
|
||||
}
|
||||
|
||||
PlayerUpdateWeapon(p, u->WeaponNum);
|
||||
}
|
||||
}
|
||||
|
@ -269,6 +298,55 @@ void ItemCheat(PLAYERp pp, const char *cheat_string)
|
|||
PlayerUpdateKeys(pp);
|
||||
}
|
||||
|
||||
void InventoryCheat(PLAYERp pp, const char *cheat_string)
|
||||
{
|
||||
//
|
||||
// Get all ITEMS
|
||||
//
|
||||
PLAYERp p;
|
||||
short pnum;
|
||||
short inv;
|
||||
int i;
|
||||
|
||||
PutStringInfo(pp, "INVENTORY");
|
||||
|
||||
TRAVERSE_CONNECT(pnum)
|
||||
{
|
||||
p = &Player[pnum];
|
||||
|
||||
p->WpnShotgunAuto = 50;
|
||||
p->WpnRocketHeat = 5;
|
||||
p->WpnRocketNuke = 1;
|
||||
p->Armor = 100;
|
||||
|
||||
for (inv = 0; inv < MAX_INVENTORY; inv++)
|
||||
{
|
||||
p->InventoryPercent[inv] = 100;
|
||||
//p->InventoryAmount[inv] = 1;
|
||||
p->InventoryAmount[inv] = InventoryData[inv].MaxInv;
|
||||
//PlayerUpdateInventory(p, inv);
|
||||
}
|
||||
|
||||
PlayerUpdateInventory(p, p->InventoryNum);
|
||||
//p->InventoryNum = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ArmorCheat(PLAYERp pp, const char *cheat_string)
|
||||
{
|
||||
short pnum;
|
||||
const char *str = nullptr;
|
||||
|
||||
TRAVERSE_CONNECT(pnum)
|
||||
{
|
||||
if (User[Player[pnum].PlayerSprite]->Health < pp->MaxHealth)
|
||||
str = "ARMOR";
|
||||
Player[pnum].Armor = 100;
|
||||
}
|
||||
if (str) PutStringInfo(pp, GStrings(str));
|
||||
}
|
||||
|
||||
void HealCheat(PLAYERp pp, const char *cheat_string)
|
||||
{
|
||||
short pnum;
|
||||
|
|
|
@ -13,11 +13,14 @@ void PrevCheat(PLAYERp pp, const char *);
|
|||
void MapCheat(PLAYERp pp, const char *);
|
||||
void LocCheat(PLAYERp pp, const char *);
|
||||
void GunsCheat(PLAYERp pp, const char *cheat_string);
|
||||
void AmmoCheat(PLAYERp pp, const char *);
|
||||
void WeaponCheat(PLAYERp pp, const char *);
|
||||
void GodCheat(PLAYERp pp, const char *);
|
||||
void ClipCheat(PLAYERp pp, const char *);
|
||||
void WarpCheat(PLAYERp pp, const char *cheat_string);
|
||||
void ItemCheat(PLAYERp pp, const char *cheat_string);
|
||||
void InventoryCheat(PLAYERp pp, const char *cheat_string);
|
||||
void ArmorCheat(PLAYERp pp, const char *cheat_string);
|
||||
void HealCheat(PLAYERp pp, const char *cheat_string);
|
||||
void SortKeyCheat(PLAYERp pp, const char *sKey);
|
||||
void KeysCheat(PLAYERp pp, const char *cheat_string);
|
||||
|
|
|
@ -103,50 +103,6 @@ static int osdcmd_map(osdcmdptr_t parm)
|
|||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
// demo <demonum or demofn> [<prof>]
|
||||
//
|
||||
// To profile a demo ("timedemo mode"), <prof> can be given in the range 0-8,
|
||||
// which will start to replay it as fast as possible, rendering <prof> frames
|
||||
// for each gametic.
|
||||
//
|
||||
// Notes:
|
||||
// * The demos should be recorded with demorec_diffs set to 0, so that the
|
||||
// game state updates are actually computed.
|
||||
// * Currently, the profiling can only be aborted on SDL 1.2 builds by
|
||||
// pressing any key.
|
||||
// * With <prof> greater than 1, interpolation should be calculated properly,
|
||||
// though this has not been verified by looking at the frames.
|
||||
// * When testing whether a change in the source has an effect on performance,
|
||||
// the variance of the run times MUST be taken into account (that is, the
|
||||
// replaying must be performed multiple times for the old and new versions,
|
||||
// etc.)
|
||||
static int osdcmd_demo(osdcmdptr_t parm)
|
||||
{
|
||||
if (numplayers > 1)
|
||||
{
|
||||
OSD_Printf("Command not allowed in multiplayer\n");
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (g_player[myconnectindex].ps->gm & MODE_GAME)
|
||||
{
|
||||
OSD_Printf("demo: Must not be in a game.\n");
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms != 1 && parm->numparms != 2)
|
||||
return OSDCMD_SHOWHELP;
|
||||
|
||||
{
|
||||
int32_t prof = parm->numparms==2 ? Batoi(parm->parms[1]) : -1;
|
||||
|
||||
Demo_SetFirst(parm->parms[0]);
|
||||
Demo_PlayFirst(clamp(prof, -1, 8)+1, 0);
|
||||
}
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int osdcmd_activatecheat(osdcmdptr_t parm)
|
||||
|
@ -188,6 +144,19 @@ int osdcmd_restartmap(osdcmdptr_t UNUSED(parm))
|
|||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
int osdcmd_levelwarp(osdcmdptr_t parm)
|
||||
{
|
||||
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
|
||||
|
||||
char cheatcode[9] = "swtrek##";
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
cheatcode[6+i] = parm->parms[0][i];
|
||||
|
||||
WarpCheat(Player, cheatcode);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int osdcmd_spawn(osdcmdptr_t parm)
|
||||
{
|
||||
|
@ -282,112 +251,12 @@ static int osdcmd_spawn(osdcmdptr_t parm)
|
|||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_setvar(osdcmdptr_t parm)
|
||||
{
|
||||
if (numplayers > 1)
|
||||
{
|
||||
OSD_Printf("Command not allowed in multiplayer\n");
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms != 2)
|
||||
return OSDCMD_SHOWHELP;
|
||||
|
||||
int i = hash_find(&h_gamevars, parm->parms[1]);
|
||||
int const newValue = (i == -1) ? Batol(parm->parms[1]) : Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex);
|
||||
|
||||
if ((i = hash_find(&h_gamevars, parm->parms[0])) >= 0)
|
||||
{
|
||||
Gv_SetVar(i, newValue, g_player[myconnectindex].ps->i, myconnectindex);
|
||||
|
||||
OSD_Printf("Variable \"%s\" now has value %d (input: %d)\n", aGameVars[i].szLabel,
|
||||
Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex), newValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSD_Printf("setvar: \"%s\" is not a game variable!\n", parm->parms[0]);
|
||||
return OSDCMD_SHOWHELP;
|
||||
}
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_addlogvar(osdcmdptr_t parm)
|
||||
{
|
||||
if (numplayers > 1)
|
||||
{
|
||||
OSD_Printf("Command not allowed in multiplayer\n");
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms != 1)
|
||||
return OSDCMD_SHOWHELP;
|
||||
|
||||
int const i = hash_find(&h_gamevars, parm->parms[0]);
|
||||
|
||||
if (i >= 0)
|
||||
OSD_Printf("Variable \"%s\" has value %d, default %d\n", parm->parms[0], Gv_GetVar(i, g_player[screenpeek].ps->i, screenpeek), (int)aGameVars[i].defaultValue);
|
||||
else
|
||||
{
|
||||
OSD_Printf("addlogvar: %s is not a game variable!\n", parm->parms[0]);
|
||||
return OSDCMD_SHOWHELP;
|
||||
}
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_setactorvar(osdcmdptr_t parm)
|
||||
{
|
||||
if (numplayers > 1)
|
||||
{
|
||||
OSD_Printf("Command not allowed in multiplayer\n");
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms != 3)
|
||||
return OSDCMD_SHOWHELP;
|
||||
|
||||
int16_t const spriteNum = Batol(parm->parms[0]);
|
||||
|
||||
if ((unsigned)spriteNum >= MAXSPRITES)
|
||||
{
|
||||
OSD_Printf("setactorvar: Invalid sprite number!\n");
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
// get value to set
|
||||
int i = hash_find(&h_gamevars, parm->parms[2]);
|
||||
int const newValue = (i >= 0) ? Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex) : Batol(parm->parms[2]);
|
||||
|
||||
if ((i = hash_find(&h_gamevars, parm->parms[1])) >= 0)
|
||||
{
|
||||
Gv_SetVar(i, newValue, spriteNum, myconnectindex);
|
||||
|
||||
OSD_Printf("Variable \"%s\" for sprite %d value is now %d (input: %d)\n", aGameVars[i].szLabel, spriteNum,
|
||||
Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex), newValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSD_Printf("setactorvar: %s is not a game variable!\n", parm->parms[1]);
|
||||
return OSDCMD_SHOWHELP;
|
||||
}
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int osdcmd_give(osdcmdptr_t parm)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
// if (numplayers != 1 || (g_player[myconnectindex].ps->gm & MODE_GAME) == 0 ||
|
||||
// g_player[myconnectindex].ps->dead_flag != 0)
|
||||
// {
|
||||
// OSD_Printf("give: Cannot give while dead or not in a single-player game.\n");
|
||||
// return OSDCMD_OK;
|
||||
// }
|
||||
|
||||
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
|
||||
|
||||
if (!Bstrcasecmp(parm->parms[0], "all"))
|
||||
|
@ -407,141 +276,27 @@ static int osdcmd_give(osdcmdptr_t parm)
|
|||
}
|
||||
else if (!Bstrcasecmp(parm->parms[0], "ammo"))
|
||||
{
|
||||
// for (i=MAX_WEAPONS-(VOLUMEONE?6:1)-1; i>=PISTOL_WEAPON; i--)
|
||||
// P_AddAmmo(g_player[myconnectindex].ps,i,g_player[myconnectindex].ps->max_ammo_amount[i]);
|
||||
AmmoCheat(Player, "");
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
else if (!Bstrcasecmp(parm->parms[0], "armor"))
|
||||
{
|
||||
// g_player[myconnectindex].ps->inv_amount[GET_SHIELD] = 100;
|
||||
ArmorCheat(Player, ""); // this cheat did not exist before
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
else if (!Bstrcasecmp(parm->parms[0], "keys"))
|
||||
{
|
||||
KeysCheat(Player,"swkeys");
|
||||
KeysCheat(Player, "swkeys");
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
else if (!Bstrcasecmp(parm->parms[0], "inventory"))
|
||||
{
|
||||
ItemCheat(Player, "swgimme");
|
||||
InventoryCheat(Player, ""); // this cheat did not exist before
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
return OSDCMD_SHOWHELP;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void onvideomodechange(int32_t newmode)
|
||||
{
|
||||
uint8_t palid;
|
||||
|
||||
// XXX?
|
||||
// if (!newmode || g_player[screenpeek].ps->palette < BASEPALCOUNT)
|
||||
// palid = g_player[screenpeek].ps->palette;
|
||||
// else
|
||||
// palid = BASEPAL;
|
||||
|
||||
#ifdef POLYMER
|
||||
if (videoGetRenderMode() == REND_POLYMER)
|
||||
{
|
||||
int32_t i = 0;
|
||||
|
||||
while (i < MAXSPRITES)
|
||||
{
|
||||
if (actor[i].lightptr)
|
||||
{
|
||||
polymer_deletelight(actor[i].lightId);
|
||||
actor[i].lightptr = NULL;
|
||||
actor[i].lightId = -1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
videoSetPalette(0, palid, 0);
|
||||
g_restorePalette = -1;
|
||||
g_crosshairSum = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static int osdcmd_dumpmapstate(osdfuncparm_t const * const)
|
||||
{
|
||||
// this command takes no parameters
|
||||
|
||||
DumpMapStateHistory();
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_printtimes(osdcmdptr_t UNUSED(parm))
|
||||
{
|
||||
UNREFERENCED_CONST_PARAMETER(parm);
|
||||
|
||||
char buf[32];
|
||||
int32_t maxlen = 0;
|
||||
int32_t haveev=0, haveac=0;
|
||||
static char const s_event_[] = "EVENT_";
|
||||
int constexpr strlen_event_ = ARRAY_SIZE(s_event_) - 1;
|
||||
|
||||
for (auto & EventName : EventNames)
|
||||
{
|
||||
int const len = Bstrlen(EventName+strlen_event_);
|
||||
Bassert(len < ARRAY_SSIZE(buf));
|
||||
maxlen = max(len, maxlen);
|
||||
}
|
||||
|
||||
for (int i=0; i<MAXEVENTS; i++)
|
||||
if (g_eventCalls[i])
|
||||
{
|
||||
int32_t n=Bsprintf(buf, "%s", EventNames[i]+strlen_event_);
|
||||
|
||||
if (!haveev)
|
||||
{
|
||||
haveev = 1;
|
||||
OSD_Printf("\nevent times: event, total calls, total time [ms], mean time/call [us]\n");
|
||||
}
|
||||
|
||||
buf[n] = 0;
|
||||
|
||||
OSD_Printf("%17s, %8d, %10.3f, %10.3f,\n",
|
||||
buf, g_eventCalls[i], g_eventTotalMs[i],
|
||||
1000*g_eventTotalMs[i]/g_eventCalls[i]);
|
||||
}
|
||||
|
||||
for (int i=0; i<MAXTILES; i++)
|
||||
if (g_actorCalls[i])
|
||||
{
|
||||
if (!haveac)
|
||||
{
|
||||
haveac = 1;
|
||||
OSD_Printf("\nactor times: tile, total calls, total time [ms], {min,mean,max} time/call [us]\n");
|
||||
}
|
||||
|
||||
buf[0] = 0;
|
||||
|
||||
for (int ii=0; ii<g_labelCnt; ii++)
|
||||
{
|
||||
if (labelcode[ii] == i && labeltype[ii] & LABEL_ACTOR)
|
||||
{
|
||||
Bstrcpy(buf, label+(ii<<6));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!buf[0]) Bsprintf(buf, "%d", i);
|
||||
|
||||
OSD_Printf("%17s, %8d, %9.3f, %9.3f, %9.3f, %9.3f,\n",
|
||||
buf, g_actorCalls[i], g_actorTotalMs[i],
|
||||
1000*g_actorMinMs[i],
|
||||
1000*g_actorTotalMs[i]/g_actorCalls[i],
|
||||
1000*g_actorMaxMs[i]);
|
||||
}
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t registerosdcommands(void)
|
||||
{
|
||||
OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
|
||||
|
@ -550,14 +305,9 @@ int32_t registerosdcommands(void)
|
|||
|
||||
OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
|
||||
|
||||
|
||||
// OSD_RegisterFunction("printtimes", "printtimes: prints VM timing statistics", osdcmd_printtimes);
|
||||
OSD_RegisterFunction("levelwarp", "levelwarp <num>: warp to level", osdcmd_levelwarp);
|
||||
|
||||
OSD_RegisterFunction("restartmap", "restartmap: restarts the current map", osdcmd_restartmap);
|
||||
// OSD_RegisterFunction("addlogvar","addlogvar <gamevar>: prints the value of a gamevar", osdcmd_addlogvar);
|
||||
// OSD_RegisterFunction("setvar","setvar <gamevar> <value>: sets the value of a gamevar", osdcmd_setvar);
|
||||
// OSD_RegisterFunction("setvarvar","setvarvar <gamevar1> <gamevar2>: sets the value of <gamevar1> to <gamevar2>", osdcmd_setvar);
|
||||
// OSD_RegisterFunction("setactorvar","setactorvar <actor#> <gamevar> <value>: sets the value of <actor#>'s <gamevar> to <value>", osdcmd_setactorvar);
|
||||
|
||||
// OSD_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",osdcmd_spawn);
|
||||
|
||||
|
|
Loading…
Reference in a new issue