[10465] Implement SPELL_EFFECT_REDIRECT_THREAT

Note: all spells with effect expect additional code for redirection reset.
Until code adding redirection work longer that expected.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>

Patch partly rewrited with move new data into HostileRefManager
and added redirection to threatAssist. Also bug fixed with
redirection threat to unit not in hostile list yet.
This commit is contained in:
ascent 2010-09-11 00:03:27 +04:00 committed by VladimirMangos
parent f441216aa0
commit 88cc2d440f
7 changed files with 85 additions and 9 deletions

View file

@ -392,6 +392,27 @@ void ThreatManager::addThreat(Unit* pVictim, float pThreat, bool crit, SpellScho
float threat = ThreatCalcHelper::calcThreat(pVictim, iOwner, pThreat, crit, schoolMask, pThreatSpell);
if (threat > 0.0f)
{
if (float redirectedMod = pVictim->getHostileRefManager().GetThreatRedirectionMod())
{
if (Unit* redirectedTarget = pVictim->getHostileRefManager().GetThreatRedirectionTarget())
{
if (redirectedTarget != getOwner() && redirectedTarget->isAlive())
{
float redirectedThreat = threat * redirectedMod;
threat -= redirectedThreat;
addThreatDirectly(redirectedTarget, redirectedThreat);
}
}
}
}
addThreatDirectly(pVictim, threat);
}
void ThreatManager::addThreatDirectly(Unit* pVictim, float threat)
{
HostileReference* ref = iThreatContainer.addThreat(pVictim, threat);
// Ref is online
if (ref)
@ -402,7 +423,7 @@ void ThreatManager::addThreat(Unit* pVictim, float pThreat, bool crit, SpellScho
if(!ref) // there was no ref => create a new one
{
// threat has to be 0 here
// threat has to be 0 here
HostileReference* hostileReference = new HostileReference(pVictim, this, 0);
iThreatContainer.addReference(hostileReference);
hostileReference->addThreat(threat); // now we add the real threat