mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +00:00
[11556] Implement spell 42005 proper target seelction.
Also * added TargetDistanceOrderFarAway ordering function and * renamed TargetDistanceOrder -> TargetDistanceOrderFarAway Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
8d8abd2afb
commit
7205023415
2 changed files with 36 additions and 13 deletions
|
|
@ -1500,10 +1500,10 @@ class ChainHealingFullHealth: std::unary_function<const Unit*, bool>
|
||||||
|
|
||||||
// Helper for targets nearest to the spell target
|
// Helper for targets nearest to the spell target
|
||||||
// The spell target is always first unless there is a target at _completely_ the same position (unbelievable case)
|
// The spell target is always first unless there is a target at _completely_ the same position (unbelievable case)
|
||||||
struct TargetDistanceOrder : public std::binary_function<const Unit, const Unit, bool>
|
struct TargetDistanceOrderNear : public std::binary_function<const Unit, const Unit, bool>
|
||||||
{
|
{
|
||||||
const Unit* MainTarget;
|
const Unit* MainTarget;
|
||||||
TargetDistanceOrder(const Unit* Target) : MainTarget(Target) {};
|
TargetDistanceOrderNear(const Unit* Target) : MainTarget(Target) {};
|
||||||
// functor for operator ">"
|
// functor for operator ">"
|
||||||
bool operator()(const Unit* _Left, const Unit* _Right) const
|
bool operator()(const Unit* _Left, const Unit* _Right) const
|
||||||
{
|
{
|
||||||
|
|
@ -1511,6 +1511,19 @@ struct TargetDistanceOrder : public std::binary_function<const Unit, const Unit,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Helper for targets furthest away to the spell target
|
||||||
|
// The spell target is always first unless there is a target at _completely_ the same position (unbelievable case)
|
||||||
|
struct TargetDistanceOrderFarAway : public std::binary_function<const Unit, const Unit, bool>
|
||||||
|
{
|
||||||
|
const Unit* MainTarget;
|
||||||
|
TargetDistanceOrderFarAway(const Unit* Target) : MainTarget(Target) {};
|
||||||
|
// functor for operator "<"
|
||||||
|
bool operator()(const Unit* _Left, const Unit* _Right) const
|
||||||
|
{
|
||||||
|
return !MainTarget->GetDistanceOrder(_Left, _Right);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& targetUnitMap)
|
void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& targetUnitMap)
|
||||||
{
|
{
|
||||||
float radius;
|
float radius;
|
||||||
|
|
@ -1676,7 +1689,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
if(tempTargetUnitMap.empty())
|
if(tempTargetUnitMap.empty())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
tempTargetUnitMap.sort(TargetDistanceOrder(m_caster));
|
tempTargetUnitMap.sort(TargetDistanceOrderNear(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;
|
||||||
|
|
@ -1694,7 +1707,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
|
|
||||||
tempTargetUnitMap.erase(itr);
|
tempTargetUnitMap.erase(itr);
|
||||||
|
|
||||||
tempTargetUnitMap.sort(TargetDistanceOrder(pUnitTarget));
|
tempTargetUnitMap.sort(TargetDistanceOrderNear(pUnitTarget));
|
||||||
|
|
||||||
t = unMaxTargets - 1;
|
t = unMaxTargets - 1;
|
||||||
Unit *prev = pUnitTarget;
|
Unit *prev = pUnitTarget;
|
||||||
|
|
@ -1714,7 +1727,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
prev = *next;
|
prev = *next;
|
||||||
targetUnitMap.push_back(prev);
|
targetUnitMap.push_back(prev);
|
||||||
tempTargetUnitMap.erase(next);
|
tempTargetUnitMap.erase(next);
|
||||||
tempTargetUnitMap.sort(TargetDistanceOrder(prev));
|
tempTargetUnitMap.sort(TargetDistanceOrderNear(prev));
|
||||||
next = tempTargetUnitMap.begin();
|
next = tempTargetUnitMap.begin();
|
||||||
|
|
||||||
--t;
|
--t;
|
||||||
|
|
@ -1736,7 +1749,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
if(tempTargetUnitMap.empty())
|
if(tempTargetUnitMap.empty())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
tempTargetUnitMap.sort(TargetDistanceOrder(m_caster));
|
tempTargetUnitMap.sort(TargetDistanceOrderNear(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;
|
||||||
|
|
@ -1754,7 +1767,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
|
|
||||||
tempTargetUnitMap.erase(itr);
|
tempTargetUnitMap.erase(itr);
|
||||||
|
|
||||||
tempTargetUnitMap.sort(TargetDistanceOrder(pUnitTarget));
|
tempTargetUnitMap.sort(TargetDistanceOrderNear(pUnitTarget));
|
||||||
|
|
||||||
t = unMaxTargets - 1;
|
t = unMaxTargets - 1;
|
||||||
Unit *prev = pUnitTarget;
|
Unit *prev = pUnitTarget;
|
||||||
|
|
@ -1773,7 +1786,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
prev = *next;
|
prev = *next;
|
||||||
targetUnitMap.push_back(prev);
|
targetUnitMap.push_back(prev);
|
||||||
tempTargetUnitMap.erase(next);
|
tempTargetUnitMap.erase(next);
|
||||||
tempTargetUnitMap.sort(TargetDistanceOrder(prev));
|
tempTargetUnitMap.sort(TargetDistanceOrderNear(prev));
|
||||||
next = tempTargetUnitMap.begin();
|
next = tempTargetUnitMap.begin();
|
||||||
--t;
|
--t;
|
||||||
}
|
}
|
||||||
|
|
@ -1821,7 +1834,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
if (tempTargetUnitMap.empty())
|
if (tempTargetUnitMap.empty())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
tempTargetUnitMap.sort(TargetDistanceOrder(pUnitTarget));
|
tempTargetUnitMap.sort(TargetDistanceOrderNear(pUnitTarget));
|
||||||
|
|
||||||
if (*tempTargetUnitMap.begin() == pUnitTarget)
|
if (*tempTargetUnitMap.begin() == pUnitTarget)
|
||||||
tempTargetUnitMap.erase(tempTargetUnitMap.begin());
|
tempTargetUnitMap.erase(tempTargetUnitMap.begin());
|
||||||
|
|
@ -1843,7 +1856,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
prev = *next;
|
prev = *next;
|
||||||
targetUnitMap.push_back(prev);
|
targetUnitMap.push_back(prev);
|
||||||
tempTargetUnitMap.erase(next);
|
tempTargetUnitMap.erase(next);
|
||||||
tempTargetUnitMap.sort(TargetDistanceOrder(prev));
|
tempTargetUnitMap.sort(TargetDistanceOrderNear(prev));
|
||||||
next = tempTargetUnitMap.begin();
|
next = tempTargetUnitMap.begin();
|
||||||
--t;
|
--t;
|
||||||
}
|
}
|
||||||
|
|
@ -1852,6 +1865,16 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
}
|
}
|
||||||
case TARGET_ALL_ENEMY_IN_AREA:
|
case TARGET_ALL_ENEMY_IN_AREA:
|
||||||
FillAreaTargets(targetUnitMap, radius, PUSH_DEST_CENTER, SPELL_TARGETS_AOE_DAMAGE);
|
FillAreaTargets(targetUnitMap, radius, PUSH_DEST_CENTER, SPELL_TARGETS_AOE_DAMAGE);
|
||||||
|
|
||||||
|
if (m_spellInfo->Id == 42005) // Bloodboil
|
||||||
|
{
|
||||||
|
// manually cuting, because the spell hits only the 5 furthest away targets
|
||||||
|
if (targetUnitMap.size() > unMaxTargets)
|
||||||
|
{
|
||||||
|
targetUnitMap.sort(TargetDistanceOrderFarAway(m_caster));
|
||||||
|
targetUnitMap.resize(unMaxTargets);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TARGET_AREAEFFECT_INSTANT:
|
case TARGET_AREAEFFECT_INSTANT:
|
||||||
{
|
{
|
||||||
|
|
@ -2358,7 +2381,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
if (m_caster != pUnitTarget && std::find(tempTargetUnitMap.begin(), tempTargetUnitMap.end(), m_caster) == tempTargetUnitMap.end())
|
if (m_caster != pUnitTarget && std::find(tempTargetUnitMap.begin(), tempTargetUnitMap.end(), m_caster) == tempTargetUnitMap.end())
|
||||||
tempTargetUnitMap.push_front(m_caster);
|
tempTargetUnitMap.push_front(m_caster);
|
||||||
|
|
||||||
tempTargetUnitMap.sort(TargetDistanceOrder(pUnitTarget));
|
tempTargetUnitMap.sort(TargetDistanceOrderNear(pUnitTarget));
|
||||||
|
|
||||||
if (tempTargetUnitMap.empty())
|
if (tempTargetUnitMap.empty())
|
||||||
break;
|
break;
|
||||||
|
|
@ -2391,7 +2414,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
prev = *next;
|
prev = *next;
|
||||||
targetUnitMap.push_back(prev);
|
targetUnitMap.push_back(prev);
|
||||||
tempTargetUnitMap.erase(next);
|
tempTargetUnitMap.erase(next);
|
||||||
tempTargetUnitMap.sort(TargetDistanceOrder(prev));
|
tempTargetUnitMap.sort(TargetDistanceOrderNear(prev));
|
||||||
next = tempTargetUnitMap.begin();
|
next = tempTargetUnitMap.begin();
|
||||||
|
|
||||||
--t;
|
--t;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11555"
|
#define REVISION_NR "11556"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue