- scriptified P_CheckMeleeRange2.

This commit is contained in:
Christoph Oelckers 2018-12-05 18:58:15 +01:00
commit 2e7e6cba9d
4 changed files with 45 additions and 51 deletions

View file

@ -317,56 +317,6 @@ DEFINE_ACTION_FUNCTION(AActor, CheckMeleeRange)
ACTION_RETURN_INT(self->CheckMeleeRange());
}
//----------------------------------------------------------------------------
//
// FUNC P_CheckMeleeRange2
//
//----------------------------------------------------------------------------
bool P_CheckMeleeRange2 (AActor *actor)
{
AActor *mo;
double dist;
if (!actor->target || (actor->Sector->Flags & SECF_NOATTACK))
{
return false;
}
mo = actor->target;
dist = mo->Distance2D (actor);
if (dist >= 128 || dist < actor->meleerange + mo->radius)
{
return false;
}
if (mo->Z() > actor->Top())
{ // Target is higher than the attacker
return false;
}
else if (actor->Z() > mo->Top())
{ // Attacker is higher
return false;
}
else if (actor->IsFriend(mo))
{
// killough 7/18/98: friendly monsters don't attack other friends
return false;
}
if (!P_CheckSight(actor, mo))
{
return false;
}
return true;
}
DEFINE_ACTION_FUNCTION(AActor, CheckMeleeRange2)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_INT(P_CheckMeleeRange2(self));
}
//=============================================================================
//
// P_CheckMissileRange