예제 #1
0
bool BSWScriptedAI::_hasAura(uint8 m_uiSpellIdx, Unit* pTarget)
{
    BSWRecord* pSpell = &m_BSWRecords[m_uiSpellIdx];

    return _hasAura(pSpell->m_uiSpellEntry[currentDifficulty], pTarget);

};
예제 #2
0
bool BSWScriptedAI::_doRemove(uint32 SpellID, Unit* pTarget, uint8 index)
{

    if (!_hasAura(SpellID, pTarget)) return false;

        if (index == EFFECT_INDEX_ALL)
        {
            pTarget->RemoveAurasDueToSpell(SpellID);
        }
        else if (_auraCount(SpellID,pTarget,(SpellEffectIndex)index) > 1)
        {
            if (SpellAuraHolderPtr holder = pTarget->GetSpellAuraHolder(SpellID, pTarget->GetObjectGuid()))
            {
                if (holder->ModStackAmount(-1))
                {
                    pTarget->RemoveSpellAuraHolder(holder, AURA_REMOVE_BY_DISPEL);
                } else return false;
            }
        }
        else
            pTarget->RemoveAurasDueToSpell(SpellID);

    debug_log("BSW: Removed effects of spell %u index %u",SpellID, index);
    return true;
};
예제 #3
0
bool BossSpellWorker::_doAura(uint8 m_uiSpellIdx, Unit* pTarget, SpellEffectIndex index)
{
    SpellTable* pSpell = &m_BossSpell[m_uiSpellIdx];

    if (!pTarget || !pTarget->IsInMap(boss) || !pTarget->isAlive())
        {
           error_log("BSW: FAILED adding aura of spell number %u - no target or target not in map or target is dead",pSpell->m_uiSpellEntry[currentDifficulty]);
           return false;
        }

    SpellEntry const *spell;

    if (_hasAura(m_uiSpellIdx,pTarget))
         debug_log("BSW: adding aura stack from spell %u index %u",pSpell->m_uiSpellEntry[currentDifficulty], index);
    else debug_log("BSW: adding new aura from spell %u index %u",pSpell->m_uiSpellEntry[currentDifficulty], index);

    spell = (SpellEntry *)GetSpellStore()->LookupEntry(pSpell->m_uiSpellEntry[currentDifficulty]);
    if (spell)
        {
            int32 basepoint = pSpell->varData ?  pSpell->varData - 1 : spell->EffectBasePoints[index] + 1;
            if (pTarget->AddAura(new BossAura(spell, index, &basepoint, pTarget, pTarget)))
                return true;
        };

    error_log("BSW: FAILED adding aura from spell %u index %u",pSpell->m_uiSpellEntry[currentDifficulty], index);

    return false;
};
예제 #4
0
uint8 BSWScriptedAI::_auraCount(uint32 SpellID, Unit* pTarget, SpellEffectIndex index)
{
    if (!_hasAura(SpellID,pTarget)) return 0;

    if (Aura* aura = pTarget->GetAura(SpellID, index))
        if (aura->GetStackAmount() > 0)
            return aura->GetStackAmount();
    return 0;

};
예제 #5
0
uint8 BossSpellWorker::_auraCount(uint8 m_uiSpellIdx, Unit* pTarget, SpellEffectIndex index)
{
    if (!_hasAura(m_uiSpellIdx,pTarget)) return 0;

    SpellTable* pSpell = &m_BossSpell[m_uiSpellIdx];

    if (Aura* aura = pTarget->GetAura(pSpell->m_uiSpellEntry[currentDifficulty], index))
        if (aura->GetStackAmount() > 0)
            return aura->GetStackAmount();
    return 0;

};
예제 #6
0
bool BSWScriptedAI::_doAura(uint8 m_uiSpellIdx, Unit* pTarget, SpellEffectIndex index)
{
    SpellTable* pSpell = &m_BossSpell[m_uiSpellIdx];

    if (!pTarget || !pTarget->IsInMap(m_creature) || !pTarget->isAlive())
        {
           error_log("BSW: FAILED adding aura of spell number %u - no target or target not in map or target is dead",pSpell->m_uiSpellEntry[currentDifficulty]);
           return false;
        }

    if (_hasAura(m_uiSpellIdx,pTarget))
         debug_log("BSW: adding aura stack from spell %u index %u",pSpell->m_uiSpellEntry[currentDifficulty], index);
    else debug_log("BSW: adding new aura from spell %u index %u",pSpell->m_uiSpellEntry[currentDifficulty], index);

    SpellEntry const *spell = (SpellEntry *)GetSpellStore()->LookupEntry(pSpell->m_uiSpellEntry[currentDifficulty]);
    if (spell && spell->Effect[index] < TOTAL_SPELL_EFFECTS)
    {
        if (IsSpellAppliesAura(spell, (1 << EFFECT_INDEX_0) | (1 << EFFECT_INDEX_1) | (1 << EFFECT_INDEX_2)) || IsSpellHaveEffect(spell, SPELL_EFFECT_PERSISTENT_AREA_AURA))
        {
            SpellAuraHolder *holder = CreateSpellAuraHolder(spell, pTarget, pTarget);

            int32 basepoint = pSpell->varData ?  pSpell->varData - 1 : spell->EffectBasePoints[index] + 1;

            if ( IsAreaAuraEffect(spell->Effect[index]) ||
                spell->Effect[index] == SPELL_EFFECT_APPLY_AURA  ||
                spell->Effect[index] == SPELL_EFFECT_PERSISTENT_AREA_AURA )
                {
                    Aura *aura = CreateAura(spell, SpellEffectIndex(index), &basepoint, holder, pTarget);
                    holder->AddAura(aura, SpellEffectIndex(index));
                    return true;
                }
        }
    }

    error_log("BSW: FAILED adding aura from spell %u index %u",pSpell->m_uiSpellEntry[currentDifficulty], index);

    return false;
};
예제 #7
0
bool BSWScriptedAI::_doAura(uint32 SpellID, Unit* pTarget, SpellEffectIndex index, int32 basepoint, bool isStack)
{
    if (!pTarget || !pTarget->IsInMap(m_creature) || !pTarget->isAlive())
    {
        error_log("BSW: FAILED adding aura of spell number %u - no target or target not in map or target is dead",SpellID);
        return false;
    }

    if (_hasAura(SpellID,pTarget))
         debug_log("BSW: adding aura stack from spell %u index %u",SpellID, index);
    else debug_log("BSW: adding new aura from spell %u index %u",SpellID, index);

    SpellEntry const *spell = (SpellEntry *)GetSpellStore()->LookupEntry(SpellID);

    if (spell)
    {
        if (IsSpellAppliesAura(spell, (1 << EFFECT_INDEX_0) | (1 << EFFECT_INDEX_1) | (1 << EFFECT_INDEX_2)) || IsSpellHaveEffect(spell, SPELL_EFFECT_PERSISTENT_AREA_AURA))
        {
            int32 _basepoint = basepoint ?  basepoint - 1 : spell->EffectBasePoints[index] + 1;

            bool addedToExisting = true;

            SpellAuraHolderPtr holder = pTarget->GetSpellAuraHolder(SpellID, pTarget->GetObjectGuid());

            Aura* aura = NULL;

            if (!holder)
            {
                holder = CreateSpellAuraHolder(spell, pTarget, pTarget);
                addedToExisting = false;
            }


            if (aura = holder->GetAuraByEffectIndex(index))
            {
                if (isStack)
                    holder->ModStackAmount(1);
            }
            else
            {
                aura = holder->CreateAura(spell, index, &_basepoint, holder, pTarget, m_creature, NULL);
                holder->SetAuraDuration(aura->GetAuraMaxDuration());
            }

            if (addedToExisting)
            {
                pTarget->AddAuraToModList(aura);
                holder->SetInUse(true);
                aura->ApplyModifier(true,true);
                holder->SetInUse(false);
            }
            else
                pTarget->AddSpellAuraHolder(holder);

            return true;
        }
    }

    error_log("BSW: FAILED adding aura from spell %u index %u",SpellID, index);

    return false;
};
예제 #8
0
bool BossSpellWorker::_doRemove(uint8 m_uiSpellIdx, Unit* pTarget, uint8 index)
{
    SpellTable* pSpell = &m_BossSpell[m_uiSpellIdx];

    debug_log("BSW: Removing effects of spell %u type %u",pSpell->m_uiSpellEntry[currentDifficulty], pSpell->m_CastTarget);

        switch (pSpell->m_CastTarget) 
        {
                case DO_NOTHING: 
                                 return true;
                case SUMMON_NORMAL:
                case SUMMON_TEMP:
                case SUMMON_INSTANT:
                                 return false;

                case CAST_ON_SELF:
                case APPLY_AURA_SELF:
                         pTarget = boss;
                     break;

                case CAST_ON_SUMMONS:
                case CAST_ON_VICTIM:
                case CAST_ON_BOTTOMAGGRO:
                case CAST_ON_TARGET:
                case APPLY_AURA_TARGET:
                         if (!pTarget) return false;
                     break;

                case CAST_ON_RANDOM:
                case CAST_ON_RANDOM_PLAYER:
                case APPLY_AURA_ALLPLAYERS:
                case CAST_ON_ALLPLAYERS:
                     {
                         Map::PlayerList const& pPlayers = pMap->GetPlayers();
                         for (Map::PlayerList::const_iterator itr = pPlayers.begin(); itr != pPlayers.end(); ++itr)
                         {
                             pTarget = itr->getSource();
                             if (_hasAura(m_uiSpellIdx,pTarget))
                                 pTarget->RemoveAurasDueToSpell(pSpell->m_uiSpellEntry[currentDifficulty]);
                          }
                          return true;
                      }
                      break;
                  default: 
                      debug_log("BSW: FAILED Removing effects of spell %u type %u - unsupported type",pSpell->m_uiSpellEntry[currentDifficulty], pSpell->m_CastTarget);
                      return false;
        }

    if (!pTarget || !pTarget->IsInMap(boss) || !pTarget->isAlive())
        {
           error_log("BSW: FAILED removing effects of spell number %u - no target or target not in map or target is dead",pSpell->m_uiSpellEntry[currentDifficulty]);
           return false;
        }

        if (index == EFFECT_INDEX_ALL)
        {
            pTarget->RemoveAurasDueToSpell(pSpell->m_uiSpellEntry[currentDifficulty]);
            return true;
        }

        if (_auraCount(m_uiSpellIdx,pTarget,(SpellEffectIndex)index) > 1)
        {
            if (pTarget->GetAura(pSpell->m_uiSpellEntry[currentDifficulty],(SpellEffectIndex)index)->modStackAmount(-1))
                return true;
            else return false;
        }
        else pTarget->RemoveAurasDueToSpell(pSpell->m_uiSpellEntry[currentDifficulty]);
    return true;
};