Ejemplo n.º 1
0
void ThreatManager::addThreat(Unit* pVictim, float pThreat, SpellSchoolMask schoolMask, SpellEntry const *pThreatSpell)
{
    //function deals with adding threat and adding players and pets into ThreatList
    //mobs, NPCs, guards have ThreatList and HateOfflineList
    //players and pets have only InHateListOf
    //HateOfflineList is used co contain unattackable victims (in-flight, in-water, GM etc.)

    if (pVictim == getOwner())                              // only for same creatures :)
        return;

    if(!pVictim || (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster()) )
        return;

    assert(getOwner()->GetTypeId()== TYPEID_UNIT);

    float threat = ThreatCalcHelper::calcThreat(pVictim, iOwner, pThreat, schoolMask, pThreatSpell);

    // must check > 0.0f, otherwise dead loop
    if(threat > 0.0f && pVictim->GetReducedThreatPercent())
    {
        float reducedThreat = threat * pVictim->GetReducedThreatPercent() / 100;
        threat -= reducedThreat;
        if(Unit *unit = pVictim->GetMisdirectionTarget())
            _addThreat(unit, reducedThreat);
    }

    _addThreat(pVictim, threat);
}
Ejemplo n.º 2
0
void ThreatManager::doAddThreat(Unit* victim, float threat)
{
    uint32 redirectThreadPct = victim->GetRedirectThreatPercent();
    Unit* redirectTarget = victim->GetRedirectThreatTarget();

    // If victim is personnal spawn, redirect all aggro to summoner
    if (TempSummon* tempSummonVictim = victim->ToTempSummon())
    {
        if (tempSummonVictim->IsVisibleBySummonerOnly())
        {
            // Personnal Spawns from same summoner can aggro each other
            if (!GetOwner()->ToTempSummon() ||
                !GetOwner()->ToTempSummon()->IsVisibleBySummonerOnly() ||
                tempSummonVictim->GetSummonerGUID() != GetOwner()->ToTempSummon()->GetSummonerGUID())
            {
                redirectThreadPct = 100;
                redirectTarget = tempSummonVictim->GetSummoner();
            }
        }
    }

    // must check > 0.0f, otherwise dead loop
    if (threat > 0.0f && redirectThreadPct)
    {
        if (redirectTarget)
        {
            float redirectThreat = CalculatePct(threat, redirectThreadPct);
            threat -= redirectThreat;
            _addThreat(redirectTarget, redirectThreat);
        }
    }

    _addThreat(victim, threat);
}
Ejemplo n.º 3
0
void ThreatManager::doAddThreat(Unit* victim, float threat)
{
    uint32 reducedThreadPercent = victim->GetReducedThreatPercent();

    // must check > 0.0f, otherwise dead loop
    if (threat > 0.0f && reducedThreadPercent)
    {
        Unit* redirectTarget = victim->GetMisdirectionTarget();
        float reducedThreat = threat * reducedThreadPercent / 100.0f;
        threat -= reducedThreat;
        if (redirectTarget)
            _addThreat(redirectTarget, reducedThreat);
    }

    _addThreat(victim, threat);
}
Ejemplo n.º 4
0
void ThreatManager::doAddThreat(Unit* victim, float threat)
{
    uint32 redirectThreadPct = victim->GetRedirectThreatPercent();

    // must check > 0.0f, otherwise dead loop
    if (threat > 0.0f && redirectThreadPct)
    {
        if (Unit* redirectTarget = victim->GetRedirectThreatTarget())
        {
            float redirectThreat = CalculatePct(threat, redirectThreadPct);
            threat -= redirectThreat;
            _addThreat(redirectTarget, redirectThreat);
        }
    }

    _addThreat(victim, threat);
}
Ejemplo n.º 5
0
void ThreatManager::doAddThreat(Unit* victim, float threat)
{
    uint32 reducedThreadPercent = victim->GetReducedThreatPercent();

    // must check > 0.0f, otherwise dead loop
    if (threat > 0.0f && reducedThreadPercent)
    {
        Unit* redirectTarget = victim->GetMisdirectionTarget();
        if (redirectTarget)
            if (Aura* glyphAura = redirectTarget->GetAura(63326)) // Glyph of Vigilance
                reducedThreadPercent += glyphAura->GetSpellInfo()->Effects[0].CalcValue();

        float reducedThreat = threat * reducedThreadPercent / 100.0f;
        threat -= reducedThreat;
        if (redirectTarget)
            _addThreat(redirectTarget, reducedThreat);
    }

    _addThreat(victim, threat);
}
Ejemplo n.º 6
0
void ThreatManager::addThreat(Unit* pVictim, float fThreat, SpellSchoolMask schoolMask, SpellEntry const *pThreatSpell)
{
    //function deals with adding threat and adding players and pets into ThreatList
    //mobs, NPCs, guards have ThreatList and HateOfflineList
    //players and pets have only InHateListOf
    //HateOfflineList is used co contain unattackable victims (in-flight, in-water, GM etc.)

    // not to self
    if (pVictim == getOwner())
        return;

    // not to GM
    if (!pVictim || (pVictim->GetTypeId() == TYPEID_PLAYER && pVictim->ToPlayer()->isGameMaster()))
        return;

    // not to dead and not for dead
    if (!pVictim->isAlive() || !getOwner()->isAlive())
        return;

    ASSERT(getOwner()->GetTypeId() == TYPEID_UNIT);

    float threat = ThreatCalcHelper::calcThreat(pVictim, iOwner, fThreat, schoolMask, pThreatSpell);

    // must check > 0.0f, otherwise dead loop
    if (threat > 0.0f && pVictim->GetReducedThreatPercent())
    {
        uint32 reducedThreadPercent = pVictim->GetReducedThreatPercent();

        Unit *unit = pVictim->GetMisdirectionTarget();
        if (unit)
            if (Aura* pAura = unit->GetAura(63326)) // Glyph of Vigilance
                reducedThreadPercent += SpellMgr::CalculateSpellEffectAmount(pAura->GetSpellProto(), 0);

        float reducedThreat = threat * reducedThreadPercent / 100;
        threat -= reducedThreat;
        if (unit)
            _addThreat(unit, reducedThreat);
    }

    _addThreat(pVictim, threat);
}