- Fixed: Do not exit P_DamageMobj early if damage is 0, so we can still get

the side effects from it. PainThreshold also needs to be inclusive, as
  the docs already state.


SVN r1943 (trunk)
This commit is contained in:
Randy Heit 2009-10-28 23:14:20 +00:00
parent 1c3de33585
commit df317801bf
2 changed files with 25 additions and 16 deletions

View file

@ -1,3 +1,8 @@
October 28, 2009
- Fixed: Do not exit P_DamageMobj early if damage is 0, so we can still get
the side effects from it. PainThreshold also needs to be inclusive, as
the docs already state.
October 26, 2009 October 26, 2009
- Changes to both A_MonsterRail() and A_CustomRailgun(): Save actor's pitch, - Changes to both A_MonsterRail() and A_CustomRailgun(): Save actor's pitch,
use a larger aiming range, ignore non-targets in P_AimLineAttack(), and use a larger aiming range, ignore non-targets in P_AimLineAttack(), and

View file

@ -931,7 +931,8 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
} }
if (inflictor != NULL) if (inflictor != NULL)
{ {
if (inflictor->flags5 & MF5_PIERCEARMOR) flags |= DMG_NO_ARMOR; if (inflictor->flags5 & MF5_PIERCEARMOR)
flags |= DMG_NO_ARMOR;
} }
MeansOfDeath = mod; MeansOfDeath = mod;
@ -981,21 +982,22 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
{ {
return; return;
} }
} }
// Handle active damage modifiers (e.g. PowerDamage) // Handle active damage modifiers (e.g. PowerDamage)
if (source != NULL && source->Inventory != NULL) if (source != NULL && source->Inventory != NULL)
{ {
int olddam = damage; int olddam = damage;
source->Inventory->ModifyDamage(olddam, mod, damage, false); source->Inventory->ModifyDamage(olddam, mod, damage, false);
if (olddam != damage && damage <= 0) return; if (olddam != damage && damage <= 0)
return;
} }
// Handle passive damage modifiers (e.g. PowerProtection) // Handle passive damage modifiers (e.g. PowerProtection)
if (target->Inventory != NULL) if (target->Inventory != NULL)
{ {
int olddam = damage; int olddam = damage;
target->Inventory->ModifyDamage(olddam, mod, damage, true); target->Inventory->ModifyDamage(olddam, mod, damage, true);
if (olddam != damage && damage <= 0) return; if (olddam != damage && damage <= 0)
return;
} }
DmgFactors * df = target->GetClass()->ActorInfo->DamageFactors; DmgFactors * df = target->GetClass()->ActorInfo->DamageFactors;
@ -1006,11 +1008,13 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
if (pdf != NULL) if (pdf != NULL)
{ {
damage = FixedMul(damage, *pdf); damage = FixedMul(damage, *pdf);
if (damage <= 0) return; if (damage <= 0)
return;
} }
} }
damage = FixedMul(damage, target->DamageFactor); damage = FixedMul(damage, target->DamageFactor);
if (damage <= 0) return; if (damage < 0)
return;
damage = target->TakeSpecialDamage (inflictor, source, damage, mod); damage = target->TakeSpecialDamage (inflictor, source, damage, mod);
} }
@ -1040,7 +1044,6 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
ang = R_PointToAngle2 (origin->x, origin->y, ang = R_PointToAngle2 (origin->x, origin->y,
target->x, target->y); target->x, target->y);
// Calculate this as float to avoid overflows so that the // Calculate this as float to avoid overflows so that the
// clamping that had to be done here can be removed. // clamping that had to be done here can be removed.
double fltthrust; double fltthrust;
@ -1131,8 +1134,9 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
damage = newdam; damage = newdam;
if (damage <= 0) if (damage <= 0)
{ {
// If MF&_FORCEPAIN is set make the player enter the pain state. // If MF6_FORCEPAIN is set, make the player enter the pain state.
if (inflictor != NULL && (inflictor->flags6 & MF6_FORCEPAIN)) goto dopain; if (inflictor != NULL && (inflictor->flags6 & MF6_FORCEPAIN))
goto dopain;
return; return;
} }
} }
@ -1268,7 +1272,6 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
if (!(target->flags5 & MF5_NOPAIN) && (inflictor == NULL || !(inflictor->flags5 & MF5_PAINLESS)) && if (!(target->flags5 & MF5_NOPAIN) && (inflictor == NULL || !(inflictor->flags5 & MF5_PAINLESS)) &&
!G_SkillProperty(SKILLP_NoPain) && !(target->flags & MF_SKULLFLY)) !G_SkillProperty(SKILLP_NoPain) && !(target->flags & MF_SKULLFLY))
{ {
pc = target->GetClass()->ActorInfo->PainChances; pc = target->GetClass()->ActorInfo->PainChances;
painchance = target->PainChance; painchance = target->PainChance;
if (pc != NULL) if (pc != NULL)
@ -1280,7 +1283,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
} }
} }
if ((damage > target->PainThreshold && pr_damagemobj() < painchance) || if ((damage >= target->PainThreshold && pr_damagemobj() < painchance) ||
(inflictor != NULL && (inflictor->flags6 & MF6_FORCEPAIN))) (inflictor != NULL && (inflictor->flags6 & MF6_FORCEPAIN)))
{ {
dopain: dopain:
@ -1290,7 +1293,8 @@ dopain:
{ {
justhit = true; justhit = true;
FState *painstate = target->FindState(NAME_Pain, mod); FState *painstate = target->FindState(NAME_Pain, mod);
if (painstate != NULL) target->SetState (painstate); if (painstate != NULL)
target->SetState(painstate);
} }
else else
{ // "electrocute" the target { // "electrocute" the target
@ -1305,7 +1309,8 @@ dopain:
{ {
justhit = true; justhit = true;
FState *painstate = target->FindState(NAME_Pain, mod); FState *painstate = target->FindState(NAME_Pain, mod);
if (painstate != NULL) target->SetState (painstate); if (painstate != NULL)
target->SetState(painstate);
if (mod == NAME_PoisonCloud) if (mod == NAME_PoisonCloud)
{ {
if ((target->flags3 & MF3_ISMONSTER) && pr_poison() < 128) if ((target->flags3 & MF3_ISMONSTER) && pr_poison() < 128)
@ -1353,7 +1358,6 @@ 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!
} }
bool AActor::OkayToSwitchTarget (AActor *other) bool AActor::OkayToSwitchTarget (AActor *other)