- P_DamageMobj() now returns the amount of damage actually done so that the bleed functions

can perform based on the amount of damage actually taken after all modifications are done to
  it. However, if the damage is canceled away, blood will still spawn for the original damage
  amount rather than the modified amount.

SVN r4012 (trunk)
This commit is contained in:
Randy Heit 2013-01-02 04:39:59 +00:00
parent 60fb004a78
commit 549712e719
26 changed files with 148 additions and 136 deletions

View file

@ -123,8 +123,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileAttack)
return; return;
S_Sound (self, CHAN_WEAPON, snd, 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, snd, 1, ATTN_NORM);
P_TraceBleed (dmg, target); int newdam = P_DamageMobj (target, self, self, dmg, NAME_None);
P_DamageMobj (target, self, self, dmg, NAME_None); P_TraceBleed (newdam > 0 ? newdam : dmg, target);
an = self->angle >> ANGLETOFINESHIFT; an = self->angle >> ANGLETOFINESHIFT;
fire = self->tracer; fire = self->tracer;

View file

@ -10,8 +10,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_BruisAttack)
{ {
int damage = (pr_bruisattack()%8+1)*10; int damage = (pr_bruisattack()%8+1)*10;
S_Sound (self, CHAN_WEAPON, "baron/melee", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "baron/melee", 1, ATTN_NORM);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
return; return;
} }

View file

@ -22,8 +22,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_HeadAttack)
{ {
int damage = (pr_headattack()%6+1)*10; int damage = (pr_headattack()%6+1)*10;
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
return; return;
} }

View file

@ -20,7 +20,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SargAttack)
if (self->CheckMeleeRange ()) if (self->CheckMeleeRange ())
{ {
int damage = ((pr_sargattack()%10)+1)*4; int damage = ((pr_sargattack()%10)+1)*4;
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
} }
} }

View file

@ -25,8 +25,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_TroopAttack)
{ {
int damage = (pr_troopattack()%8+1)*3; int damage = (pr_troopattack()%8+1)*3;
S_Sound (self, CHAN_WEAPON, "imp/melee", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "imp/melee", 1, ATTN_NORM);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
return; return;
} }

View file

@ -584,8 +584,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
damage += (pr_bfgspray() & 7) + 1; damage += (pr_bfgspray() & 7) + 1;
thingToHit = linetarget; thingToHit = linetarget;
P_DamageMobj (thingToHit, self->target, self->target, damage, spray != NULL? FName(spray->DamageType) : FName(NAME_BFGSplash)); int newdam = P_DamageMobj (thingToHit, self->target, self->target, damage, spray != NULL? FName(spray->DamageType) : FName(NAME_BFGSplash));
P_TraceBleed (damage, thingToHit, self->target); P_TraceBleed (newdam > 0 ? newdam : damage, thingToHit, self->target);
} }
} }

View file

@ -146,7 +146,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkelFist)
{ {
int damage = ((pr_skelfist()%10)+1)*6; int damage = ((pr_skelfist()%10)+1)*6;
S_Sound (self, CHAN_WEAPON, "skeleton/melee", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "skeleton/melee", 1, ATTN_NORM);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
} }
} }

View file

@ -73,8 +73,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_ChicAttack)
if (self->CheckMeleeRange()) if (self->CheckMeleeRange())
{ {
int damage = 1 + (pr_chicattack() & 1); int damage = 1 + (pr_chicattack() & 1);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
} }
} }

View file

@ -70,8 +70,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Srcr1Attack)
if (self->CheckMeleeRange ()) if (self->CheckMeleeRange ())
{ {
int damage = pr_scrc1atk.HitDice (8); int damage = pr_scrc1atk.HitDice (8);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
return; return;
} }
@ -203,8 +203,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Srcr2Attack)
if (self->CheckMeleeRange()) if (self->CheckMeleeRange())
{ {
int damage = pr_s2a.HitDice (20); int damage = pr_s2a.HitDice (20);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
return; return;
} }
chance = self->health < self->SpawnHealth()/2 ? 96 : 48; chance = self->health < self->SpawnHealth()/2 ? 96 : 48;

View file

@ -83,8 +83,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichAttack)
if (self->CheckMeleeRange ()) if (self->CheckMeleeRange ())
{ {
int damage = pr_atk.HitDice (6); int damage = pr_atk.HitDice (6);
P_DamageMobj (target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, target, self); P_TraceBleed (newdam > 0 ? newdam : damage, target, self);
return; return;
} }
dist = P_AproxDistance (self->x-target->x, self->y-target->y) dist = P_AproxDistance (self->x-target->x, self->y-target->y)

View file

@ -47,8 +47,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_KnightAttack)
if (self->CheckMeleeRange ()) if (self->CheckMeleeRange ())
{ {
int damage = pr_knightatk.HitDice (3); int damage = pr_knightatk.HitDice (3);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
S_Sound (self, CHAN_BODY, "hknight/melee", 1, ATTN_NORM); S_Sound (self, CHAN_BODY, "hknight/melee", 1, ATTN_NORM);
return; return;
} }

View file

@ -69,8 +69,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_WizAtk3)
if (self->CheckMeleeRange()) if (self->CheckMeleeRange())
{ {
int damage = pr_wizatk3.HitDice (4); int damage = pr_wizatk3.HitDice (4);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
return; return;
} }
const PClass *fx = PClass::FindClass("WizardFX1"); const PClass *fx = PClass::FindClass("WizardFX1");

View file

@ -32,8 +32,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopAttack)
if (self->CheckMeleeRange()) if (self->CheckMeleeRange())
{ {
int damage = pr_atk.HitDice (4); int damage = pr_atk.HitDice (4);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
return; return;
} }
self->special1 = (pr_atk() & 3) + 5; self->special1 = (pr_atk() & 3) + 5;

View file

@ -87,8 +87,8 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax)
if (actor->CheckMeleeRange ()) if (actor->CheckMeleeRange ())
{ {
int damage = pr_dragonseek.HitDice (10); int damage = pr_dragonseek.HitDice (10);
P_DamageMobj (actor->target, actor, actor, damage, NAME_Melee); int newdam = P_DamageMobj (actor->target, actor, actor, damage, NAME_Melee);
P_TraceBleed (damage, actor->target, actor); P_TraceBleed (newdam > 0 ? newdam : damage, actor->target, actor);
S_Sound (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM); S_Sound (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
} }
else if (pr_dragonseek() < 128 && P_CheckMissileRange(actor)) else if (pr_dragonseek() < 128 && P_CheckMissileRange(actor))
@ -201,8 +201,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFlight)
if (abs(self->angle-angle) < ANGLE_45/2 && self->CheckMeleeRange()) if (abs(self->angle-angle) < ANGLE_45/2 && self->CheckMeleeRange())
{ {
int damage = pr_dragonflight.HitDice (8); int damage = pr_dragonflight.HitDice (8);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
} }
else if (abs(self->angle-angle) <= ANGLE_1*20) else if (abs(self->angle-angle) <= ANGLE_1*20)

View file

@ -174,8 +174,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentMeleeAttack)
if (self->CheckMeleeRange ()) if (self->CheckMeleeRange ())
{ {
int damage = pr_serpentmeattack.HitDice (5); int damage = pr_serpentmeattack.HitDice (5);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
S_Sound (self, CHAN_BODY, "SerpentMeleeHit", 1, ATTN_NORM); S_Sound (self, CHAN_BODY, "SerpentMeleeHit", 1, ATTN_NORM);
} }
if (pr_serpentmeattack() < 96) if (pr_serpentmeattack() < 96)

View file

@ -154,8 +154,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_ThrustImpale)
if (thing == self) if (thing == self)
continue; // don't clip against self continue; // don't clip against self
P_DamageMobj (thing, self, self, 10001, NAME_Crush); int newdam = P_DamageMobj (thing, self, self, 10001, NAME_Crush);
P_TraceBleed (10001, thing); P_TraceBleed (newdam > 0 ? newdam : 10001, thing);
self->args[1] = 1; // Mark thrust thing as bloody self->args[1] = 1; // Mark thrust thing as bloody
} }
} }

View file

@ -149,8 +149,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk1)
if (self->CheckMeleeRange()) if (self->CheckMeleeRange())
{ {
int damage = pr_minotauratk1.HitDice (4); int damage = pr_minotauratk1.HitDice (4);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
if ((player = self->target->player) != NULL && if ((player = self->target->player) != NULL &&
player->mo == self->target) player->mo == self->target)
{ // Squish the player { // Squish the player
@ -281,8 +281,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk2)
{ {
int damage; int damage;
damage = pr_atk.HitDice (friendly ? 3 : 5); damage = pr_atk.HitDice (friendly ? 3 : 5);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
return; return;
} }
z = self->z + 40*FRACUNIT; z = self->z + 40*FRACUNIT;
@ -327,8 +327,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk3)
int damage; int damage;
damage = pr_minotauratk3.HitDice (friendly ? 3 : 5); damage = pr_minotauratk3.HitDice (friendly ? 3 : 5);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
if ((player = self->target->player) != NULL && if ((player = self->target->player) != NULL &&
player->mo == self->target) player->mo == self->target)
{ // Squish the player { // Squish the player
@ -396,8 +396,8 @@ void P_MinotaurSlam (AActor *source, AActor *target)
target->velx += FixedMul (thrust, finecosine[angle]); target->velx += FixedMul (thrust, finecosine[angle]);
target->vely += FixedMul (thrust, finesine[angle]); target->vely += FixedMul (thrust, finesine[angle]);
damage = pr_minotaurslam.HitDice (static_cast<AMinotaur *>(source) ? 4 : 6); damage = pr_minotaurslam.HitDice (static_cast<AMinotaur *>(source) ? 4 : 6);
P_DamageMobj (target, NULL, NULL, damage, NAME_Melee); int newdam = P_DamageMobj (target, NULL, NULL, damage, NAME_Melee);
P_TraceBleed (damage, target, angle, 0); P_TraceBleed (newdam > 0 ? newdam : damage, target, angle, 0);
if (target->player) if (target->player)
{ {
target->reactiontime = 14+(pr_minotaurslam()&7); target->reactiontime = 14+(pr_minotaurslam()&7);

View file

@ -1503,7 +1503,7 @@ void APowerDamage::EndEffect( )
//=========================================================================== //===========================================================================
// //
// APowerDamage :: AbsorbDamage // APowerDamage :: ModifyDamage
// //
//=========================================================================== //===========================================================================

View file

@ -87,8 +87,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_ProgrammerMelee)
S_Sound (self, CHAN_WEAPON, "programmer/clank", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "programmer/clank", 1, ATTN_NORM);
damage = ((pr_prog() % 10) + 1) * 6; damage = ((pr_prog() % 10) + 1) * 6;
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
} }
//============================================================================ //============================================================================

View file

@ -59,8 +59,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_StalkerAttack)
{ {
int damage = (pr_stalker() & 7) * 2 + 2; int damage = (pr_stalker() & 7) * 2 + 2;
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
} }
} }
} }

View file

@ -888,7 +888,9 @@ static inline bool MustForcePain(AActor *target, AActor *inflictor)
} }
void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, FName mod, int flags) // 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)
{ {
unsigned ang; unsigned ang;
player_t *player = NULL; player_t *player = NULL;
@ -901,7 +903,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
if (target == NULL || !((target->flags & MF_SHOOTABLE) || (target->flags6 & MF6_VULNERABLE))) if (target == NULL || !((target->flags & MF_SHOOTABLE) || (target->flags6 & MF6_VULNERABLE)))
{ // Shouldn't happen { // Shouldn't happen
return; return -1;
} }
// Spectral targets only take damage from spectral projectiles. // Spectral targets only take damage from spectral projectiles.
@ -909,14 +911,14 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
{ {
if (inflictor == NULL || !(inflictor->flags4 & MF4_SPECTRAL)) if (inflictor == NULL || !(inflictor->flags4 & MF4_SPECTRAL))
{ {
return; return -1;
} }
} }
if (target->health <= 0) if (target->health <= 0)
{ {
if (inflictor && mod == NAME_Ice) if (inflictor && mod == NAME_Ice)
{ {
return; return -1;
} }
else if (target->flags & MF_ICECORPSE) // frozen else if (target->flags & MF_ICECORPSE) // frozen
{ {
@ -924,7 +926,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
target->flags6 |= MF6_SHATTERING; target->flags6 |= MF6_SHATTERING;
target->velx = target->vely = target->velz = 0; target->velx = target->vely = target->velz = 0;
} }
return; return -1;
} }
if ((target->flags2 & MF2_INVULNERABLE) && damage < TELEFRAG_DAMAGE && !(flags & DMG_FORCED)) if ((target->flags2 & MF2_INVULNERABLE) && damage < TELEFRAG_DAMAGE && !(flags & DMG_FORCED))
{ // actor is invulnerable { // actor is invulnerable
@ -932,7 +934,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
{ {
if (inflictor == NULL || !(inflictor->flags3 & MF3_FOILINVUL)) if (inflictor == NULL || !(inflictor->flags3 & MF3_FOILINVUL))
{ {
return; return -1;
} }
} }
else else
@ -940,7 +942,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
// Players are optionally excluded from getting thrust by damage. // Players are optionally excluded from getting thrust by damage.
if (static_cast<APlayerPawn *>(target)->PlayerFlags & PPF_NOTHRUSTWHENINVUL) if (static_cast<APlayerPawn *>(target)->PlayerFlags & PPF_NOTHRUSTWHENINVUL)
{ {
return; return -1;
} }
} }
@ -968,7 +970,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
if (target->flags2 & MF2_DORMANT) if (target->flags2 & MF2_DORMANT)
{ {
// Invulnerable, and won't wake up // Invulnerable, and won't wake up
return; return -1;
} }
player = target->player; player = target->player;
if (player && damage > 1 && damage < TELEFRAG_DAMAGE) if (player && damage > 1 && damage < TELEFRAG_DAMAGE)
@ -984,19 +986,19 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
if (player != NULL) if (player != NULL)
{ {
if (!deathmatch && inflictor->FriendPlayer > 0) if (!deathmatch && inflictor->FriendPlayer > 0)
return; return -1;
} }
else if (target->flags4 & MF4_SPECTRAL) else if (target->flags4 & MF4_SPECTRAL)
{ {
if (inflictor->FriendPlayer == 0 && !target->IsHostile(inflictor)) if (inflictor->FriendPlayer == 0 && !target->IsHostile(inflictor))
return; return -1;
} }
} }
damage = inflictor->DoSpecialDamage (target, damage, mod); damage = inflictor->DoSpecialDamage (target, damage, mod);
if (damage == -1) if (damage == -1)
{ {
return; return -1;
} }
} }
// Handle active damage modifiers (e.g. PowerDamage) // Handle active damage modifiers (e.g. PowerDamage)
@ -1010,7 +1012,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
{ {
goto dopain; goto dopain;
} }
return; return -1;
} }
} }
// Handle passive damage modifiers (e.g. PowerProtection) // Handle passive damage modifiers (e.g. PowerProtection)
@ -1024,7 +1026,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
{ {
goto dopain; goto dopain;
} }
return; return -1;
} }
} }
@ -1041,7 +1043,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
{ {
goto dopain; goto dopain;
} }
return; return -1;
} }
} }
@ -1049,7 +1051,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
} }
if (damage == -1) if (damage == -1)
{ {
return; return -1;
} }
// Push the target unless the source's weapon's kickback is 0. // Push the target unless the source's weapon's kickback is 0.
// (i.e. Gauntlets/Chainsaw) // (i.e. Gauntlets/Chainsaw)
@ -1133,7 +1135,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
{ // Still allow telefragging :-( { // Still allow telefragging :-(
damage = (int)((float)damage * level.teamdamage); damage = (int)((float)damage * level.teamdamage);
if (damage <= 0) if (damage <= 0)
return; return damage;
} }
} }
@ -1162,7 +1164,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
if (damage < TELEFRAG_DAMAGE && ((player->mo->flags2 & MF2_INVULNERABLE) || if (damage < TELEFRAG_DAMAGE && ((player->mo->flags2 & MF2_INVULNERABLE) ||
(player->cheats & CF_GODMODE))) (player->cheats & CF_GODMODE)))
{ // player is invulnerable, so don't hurt him { // player is invulnerable, so don't hurt him
return; return -1;
} }
if (!(flags & DMG_NO_ARMOR) && player->mo->Inventory != NULL) if (!(flags & DMG_NO_ARMOR) && player->mo->Inventory != NULL)
@ -1178,7 +1180,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
{ {
goto dopain; goto dopain;
} }
return; return damage;
} }
} }
@ -1237,7 +1239,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
damage = newdam; damage = newdam;
if (damage <= 0) if (damage <= 0)
{ {
return; return damage;
} }
} }
@ -1296,7 +1298,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
} }
} }
target->Die (source, inflictor, flags); target->Die (source, inflictor, flags);
return; return damage;
} }
woundstate = target->FindState(NAME_Wound, mod); woundstate = target->FindState(NAME_Wound, mod);
@ -1307,7 +1309,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
if (target->health <= woundhealth) if (target->health <= woundhealth)
{ {
target->SetState (woundstate); target->SetState (woundstate);
return; return damage;
} }
} }
@ -1401,6 +1403,8 @@ dopain:
// killough 11/98: Don't attack a friend, unless hit by that friend. // killough 11/98: Don't attack a friend, unless hit by that friend.
if (justhit && (target->target == source || !target->target || !target->IsFriend(target->target))) if (justhit && (target->target == source || !target->target || !target->IsFriend(target->target)))
target->flags |= MF_JUSTHIT; // fight back! target->flags |= MF_JUSTHIT; // fight back!
return damage;
} }
void P_PoisonMobj (AActor *target, AActor *inflictor, AActor *source, int damage, int duration, int period, FName type) void P_PoisonMobj (AActor *target, AActor *inflictor, AActor *source, int damage, int duration, int period, FName type)

View file

@ -530,7 +530,7 @@ extern FBlockNode** blocklinks; // for thing chains
// P_INTER // P_INTER
// //
void P_TouchSpecialThing (AActor *special, AActor *toucher); void P_TouchSpecialThing (AActor *special, AActor *toucher);
void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, FName mod, int flags=0); int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, FName mod, int flags=0);
void P_PoisonMobj (AActor *target, AActor *inflictor, AActor *source, int damage, int duration, int period, FName type); void P_PoisonMobj (AActor *target, AActor *inflictor, AActor *source, int damage, int duration, int period, FName type);
bool P_GiveBody (AActor *actor, int num, int max=0); bool P_GiveBody (AActor *actor, int num, int max=0);
bool P_PoisonPlayer (player_t *player, AActor *poisoner, AActor *source, int poison); bool P_PoisonPlayer (player_t *player, AActor *poisoner, AActor *source, int poison);

View file

@ -966,12 +966,13 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm)
thing->vely += tm.thing->vely; thing->vely += tm.thing->vely;
if ((thing->velx + thing->vely) > 3*FRACUNIT) if ((thing->velx + thing->vely) > 3*FRACUNIT)
{ {
int newdam;
damage = (tm.thing->Mass / 100) + 1; damage = (tm.thing->Mass / 100) + 1;
P_DamageMobj (thing, tm.thing, tm.thing, damage, tm.thing->DamageType); newdam = P_DamageMobj (thing, tm.thing, tm.thing, damage, tm.thing->DamageType);
P_TraceBleed (damage, thing, tm.thing); P_TraceBleed (newdam > 0 ? newdam : damage, thing, tm.thing);
damage = (thing->Mass / 100) + 1; damage = (thing->Mass / 100) + 1;
P_DamageMobj (tm.thing, thing, thing, damage >> 2, tm.thing->DamageType); newdam = P_DamageMobj (tm.thing, thing, thing, damage >> 2, tm.thing->DamageType);
P_TraceBleed (damage, tm.thing, thing); P_TraceBleed (newdam > 0 ? newdam : damage, tm.thing, thing);
} }
return false; return false;
} }
@ -1149,10 +1150,10 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm)
} }
damage = tm.thing->GetMissileDamage (3, 2); damage = tm.thing->GetMissileDamage (3, 2);
P_DamageMobj (thing, tm.thing, tm.thing->target, damage, tm.thing->DamageType); int newdam = P_DamageMobj (thing, tm.thing, tm.thing->target, damage, tm.thing->DamageType);
if (!(tm.thing->flags3 & MF3_BLOODLESSIMPACT)) if (!(tm.thing->flags3 & MF3_BLOODLESSIMPACT))
{ {
P_TraceBleed (damage, thing, tm.thing); P_TraceBleed (newdam > 0 ? newdam : damage, thing, tm.thing);
} }
if (thing->flags2 & MF2_PUSHABLE if (thing->flags2 & MF2_PUSHABLE
&& !(tm.thing->flags2 & MF2_CANNOTPUSH)) && !(tm.thing->flags2 & MF2_CANNOTPUSH))
@ -1180,7 +1181,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm)
damage = tm.thing->GetMissileDamage ((tm.thing->flags4 & MF4_STRIFEDAMAGE) ? 3 : 7, 1); damage = tm.thing->GetMissileDamage ((tm.thing->flags4 & MF4_STRIFEDAMAGE) ? 3 : 7, 1);
if ((damage > 0) || (tm.thing->flags6 & MF6_FORCEPAIN)) if ((damage > 0) || (tm.thing->flags6 & MF6_FORCEPAIN))
{ {
P_DamageMobj (thing, tm.thing, tm.thing->target, damage, tm.thing->DamageType); int newdam = P_DamageMobj (thing, tm.thing, tm.thing->target, damage, tm.thing->DamageType);
if (damage > 0) if (damage > 0)
{ {
if ((tm.thing->flags5 & MF5_BLOODSPLATTER) && if ((tm.thing->flags5 & MF5_BLOODSPLATTER) &&
@ -1194,7 +1195,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm)
} }
if (!(tm.thing->flags3 & MF3_BLOODLESSIMPACT)) if (!(tm.thing->flags3 & MF3_BLOODLESSIMPACT))
{ {
P_TraceBleed (damage, thing, tm.thing); P_TraceBleed (newdam > 0 ? newdam : damage, thing, tm.thing);
} }
} }
} }
@ -3612,13 +3613,42 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance,
// We must pass the unreplaced puff type here // We must pass the unreplaced puff type here
puff = P_SpawnPuff (t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, flags|PF_HITTHING); puff = P_SpawnPuff (t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, flags|PF_HITTHING);
} }
// Allow puffs to inflict poison damage, so that hitscans can poison, too.
if (puffDefaults->PoisonDamage > 0 && puffDefaults->PoisonDuration != INT_MIN)
{
P_PoisonMobj(trace.Actor, puff ? puff : t1, t1, puffDefaults->PoisonDamage, puffDefaults->PoisonDuration, puffDefaults->PoisonPeriod, puffDefaults->PoisonDamageType);
}
// [GZ] If MF6_FORCEPAIN is set, we need to call P_DamageMobj even if damage is 0!
// Note: The puff may not yet be spawned here so we must check the class defaults, not the actor.
int newdam = damage;
if (damage || (puffDefaults->flags6 & MF6_FORCEPAIN))
{
int dmgflags = DMG_INFLICTOR_IS_PUFF | pflag;
// Allow MF5_PIERCEARMOR on a weapon as well.
if (t1->player != NULL && (dmgflags & DMG_PLAYERATTACK) && t1->player->ReadyWeapon != NULL &&
t1->player->ReadyWeapon->flags5 & MF5_PIERCEARMOR)
{
dmgflags |= DMG_NO_ARMOR;
}
if (puff == NULL)
{
// Since the puff is the damage inflictor we need it here
// regardless of whether it is displayed or not.
puff = P_SpawnPuff (t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, flags|PF_HITTHING|PF_TEMPORARY);
killPuff = true;
}
newdam = P_DamageMobj (trace.Actor, puff ? puff : t1, t1, damage, damageType, dmgflags);
}
if (!(puffDefaults->flags3&MF3_BLOODLESSIMPACT)) if (!(puffDefaults->flags3&MF3_BLOODLESSIMPACT))
{ {
if (!bloodsplatter && !axeBlood && if (!bloodsplatter && !axeBlood &&
!(trace.Actor->flags & MF_NOBLOOD) && !(trace.Actor->flags & MF_NOBLOOD) &&
!(trace.Actor->flags2 & (MF2_INVULNERABLE|MF2_DORMANT))) !(trace.Actor->flags2 & (MF2_INVULNERABLE|MF2_DORMANT)))
{ {
P_SpawnBlood (hitx, hity, hitz, angle - ANG180, damage, trace.Actor); P_SpawnBlood (hitx, hity, hitz, angle - ANG180, newdam > 0 ? newdam : damage, trace.Actor);
} }
if (damage) if (damage)
@ -3639,38 +3669,10 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance,
} }
} }
// [RH] Stick blood to walls // [RH] Stick blood to walls
P_TraceBleed (damage, trace.X, trace.Y, trace.Z, P_TraceBleed (newdam > 0 ? newdam : damage, trace.X, trace.Y, trace.Z,
trace.Actor, srcangle, srcpitch); trace.Actor, srcangle, srcpitch);
} }
} }
// Allow puffs to inflict poison damage, so that hitscans can poison, too.
if (puffDefaults->PoisonDamage > 0 && puffDefaults->PoisonDuration != INT_MIN)
{
P_PoisonMobj(trace.Actor, puff ? puff : t1, t1, puffDefaults->PoisonDamage, puffDefaults->PoisonDuration, puffDefaults->PoisonPeriod, puffDefaults->PoisonDamageType);
}
// [GZ] If MF6_FORCEPAIN is set, we need to call P_DamageMobj even if damage is 0!
// Note: The puff may not yet be spawned here so we must check the class defaults, not the actor.
if (damage || (puffDefaults->flags6 & MF6_FORCEPAIN))
{
int dmgflags = DMG_INFLICTOR_IS_PUFF | pflag;
// Allow MF5_PIERCEARMOR on a weapon as well.
if (t1->player != NULL && (dmgflags & DMG_PLAYERATTACK) && t1->player->ReadyWeapon != NULL &&
t1->player->ReadyWeapon->flags5 & MF5_PIERCEARMOR)
{
dmgflags |= DMG_NO_ARMOR;
}
if (puff == NULL)
{
// Since the puff is the damage inflictor we need it here
// regardless of whether it is displayed or not.
puff = P_SpawnPuff (t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, flags|PF_HITTHING|PF_TEMPORARY);
killPuff = true;
}
P_DamageMobj (trace.Actor, puff ? puff : t1, t1, damage, damageType, dmgflags);
}
if (victim != NULL) if (victim != NULL)
{ {
*victim = trace.Actor; *victim = trace.Actor;
@ -3995,6 +3997,7 @@ void P_RailAttack (AActor *source, int damage, int offset, int color1, int color
{ {
fixed_t x, y, z; fixed_t x, y, z;
bool spawnpuff; bool spawnpuff;
bool bleed = false;
int puffflags = PF_HITTHING; int puffflags = PF_HITTHING;
x = x1 + FixedMul (RailHits[i].Distance, vx); x = x1 + FixedMul (RailHits[i].Distance, vx);
@ -4012,8 +4015,7 @@ void P_RailAttack (AActor *source, int damage, int offset, int color1, int color
puffflags |= PF_HITTHINGBLEED; // [XA] Allow for puffs to jump to XDeath state. puffflags |= PF_HITTHINGBLEED; // [XA] Allow for puffs to jump to XDeath state.
if(!(puffDefaults->flags3 & MF3_BLOODLESSIMPACT)) if(!(puffDefaults->flags3 & MF3_BLOODLESSIMPACT))
{ {
P_SpawnBlood (x, y, z, (source->angle + angleoffset) - ANG180, damage, RailHits[i].HitActor); bleed = true;
P_TraceBleed (damage, x, y, z, RailHits[i].HitActor, source->angle, pitch);
} }
} }
if (spawnpuff) if (spawnpuff)
@ -4021,7 +4023,12 @@ void P_RailAttack (AActor *source, int damage, int offset, int color1, int color
if (puffDefaults && puffDefaults->PoisonDamage > 0 && puffDefaults->PoisonDuration != INT_MIN) if (puffDefaults && puffDefaults->PoisonDamage > 0 && puffDefaults->PoisonDuration != INT_MIN)
P_PoisonMobj(RailHits[i].HitActor, thepuff ? thepuff : source, source, puffDefaults->PoisonDamage, puffDefaults->PoisonDuration, puffDefaults->PoisonPeriod, puffDefaults->PoisonDamageType); P_PoisonMobj(RailHits[i].HitActor, thepuff ? thepuff : source, source, puffDefaults->PoisonDamage, puffDefaults->PoisonDuration, puffDefaults->PoisonPeriod, puffDefaults->PoisonDamageType);
P_DamageMobj (RailHits[i].HitActor, thepuff? thepuff:source, source, damage, damagetype, DMG_INFLICTOR_IS_PUFF); int newdam = P_DamageMobj (RailHits[i].HitActor, thepuff? thepuff:source, source, damage, damagetype, DMG_INFLICTOR_IS_PUFF);
if (bleed)
{
P_SpawnBlood (x, y, z, (source->angle + angleoffset) - ANG180, newdam > 0 ? newdam : damage, RailHits[i].HitActor);
P_TraceBleed (newdam > 0 ? newdam : damage, x, y, z, RailHits[i].HitActor, source->angle, pitch);
}
} }
// Spawn a decal or puff at the point where the trace ended. // Spawn a decal or puff at the point where the trace ended.
@ -4551,16 +4558,17 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b
double velz; double velz;
double thrust; double thrust;
int damage = (int)points; int damage = (int)points;
int newdam = damage;
if (!(flags & RADF_NODAMAGE)) if (!(flags & RADF_NODAMAGE))
P_DamageMobj (thing, bombspot, bombsource, damage, bombmod); newdam = P_DamageMobj (thing, bombspot, bombsource, damage, bombmod);
else if (thing->player == NULL && !(flags & RADF_NOIMPACTDAMAGE)) else if (thing->player == NULL && !(flags & RADF_NOIMPACTDAMAGE))
thing->flags2 |= MF2_BLASTED; thing->flags2 |= MF2_BLASTED;
if (!(thing->flags & MF_ICECORPSE)) if (!(thing->flags & MF_ICECORPSE))
{ {
if (!(flags & RADF_NODAMAGE) && !(bombspot->flags3 & MF3_BLOODLESSIMPACT)) if (!(flags & RADF_NODAMAGE) && !(bombspot->flags3 & MF3_BLOODLESSIMPACT))
P_TraceBleed (damage, thing, bombspot); P_TraceBleed (newdam > 0 ? newdam : damage, thing, bombspot);
if (!(flags & RADF_NODAMAGE) || !(bombspot->flags2 & MF2_NODMGTHRUST)) if (!(flags & RADF_NODAMAGE) || !(bombspot->flags2 & MF2_NODMGTHRUST))
{ {
@ -4616,8 +4624,8 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b
damage = Scale(damage, thing->GetClass()->Meta.GetMetaFixed(AMETA_RDFactor, FRACUNIT), FRACUNIT); damage = Scale(damage, thing->GetClass()->Meta.GetMetaFixed(AMETA_RDFactor, FRACUNIT), FRACUNIT);
if (damage > 0) if (damage > 0)
{ {
P_DamageMobj (thing, bombspot, bombsource, damage, bombmod); int newdam = P_DamageMobj (thing, bombspot, bombsource, damage, bombmod);
P_TraceBleed (damage, thing, bombspot); P_TraceBleed (newdam > 0 ? newdam : damage, thing, bombspot);
} }
} }
} }
@ -4819,7 +4827,7 @@ void P_DoCrunch (AActor *thing, FChangePosition *cpos)
if ((cpos->crushchange > 0) && !(level.maptime & 3)) if ((cpos->crushchange > 0) && !(level.maptime & 3))
{ {
P_DamageMobj (thing, NULL, NULL, cpos->crushchange, NAME_Crush); int newdam = P_DamageMobj (thing, NULL, NULL, cpos->crushchange, NAME_Crush);
// spray blood in a random direction // spray blood in a random direction
if (!(thing->flags2&(MF2_INVULNERABLE|MF2_DORMANT))) if (!(thing->flags2&(MF2_INVULNERABLE|MF2_DORMANT)))
@ -4829,7 +4837,7 @@ void P_DoCrunch (AActor *thing, FChangePosition *cpos)
PalEntry bloodcolor = thing->GetBloodColor(); PalEntry bloodcolor = thing->GetBloodColor();
const PClass *bloodcls = thing->GetBloodType(); const PClass *bloodcls = thing->GetBloodType();
P_TraceBleed (cpos->crushchange, thing); P_TraceBleed (newdam > 0 ? newdam : cpos->crushchange, thing);
if (cl_bloodtype <= 1 && bloodcls != NULL) if (cl_bloodtype <= 1 && bloodcls != NULL)
{ {
AActor *mo; AActor *mo;

View file

@ -2806,8 +2806,8 @@ bool AActor::Slam (AActor *thing)
if (!(flags2 & MF2_DORMANT)) if (!(flags2 & MF2_DORMANT))
{ {
int dam = GetMissileDamage (7, 1); int dam = GetMissileDamage (7, 1);
P_DamageMobj (thing, this, this, dam, NAME_Melee); int newdam = P_DamageMobj (thing, this, this, dam, NAME_Melee);
P_TraceBleed (dam, thing, this); P_TraceBleed (newdam > 0 ? newdam : dam, thing, this);
// The charging monster may have died by the target's actions here. // The charging monster may have died by the target's actions here.
if (health > 0) if (health > 0)
{ {

View file

@ -907,8 +907,8 @@ void FPolyObj::ThrustMobj (AActor *actor, side_t *side)
{ {
if (bHurtOnTouch || !P_CheckMove (actor, actor->x + thrustX, actor->y + thrustY)) if (bHurtOnTouch || !P_CheckMove (actor, actor->x + thrustX, actor->y + thrustY))
{ {
P_DamageMobj (actor, NULL, NULL, crush, NAME_Crush); int newdam = P_DamageMobj (actor, NULL, NULL, crush, NAME_Crush);
P_TraceBleed (crush, actor); P_TraceBleed (newdam > 0 ? newdam : crush, actor);
} }
} }
if (level.flags2 & LEVEL2_POLYGRIND) actor->Grind(false); // crush corpses that get caught in a polyobject's way if (level.flags2 & LEVEL2_POLYGRIND) actor->Grind(false); // crush corpses that get caught in a polyobject's way

View file

@ -315,8 +315,8 @@ static void DoAttack (AActor *self, bool domelee, bool domissile,
{ {
int damage = pr_camelee.HitDice(MeleeDamage); int damage = pr_camelee.HitDice(MeleeDamage);
if (MeleeSound) S_Sound (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM); if (MeleeSound) S_Sound (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM);
P_DamageMobj (self->target, self, self, damage, NAME_Melee); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
} }
else if (domissile && MissileType != NULL) else if (domissile && MissileType != NULL)
{ {
@ -1119,8 +1119,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMeleeAttack)
if (self->CheckMeleeRange ()) if (self->CheckMeleeRange ())
{ {
if (MeleeSound) S_Sound (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM); if (MeleeSound) S_Sound (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM);
P_DamageMobj (self->target, self, self, damage, DamageType); int newdam = P_DamageMobj (self->target, self, self, damage, DamageType);
if (bleed) P_TraceBleed (damage, self->target, self); if (bleed) P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
} }
else else
{ {
@ -1151,8 +1151,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomComboAttack)
{ {
if (DamageType==NAME_None) DamageType = NAME_Melee; // Melee is the default type if (DamageType==NAME_None) DamageType = NAME_Melee; // Melee is the default type
if (MeleeSound) S_Sound (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM); if (MeleeSound) S_Sound (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM);
P_DamageMobj (self->target, self, self, damage, DamageType); int newdam = P_DamageMobj (self->target, self, self, damage, DamageType);
if (bleed) P_TraceBleed (damage, self->target, self); if (bleed) P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
} }
else if (ti) else if (ti)
{ {
@ -4053,11 +4053,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack)
damage >>= 2; damage >>= 2;
if (damage) if (damage)
{ {
P_DamageMobj(self->target, self, self, damage, mod, DMG_THRUSTLESS); int newdam = P_DamageMobj(self->target, self, self, damage, mod, DMG_THRUSTLESS);
if (spawnblood) if (spawnblood)
{ {
P_SpawnBlood(dx, dy, dz, angle, damage, self->target); P_SpawnBlood(dx, dy, dz, angle, newdam > 0 ? newdam : damage, self->target);
P_TraceBleed(damage, self->target, R_PointToAngle2(self->x, self->y, dx, dy), 0); P_TraceBleed(newdam > 0 ? newdam : damage, self->target, R_PointToAngle2(self->x, self->y, dx, dy), 0);
} }
} }
} }