diff options
author | Treeston <treeston.mmoc@gmail.com> | 2017-05-28 22:18:22 +0200 |
---|---|---|
committer | funjoker <funjoker109@gmail.com> | 2020-06-14 23:49:04 +0200 |
commit | 496263fccb28c3b412c3bd53584422a0258bd5ca (patch) | |
tree | 3fb9ac18937dd3d68cec33c66291a54f2a3679fc | |
parent | b1f1cc45147b445c9f05ad1f5d69234ba032b1bc (diff) |
Fix evade issues when a spell hits the target just before evading. (#19815)
- Creatures should no longer get stuck in evade mode following a target if a spell hits the creature just as it's entering evade mode.
- Fixes and closes #4943. Finally.
(cherry picked from commit 1945874f965a2aef951bc3dfae1144bd42365dcb)
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 02469f0ed86..6e485f64fc2 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -5657,6 +5657,11 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) if (GetTypeId() == TYPEID_PLAYER && IsMounted()) return false; + Creature* creature = ToCreature(); + // creatures cannot attack while evading + if (creature && creature->IsInEvadeMode()) + return false; + if (HasUnitFlag(UNIT_FLAG_PACIFIED)) return false; @@ -5721,7 +5726,7 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) //if (GetTypeId() == TYPEID_UNIT) // ToCreature()->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ()); - if (GetTypeId() == TYPEID_UNIT && !IsPet()) + if (creature && !IsPet()) { // should not let player enter combat by right clicking target - doesn't helps AddThreat(victim, 0.0f); @@ -5729,8 +5734,8 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) if (victim->GetTypeId() == TYPEID_PLAYER) victim->SetInCombatWith(this); - ToCreature()->SendAIReaction(AI_REACTION_HOSTILE); - ToCreature()->CallAssistance(); + creature->SendAIReaction(AI_REACTION_HOSTILE); + creature->CallAssistance(); // Remove emote state - will be restored on creature reset SetEmoteState(EMOTE_ONESHOT_NONE); @@ -5745,7 +5750,7 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) // Let the pet know we've started attacking someting. Handles melee attacks only // Spells such as auto-shot and others handled in WorldSession::HandleCastSpellOpcode - if (this->GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { Pet* playerPet = this->ToPlayer()->GetPet(); |