mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[9533] Use selected target for target mode 38/46 when provided.
For cases where provided target is not valid (or not provided), normal closest in range will be used. Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
ed042d4463
commit
81c6f3ff9b
2 changed files with 34 additions and 10 deletions
|
|
@ -4362,24 +4362,48 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||
{
|
||||
Creature *p_Creature = NULL;
|
||||
|
||||
CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY()));
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
// check if explicit target is provided and check it up against database valid target entry/state
|
||||
if (Unit* pTarget = m_targets.getUnitTarget())
|
||||
{
|
||||
if (pTarget->GetTypeId() == TYPEID_UNIT && pTarget->GetEntry() == i_spellST->second.targetEntry)
|
||||
{
|
||||
if (i_spellST->second.type == SPELL_TARGET_TYPE_DEAD && pTarget->isDead())
|
||||
{
|
||||
if (pTarget->IsWithinDistInMap(m_caster, range))
|
||||
p_Creature = (Creature*)pTarget;
|
||||
}
|
||||
else if (i_spellST->second.type == SPELL_TARGET_TYPE_CREATURE && pTarget->isAlive())
|
||||
{
|
||||
if (pTarget->IsWithinDistInMap(m_caster, range))
|
||||
p_Creature = (Creature*)pTarget;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*m_caster, i_spellST->second.targetEntry, i_spellST->second.type != SPELL_TARGET_TYPE_DEAD, range);
|
||||
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(m_caster, p_Creature, u_check);
|
||||
// no target provided or it was not valid, so use closest in range
|
||||
if (!p_Creature)
|
||||
{
|
||||
CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY()));
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
|
||||
TypeContainerVisitor<MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher);
|
||||
MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*m_caster, i_spellST->second.targetEntry, i_spellST->second.type != SPELL_TARGET_TYPE_DEAD, range);
|
||||
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(m_caster, p_Creature, u_check);
|
||||
|
||||
cell.Visit(p, grid_creature_searcher, *m_caster->GetMap(), *m_caster, range);
|
||||
TypeContainerVisitor<MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher);
|
||||
|
||||
cell.Visit(p, grid_creature_searcher, *m_caster->GetMap(), *m_caster, range);
|
||||
|
||||
range = u_check.GetLastRange();
|
||||
}
|
||||
|
||||
if (p_Creature)
|
||||
{
|
||||
creatureScriptTarget = p_Creature;
|
||||
goScriptTarget = NULL;
|
||||
range = u_check.GetLastRange();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9532"
|
||||
#define REVISION_NR "9533"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue