[9083] Rename maps naming used in spell targeting code for easier readability

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2009-12-29 13:11:21 +01:00
parent 70c8eb5906
commit 663f8df849
3 changed files with 164 additions and 164 deletions

View file

@ -1284,7 +1284,7 @@ struct TargetDistanceOrder : public std::binary_function<const Unit, const Unit,
} }
}; };
void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap) void Spell::SetTargetMap(uint32 effIndex, uint32 targetMode, UnitList& targetUnitMap)
{ {
float radius; float radius;
if (m_spellInfo->EffectRadiusIndex[effIndex]) if (m_spellInfo->EffectRadiusIndex[effIndex])
@ -1361,7 +1361,7 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
m_caster->GetClosePoint(dest_x, dest_y, dest_z, 0.0f, radius, angle); m_caster->GetClosePoint(dest_x, dest_y, dest_z, 0.0f, radius, angle);
m_targets.setDestination(dest_x, dest_y, dest_z); m_targets.setDestination(dest_x, dest_y, dest_z);
TagUnitMap.push_back(m_caster); targetUnitMap.push_back(m_caster);
break; break;
} }
case TARGET_RANDOM_NEARBY_DEST: case TARGET_RANDOM_NEARBY_DEST:
@ -1377,10 +1377,10 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
if (radius > 0.0f) if (radius > 0.0f)
{ {
// caster included here? // caster included here?
FillAreaTargets(TagUnitMap, dest_x, dest_y, radius, PUSH_DEST_CENTER, SPELL_TARGETS_AOE_DAMAGE); FillAreaTargets(targetUnitMap, dest_x, dest_y, radius, PUSH_DEST_CENTER, SPELL_TARGETS_AOE_DAMAGE);
} }
else else
TagUnitMap.push_back(m_caster); targetUnitMap.push_back(m_caster);
break; break;
} }
@ -1393,7 +1393,7 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
case TARGET_AREAEFFECT_CUSTOM: case TARGET_AREAEFFECT_CUSTOM:
case TARGET_AREAEFFECT_CUSTOM_2: case TARGET_AREAEFFECT_CUSTOM_2:
case TARGET_SUMMON: case TARGET_SUMMON:
TagUnitMap.push_back(m_caster); targetUnitMap.push_back(m_caster);
break; break;
case TARGET_RANDOM_ENEMY_CHAIN_IN_AREA: case TARGET_RANDOM_ENEMY_CHAIN_IN_AREA:
{ {
@ -1406,11 +1406,11 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
cell.data.Part.reserved = ALL_DISTRICT; cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate(); cell.SetNoCreate();
std::list<Unit *> tempUnitMap; std::list<Unit *> tempTargetUnitMap;
{ {
MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(m_caster, m_caster, max_range); MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(m_caster, m_caster, max_range);
MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(m_caster, tempUnitMap, u_check); MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(m_caster, tempTargetUnitMap, u_check);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
@ -1420,34 +1420,34 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
cell_lock->Visit(cell_lock, grid_unit_searcher, *m_caster->GetMap(), *m_caster, max_range); cell_lock->Visit(cell_lock, grid_unit_searcher, *m_caster->GetMap(), *m_caster, max_range);
} }
if(tempUnitMap.empty()) if(tempTargetUnitMap.empty())
break; break;
tempUnitMap.sort(TargetDistanceOrder(m_caster)); tempTargetUnitMap.sort(TargetDistanceOrder(m_caster));
//Now to get us a random target that's in the initial range of the spell //Now to get us a random target that's in the initial range of the spell
uint32 t = 0; uint32 t = 0;
std::list<Unit *>::iterator itr = tempUnitMap.begin(); std::list<Unit *>::iterator itr = tempTargetUnitMap.begin();
while(itr!= tempUnitMap.end() && (*itr)->IsWithinDist(m_caster,radius)) while(itr!= tempTargetUnitMap.end() && (*itr)->IsWithinDist(m_caster, radius))
++t, ++itr; ++t, ++itr;
if(!t) if(!t)
break; break;
itr = tempUnitMap.begin(); itr = tempTargetUnitMap.begin();
std::advance(itr, rand()%t); std::advance(itr, rand()%t);
Unit *pUnitTarget = *itr; Unit *pUnitTarget = *itr;
TagUnitMap.push_back(pUnitTarget); targetUnitMap.push_back(pUnitTarget);
tempUnitMap.erase(itr); tempTargetUnitMap.erase(itr);
tempUnitMap.sort(TargetDistanceOrder(pUnitTarget)); tempTargetUnitMap.sort(TargetDistanceOrder(pUnitTarget));
t = unMaxTargets - 1; t = unMaxTargets - 1;
Unit *prev = pUnitTarget; Unit *prev = pUnitTarget;
std::list<Unit*>::iterator next = tempUnitMap.begin(); std::list<Unit*>::iterator next = tempTargetUnitMap.begin();
while(t && next != tempUnitMap.end() ) while(t && next != tempTargetUnitMap.end() )
{ {
if(!prev->IsWithinDist(*next,CHAIN_SPELL_JUMP_RADIUS)) if(!prev->IsWithinDist(*next,CHAIN_SPELL_JUMP_RADIUS))
break; break;
@ -1459,10 +1459,10 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
} }
prev = *next; prev = *next;
TagUnitMap.push_back(prev); targetUnitMap.push_back(prev);
tempUnitMap.erase(next); tempTargetUnitMap.erase(next);
tempUnitMap.sort(TargetDistanceOrder(prev)); tempTargetUnitMap.sort(TargetDistanceOrder(prev));
next = tempUnitMap.begin(); next = tempTargetUnitMap.begin();
--t; --t;
} }
@ -1477,10 +1477,10 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
Cell cell(p); Cell cell(p);
cell.data.Part.reserved = ALL_DISTRICT; cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate(); cell.SetNoCreate();
std::list<Unit *> tempUnitMap; std::list<Unit *> tempTargetUnitMap;
{ {
MaNGOS::AnyFriendlyUnitInObjectRangeCheck u_check(m_caster, m_caster, max_range); MaNGOS::AnyFriendlyUnitInObjectRangeCheck u_check(m_caster, m_caster, max_range);
MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck> searcher(m_caster, tempUnitMap, u_check); MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck> searcher(m_caster, tempTargetUnitMap, u_check);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
@ -1490,34 +1490,34 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
cell_lock->Visit(cell_lock, grid_unit_searcher, *m_caster->GetMap(), *m_caster, max_range); cell_lock->Visit(cell_lock, grid_unit_searcher, *m_caster->GetMap(), *m_caster, max_range);
} }
if(tempUnitMap.empty()) if(tempTargetUnitMap.empty())
break; break;
tempUnitMap.sort(TargetDistanceOrder(m_caster)); tempTargetUnitMap.sort(TargetDistanceOrder(m_caster));
//Now to get us a random target that's in the initial range of the spell //Now to get us a random target that's in the initial range of the spell
uint32 t = 0; uint32 t = 0;
std::list<Unit *>::iterator itr = tempUnitMap.begin(); std::list<Unit *>::iterator itr = tempTargetUnitMap.begin();
while(itr!= tempUnitMap.end() && (*itr)->IsWithinDist(m_caster,radius)) while(itr!= tempTargetUnitMap.end() && (*itr)->IsWithinDist(m_caster, radius))
++t, ++itr; ++t, ++itr;
if(!t) if(!t)
break; break;
itr = tempUnitMap.begin(); itr = tempTargetUnitMap.begin();
std::advance(itr, rand()%t); std::advance(itr, rand()%t);
Unit *pUnitTarget = *itr; Unit *pUnitTarget = *itr;
TagUnitMap.push_back(pUnitTarget); targetUnitMap.push_back(pUnitTarget);
tempUnitMap.erase(itr); tempTargetUnitMap.erase(itr);
tempUnitMap.sort(TargetDistanceOrder(pUnitTarget)); tempTargetUnitMap.sort(TargetDistanceOrder(pUnitTarget));
t = unMaxTargets - 1; t = unMaxTargets - 1;
Unit *prev = pUnitTarget; Unit *prev = pUnitTarget;
std::list<Unit*>::iterator next = tempUnitMap.begin(); std::list<Unit*>::iterator next = tempTargetUnitMap.begin();
while(t && next != tempUnitMap.end() ) while(t && next != tempTargetUnitMap.end())
{ {
if(!prev->IsWithinDist(*next,CHAIN_SPELL_JUMP_RADIUS)) if(!prev->IsWithinDist(*next,CHAIN_SPELL_JUMP_RADIUS))
break; break;
@ -1528,10 +1528,10 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
continue; continue;
} }
prev = *next; prev = *next;
TagUnitMap.push_back(prev); targetUnitMap.push_back(prev);
tempUnitMap.erase(next); tempTargetUnitMap.erase(next);
tempUnitMap.sort(TargetDistanceOrder(prev)); tempTargetUnitMap.sort(TargetDistanceOrder(prev));
next = tempUnitMap.begin(); next = tempTargetUnitMap.begin();
--t; --t;
} }
break; break;
@ -1540,7 +1540,7 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
{ {
Pet* tmpUnit = m_caster->GetPet(); Pet* tmpUnit = m_caster->GetPet();
if (!tmpUnit) break; if (!tmpUnit) break;
TagUnitMap.push_back(tmpUnit); targetUnitMap.push_back(tmpUnit);
break; break;
} }
case TARGET_CHAIN_DAMAGE: case TARGET_CHAIN_DAMAGE:
@ -1550,7 +1550,7 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
if(Unit* pUnitTarget = m_caster->SelectMagnetTarget(m_targets.getUnitTarget(), m_spellInfo)) if(Unit* pUnitTarget = m_caster->SelectMagnetTarget(m_targets.getUnitTarget(), m_spellInfo))
{ {
m_targets.setUnitTarget(pUnitTarget); m_targets.setUnitTarget(pUnitTarget);
TagUnitMap.push_back(pUnitTarget); targetUnitMap.push_back(pUnitTarget);
} }
} }
else else
@ -1574,10 +1574,10 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
cell.data.Part.reserved = ALL_DISTRICT; cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate(); cell.SetNoCreate();
std::list<Unit *> tempUnitMap; std::list<Unit *> tempTargetUnitMap;
{ {
MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(pUnitTarget, originalCaster, max_range, false); MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(pUnitTarget, originalCaster, max_range, false);
MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(m_caster, tempUnitMap, u_check); MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(m_caster, tempTargetUnitMap, u_check);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer> world_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer> world_unit_searcher(searcher);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer> grid_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer> grid_unit_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p); CellLock<GridReadGuard> cell_lock(cell, p);
@ -1585,20 +1585,20 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
cell_lock->Visit(cell_lock, world_unit_searcher, *m_caster->GetMap(), *pUnitTarget, max_range); cell_lock->Visit(cell_lock, world_unit_searcher, *m_caster->GetMap(), *pUnitTarget, max_range);
cell_lock->Visit(cell_lock, grid_unit_searcher, *m_caster->GetMap(), *pUnitTarget, max_range); cell_lock->Visit(cell_lock, grid_unit_searcher, *m_caster->GetMap(), *pUnitTarget, max_range);
} }
if (tempUnitMap.empty()) if (tempTargetUnitMap.empty())
break; break;
tempUnitMap.sort(TargetDistanceOrder(pUnitTarget)); tempTargetUnitMap.sort(TargetDistanceOrder(pUnitTarget));
if (*tempUnitMap.begin() == pUnitTarget) if (*tempTargetUnitMap.begin() == pUnitTarget)
tempUnitMap.erase (tempUnitMap.begin()); tempTargetUnitMap.erase(tempTargetUnitMap.begin());
TagUnitMap.push_back(pUnitTarget); targetUnitMap.push_back(pUnitTarget);
uint32 t = unMaxTargets - 1; uint32 t = unMaxTargets - 1;
Unit *prev = pUnitTarget; Unit *prev = pUnitTarget;
std::list<Unit*>::iterator next = tempUnitMap.begin(); std::list<Unit*>::iterator next = tempTargetUnitMap.begin();
while (t && next != tempUnitMap.end()) while (t && next != tempTargetUnitMap.end())
{ {
if (!prev->IsWithinDist (*next,CHAIN_SPELL_JUMP_RADIUS)) if (!prev->IsWithinDist (*next,CHAIN_SPELL_JUMP_RADIUS))
break; break;
@ -1608,17 +1608,17 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
continue; continue;
} }
prev = *next; prev = *next;
TagUnitMap.push_back(prev); targetUnitMap.push_back(prev);
tempUnitMap.erase(next); tempTargetUnitMap.erase(next);
tempUnitMap.sort (TargetDistanceOrder(prev)); tempTargetUnitMap.sort(TargetDistanceOrder(prev));
next = tempUnitMap.begin(); next = tempTargetUnitMap.begin();
--t; --t;
} }
} }
break; break;
} }
case TARGET_ALL_ENEMY_IN_AREA: case TARGET_ALL_ENEMY_IN_AREA:
FillAreaTargets(TagUnitMap,m_targets.m_destX, m_targets.m_destY,radius,PUSH_DEST_CENTER,SPELL_TARGETS_AOE_DAMAGE); FillAreaTargets(targetUnitMap, m_targets.m_destX, m_targets.m_destY, radius, PUSH_DEST_CENTER, SPELL_TARGETS_AOE_DAMAGE);
break; break;
case TARGET_AREAEFFECT_INSTANT: case TARGET_AREAEFFECT_INSTANT:
{ {
@ -1627,10 +1627,10 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
if (IsPositiveEffect(m_spellInfo->Id, effIndex)) if (IsPositiveEffect(m_spellInfo->Id, effIndex))
targetB = SPELL_TARGETS_FRIENDLY; targetB = SPELL_TARGETS_FRIENDLY;
FillAreaTargets(TagUnitMap,m_caster->GetPositionX(), m_caster->GetPositionY(),radius, PUSH_DEST_CENTER, targetB); FillAreaTargets(targetUnitMap, m_caster->GetPositionX(), m_caster->GetPositionY(), radius, PUSH_DEST_CENTER, targetB);
// exclude caster // exclude caster
TagUnitMap.remove(m_caster); targetUnitMap.remove(m_caster);
break; break;
} }
case TARGET_ALL_ENEMY_IN_AREA_INSTANT: case TARGET_ALL_ENEMY_IN_AREA_INSTANT:
@ -1641,10 +1641,10 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
case SPELL_EFFECT_PERSISTENT_AREA_AURA: case SPELL_EFFECT_PERSISTENT_AREA_AURA:
break; break;
case SPELL_EFFECT_SUMMON: case SPELL_EFFECT_SUMMON:
TagUnitMap.push_back(m_caster); targetUnitMap.push_back(m_caster);
break; break;
default: default:
FillAreaTargets(TagUnitMap,m_targets.m_destX, m_targets.m_destY,radius,PUSH_DEST_CENTER,SPELL_TARGETS_AOE_DAMAGE); FillAreaTargets(targetUnitMap, m_targets.m_destX, m_targets.m_destY, radius, PUSH_DEST_CENTER, SPELL_TARGETS_AOE_DAMAGE);
break; break;
} }
break; break;
@ -1654,34 +1654,34 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
if(Unit* currentTarget = m_targets.getUnitTarget()) if(Unit* currentTarget = m_targets.getUnitTarget())
{ {
m_targets.setDestination(currentTarget->GetPositionX(), currentTarget->GetPositionY(), currentTarget->GetPositionZ()); m_targets.setDestination(currentTarget->GetPositionX(), currentTarget->GetPositionY(), currentTarget->GetPositionZ());
TagUnitMap.push_back(currentTarget); targetUnitMap.push_back(currentTarget);
} }
break; break;
} }
case TARGET_ALL_PARTY_AROUND_CASTER: case TARGET_ALL_PARTY_AROUND_CASTER:
case TARGET_ALL_PARTY_AROUND_CASTER_2: case TARGET_ALL_PARTY_AROUND_CASTER_2:
case TARGET_ALL_PARTY: case TARGET_ALL_PARTY:
FillRaidOrPartyTargets(TagUnitMap, m_caster, m_caster, radius, false, true, true); FillRaidOrPartyTargets(targetUnitMap, m_caster, m_caster, radius, false, true, true);
break; break;
case TARGET_ALL_RAID_AROUND_CASTER: case TARGET_ALL_RAID_AROUND_CASTER:
{ {
if(m_spellInfo->Id == 57669) // Replenishment (special target selection) if(m_spellInfo->Id == 57669) // Replenishment (special target selection)
FillRaidOrPartyManaPriorityTargets(TagUnitMap, m_caster, m_caster, radius, 10, true, false, true); FillRaidOrPartyManaPriorityTargets(targetUnitMap, m_caster, m_caster, radius, 10, true, false, true);
else if (m_spellInfo->Id==52759) // Ancestral Awakening (special target selection) else if (m_spellInfo->Id==52759) // Ancestral Awakening (special target selection)
FillRaidOrPartyHealthPriorityTargets(TagUnitMap, m_caster, m_caster, radius, 1, true, false, true); FillRaidOrPartyHealthPriorityTargets(targetUnitMap, m_caster, m_caster, radius, 1, true, false, true);
else else
FillRaidOrPartyTargets(TagUnitMap, m_caster, m_caster, radius, true, true, true); FillRaidOrPartyTargets(targetUnitMap, m_caster, m_caster, radius, true, true, true);
break; break;
} }
case TARGET_SINGLE_FRIEND: case TARGET_SINGLE_FRIEND:
case TARGET_SINGLE_FRIEND_2: case TARGET_SINGLE_FRIEND_2:
if(m_targets.getUnitTarget()) if(m_targets.getUnitTarget())
TagUnitMap.push_back(m_targets.getUnitTarget()); targetUnitMap.push_back(m_targets.getUnitTarget());
break; break;
case TARGET_NONCOMBAT_PET: case TARGET_NONCOMBAT_PET:
if(Unit* target = m_targets.getUnitTarget()) if(Unit* target = m_targets.getUnitTarget())
if( target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isPet() && ((Pet*)target)->getPetType() == MINI_PET) if( target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isPet() && ((Pet*)target)->getPetType() == MINI_PET)
TagUnitMap.push_back(target); targetUnitMap.push_back(target);
break; break;
case TARGET_CASTER_COORDINATES: case TARGET_CASTER_COORDINATES:
{ {
@ -1696,21 +1696,21 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
break; break;
} }
case TARGET_ALL_HOSTILE_UNITS_AROUND_CASTER: case TARGET_ALL_HOSTILE_UNITS_AROUND_CASTER:
FillAreaTargets(TagUnitMap, m_targets.m_destX, m_targets.m_destY, radius, PUSH_SELF_CENTER, SPELL_TARGETS_HOSTILE); FillAreaTargets(targetUnitMap, m_targets.m_destX, m_targets.m_destY, radius, PUSH_SELF_CENTER, SPELL_TARGETS_HOSTILE);
break; break;
case TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER: case TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER:
switch (m_spellInfo->Id) switch (m_spellInfo->Id)
{ {
case 64844: // Divine Hymn case 64844: // Divine Hymn
// target amount stored in parent spell dummy effect but hard to access // target amount stored in parent spell dummy effect but hard to access
FillRaidOrPartyHealthPriorityTargets(TagUnitMap, m_caster, m_caster, radius, 3, true, false, false); FillRaidOrPartyHealthPriorityTargets(targetUnitMap, m_caster, m_caster, radius, 3, true, false, false);
break; break;
case 64904: // Hymn of Hope case 64904: // Hymn of Hope
// target amount stored in parent spell dummy effect but hard to access // target amount stored in parent spell dummy effect but hard to access
FillRaidOrPartyManaPriorityTargets(TagUnitMap, m_caster, m_caster, radius, 3, true, false, false); FillRaidOrPartyManaPriorityTargets(targetUnitMap, m_caster, m_caster, radius, 3, true, false, false);
break; break;
default: default:
FillAreaTargets(TagUnitMap, m_targets.m_destX, m_targets.m_destY, radius, PUSH_SELF_CENTER, SPELL_TARGETS_FRIENDLY); FillAreaTargets(targetUnitMap, m_targets.m_destX, m_targets.m_destY, radius, PUSH_SELF_CENTER, SPELL_TARGETS_FRIENDLY);
break; break;
} }
break; break;
@ -1721,7 +1721,7 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
// checked in Spell::CheckCast // checked in Spell::CheckCast
if (m_caster->GetTypeId()==TYPEID_PLAYER) if (m_caster->GetTypeId()==TYPEID_PLAYER)
if (Unit* target = m_caster->GetMap()->GetPet(((Player*)m_caster)->GetSelection())) if (Unit* target = m_caster->GetMap()->GetPet(((Player*)m_caster)->GetSelection()))
TagUnitMap.push_back(target); targetUnitMap.push_back(target);
} }
// Wild Growth // Wild Growth
else if (m_spellInfo->SpellFamilyName == SPELLFAMILY_DRUID && m_spellInfo->SpellIconID == 2864) else if (m_spellInfo->SpellFamilyName == SPELLFAMILY_DRUID && m_spellInfo->SpellIconID == 2864)
@ -1731,10 +1731,10 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
target = m_caster; target = m_caster;
uint32 count = CalculateDamage(2,m_caster); // stored in dummy effect, affected by mods uint32 count = CalculateDamage(2,m_caster); // stored in dummy effect, affected by mods
FillRaidOrPartyHealthPriorityTargets(TagUnitMap, m_caster, target, radius, count, true, false, true); FillRaidOrPartyHealthPriorityTargets(targetUnitMap, m_caster, target, radius, count, true, false, true);
} }
else else
FillAreaTargets(TagUnitMap, m_targets.m_destX, m_targets.m_destY, radius, PUSH_DEST_CENTER, SPELL_TARGETS_FRIENDLY); FillAreaTargets(targetUnitMap, m_targets.m_destX, m_targets.m_destY, radius, PUSH_DEST_CENTER, SPELL_TARGETS_FRIENDLY);
break; break;
// TARGET_SINGLE_PARTY means that the spells can only be casted on a party member and not on the caster (some seals, fire shield from imp, etc..) // TARGET_SINGLE_PARTY means that the spells can only be casted on a party member and not on the caster (some seals, fire shield from imp, etc..)
case TARGET_SINGLE_PARTY: case TARGET_SINGLE_PARTY:
@ -1754,7 +1754,7 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
{ {
if( target == owner ) if( target == owner )
{ {
TagUnitMap.push_back(target); targetUnitMap.push_back(target);
break; break;
} }
pGroup = ((Player*)owner)->GetGroup(); pGroup = ((Player*)owner)->GetGroup();
@ -1764,7 +1764,7 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
{ {
if( targetOwner == m_caster && target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isPet()) if( targetOwner == m_caster && target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isPet())
{ {
TagUnitMap.push_back(target); targetUnitMap.push_back(target);
break; break;
} }
pGroup = ((Player*)m_caster)->GetGroup(); pGroup = ((Player*)m_caster)->GetGroup();
@ -1780,13 +1780,13 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
target->GetOwnerGUID() == targetOwner->GetGUID() && target->GetOwnerGUID() == targetOwner->GetGUID() &&
pGroup->IsMember(((Player*)targetOwner)->GetGUID())) pGroup->IsMember(((Player*)targetOwner)->GetGUID()))
{ {
TagUnitMap.push_back(target); targetUnitMap.push_back(target);
} }
} }
// 1Our target can be a player who is on our group // 1Our target can be a player who is on our group
else if (target->GetTypeId() == TYPEID_PLAYER && pGroup->IsMember(((Player*)target)->GetGUID())) else if (target->GetTypeId() == TYPEID_PLAYER && pGroup->IsMember(((Player*)target)->GetGUID()))
{ {
TagUnitMap.push_back(target); targetUnitMap.push_back(target);
} }
} }
} }
@ -1799,17 +1799,17 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
case TARGET_IN_FRONT_OF_CASTER: case TARGET_IN_FRONT_OF_CASTER:
{ {
bool inFront = m_spellInfo->SpellVisual[0] != 3879; bool inFront = m_spellInfo->SpellVisual[0] != 3879;
FillAreaTargets(TagUnitMap,m_caster->GetPositionX(), m_caster->GetPositionY(),radius,inFront ? PUSH_IN_FRONT : PUSH_IN_BACK,SPELL_TARGETS_AOE_DAMAGE); FillAreaTargets(targetUnitMap, m_caster->GetPositionX(), m_caster->GetPositionY(), radius, inFront ? PUSH_IN_FRONT : PUSH_IN_BACK, SPELL_TARGETS_AOE_DAMAGE);
break; break;
} }
case TARGET_LARGE_FRONTAL_CONE: case TARGET_LARGE_FRONTAL_CONE:
FillAreaTargets(TagUnitMap,m_caster->GetPositionX(), m_caster->GetPositionY(), radius, PUSH_IN_FRONT_90, SPELL_TARGETS_AOE_DAMAGE); FillAreaTargets(targetUnitMap, m_caster->GetPositionX(), m_caster->GetPositionY(), radius, PUSH_IN_FRONT_90, SPELL_TARGETS_AOE_DAMAGE);
break; break;
case TARGET_NARROW_FRONTAL_CONE: case TARGET_NARROW_FRONTAL_CONE:
FillAreaTargets(TagUnitMap,m_caster->GetPositionX(), m_caster->GetPositionY(), radius, PUSH_IN_FRONT_15, SPELL_TARGETS_AOE_DAMAGE); FillAreaTargets(targetUnitMap, m_caster->GetPositionX(), m_caster->GetPositionY(), radius, PUSH_IN_FRONT_15, SPELL_TARGETS_AOE_DAMAGE);
break; break;
case TARGET_IN_FRONT_OF_CASTER_30: case TARGET_IN_FRONT_OF_CASTER_30:
FillAreaTargets(TagUnitMap,m_caster->GetPositionX(), m_caster->GetPositionY(), radius, PUSH_IN_FRONT_30, SPELL_TARGETS_AOE_DAMAGE); FillAreaTargets(targetUnitMap, m_caster->GetPositionX(), m_caster->GetPositionY(), radius, PUSH_IN_FRONT_30, SPELL_TARGETS_AOE_DAMAGE);
break; break;
case TARGET_DUELVSPLAYER: case TARGET_DUELVSPLAYER:
{ {
@ -1818,14 +1818,14 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
{ {
if(m_caster->IsFriendlyTo(target)) if(m_caster->IsFriendlyTo(target))
{ {
TagUnitMap.push_back(target); targetUnitMap.push_back(target);
} }
else else
{ {
if(Unit* pUnitTarget = m_caster->SelectMagnetTarget(m_targets.getUnitTarget(), m_spellInfo)) if(Unit* pUnitTarget = m_caster->SelectMagnetTarget(m_targets.getUnitTarget(), m_spellInfo))
{ {
m_targets.setUnitTarget(pUnitTarget); m_targets.setUnitTarget(pUnitTarget);
TagUnitMap.push_back(pUnitTarget); targetUnitMap.push_back(pUnitTarget);
} }
} }
} }
@ -1839,23 +1839,23 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
break; break;
case TARGET_MASTER: case TARGET_MASTER:
if(Unit* owner = m_caster->GetCharmerOrOwner()) if(Unit* owner = m_caster->GetCharmerOrOwner())
TagUnitMap.push_back(owner); targetUnitMap.push_back(owner);
break; break;
case TARGET_ALL_ENEMY_IN_AREA_CHANNELED: case TARGET_ALL_ENEMY_IN_AREA_CHANNELED:
// targets the ground, not the units in the area // targets the ground, not the units in the area
if (m_spellInfo->Effect[effIndex]!=SPELL_EFFECT_PERSISTENT_AREA_AURA) if (m_spellInfo->Effect[effIndex]!=SPELL_EFFECT_PERSISTENT_AREA_AURA)
FillAreaTargets(TagUnitMap, m_targets.m_destX, m_targets.m_destY, radius, PUSH_DEST_CENTER, SPELL_TARGETS_AOE_DAMAGE); FillAreaTargets(targetUnitMap, m_targets.m_destX, m_targets.m_destY, radius, PUSH_DEST_CENTER, SPELL_TARGETS_AOE_DAMAGE);
break; break;
case TARGET_MINION: case TARGET_MINION:
if(m_spellInfo->Effect[effIndex] != SPELL_EFFECT_DUEL) if(m_spellInfo->Effect[effIndex] != SPELL_EFFECT_DUEL)
TagUnitMap.push_back(m_caster); targetUnitMap.push_back(m_caster);
break; break;
case TARGET_SINGLE_ENEMY: case TARGET_SINGLE_ENEMY:
{ {
if(Unit* pUnitTarget = m_caster->SelectMagnetTarget(m_targets.getUnitTarget(), m_spellInfo)) if(Unit* pUnitTarget = m_caster->SelectMagnetTarget(m_targets.getUnitTarget(), m_spellInfo))
{ {
m_targets.setUnitTarget(pUnitTarget); m_targets.setUnitTarget(pUnitTarget);
TagUnitMap.push_back(pUnitTarget); targetUnitMap.push_back(pUnitTarget);
} }
break; break;
} }
@ -1866,7 +1866,7 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
if(owner) if(owner)
{ {
TagUnitMap.push_back(m_caster); targetUnitMap.push_back(m_caster);
if(owner->GetTypeId() == TYPEID_PLAYER) if(owner->GetTypeId() == TYPEID_PLAYER)
pTarget = (Player*)owner; pTarget = (Player*)owner;
} }
@ -1902,39 +1902,39 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
if(Target && Target->GetSubGroup()==subgroup && !m_caster->IsHostileTo(Target)) if(Target && Target->GetSubGroup()==subgroup && !m_caster->IsHostileTo(Target))
{ {
if( pTarget->IsWithinDistInMap(Target, radius) ) if( pTarget->IsWithinDistInMap(Target, radius) )
TagUnitMap.push_back(Target); targetUnitMap.push_back(Target);
if(Pet* pet = Target->GetPet()) if(Pet* pet = Target->GetPet())
if( pTarget->IsWithinDistInMap(pet, radius) ) if( pTarget->IsWithinDistInMap(pet, radius) )
TagUnitMap.push_back(pet); targetUnitMap.push_back(pet);
} }
} }
} }
else if (owner) else if (owner)
{ {
if(m_caster->IsWithinDistInMap(owner, radius)) if(m_caster->IsWithinDistInMap(owner, radius))
TagUnitMap.push_back(owner); targetUnitMap.push_back(owner);
} }
else if(pTarget) else if(pTarget)
{ {
TagUnitMap.push_back(pTarget); targetUnitMap.push_back(pTarget);
if(Pet* pet = pTarget->GetPet()) if(Pet* pet = pTarget->GetPet())
if( m_caster->IsWithinDistInMap(pet, radius) ) if( m_caster->IsWithinDistInMap(pet, radius) )
TagUnitMap.push_back(pet); targetUnitMap.push_back(pet);
} }
break; break;
} }
case TARGET_SCRIPT: case TARGET_SCRIPT:
{ {
if(m_targets.getUnitTarget()) if(m_targets.getUnitTarget())
TagUnitMap.push_back(m_targets.getUnitTarget()); targetUnitMap.push_back(m_targets.getUnitTarget());
if(m_targets.getItemTarget()) if(m_targets.getItemTarget())
AddItemTarget(m_targets.getItemTarget(), effIndex); AddItemTarget(m_targets.getItemTarget(), effIndex);
break; break;
} }
case TARGET_SELF_FISHING: case TARGET_SELF_FISHING:
TagUnitMap.push_back(m_caster); targetUnitMap.push_back(m_caster);
break; break;
case TARGET_CHAIN_HEAL: case TARGET_CHAIN_HEAL:
{ {
@ -1943,33 +1943,33 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
break; break;
if (EffectChainTarget <= 1) if (EffectChainTarget <= 1)
TagUnitMap.push_back(pUnitTarget); targetUnitMap.push_back(pUnitTarget);
else else
{ {
unMaxTargets = EffectChainTarget; unMaxTargets = EffectChainTarget;
float max_range = radius + unMaxTargets * CHAIN_SPELL_JUMP_RADIUS; float max_range = radius + unMaxTargets * CHAIN_SPELL_JUMP_RADIUS;
UnitList tempUnitMap; UnitList tempTargetUnitMap;
FillAreaTargets(tempUnitMap, m_caster->GetPositionX(), m_caster->GetPositionY(), max_range, PUSH_SELF_CENTER, SPELL_TARGETS_FRIENDLY); FillAreaTargets(tempTargetUnitMap, m_caster->GetPositionX(), m_caster->GetPositionY(), max_range, PUSH_SELF_CENTER, SPELL_TARGETS_FRIENDLY);
if(m_caster != pUnitTarget && std::find(tempUnitMap.begin(),tempUnitMap.end(), m_caster) == tempUnitMap.end() ) if (m_caster != pUnitTarget && std::find(tempTargetUnitMap.begin(), tempTargetUnitMap.end(), m_caster) == tempTargetUnitMap.end())
tempUnitMap.push_front(m_caster); tempTargetUnitMap.push_front(m_caster);
tempUnitMap.sort(TargetDistanceOrder(pUnitTarget)); tempTargetUnitMap.sort(TargetDistanceOrder(pUnitTarget));
if(tempUnitMap.empty()) if (tempTargetUnitMap.empty())
break; break;
if(*tempUnitMap.begin() == pUnitTarget) if (*tempTargetUnitMap.begin() == pUnitTarget)
tempUnitMap.erase(tempUnitMap.begin()); tempTargetUnitMap.erase(tempTargetUnitMap.begin());
TagUnitMap.push_back(pUnitTarget); targetUnitMap.push_back(pUnitTarget);
uint32 t = unMaxTargets - 1; uint32 t = unMaxTargets - 1;
Unit *prev = pUnitTarget; Unit *prev = pUnitTarget;
std::list<Unit*>::iterator next = tempUnitMap.begin(); std::list<Unit*>::iterator next = tempTargetUnitMap.begin();
while(t && next != tempUnitMap.end() ) while(t && next != tempTargetUnitMap.end())
{ {
if(!prev->IsWithinDist(*next, CHAIN_SPELL_JUMP_RADIUS)) if(!prev->IsWithinDist(*next, CHAIN_SPELL_JUMP_RADIUS))
break; break;
@ -1982,15 +1982,15 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
if((*next)->GetHealth() == (*next)->GetMaxHealth()) if((*next)->GetHealth() == (*next)->GetMaxHealth())
{ {
next = tempUnitMap.erase(next); next = tempTargetUnitMap.erase(next);
continue; continue;
} }
prev = *next; prev = *next;
TagUnitMap.push_back(prev); targetUnitMap.push_back(prev);
tempUnitMap.erase(next); tempTargetUnitMap.erase(next);
tempUnitMap.sort(TargetDistanceOrder(prev)); tempTargetUnitMap.sort(TargetDistanceOrder(prev));
next = tempUnitMap.begin(); next = tempTargetUnitMap.begin();
--t; --t;
} }
@ -2002,10 +2002,10 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
Unit* currentTarget = m_targets.getUnitTarget(); Unit* currentTarget = m_targets.getUnitTarget();
if(currentTarget) if(currentTarget)
{ {
TagUnitMap.push_back(currentTarget); targetUnitMap.push_back(currentTarget);
m_targets.setDestination(currentTarget->GetPositionX(), currentTarget->GetPositionY(), currentTarget->GetPositionZ()); m_targets.setDestination(currentTarget->GetPositionX(), currentTarget->GetPositionY(), currentTarget->GetPositionZ());
if(m_spellInfo->EffectImplicitTargetB[effIndex]==TARGET_ALL_ENEMY_IN_AREA_INSTANT) if(m_spellInfo->EffectImplicitTargetB[effIndex]==TARGET_ALL_ENEMY_IN_AREA_INSTANT)
FillAreaTargets(TagUnitMap, currentTarget->GetPositionX(), currentTarget->GetPositionY(), radius, PUSH_TARGET_CENTER, SPELL_TARGETS_AOE_DAMAGE); FillAreaTargets(targetUnitMap, currentTarget->GetPositionX(), currentTarget->GetPositionY(), radius, PUSH_TARGET_CENTER, SPELL_TARGETS_AOE_DAMAGE);
} }
break; break;
} }
@ -2026,12 +2026,12 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
targetPlayer->getClass() == Target->getClass() && targetPlayer->getClass() == Target->getClass() &&
!m_caster->IsHostileTo(Target) ) !m_caster->IsHostileTo(Target) )
{ {
TagUnitMap.push_back(Target); targetUnitMap.push_back(Target);
} }
} }
} }
else if(m_targets.getUnitTarget()) else if(m_targets.getUnitTarget())
TagUnitMap.push_back(m_targets.getUnitTarget()); targetUnitMap.push_back(m_targets.getUnitTarget());
break; break;
} }
case TARGET_TABLE_X_Y_Z_COORDINATES: case TARGET_TABLE_X_Y_Z_COORDINATES:
@ -2084,7 +2084,7 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
pTarget->GetClosePoint(_target_x, _target_y, _target_z, pTarget->GetObjectSize(), dist, angle); pTarget->GetClosePoint(_target_x, _target_y, _target_z, pTarget->GetObjectSize(), dist, angle);
if(pTarget->IsWithinLOS(_target_x, _target_y, _target_z)) if(pTarget->IsWithinLOS(_target_x, _target_y, _target_z))
{ {
TagUnitMap.push_back(m_caster); targetUnitMap.push_back(m_caster);
m_targets.setDestination(_target_x, _target_y, _target_z); m_targets.setDestination(_target_x, _target_y, _target_z);
} }
} }
@ -2114,7 +2114,7 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
m_targets.setDestination(x,y,m_caster->GetPositionZ()); m_targets.setDestination(x,y,m_caster->GetPositionZ());
} }
TagUnitMap.push_back(m_caster); targetUnitMap.push_back(m_caster);
break; break;
case TARGET_POINT_AT_NORTH: case TARGET_POINT_AT_NORTH:
@ -2164,7 +2164,7 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
m_targets.setDestination(_target_x, _target_y, _target_z); m_targets.setDestination(_target_x, _target_y, _target_z);
} }
TagUnitMap.push_back(m_caster); targetUnitMap.push_back(m_caster);
break; break;
} }
case TARGET_EFFECT_SELECT: case TARGET_EFFECT_SELECT:
@ -2187,12 +2187,12 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
{ {
case TYPEID_UNIT: case TYPEID_UNIT:
case TYPEID_PLAYER: case TYPEID_PLAYER:
TagUnitMap.push_back((Unit*)result); targetUnitMap.push_back((Unit*)result);
break; break;
case TYPEID_CORPSE: case TYPEID_CORPSE:
m_targets.setCorpseTarget((Corpse*)result); m_targets.setCorpseTarget((Corpse*)result);
if (Player* owner = ObjectAccessor::FindPlayer(((Corpse*)result)->GetOwnerGUID())) if (Player* owner = ObjectAccessor::FindPlayer(((Corpse*)result)->GetOwnerGUID()))
TagUnitMap.push_back(owner); targetUnitMap.push_back(owner);
break; break;
} }
} }
@ -2208,7 +2208,7 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
} }
default: default:
if (m_targets.getUnitTarget()) if (m_targets.getUnitTarget())
TagUnitMap.push_back(m_targets.getUnitTarget()); targetUnitMap.push_back(m_targets.getUnitTarget());
break; break;
} }
break; break;
@ -2227,22 +2227,22 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
case SPELL_EFFECT_REPUTATION: case SPELL_EFFECT_REPUTATION:
case SPELL_EFFECT_SEND_TAXI: case SPELL_EFFECT_SEND_TAXI:
if (m_targets.getUnitTarget()) if (m_targets.getUnitTarget())
TagUnitMap.push_back(m_targets.getUnitTarget()); targetUnitMap.push_back(m_targets.getUnitTarget());
// Triggered spells have additional spell targets - cast them even if no explicit unit target is given (required for spell 50516 for example) // Triggered spells have additional spell targets - cast them even if no explicit unit target is given (required for spell 50516 for example)
else if (m_spellInfo->Effect[effIndex] == SPELL_EFFECT_TRIGGER_SPELL) else if (m_spellInfo->Effect[effIndex] == SPELL_EFFECT_TRIGGER_SPELL)
TagUnitMap.push_back(m_caster); targetUnitMap.push_back(m_caster);
break; break;
case SPELL_EFFECT_SUMMON_PLAYER: case SPELL_EFFECT_SUMMON_PLAYER:
if (m_caster->GetTypeId()==TYPEID_PLAYER && ((Player*)m_caster)->GetSelection()) if (m_caster->GetTypeId()==TYPEID_PLAYER && ((Player*)m_caster)->GetSelection())
{ {
Player* target = sObjectMgr.GetPlayer(((Player*)m_caster)->GetSelection()); Player* target = sObjectMgr.GetPlayer(((Player*)m_caster)->GetSelection());
if(target) if(target)
TagUnitMap.push_back(target); targetUnitMap.push_back(target);
} }
break; break;
case SPELL_EFFECT_RESURRECT_NEW: case SPELL_EFFECT_RESURRECT_NEW:
if (m_targets.getUnitTarget()) if (m_targets.getUnitTarget())
TagUnitMap.push_back(m_targets.getUnitTarget()); targetUnitMap.push_back(m_targets.getUnitTarget());
if (m_targets.getCorpseTargetGUID()) if (m_targets.getCorpseTargetGUID())
{ {
Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID()); Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID());
@ -2250,12 +2250,12 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
{ {
Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID()); Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID());
if(owner) if(owner)
TagUnitMap.push_back(owner); targetUnitMap.push_back(owner);
} }
} }
break; break;
case SPELL_EFFECT_SUMMON: case SPELL_EFFECT_SUMMON:
TagUnitMap.push_back(m_caster); targetUnitMap.push_back(m_caster);
break; break;
case SPELL_EFFECT_SUMMON_CHANGE_ITEM: case SPELL_EFFECT_SUMMON_CHANGE_ITEM:
case SPELL_EFFECT_TRANS_DOOR: case SPELL_EFFECT_TRANS_DOOR:
@ -2265,11 +2265,11 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
case SPELL_EFFECT_FEED_PET: case SPELL_EFFECT_FEED_PET:
case SPELL_EFFECT_DESTROY_ALL_TOTEMS: case SPELL_EFFECT_DESTROY_ALL_TOTEMS:
case SPELL_EFFECT_SKILL: case SPELL_EFFECT_SKILL:
TagUnitMap.push_back(m_caster); targetUnitMap.push_back(m_caster);
break; break;
case SPELL_EFFECT_LEARN_PET_SPELL: case SPELL_EFFECT_LEARN_PET_SPELL:
if (Pet* pet = m_caster->GetPet()) if (Pet* pet = m_caster->GetPet())
TagUnitMap.push_back(pet); targetUnitMap.push_back(pet);
break; break;
case SPELL_EFFECT_ENCHANT_ITEM: case SPELL_EFFECT_ENCHANT_ITEM:
case SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY: case SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY:
@ -2285,27 +2285,27 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
{ {
case SPELL_AURA_ADD_FLAT_MODIFIER: // some spell mods auras have 0 target modes instead expected TARGET_SELF(1) (and present for other ranks for same spell for example) case SPELL_AURA_ADD_FLAT_MODIFIER: // some spell mods auras have 0 target modes instead expected TARGET_SELF(1) (and present for other ranks for same spell for example)
case SPELL_AURA_ADD_PCT_MODIFIER: case SPELL_AURA_ADD_PCT_MODIFIER:
TagUnitMap.push_back(m_caster); targetUnitMap.push_back(m_caster);
break; break;
default: // apply to target in other case default: // apply to target in other case
if (m_targets.getUnitTarget()) if (m_targets.getUnitTarget())
TagUnitMap.push_back(m_targets.getUnitTarget()); targetUnitMap.push_back(m_targets.getUnitTarget());
break; break;
} }
break; break;
case SPELL_EFFECT_APPLY_AREA_AURA_PARTY: case SPELL_EFFECT_APPLY_AREA_AURA_PARTY:
// AreaAura // AreaAura
if(m_spellInfo->Attributes == 0x9050000 || m_spellInfo->Attributes == 0x10000) if(m_spellInfo->Attributes == 0x9050000 || m_spellInfo->Attributes == 0x10000)
SetTargetMap(effIndex,TARGET_AREAEFFECT_PARTY, TagUnitMap); SetTargetMap(effIndex, TARGET_AREAEFFECT_PARTY, targetUnitMap);
break; break;
case SPELL_EFFECT_SKIN_PLAYER_CORPSE: case SPELL_EFFECT_SKIN_PLAYER_CORPSE:
if (m_targets.getUnitTarget()) if (m_targets.getUnitTarget())
TagUnitMap.push_back(m_targets.getUnitTarget()); targetUnitMap.push_back(m_targets.getUnitTarget());
else if (m_targets.getCorpseTargetGUID()) else if (m_targets.getCorpseTargetGUID())
{ {
if (Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID())) if (Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID()))
if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID())) if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID()))
TagUnitMap.push_back(owner); targetUnitMap.push_back(owner);
} }
break; break;
@ -2319,40 +2319,40 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
break; break;
} }
if (unMaxTargets && TagUnitMap.size() > unMaxTargets) if (unMaxTargets && targetUnitMap.size() > unMaxTargets)
{ {
// make sure one unit is always removed per iteration // make sure one unit is always removed per iteration
uint32 removed_utarget = 0; uint32 removed_utarget = 0;
for (UnitList::iterator itr = TagUnitMap.begin(), next; itr != TagUnitMap.end(); itr = next) for (UnitList::iterator itr = targetUnitMap.begin(), next; itr != targetUnitMap.end(); itr = next)
{ {
next = itr; next = itr;
++next; ++next;
if (!*itr) continue; if (!*itr) continue;
if ((*itr) == m_targets.getUnitTarget()) if ((*itr) == m_targets.getUnitTarget())
{ {
TagUnitMap.erase(itr); targetUnitMap.erase(itr);
removed_utarget = 1; removed_utarget = 1;
// break; // break;
} }
} }
// remove random units from the map // remove random units from the map
while (TagUnitMap.size() > unMaxTargets - removed_utarget) while (targetUnitMap.size() > unMaxTargets - removed_utarget)
{ {
uint32 poz = urand(0, TagUnitMap.size()-1); uint32 poz = urand(0, targetUnitMap.size()-1);
for (UnitList::iterator itr = TagUnitMap.begin(); itr != TagUnitMap.end(); ++itr, --poz) for (UnitList::iterator itr = targetUnitMap.begin(); itr != targetUnitMap.end(); ++itr, --poz)
{ {
if (!*itr) continue; if (!*itr) continue;
if (!poz) if (!poz)
{ {
TagUnitMap.erase(itr); targetUnitMap.erase(itr);
break; break;
} }
} }
} }
// the player's target will always be added to the map // the player's target will always be added to the map
if (removed_utarget && m_targets.getUnitTarget()) if (removed_utarget && m_targets.getUnitTarget())
TagUnitMap.push_back(m_targets.getUnitTarget()); targetUnitMap.push_back(m_targets.getUnitTarget());
} }
} }
@ -6142,13 +6142,13 @@ SpellCastResult Spell::CanOpenLock(uint32 effIndex, uint32 lockId, SkillType& sk
return SPELL_CAST_OK; return SPELL_CAST_OK;
} }
void Spell::FillAreaTargets( UnitList& TagUnitMap, float x, float y, float radius, SpellNotifyPushType pushType, SpellTargets spellTargets ) void Spell::FillAreaTargets(UnitList &targetUnitMap, float x, float y, float radius, SpellNotifyPushType pushType, SpellTargets spellTargets)
{ {
CellPair p(MaNGOS::ComputeCellPair(x, y)); CellPair p(MaNGOS::ComputeCellPair(x, y));
Cell cell(p); Cell cell(p);
cell.data.Part.reserved = ALL_DISTRICT; cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate(); cell.SetNoCreate();
MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius, pushType, spellTargets); MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, targetUnitMap, radius, pushType, spellTargets);
TypeContainerVisitor<MaNGOS::SpellNotifierCreatureAndPlayer, WorldTypeMapContainer > world_notifier(notifier); TypeContainerVisitor<MaNGOS::SpellNotifierCreatureAndPlayer, WorldTypeMapContainer > world_notifier(notifier);
TypeContainerVisitor<MaNGOS::SpellNotifierCreatureAndPlayer, GridTypeMapContainer > grid_notifier(notifier); TypeContainerVisitor<MaNGOS::SpellNotifierCreatureAndPlayer, GridTypeMapContainer > grid_notifier(notifier);
CellLock<GridReadGuard> cell_lock(cell, p); CellLock<GridReadGuard> cell_lock(cell, p);
@ -6156,7 +6156,7 @@ void Spell::FillAreaTargets( UnitList& TagUnitMap, float x, float y, float radiu
cell_lock->Visit(cell_lock, grid_notifier, *m_caster->GetMap(), *m_caster, radius); cell_lock->Visit(cell_lock, grid_notifier, *m_caster->GetMap(), *m_caster, radius);
} }
void Spell::FillRaidOrPartyTargets( UnitList &TagUnitMap, Unit* member, Unit* center, float radius, bool raid, bool withPets, bool withcaster ) void Spell::FillRaidOrPartyTargets(UnitList &targetUnitMap, Unit* member, Unit* center, float radius, bool raid, bool withPets, bool withcaster)
{ {
Player *pMember = member->GetCharmerOrOwnerPlayerOrPlayerItself(); Player *pMember = member->GetCharmerOrOwnerPlayerOrPlayerItself();
Group *pGroup = pMember ? pMember->GetGroup() : NULL; Group *pGroup = pMember ? pMember->GetGroup() : NULL;
@ -6175,13 +6175,13 @@ void Spell::FillRaidOrPartyTargets( UnitList &TagUnitMap, Unit* member, Unit* ce
{ {
if ((Target==center || center->IsWithinDistInMap(Target, radius)) && if ((Target==center || center->IsWithinDistInMap(Target, radius)) &&
(withcaster || Target != m_caster)) (withcaster || Target != m_caster))
TagUnitMap.push_back(Target); targetUnitMap.push_back(Target);
if (withPets) if (withPets)
if (Pet* pet = Target->GetPet()) if (Pet* pet = Target->GetPet())
if ((pet==center || center->IsWithinDistInMap(pet, radius)) && if ((pet==center || center->IsWithinDistInMap(pet, radius)) &&
(withcaster || pet != m_caster)) (withcaster || pet != m_caster))
TagUnitMap.push_back(pet); targetUnitMap.push_back(pet);
} }
} }
} }
@ -6190,46 +6190,46 @@ void Spell::FillRaidOrPartyTargets( UnitList &TagUnitMap, Unit* member, Unit* ce
Unit* ownerOrSelf = pMember ? pMember : member->GetCharmerOrOwnerOrSelf(); Unit* ownerOrSelf = pMember ? pMember : member->GetCharmerOrOwnerOrSelf();
if ((ownerOrSelf==center || center->IsWithinDistInMap(ownerOrSelf, radius)) && if ((ownerOrSelf==center || center->IsWithinDistInMap(ownerOrSelf, radius)) &&
(withcaster || ownerOrSelf != m_caster)) (withcaster || ownerOrSelf != m_caster))
TagUnitMap.push_back(ownerOrSelf); targetUnitMap.push_back(ownerOrSelf);
if (withPets) if (withPets)
if (Pet* pet = ownerOrSelf->GetPet()) if (Pet* pet = ownerOrSelf->GetPet())
if ((pet==center || center->IsWithinDistInMap(pet, radius)) && if ((pet==center || center->IsWithinDistInMap(pet, radius)) &&
(withcaster || pet != m_caster)) (withcaster || pet != m_caster))
TagUnitMap.push_back(pet); targetUnitMap.push_back(pet);
} }
} }
void Spell::FillRaidOrPartyManaPriorityTargets( UnitList &TagUnitMap, Unit* member, Unit* center, float radius, uint32 count, bool raid, bool withPets, bool withCaster ) void Spell::FillRaidOrPartyManaPriorityTargets(UnitList &targetUnitMap, Unit* member, Unit* center, float radius, uint32 count, bool raid, bool withPets, bool withCaster)
{ {
FillRaidOrPartyTargets(TagUnitMap, member, center, radius, raid, withPets, withCaster); FillRaidOrPartyTargets(targetUnitMap, member, center, radius, raid, withPets, withCaster);
PrioritizeManaUnitQueue manaUsers; PrioritizeManaUnitQueue manaUsers;
for(UnitList::const_iterator itr = TagUnitMap.begin(); itr != TagUnitMap.end() && manaUsers.size() < count; ++itr) for(UnitList::const_iterator itr = targetUnitMap.begin(); itr != targetUnitMap.end() && manaUsers.size() < count; ++itr)
if ((*itr)->getPowerType() == POWER_MANA && !(*itr)->isDead()) if ((*itr)->getPowerType() == POWER_MANA && !(*itr)->isDead())
manaUsers.push(PrioritizeManaUnitWraper(*itr)); manaUsers.push(PrioritizeManaUnitWraper(*itr));
TagUnitMap.clear(); targetUnitMap.clear();
while(!manaUsers.empty()) while(!manaUsers.empty())
{ {
TagUnitMap.push_back(manaUsers.top().getUnit()); targetUnitMap.push_back(manaUsers.top().getUnit());
manaUsers.pop(); manaUsers.pop();
} }
} }
void Spell::FillRaidOrPartyHealthPriorityTargets( UnitList &TagUnitMap, Unit* member, Unit* center, float radius, uint32 count, bool raid, bool withPets, bool withCaster ) void Spell::FillRaidOrPartyHealthPriorityTargets(UnitList &targetUnitMap, Unit* member, Unit* center, float radius, uint32 count, bool raid, bool withPets, bool withCaster)
{ {
FillRaidOrPartyTargets(TagUnitMap, member, center, radius, raid, withPets, withCaster); FillRaidOrPartyTargets(targetUnitMap, member, center, radius, raid, withPets, withCaster);
PrioritizeHealthUnitQueue healthQueue; PrioritizeHealthUnitQueue healthQueue;
for(UnitList::const_iterator itr = TagUnitMap.begin(); itr != TagUnitMap.end() && healthQueue.size() < count; ++itr) for(UnitList::const_iterator itr = targetUnitMap.begin(); itr != targetUnitMap.end() && healthQueue.size() < count; ++itr)
if (!(*itr)->isDead()) if (!(*itr)->isDead())
healthQueue.push(PrioritizeHealthUnitWraper(*itr)); healthQueue.push(PrioritizeHealthUnitWraper(*itr));
TagUnitMap.clear(); targetUnitMap.clear();
while(!healthQueue.empty()) while(!healthQueue.empty())
{ {
TagUnitMap.push_back(healthQueue.top().getUnit()); targetUnitMap.push_back(healthQueue.top().getUnit());
healthQueue.pop(); healthQueue.pop();
} }
} }

View file

@ -372,12 +372,12 @@ class Spell
typedef std::list<Unit*> UnitList; typedef std::list<Unit*> UnitList;
void FillTargetMap(); void FillTargetMap();
void SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap); void SetTargetMap(uint32 effIndex, uint32 targetMode, UnitList &targetUnitMap);
void FillAreaTargets( UnitList& TagUnitMap, float x, float y, float radius, SpellNotifyPushType pushType, SpellTargets spellTargets ); void FillAreaTargets(UnitList &targetUnitMap, float x, float y, float radius, SpellNotifyPushType pushType, SpellTargets spellTargets);
void FillRaidOrPartyTargets( UnitList &TagUnitMap, Unit* member, Unit* center, float radius, bool raid, bool withPets, bool withcaster ); void FillRaidOrPartyTargets(UnitList &targetUnitMap, Unit* member, Unit* center, float radius, bool raid, bool withPets, bool withcaster);
void FillRaidOrPartyManaPriorityTargets( UnitList &TagUnitMap, Unit* member, Unit* center, float radius, uint32 count, bool raid, bool withPets, bool withcaster ); void FillRaidOrPartyManaPriorityTargets(UnitList &targetUnitMap, Unit* member, Unit* center, float radius, uint32 count, bool raid, bool withPets, bool withcaster);
void FillRaidOrPartyHealthPriorityTargets( UnitList &TagUnitMap, Unit* member, Unit* center, float radius, uint32 count, bool raid, bool withPets, bool withcaster ); void FillRaidOrPartyHealthPriorityTargets(UnitList &targetUnitMap, Unit* member, Unit* center, float radius, uint32 count, bool raid, bool withPets, bool withcaster);
template<typename T> WorldObject* FindCorpseUsing(); template<typename T> WorldObject* FindCorpseUsing();

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "9082" #define REVISION_NR "9083"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__