diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 04d2b261b5..986268c7ee 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -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 diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 86d916348e..07e409dd89 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -663,7 +663,6 @@ class Actor : Thinker native native void SetIdle(bool nofunction = false); native bool CheckMeleeRange(); - native bool CheckMeleeRange2(); native virtual int DamageMobj(Actor inflictor, Actor source, int damage, Name mod, int flags = 0, double angle = 0); native void PoisonMobj (Actor inflictor, Actor source, int damage, int duration, int period, Name type); native double AimLineAttack(double angle, double distance, out FTranslatedLineTarget pLineTarget = null, double vrange = 0., int flags = 0, Actor target = null, Actor friender = null); diff --git a/wadsrc/static/zscript/hexen/serpent.txt b/wadsrc/static/zscript/hexen/serpent.txt index 9d68263811..7688dbd0ef 100644 --- a/wadsrc/static/zscript/hexen/serpent.txt +++ b/wadsrc/static/zscript/hexen/serpent.txt @@ -290,6 +290,50 @@ class Serpent : Actor } } +extend class Actor +{ + //---------------------------------------------------------------------------- + // + // FUNC P_CheckMeleeRange2 + // + // This belongs to the Serpent but was initially exported on Actor + // so it needs to remain there. + // + //---------------------------------------------------------------------------- + + bool CheckMeleeRange2 () + { + Actor mo; + double dist; + + + if (!target || (CurSector.Flags & Sector.SECF_NOATTACK)) + { + return false; + } + mo = target; + dist = mo.Distance2D (self); + if (dist >= 128 || dist < meleerange + mo.radius) + { + return false; + } + if (mo.pos.Z > pos.Z + height) + { // Target is higher than the attacker + return false; + } + else if (pos.Z > mo.pos.Z + mo.height) + { // Attacker is higher + return false; + } + else if (IsFriend(mo)) + { + // killough 7/18/98: friendly monsters don't attack other friends + return false; + } + return CheckSight(mo); + } +} + // Serpent Leader ----------------------------------------------------------- class SerpentLeader : Serpent diff --git a/wadsrc/static/zscript/mapdata.txt b/wadsrc/static/zscript/mapdata.txt index cf2458c10b..601031f222 100644 --- a/wadsrc/static/zscript/mapdata.txt +++ b/wadsrc/static/zscript/mapdata.txt @@ -334,6 +334,7 @@ struct Sector native play SECF_ENDGODMODE = 256, // getting damaged by this sector ends god mode SECF_ENDLEVEL = 512, // ends level when health goes below 10 SECF_HAZARD = 1024, // Change to Strife's delayed damage handling. + SECF_NOATTACK = 2048, // monsters cannot start attacks in this sector. SECF_WASSECRET = 1 << 30, // a secret that was discovered SECF_SECRET = 1 << 31, // a secret sector