Skip to content

Commit

Permalink
- merged SuggestMissileAttack back into P_CheckMissileRange.
Browse files Browse the repository at this point in the history
This was once a virtual function to handle the various monster specific modifiers but this had been changed into properties a long time ago.
  • Loading branch information
coelckers committed Aug 21, 2021
1 parent d15f450 commit ac48518
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
3 changes: 0 additions & 3 deletions src/playsim/actor.h
Expand Up @@ -687,9 +687,6 @@ class AActor : public DThinker

FDropItem *GetDropItems() const;

// Return true if the monster should use a missile attack, false for melee
bool SuggestMissileAttack (double dist);

// Adjusts the angle for deflection/reflection of incoming missiles
// Returns true if the missile should be allowed to explode anyway
bool AdjustReflectionAngle (AActor *thing, DAngle &angle);
Expand Down
35 changes: 14 additions & 21 deletions src/playsim/p_enemy.cpp
Expand Up @@ -312,6 +312,7 @@ DEFINE_ACTION_FUNCTION(AActor, CheckMeleeRange)
// P_CheckMissileRange
//
//=============================================================================

bool P_CheckMissileRange (AActor *actor)
{
double dist;
Expand Down Expand Up @@ -360,34 +361,26 @@ bool P_CheckMissileRange (AActor *actor)
if (actor->MeleeState == NULL)
dist -= 128; // no melee attack, so fire more

return actor->SuggestMissileAttack (dist);

if (actor->maxtargetrange > 0 && dist > actor->maxtargetrange)
return false; // The Arch Vile's special behavior turned into a property

if (actor->MeleeState != nullptr && dist < actor->meleethreshold)
return false; // From the Revenant: close enough for fist attack

if (actor->flags4 & MF4_MISSILEMORE) dist *= 0.5;
if (actor->flags4 & MF4_MISSILEEVENMORE) dist *= 0.125;

int mmc = int(actor->MinMissileChance * G_SkillProperty(SKILLP_Aggressiveness));
return pr_checkmissilerange() >= min(int(dist), mmc);
}

DEFINE_ACTION_FUNCTION(AActor, CheckMissileRange)
DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckMissileRange, P_CheckMissileRange)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_BOOL(P_CheckMissileRange(self));
}

bool AActor::SuggestMissileAttack (double dist)
{
// new version encapsulates the different behavior in flags instead of virtual functions
// The advantage is that this allows inheriting the missile attack attributes from the
// various Doom monsters by custom monsters

if (maxtargetrange > 0 && dist > maxtargetrange)
return false; // The Arch Vile's special behavior turned into a property

if (MeleeState != NULL && dist < meleethreshold)
return false; // From the Revenant: close enough for fist attack

if (flags4 & MF4_MISSILEMORE) dist *= 0.5;
if (flags4 & MF4_MISSILEEVENMORE) dist *= 0.125;

int mmc = int(MinMissileChance * G_SkillProperty(SKILLP_Aggressiveness));
return pr_checkmissilerange() >= MIN<int> (int(dist), mmc);
}

//=============================================================================
//
// P_HitFriend()
Expand Down

0 comments on commit ac48518

Please sign in to comment.