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 "a_doomglobal.h"
|
|
|
|
#include "a_hereticglobal.h"
|
|
|
|
#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"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_obituary ("Obituary");
|
|
|
|
static FRandom pr_botrespawn ("BotRespawn");
|
|
|
|
static FRandom pr_killmobj ("ActorDie");
|
|
|
|
static FRandom pr_damagemobj ("ActorTakeDamage");
|
|
|
|
static FRandom pr_lightning ("LightningDamage");
|
|
|
|
static FRandom pr_poison ("PoisonDamage");
|
|
|
|
static FRandom pr_switcher ("SwitchTarget");
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (delta > toucher->height || delta < -32*FRACUNIT)
|
|
|
|
{ // 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.
|
|
|
|
if (toucher->player != NULL && toucher->player->isbot && special == toucher->player->dest)
|
|
|
|
{
|
|
|
|
toucher->player->prev = toucher->player->dest;
|
|
|
|
toucher->player->dest = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
//
|
|
|
|
void ClientObituary (AActor *self, AActor *inflictor, AActor *attacker)
|
|
|
|
{
|
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;
|
|
|
|
|
|
|
|
gender = self->player->userinfo.gender;
|
|
|
|
|
|
|
|
// Treat voodoo dolls as unknown deaths
|
|
|
|
if (inflictor && inflictor->player == self->player)
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
gender = self->player->userinfo.gender;
|
|
|
|
sprintf (gendermessage, "OB_FRIENDLY%c", '1' + (pr_obituary() & 3));
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
if (message == NULL && attacker->player->ReadyWeapon != NULL)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
{
|
2006-06-17 20:29:41 +00:00
|
|
|
message=GStrings[message+1];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
{
|
|
|
|
message = GStrings("OB_DEFAULT");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-06-17 20:29:41 +00:00
|
|
|
SexMessage (message, gendermessage, gender,
|
2006-06-21 12:10:36 +00:00
|
|
|
self->player->userinfo.netname, attacker->player->userinfo.netname);
|
2006-02-24 04:48:15 +00:00
|
|
|
Printf (PRINT_MEDIUM, "%s\n", gendermessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// KillMobj
|
|
|
|
//
|
|
|
|
EXTERN_CVAR (Int, fraglimit)
|
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
static int GibHealth(AActor *actor)
|
|
|
|
{
|
|
|
|
return -abs(
|
|
|
|
actor->GetClass()->Meta.GetMetaInt (
|
|
|
|
AMETA_GibHealth,
|
|
|
|
gameinfo.gametype == GAME_Doom ?
|
|
|
|
-actor->GetDefault()->health :
|
|
|
|
-actor->GetDefault()->health/2));
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
void AActor::Die (AActor *source, AActor *inflictor)
|
|
|
|
{
|
2008-05-22 19:35:38 +00:00
|
|
|
// Handle possible unmorph on death
|
|
|
|
bool wasgibbed = (health < GibHealth(this));
|
|
|
|
AActor *realthis = NULL;
|
|
|
|
int realstyle = 0;
|
|
|
|
int realhealth = 0;
|
|
|
|
if (P_MorphedDeath(this, &realthis, &realstyle, &realhealth))
|
|
|
|
{
|
|
|
|
if (!(realstyle & MORPH_UNDOBYDEATHSAVES))
|
|
|
|
{
|
|
|
|
if (wasgibbed)
|
|
|
|
{
|
|
|
|
int realgibhealth = GibHealth(realthis);
|
|
|
|
if (realthis->health >= realgibhealth)
|
|
|
|
{
|
|
|
|
realthis->health = realgibhealth -1; // if morphed was gibbed, so must original be (where allowed)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
realthis->Die(source, inflictor);
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
static int dieticks[MAXPLAYERS];
|
|
|
|
int pnum = this->player-players;
|
|
|
|
if (dieticks[pnum] == gametic)
|
|
|
|
gametic=gametic;
|
|
|
|
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;
|
2006-10-31 14:53:21 +00:00
|
|
|
if ((flags3 & MF3_ISMONSTER) || FindState(NAME_Raise) != NULL)
|
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.
|
2006-02-24 04:48:15 +00:00
|
|
|
flags |= MF_CORPSE;
|
|
|
|
}
|
|
|
|
// [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.
|
|
|
|
if (special && (!(flags & MF_SPECIAL) || (flags3 & MF3_ISMONSTER)))
|
|
|
|
{
|
|
|
|
LineSpecials[special] (NULL, level.flags & LEVEL_ACTOWNSPECIAL
|
|
|
|
? this : source, false, args[0], args[1], args[2], args[3], args[4]);
|
|
|
|
special = 0;
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
player->userinfo.gender, player->userinfo.netname,
|
|
|
|
player->userinfo.netname);
|
|
|
|
StatusBar->AttachMessage (new DHUDMessageFadeOut (buff,
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
SexMessage (GStrings("SPREEOVER"), buff, player->userinfo.gender,
|
|
|
|
player->userinfo.netname, source->player->userinfo.netname);
|
|
|
|
StatusBar->AttachMessage (new DHUDMessageFadeOut (buff,
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
SexMessage (spreemsg, buff, player->userinfo.gender,
|
|
|
|
player->userinfo.netname, source->player->userinfo.netname);
|
|
|
|
StatusBar->AttachMessage (new DHUDMessageFadeOut (buff,
|
|
|
|
1.5f, 0.2f, 0, 0, CR_WHITE, 3.f, 0.5f), MAKE_ID('K','S','P','R'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] Multikills
|
|
|
|
source->player->multicount++;
|
|
|
|
if (source->player->lastkilltime > 0)
|
|
|
|
{
|
|
|
|
if (source->player->lastkilltime < level.time - 3*TICRATE)
|
|
|
|
{
|
|
|
|
source->player->multicount = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (deathmatch &&
|
|
|
|
source->CheckLocalView (consoleplayer) &&
|
|
|
|
cl_showmultikills)
|
|
|
|
{
|
|
|
|
const char *multimsg;
|
|
|
|
|
|
|
|
switch (source->player->multicount)
|
|
|
|
{
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
SexMessage (multimsg, buff, player->userinfo.gender,
|
|
|
|
player->userinfo.netname, source->player->userinfo.netname);
|
|
|
|
StatusBar->AttachMessage (new DHUDMessageFadeOut (buff,
|
|
|
|
1.5f, 0.8f, 0, 0, CR_RED, 3.f, 0.5f), MAKE_ID('M','K','I','L'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
source->player->lastkilltime = level.time;
|
|
|
|
|
|
|
|
// [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++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (player)
|
|
|
|
{
|
|
|
|
// [RH] Death messages
|
|
|
|
ClientObituary (this, inflictor, source);
|
|
|
|
|
|
|
|
// 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
|
2008-03-28 00:38:17 +00:00
|
|
|
if (bglobal.botnum && consoleplayer == Net_Arbitrator && !demoplayback)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (player->isbot)
|
2008-03-28 00:38:17 +00:00
|
|
|
player->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++)
|
|
|
|
{
|
|
|
|
if (players[i].isbot && this == players[i].enemy)
|
|
|
|
{
|
|
|
|
if (players[i].dest == players[i].enemy)
|
|
|
|
players[i].dest = NULL;
|
|
|
|
players[i].enemy = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2006-10-31 14:53:21 +00:00
|
|
|
|
|
|
|
if (DamageType != NAME_None)
|
|
|
|
{
|
2006-12-16 14:06:21 +00:00
|
|
|
diestate = FindState (NAME_Death, DamageType, true);
|
2006-10-31 14:53:21 +00:00
|
|
|
if (diestate == NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
if (DamageType == NAME_Ice)
|
|
|
|
{ // 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)))
|
|
|
|
{
|
|
|
|
diestate = &AActor::States[S_GENERICFREEZEDEATH];
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
{
|
2007-05-12 11:14:09 +00:00
|
|
|
int flags4 = inflictor == NULL ? 0 : inflictor->flags4;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
int gibhealth = GibHealth(this);
|
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.
|
2008-03-04 00:56:22 +00:00
|
|
|
if (DamageType != NAME_Massacre)
|
|
|
|
{
|
|
|
|
DamageType = NAME_None;
|
|
|
|
}
|
2006-10-31 15:24:22 +00:00
|
|
|
|
2008-03-04 00:56:22 +00:00
|
|
|
if ((health < gibhealth || flags4 & MF4_EXTREMEDEATH) && !(flags4 & MF4_NOEXTREMEDEATH))
|
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);
|
2008-03-04 00:56:22 +00:00
|
|
|
// If a non-player, mark as extremely dead for the crash state.
|
|
|
|
if (diestate != NULL && player == NULL && health >= gibhealth)
|
|
|
|
{
|
|
|
|
health = gibhealth - 1;
|
|
|
|
}
|
|
|
|
// For players, mark the appropriate flag.
|
|
|
|
else if (player != NULL)
|
|
|
|
{
|
|
|
|
player->cheats |= CF_EXTREMELYDEAD;
|
|
|
|
}
|
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
|
2006-10-31 14:53:21 +00:00
|
|
|
diestate = FindState (NAME_Death);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-31 14:53:21 +00:00
|
|
|
if (diestate != NULL)
|
|
|
|
{
|
|
|
|
SetState (diestate);
|
|
|
|
|
|
|
|
tics -= pr_killmobj() & 3;
|
|
|
|
if (tics < 1)
|
|
|
|
tics = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Destroy();
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// PROC P_AutoUseHealth
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void P_AutoUseHealth(player_t *player, int saveHealth)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int count;
|
2006-05-10 02:40:43 +00:00
|
|
|
const PClass *normalType = PClass::FindClass (NAME_ArtiHealth);
|
|
|
|
const PClass *superType = PClass::FindClass (NAME_ArtiSuperHealth);
|
2006-02-24 04:48:15 +00:00
|
|
|
AInventory *normalItem = player->mo->FindInventory (normalType);
|
|
|
|
AInventory *superItem = player->mo->FindInventory (superType);
|
|
|
|
int normalAmount, superAmount;
|
|
|
|
|
|
|
|
normalAmount = normalItem != NULL ? normalItem->Amount : 0;
|
|
|
|
superAmount = superItem != NULL ? superItem->Amount : 0;
|
|
|
|
|
2007-10-29 22:15:46 +00:00
|
|
|
bool skilluse = !!G_SkillProperty(SKILLP_AutoUseHealth);
|
|
|
|
|
|
|
|
if (skilluse && (normalAmount*25 >= saveHealth))
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Use quartz flasks
|
|
|
|
count = (saveHealth+24)/25;
|
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
player->health += 25;
|
|
|
|
if (--normalItem->Amount == 0)
|
|
|
|
{
|
|
|
|
normalItem->Destroy ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (superAmount*100 >= saveHealth)
|
|
|
|
{ // Use mystic urns
|
|
|
|
count = (saveHealth+99)/100;
|
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
player->health += 100;
|
|
|
|
if (--superItem->Amount == 0)
|
|
|
|
{
|
|
|
|
superItem->Destroy ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-29 22:15:46 +00:00
|
|
|
else if (skilluse
|
2006-02-24 04:48:15 +00:00
|
|
|
&& (superAmount*100+normalAmount*25 >= saveHealth))
|
|
|
|
{ // Use mystic urns and quartz flasks
|
|
|
|
count = (saveHealth+24)/25;
|
|
|
|
saveHealth -= count*25;
|
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
player->health += 25;
|
|
|
|
if (--normalItem->Amount == 0)
|
|
|
|
{
|
|
|
|
normalItem->Destroy ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
count = (saveHealth+99)/100;
|
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
player->health += 100;
|
|
|
|
if (--superItem->Amount == 0)
|
|
|
|
{
|
|
|
|
superItem->Destroy ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
player->mo->health = player->health;
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// P_AutoUseStrifeHealth
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void P_AutoUseStrifeHealth (player_t *player)
|
|
|
|
{
|
2006-05-10 02:40:43 +00:00
|
|
|
static const ENamedName healthnames[2] = { NAME_MedicalKit, NAME_MedPatch };
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 2; ++i)
|
|
|
|
{
|
2006-05-10 02:40:43 +00:00
|
|
|
const PClass *type = PClass::FindClass (healthnames[i]);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
while (player->health < 50)
|
|
|
|
{
|
|
|
|
AInventory *item = player->mo->FindInventory (type);
|
|
|
|
if (item == NULL)
|
|
|
|
break;
|
|
|
|
if (!player->mo->UseInventory (item))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
=
|
|
|
|
= 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
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2006-10-31 14:53:21 +00:00
|
|
|
void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, FName mod, int flags)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
unsigned ang;
|
|
|
|
player_t *player;
|
|
|
|
fixed_t thrust;
|
|
|
|
int temp;
|
|
|
|
|
|
|
|
if (target == NULL || !(target->flags & MF_SHOOTABLE))
|
|
|
|
{ // Shouldn't happen
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Spectral targets only take damage from spectral projectiles.
|
|
|
|
if (target->flags4 & MF4_SPECTRAL && damage < 1000000)
|
|
|
|
{
|
|
|
|
if (inflictor == NULL || !(inflictor->flags4 & MF4_SPECTRAL))
|
|
|
|
{
|
2006-04-13 16:52:24 +00:00
|
|
|
/*
|
2006-02-24 04:48:15 +00:00
|
|
|
if (target->MissileState != NULL)
|
|
|
|
{
|
|
|
|
target->SetState (target->MissileState);
|
|
|
|
}
|
2006-04-13 16:52:24 +00:00
|
|
|
*/
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (target->flags & MF_ICECORPSE) // frozen
|
|
|
|
{
|
|
|
|
target->tics = 1;
|
|
|
|
target->momx = target->momy = target->momz = 0;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((target->flags2 & MF2_INVULNERABLE) && damage < 1000000)
|
|
|
|
{ // actor is invulnerable
|
|
|
|
if (!target->player)
|
|
|
|
{
|
|
|
|
if (!inflictor || !(inflictor->flags3 & MF3_FOILINVUL))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Only in Hexen invulnerable players are excluded from getting
|
|
|
|
// thrust by damage.
|
|
|
|
if (gameinfo.gametype == GAME_Hexen) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2006-10-22 10:32:41 +00:00
|
|
|
if (inflictor != NULL)
|
|
|
|
{
|
|
|
|
if (inflictor->flags5 & MF5_PIERCEARMOR) flags |= DMG_NO_ARMOR;
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
target->momx = target->momy = target->momz = 0;
|
|
|
|
}
|
|
|
|
if (target->flags2 & MF2_DORMANT)
|
|
|
|
{
|
|
|
|
// Invulnerable, and won't wake up
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
player = target->player;
|
2007-10-29 22:15:46 +00:00
|
|
|
if (player && damage > 1)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// Take half damage in trainer mode
|
2007-10-29 22:15:46 +00:00
|
|
|
damage = FixedMul(damage, G_SkillProperty(SKILLP_DamageFactor));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
// Special damage types
|
|
|
|
if (inflictor)
|
|
|
|
{
|
|
|
|
if (inflictor->flags4 & MF4_SPECTRAL)
|
|
|
|
{
|
|
|
|
if (player != NULL)
|
|
|
|
{
|
|
|
|
if (inflictor->health == -1)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (target->flags4 & MF4_SPECTRAL)
|
|
|
|
{
|
|
|
|
if (inflictor->health == -2)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2007-04-28 09:06:32 +00:00
|
|
|
|
2007-05-10 22:22:38 +00:00
|
|
|
damage = inflictor->DoSpecialDamage (target, damage);
|
|
|
|
if (damage == -1)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2007-05-10 22:22:38 +00:00
|
|
|
return;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2007-05-10 22:22:38 +00:00
|
|
|
|
2007-07-12 15:15:57 +00:00
|
|
|
}
|
|
|
|
// Handle active damage modifiers (e.g. PowerDamage)
|
|
|
|
if (source != NULL && source->Inventory != NULL)
|
|
|
|
{
|
|
|
|
int olddam = damage;
|
|
|
|
source->Inventory->ModifyDamage(olddam, mod, damage, false);
|
|
|
|
if (olddam != damage && damage <= 0) return;
|
2007-05-10 22:22:38 +00:00
|
|
|
}
|
|
|
|
// Handle passive damage modifiers (e.g. PowerProtection)
|
|
|
|
if (target->Inventory != NULL)
|
|
|
|
{
|
2007-05-12 11:14:09 +00:00
|
|
|
int olddam = damage;
|
2007-05-10 22:22:38 +00:00
|
|
|
target->Inventory->ModifyDamage(olddam, mod, damage, true);
|
|
|
|
if (olddam != damage && damage <= 0) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// to be removed and replaced by an actual damage factor
|
|
|
|
// once the actors using it are converted to DECORATE.
|
|
|
|
if (mod == NAME_Fire && target->flags4 & MF4_FIRERESIST)
|
|
|
|
{
|
|
|
|
damage /= 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DmgFactors * df = target->GetClass()->ActorInfo->DamageFactors;
|
|
|
|
if (df != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2007-05-10 22:22:38 +00:00
|
|
|
fixed_t * pdf = df->CheckKey(mod);
|
|
|
|
if (pdf != NULL)
|
|
|
|
{
|
|
|
|
damage = FixedMul(damage, *pdf);
|
|
|
|
if (damage <= 0) return;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-10 22:22:38 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
damage = target->TakeSpecialDamage (inflictor, source, damage, mod);
|
2007-05-10 22:22:38 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (damage == -1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Push the target unless the source's weapon's kickback is 0.
|
|
|
|
// (i.e. Guantlets/Chainsaw)
|
|
|
|
if (inflictor && inflictor != target // [RH] Not if hurting own self
|
|
|
|
&& !(target->flags & MF_NOCLIP)
|
2008-06-02 16:56:53 +00:00
|
|
|
&& !(inflictor->flags2 & MF2_NODMGTHRUST)
|
|
|
|
&& !(flags & DMG_THRUSTLESS))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int kickback;
|
|
|
|
|
|
|
|
if (!source || !source->player || !source->player->ReadyWeapon)
|
|
|
|
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;
|
|
|
|
|
|
|
|
ang = R_PointToAngle2 (origin->x, origin->y,
|
2006-02-24 04:48:15 +00:00
|
|
|
target->x, target->y);
|
|
|
|
thrust = damage*(FRACUNIT>>3)*kickback / target->Mass;
|
|
|
|
// [RH] If thrust overflows, use a more reasonable amount
|
|
|
|
if (thrust < 0 || thrust > 10*FRACUNIT)
|
|
|
|
{
|
|
|
|
thrust = 10*FRACUNIT;
|
|
|
|
}
|
|
|
|
// 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
|
|
|
|
&& !(target->flags & MF_NOGRAVITY))
|
|
|
|
{
|
|
|
|
ang += ANG180;
|
|
|
|
thrust *= 4;
|
|
|
|
}
|
|
|
|
ang >>= ANGLETOFINESHIFT;
|
|
|
|
if (source && source->player && (source == inflictor)
|
|
|
|
&& source->player->ReadyWeapon != NULL &&
|
|
|
|
(source->player->ReadyWeapon->WeaponFlags & WIF_STAFF2_KICKBACK))
|
|
|
|
{
|
|
|
|
// Staff power level 2
|
|
|
|
target->momx += FixedMul (10*FRACUNIT, finecosine[ang]);
|
|
|
|
target->momy += FixedMul (10*FRACUNIT, finesine[ang]);
|
|
|
|
if (!(target->flags & MF_NOGRAVITY))
|
|
|
|
{
|
|
|
|
target->momz += 5*FRACUNIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
target->momx += FixedMul (thrust, finecosine[ang]);
|
|
|
|
target->momy += FixedMul (thrust, finesine[ang]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// player specific
|
|
|
|
//
|
|
|
|
if (player)
|
|
|
|
{
|
|
|
|
if ((target->flags2 & MF2_INVULNERABLE) && damage < 1000000)
|
|
|
|
{ // player is invulnerable, so don't hurt him
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Added by MC: Lets bots look allround for enemies if they survive an ambush.
|
|
|
|
if (player->isbot)
|
|
|
|
{
|
|
|
|
player->allround = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// end of game hell hack
|
|
|
|
if ((target->Sector->special & 255) == dDamage_End
|
|
|
|
&& damage >= target->health)
|
|
|
|
{
|
|
|
|
damage = target->health - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (damage < 1000 && ((target->player->cheats & CF_GODMODE)
|
|
|
|
|| (target->player->mo->flags2 & MF2_INVULNERABLE)))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] Avoid friendly fire if enabled
|
|
|
|
if (source != NULL && player != source->player && target->IsTeammate (source))
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
FriendlyFire = true;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (damage < 1000000)
|
|
|
|
{ // Still allow telefragging :-(
|
2007-12-22 22:04:20 +00:00
|
|
|
damage = (int)((float)damage * level.teamdamage);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (damage <= 0)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!(flags & DMG_NO_ARMOR) && player->mo->Inventory != NULL)
|
|
|
|
{
|
|
|
|
int newdam = damage;
|
|
|
|
player->mo->Inventory->AbsorbDamage (damage, mod, newdam);
|
|
|
|
damage = newdam;
|
|
|
|
if (damage <= 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
P_AutoUseHealth (player, damage - player->health + 1);
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
if (player->health < 50 && !deathmatch)
|
|
|
|
{
|
|
|
|
P_AutoUseStrifeHealth (player);
|
|
|
|
player->mo->health = player->health;
|
|
|
|
}
|
|
|
|
if (player->health < 0)
|
|
|
|
{
|
|
|
|
player->health = 0;
|
|
|
|
}
|
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
|
|
|
|
{
|
|
|
|
target->health -= damage;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// the damage has been dealt; now deal with the consequences
|
|
|
|
//
|
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.
|
|
|
|
if ( source && source->player && source->player->cheats & CF_DRAIN)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{ // Death
|
|
|
|
target->special1 = damage;
|
|
|
|
// check for special fire damage or ice damage deaths
|
2006-10-31 14:53:21 +00:00
|
|
|
if (mod == NAME_Fire)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (player && !player->morphTics)
|
|
|
|
{ // Check for flame death
|
|
|
|
if (!inflictor ||
|
|
|
|
((target->health > -50) && (damage > 25)) ||
|
|
|
|
!inflictor->IsKindOf (RUNTIME_CLASS(APhoenixFX1)))
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
target->DamageType = NAME_Fire;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
target->DamageType = NAME_Fire;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
target->DamageType = mod;
|
|
|
|
}
|
|
|
|
if (source && source->tracer && source->IsKindOf (RUNTIME_CLASS (AMinotaur)))
|
|
|
|
{ // 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
target->Die (source, inflictor);
|
|
|
|
return;
|
|
|
|
}
|
2006-10-31 14:53:21 +00:00
|
|
|
|
2006-12-16 14:06:21 +00:00
|
|
|
FState * 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);
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2007-05-26 10:50:32 +00:00
|
|
|
|
|
|
|
PainChanceList * pc = target->GetClass()->ActorInfo->PainChances;
|
|
|
|
int painchance = target->PainChance;
|
|
|
|
if (pc != NULL)
|
|
|
|
{
|
|
|
|
BYTE * ppc = pc->CheckKey(mod);
|
|
|
|
if (ppc != NULL)
|
|
|
|
{
|
|
|
|
painchance = *ppc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(target->flags5 & MF5_NOPAIN) && (pr_damagemobj() < painchance) && !(target->flags & MF_SKULLFLY))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (inflictor && inflictor->IsKindOf (RUNTIME_CLASS(ALightning)))
|
|
|
|
{
|
|
|
|
if (pr_lightning() < 96)
|
|
|
|
{
|
|
|
|
target->flags |= MF_JUSTHIT; // fight back!
|
2006-12-16 14:06:21 +00:00
|
|
|
FState * painstate = target->FindState(NAME_Pain, mod);
|
2006-10-31 14:53:21 +00:00
|
|
|
if (painstate != NULL) target->SetState (painstate);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // "electrocute" the target
|
|
|
|
target->renderflags |= RF_FULLBRIGHT;
|
|
|
|
if ((target->flags3 & MF3_ISMONSTER) && pr_lightning() < 128)
|
|
|
|
{
|
|
|
|
target->Howl ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
target->flags |= MF_JUSTHIT; // fight back!
|
2006-12-16 14:06:21 +00:00
|
|
|
FState * painstate = target->FindState(NAME_Pain, mod);
|
2006-10-31 14:53:21 +00:00
|
|
|
if (painstate != NULL) target->SetState (painstate);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (inflictor && inflictor->IsKindOf (RUNTIME_CLASS(APoisonCloud)))
|
|
|
|
{
|
|
|
|
if ((target->flags3 & MF3_ISMONSTER) && pr_poison() < 128)
|
|
|
|
{
|
|
|
|
target->Howl ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AActor::OkayToSwitchTarget (AActor *other)
|
|
|
|
{
|
|
|
|
if (other == this)
|
|
|
|
return false; // [RH] Don't hate self (can happen when shooting barrels)
|
|
|
|
|
|
|
|
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;
|
|
|
|
else if (level.flags & LEVEL_TOTALINFIGHTING) infight=1;
|
|
|
|
else if (level.flags & LEVEL_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
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void P_PoisonPlayer (player_t *player, AActor *poisoner, AActor *source, int poison)
|
|
|
|
{
|
|
|
|
if((player->cheats&CF_GODMODE) || (player->mo->flags2 & MF2_INVULNERABLE))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
player->poisoner = poisoner;
|
|
|
|
if(player->poisoncount > 100)
|
|
|
|
{
|
|
|
|
player->poisoncount = 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// P_PoisonDamage - Similar to P_DamageMobj
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void P_PoisonDamage (player_t *player, AActor *source, int damage,
|
|
|
|
bool playPainSound)
|
|
|
|
{
|
|
|
|
AActor *target;
|
|
|
|
AActor *inflictor;
|
|
|
|
|
|
|
|
target = player->mo;
|
|
|
|
inflictor = source;
|
|
|
|
if (target->health <= 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (target->flags2&MF2_INVULNERABLE && damage < 1000000)
|
|
|
|
{ // target is invulnerable
|
|
|
|
return;
|
|
|
|
}
|
2007-10-29 22:15:46 +00:00
|
|
|
if (player)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// Take half damage in trainer mode
|
2007-10-29 22:15:46 +00:00
|
|
|
damage = FixedMul(damage, G_SkillProperty(SKILLP_DamageFactor));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
if(damage < 1000 && ((player->cheats&CF_GODMODE)
|
|
|
|
|| (player->mo->flags2 & MF2_INVULNERABLE)))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
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
|
|
|
|
P_AutoUseHealth (player, damage - player->health+1);
|
|
|
|
}
|
|
|
|
player->health -= damage; // mirror mobj health here for Dave
|
|
|
|
if (player->health < 50 && !deathmatch)
|
|
|
|
{
|
|
|
|
P_AutoUseStrifeHealth (player);
|
|
|
|
}
|
|
|
|
if (player->health < 0)
|
|
|
|
{
|
|
|
|
player->health = 0;
|
|
|
|
}
|
|
|
|
player->attacker = source;
|
|
|
|
|
|
|
|
//
|
|
|
|
// do the damage
|
|
|
|
//
|
|
|
|
target->health -= damage;
|
|
|
|
if (target->health <= 0)
|
|
|
|
{ // Death
|
|
|
|
target->special1 = damage;
|
|
|
|
if (player && inflictor && !player->morphTics)
|
|
|
|
{ // Check for flame death
|
2006-10-31 14:53:21 +00:00
|
|
|
if ((inflictor->DamageType == NAME_Fire)
|
2006-02-24 04:48:15 +00:00
|
|
|
&& (target->health > -50) && (damage > 25))
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
target->DamageType = NAME_Fire;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-10-31 14:53:21 +00:00
|
|
|
else target->DamageType = inflictor->DamageType;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
target->Die (source, source);
|
|
|
|
return;
|
|
|
|
}
|
2006-10-31 14:53:21 +00:00
|
|
|
if (!(level.time&63) && playPainSound)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-12-16 14:06:21 +00:00
|
|
|
FState * painstate = target->FindState(NAME_Pain, target->DamageType);
|
2006-10-31 14:53:21 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
bool CheckCheatmode ();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
// Kill the player
|
|
|
|
Net_WriteByte (DEM_SUICIDE);
|
|
|
|
}
|
|
|
|
C_HideConsole ();
|
|
|
|
}
|