diff --git a/src/creatures/monsters/monster.cpp b/src/creatures/monsters/monster.cpp index 204e750e90a..7430c6d962a 100644 --- a/src/creatures/monsters/monster.cpp +++ b/src/creatures/monsters/monster.cpp @@ -135,11 +135,6 @@ void Monster::onCreatureAppear(Creature* creature, bool isLogin) { } if (creature == this) { - // We just spawned lets look around to see who is there. - if (isSummon()) { - isMasterInRange = canSee(getMaster()->getPosition()); - } - updateTargetList(); updateIdleStatus(); } else { @@ -222,10 +217,6 @@ void Monster::onCreatureMove(Creature* creature, const Tile* newTile, const Posi } if (creature == this) { - if (isSummon()) { - isMasterInRange = canSee(getMaster()->getPosition()); - } - updateTargetList(); updateIdleStatus(); } else { @@ -238,10 +229,6 @@ void Monster::onCreatureMove(Creature* creature, const Tile* newTile, const Posi onCreatureLeave(creature); } - if (canSeeNewPos && isSummon() && getMaster() == creature) { - isMasterInRange = true; // Follow master again - } - updateIdleStatus(); if (!isSummon()) { @@ -409,11 +396,6 @@ void Monster::onCreatureFound(Creature* creature, bool pushFront /* = false*/) { } void Monster::onCreatureEnter(Creature* creature) { - if (getMaster() == creature) { - // Follow master again - isMasterInRange = true; - } - onCreatureFound(creature, true); } @@ -462,11 +444,6 @@ bool Monster::isOpponent(const Creature* creature) const { } void Monster::onCreatureLeave(Creature* creature) { - if (getMaster() == creature) { - // Take random steps and only use defense abilities (e.g. heal) until its master comes back - isMasterInRange = false; - } - // update friendList if (isFriend(creature)) { removeFriend(creature); @@ -730,21 +707,18 @@ void Monster::updateIdleStatus() { } void Monster::onAddCondition(ConditionType_t type) { + onConditionStatusChange(type); +} + +void Monster::onConditionStatusChange(const ConditionType_t &type) { if (type == CONDITION_FIRE || type == CONDITION_ENERGY || type == CONDITION_POISON) { - ignoreFieldDamage = true; updateMapCache(); } - updateIdleStatus(); } void Monster::onEndCondition(ConditionType_t type) { - if (type == CONDITION_FIRE || type == CONDITION_ENERGY || type == CONDITION_POISON) { - ignoreFieldDamage = false; - updateMapCache(); - } - - updateIdleStatus(); + onConditionStatusChange(type); } void Monster::onThink(uint32_t interval) { @@ -1224,6 +1198,7 @@ void Monster::doFollowCreature(uint32_t &flags, Direction &nextDirection, bool & flags |= FLAG_PATHFINDING; } else { if (ignoreFieldDamage) { + ignoreFieldDamage = false; updateMapCache(); } // target dancing diff --git a/src/creatures/monsters/monster.h b/src/creatures/monsters/monster.h index 42e9c9c7a88..5df54da3573 100644 --- a/src/creatures/monsters/monster.h +++ b/src/creatures/monsters/monster.h @@ -344,7 +344,6 @@ class Monster final : public Creature { bool isIdle = true; bool extraMeleeAttack = false; - bool isMasterInRange = false; bool randomStepping = false; bool ignoreFieldDamage = false; @@ -415,6 +414,8 @@ class Monster final : public Creature { void doFollowCreature(uint32_t &flags, Direction &nextDirection, bool &result); void doRandomStep(Direction &nextDirection, bool &result); + + void onConditionStatusChange(const ConditionType_t &type); }; #endif // SRC_CREATURES_MONSTERS_MONSTER_H_