Jump to content

[fix] isPassiveToHostile


Recommended Posts

Posted

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;

  • 4 weeks later...
  • 2 weeks later...
Posted

Instead modify code, maybe Db miss for creature

    UNIT_FLAG_PASSIVE               = 0x00000200,           // makes you unable to attack everything. Almost identical to our "civilian"-term. Will ignore it's surroundings and not engage in combat unless "called upon" or engaged by another unit.

in flags field.

  • 4 months later...
Posted
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?

×
×
  • 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