diff options
Diffstat (limited to 'src')
-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 8241b88fedf..f16fb651727 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -5790,6 +5790,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 (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED)) return false; @@ -5854,7 +5859,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); @@ -5862,8 +5867,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 SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); @@ -5878,7 +5883,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(); |