Jump to content

[fix] isPassiveToHostile


Guest Vinolentus

Recommended Posts

eg, should fix Creature::CanInitiateAttack()

diff --git a/src/game/Creature.h b/src/game/Creature.h
index c19c386..3c034da 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -620,6 +620,11 @@ class MANGOS_DLL_SPEC Creature : public Unit
        bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const;
        bool CanInitiateAttack();

+        bool isPassiveToHostile()
+        {
+            return (IsCivilian() || Unit::isPassiveToHostile());
+        }
+
        MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; }
        void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; }

diff --git a/src/game/Unit.h b/src/game/Unit.h
index d279a32..148b814 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1453,7 +1453,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
        void RemoveSpellbyDamageTaken(AuraType auraType, uint32 damage);

        bool isTargetableForAttack(bool inversAlive = false) const;
-        bool isPassiveToHostile() { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE); }
+        // overwrited in Creature
+        virtual bool isPassiveToHostile() { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE); }

        virtual bool IsInWater() const;
        virtual bool IsUnderWater() const;

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...
  • 4 months later...
what is the problem with current Creature::CanInitiateAttack() function?

Current Creature::CanInitiateAttack() returns true if creature has CREATURE_FLAG_EXTRA_CIVILIAN, but has no UNIT_FLAG_PASSIVE. If we should not use CREATURE_FLAG_EXTRA_CIVILIAN without UNIT_FLAG_PASSIVE - what for is that extraflag needed at all?

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use