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:
|
|
|
|
// Handling interactions (i.e., collisions).
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Data.
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "gstrings.h"
|
|
|
|
|
|
|
|
#include "doomstat.h"
|
|
|
|
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "announcer.h"
|
|
|
|
|
|
|
|
#include "am_map.h"
|
|
|
|
|
|
|
|
#include "c_console.h"
|
|
|
|
#include "c_dispatch.h"
|
|
|
|
|
|
|
|
#include "p_local.h"
|
|
|
|
|
|
|
|
#include "p_lnspec.h"
|
|
|
|
#include "p_effect.h"
|
|
|
|
#include "p_acs.h"
|
|
|
|
|
|
|
|
#include "b_bot.h" //Added by MC:
|
|
|
|
|
|
|
|
#include "ravenshared.h"
|
|
|
|
#include "a_hexenglobal.h"
|
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "a_pickups.h"
|
|
|
|
#include "gi.h"
|
|
|
|
#include "templates.h"
|
|
|
|
#include "sbar.h"
|
2007-05-10 22:22:38 +00:00
|
|
|
#include "s_sound.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "g_level.h"
|
|
|
|
#include "d_net.h"
|
2008-09-15 00:47:31 +00:00
|
|
|
#include "d_netinf.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_obituary ("Obituary");
|
|
|
|
static FRandom pr_botrespawn ("BotRespawn");
|
|
|
|
static FRandom pr_killmobj ("ActorDie");
|
2013-05-30 10:18:46 +00:00
|
|
|
FRandom pr_damagemobj ("ActorTakeDamage");
|
2006-02-24 04:48:15 +00:00
|
|
|
static FRandom pr_lightning ("LightningDamage");
|
|
|
|
static FRandom pr_poison ("PoisonDamage");
|
|
|
|
static FRandom pr_switcher ("SwitchTarget");
|
2013-02-07 21:02:26 +00:00
|
|
|
static FRandom pr_kickbackdir ("KickbackDir");
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
CVAR (Bool, cl_showsprees, true, CVAR_ARCHIVE)
|
|
|
|
CVAR (Bool, cl_showmultikills, true, CVAR_ARCHIVE)
|
2006-05-15 15:28:46 +00:00
|
|
|
EXTERN_CVAR (Bool, show_obituaries)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-10-31 14:53:21 +00:00
|
|
|
|
|
|
|
FName MeansOfDeath;
|
|
|
|
bool FriendlyFire;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// GET STUFF
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// P_TouchSpecialThing
|
|
|
|
//
|
|
|
|
void P_TouchSpecialThing (AActor *special, AActor *toucher)
|
|
|
|
{
|
|
|
|
fixed_t delta = special->z - toucher->z;
|
|
|
|
|
2012-08-10 02:17:16 +00:00
|
|
|
// The pickup is at or above the toucher's feet OR
|
|
|
|
// The pickup is below the toucher.
|
|
|
|
if (delta > toucher->height || delta < MIN(-32*FRACUNIT, -special->height))
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // out of reach
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dead thing touching.
|
|
|
|
// Can happen with a sliding player corpse.
|
|
|
|
if (toucher->health <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
//Added by MC: Finished with this destination.
|
2014-10-14 18:57:11 +00:00
|
|
|
if (toucher->player != NULL && toucher->player->Bot != NULL && special == toucher->player->Bot->dest)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-14 18:57:11 +00:00
|
|
|
toucher->player->Bot->prev = toucher->player->Bot->dest;
|
|
|
|
toucher->player->Bot->dest = NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
special->Touch (toucher);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// [RH]
|
|
|
|
// SexMessage: Replace parts of strings with gender-specific pronouns
|
|
|
|
//
|
|
|
|
// The following expansions are performed:
|
|
|
|
// %g -> he/she/it
|
|
|
|
// %h -> him/her/it
|
|
|
|
// %p -> his/her/its
|
|
|
|
// %o -> other (victim)
|
|
|
|
// %k -> killer
|
|
|
|
//
|
|
|
|
void SexMessage (const char *from, char *to, int gender, const char *victim, const char *killer)
|
|
|
|
{
|
|
|
|
static const char *genderstuff[3][3] =
|
|
|
|
{
|
|
|
|
{ "he", "him", "his" },
|
|
|
|
{ "she", "her", "her" },
|
|
|
|
{ "it", "it", "its" }
|
|
|
|
};
|
|
|
|
static const int gendershift[3][3] =
|
|
|
|
{
|
|
|
|
{ 2, 3, 3 },
|
|
|
|
{ 3, 3, 3 },
|
|
|
|
{ 2, 2, 3 }
|
|
|
|
};
|
|
|
|
const char *subst = NULL;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (*from != '%')
|
|
|
|
{
|
|
|
|
*to++ = *from;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int gendermsg = -1;
|
|
|
|
|
|
|
|
switch (from[1])
|
|
|
|
{
|
|
|
|
case 'g': gendermsg = 0; break;
|
|
|
|
case 'h': gendermsg = 1; break;
|
|
|
|
case 'p': gendermsg = 2; break;
|
|
|
|
case 'o': subst = victim; break;
|
|
|
|
case 'k': subst = killer; break;
|
|
|
|
}
|
|
|
|
if (subst != NULL)
|
|
|
|
{
|
|
|
|
size_t len = strlen (subst);
|
|
|
|
memcpy (to, subst, len);
|
|
|
|
to += len;
|
|
|
|
from++;
|
|
|
|
subst = NULL;
|
|
|
|
}
|
|
|
|
else if (gendermsg < 0)
|
|
|
|
{
|
|
|
|
*to++ = '%';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy (to, genderstuff[gender][gendermsg]);
|
|
|
|
to += gendershift[gender][gendermsg];
|
|
|
|
from++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (*from++);
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH]
|
|
|
|
// ClientObituary: Show a message when a player dies
|
|
|
|
//
|
2012-05-13 07:54:44 +00:00
|
|
|
void ClientObituary (AActor *self, AActor *inflictor, AActor *attacker, int dmgflags)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
FName mod;
|
2006-02-24 04:48:15 +00:00
|
|
|
const char *message;
|
|
|
|
const char *messagename;
|
|
|
|
char gendermessage[1024];
|
2006-10-31 14:53:21 +00:00
|
|
|
bool friendly;
|
2006-02-24 04:48:15 +00:00
|
|
|
int gender;
|
|
|
|
|
2006-05-15 15:28:46 +00:00
|
|
|
// No obituaries for non-players, voodoo dolls or when not wanted
|
|
|
|
if (self->player == NULL || self->player->mo != self || !show_obituaries)
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
|
2013-05-12 18:27:03 +00:00
|
|
|
gender = self->player->userinfo.GetGender();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Treat voodoo dolls as unknown deaths
|
2012-04-19 04:03:42 +00:00
|
|
|
if (inflictor && inflictor->player && inflictor->player->mo != inflictor)
|
2006-10-31 14:53:21 +00:00
|
|
|
MeansOfDeath = NAME_None;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (multiplayer && !deathmatch)
|
2006-10-31 14:53:21 +00:00
|
|
|
FriendlyFire = true;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-10-31 14:53:21 +00:00
|
|
|
friendly = FriendlyFire;
|
|
|
|
mod = MeansOfDeath;
|
2006-02-24 04:48:15 +00:00
|
|
|
message = NULL;
|
|
|
|
messagename = NULL;
|
|
|
|
|
|
|
|
if (attacker == NULL || attacker->player != NULL)
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
if (mod == NAME_Telefrag)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (AnnounceTelefrag (attacker, self))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (AnnounceKill (attacker, self))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mod)
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
case NAME_Suicide: messagename = "OB_SUICIDE"; break;
|
|
|
|
case NAME_Falling: messagename = "OB_FALLING"; break;
|
|
|
|
case NAME_Crush: messagename = "OB_CRUSH"; break;
|
|
|
|
case NAME_Exit: messagename = "OB_EXIT"; break;
|
2007-01-28 04:59:04 +00:00
|
|
|
case NAME_Drowning: messagename = "OB_WATER"; break;
|
2006-10-31 14:53:21 +00:00
|
|
|
case NAME_Slime: messagename = "OB_SLIME"; break;
|
|
|
|
case NAME_Fire: if (attacker == NULL) messagename = "OB_LAVA"; break;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 04:03:42 +00:00
|
|
|
// Check for being killed by a voodoo doll.
|
|
|
|
if (inflictor && inflictor->player && inflictor->player->mo != inflictor)
|
|
|
|
{
|
|
|
|
messagename = "OB_VOODOO";
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (messagename != NULL)
|
|
|
|
message = GStrings(messagename);
|
|
|
|
|
|
|
|
if (attacker != NULL && message == NULL)
|
|
|
|
{
|
|
|
|
if (attacker == self)
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
message = GStrings("OB_KILLEDSELF");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (attacker->player == NULL)
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
if (mod == NAME_Telefrag)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
message = GStrings("OB_MONTELEFRAG");
|
|
|
|
}
|
2006-10-31 14:53:21 +00:00
|
|
|
else if (mod == NAME_Melee)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
message = attacker->GetClass()->Meta.GetMetaString (AMETA_HitObituary);
|
|
|
|
if (message == NULL)
|
|
|
|
{
|
|
|
|
message = attacker->GetClass()->Meta.GetMetaString (AMETA_Obituary);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message = attacker->GetClass()->Meta.GetMetaString (AMETA_Obituary);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-17 20:29:41 +00:00
|
|
|
if (message == NULL && attacker != NULL && attacker->player != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (friendly)
|
|
|
|
{
|
|
|
|
attacker->player->fragcount -= 2;
|
|
|
|
attacker->player->frags[attacker->player - players]++;
|
|
|
|
self = attacker;
|
2013-05-12 18:27:03 +00:00
|
|
|
gender = self->player->userinfo.GetGender();
|
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 (gendermessage, countof(gendermessage), "OB_FRIENDLY%c", '1' + (pr_obituary() & 3));
|
2006-02-24 04:48:15 +00:00
|
|
|
message = GStrings(gendermessage);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
if (mod == NAME_Telefrag) message = GStrings("OB_MPTELEFRAG");
|
2006-02-24 04:48:15 +00:00
|
|
|
if (message == NULL)
|
|
|
|
{
|
2006-09-28 07:37:19 +00:00
|
|
|
if (inflictor != NULL)
|
|
|
|
{
|
|
|
|
message = inflictor->GetClass()->Meta.GetMetaString (AMETA_Obituary);
|
|
|
|
}
|
2012-05-13 07:54:44 +00:00
|
|
|
if (message == NULL && (dmgflags & DMG_PLAYERATTACK) && attacker->player->ReadyWeapon != NULL)
|
2006-09-28 07:37:19 +00:00
|
|
|
{
|
|
|
|
message = attacker->player->ReadyWeapon->GetClass()->Meta.GetMetaString (AMETA_Obituary);
|
|
|
|
}
|
|
|
|
if (message == NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-09-28 07:37:19 +00:00
|
|
|
switch (mod)
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
case NAME_BFGSplash: messagename = "OB_MPBFG_SPLASH"; break;
|
|
|
|
case NAME_Railgun: messagename = "OB_RAILGUN"; break;
|
2006-09-28 07:37:19 +00:00
|
|
|
}
|
|
|
|
if (messagename != NULL)
|
|
|
|
message = GStrings(messagename);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2012-05-13 01:06:28 +00:00
|
|
|
if (message == NULL)
|
|
|
|
{
|
|
|
|
message = attacker->GetClass()->Meta.GetMetaString (AMETA_Obituary);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-06-21 12:10:36 +00:00
|
|
|
else attacker = self; // for the message creation
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-06-17 20:29:41 +00:00
|
|
|
if (message != NULL && message[0] == '$')
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-05-13 01:06:28 +00:00
|
|
|
message = GStrings[message+1];
|
2006-06-17 20:29:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
{
|
|
|
|
message = GStrings("OB_DEFAULT");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2014-06-12 03:30:25 +00:00
|
|
|
// [CK] Don't display empty strings
|
|
|
|
if (message == NULL || strlen(message) <= 0)
|
|
|
|
return;
|
|
|
|
|
2006-06-17 20:29:41 +00:00
|
|
|
SexMessage (message, gendermessage, gender,
|
2013-05-12 18:27:03 +00:00
|
|
|
self->player->userinfo.GetName(), attacker->player->userinfo.GetName());
|
2006-02-24 04:48:15 +00:00
|
|
|
Printf (PRINT_MEDIUM, "%s\n", gendermessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// KillMobj
|
|
|
|
//
|
|
|
|
EXTERN_CVAR (Int, fraglimit)
|
|
|
|
|
2012-05-13 07:54:44 +00:00
|
|
|
void AActor::Die (AActor *source, AActor *inflictor, int dmgflags)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-05-22 19:35:38 +00:00
|
|
|
// Handle possible unmorph on death
|
2010-09-19 10:39:34 +00:00
|
|
|
bool wasgibbed = (health < GibHealth());
|
2009-07-04 18:17:44 +00:00
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
AActor *realthis = NULL;
|
|
|
|
int realstyle = 0;
|
|
|
|
int realhealth = 0;
|
|
|
|
if (P_MorphedDeath(this, &realthis, &realstyle, &realhealth))
|
|
|
|
{
|
|
|
|
if (!(realstyle & MORPH_UNDOBYDEATHSAVES))
|
|
|
|
{
|
|
|
|
if (wasgibbed)
|
|
|
|
{
|
2010-09-19 10:39:34 +00:00
|
|
|
int realgibhealth = realthis->GibHealth();
|
2008-05-22 19:35:38 +00:00
|
|
|
if (realthis->health >= realgibhealth)
|
|
|
|
{
|
2013-04-17 01:32:40 +00:00
|
|
|
realthis->health = realgibhealth -1; // if morphed was gibbed, so must original be (where allowed)l
|
2008-05-22 19:35:38 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-13 07:54:44 +00:00
|
|
|
realthis->Die(source, inflictor, dmgflags);
|
2008-05-22 19:35:38 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// [SO] 9/2/02 -- It's rather funny to see an exploded player body with the invuln sparkle active :)
|
|
|
|
effects &= ~FX_RESPAWNINVUL;
|
|
|
|
//flags &= ~MF_INVINCIBLE;
|
|
|
|
|
|
|
|
if (debugfile && this->player)
|
|
|
|
{
|
2015-02-08 09:03:49 +00:00
|
|
|
static int dieticks[MAXPLAYERS]; // [ZzZombo] not used? Except if for peeking in debugger...
|
2008-09-14 23:54:38 +00:00
|
|
|
int pnum = int(this->player-players);
|
2006-02-24 04:48:15 +00:00
|
|
|
dieticks[pnum] = gametic;
|
|
|
|
fprintf (debugfile, "died (%d) on tic %d (%s)\n", pnum, gametic,
|
|
|
|
this->player->cheats&CF_PREDICTING?"predicting":"real");
|
|
|
|
}
|
2006-06-18 04:10:47 +00:00
|
|
|
|
|
|
|
// [RH] Notify this actor's items.
|
|
|
|
for (AInventory *item = Inventory; item != NULL; )
|
|
|
|
{
|
|
|
|
AInventory *next = item->Inventory;
|
|
|
|
item->OwnerDied();
|
|
|
|
item = next;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (flags & MF_MISSILE)
|
|
|
|
{ // [RH] When missiles die, they just explode
|
2006-10-22 10:32:41 +00:00
|
|
|
P_ExplodeMissile (this, NULL, NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// [RH] Set the target to the thing that killed it. Strife apparently does this.
|
|
|
|
if (source != NULL)
|
|
|
|
{
|
|
|
|
target = source;
|
|
|
|
}
|
|
|
|
|
|
|
|
flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SKULLFLY);
|
|
|
|
if (!(flags4 & MF4_DONTFALL)) flags&=~MF_NOGRAVITY;
|
|
|
|
flags |= MF_DROPOFF;
|
2008-06-28 12:24:15 +00:00
|
|
|
if ((flags3 & MF3_ISMONSTER) || FindState(NAME_Raise) != NULL || IsKindOf(RUNTIME_CLASS(APlayerPawn)))
|
2006-04-11 16:27:41 +00:00
|
|
|
{ // [RH] Only monsters get to be corpses.
|
|
|
|
// Objects with a raise state should get the flag as well so they can
|
|
|
|
// be revived by an Arch-Vile. Batman Doom needs this.
|
2011-05-26 23:27:58 +00:00
|
|
|
// [RC] And disable this if DONTCORPSE is set, of course.
|
|
|
|
if(!(flags6 & MF6_DONTCORPSE)) flags |= MF_CORPSE;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2009-12-25 11:09:56 +00:00
|
|
|
flags6 |= MF6_KILLED;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// [RH] Allow the death height to be overridden using metadata.
|
|
|
|
fixed_t metaheight = 0;
|
2006-10-31 14:53:21 +00:00
|
|
|
if (DamageType == NAME_Fire)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
metaheight = GetClass()->Meta.GetMetaFixed (AMETA_BurnHeight);
|
|
|
|
}
|
|
|
|
if (metaheight == 0)
|
|
|
|
{
|
|
|
|
metaheight = GetClass()->Meta.GetMetaFixed (AMETA_DeathHeight);
|
|
|
|
}
|
|
|
|
if (metaheight != 0)
|
|
|
|
{
|
|
|
|
height = MAX<fixed_t> (metaheight, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
height >>= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] If the thing has a special, execute and remove it
|
|
|
|
// Note that the thing that killed it is considered
|
|
|
|
// the activator of the script.
|
|
|
|
// New: In Hexen, the thing that died is the activator,
|
|
|
|
// so now a level flag selects who the activator gets to be.
|
2009-10-09 20:35:07 +00:00
|
|
|
// Everything is now moved to P_ActivateThingSpecial().
|
|
|
|
if (special && (!(flags & MF_SPECIAL) || (flags3 & MF3_ISMONSTER))
|
|
|
|
&& !(activationtype & THINGSPEC_NoDeathSpecial))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-10-09 20:35:07 +00:00
|
|
|
P_ActivateThingSpecial(this, source, true);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-07-14 08:04:17 +00:00
|
|
|
if (CountsAsKill())
|
|
|
|
level.killed_monsters++;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (source && source->player)
|
|
|
|
{
|
2006-04-16 13:29:50 +00:00
|
|
|
if (CountsAsKill())
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // count for intermission
|
|
|
|
source->player->killcount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't count any frags at level start, because they're just telefrags
|
|
|
|
// resulting from insufficient deathmatch starts, and it wouldn't be
|
|
|
|
// fair to count them toward a player's score.
|
|
|
|
if (player && level.maptime)
|
|
|
|
{
|
|
|
|
source->player->frags[player - players]++;
|
|
|
|
if (player == source->player) // [RH] Cumulative frag count
|
|
|
|
{
|
|
|
|
char buff[256];
|
|
|
|
|
|
|
|
player->fragcount--;
|
|
|
|
if (deathmatch && player->spreecount >= 5 && cl_showsprees)
|
|
|
|
{
|
|
|
|
SexMessage (GStrings("SPREEKILLSELF"), buff,
|
2013-05-12 18:27:03 +00:00
|
|
|
player->userinfo.GetGender(), player->userinfo.GetName(),
|
|
|
|
player->userinfo.GetName());
|
2008-11-27 17:43:36 +00:00
|
|
|
StatusBar->AttachMessage (new DHUDMessageFadeOut (SmallFont, buff,
|
2006-02-24 04:48:15 +00:00
|
|
|
1.5f, 0.2f, 0, 0, CR_WHITE, 3.f, 0.5f), MAKE_ID('K','S','P','R'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-23 17:45:53 +00:00
|
|
|
if ((dmflags2 & DF2_YES_LOSEFRAG) && deathmatch)
|
|
|
|
player->fragcount--;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
++source->player->fragcount;
|
|
|
|
++source->player->spreecount;
|
|
|
|
if (source->player->morphTics)
|
|
|
|
{ // Make a super chicken
|
|
|
|
source->GiveInventoryType (RUNTIME_CLASS(APowerWeaponLevel2));
|
|
|
|
}
|
|
|
|
if (deathmatch && cl_showsprees)
|
|
|
|
{
|
|
|
|
const char *spreemsg;
|
|
|
|
char buff[256];
|
|
|
|
|
|
|
|
switch (source->player->spreecount)
|
|
|
|
{
|
|
|
|
case 5:
|
|
|
|
spreemsg = GStrings("SPREE5");
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
spreemsg = GStrings("SPREE10");
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
spreemsg = GStrings("SPREE15");
|
|
|
|
break;
|
|
|
|
case 20:
|
|
|
|
spreemsg = GStrings("SPREE20");
|
|
|
|
break;
|
|
|
|
case 25:
|
|
|
|
spreemsg = GStrings("SPREE25");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
spreemsg = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (spreemsg == NULL && player->spreecount >= 5)
|
|
|
|
{
|
|
|
|
if (!AnnounceSpreeLoss (this))
|
|
|
|
{
|
2013-05-12 18:27:03 +00:00
|
|
|
SexMessage (GStrings("SPREEOVER"), buff, player->userinfo.GetGender(),
|
|
|
|
player->userinfo.GetName(), source->player->userinfo.GetName());
|
2008-11-27 17:43:36 +00:00
|
|
|
StatusBar->AttachMessage (new DHUDMessageFadeOut (SmallFont, buff,
|
2006-02-24 04:48:15 +00:00
|
|
|
1.5f, 0.2f, 0, 0, CR_WHITE, 3.f, 0.5f), MAKE_ID('K','S','P','R'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (spreemsg != NULL)
|
|
|
|
{
|
|
|
|
if (!AnnounceSpree (source))
|
|
|
|
{
|
2013-05-12 18:27:03 +00:00
|
|
|
SexMessage (spreemsg, buff, player->userinfo.GetGender(),
|
|
|
|
player->userinfo.GetName(), source->player->userinfo.GetName());
|
2008-11-27 17:43:36 +00:00
|
|
|
StatusBar->AttachMessage (new DHUDMessageFadeOut (SmallFont, buff,
|
2006-02-24 04:48:15 +00:00
|
|
|
1.5f, 0.2f, 0, 0, CR_WHITE, 3.f, 0.5f), MAKE_ID('K','S','P','R'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] Multikills
|
2012-05-08 12:27:01 +00:00
|
|
|
if (player != source->player)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-05-08 12:27:01 +00:00
|
|
|
source->player->multicount++;
|
|
|
|
if (source->player->lastkilltime > 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-05-08 12:27:01 +00:00
|
|
|
if (source->player->lastkilltime < level.time - 3*TICRATE)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-05-08 12:27:01 +00:00
|
|
|
source->player->multicount = 1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2012-05-08 12:27:01 +00:00
|
|
|
|
|
|
|
if (deathmatch &&
|
|
|
|
source->CheckLocalView (consoleplayer) &&
|
|
|
|
cl_showmultikills)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-05-08 12:27:01 +00:00
|
|
|
const char *multimsg;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2012-05-08 12:27:01 +00:00
|
|
|
switch (source->player->multicount)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-05-08 12:27:01 +00:00
|
|
|
case 1:
|
|
|
|
multimsg = NULL;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
multimsg = GStrings("MULTI2");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
multimsg = GStrings("MULTI3");
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
multimsg = GStrings("MULTI4");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
multimsg = GStrings("MULTI5");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (multimsg != NULL)
|
|
|
|
{
|
|
|
|
char buff[256];
|
|
|
|
|
|
|
|
if (!AnnounceMultikill (source))
|
|
|
|
{
|
2013-05-12 18:27:03 +00:00
|
|
|
SexMessage (multimsg, buff, player->userinfo.GetGender(),
|
|
|
|
player->userinfo.GetName(), source->player->userinfo.GetName());
|
2012-05-08 12:27:01 +00:00
|
|
|
StatusBar->AttachMessage (new DHUDMessageFadeOut (SmallFont, buff,
|
|
|
|
1.5f, 0.8f, 0, 0, CR_RED, 3.f, 0.5f), MAKE_ID('M','K','I','L'));
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-05-08 12:27:01 +00:00
|
|
|
source->player->lastkilltime = level.time;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] Implement fraglimit
|
|
|
|
if (deathmatch && fraglimit &&
|
2007-12-15 03:51:17 +00:00
|
|
|
fraglimit <= D_GetFragCount (source->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
Printf ("%s\n", GStrings("TXT_FRAGLIMIT"));
|
|
|
|
G_ExitLevel (0, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-16 13:29:50 +00:00
|
|
|
else if (!multiplayer && CountsAsKill())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// count all monster deaths,
|
|
|
|
// even those caused by other monsters
|
|
|
|
players[0].killcount++;
|
|
|
|
}
|
2014-10-13 17:40:25 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (player)
|
|
|
|
{
|
|
|
|
// [RH] Death messages
|
2012-05-13 07:54:44 +00:00
|
|
|
ClientObituary (this, inflictor, source, dmgflags);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Death script execution, care of Skull Tag
|
|
|
|
FBehavior::StaticStartTypedScripts (SCRIPT_Death, this, true);
|
|
|
|
|
|
|
|
// [RH] Force a delay between death and respawn
|
|
|
|
player->respawn_time = level.time + TICRATE;
|
|
|
|
|
|
|
|
//Added by MC: Respawn bots
|
2014-11-08 17:38:09 +00:00
|
|
|
if (bglobal.botnum && !demoplayback)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-14 18:57:11 +00:00
|
|
|
if (player->Bot != NULL)
|
|
|
|
player->Bot->t_respawn = (pr_botrespawn()%15)+((bglobal.botnum-1)*2)+TICRATE+1;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//Added by MC: Discard enemies.
|
|
|
|
for (int i = 0; i < MAXPLAYERS; i++)
|
|
|
|
{
|
2014-10-14 18:57:11 +00:00
|
|
|
if (players[i].Bot != NULL && this == players[i].Bot->enemy)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-14 18:57:11 +00:00
|
|
|
if (players[i].Bot->dest == players[i].Bot->enemy)
|
|
|
|
players[i].Bot->dest = NULL;
|
|
|
|
players[i].Bot->enemy = NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
player->spreecount = 0;
|
|
|
|
player->multicount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// count environment kills against you
|
|
|
|
if (!source)
|
|
|
|
{
|
|
|
|
player->frags[player - players]++;
|
|
|
|
player->fragcount--; // [RH] Cumulative frag count
|
|
|
|
}
|
|
|
|
|
|
|
|
flags &= ~MF_SOLID;
|
|
|
|
player->playerstate = PST_DEAD;
|
|
|
|
P_DropWeapon (player);
|
|
|
|
if (this == players[consoleplayer].camera && automapactive)
|
|
|
|
{
|
|
|
|
// don't die in auto map, switch view prior to dying
|
|
|
|
AM_Stop ();
|
|
|
|
}
|
|
|
|
|
|
|
|
// [GRB] Clear extralight. When you killed yourself with weapon that
|
|
|
|
// called A_Light1/2 before it called A_Light0, extraligh remained.
|
|
|
|
player->extralight = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] If this is the unmorphed version of another monster, destroy this
|
|
|
|
// actor, because the morphed version is the one that will stick around in
|
|
|
|
// the level.
|
|
|
|
if (flags & MF_UNMORPHED)
|
|
|
|
{
|
|
|
|
Destroy ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-31 14:53:21 +00:00
|
|
|
|
|
|
|
|
2008-03-04 00:56:22 +00:00
|
|
|
FState *diestate = NULL;
|
2013-07-01 09:02:35 +00:00
|
|
|
int gibhealth = GibHealth();
|
2013-07-02 20:01:54 +00:00
|
|
|
int iflags4 = inflictor == NULL ? 0 : inflictor->flags4;
|
|
|
|
bool extremelydead = ((health < gibhealth || iflags4 & MF4_EXTREMEDEATH) && !(iflags4 & MF4_NOEXTREMEDEATH));
|
2013-07-01 09:02:35 +00:00
|
|
|
|
|
|
|
// Special check for 'extreme' damage type to ensure that it gets recorded properly as an extreme death for subsequent checks.
|
|
|
|
if (DamageType == NAME_Extreme)
|
|
|
|
{
|
|
|
|
extremelydead = true;
|
|
|
|
DamageType = NAME_None;
|
|
|
|
}
|
|
|
|
|
|
|
|
// find the appropriate death state. The order is:
|
|
|
|
//
|
|
|
|
// 1. If damagetype is not 'none' and death is extreme, try a damage type specific extreme death state
|
|
|
|
// 2. If no such state is found or death is not extreme try a damage type specific normal death state
|
|
|
|
// 3. If damagetype is 'ice' and actor is a monster or player, try the generic freeze death (unless prohibited)
|
|
|
|
// 4. If no state has been found and death is extreme, try the extreme death state
|
|
|
|
// 5. If no such state is found or death is not extreme try the regular death state.
|
|
|
|
// 6. If still no state has been found, destroy the actor immediately.
|
2006-10-31 14:53:21 +00:00
|
|
|
|
2013-06-24 13:40:17 +00:00
|
|
|
if (DamageType != NAME_None)
|
2006-10-31 14:53:21 +00:00
|
|
|
{
|
2013-07-01 09:02:35 +00:00
|
|
|
if (extremelydead)
|
|
|
|
{
|
|
|
|
FName labels[] = { NAME_Death, NAME_Extreme, DamageType };
|
|
|
|
diestate = FindState(3, labels, true);
|
|
|
|
}
|
|
|
|
if (diestate == NULL)
|
|
|
|
{
|
|
|
|
diestate = FindState (NAME_Death, DamageType, true);
|
|
|
|
if (diestate != NULL) extremelydead = false;
|
|
|
|
}
|
2006-10-31 14:53:21 +00:00
|
|
|
if (diestate == NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2013-06-24 13:40:17 +00:00
|
|
|
if (DamageType == NAME_Ice)
|
2006-10-31 14:53:21 +00:00
|
|
|
{ // If an actor doesn't have an ice death, we can still give them a generic one.
|
|
|
|
|
|
|
|
if (!deh.NoAutofreeze && !(flags4 & MF4_NOICEDEATH) && (player || (flags3 & MF3_ISMONSTER)))
|
|
|
|
{
|
2008-08-10 14:19:47 +00:00
|
|
|
diestate = FindState(NAME_GenericFreezeDeath);
|
2013-07-01 09:02:35 +00:00
|
|
|
extremelydead = false;
|
2006-10-31 14:53:21 +00:00
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2006-10-31 14:53:21 +00:00
|
|
|
if (diestate == NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
|
2008-03-04 00:56:22 +00:00
|
|
|
// Don't pass on a damage type this actor cannot handle.
|
|
|
|
// (most importantly, prevent barrels from passing on ice damage.)
|
2006-10-31 15:24:22 +00:00
|
|
|
// Massacre must be preserved though.
|
2013-06-24 13:40:17 +00:00
|
|
|
if (DamageType != NAME_Massacre)
|
2008-03-04 00:56:22 +00:00
|
|
|
{
|
2013-06-24 13:40:17 +00:00
|
|
|
DamageType = NAME_None;
|
2008-03-04 00:56:22 +00:00
|
|
|
}
|
2006-10-31 15:24:22 +00:00
|
|
|
|
2013-07-01 09:02:35 +00:00
|
|
|
if (extremelydead)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Extreme death
|
2006-12-16 14:06:21 +00:00
|
|
|
diestate = FindState (NAME_Death, NAME_Extreme, true);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-11-29 10:03:35 +00:00
|
|
|
if (diestate == NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Normal death
|
2013-07-01 09:02:35 +00:00
|
|
|
extremelydead = false;
|
2006-10-31 14:53:21 +00:00
|
|
|
diestate = FindState (NAME_Death);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-01 09:02:35 +00:00
|
|
|
if (extremelydead)
|
|
|
|
{
|
|
|
|
// We'll only get here if an actual extreme death state was used.
|
|
|
|
|
|
|
|
// For players, mark the appropriate flag.
|
|
|
|
if (player != NULL)
|
|
|
|
{
|
|
|
|
player->cheats |= CF_EXTREMELYDEAD;
|
|
|
|
}
|
|
|
|
// If a non-player, mark as extremely dead for the crash state.
|
|
|
|
else if (health >= gibhealth)
|
|
|
|
{
|
|
|
|
health = gibhealth - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-31 14:53:21 +00:00
|
|
|
if (diestate != NULL)
|
|
|
|
{
|
|
|
|
SetState (diestate);
|
|
|
|
|
2013-07-30 14:52:36 +00:00
|
|
|
if (tics > 1)
|
|
|
|
{
|
|
|
|
tics -= pr_killmobj() & 3;
|
|
|
|
if (tics < 1)
|
|
|
|
tics = 1;
|
|
|
|
}
|
2006-10-31 14:53:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Destroy();
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// PROC P_AutoUseHealth
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2009-02-28 21:38:20 +00:00
|
|
|
static int CountHealth(TArray<AInventory *> &Items)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-02-28 21:38:20 +00:00
|
|
|
int counted = 0;
|
|
|
|
for(unsigned i = 0; i < Items.Size(); i++)
|
|
|
|
{
|
|
|
|
counted += Items[i]->Amount * Items[i]->health;
|
|
|
|
}
|
|
|
|
return counted;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-02-28 21:38:20 +00:00
|
|
|
static int UseHealthItems(TArray<AInventory *> &Items, int &saveHealth)
|
|
|
|
{
|
|
|
|
int saved = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-02-28 21:38:20 +00:00
|
|
|
while (Items.Size() > 0 && saveHealth > 0)
|
|
|
|
{
|
|
|
|
int maxhealth = 0;
|
|
|
|
int index = -1;
|
2007-10-29 22:15:46 +00:00
|
|
|
|
2009-02-28 21:38:20 +00:00
|
|
|
// Find the largest item in the list
|
|
|
|
for(unsigned i = 0; i < Items.Size(); i++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-02-28 21:38:20 +00:00
|
|
|
if (Items[i]->health > maxhealth)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-02-28 21:38:20 +00:00
|
|
|
index = i;
|
2009-04-03 01:25:06 +00:00
|
|
|
maxhealth = Items[i]->health;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-28 21:38:20 +00:00
|
|
|
|
2009-04-03 01:25:06 +00:00
|
|
|
// Now apply the health items, using the same logic as Heretic and Hexen.
|
2009-02-28 21:38:20 +00:00
|
|
|
int count = (saveHealth + maxhealth-1) / maxhealth;
|
|
|
|
for(int i = 0; i < count; i++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-02-28 21:38:20 +00:00
|
|
|
saved += maxhealth;
|
|
|
|
saveHealth -= maxhealth;
|
|
|
|
if (--Items[index]->Amount == 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-02-28 21:38:20 +00:00
|
|
|
if (!(Items[index]->ItemFlags & IF_KEEPDEPLETED))
|
|
|
|
{
|
|
|
|
Items[index]->Destroy ();
|
|
|
|
}
|
|
|
|
Items.Delete(index);
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-28 21:38:20 +00:00
|
|
|
return saved;
|
|
|
|
}
|
|
|
|
|
|
|
|
void P_AutoUseHealth(player_t *player, int saveHealth)
|
|
|
|
{
|
|
|
|
TArray<AInventory *> NormalHealthItems;
|
|
|
|
TArray<AInventory *> LargeHealthItems;
|
|
|
|
|
|
|
|
for(AInventory *inv = player->mo->Inventory; inv != NULL; inv = inv->Inventory)
|
|
|
|
{
|
|
|
|
if (inv->Amount > 0 && inv->IsKindOf(RUNTIME_CLASS(AHealthPickup)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-02-28 21:38:20 +00:00
|
|
|
int mode = static_cast<AHealthPickup*>(inv)->autousemode;
|
|
|
|
|
2009-03-26 02:06:14 +00:00
|
|
|
if (mode == 1) NormalHealthItems.Push(inv);
|
|
|
|
else if (mode == 2) LargeHealthItems.Push(inv);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-28 21:38:20 +00:00
|
|
|
|
|
|
|
int normalhealth = CountHealth(NormalHealthItems);
|
|
|
|
int largehealth = CountHealth(LargeHealthItems);
|
|
|
|
|
|
|
|
bool skilluse = !!G_SkillProperty(SKILLP_AutoUseHealth);
|
|
|
|
|
|
|
|
if (skilluse && normalhealth >= saveHealth)
|
|
|
|
{ // Use quartz flasks
|
|
|
|
player->health += UseHealthItems(NormalHealthItems, saveHealth);
|
|
|
|
}
|
|
|
|
else if (largehealth >= saveHealth)
|
|
|
|
{
|
|
|
|
// Use mystic urns
|
|
|
|
player->health += UseHealthItems(LargeHealthItems, saveHealth);
|
|
|
|
}
|
|
|
|
else if (skilluse && normalhealth + largehealth >= saveHealth)
|
|
|
|
{ // Use mystic urns and quartz flasks
|
|
|
|
player->health += UseHealthItems(NormalHealthItems, saveHealth);
|
|
|
|
if (saveHealth > 0) player->health += UseHealthItems(LargeHealthItems, saveHealth);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
player->mo->health = player->health;
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// P_AutoUseStrifeHealth
|
|
|
|
//
|
|
|
|
//============================================================================
|
2009-02-28 21:38:20 +00:00
|
|
|
CVAR(Bool, sv_disableautohealth, false, CVAR_ARCHIVE|CVAR_SERVERINFO)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void P_AutoUseStrifeHealth (player_t *player)
|
|
|
|
{
|
2009-02-28 21:38:20 +00:00
|
|
|
TArray<AInventory *> Items;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-02-28 21:38:20 +00:00
|
|
|
for(AInventory *inv = player->mo->Inventory; inv != NULL; inv = inv->Inventory)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-02-28 21:38:20 +00:00
|
|
|
if (inv->Amount > 0 && inv->IsKindOf(RUNTIME_CLASS(AHealthPickup)))
|
|
|
|
{
|
|
|
|
int mode = static_cast<AHealthPickup*>(inv)->autousemode;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-02-28 21:38:20 +00:00
|
|
|
if (mode == 3) Items.Push(inv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sv_disableautohealth)
|
|
|
|
{
|
|
|
|
while (Items.Size() > 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-02-28 21:38:20 +00:00
|
|
|
int maxhealth = 0;
|
|
|
|
int index = -1;
|
|
|
|
|
|
|
|
// Find the largest item in the list
|
|
|
|
for(unsigned i = 0; i < Items.Size(); i++)
|
|
|
|
{
|
|
|
|
if (Items[i]->health > maxhealth)
|
|
|
|
{
|
|
|
|
index = i;
|
|
|
|
maxhealth = Items[i]->Amount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (player->health < 50)
|
|
|
|
{
|
|
|
|
if (!player->mo->UseInventory (Items[index]))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (player->health >= 50) return;
|
|
|
|
// Using all of this item was not enough so delete it and restart with the next best one
|
|
|
|
Items.Delete(index);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
=
|
|
|
|
= P_DamageMobj
|
|
|
|
=
|
|
|
|
= Damages both enemies and players
|
|
|
|
= inflictor is the thing that caused the damage
|
|
|
|
= creature or missile, can be NULL (slime, etc)
|
|
|
|
= source is the thing to target after taking damage
|
|
|
|
= creature or NULL
|
|
|
|
= Source and inflictor are the same for melee attacks
|
|
|
|
= source can be null for barrel explosions and other environmental stuff
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
|
2012-05-13 08:04:58 +00:00
|
|
|
static inline bool MustForcePain(AActor *target, AActor *inflictor)
|
|
|
|
{
|
|
|
|
return (!(target->flags5 & MF5_NOPAIN) && inflictor != NULL &&
|
|
|
|
(inflictor->flags6 & MF6_FORCEPAIN) && !(inflictor->flags5 & MF5_PAINLESS));
|
|
|
|
}
|
|
|
|
|
2015-03-25 19:19:50 +00:00
|
|
|
static inline bool isFakePain(AActor *target, AActor *inflictor, int damage)
|
2014-11-25 00:30:17 +00:00
|
|
|
{
|
2015-03-25 19:19:50 +00:00
|
|
|
return ((target->flags7 & MF7_ALLOWPAIN && damage > 0) || ((inflictor != NULL) && (inflictor->flags7 & MF7_CAUSEPAIN)));
|
2014-11-25 00:30:17 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2013-01-02 04:39:59 +00:00
|
|
|
// Returns the amount of damage actually inflicted upon the target, or -1 if
|
|
|
|
// the damage was cancelled.
|
|
|
|
int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, FName mod, int flags)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
unsigned ang;
|
2009-05-26 22:33:02 +00:00
|
|
|
player_t *player = NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
fixed_t thrust;
|
|
|
|
int temp;
|
2009-06-07 17:04:40 +00:00
|
|
|
int painchance = 0;
|
|
|
|
FState * woundstate = NULL;
|
|
|
|
PainChanceList * pc = NULL;
|
2009-09-16 15:54:04 +00:00
|
|
|
bool justhit = false;
|
2014-11-01 05:00:29 +00:00
|
|
|
bool plrDontThrust = false;
|
|
|
|
bool invulpain = false;
|
2014-11-25 00:30:17 +00:00
|
|
|
bool fakedPain = false;
|
|
|
|
bool forcedPain = false;
|
2014-11-01 05:00:29 +00:00
|
|
|
int fakeDamage = 0;
|
|
|
|
int holdDamage = 0;
|
2014-10-25 00:31:28 +00:00
|
|
|
|
2009-09-14 20:47:53 +00:00
|
|
|
if (target == NULL || !((target->flags & MF_SHOOTABLE) || (target->flags6 & MF6_VULNERABLE)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Shouldn't happen
|
2013-01-02 04:39:59 +00:00
|
|
|
return -1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 00:30:17 +00:00
|
|
|
//Rather than unnecessarily call the function over and over again, let's be a little more efficient.
|
2015-03-25 19:19:50 +00:00
|
|
|
fakedPain = (isFakePain(target, inflictor, damage));
|
2014-11-25 00:30:17 +00:00
|
|
|
forcedPain = (MustForcePain(target, inflictor));
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// Spectral targets only take damage from spectral projectiles.
|
2009-08-07 03:57:03 +00:00
|
|
|
if (target->flags4 & MF4_SPECTRAL && damage < TELEFRAG_DAMAGE)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (inflictor == NULL || !(inflictor->flags4 & MF4_SPECTRAL))
|
|
|
|
{
|
2013-01-02 04:39:59 +00:00
|
|
|
return -1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (target->health <= 0)
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
if (inflictor && mod == NAME_Ice)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2013-01-02 04:39:59 +00:00
|
|
|
return -1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (target->flags & MF_ICECORPSE) // frozen
|
|
|
|
{
|
|
|
|
target->tics = 1;
|
2009-12-16 16:09:48 +00:00
|
|
|
target->flags6 |= MF6_SHATTERING;
|
2009-06-30 20:57:51 +00:00
|
|
|
target->velx = target->vely = target->velz = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2013-01-02 04:39:59 +00:00
|
|
|
return -1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2014-11-12 20:08:26 +00:00
|
|
|
if ((target->flags2 & MF2_INVULNERABLE) && (damage < TELEFRAG_DAMAGE) && (!(flags & DMG_FORCED)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // actor is invulnerable
|
2009-06-30 23:23:12 +00:00
|
|
|
if (target->player == NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2013-07-25 22:52:12 +00:00
|
|
|
if (inflictor == NULL || (!(inflictor->flags3 & MF3_FOILINVUL) && !(flags & DMG_FOILINVUL)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-11-25 00:30:17 +00:00
|
|
|
if (fakedPain)
|
2014-11-01 05:00:29 +00:00
|
|
|
{
|
2015-03-27 12:49:47 +00:00
|
|
|
// big mess here: What do we use for the pain threshold?
|
|
|
|
// We cannot run the various damage filters below so for consistency it needs to be 0.
|
|
|
|
damage = 0;
|
|
|
|
invulpain = true;
|
|
|
|
goto fakepain;
|
2014-11-01 05:00:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return -1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-06-30 23:23:12 +00:00
|
|
|
// Players are optionally excluded from getting thrust by damage.
|
|
|
|
if (static_cast<APlayerPawn *>(target)->PlayerFlags & PPF_NOTHRUSTWHENINVUL)
|
|
|
|
{
|
2014-11-25 00:30:17 +00:00
|
|
|
if (fakedPain)
|
2014-11-01 05:00:29 +00:00
|
|
|
plrDontThrust = 1;
|
|
|
|
else
|
|
|
|
return -1;
|
2009-06-30 23:23:12 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2014-11-01 05:00:29 +00:00
|
|
|
|
2006-10-22 10:32:41 +00:00
|
|
|
if (inflictor != NULL)
|
|
|
|
{
|
2009-10-28 23:14:20 +00:00
|
|
|
if (inflictor->flags5 & MF5_PIERCEARMOR)
|
|
|
|
flags |= DMG_NO_ARMOR;
|
2006-10-22 10:32:41 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
MeansOfDeath = mod;
|
2006-10-31 14:53:21 +00:00
|
|
|
FriendlyFire = false;
|
2006-02-24 04:48:15 +00:00
|
|
|
// [RH] Andy Baker's Stealth monsters
|
|
|
|
if (target->flags & MF_STEALTH)
|
|
|
|
{
|
|
|
|
target->alpha = OPAQUE;
|
|
|
|
target->visdir = -1;
|
|
|
|
}
|
|
|
|
if (target->flags & MF_SKULLFLY)
|
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
target->velx = target->vely = target->velz = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2015-03-27 12:49:47 +00:00
|
|
|
if (!(flags & DMG_FORCED) && damage < TELEFRAG_DAMAGE) // DMG_FORCED skips all special damage checks, TELEFRAG_DAMAGE may not be reduced at all
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-05-23 08:30:36 +00:00
|
|
|
if (target->flags2 & MF2_DORMANT)
|
|
|
|
{
|
|
|
|
// Invulnerable, and won't wake up
|
2013-01-02 04:39:59 +00:00
|
|
|
return -1;
|
2009-05-23 08:30:36 +00:00
|
|
|
}
|
|
|
|
player = target->player;
|
2015-03-27 12:49:47 +00:00
|
|
|
if (player && damage > 1)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-05-23 08:30:36 +00:00
|
|
|
// Take half damage in trainer mode
|
|
|
|
damage = FixedMul(damage, G_SkillProperty(SKILLP_DamageFactor));
|
|
|
|
}
|
|
|
|
// Special damage types
|
|
|
|
if (inflictor)
|
|
|
|
{
|
|
|
|
if (inflictor->flags4 & MF4_SPECTRAL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-05-23 08:30:36 +00:00
|
|
|
if (player != NULL)
|
|
|
|
{
|
2012-05-13 11:17:27 +00:00
|
|
|
if (!deathmatch && inflictor->FriendPlayer > 0)
|
2013-01-02 04:39:59 +00:00
|
|
|
return -1;
|
2009-05-23 08:30:36 +00:00
|
|
|
}
|
|
|
|
else if (target->flags4 & MF4_SPECTRAL)
|
|
|
|
{
|
2012-05-13 11:17:27 +00:00
|
|
|
if (inflictor->FriendPlayer == 0 && !target->IsHostile(inflictor))
|
2013-01-02 04:39:59 +00:00
|
|
|
return -1;
|
2009-05-23 08:30:36 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2015-03-27 12:49:47 +00:00
|
|
|
|
2015-03-27 10:50:27 +00:00
|
|
|
damage = inflictor->DoSpecialDamage (target, damage, mod);
|
2015-03-27 12:49:47 +00:00
|
|
|
if (damage < 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2013-01-02 04:39:59 +00:00
|
|
|
return -1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2009-05-23 08:30:36 +00:00
|
|
|
}
|
2014-11-20 05:57:40 +00:00
|
|
|
|
2015-03-27 12:49:47 +00:00
|
|
|
int olddam = damage;
|
2014-11-25 00:30:17 +00:00
|
|
|
|
2015-03-27 12:49:47 +00:00
|
|
|
if (damage > 0 && source != NULL)
|
|
|
|
{
|
|
|
|
damage = FixedMul(damage, source->DamageMultiply);
|
|
|
|
|
|
|
|
// Handle active damage modifiers (e.g. PowerDamage)
|
|
|
|
if (damage > 0 && source->Inventory != NULL)
|
|
|
|
{
|
|
|
|
source->Inventory->ModifyDamage(damage, mod, damage, false);
|
2012-04-15 03:48:27 +00:00
|
|
|
}
|
2009-05-23 08:30:36 +00:00
|
|
|
}
|
2014-10-28 03:29:10 +00:00
|
|
|
// Handle passive damage modifiers (e.g. PowerProtection), provided they are not afflicted with protection penetrating powers.
|
2015-03-27 12:49:47 +00:00
|
|
|
if (damage > 0 && (target->Inventory != NULL) && !(flags & DMG_NO_PROTECT))
|
2009-05-23 08:30:36 +00:00
|
|
|
{
|
2015-03-27 12:49:47 +00:00
|
|
|
target->Inventory->ModifyDamage(damage, mod, damage, true);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2015-03-27 12:49:47 +00:00
|
|
|
if (damage > 0 && !(flags & DMG_NO_FACTOR))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-12-13 05:04:12 +00:00
|
|
|
damage = FixedMul(damage, target->DamageFactor);
|
2014-11-12 20:08:26 +00:00
|
|
|
if (damage > 0)
|
2012-04-15 03:48:27 +00:00
|
|
|
{
|
|
|
|
damage = DamageTypeDefinition::ApplyMobjDamageFactor(damage, mod, target->GetClass()->ActorInfo->DamageFactors);
|
|
|
|
}
|
2015-03-27 12:49:47 +00:00
|
|
|
}
|
|
|
|
|
2015-03-27 13:37:13 +00:00
|
|
|
if (damage >= 0)
|
2015-03-27 12:49:47 +00:00
|
|
|
{
|
|
|
|
damage = target->TakeSpecialDamage(inflictor, source, damage, mod);
|
|
|
|
}
|
|
|
|
|
|
|
|
// '<0' is handled below. This only handles the case where damage gets reduced to 0.
|
|
|
|
if (damage == 0 && olddam > 0)
|
|
|
|
{
|
2012-04-15 03:48:27 +00:00
|
|
|
{ // Still allow FORCEPAIN
|
2014-11-25 00:30:17 +00:00
|
|
|
if (forcedPain)
|
2015-03-27 12:49:47 +00:00
|
|
|
{
|
2012-04-15 03:48:27 +00:00
|
|
|
goto dopain;
|
2015-03-27 12:49:47 +00:00
|
|
|
}
|
2014-11-25 00:30:17 +00:00
|
|
|
else if (fakedPain)
|
2015-03-27 12:49:47 +00:00
|
|
|
{
|
2014-11-01 05:00:29 +00:00
|
|
|
goto fakepain;
|
2015-03-27 12:49:47 +00:00
|
|
|
}
|
2013-01-02 04:39:59 +00:00
|
|
|
return -1;
|
2012-04-15 03:48:27 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2009-05-23 08:30:36 +00:00
|
|
|
}
|
2015-03-27 12:49:47 +00:00
|
|
|
if (damage < 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2015-03-27 12:49:47 +00:00
|
|
|
// any negative value means that something in the above chain has cancelled out all damage and all damage effects, including pain.
|
2013-01-02 04:39:59 +00:00
|
|
|
return -1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
// Push the target unless the source's weapon's kickback is 0.
|
2009-09-14 19:44:14 +00:00
|
|
|
// (i.e. Gauntlets/Chainsaw)
|
2015-03-27 12:49:47 +00:00
|
|
|
if (!plrDontThrust && inflictor && inflictor != target // [RH] Not if hurting own self
|
2006-02-24 04:48:15 +00:00
|
|
|
&& !(target->flags & MF_NOCLIP)
|
2008-06-02 16:56:53 +00:00
|
|
|
&& !(inflictor->flags2 & MF2_NODMGTHRUST)
|
2009-06-30 23:23:12 +00:00
|
|
|
&& !(flags & DMG_THRUSTLESS)
|
2014-10-28 07:40:34 +00:00
|
|
|
&& !(target->flags7 & MF7_DONTTHRUST)
|
2009-06-30 23:23:12 +00:00
|
|
|
&& (source == NULL || source->player == NULL || !(source->flags2 & MF2_NODMGTHRUST)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int kickback;
|
|
|
|
|
2011-06-13 09:16:57 +00:00
|
|
|
if (inflictor && inflictor->projectileKickback)
|
|
|
|
kickback = inflictor->projectileKickback;
|
|
|
|
else if (!source || !source->player || !source->player->ReadyWeapon)
|
2006-02-24 04:48:15 +00:00
|
|
|
kickback = gameinfo.defKickback;
|
|
|
|
else
|
|
|
|
kickback = source->player->ReadyWeapon->Kickback;
|
|
|
|
|
|
|
|
if (kickback)
|
|
|
|
{
|
2007-11-19 08:13:23 +00:00
|
|
|
AActor *origin = (source && (flags & DMG_INFLICTOR_IS_PUFF))? source : inflictor;
|
2013-02-07 21:02:26 +00:00
|
|
|
|
|
|
|
// If the origin and target are in exactly the same spot, choose a random direction.
|
|
|
|
// (Most likely cause is from telefragging somebody during spawning because they
|
|
|
|
// haven't moved from their spawn spot at all.)
|
|
|
|
if (origin->x == target->x && origin->y == target->y)
|
|
|
|
{
|
|
|
|
ang = pr_kickbackdir.GenRand32();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ang = R_PointToAngle2 (origin->x, origin->y, target->x, target->y);
|
|
|
|
}
|
2009-06-14 13:47:38 +00:00
|
|
|
|
|
|
|
// Calculate this as float to avoid overflows so that the
|
|
|
|
// clamping that had to be done here can be removed.
|
2009-09-14 19:44:14 +00:00
|
|
|
double fltthrust;
|
2009-09-11 01:00:01 +00:00
|
|
|
|
2009-09-14 19:44:14 +00:00
|
|
|
fltthrust = mod == NAME_MDK ? 10 : 32;
|
|
|
|
if (target->Mass > 0)
|
|
|
|
{
|
|
|
|
fltthrust = clamp((damage * 0.125 * kickback) / target->Mass, 0., fltthrust);
|
|
|
|
}
|
2015-03-27 12:49:47 +00:00
|
|
|
|
2009-06-16 22:04:26 +00:00
|
|
|
thrust = FLOAT2FIXED(fltthrust);
|
2015-03-27 12:49:47 +00:00
|
|
|
|
|
|
|
// Don't apply ultra-small damage thrust
|
|
|
|
if (thrust < FRACUNIT/100) thrust = 0;
|
2010-01-30 13:48:44 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// make fall forwards sometimes
|
|
|
|
if ((damage < 40) && (damage > target->health)
|
2007-11-19 08:13:23 +00:00
|
|
|
&& (target->z - origin->z > 64*FRACUNIT)
|
2006-02-24 04:48:15 +00:00
|
|
|
&& (pr_damagemobj()&1)
|
|
|
|
// [RH] But only if not too fast and not flying
|
|
|
|
&& thrust < 10*FRACUNIT
|
2013-08-09 18:20:23 +00:00
|
|
|
&& !(target->flags & MF_NOGRAVITY)
|
2015-03-27 12:49:47 +00:00
|
|
|
&& (inflictor == NULL || !(inflictor->flags5 & MF5_NOFORWARDFALL))
|
|
|
|
)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
ang += ANG180;
|
|
|
|
thrust *= 4;
|
|
|
|
}
|
|
|
|
ang >>= ANGLETOFINESHIFT;
|
2009-08-30 10:43:51 +00:00
|
|
|
if (source && source->player && (flags & DMG_INFLICTOR_IS_PUFF)
|
2006-02-24 04:48:15 +00:00
|
|
|
&& source->player->ReadyWeapon != NULL &&
|
|
|
|
(source->player->ReadyWeapon->WeaponFlags & WIF_STAFF2_KICKBACK))
|
|
|
|
{
|
|
|
|
// Staff power level 2
|
2009-06-30 20:57:51 +00:00
|
|
|
target->velx += FixedMul (10*FRACUNIT, finecosine[ang]);
|
|
|
|
target->vely += FixedMul (10*FRACUNIT, finesine[ang]);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (!(target->flags & MF_NOGRAVITY))
|
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
target->velz += 5*FRACUNIT;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
target->velx += FixedMul (thrust, finecosine[ang]);
|
|
|
|
target->vely += FixedMul (thrust, finesine[ang]);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-22 03:35:33 +00:00
|
|
|
// [RH] Avoid friendly fire if enabled
|
|
|
|
if (!(flags & DMG_FORCED) && source != NULL &&
|
2012-04-01 20:43:14 +00:00
|
|
|
((player && player != source->player) || (!player && target != source)) &&
|
2011-01-22 03:35:33 +00:00
|
|
|
target->IsTeammate (source))
|
|
|
|
{
|
|
|
|
if (player)
|
|
|
|
FriendlyFire = true;
|
|
|
|
if (damage < TELEFRAG_DAMAGE)
|
|
|
|
{ // Still allow telefragging :-(
|
|
|
|
damage = (int)((float)damage * level.teamdamage);
|
2015-03-27 12:49:47 +00:00
|
|
|
if (damage < 0)
|
|
|
|
{
|
2013-01-02 04:39:59 +00:00
|
|
|
return damage;
|
2015-03-27 12:49:47 +00:00
|
|
|
}
|
|
|
|
else if (damage == 0)
|
|
|
|
{
|
|
|
|
if (forcedPain)
|
|
|
|
{
|
|
|
|
goto dopain;
|
|
|
|
}
|
|
|
|
else if (fakedPain)
|
|
|
|
{
|
|
|
|
goto fakepain;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
2011-01-22 03:35:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// player specific
|
|
|
|
//
|
|
|
|
if (player)
|
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
//Added by MC: Lets bots look allround for enemies if they survive an ambush.
|
2014-10-14 18:57:11 +00:00
|
|
|
if (player->Bot != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-14 18:57:11 +00:00
|
|
|
player->Bot->allround = true;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// end of game hell hack
|
|
|
|
if ((target->Sector->special & 255) == dDamage_End
|
|
|
|
&& damage >= target->health)
|
|
|
|
{
|
|
|
|
damage = target->health - 1;
|
|
|
|
}
|
|
|
|
|
2009-05-23 08:30:36 +00:00
|
|
|
if (!(flags & DMG_FORCED))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-09-27 20:54:46 +00:00
|
|
|
// check the real player, not a voodoo doll here for invulnerability effects
|
2014-10-25 00:31:28 +00:00
|
|
|
if ((damage < TELEFRAG_DAMAGE && ((player->mo->flags2 & MF2_INVULNERABLE) ||
|
2014-11-12 20:08:26 +00:00
|
|
|
(player->cheats & CF_GODMODE))) ||
|
|
|
|
(player->cheats & CF_GODMODE2) || (player->mo->flags5 & MF5_NODAMAGE))
|
2014-10-25 00:31:28 +00:00
|
|
|
//Absolutely no hurting if NODAMAGE is involved. Same for GODMODE2.
|
2009-05-23 08:30:36 +00:00
|
|
|
{ // player is invulnerable, so don't hurt him
|
2014-11-12 20:08:26 +00:00
|
|
|
//Make sure no godmodes and NOPAIN flags are found first.
|
|
|
|
//Then, check to see if the player has NODAMAGE or ALLOWPAIN, or inflictor has CAUSEPAIN.
|
2014-11-25 00:30:17 +00:00
|
|
|
if ((player->cheats & CF_GODMODE) || (player->cheats & CF_GODMODE2) || (player->mo->flags5 & MF5_NOPAIN))
|
|
|
|
return -1;
|
|
|
|
else if ((((player->mo->flags7 & MF7_ALLOWPAIN) || (player->mo->flags5 & MF5_NODAMAGE)) || ((inflictor != NULL) && (inflictor->flags7 & MF7_CAUSEPAIN))))
|
|
|
|
{
|
2014-11-01 05:00:29 +00:00
|
|
|
invulpain = true;
|
|
|
|
goto fakepain;
|
|
|
|
}
|
2014-11-25 00:30:17 +00:00
|
|
|
else
|
|
|
|
return -1;
|
2009-05-23 08:30:36 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-05-23 08:30:36 +00:00
|
|
|
if (!(flags & DMG_NO_ARMOR) && player->mo->Inventory != NULL)
|
|
|
|
{
|
|
|
|
int newdam = damage;
|
2015-01-20 09:25:58 +00:00
|
|
|
if (damage > 0)
|
|
|
|
{
|
|
|
|
player->mo->Inventory->AbsorbDamage(damage, mod, newdam);
|
|
|
|
}
|
2014-10-24 22:52:27 +00:00
|
|
|
if (damage < TELEFRAG_DAMAGE)
|
|
|
|
{
|
|
|
|
// if we are telefragging don't let the damage value go below that magic value. Some further checks would fail otherwise.
|
|
|
|
damage = newdam;
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (damage <= 0)
|
2009-05-23 08:30:36 +00:00
|
|
|
{
|
2009-10-28 23:14:20 +00:00
|
|
|
// If MF6_FORCEPAIN is set, make the player enter the pain state.
|
2013-01-02 04:39:59 +00:00
|
|
|
if (!(target->flags5 & MF5_NOPAIN) && inflictor != NULL &&
|
2014-11-12 20:08:26 +00:00
|
|
|
(inflictor->flags6 & MF6_FORCEPAIN) && !(inflictor->flags5 & MF5_PAINLESS)
|
|
|
|
&& (!(player->mo->flags2 & MF2_INVULNERABLE)) && (!(player->cheats & CF_GODMODE)) && (!(player->cheats & CF_GODMODE2)))
|
2013-01-02 04:39:59 +00:00
|
|
|
{
|
|
|
|
goto dopain;
|
|
|
|
}
|
|
|
|
return damage;
|
2009-05-23 08:30:36 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2009-05-23 08:30:36 +00:00
|
|
|
|
2014-10-24 23:00:40 +00:00
|
|
|
if (damage >= player->health && damage < TELEFRAG_DAMAGE
|
2009-05-23 08:30:36 +00:00
|
|
|
&& (G_SkillProperty(SKILLP_AutoUseHealth) || deathmatch)
|
|
|
|
&& !player->morphTics)
|
|
|
|
{ // Try to use some inventory health
|
|
|
|
P_AutoUseHealth (player, damage - player->health + 1);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
player->health -= damage; // mirror mobj health here for Dave
|
|
|
|
// [RH] Make voodoo dolls and real players record the same health
|
|
|
|
target->health = player->mo->health -= damage;
|
2009-05-23 08:30:36 +00:00
|
|
|
if (player->health < 50 && !deathmatch && !(flags & DMG_FORCED))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
P_AutoUseStrifeHealth (player);
|
|
|
|
player->mo->health = player->health;
|
|
|
|
}
|
2009-08-07 04:08:38 +00:00
|
|
|
if (player->health <= 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-08-07 04:08:38 +00:00
|
|
|
// [SP] Buddha cheat: if the player is about to die, rescue him to 1 health.
|
|
|
|
// This does not save the player if damage >= TELEFRAG_DAMAGE, still need to
|
|
|
|
// telefrag him right? ;) (Unfortunately the damage is "absorbed" by armor,
|
|
|
|
// but telefragging should still do enough damage to kill the player)
|
2014-10-25 00:31:28 +00:00
|
|
|
// Ignore players that are already dead.
|
2014-11-25 00:30:17 +00:00
|
|
|
// [MC]Buddha2 absorbs telefrag damage, and anything else thrown their way.
|
2015-03-02 21:43:25 +00:00
|
|
|
if (((player->cheats & CF_BUDDHA2) || (((player->cheats & CF_BUDDHA) || (player->mo->flags7 & MF7_BUDDHA)) && (damage < TELEFRAG_DAMAGE))) && (player->playerstate != PST_DEAD))
|
2009-08-07 04:08:38 +00:00
|
|
|
{
|
2010-11-03 23:43:34 +00:00
|
|
|
// If this is a voodoo doll we need to handle the real player as well.
|
|
|
|
player->mo->health = target->health = player->health = 1;
|
2009-08-07 04:08:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player->health = 0;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2007-01-28 04:59:04 +00:00
|
|
|
player->LastDamageType = mod;
|
2006-02-24 04:48:15 +00:00
|
|
|
player->attacker = source;
|
|
|
|
player->damagecount += damage; // add damage after armor / invuln
|
|
|
|
if (player->damagecount > 100)
|
|
|
|
{
|
|
|
|
player->damagecount = 100; // teleport stomp does 10k points...
|
|
|
|
}
|
|
|
|
temp = damage < 100 ? damage : 100;
|
|
|
|
if (player == &players[consoleplayer])
|
|
|
|
{
|
|
|
|
I_Tactile (40,10,40+temp*2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-03-19 22:48:55 +00:00
|
|
|
// Armor for monsters.
|
2009-05-23 08:30:36 +00:00
|
|
|
if (!(flags & (DMG_NO_ARMOR|DMG_FORCED)) && target->Inventory != NULL && damage > 0)
|
2009-03-19 22:48:55 +00:00
|
|
|
{
|
|
|
|
int newdam = damage;
|
|
|
|
target->Inventory->AbsorbDamage (damage, mod, newdam);
|
|
|
|
damage = newdam;
|
|
|
|
if (damage <= 0)
|
|
|
|
{
|
2014-11-25 00:30:17 +00:00
|
|
|
if (fakedPain)
|
2014-11-01 05:00:29 +00:00
|
|
|
goto fakepain;
|
|
|
|
else
|
|
|
|
return damage;
|
2009-03-19 22:48:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
target->health -= damage;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// the damage has been dealt; now deal with the consequences
|
|
|
|
//
|
2011-06-06 22:23:43 +00:00
|
|
|
target->DamageTypeReceived = mod;
|
2007-05-10 22:22:38 +00:00
|
|
|
|
|
|
|
// If the damaging player has the power of drain, give the player 50% of the damage
|
|
|
|
// done in health.
|
2013-06-24 14:42:43 +00:00
|
|
|
if ( source && source->player && source->player->cheats & CF_DRAIN && !(target->flags5 & MF5_DONTDRAIN))
|
2007-05-10 22:22:38 +00:00
|
|
|
{
|
|
|
|
if (!target->player || target->player != source->player)
|
|
|
|
{
|
|
|
|
if ( P_GiveBody( source, damage / 2 ))
|
|
|
|
{
|
|
|
|
S_Sound( source, CHAN_ITEM, "*drainhealth", 1, ATTN_NORM );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (target->health <= 0)
|
2014-10-25 04:09:39 +00:00
|
|
|
{
|
2014-11-25 00:30:17 +00:00
|
|
|
//[MC]Buddha flag for monsters.
|
2014-11-15 13:59:37 +00:00
|
|
|
if ((target->flags7 & MF7_BUDDHA) && (damage < TELEFRAG_DAMAGE) && ((inflictor == NULL || !(inflictor->flags3 & MF7_FOILBUDDHA)) && !(flags & DMG_FOILBUDDHA)))
|
2014-10-28 02:35:55 +00:00
|
|
|
{ //FOILBUDDHA or Telefrag damage must kill it.
|
2014-10-25 04:09:39 +00:00
|
|
|
target->health = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
// Death
|
|
|
|
target->special1 = damage;
|
2013-06-24 13:40:17 +00:00
|
|
|
|
2014-10-25 04:09:39 +00:00
|
|
|
// use inflictor's death type if it got one.
|
|
|
|
if (inflictor && inflictor->DeathType != NAME_None) mod = inflictor->DeathType;
|
2013-06-24 13:40:17 +00:00
|
|
|
|
2014-10-25 04:09:39 +00:00
|
|
|
// check for special fire damage or ice damage deaths
|
|
|
|
if (mod == NAME_Fire)
|
|
|
|
{
|
|
|
|
if (player && !player->morphTics)
|
|
|
|
{ // Check for flame death
|
|
|
|
if (!inflictor ||
|
|
|
|
((target->health > -50) && (damage > 25)) ||
|
|
|
|
!(inflictor->flags5 & MF5_SPECIALFIREDAMAGE))
|
|
|
|
{
|
|
|
|
target->DamageType = NAME_Fire;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
target->DamageType = NAME_Fire;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-25 04:09:39 +00:00
|
|
|
target->DamageType = mod;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2014-10-25 04:09:39 +00:00
|
|
|
if (source && source->tracer && (source->flags5 & MF5_SUMMONEDMONSTER))
|
|
|
|
{ // Minotaur's kills go to his master
|
|
|
|
// Make sure still alive and not a pointer to fighter head
|
|
|
|
if (source->tracer->player && (source->tracer->player->mo == source->tracer))
|
|
|
|
{
|
|
|
|
source = source->tracer;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2014-10-25 04:09:39 +00:00
|
|
|
target->Die (source, inflictor, flags);
|
|
|
|
return damage;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2006-10-31 14:53:21 +00:00
|
|
|
|
2009-06-07 17:04:40 +00:00
|
|
|
woundstate = target->FindState(NAME_Wound, mod);
|
2006-10-31 14:53:21 +00:00
|
|
|
if (woundstate != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-03-03 03:57:01 +00:00
|
|
|
int woundhealth = RUNTIME_TYPE(target)->Meta.GetMetaInt (AMETA_WoundHealth, 6);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (target->health <= woundhealth)
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
target->SetState (woundstate);
|
2013-01-02 04:39:59 +00:00
|
|
|
return damage;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-07 17:04:40 +00:00
|
|
|
|
2014-11-01 05:00:29 +00:00
|
|
|
fakepain: //Needed so we can skip the rest of the above, but still obey the original rules.
|
2014-11-12 20:08:26 +00:00
|
|
|
|
2009-07-04 18:17:44 +00:00
|
|
|
if (!(target->flags5 & MF5_NOPAIN) && (inflictor == NULL || !(inflictor->flags5 & MF5_PAINLESS)) &&
|
2012-05-15 21:51:02 +00:00
|
|
|
(target->player != NULL || !G_SkillProperty(SKILLP_NoPain)) && !(target->flags & MF_SKULLFLY))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-10-08 17:43:50 +00:00
|
|
|
pc = target->GetClass()->ActorInfo->PainChances;
|
|
|
|
painchance = target->PainChance;
|
|
|
|
if (pc != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-03-22 21:18:54 +00:00
|
|
|
int *ppc = pc->CheckKey(mod);
|
2009-10-08 17:43:50 +00:00
|
|
|
if (ppc != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-10-08 17:43:50 +00:00
|
|
|
painchance = *ppc;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2009-10-08 17:43:50 +00:00
|
|
|
}
|
|
|
|
|
2015-03-25 19:27:12 +00:00
|
|
|
if (((damage >= target->PainThreshold) && (pr_damagemobj() < painchance))
|
2014-11-12 20:08:26 +00:00
|
|
|
|| (inflictor != NULL && (inflictor->flags6 & MF6_FORCEPAIN)))
|
2009-10-08 17:43:50 +00:00
|
|
|
{
|
|
|
|
dopain:
|
|
|
|
if (mod == NAME_Electric)
|
|
|
|
{
|
|
|
|
if (pr_lightning() < 96)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-10-08 17:43:50 +00:00
|
|
|
justhit = true;
|
2009-10-28 23:14:20 +00:00
|
|
|
FState *painstate = target->FindState(NAME_Pain, mod);
|
|
|
|
if (painstate != NULL)
|
|
|
|
target->SetState(painstate);
|
2009-10-08 17:43:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // "electrocute" the target
|
|
|
|
target->renderflags |= RF_FULLBRIGHT;
|
|
|
|
if ((target->flags3 & MF3_ISMONSTER) && pr_lightning() < 128)
|
|
|
|
{
|
|
|
|
target->Howl ();
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2009-10-08 17:43:50 +00:00
|
|
|
else
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-10-08 17:43:50 +00:00
|
|
|
justhit = true;
|
2011-06-13 17:15:09 +00:00
|
|
|
FState *painstate = target->FindState(NAME_Pain, ((inflictor && inflictor->PainType != NAME_None) ? inflictor->PainType : mod));
|
2009-10-28 23:14:20 +00:00
|
|
|
if (painstate != NULL)
|
|
|
|
target->SetState(painstate);
|
2009-10-08 17:43:50 +00:00
|
|
|
if (mod == NAME_PoisonCloud)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-10-08 17:43:50 +00:00
|
|
|
if ((target->flags3 & MF3_ISMONSTER) && pr_poison() < 128)
|
|
|
|
{
|
|
|
|
target->Howl ();
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-11-12 20:08:26 +00:00
|
|
|
//ALLOWPAIN and CAUSEPAIN can still trigger infighting, even if no pain state is worked out.
|
2006-02-24 04:48:15 +00:00
|
|
|
target->reactiontime = 0; // we're awake now...
|
|
|
|
if (source)
|
|
|
|
{
|
|
|
|
if (source == target->target)
|
|
|
|
{
|
|
|
|
target->threshold = BASETHRESHOLD;
|
|
|
|
if (target->state == target->SpawnState && target->SeeState != NULL)
|
|
|
|
{
|
|
|
|
target->SetState (target->SeeState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (source != target->target && target->OkayToSwitchTarget (source))
|
|
|
|
{
|
|
|
|
// Target actor is not intent on another actor,
|
|
|
|
// so make him chase after source
|
|
|
|
|
|
|
|
// killough 2/15/98: remember last enemy, to prevent
|
|
|
|
// sleeping early; 2/21/98: Place priority on players
|
|
|
|
|
|
|
|
if (target->lastenemy == NULL ||
|
|
|
|
(target->lastenemy->player == NULL && target->TIDtoHate == 0) ||
|
|
|
|
target->lastenemy->health <= 0)
|
|
|
|
{
|
|
|
|
target->lastenemy = target->target; // remember last enemy - killough
|
|
|
|
}
|
|
|
|
target->target = source;
|
|
|
|
target->threshold = BASETHRESHOLD;
|
|
|
|
if (target->state == target->SpawnState && target->SeeState != NULL)
|
|
|
|
{
|
|
|
|
target->SetState (target->SeeState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-09-16 15:54:04 +00:00
|
|
|
|
|
|
|
// killough 11/98: Don't attack a friend, unless hit by that friend.
|
|
|
|
if (justhit && (target->target == source || !target->target || !target->IsFriend(target->target)))
|
|
|
|
target->flags |= MF_JUSTHIT; // fight back!
|
2013-01-02 04:39:59 +00:00
|
|
|
|
2014-11-01 05:00:29 +00:00
|
|
|
if (invulpain) //Note that this takes into account all the cheats a player has, in terms of invulnerability.
|
|
|
|
{
|
|
|
|
return -1; //NOW we return -1!
|
|
|
|
}
|
2013-01-02 04:39:59 +00:00
|
|
|
return damage;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2011-06-13 10:39:14 +00:00
|
|
|
void P_PoisonMobj (AActor *target, AActor *inflictor, AActor *source, int damage, int duration, int period, FName type)
|
2010-07-23 21:36:17 +00:00
|
|
|
{
|
2011-06-13 10:25:03 +00:00
|
|
|
// Check for invulnerability.
|
|
|
|
if (!(inflictor->flags6 & MF6_POISONALWAYS))
|
|
|
|
{
|
|
|
|
if (target->flags2 & MF2_INVULNERABLE)
|
|
|
|
{ // actor is invulnerable
|
|
|
|
if (target->player == NULL)
|
|
|
|
{
|
|
|
|
if (!(inflictor->flags3 & MF3_FOILINVUL))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-23 21:36:17 +00:00
|
|
|
target->Poisoner = source;
|
2011-06-13 10:39:14 +00:00
|
|
|
target->PoisonDamageTypeReceived = type;
|
|
|
|
target->PoisonPeriodReceived = period;
|
2010-07-23 21:36:17 +00:00
|
|
|
|
|
|
|
if (inflictor->flags6 & MF6_ADDITIVEPOISONDAMAGE)
|
|
|
|
{
|
|
|
|
target->PoisonDamageReceived += damage;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
target->PoisonDamageReceived = damage;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inflictor->flags6 & MF6_ADDITIVEPOISONDURATION)
|
|
|
|
{
|
|
|
|
target->PoisonDurationReceived += duration;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
target->PoisonDurationReceived = duration;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
bool AActor::OkayToSwitchTarget (AActor *other)
|
|
|
|
{
|
|
|
|
if (other == this)
|
|
|
|
return false; // [RH] Don't hate self (can happen when shooting barrels)
|
|
|
|
|
2013-08-12 18:41:33 +00:00
|
|
|
if (other->flags7 & MF7_NEVERTARGET)
|
|
|
|
return false; // never EVER target me!
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (!(other->flags & MF_SHOOTABLE))
|
|
|
|
return false; // Don't attack things that can't be hurt
|
|
|
|
|
|
|
|
if ((flags4 & MF4_NOTARGETSWITCH) && target != NULL)
|
|
|
|
return false; // Don't switch target if not allowed
|
|
|
|
|
|
|
|
if ((master != NULL && other->IsA(master->GetClass())) || // don't attack your master (or others of its type)
|
|
|
|
(other->master != NULL && IsA(other->master->GetClass()))) // don't attack your minion (or those of others of your type)
|
|
|
|
{
|
- 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 (!IsHostile (other) && // allow target switch if other is considered hostile
|
2006-02-24 04:48:15 +00:00
|
|
|
(other->tid != TIDtoHate || TIDtoHate == 0) && // or has the tid we hate
|
|
|
|
other->TIDtoHate == TIDtoHate) // or has different hate information
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((other->flags3 & MF3_NOTARGET) &&
|
|
|
|
(other->tid != TIDtoHate || TIDtoHate == 0) &&
|
- 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
|
|
|
!IsHostile (other))
|
2006-02-24 04:48:15 +00:00
|
|
|
return false;
|
|
|
|
if (threshold != 0 && !(flags4 & MF4_QUICKTORETALIATE))
|
|
|
|
return false;
|
2006-03-03 03:57:01 +00:00
|
|
|
if (IsFriend (other))
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // [RH] Friendlies don't target other friendlies
|
|
|
|
return false;
|
|
|
|
}
|
2007-05-20 11:08:36 +00:00
|
|
|
|
|
|
|
int infight;
|
2008-03-24 22:06:26 +00:00
|
|
|
if (flags5 & MF5_NOINFIGHTING) infight=-1;
|
2009-02-03 19:11:43 +00:00
|
|
|
else if (level.flags2 & LEVEL2_TOTALINFIGHTING) infight=1;
|
|
|
|
else if (level.flags2 & LEVEL2_NOINFIGHTING) infight=-1;
|
2007-05-20 11:08:36 +00:00
|
|
|
else infight = infighting;
|
|
|
|
|
|
|
|
if (infight < 0 && other->player == NULL && !IsHostile (other))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2007-05-20 11:08:36 +00:00
|
|
|
return false; // infighting off: Non-friendlies don't target other non-friendlies
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
if (TIDtoHate != 0 && TIDtoHate == other->TIDtoHate)
|
|
|
|
return false; // [RH] Don't target "teammates"
|
|
|
|
if (other->player != NULL && (flags4 & MF4_NOHATEPLAYERS))
|
|
|
|
return false; // [RH] Don't target players
|
|
|
|
if (target != NULL && target->health > 0 &&
|
|
|
|
TIDtoHate != 0 && target->tid == TIDtoHate && pr_switcher() < 128 &&
|
|
|
|
P_CheckSight (this, target))
|
|
|
|
return false; // [RH] Don't be too quick to give up things we hate
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// P_PoisonPlayer - Sets up all data concerning poisoning
|
|
|
|
//
|
2013-01-25 02:35:11 +00:00
|
|
|
// poisoner is the object directly responsible for poisoning the player,
|
|
|
|
// such as a missile. source is the actor responsible for creating the
|
|
|
|
// poisoner.
|
|
|
|
//
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
|
2009-06-07 09:41:22 +00:00
|
|
|
bool P_PoisonPlayer (player_t *player, AActor *poisoner, AActor *source, int poison)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-28 03:29:10 +00:00
|
|
|
if((player->cheats&CF_GODMODE) || (player->mo->flags2 & MF2_INVULNERABLE) || (player->cheats & CF_GODMODE2))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-06-07 09:41:22 +00:00
|
|
|
return false;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
if (source != NULL && source->player != player && player->mo->IsTeammate (source))
|
|
|
|
{
|
2007-12-22 22:04:20 +00:00
|
|
|
poison = (int)((float)poison * level.teamdamage);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
if (poison > 0)
|
|
|
|
{
|
|
|
|
player->poisoncount += poison;
|
2013-01-25 02:35:11 +00:00
|
|
|
player->poisoner = source;
|
2012-03-23 20:57:10 +00:00
|
|
|
if (poisoner == NULL)
|
|
|
|
{
|
|
|
|
player->poisontype = player->poisonpaintype = NAME_None;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // We need to record these in case the poisoner disappears before poisoncount reaches 0.
|
|
|
|
player->poisontype = poisoner->DamageType;
|
|
|
|
player->poisonpaintype = poisoner->PainType != NAME_None ? poisoner->PainType : poisoner->DamageType;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
if(player->poisoncount > 100)
|
|
|
|
{
|
|
|
|
player->poisoncount = 100;
|
|
|
|
}
|
|
|
|
}
|
2009-06-07 09:41:22 +00:00
|
|
|
return true;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// P_PoisonDamage - Similar to P_DamageMobj
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void P_PoisonDamage (player_t *player, AActor *source, int damage,
|
|
|
|
bool playPainSound)
|
|
|
|
{
|
|
|
|
AActor *target;
|
|
|
|
|
2013-01-03 03:05:44 +00:00
|
|
|
if (player == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
target = player->mo;
|
|
|
|
if (target->health <= 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-10-28 03:29:10 +00:00
|
|
|
if ((damage < TELEFRAG_DAMAGE && ((target->flags2 & MF2_INVULNERABLE) ||
|
|
|
|
(player->cheats & CF_GODMODE))) || (player->cheats & CF_GODMODE2))
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // target is invulnerable
|
|
|
|
return;
|
|
|
|
}
|
2013-01-03 03:05:44 +00:00
|
|
|
// Take half damage in trainer mode
|
|
|
|
damage = FixedMul(damage, G_SkillProperty(SKILLP_DamageFactor));
|
2012-06-30 01:06:30 +00:00
|
|
|
// Handle passive damage modifiers (e.g. PowerProtection)
|
|
|
|
if (target->Inventory != NULL)
|
|
|
|
{
|
|
|
|
target->Inventory->ModifyDamage(damage, player->poisontype, damage, true);
|
|
|
|
}
|
2012-06-29 04:21:31 +00:00
|
|
|
// Modify with damage factors
|
2012-06-30 01:06:30 +00:00
|
|
|
damage = FixedMul(damage, target->DamageFactor);
|
2012-06-29 04:21:31 +00:00
|
|
|
if (damage > 0)
|
|
|
|
{
|
2012-06-30 01:06:30 +00:00
|
|
|
damage = DamageTypeDefinition::ApplyMobjDamageFactor(damage, player->poisontype, target->GetClass()->ActorInfo->DamageFactors);
|
|
|
|
}
|
|
|
|
if (damage <= 0)
|
|
|
|
{ // Damage was reduced to 0, so don't bother further.
|
|
|
|
return;
|
2012-06-29 04:21:31 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
if (damage >= player->health
|
2007-10-29 22:15:46 +00:00
|
|
|
&& (G_SkillProperty(SKILLP_AutoUseHealth) || deathmatch)
|
2006-02-24 04:48:15 +00:00
|
|
|
&& !player->morphTics)
|
|
|
|
{ // Try to use some inventory health
|
2012-03-23 20:57:10 +00:00
|
|
|
P_AutoUseHealth(player, damage - player->health+1);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
player->health -= damage; // mirror mobj health here for Dave
|
|
|
|
if (player->health < 50 && !deathmatch)
|
|
|
|
{
|
2012-03-23 20:57:10 +00:00
|
|
|
P_AutoUseStrifeHealth(player);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
if (player->health < 0)
|
|
|
|
{
|
|
|
|
player->health = 0;
|
|
|
|
}
|
|
|
|
player->attacker = source;
|
|
|
|
|
|
|
|
//
|
|
|
|
// do the damage
|
|
|
|
//
|
|
|
|
target->health -= damage;
|
|
|
|
if (target->health <= 0)
|
|
|
|
{ // Death
|
2014-11-06 04:05:21 +00:00
|
|
|
if ((((player->cheats & CF_BUDDHA) || (player->mo->flags7 & MF7_BUDDHA)) && damage < TELEFRAG_DAMAGE) || (player->cheats & CF_BUDDHA2))
|
2009-08-07 04:08:38 +00:00
|
|
|
{ // [SP] Save the player...
|
|
|
|
player->health = target->health = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
target->special1 = damage;
|
2012-03-23 20:57:10 +00:00
|
|
|
if (player && !player->morphTics)
|
2009-08-07 04:08:38 +00:00
|
|
|
{ // Check for flame death
|
2012-03-23 20:57:10 +00:00
|
|
|
if ((player->poisontype == NAME_Fire) && (target->health > -50) && (damage > 25))
|
2009-08-07 04:08:38 +00:00
|
|
|
{
|
|
|
|
target->DamageType = NAME_Fire;
|
|
|
|
}
|
2012-03-23 20:57:10 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
target->DamageType = player->poisontype;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2012-03-23 20:57:10 +00:00
|
|
|
target->Die(source, source);
|
2009-08-07 04:08:38 +00:00
|
|
|
return;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2006-10-31 14:53:21 +00:00
|
|
|
if (!(level.time&63) && playPainSound)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-03-23 20:57:10 +00:00
|
|
|
FState *painstate = target->FindState(NAME_Pain, player->poisonpaintype);
|
|
|
|
if (painstate != NULL)
|
|
|
|
{
|
|
|
|
target->SetState(painstate);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
if((P_Random() < target->info->painchance)
|
|
|
|
&& !(target->flags&MF_SKULLFLY))
|
|
|
|
{
|
|
|
|
target->flags |= MF_JUSTHIT; // fight back!
|
|
|
|
P_SetMobjState(target, target->info->painstate);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCMD (kill)
|
|
|
|
{
|
2006-04-17 13:53:34 +00:00
|
|
|
if (argv.argc() > 1)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-02-20 21:28:55 +00:00
|
|
|
if (CheckCheatmode ())
|
|
|
|
return;
|
|
|
|
|
2006-04-17 13:53:34 +00:00
|
|
|
if (!stricmp (argv[1], "monsters"))
|
|
|
|
{
|
|
|
|
// Kill all the monsters
|
|
|
|
if (CheckCheatmode ())
|
|
|
|
return;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-04-17 13:53:34 +00:00
|
|
|
Net_WriteByte (DEM_GENERICCHEAT);
|
|
|
|
Net_WriteByte (CHT_MASSACRE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-02-20 21:28:55 +00:00
|
|
|
Net_WriteByte (DEM_KILLCLASSCHEAT);
|
|
|
|
Net_WriteString (argv[1]);
|
2006-04-17 13:53:34 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-28 09:49:15 +00:00
|
|
|
// If suiciding is disabled, then don't do it.
|
|
|
|
if (dmflags2 & DF2_NOSUICIDE)
|
|
|
|
return;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// Kill the player
|
|
|
|
Net_WriteByte (DEM_SUICIDE);
|
|
|
|
}
|
|
|
|
C_HideConsole ();
|
|
|
|
}
|