From 9508001213e8bc4c199c83d6347adabd0113cad9 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 8 Nov 2010 02:40:03 +0300 Subject: [PATCH] [10696] Avoid selection despawned creatures as spell autoselected targets. Original patch provided by virusav. --- src/game/GridNotifiers.h | 2 +- src/game/Spell.cpp | 2 +- src/game/Unit.h | 2 +- src/shared/revision_nr.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index b02023827..8c7567279 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -1091,7 +1091,7 @@ namespace MaNGOS WorldObject const& GetFocusObject() const { return i_obj; } bool operator()(Creature* u) { - if(u->GetEntry() == i_entry && u->isAlive()==i_alive && i_obj.IsWithinDistInMap(u, i_range)) + if (u->GetEntry() == i_entry && (i_alive && u->isAlive() || !i_alive && u->IsCorpse()) && i_obj.IsWithinDistInMap(u, i_range)) { i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check return true; diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index be8e533c2..262ec543f 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -4628,7 +4628,7 @@ SpellCastResult Spell::CheckCast(bool strict) { if (pTarget->GetTypeId() == TYPEID_UNIT && pTarget->GetEntry() == i_spellST->second.targetEntry) { - if (i_spellST->second.type == SPELL_TARGET_TYPE_DEAD && pTarget->isDead()) + if (i_spellST->second.type == SPELL_TARGET_TYPE_DEAD && ((Creature*)pTarget)->IsCorpse()) { // always use spellMaxRange, in case GetLastRange returned different in a previous pass if (pTarget->IsWithinDistInMap(m_caster, GetSpellMaxRange(srange))) diff --git a/src/game/Unit.h b/src/game/Unit.h index 8a786c977..efd815366 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -403,7 +403,7 @@ enum BaseModType enum DeathState { - ALIVE = 0, // show as alive + ALIVE = 0, // show as alive JUST_DIED = 1, // temporary state at die, for creature auto converted to CORPSE, for player at next update call CORPSE = 2, // corpse state, for player this also meaning that player not leave corpse DEAD = 3, // for creature despawned state (corpse despawned), for player CORPSE/DEAD not clear way switches (FIXME), and use m_deathtimer > 0 check for real corpse state diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 437a87825..f76f07c7e 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10695" + #define REVISION_NR "10696" #endif // __REVISION_NR_H__