예제 #1
0
void ThreatManager::addThreat(Unit* pVictim, float pThreat, bool crit, 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 && ((Player*)pVictim)->isGameMaster()))
    {
        return;
    }

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

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

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

    addThreatDirectly(pVictim, threat);
}
예제 #2
0
void ThreatManager::addThreat(Unit* pVictim, float pThreat, bool crit, 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 && ((Player*)pVictim)->isGameMaster()))
        return;

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

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

    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);
}