2006-02-24 04:48:15 +00:00
|
|
|
// Emacs style mode select -*- C++ -*-
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// $Id:$
|
|
|
|
//
|
|
|
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
|
|
//
|
|
|
|
// This source is available for distribution and/or modification
|
|
|
|
// only under the terms of the DOOM Source Code License as
|
|
|
|
// published by id Software. All rights reserved.
|
|
|
|
//
|
|
|
|
// The source is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
// $Log:$
|
|
|
|
//
|
|
|
|
// DESCRIPTION:
|
|
|
|
// Cheat sequence checking.
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "m_cheat.h"
|
|
|
|
#include "d_player.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "gstrings.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "a_strifeglobal.h"
|
|
|
|
#include "gi.h"
|
|
|
|
#include "p_enemy.h"
|
|
|
|
#include "sbar.h"
|
|
|
|
#include "c_dispatch.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "w_wad.h"
|
|
|
|
#include "a_keys.h"
|
|
|
|
#include "templates.h"
|
2007-12-23 14:23:52 +00:00
|
|
|
#include "c_console.h"
|
2011-07-06 08:50:15 +00:00
|
|
|
#include "r_data/r_translate.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "g_level.h"
|
|
|
|
#include "d_net.h"
|
2008-09-17 00:14:33 +00:00
|
|
|
#include "d_dehacked.h"
|
2008-09-21 18:02:38 +00:00
|
|
|
#include "gi.h"
|
2012-08-30 03:24:57 +00:00
|
|
|
#include "farchive.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// [RH] Actually handle the cheat. The cheat code in st_stuff.c now just
|
|
|
|
// writes some bytes to the network data stream, and the network code
|
|
|
|
// later calls us.
|
|
|
|
|
|
|
|
void cht_DoCheat (player_t *player, int cheat)
|
|
|
|
{
|
2010-04-04 04:09:24 +00:00
|
|
|
static const char * const BeholdPowers[9] =
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-03-29 20:25:08 +00:00
|
|
|
"PowerInvulnerable",
|
|
|
|
"PowerStrength",
|
|
|
|
"PowerInvisibility",
|
|
|
|
"PowerIronFeet",
|
|
|
|
"MapRevealer",
|
|
|
|
"PowerLightAmp",
|
|
|
|
"PowerShadow",
|
|
|
|
"PowerMask",
|
|
|
|
"PowerTargeter",
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
2010-03-24 02:49:37 +00:00
|
|
|
PClassActor *type;
|
2006-02-24 04:48:15 +00:00
|
|
|
AInventory *item;
|
|
|
|
const char *msg = "";
|
|
|
|
char msgbuild[32];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
switch (cheat)
|
|
|
|
{
|
|
|
|
case CHT_IDDQD:
|
2006-06-22 20:52:49 +00:00
|
|
|
if (!(player->cheats & CF_GODMODE) && player->playerstate == PST_LIVE)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (player->mo)
|
|
|
|
player->mo->health = deh.GodHealth;
|
|
|
|
|
|
|
|
player->health = deh.GodHealth;
|
|
|
|
}
|
|
|
|
// fall through to CHT_GOD
|
|
|
|
case CHT_GOD:
|
|
|
|
player->cheats ^= CF_GODMODE;
|
2010-10-11 19:16:09 +00:00
|
|
|
if (player->cheats & CF_GODMODE)
|
|
|
|
msg = GStrings("STSTR_DQDON");
|
2006-02-24 04:48:15 +00:00
|
|
|
else
|
2010-10-11 19:16:09 +00:00
|
|
|
msg = GStrings("STSTR_DQDOFF");
|
2013-02-27 03:10:25 +00:00
|
|
|
ST_SetNeedRefresh();
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
2009-08-07 04:08:38 +00:00
|
|
|
case CHT_BUDDHA:
|
|
|
|
player->cheats ^= CF_BUDDHA;
|
|
|
|
if (player->cheats & CF_BUDDHA)
|
|
|
|
msg = GStrings("TXT_BUDDHAON");
|
|
|
|
else
|
|
|
|
msg = GStrings("TXT_BUDDHAOFF");
|
|
|
|
break;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
case CHT_NOCLIP:
|
|
|
|
player->cheats ^= CF_NOCLIP;
|
|
|
|
if (player->cheats & CF_NOCLIP)
|
|
|
|
msg = GStrings("STSTR_NCON");
|
|
|
|
else
|
|
|
|
msg = GStrings("STSTR_NCOFF");
|
|
|
|
break;
|
|
|
|
|
2012-08-22 21:31:48 +00:00
|
|
|
case CHT_NOCLIP2:
|
|
|
|
player->cheats ^= CF_NOCLIP2;
|
|
|
|
if (player->cheats & CF_NOCLIP2)
|
|
|
|
{
|
|
|
|
player->cheats |= CF_NOCLIP;
|
|
|
|
msg = GStrings("STSTR_NC2ON");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player->cheats &= ~CF_NOCLIP;
|
|
|
|
msg = GStrings("STSTR_NCOFF");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-06-30 20:57:51 +00:00
|
|
|
case CHT_NOVELOCITY:
|
|
|
|
player->cheats ^= CF_NOVELOCITY;
|
|
|
|
if (player->cheats & CF_NOVELOCITY)
|
2008-08-21 07:08:55 +00:00
|
|
|
msg = GStrings("TXT_LEADBOOTSON");
|
2006-02-24 04:48:15 +00:00
|
|
|
else
|
2008-08-21 07:08:55 +00:00
|
|
|
msg = GStrings("TXT_LEADBOOTSOFF");
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_FLY:
|
|
|
|
if (player->mo != NULL)
|
|
|
|
{
|
|
|
|
player->cheats ^= CF_FLY;
|
|
|
|
if (player->cheats & CF_FLY)
|
|
|
|
{
|
|
|
|
player->mo->flags |= MF_NOGRAVITY;
|
|
|
|
player->mo->flags2 |= MF2_FLY;
|
2008-08-21 07:08:55 +00:00
|
|
|
msg = GStrings("TXT_LIGHTER");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player->mo->flags &= ~MF_NOGRAVITY;
|
|
|
|
player->mo->flags2 &= ~MF2_FLY;
|
2008-08-21 07:08:55 +00:00
|
|
|
msg = GStrings("TXT_GRAVITY");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_MORPH:
|
2010-03-25 20:38:00 +00:00
|
|
|
msg = cht_Morph (player, static_cast<PClassPlayerPawn *>(PClass::FindClass (gameinfo.gametype == GAME_Heretic ? NAME_ChickenPlayer : NAME_PigPlayer)), true);
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_NOTARGET:
|
|
|
|
player->cheats ^= CF_NOTARGET;
|
|
|
|
if (player->cheats & CF_NOTARGET)
|
|
|
|
msg = "notarget ON";
|
|
|
|
else
|
|
|
|
msg = "notarget OFF";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_ANUBIS:
|
|
|
|
player->cheats ^= CF_FRIGHTENING;
|
|
|
|
if (player->cheats & CF_FRIGHTENING)
|
|
|
|
msg = "\"Quake with fear!\"";
|
|
|
|
else
|
|
|
|
msg = "No more ogre armor";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_CHASECAM:
|
|
|
|
player->cheats ^= CF_CHASECAM;
|
|
|
|
if (player->cheats & CF_CHASECAM)
|
|
|
|
msg = "chasecam ON";
|
|
|
|
else
|
|
|
|
msg = "chasecam OFF";
|
|
|
|
R_ResetViewInterpolation ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_CHAINSAW:
|
2006-06-22 20:52:49 +00:00
|
|
|
if (player->mo != NULL && player->health >= 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
type = PClass::FindActor("Chainsaw");
|
- Fixed: ActorFlagSetOrReset() wasn't receiving the + or - character from
ParseActorProperties().
- Fixed: The decorate FindFlag() function returned flags from ActorFlags
instead of the passed flags set.
- Fixed: The CHT_CHAINSAW, CHT_POWER, CHT_HEALTH, and CHT_RESSURECT needed
NULL player->mo checks.
- Fixed: The "give all" command didn't give the backpack in Doom, and it
must give the backpack before giving ammo.
- Fixed: P_SetPsprite() must not call the action function if the player is
not attached to an actor. This can happen, for instance, if the level is
destroyed while the player is holding a powered-up Phoenix Rod. As part
of its EndPowerup() function, it sets the psprite to the regular version,
but the player actor has already been destroyed.
- Fixed: FinishThingdef() needs to check for valid names, because weapons
could have inherited valid pointers from their superclass.
- Fixed: fuglyname didn't work.
- Fixed: Redefining $ambient sounds leaked memory.
- Added Jim's crashcatcher.c fix for better shell support.
- VC7.1 seems to have no trouble distinguishing between passing a (const
TypeInfo *) reference to operator<< and the generic, templated (object *)
version, so a few places that can benefit from it now use it. I believe
VC6 had problems with this, which is why I didn't do it all along. The
function's implementation was also moved out of dobject.cpp and into
farchive.cpp.
- Fixed: UnpackPixels() unpacked all chunks in a byte, which is wrong for the
last byte in a row if the image width is not an even multiple of the number
pixels per byte.
- Fixed: P_TranslateLineDef() should only clear monster activation for secret
useable lines, not crossable lines.
- Fixed: Some leftover P_IsHostile() calls still needed to be rewritten.
- Fixed: AWeaponHolder::Serialize() wrote the class type in all circumstances.
SVN r20 (trunk)
2006-03-14 06:11:39 +00:00
|
|
|
if (player->mo->FindInventory (type) == NULL)
|
|
|
|
{
|
|
|
|
player->mo->GiveInventoryType (type);
|
|
|
|
}
|
2010-10-11 19:16:09 +00:00
|
|
|
msg = GStrings("STSTR_CHOPPERS");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
// [RH] The original cheat also set powers[pw_invulnerability] to true.
|
|
|
|
// Since this is a timer and not a boolean, it effectively turned off
|
|
|
|
// the invulnerability powerup, although it looks like it was meant to
|
|
|
|
// turn it on.
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_POWER:
|
2006-06-22 20:52:49 +00:00
|
|
|
if (player->mo != NULL && player->health >= 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2011-11-07 00:43:41 +00:00
|
|
|
item = player->mo->FindInventory (RUNTIME_CLASS(APowerWeaponLevel2), true);
|
- Fixed: ActorFlagSetOrReset() wasn't receiving the + or - character from
ParseActorProperties().
- Fixed: The decorate FindFlag() function returned flags from ActorFlags
instead of the passed flags set.
- Fixed: The CHT_CHAINSAW, CHT_POWER, CHT_HEALTH, and CHT_RESSURECT needed
NULL player->mo checks.
- Fixed: The "give all" command didn't give the backpack in Doom, and it
must give the backpack before giving ammo.
- Fixed: P_SetPsprite() must not call the action function if the player is
not attached to an actor. This can happen, for instance, if the level is
destroyed while the player is holding a powered-up Phoenix Rod. As part
of its EndPowerup() function, it sets the psprite to the regular version,
but the player actor has already been destroyed.
- Fixed: FinishThingdef() needs to check for valid names, because weapons
could have inherited valid pointers from their superclass.
- Fixed: fuglyname didn't work.
- Fixed: Redefining $ambient sounds leaked memory.
- Added Jim's crashcatcher.c fix for better shell support.
- VC7.1 seems to have no trouble distinguishing between passing a (const
TypeInfo *) reference to operator<< and the generic, templated (object *)
version, so a few places that can benefit from it now use it. I believe
VC6 had problems with this, which is why I didn't do it all along. The
function's implementation was also moved out of dobject.cpp and into
farchive.cpp.
- Fixed: UnpackPixels() unpacked all chunks in a byte, which is wrong for the
last byte in a row if the image width is not an even multiple of the number
pixels per byte.
- Fixed: P_TranslateLineDef() should only clear monster activation for secret
useable lines, not crossable lines.
- Fixed: Some leftover P_IsHostile() calls still needed to be rewritten.
- Fixed: AWeaponHolder::Serialize() wrote the class type in all circumstances.
SVN r20 (trunk)
2006-03-14 06:11:39 +00:00
|
|
|
if (item != NULL)
|
|
|
|
{
|
|
|
|
item->Destroy ();
|
|
|
|
msg = GStrings("TXT_CHEATPOWEROFF");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player->mo->GiveInventoryType (RUNTIME_CLASS(APowerWeaponLevel2));
|
|
|
|
msg = GStrings("TXT_CHEATPOWERON");
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_IDKFA:
|
|
|
|
cht_Give (player, "backpack");
|
|
|
|
cht_Give (player, "weapons");
|
|
|
|
cht_Give (player, "ammo");
|
|
|
|
cht_Give (player, "keys");
|
|
|
|
cht_Give (player, "armor");
|
2010-10-11 19:16:09 +00:00
|
|
|
msg = GStrings("STSTR_KFAADDED");
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_IDFA:
|
|
|
|
cht_Give (player, "backpack");
|
|
|
|
cht_Give (player, "weapons");
|
|
|
|
cht_Give (player, "ammo");
|
|
|
|
cht_Give (player, "armor");
|
2010-10-11 19:16:09 +00:00
|
|
|
msg = GStrings("STSTR_FAADDED");
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_BEHOLDV:
|
|
|
|
case CHT_BEHOLDS:
|
|
|
|
case CHT_BEHOLDI:
|
|
|
|
case CHT_BEHOLDR:
|
|
|
|
case CHT_BEHOLDA:
|
|
|
|
case CHT_BEHOLDL:
|
|
|
|
case CHT_PUMPUPI:
|
|
|
|
case CHT_PUMPUPM:
|
|
|
|
case CHT_PUMPUPT:
|
|
|
|
i = cheat - CHT_BEHOLDV;
|
|
|
|
|
|
|
|
if (i == 4)
|
|
|
|
{
|
2009-02-03 19:11:43 +00:00
|
|
|
level.flags2 ^= LEVEL2_ALLMAP;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-06-22 20:52:49 +00:00
|
|
|
else if (player->mo != NULL && player->health >= 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-04-04 04:09:24 +00:00
|
|
|
item = player->mo->FindInventory(PClass::FindActor(BeholdPowers[i]));
|
2006-02-24 04:48:15 +00:00
|
|
|
if (item == NULL)
|
|
|
|
{
|
2008-08-06 19:25:59 +00:00
|
|
|
if (i != 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-03-26 22:26:50 +00:00
|
|
|
cht_Give(player, BeholdPowers[i]);
|
2008-08-06 19:25:59 +00:00
|
|
|
if (cheat == CHT_BEHOLDS)
|
|
|
|
{
|
|
|
|
P_GiveBody (player->mo, -100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Let's give the item here so that the power doesn't need colormap information.
|
2010-03-26 22:26:50 +00:00
|
|
|
cht_Give(player, "InvulnerabilitySphere");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->Destroy ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
msg = GStrings("STSTR_BEHOLDX");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_MASSACRE:
|
|
|
|
{
|
|
|
|
int killcount = P_Massacre ();
|
|
|
|
// killough 3/22/98: make more intelligent about plural
|
|
|
|
// Ty 03/27/98 - string(s) *not* externalized
|
About a week's worth of changes here. As a heads-up, I wouldn't be
surprised if this doesn't build in Linux right now. The CMakeLists.txt
were checked with MinGW and NMake, but how they fair under Linux is an
unknown to me at this time.
- Converted most sprintf (and all wsprintf) calls to either mysnprintf or
FStrings, depending on the situation.
- Changed the strings in the wbstartstruct to be FStrings.
- Changed myvsnprintf() to output nothing if count is greater than INT_MAX.
This is so that I can use a series of mysnprintf() calls and advance the
pointer for each one. Once the pointer goes beyond the end of the buffer,
the count will go negative, but since it's an unsigned type it will be
seen as excessively huge instead. This should not be a problem, as there's
no reason for ZDoom to be using text buffers larger than 2 GB anywhere.
- Ripped out the disabled bit from FGameConfigFile::MigrateOldConfig().
- Changed CalcMapName() to return an FString instead of a pointer to a static
buffer.
- Changed startmap in d_main.cpp into an FString.
- Changed CheckWarpTransMap() to take an FString& as the first argument.
- Changed d_mapname in g_level.cpp into an FString.
- Changed DoSubstitution() in ct_chat.cpp to place the substitutions in an
FString.
- Fixed: The MAPINFO parser wrote into the string buffer to construct a map
name when given a Hexen map number. This was fine with the old scanner
code, but only a happy coincidence prevents it from crashing with the new
code
- Added the 'B' conversion specifier to StringFormat::VWorker() for printing
binary numbers.
- Added CMake support for building with MinGW, MSYS, and NMake. Linux support
is probably broken until I get around to booting into Linux again. Niceties
provided over the existing Makefiles they're replacing:
* All command-line builds can use the same build system, rather than having
a separate one for MinGW and another for Linux.
* Microsoft's NMake tool is supported as a target.
* Progress meters.
* Parallel makes work from a fresh checkout without needing to be primed
first with a single-threaded make.
* Porting to other architectures should be simplified, whenever that day
comes.
- Replaced the makewad tool with zipdir. This handles the dependency tracking
itself instead of generating an external makefile to do it, since I couldn't
figure out how to generate a makefile with an external tool and include it
with a CMake-generated makefile. Where makewad used a master list of files
to generate the package file, zipdir just zips the entire contents of one or
more directories.
- Added the gdtoa package from netlib's fp library so that ZDoom's printf-style
formatting can be entirely independant of the CRT.
SVN r1082 (trunk)
2008-07-23 04:57:26 +00:00
|
|
|
mysnprintf (msgbuild, countof(msgbuild), "%d Monster%s Killed", killcount, killcount==1 ? "" : "s");
|
2006-02-24 04:48:15 +00:00
|
|
|
msg = msgbuild;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_HEALTH:
|
2006-06-22 20:52:49 +00:00
|
|
|
if (player->mo != NULL && player->playerstate == PST_LIVE)
|
- Fixed: ActorFlagSetOrReset() wasn't receiving the + or - character from
ParseActorProperties().
- Fixed: The decorate FindFlag() function returned flags from ActorFlags
instead of the passed flags set.
- Fixed: The CHT_CHAINSAW, CHT_POWER, CHT_HEALTH, and CHT_RESSURECT needed
NULL player->mo checks.
- Fixed: The "give all" command didn't give the backpack in Doom, and it
must give the backpack before giving ammo.
- Fixed: P_SetPsprite() must not call the action function if the player is
not attached to an actor. This can happen, for instance, if the level is
destroyed while the player is holding a powered-up Phoenix Rod. As part
of its EndPowerup() function, it sets the psprite to the regular version,
but the player actor has already been destroyed.
- Fixed: FinishThingdef() needs to check for valid names, because weapons
could have inherited valid pointers from their superclass.
- Fixed: fuglyname didn't work.
- Fixed: Redefining $ambient sounds leaked memory.
- Added Jim's crashcatcher.c fix for better shell support.
- VC7.1 seems to have no trouble distinguishing between passing a (const
TypeInfo *) reference to operator<< and the generic, templated (object *)
version, so a few places that can benefit from it now use it. I believe
VC6 had problems with this, which is why I didn't do it all along. The
function's implementation was also moved out of dobject.cpp and into
farchive.cpp.
- Fixed: UnpackPixels() unpacked all chunks in a byte, which is wrong for the
last byte in a row if the image width is not an even multiple of the number
pixels per byte.
- Fixed: P_TranslateLineDef() should only clear monster activation for secret
useable lines, not crossable lines.
- Fixed: Some leftover P_IsHostile() calls still needed to be rewritten.
- Fixed: AWeaponHolder::Serialize() wrote the class type in all circumstances.
SVN r20 (trunk)
2006-03-14 06:11:39 +00:00
|
|
|
{
|
|
|
|
player->health = player->mo->health = player->mo->GetDefault()->health;
|
|
|
|
msg = GStrings("TXT_CHEATHEALTH");
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_KEYS:
|
|
|
|
cht_Give (player, "keys");
|
|
|
|
msg = GStrings("TXT_CHEATKEYS");
|
|
|
|
break;
|
|
|
|
|
|
|
|
// [GRB]
|
|
|
|
case CHT_RESSURECT:
|
- Fixed: ActorFlagSetOrReset() wasn't receiving the + or - character from
ParseActorProperties().
- Fixed: The decorate FindFlag() function returned flags from ActorFlags
instead of the passed flags set.
- Fixed: The CHT_CHAINSAW, CHT_POWER, CHT_HEALTH, and CHT_RESSURECT needed
NULL player->mo checks.
- Fixed: The "give all" command didn't give the backpack in Doom, and it
must give the backpack before giving ammo.
- Fixed: P_SetPsprite() must not call the action function if the player is
not attached to an actor. This can happen, for instance, if the level is
destroyed while the player is holding a powered-up Phoenix Rod. As part
of its EndPowerup() function, it sets the psprite to the regular version,
but the player actor has already been destroyed.
- Fixed: FinishThingdef() needs to check for valid names, because weapons
could have inherited valid pointers from their superclass.
- Fixed: fuglyname didn't work.
- Fixed: Redefining $ambient sounds leaked memory.
- Added Jim's crashcatcher.c fix for better shell support.
- VC7.1 seems to have no trouble distinguishing between passing a (const
TypeInfo *) reference to operator<< and the generic, templated (object *)
version, so a few places that can benefit from it now use it. I believe
VC6 had problems with this, which is why I didn't do it all along. The
function's implementation was also moved out of dobject.cpp and into
farchive.cpp.
- Fixed: UnpackPixels() unpacked all chunks in a byte, which is wrong for the
last byte in a row if the image width is not an even multiple of the number
pixels per byte.
- Fixed: P_TranslateLineDef() should only clear monster activation for secret
useable lines, not crossable lines.
- Fixed: Some leftover P_IsHostile() calls still needed to be rewritten.
- Fixed: AWeaponHolder::Serialize() wrote the class type in all circumstances.
SVN r20 (trunk)
2006-03-14 06:11:39 +00:00
|
|
|
if (player->playerstate != PST_LIVE && player->mo != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-04-16 13:29:50 +00:00
|
|
|
if (player->mo->IsKindOf(RUNTIME_CLASS(APlayerChunk)))
|
2006-04-13 22:40:43 +00:00
|
|
|
{
|
2006-04-16 13:29:50 +00:00
|
|
|
Printf("Unable to resurrect. Player is no longer connected to its body.\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player->playerstate = PST_LIVE;
|
|
|
|
player->health = player->mo->health = player->mo->GetDefault()->health;
|
2006-07-13 10:17:56 +00:00
|
|
|
player->viewheight = ((APlayerPawn *)player->mo->GetDefault())->ViewHeight;
|
2006-04-16 13:29:50 +00:00
|
|
|
player->mo->flags = player->mo->GetDefault()->flags;
|
2007-05-10 22:22:38 +00:00
|
|
|
player->mo->flags2 = player->mo->GetDefault()->flags2;
|
|
|
|
player->mo->flags3 = player->mo->GetDefault()->flags3;
|
|
|
|
player->mo->flags4 = player->mo->GetDefault()->flags4;
|
|
|
|
player->mo->flags5 = player->mo->GetDefault()->flags5;
|
2012-11-09 05:20:15 +00:00
|
|
|
player->mo->flags6 = player->mo->GetDefault()->flags6;
|
2008-10-04 07:45:54 +00:00
|
|
|
player->mo->renderflags &= ~RF_INVISIBLE;
|
2006-04-16 13:29:50 +00:00
|
|
|
player->mo->height = player->mo->GetDefault()->height;
|
2013-01-02 01:34:27 +00:00
|
|
|
player->mo->radius = player->mo->GetDefault()->radius;
|
2007-05-26 10:50:32 +00:00
|
|
|
player->mo->special1 = 0; // required for the Hexen fighter's fist attack.
|
|
|
|
// This gets set by AActor::Die as flag for the wimpy death and must be reset here.
|
2006-04-16 13:29:50 +00:00
|
|
|
player->mo->SetState (player->mo->SpawnState);
|
2010-03-06 09:30:38 +00:00
|
|
|
if (!(player->mo->flags2 & MF2_DONTTRANSLATE))
|
|
|
|
{
|
|
|
|
player->mo->Translation = TRANSLATION(TRANSLATION_Players, BYTE(player-players));
|
|
|
|
}
|
2006-10-31 14:53:21 +00:00
|
|
|
player->mo->DamageType = NAME_None;
|
2006-06-18 04:10:47 +00:00
|
|
|
// player->mo->GiveDefaultInventory();
|
2006-07-31 10:22:53 +00:00
|
|
|
if (player->ReadyWeapon != NULL)
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
P_SetPsprite(player, ps_weapon, player->ReadyWeapon->GetUpState());
|
2006-07-31 10:22:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (player->morphTics > 0)
|
|
|
|
{
|
2008-05-22 19:35:38 +00:00
|
|
|
P_UndoPlayerMorph(player, player);
|
2006-07-31 10:22:53 +00:00
|
|
|
}
|
|
|
|
|
2006-04-13 22:40:43 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-08-21 07:08:55 +00:00
|
|
|
case CHT_GIMMIEA:
|
|
|
|
cht_Give (player, "ArtiInvulnerability");
|
|
|
|
msg = "Valador's Ring of Invunerability";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_GIMMIEB:
|
|
|
|
cht_Give (player, "ArtiInvisibility");
|
|
|
|
msg = "Shadowsphere";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_GIMMIEC:
|
|
|
|
cht_Give (player, "ArtiHealth");
|
|
|
|
msg = "Quartz Flask";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_GIMMIED:
|
|
|
|
cht_Give (player, "ArtiSuperHealth");
|
|
|
|
msg = "Mystic Urn";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_GIMMIEE:
|
|
|
|
cht_Give (player, "ArtiTomeOfPower");
|
|
|
|
msg = "Tyketto's Tome of Power";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_GIMMIEF:
|
|
|
|
cht_Give (player, "ArtiTorch");
|
|
|
|
msg = "Torch";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_GIMMIEG:
|
|
|
|
cht_Give (player, "ArtiTimeBomb");
|
|
|
|
msg = "Delmintalintar's Time Bomb of the Ancients";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_GIMMIEH:
|
|
|
|
cht_Give (player, "ArtiEgg");
|
|
|
|
msg = "Torpol's Morph Ovum";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_GIMMIEI:
|
|
|
|
cht_Give (player, "ArtiFly");
|
|
|
|
msg = "Inhilicon's Wings of Wrath";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_GIMMIEJ:
|
|
|
|
cht_Give (player, "ArtiTeleport");
|
|
|
|
msg = "Darchala's Chaos Device";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_GIMMIEZ:
|
|
|
|
for (int i=0;i<16;i++)
|
|
|
|
{
|
|
|
|
cht_Give (player, "artifacts");
|
|
|
|
}
|
|
|
|
msg = "All artifacts!";
|
|
|
|
break;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
case CHT_TAKEWEAPS:
|
2008-01-07 08:58:18 +00:00
|
|
|
if (player->morphTics || player->mo == NULL || player->mo->health <= 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
{
|
2009-05-26 17:35:30 +00:00
|
|
|
// Take away all weapons that are either non-wimpy or use ammo.
|
|
|
|
AInventory **invp = &player->mo->Inventory, **lastinvp;
|
|
|
|
for (item = *invp; item != NULL; item = *invp)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-05-26 17:35:30 +00:00
|
|
|
lastinvp = invp;
|
|
|
|
invp = &(*invp)->Inventory;
|
|
|
|
if (item->IsKindOf (RUNTIME_CLASS(AWeapon)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-05-26 17:35:30 +00:00
|
|
|
AWeapon *weap = static_cast<AWeapon *> (item);
|
|
|
|
if (!(weap->WeaponFlags & WIF_WIMPY_WEAPON) ||
|
|
|
|
weap->AmmoType1 != NULL)
|
|
|
|
{
|
|
|
|
item->Destroy ();
|
|
|
|
invp = lastinvp;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
msg = GStrings("TXT_CHEATIDKFA");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_NOWUDIE:
|
|
|
|
cht_Suicide (player);
|
|
|
|
msg = GStrings("TXT_CHEATIDDQD");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_ALLARTI:
|
2006-04-11 16:27:41 +00:00
|
|
|
for (int i=0;i<25;i++)
|
|
|
|
{
|
|
|
|
cht_Give (player, "artifacts");
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
msg = GStrings("TXT_CHEATARTIFACTS3");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_PUZZLE:
|
|
|
|
cht_Give (player, "puzzlepieces");
|
|
|
|
msg = GStrings("TXT_CHEATARTIFACTS3");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_MDK:
|
|
|
|
if (player->mo == NULL)
|
|
|
|
{
|
- Fixed: ActorFlagSetOrReset() wasn't receiving the + or - character from
ParseActorProperties().
- Fixed: The decorate FindFlag() function returned flags from ActorFlags
instead of the passed flags set.
- Fixed: The CHT_CHAINSAW, CHT_POWER, CHT_HEALTH, and CHT_RESSURECT needed
NULL player->mo checks.
- Fixed: The "give all" command didn't give the backpack in Doom, and it
must give the backpack before giving ammo.
- Fixed: P_SetPsprite() must not call the action function if the player is
not attached to an actor. This can happen, for instance, if the level is
destroyed while the player is holding a powered-up Phoenix Rod. As part
of its EndPowerup() function, it sets the psprite to the regular version,
but the player actor has already been destroyed.
- Fixed: FinishThingdef() needs to check for valid names, because weapons
could have inherited valid pointers from their superclass.
- Fixed: fuglyname didn't work.
- Fixed: Redefining $ambient sounds leaked memory.
- Added Jim's crashcatcher.c fix for better shell support.
- VC7.1 seems to have no trouble distinguishing between passing a (const
TypeInfo *) reference to operator<< and the generic, templated (object *)
version, so a few places that can benefit from it now use it. I believe
VC6 had problems with this, which is why I didn't do it all along. The
function's implementation was also moved out of dobject.cpp and into
farchive.cpp.
- Fixed: UnpackPixels() unpacked all chunks in a byte, which is wrong for the
last byte in a row if the image width is not an even multiple of the number
pixels per byte.
- Fixed: P_TranslateLineDef() should only clear monster activation for secret
useable lines, not crossable lines.
- Fixed: Some leftover P_IsHostile() calls still needed to be rewritten.
- Fixed: AWeaponHolder::Serialize() wrote the class type in all circumstances.
SVN r20 (trunk)
2006-03-14 06:11:39 +00:00
|
|
|
Printf ("What do you want to kill outside of a game?\n");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (!deathmatch)
|
|
|
|
{
|
|
|
|
// Don't allow this in deathmatch even with cheats enabled, because it's
|
|
|
|
// a very very cheap kill.
|
|
|
|
P_LineAttack (player->mo, player->mo->angle, PLAYERMISSILERANGE,
|
2009-08-07 03:57:03 +00:00
|
|
|
P_AimLineAttack (player->mo, player->mo->angle, PLAYERMISSILERANGE), TELEFRAG_DAMAGE,
|
2009-06-16 22:04:26 +00:00
|
|
|
NAME_MDK, NAME_BulletPuff);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_DONNYTRUMP:
|
|
|
|
cht_Give (player, "HealthTraining");
|
2008-08-21 07:08:55 +00:00
|
|
|
msg = GStrings("TXT_MIDASTOUCH");
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_LEGO:
|
2006-06-22 20:52:49 +00:00
|
|
|
if (player->mo != NULL && player->health >= 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int oldpieces = ASigil::GiveSigilPiece (player->mo);
|
|
|
|
item = player->mo->FindInventory (RUNTIME_CLASS(ASigil));
|
|
|
|
|
|
|
|
if (item != NULL)
|
|
|
|
{
|
|
|
|
if (oldpieces == 5)
|
|
|
|
{
|
|
|
|
item->Destroy ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player->PendingWeapon = static_cast<AWeapon *> (item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_PUMPUPH:
|
|
|
|
cht_Give (player, "MedPatch");
|
|
|
|
cht_Give (player, "MedicalKit");
|
|
|
|
cht_Give (player, "SurgeryKit");
|
2008-08-21 07:08:55 +00:00
|
|
|
msg = GStrings("TXT_GOTSTUFF");
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_PUMPUPP:
|
|
|
|
cht_Give (player, "AmmoSatchel");
|
2008-08-21 07:08:55 +00:00
|
|
|
msg = GStrings("TXT_GOTSTUFF");
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CHT_PUMPUPS:
|
2006-06-24 08:03:15 +00:00
|
|
|
cht_Give (player, "UpgradeStamina", 10);
|
2006-02-24 04:48:15 +00:00
|
|
|
cht_Give (player, "UpgradeAccuracy");
|
2008-08-21 07:08:55 +00:00
|
|
|
msg = GStrings("TXT_GOTSTUFF");
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
2006-10-24 02:32:12 +00:00
|
|
|
|
|
|
|
case CHT_CLEARFROZENPROPS:
|
|
|
|
player->cheats &= ~(CF_FROZEN|CF_TOTALLYFROZEN);
|
|
|
|
msg = "Frozen player properties turned off";
|
|
|
|
break;
|
2007-10-29 20:27:40 +00:00
|
|
|
|
|
|
|
case CHT_FREEZE:
|
2008-03-28 00:38:17 +00:00
|
|
|
bglobal.changefreeze ^= 1;
|
|
|
|
if (bglobal.freeze ^ bglobal.changefreeze)
|
2007-10-29 20:27:40 +00:00
|
|
|
{
|
2008-08-21 07:08:55 +00:00
|
|
|
msg = GStrings("TXT_FREEZEON");
|
2007-10-29 20:27:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-21 07:08:55 +00:00
|
|
|
msg = GStrings("TXT_FREEZEOFF");
|
2007-10-29 20:27:40 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!*msg) // [SO] Don't print blank lines!
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (player == &players[consoleplayer])
|
|
|
|
Printf ("%s\n", msg);
|
2012-09-09 03:07:41 +00:00
|
|
|
else if (cheat != CHT_CHASECAM)
|
2013-05-12 18:27:03 +00:00
|
|
|
Printf ("%s cheats: %s\n", player->userinfo.GetName(), msg);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-03-25 20:38:00 +00:00
|
|
|
const char *cht_Morph (player_t *player, PClassPlayerPawn *morphclass, bool quickundo)
|
2006-10-27 03:03:34 +00:00
|
|
|
{
|
|
|
|
if (player->mo == NULL)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
2010-03-25 20:38:00 +00:00
|
|
|
PClassPlayerPawn *oldclass = player->mo->GetClass();
|
2008-04-08 09:52:50 +00:00
|
|
|
|
|
|
|
// Set the standard morph style for the current game
|
|
|
|
int style = MORPH_UNDOBYTOMEOFPOWER;
|
|
|
|
if (gameinfo.gametype == GAME_Hexen) style |= MORPH_UNDOBYCHAOSDEVICE;
|
|
|
|
|
2006-10-27 03:03:34 +00:00
|
|
|
if (player->morphTics)
|
|
|
|
{
|
2008-05-22 19:35:38 +00:00
|
|
|
if (P_UndoPlayerMorph (player, player))
|
2006-10-27 03:03:34 +00:00
|
|
|
{
|
2008-04-12 15:31:18 +00:00
|
|
|
if (!quickundo && oldclass != morphclass && P_MorphPlayer (player, player, morphclass, 0, style))
|
2006-10-27 03:03:34 +00:00
|
|
|
{
|
2008-08-21 07:08:55 +00:00
|
|
|
return GStrings("TXT_STRANGER");
|
2006-10-27 03:03:34 +00:00
|
|
|
}
|
2008-08-21 07:08:55 +00:00
|
|
|
return GStrings("TXT_NOTSTRANGE");
|
2006-10-27 03:03:34 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-12 15:31:18 +00:00
|
|
|
else if (P_MorphPlayer (player, player, morphclass, 0, style))
|
2006-10-27 03:03:34 +00:00
|
|
|
{
|
2008-08-21 07:08:55 +00:00
|
|
|
return GStrings("TXT_STRANGE");
|
2006-10-27 03:03:34 +00:00
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2010-04-03 04:07:17 +00:00
|
|
|
void GiveSpawner (player_t *player, PClassInventory *type, int amount)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-06-22 20:52:49 +00:00
|
|
|
if (player->mo == NULL || player->health <= 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
AInventory *item = static_cast<AInventory *>
|
2006-07-16 09:10:45 +00:00
|
|
|
(Spawn (type, player->mo->x, player->mo->y, player->mo->z, NO_REPLACE));
|
2006-02-24 04:48:15 +00:00
|
|
|
if (item != NULL)
|
|
|
|
{
|
|
|
|
if (amount > 0)
|
|
|
|
{
|
|
|
|
if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorPickup)))
|
|
|
|
{
|
|
|
|
if (static_cast<ABasicArmorPickup*>(item)->SaveAmount != 0)
|
|
|
|
{
|
|
|
|
static_cast<ABasicArmorPickup*>(item)->SaveAmount *= amount;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
static_cast<ABasicArmorPickup*>(item)->SaveAmount *= amount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorBonus)))
|
|
|
|
{
|
|
|
|
static_cast<ABasicArmorBonus*>(item)->SaveAmount *= amount;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->Amount = MIN (amount, item->MaxAmount);
|
|
|
|
}
|
|
|
|
}
|
2010-09-19 00:06:45 +00:00
|
|
|
item->ClearCounters();
|
2008-09-13 22:08:41 +00:00
|
|
|
if (!item->CallTryPickup (player->mo))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
item->Destroy ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-29 03:38:37 +00:00
|
|
|
void cht_Give (player_t *player, const char *name, int amount)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-07-09 01:57:46 +00:00
|
|
|
enum { ALL_NO, ALL_YES, ALL_YESYES } giveall;
|
2006-02-24 04:48:15 +00:00
|
|
|
int i;
|
2010-04-16 02:57:51 +00:00
|
|
|
PClassActor *type;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (player != &players[consoleplayer])
|
2013-05-12 18:27:03 +00:00
|
|
|
Printf ("%s is a cheater: give %s\n", player->userinfo.GetName(), name);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-04-13 22:40:43 +00:00
|
|
|
if (player->mo == NULL || player->health <= 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-07-09 01:57:46 +00:00
|
|
|
giveall = ALL_NO;
|
|
|
|
if (stricmp (name, "all") == 0)
|
|
|
|
{
|
|
|
|
giveall = ALL_YES;
|
|
|
|
}
|
|
|
|
else if (stricmp (name, "everything") == 0)
|
|
|
|
{
|
2010-07-10 00:51:38 +00:00
|
|
|
giveall = ALL_YESYES;
|
2010-07-09 01:57:46 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-07-09 01:57:46 +00:00
|
|
|
if (stricmp (name, "health") == 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (amount > 0)
|
|
|
|
{
|
|
|
|
if (player->mo)
|
|
|
|
{
|
|
|
|
player->mo->health += amount;
|
|
|
|
player->health = player->mo->health;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player->health += amount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-25 03:07:20 +00:00
|
|
|
if (player->mo != NULL)
|
|
|
|
{
|
|
|
|
player->health = player->mo->health = player->mo->GetMaxHealth();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player->health = deh.GodHealth;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
- Fixed: ActorFlagSetOrReset() wasn't receiving the + or - character from
ParseActorProperties().
- Fixed: The decorate FindFlag() function returned flags from ActorFlags
instead of the passed flags set.
- Fixed: The CHT_CHAINSAW, CHT_POWER, CHT_HEALTH, and CHT_RESSURECT needed
NULL player->mo checks.
- Fixed: The "give all" command didn't give the backpack in Doom, and it
must give the backpack before giving ammo.
- Fixed: P_SetPsprite() must not call the action function if the player is
not attached to an actor. This can happen, for instance, if the level is
destroyed while the player is holding a powered-up Phoenix Rod. As part
of its EndPowerup() function, it sets the psprite to the regular version,
but the player actor has already been destroyed.
- Fixed: FinishThingdef() needs to check for valid names, because weapons
could have inherited valid pointers from their superclass.
- Fixed: fuglyname didn't work.
- Fixed: Redefining $ambient sounds leaked memory.
- Added Jim's crashcatcher.c fix for better shell support.
- VC7.1 seems to have no trouble distinguishing between passing a (const
TypeInfo *) reference to operator<< and the generic, templated (object *)
version, so a few places that can benefit from it now use it. I believe
VC6 had problems with this, which is why I didn't do it all along. The
function's implementation was also moved out of dobject.cpp and into
farchive.cpp.
- Fixed: UnpackPixels() unpacked all chunks in a byte, which is wrong for the
last byte in a row if the image width is not an even multiple of the number
pixels per byte.
- Fixed: P_TranslateLineDef() should only clear monster activation for secret
useable lines, not crossable lines.
- Fixed: Some leftover P_IsHostile() calls still needed to be rewritten.
- Fixed: AWeaponHolder::Serialize() wrote the class type in all circumstances.
SVN r20 (trunk)
2006-03-14 06:11:39 +00:00
|
|
|
if (giveall || stricmp (name, "backpack") == 0)
|
|
|
|
{
|
|
|
|
// Select the correct type of backpack based on the game
|
2010-04-16 02:57:51 +00:00
|
|
|
type = PClass::FindActor(gameinfo.backpacktype);
|
- Fixed: ActorFlagSetOrReset() wasn't receiving the + or - character from
ParseActorProperties().
- Fixed: The decorate FindFlag() function returned flags from ActorFlags
instead of the passed flags set.
- Fixed: The CHT_CHAINSAW, CHT_POWER, CHT_HEALTH, and CHT_RESSURECT needed
NULL player->mo checks.
- Fixed: The "give all" command didn't give the backpack in Doom, and it
must give the backpack before giving ammo.
- Fixed: P_SetPsprite() must not call the action function if the player is
not attached to an actor. This can happen, for instance, if the level is
destroyed while the player is holding a powered-up Phoenix Rod. As part
of its EndPowerup() function, it sets the psprite to the regular version,
but the player actor has already been destroyed.
- Fixed: FinishThingdef() needs to check for valid names, because weapons
could have inherited valid pointers from their superclass.
- Fixed: fuglyname didn't work.
- Fixed: Redefining $ambient sounds leaked memory.
- Added Jim's crashcatcher.c fix for better shell support.
- VC7.1 seems to have no trouble distinguishing between passing a (const
TypeInfo *) reference to operator<< and the generic, templated (object *)
version, so a few places that can benefit from it now use it. I believe
VC6 had problems with this, which is why I didn't do it all along. The
function's implementation was also moved out of dobject.cpp and into
farchive.cpp.
- Fixed: UnpackPixels() unpacked all chunks in a byte, which is wrong for the
last byte in a row if the image width is not an even multiple of the number
pixels per byte.
- Fixed: P_TranslateLineDef() should only clear monster activation for secret
useable lines, not crossable lines.
- Fixed: Some leftover P_IsHostile() calls still needed to be rewritten.
- Fixed: AWeaponHolder::Serialize() wrote the class type in all circumstances.
SVN r20 (trunk)
2006-03-14 06:11:39 +00:00
|
|
|
if (type != NULL)
|
|
|
|
{
|
2010-04-03 04:07:17 +00:00
|
|
|
GiveSpawner (player, static_cast<PClassInventory *>(type), 1);
|
- Fixed: ActorFlagSetOrReset() wasn't receiving the + or - character from
ParseActorProperties().
- Fixed: The decorate FindFlag() function returned flags from ActorFlags
instead of the passed flags set.
- Fixed: The CHT_CHAINSAW, CHT_POWER, CHT_HEALTH, and CHT_RESSURECT needed
NULL player->mo checks.
- Fixed: The "give all" command didn't give the backpack in Doom, and it
must give the backpack before giving ammo.
- Fixed: P_SetPsprite() must not call the action function if the player is
not attached to an actor. This can happen, for instance, if the level is
destroyed while the player is holding a powered-up Phoenix Rod. As part
of its EndPowerup() function, it sets the psprite to the regular version,
but the player actor has already been destroyed.
- Fixed: FinishThingdef() needs to check for valid names, because weapons
could have inherited valid pointers from their superclass.
- Fixed: fuglyname didn't work.
- Fixed: Redefining $ambient sounds leaked memory.
- Added Jim's crashcatcher.c fix for better shell support.
- VC7.1 seems to have no trouble distinguishing between passing a (const
TypeInfo *) reference to operator<< and the generic, templated (object *)
version, so a few places that can benefit from it now use it. I believe
VC6 had problems with this, which is why I didn't do it all along. The
function's implementation was also moved out of dobject.cpp and into
farchive.cpp.
- Fixed: UnpackPixels() unpacked all chunks in a byte, which is wrong for the
last byte in a row if the image width is not an even multiple of the number
pixels per byte.
- Fixed: P_TranslateLineDef() should only clear monster activation for secret
useable lines, not crossable lines.
- Fixed: Some leftover P_IsHostile() calls still needed to be rewritten.
- Fixed: AWeaponHolder::Serialize() wrote the class type in all circumstances.
SVN r20 (trunk)
2006-03-14 06:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!giveall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (giveall || stricmp (name, "ammo") == 0)
|
|
|
|
{
|
|
|
|
// Find every unique type of ammo. Give it to the player if
|
|
|
|
// he doesn't have it already, and set each to its maximum.
|
2010-04-16 02:57:51 +00:00
|
|
|
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
PClassActor *type = PClassActor::AllActorClasses[i];
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-10 02:40:43 +00:00
|
|
|
if (type->ParentClass == RUNTIME_CLASS(AAmmo))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-04-03 04:07:17 +00:00
|
|
|
PClassAmmo *atype = static_cast<PClassAmmo *>(type);
|
|
|
|
AInventory *ammo = player->mo->FindInventory(atype);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (ammo == NULL)
|
|
|
|
{
|
2010-04-03 04:07:17 +00:00
|
|
|
ammo = static_cast<AInventory *>(Spawn (atype, 0, 0, 0, NO_REPLACE));
|
2006-02-24 04:48:15 +00:00
|
|
|
ammo->AttachToOwner (player->mo);
|
|
|
|
ammo->Amount = ammo->MaxAmount;
|
|
|
|
}
|
|
|
|
else if (ammo->Amount < ammo->MaxAmount)
|
|
|
|
{
|
|
|
|
ammo->Amount = ammo->MaxAmount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!giveall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (giveall || stricmp (name, "armor") == 0)
|
|
|
|
{
|
|
|
|
if (gameinfo.gametype != GAME_Hexen)
|
|
|
|
{
|
2006-07-16 09:10:45 +00:00
|
|
|
ABasicArmorPickup *armor = Spawn<ABasicArmorPickup> (0,0,0, NO_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
armor->SaveAmount = 100*deh.BlueAC;
|
2009-09-07 19:46:54 +00:00
|
|
|
armor->SavePercent = gameinfo.Armor2Percent > 0? gameinfo.Armor2Percent : FRACUNIT/2;
|
2008-09-13 22:08:41 +00:00
|
|
|
if (!armor->CallTryPickup (player->mo))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
armor->Destroy ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
{
|
2006-07-16 09:10:45 +00:00
|
|
|
AHexenArmor *armor = Spawn<AHexenArmor> (0,0,0, NO_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
armor->health = i;
|
|
|
|
armor->Amount = 0;
|
2008-09-13 22:08:41 +00:00
|
|
|
if (!armor->CallTryPickup (player->mo))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
armor->Destroy ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!giveall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (giveall || stricmp (name, "keys") == 0)
|
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
if (PClassActor::AllActorClasses[i]->IsDescendantOf (RUNTIME_CLASS(AKey)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
AKey *key = (AKey *)GetDefaultByType (PClassActor::AllActorClasses[i]);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (key->KeyNumber != 0)
|
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
key = static_cast<AKey *>(Spawn(static_cast<PClassActor *>(PClassActor::AllActorClasses[i]), 0,0,0, NO_REPLACE));
|
2008-09-13 22:08:41 +00:00
|
|
|
if (!key->CallTryPickup (player->mo))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
key->Destroy ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!giveall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (giveall || stricmp (name, "weapons") == 0)
|
|
|
|
{
|
|
|
|
AWeapon *savedpending = player->PendingWeapon;
|
2010-04-16 02:57:51 +00:00
|
|
|
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
type = PClassActor::AllActorClasses[i];
|
2008-09-17 00:14:33 +00:00
|
|
|
// Don't give replaced weapons unless the replacement was done by Dehacked.
|
2006-02-24 04:48:15 +00:00
|
|
|
if (type != RUNTIME_CLASS(AWeapon) &&
|
2008-09-17 00:14:33 +00:00
|
|
|
type->IsDescendantOf (RUNTIME_CLASS(AWeapon)) &&
|
2010-03-24 02:49:37 +00:00
|
|
|
(static_cast<PClassActor *>(type)->GetReplacement() == type ||
|
|
|
|
static_cast<PClassActor *>(type)->GetReplacement()->IsDescendantOf(RUNTIME_CLASS(ADehackedPickup))))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-09-17 00:14:33 +00:00
|
|
|
// Give the weapon only if it belongs to the current game or
|
2009-02-20 22:28:48 +00:00
|
|
|
// is in a weapon slot.
|
2010-03-24 02:49:37 +00:00
|
|
|
if (static_cast<PClassActor *>(type)->GameFilter == GAME_Any ||
|
|
|
|
(static_cast<PClassActor *>(type)->GameFilter & gameinfo.gametype) ||
|
2010-03-25 20:38:00 +00:00
|
|
|
player->weapons.LocateWeapon(static_cast<PClassWeapon *>(type), NULL, NULL))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-09-17 00:14:33 +00:00
|
|
|
AWeapon *def = (AWeapon*)GetDefaultByType (type);
|
2010-07-09 01:57:46 +00:00
|
|
|
if (giveall == ALL_YESYES || !(def->WeaponFlags & WIF_CHEATNOTWEAPON))
|
2008-09-17 00:14:33 +00:00
|
|
|
{
|
2010-04-03 04:07:17 +00:00
|
|
|
GiveSpawner (player, static_cast<PClassInventory *>(type), 1);
|
2008-09-17 00:14:33 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
player->PendingWeapon = savedpending;
|
|
|
|
|
|
|
|
if (!giveall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (giveall || stricmp (name, "artifacts") == 0)
|
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
type = PClassActor::AllActorClasses[i];
|
2006-02-24 04:48:15 +00:00
|
|
|
if (type->IsDescendantOf (RUNTIME_CLASS(AInventory)))
|
|
|
|
{
|
|
|
|
AInventory *def = (AInventory*)GetDefaultByType (type);
|
2008-06-15 18:36:26 +00:00
|
|
|
if (def->Icon.isValid() && def->MaxAmount > 1 &&
|
2006-02-24 04:48:15 +00:00
|
|
|
!type->IsDescendantOf (RUNTIME_CLASS(APuzzleItem)) &&
|
|
|
|
!type->IsDescendantOf (RUNTIME_CLASS(APowerup)) &&
|
|
|
|
!type->IsDescendantOf (RUNTIME_CLASS(AArmor)))
|
|
|
|
{
|
2012-03-08 23:34:00 +00:00
|
|
|
// Do not give replaced items unless using "give everything"
|
|
|
|
if (giveall == ALL_YESYES || type->GetReplacement() == type)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
GiveSpawner (player, static_cast<PClassInventory *>(type), amount <= 0 ? def->MaxAmount : amount);
|
2012-03-08 23:34:00 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!giveall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (giveall || stricmp (name, "puzzlepieces") == 0)
|
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
type = PClassActor::AllActorClasses[i];
|
2006-02-24 04:48:15 +00:00
|
|
|
if (type->IsDescendantOf (RUNTIME_CLASS(APuzzleItem)))
|
|
|
|
{
|
|
|
|
AInventory *def = (AInventory*)GetDefaultByType (type);
|
2008-06-15 18:36:26 +00:00
|
|
|
if (def->Icon.isValid())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-03-08 23:34:00 +00:00
|
|
|
// Do not give replaced items unless using "give everything"
|
|
|
|
if (giveall == ALL_YESYES || type->GetReplacement() == type)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
GiveSpawner (player, static_cast<PClassInventory *>(type), amount <= 0 ? def->MaxAmount : amount);
|
2012-03-08 23:34:00 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!giveall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-04-11 08:36:23 +00:00
|
|
|
if (giveall)
|
|
|
|
return;
|
|
|
|
|
2010-04-16 02:57:51 +00:00
|
|
|
type = PClass::FindActor(name);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (type == NULL || !type->IsDescendantOf (RUNTIME_CLASS(AInventory)))
|
|
|
|
{
|
|
|
|
if (player == &players[consoleplayer])
|
|
|
|
Printf ("Unknown item \"%s\"\n", name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-04-03 04:07:17 +00:00
|
|
|
GiveSpawner (player, static_cast<PClassInventory *>(type), amount);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-23 14:23:52 +00:00
|
|
|
void cht_Take (player_t *player, const char *name, int amount)
|
|
|
|
{
|
|
|
|
bool takeall;
|
2010-03-24 02:49:37 +00:00
|
|
|
PClass *type;
|
2007-12-23 14:23:52 +00:00
|
|
|
|
|
|
|
if (player->mo == NULL || player->health <= 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
takeall = (stricmp (name, "all") == 0);
|
|
|
|
|
|
|
|
if (!takeall && stricmp (name, "health") == 0)
|
|
|
|
{
|
|
|
|
if (player->mo->health - amount <= 0
|
|
|
|
|| player->health - amount <= 0
|
|
|
|
|| amount == 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
cht_Suicide (player);
|
|
|
|
|
|
|
|
if (player == &players[consoleplayer])
|
|
|
|
C_HideConsole ();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (amount > 0)
|
|
|
|
{
|
|
|
|
if (player->mo)
|
|
|
|
{
|
|
|
|
player->mo->health -= amount;
|
|
|
|
player->health = player->mo->health;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player->health -= amount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!takeall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (takeall || stricmp (name, "backpack") == 0)
|
|
|
|
{
|
2008-09-21 18:02:38 +00:00
|
|
|
// Take away all types of backpacks the player might own.
|
2010-04-16 02:57:51 +00:00
|
|
|
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
2007-12-23 14:23:52 +00:00
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
PClass *type = PClassActor::AllActorClasses[i];
|
2007-12-23 14:23:52 +00:00
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
if (type->IsDescendantOf(RUNTIME_CLASS (ABackpackItem)))
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
AInventory *pack = player->mo->FindInventory(static_cast<PClassActor *>(type));
|
2008-09-21 18:02:38 +00:00
|
|
|
|
2010-03-24 02:49:37 +00:00
|
|
|
if (pack)
|
|
|
|
pack->Destroy();
|
2008-09-21 18:02:38 +00:00
|
|
|
}
|
2007-12-23 14:23:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!takeall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (takeall || stricmp (name, "ammo") == 0)
|
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
2007-12-23 14:23:52 +00:00
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
PClass *type = PClassActor::AllActorClasses[i];
|
2007-12-23 14:23:52 +00:00
|
|
|
|
|
|
|
if (type->ParentClass == RUNTIME_CLASS (AAmmo))
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
AInventory *ammo = player->mo->FindInventory(static_cast<PClassActor *>(type));
|
2007-12-23 14:23:52 +00:00
|
|
|
|
|
|
|
if (ammo)
|
|
|
|
ammo->Amount = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!takeall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (takeall || stricmp (name, "armor") == 0)
|
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
2007-12-23 14:23:52 +00:00
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
type = PClassActor::AllActorClasses[i];
|
2007-12-23 14:23:52 +00:00
|
|
|
|
|
|
|
if (type->IsDescendantOf (RUNTIME_CLASS (AArmor)))
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
AActor *armor = player->mo->FindInventory(static_cast<PClassActor *>(type));
|
2007-12-23 14:23:52 +00:00
|
|
|
|
|
|
|
if (armor)
|
|
|
|
armor->Destroy ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!takeall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (takeall || stricmp (name, "keys") == 0)
|
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
2007-12-23 14:23:52 +00:00
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
type = PClassActor::AllActorClasses[i];
|
2007-12-23 14:23:52 +00:00
|
|
|
|
|
|
|
if (type->IsDescendantOf (RUNTIME_CLASS (AKey)))
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
AActor *key = player->mo->FindInventory(static_cast<PClassActor *>(type));
|
2007-12-23 14:23:52 +00:00
|
|
|
|
|
|
|
if (key)
|
|
|
|
key->Destroy ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!takeall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (takeall || stricmp (name, "weapons") == 0)
|
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
2007-12-23 14:23:52 +00:00
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
type = PClassActor::AllActorClasses[i];
|
2007-12-23 14:23:52 +00:00
|
|
|
|
|
|
|
if (type != RUNTIME_CLASS(AWeapon) &&
|
|
|
|
type->IsDescendantOf (RUNTIME_CLASS (AWeapon)))
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
AActor *weapon = player->mo->FindInventory(static_cast<PClassActor *>(type));
|
2007-12-23 14:23:52 +00:00
|
|
|
|
|
|
|
if (weapon)
|
|
|
|
weapon->Destroy ();
|
|
|
|
|
|
|
|
player->ReadyWeapon = NULL;
|
|
|
|
player->PendingWeapon = WP_NOCHANGE;
|
|
|
|
player->psprites[ps_weapon].state = NULL;
|
|
|
|
player->psprites[ps_flash].state = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!takeall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (takeall || stricmp (name, "artifacts") == 0)
|
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
2007-12-23 14:23:52 +00:00
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
type = PClassActor::AllActorClasses[i];
|
2007-12-23 14:23:52 +00:00
|
|
|
|
|
|
|
if (type->IsDescendantOf (RUNTIME_CLASS (AInventory)))
|
|
|
|
{
|
|
|
|
if (!type->IsDescendantOf (RUNTIME_CLASS (APuzzleItem)) &&
|
|
|
|
!type->IsDescendantOf (RUNTIME_CLASS (APowerup)) &&
|
|
|
|
!type->IsDescendantOf (RUNTIME_CLASS (AArmor)) &&
|
|
|
|
!type->IsDescendantOf (RUNTIME_CLASS (AWeapon)) &&
|
|
|
|
!type->IsDescendantOf (RUNTIME_CLASS (AKey)))
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
AActor *artifact = player->mo->FindInventory(static_cast<PClassActor *>(type));
|
2007-12-23 14:23:52 +00:00
|
|
|
|
|
|
|
if (artifact)
|
|
|
|
artifact->Destroy ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!takeall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (takeall || stricmp (name, "puzzlepieces") == 0)
|
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
2007-12-23 14:23:52 +00:00
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
type = PClassActor::AllActorClasses[i];
|
2007-12-23 14:23:52 +00:00
|
|
|
|
|
|
|
if (type->IsDescendantOf (RUNTIME_CLASS (APuzzleItem)))
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
AActor *puzzlepiece = player->mo->FindInventory(static_cast<PClassActor *>(type));
|
2007-12-23 14:23:52 +00:00
|
|
|
|
|
|
|
if (puzzlepiece)
|
|
|
|
puzzlepiece->Destroy ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!takeall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (takeall)
|
|
|
|
return;
|
|
|
|
|
|
|
|
type = PClass::FindClass (name);
|
|
|
|
if (type == NULL || !type->IsDescendantOf (RUNTIME_CLASS (AInventory)))
|
|
|
|
{
|
|
|
|
if (player == &players[consoleplayer])
|
|
|
|
Printf ("Unknown item \"%s\"\n", name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
AInventory *inventory = player->mo->FindInventory(static_cast<PClassActor *>(type));
|
2007-12-23 14:23:52 +00:00
|
|
|
|
|
|
|
if (inventory != NULL)
|
|
|
|
{
|
|
|
|
inventory->Amount -= amount ? amount : 1;
|
|
|
|
|
|
|
|
if (inventory->Amount <= 0)
|
|
|
|
{
|
|
|
|
if (inventory->ItemFlags & IF_KEEPDEPLETED)
|
|
|
|
{
|
|
|
|
inventory->Amount = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inventory->Destroy ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-30 03:24:57 +00:00
|
|
|
class DSuicider : public DThinker
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-08-30 03:24:57 +00:00
|
|
|
DECLARE_CLASS(DSuicider, DThinker)
|
|
|
|
HAS_OBJECT_POINTERS;
|
|
|
|
public:
|
|
|
|
TObjPtr<APlayerPawn> Pawn;
|
|
|
|
|
|
|
|
void Tick()
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-08-30 03:24:57 +00:00
|
|
|
Pawn->flags |= MF_SHOOTABLE;
|
|
|
|
Pawn->flags2 &= ~MF2_INVULNERABLE;
|
|
|
|
// Store the player's current damage factor, to restore it later.
|
|
|
|
fixed_t plyrdmgfact = Pawn->DamageFactor;
|
|
|
|
Pawn->DamageFactor = 65536;
|
|
|
|
P_DamageMobj (Pawn, Pawn, Pawn, TELEFRAG_DAMAGE, NAME_Suicide);
|
|
|
|
Pawn->DamageFactor = plyrdmgfact;
|
|
|
|
if (Pawn->health <= 0)
|
2010-03-24 02:49:37 +00:00
|
|
|
{
|
2012-08-30 03:24:57 +00:00
|
|
|
Pawn->flags &= ~MF_SHOOTABLE;
|
2010-03-24 02:49:37 +00:00
|
|
|
}
|
2012-08-30 03:24:57 +00:00
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
// You'll probably never be able to catch this in a save game, but
|
|
|
|
// just in case, add a proper serializer.
|
|
|
|
void Serialize(FArchive &arc)
|
|
|
|
{
|
|
|
|
Super::Serialize(arc);
|
|
|
|
arc << Pawn;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_POINTY_CLASS(DSuicider)
|
|
|
|
DECLARE_POINTER(Pawn)
|
|
|
|
END_POINTERS
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
void cht_Suicide (player_t *plyr)
|
|
|
|
{
|
2012-08-30 03:24:57 +00:00
|
|
|
// If this cheat was initiated by the suicide ccmd, and this is a single
|
|
|
|
// player game, the CHT_SUICIDE will be processed before the tic is run,
|
|
|
|
// so the console has not gone up yet. Use a temporary thinker to delay
|
|
|
|
// the suicide until the game ticks so that death noises can be heard on
|
|
|
|
// the initial tick.
|
2006-02-24 04:48:15 +00:00
|
|
|
if (plyr->mo != NULL)
|
|
|
|
{
|
2012-08-30 03:24:57 +00:00
|
|
|
DSuicider *suicide = new DSuicider;
|
|
|
|
suicide->Pawn = plyr->mo;
|
|
|
|
GC::WriteBarrier(suicide, suicide->Pawn);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCMD (mdk)
|
|
|
|
{
|
|
|
|
if (CheckCheatmode ())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Net_WriteByte (DEM_GENERICCHEAT);
|
|
|
|
Net_WriteByte (CHT_MDK);
|
|
|
|
}
|