Merged Cacodemon345's PR (1068) which fixes bouncing prjectiles not damaging when hitting an actor from top or bottom.

This commit is contained in:
Major Cooke 2020-04-08 10:08:16 -05:00
parent d29b514985
commit 4a7eb8fda6
4 changed files with 56 additions and 32 deletions

View file

@ -252,6 +252,7 @@ extern TArray<spechit_t> portalhit;
int P_TestMobjLocation (AActor *mobj);
int P_TestMobjZ (AActor *mobj, bool quick=true, AActor **pOnmobj = NULL);
bool P_CheckPosition(AActor *thing, const DVector2 &pos, bool actorsonly = false);
void P_DoMissileDamage(AActor* inflictor, AActor* target);
bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, bool actorsonly = false);
AActor *P_CheckOnmobj (AActor *thing);
void P_FakeZMovement (AActor *mo);

View file

@ -1230,6 +1230,58 @@ static bool CanAttackHurt(AActor *victim, AActor *shooter)
return true;
}
//==========================================================================
//
// P_DoMissileDamage
// Handle damaging/poisoning enemies from missiles.
// target is the target to be dealt damage to.
// inflictor is the actor dealing the damage.
//
//==========================================================================
void P_DoMissileDamage(AActor* inflictor, AActor* target)
{
// Do poisoning (if using new style poison)
if (inflictor->PoisonDamage > 0 && inflictor->PoisonDuration != INT_MIN)
{
P_PoisonMobj(target, inflictor, inflictor->target, inflictor->PoisonDamage, inflictor->PoisonDuration, inflictor->PoisonPeriod, inflictor->PoisonDamageType);
}
// Do damage
int damage = inflictor->GetMissileDamage((inflictor->flags4 & MF4_STRIFEDAMAGE) ? 3 : 7, 1);
if ((damage > 0) || (inflictor->flags6 & MF6_FORCEPAIN) || (inflictor->flags7 & MF7_CAUSEPAIN))
{
int newdam = P_DamageMobj(target, inflictor, inflictor->target, damage, inflictor->DamageType);
if (damage > 0)
{
if ((inflictor->flags5 & MF5_BLOODSPLATTER) &&
!(target->flags & MF_NOBLOOD) &&
!(target->flags2 & MF2_REFLECTIVE) &&
!(target->flags2 & (MF2_INVULNERABLE | MF2_DORMANT)) &&
!(inflictor->flags3 & MF3_BLOODLESSIMPACT) &&
(pr_checkthing() < 192))
{
P_BloodSplatter(inflictor->Pos(), target, inflictor->AngleTo(target));
}
if (!(inflictor->flags3 & MF3_BLOODLESSIMPACT))
{
P_TraceBleed(newdam > 0 ? newdam : damage, target, inflictor);
}
}
}
else
{
P_GiveBody(target, -damage);
}
}
DEFINE_ACTION_FUNCTION(AActor, DoMissileDamage)
{
PARAM_PROLOGUE;
PARAM_OBJECT_NOT_NULL(target, AActor);
PARAM_OBJECT_NOT_NULL(inflictor, AActor);
P_DoMissileDamage(inflictor, target);
return 0;
}
//==========================================================================
//
// PIT_CheckThing
@ -1555,38 +1607,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch
}
}
// Do poisoning (if using new style poison)
if (tm.thing->PoisonDamage > 0 && tm.thing->PoisonDuration != INT_MIN)
{
P_PoisonMobj(thing, tm.thing, tm.thing->target, tm.thing->PoisonDamage, tm.thing->PoisonDuration, tm.thing->PoisonPeriod, tm.thing->PoisonDamageType);
}
// Do damage
damage = tm.thing->GetMissileDamage((tm.thing->flags4 & MF4_STRIFEDAMAGE) ? 3 : 7, 1);
if ((damage > 0) || (tm.thing->flags6 & MF6_FORCEPAIN) || (tm.thing->flags7 & MF7_CAUSEPAIN))
{
int newdam = P_DamageMobj(thing, tm.thing, tm.thing->target, damage, tm.thing->DamageType);
if (damage > 0)
{
if ((tm.thing->flags5 & MF5_BLOODSPLATTER) &&
!(thing->flags & MF_NOBLOOD) &&
!(thing->flags2 & MF2_REFLECTIVE) &&
!(thing->flags2 & (MF2_INVULNERABLE | MF2_DORMANT)) &&
!(tm.thing->flags3 & MF3_BLOODLESSIMPACT) &&
(pr_checkthing() < 192))
{
P_BloodSplatter(tm.thing->Pos(), thing, tm.thing->AngleTo(thing));
}
if (!(tm.thing->flags3 & MF3_BLOODLESSIMPACT))
{
P_TraceBleed(newdam > 0 ? newdam : damage, thing, tm.thing);
}
}
}
else
{
P_GiveBody(thing, -damage);
}
P_DoMissileDamage(tm.thing, thing);
if ((thing->flags7 & MF7_THRUREFLECT) && (thing->flags2 & MF2_REFLECTIVE) && (tm.thing->flags & MF_MISSILE))
{

View file

@ -4029,6 +4029,7 @@ void AActor::Tick ()
// to be in line with the case when an actor's side is hit.
if (!res && (flags & MF_MISSILE))
{
P_DoMissileDamage(this, onmo);
P_ExplodeMissile(this, nullptr, onmo);
}
}

View file

@ -761,6 +761,7 @@ class Actor : Thinker native
native void GiveSecret(bool printmsg = true, bool playsound = true);
native clearscope double GetCameraHeight() const;
native clearscope double GetGravity() const;
native static void DoMissileDamage(Actor target, Actor inflictor);
//==========================================================================
//