Skip to content

Commit

Permalink
Fix search for TARGET_SCRIPT if searcher DYN/GAMEOBJ
Browse files Browse the repository at this point in the history
bug after cmangos/mangos-wotlk@6cd4c2b commit.
when caster (player) and GO have different phase mask, we don't find targets.

example: Q24507
GO 201969 (Ball and chain) have phase mask 1
NPC 36770... (Horde Slave) have phase mask 64

player have phase mask 65
so player see GO and NPC, but if search target from GO we don't find NPC.

(based on cmangos/mangos-wotlk@e928ef66f)

Signed-off-by: Xfurry <xfurry.cmangos@outlook.com>
  • Loading branch information
boxa authored and xfurry committed Dec 10, 2017
1 parent 47dfd7e commit bcff80e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/game/Spell.cpp
Expand Up @@ -5768,13 +5768,25 @@ SpellCastResult Spell::CheckCast(bool strict)
// no target provided or it was not valid, so use closest in range
if (!targetExplicit)
{
WorldObject* objectForSearch = (worldObject && (worldObject->GetTypeId() == TYPEID_GAMEOBJECT || worldObject->GetTypeId() == TYPEID_DYNAMICOBJECT)) ? worldObject : m_caster;
WorldObject* objectForSearch = m_caster;
uint32 savePhaseMask = 0;

if (worldObject && (worldObject->GetTypeId() == TYPEID_GAMEOBJECT || worldObject->GetTypeId() == TYPEID_DYNAMICOBJECT))
{
objectForSearch = worldObject;
savePhaseMask = worldObject->GetPhaseMask();
objectForSearch->SetPhaseMask(m_caster->GetPhaseMask(), false);
}

MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*objectForSearch, i_spellST->targetEntry, i_spellST->type != SPELL_TARGET_TYPE_DEAD, i_spellST->type == SPELL_TARGET_TYPE_DEAD, range);
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(p_Creature, u_check);

// Visit all, need to find also Pet* objects
Cell::VisitAllObjects(objectForSearch, searcher, range);

if (savePhaseMask)
objectForSearch->SetPhaseMask(savePhaseMask, false);

range = u_check.GetLastRange();
}

Expand Down

0 comments on commit bcff80e

Please sign in to comment.