From ac48518abcc8ac2024b3a32f0cd7d5638d44328f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 21 Aug 2021 12:37:23 +0200 Subject: [PATCH] - merged SuggestMissileAttack back into P_CheckMissileRange. This was once a virtual function to handle the various monster specific modifiers but this had been changed into properties a long time ago. --- src/playsim/actor.h | 3 --- src/playsim/p_enemy.cpp | 35 ++++++++++++++--------------------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/playsim/actor.h b/src/playsim/actor.h index bfc1cf566..51cf4308d 100644 --- a/src/playsim/actor.h +++ b/src/playsim/actor.h @@ -687,9 +687,6 @@ public: 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); diff --git a/src/playsim/p_enemy.cpp b/src/playsim/p_enemy.cpp index 6b692e229..fc032a2a8 100644 --- a/src/playsim/p_enemy.cpp +++ b/src/playsim/p_enemy.cpp @@ -312,6 +312,7 @@ DEFINE_ACTION_FUNCTION(AActor, CheckMeleeRange) // P_CheckMissileRange // //============================================================================= + bool P_CheckMissileRange (AActor *actor) { double dist; @@ -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(dist), mmc); -} - //============================================================================= // // P_HitFriend()