void Reset()
    {
        LeechingThrow_Timer = 20000;
        TheBeastWithin_Timer = 30000;
        Multishot_Timer = 15000;
        Pet_Timer = 10000;

        pet = false;

        Creature* Pet = Unit::GetCreature(*me, SummonedPet);
        if (Pet && Pet->IsAlive())
            Pet->DealDamage(Pet, Pet->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);

        SummonedPet = 0;

        if (pInstance)
            pInstance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED);
    }
Пример #2
0
    void DeSpawnAdds()
    {
        for (uint8 i = 0; i < 4 ; ++i)
        {
            Creature* Temp = NULL;
            if (AddGUID[i])
            {
                Temp = Creature::GetCreature((*me),AddGUID[i]);
                if (Temp && Temp->isAlive())
                {
                    (*Temp).GetMotionMaster()->Clear(true);
                    Temp->DealDamage(Temp, Temp->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                    Temp->RemoveCorpse();
                }

            }
        }
    }
Пример #3
0
    void DoEndEvent()
    {
        if (!m_pInstance || m_bEventEnd)
            return;

        // Prevent further handling for next council uiMember death
        m_bEventEnd = true;

        // Kill all the other council members
        for (unsigned int i : aCouncilMember)
        {
            Creature* pMember = m_pInstance->GetSingleCreatureFromStorage(i);
            if (pMember && pMember->isAlive())
                pMember->DealDamage(pMember, pMember->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
        }

        // Self kill the voice trigger and the controller
        if (Creature* pVoiceTrigger = m_pInstance->GetSingleCreatureFromStorage(NPC_COUNCIL_VOICE))
            pVoiceTrigger->DealDamage(pVoiceTrigger, pVoiceTrigger->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);

        m_creature->DealDamage(m_creature, m_creature->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
    }
    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (!m_bDrainingCrystal)
        {
            uint32 uiMaxPowerMana = m_creature->GetMaxPower(POWER_MANA);
            if (uiMaxPowerMana && ((m_creature->GetPower(POWER_MANA)*100 / uiMaxPowerMana) < 10))
            {
                if (m_uiDrainLifeTimer < uiDiff)
                {
                    if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                    {
                        if (DoCastSpellIfCan(pTarget, SPELL_DRAIN_LIFE) == CAST_OK)
                            m_uiDrainLifeTimer = 10000;
                    }
                }
                else
                    m_uiDrainLifeTimer -= uiDiff;

                // Heroic only
                if (!m_bIsRegularMode)
                {
                    if (m_uiDrainManaTimer < uiDiff)
                    {
                        Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1);
                        if (!pTarget)
                            pTarget = m_creature->getVictim();

                        if (DoCastSpellIfCan(pTarget, SPELL_DRAIN_MANA) == CAST_OK)
                            m_uiDrainManaTimer = 10000;
                    }
                    else
                        m_uiDrainManaTimer -= uiDiff;
                }
            }

            if (m_uiFelExplosionTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_FEL_EXPLOSION) == CAST_OK)
                    m_uiFelExplosionTimer = 2000;
            }
            else
                m_uiFelExplosionTimer -= uiDiff;

            // If below 10% mana, start recharging
            uiMaxPowerMana = m_creature->GetMaxPower(POWER_MANA);
            if (uiMaxPowerMana && ((m_creature->GetPower(POWER_MANA)*100 / uiMaxPowerMana) < 10))
            {
                if (m_uiDrainCrystalTimer < uiDiff)
                {
                    SelectNearestCrystal();

                    if (m_bIsRegularMode)
                        m_uiDrainCrystalTimer = urand(20000, 25000);
                    else
                        m_uiDrainCrystalTimer = urand(10000, 15000);

                }
                else
                    m_uiDrainCrystalTimer -= uiDiff;
            }

            DoMeleeAttackIfReady();
        }
        else                                                // if m_bDrainingCrystal
        {
            if (m_bIsDraining)
            {
                if (m_uiEmpowerTimer < uiDiff)
                {
                    m_bIsDraining = false;
                    m_bDrainingCrystal = false;

                    DoScriptText(SAY_EMPOWERED, m_creature);

                    Creature* CrystalChosen = m_creature->GetMap()->GetCreature(m_crystalGuid);
                    if (CrystalChosen && CrystalChosen->isAlive())
                        // Use Deal Damage to kill it, not SetDeathState.
                        CrystalChosen->DealDamage(CrystalChosen, CrystalChosen->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);

                    m_crystalGuid.Clear();

                    m_creature->GetMotionMaster()->Clear();
                    m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                }
                else
                    m_uiEmpowerTimer -= uiDiff;
            }
        }
    }
Пример #5
0
    void UpdateAI(const uint32 uiDiff) override
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (!m_bDrainingCrystal)
        {
            if (m_creature->GetPower(POWER_MANA) * 100 / m_creature->GetMaxPower(POWER_MANA) < 10)
            {
                if (m_uiDrainLifeTimer < uiDiff)
                {
                    if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                    {
                        if (DoCastSpellIfCan(pTarget, m_bIsRegularMode ? SPELL_DRAIN_LIFE : SPELL_DRAIN_LIFE_H) == CAST_OK)
                            m_uiDrainLifeTimer = 10000;
                    }
                }
                else
                    m_uiDrainLifeTimer -= uiDiff;

                // Heroic only
                if (!m_bIsRegularMode)
                {
                    if (m_uiDrainManaTimer < uiDiff)
                    {
                        if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, SPELL_DRAIN_MANA, SELECT_FLAG_POWER_MANA))
                        {
                            if (DoCastSpellIfCan(pTarget, SPELL_DRAIN_MANA) == CAST_OK)
                                m_uiDrainManaTimer = 10000;
                        }
                    }
                    else
                        m_uiDrainManaTimer -= uiDiff;
                }

                if (m_uiDrainCrystalTimer < uiDiff)
                {
                    if (DoSelectNearestCrystal())
                        m_uiDrainCrystalTimer = m_bIsRegularMode ? urand(20000, 25000) : urand(10000, 15000);
                }
                else
                    m_uiDrainCrystalTimer -= uiDiff;
            }

            if (m_uiFelExplosionTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_FEL_EXPLOSION) == CAST_OK)
                    m_uiFelExplosionTimer = 2000;
            }
            else
                m_uiFelExplosionTimer -= uiDiff;

            DoMeleeAttackIfReady();
        }
        else
        {
            if (m_uiManaRageTimer)
            {
                if (m_uiManaRageTimer <= uiDiff)
                {
                    DoScriptText(SAY_EMPOWERED, m_creature);
                    ManaRageComplete();

                    // Kill the drained crystal
                    Creature* pCrystalChosen = m_creature->GetMap()->GetCreature(m_crystalGuid);
                    if (pCrystalChosen && pCrystalChosen->isAlive())
                        pCrystalChosen->DealDamage(pCrystalChosen, pCrystalChosen->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);

                    m_uiManaRageTimer = 0;
                }
                else
                    m_uiManaRageTimer -= uiDiff;
            }
        }
    }
Пример #6
0
void instance_arcatraz::JustDidDialogueStep(int32 iEntry)
{
    Creature* pMellichar = GetSingleCreatureFromStorage(NPC_MELLICHAR);
    if (!pMellichar)
        return;

    switch (iEntry)
    {
        case SPELL_TARGET_ALPHA:
            pMellichar->CastSpell(pMellichar, SPELL_TARGET_ALPHA, false);
            if (Creature* pTarget = GetSingleCreatureFromStorage(NPC_PRISON_APHPA_POD))
                pMellichar->SetFacingToObject(pTarget);
            SetData(TYPE_WARDEN_1, IN_PROGRESS);
            break;
        case YELL_MELLICHAR_RELEASE1:
            pMellichar->SummonCreature(urand(0, 1) ? NPC_BLAZING_TRICKSTER : NPC_PHASE_HUNTER, aSummonPosition[0].m_fX, aSummonPosition[0].m_fY, aSummonPosition[0].m_fZ, aSummonPosition[0].m_fO, TEMPSUMMON_DEAD_DESPAWN, 0);
            break;
        case YELL_MELLICHAR_RELEASE2:
            if (Creature* pTarget = GetSingleCreatureFromStorage(NPC_PRISON_BETA_POD))
                pMellichar->SetFacingToObject(pTarget);
            break;
        case SPELL_TARGET_BETA:
            pMellichar->CastSpell(pMellichar, SPELL_TARGET_BETA, false);
            SetData(TYPE_WARDEN_2, IN_PROGRESS);
            break;
        case TYPE_WARDEN_2:
            pMellichar->SummonCreature(NPC_MILLHOUSE, aSummonPosition[1].m_fX, aSummonPosition[1].m_fY, aSummonPosition[1].m_fZ, aSummonPosition[1].m_fO, TEMPSUMMON_DEAD_DESPAWN, 0);
            break;
        case SPELL_TARGET_DELTA:
            pMellichar->CastSpell(pMellichar, SPELL_TARGET_DELTA, false);
            if (Creature* pTarget = GetSingleCreatureFromStorage(NPC_PRISON_DELTA_POD))
                pMellichar->SetFacingToObject(pTarget);
            SetData(TYPE_WARDEN_3, IN_PROGRESS);
            break;
        case TYPE_WARDEN_3:
            pMellichar->SummonCreature(urand(0, 1) ? NPC_AKKIRIS : NPC_SULFURON, aSummonPosition[2].m_fX, aSummonPosition[2].m_fY, aSummonPosition[2].m_fZ, aSummonPosition[2].m_fO, TEMPSUMMON_DEAD_DESPAWN, 0);
            pMellichar->CastSpell(pMellichar, SPELL_TARGET_OMEGA, false);
            if (Creature* pTarget = GetSingleCreatureFromStorage(NPC_PRISON_BOSS_POD))
                pMellichar->SetFacingToObject(pTarget);
            break;
        case YELL_MELLICHAR_RELEASE4:
            pMellichar->InterruptNonMeleeSpells(false);
            if (Creature* pTarget = GetSingleCreatureFromStorage(NPC_PRISON_GAMMA_POD))
                pMellichar->SetFacingToObject(pTarget);
            break;
        case SPELL_TARGET_GAMMA:
            pMellichar->CastSpell(pMellichar, SPELL_TARGET_GAMMA, false);
            if (Creature* pTarget = GetSingleCreatureFromStorage(NPC_PRISON_GAMMA_POD))
                pMellichar->SetFacingToObject(pTarget);
            SetData(TYPE_WARDEN_4, IN_PROGRESS);
            break;
        case TYPE_WARDEN_4:
            pMellichar->SummonCreature(urand(0, 1) ? NPC_TW_DRAKONAAR : NPC_BL_DRAKONAAR, aSummonPosition[3].m_fX, aSummonPosition[3].m_fY, aSummonPosition[3].m_fZ, aSummonPosition[3].m_fO, TEMPSUMMON_DEAD_DESPAWN, 0);
            pMellichar->CastSpell(pMellichar, SPELL_TARGET_OMEGA, false);
            if (Creature* pTarget = GetSingleCreatureFromStorage(NPC_PRISON_BOSS_POD))
                pMellichar->SetFacingToObject(pTarget);
            break;
        case YELL_MELLICHAR_RELEASE5:
            pMellichar->InterruptNonMeleeSpells(false);
            SetData(TYPE_WARDEN_5, IN_PROGRESS);
            break;
        case TYPE_WARDEN_5:
            if (Creature* pSkyriss = pMellichar->SummonCreature(NPC_SKYRISS, aSummonPosition[4].m_fX, aSummonPosition[4].m_fY, aSummonPosition[4].m_fZ, aSummonPosition[4].m_fO, TEMPSUMMON_DEAD_DESPAWN, 0))
                pSkyriss->CastSpell(pSkyriss, SPELL_SIMPLE_TELEPORT, false);
            break;
        case YELL_MELLICAR_WELCOME:
            if (Creature* pSkyriss = GetSingleCreatureFromStorage(NPC_SKYRISS))
                pSkyriss->CastSpell(pSkyriss, SPELL_MIND_REND, false);
            break;
        case SAY_SKYRISS_AGGRO:
            // Kill Mellichar and start combat
            if (Creature* pSkyriss = GetSingleCreatureFromStorage(NPC_SKYRISS))
            {
                pSkyriss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE);
                pMellichar->DealDamage(pMellichar, pMellichar->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
            }
            DoUseDoorOrButton(GO_SEAL_SPHERE);
            break;
    }
}
Пример #7
0
        uint32 NextStep(uint32 Step)
        {
            Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID);
            Map* map = me->GetMap();
            switch (Step)
            {
            case 0: return 9999999;
            case 1:
                me->Yell(SAY_DIALOG_MEDIVH_1, LANG_UNIVERSAL);
                return 10000;
            case 2:
                if (arca)
                    arca->Yell(SAY_DIALOG_ARCANAGOS_2, LANG_UNIVERSAL);
                return 20000;
            case 3:
                me->Yell(SAY_DIALOG_MEDIVH_3, LANG_UNIVERSAL);
                return 10000;
            case 4:
                if (arca)
                    arca->Yell(SAY_DIALOG_ARCANAGOS_4, LANG_UNIVERSAL);
                return 20000;
            case 5:
                me->Yell(SAY_DIALOG_MEDIVH_5, LANG_UNIVERSAL);
                return 20000;
            case 6:
                if (arca)
                    arca->Yell(SAY_DIALOG_ARCANAGOS_6, LANG_UNIVERSAL);
                return 10000;
            case 7:
                FireArcanagosTimer = 500;
                return 5000;
            case 8:
                FireMedivhTimer = 500;
                DoCast(me, SPELL_MANA_SHIELD);
                return 10000;
            case 9:
                me->TextEmote(EMOTE_DIALOG_MEDIVH_7);
                return 10000;
            case 10:
                if (arca)
                    DoCast(arca, SPELL_CONFLAGRATION_BLAST, false);
                return 1000;
            case 11:
                if (arca)
                    arca->Yell(SAY_DIALOG_ARCANAGOS_8, LANG_UNIVERSAL);
                return 5000;
            case 12:
                if (arca)
                {
                    arca->GetMotionMaster()->MovePoint(0, -11010.82f, -1761.18f, 156.47f);
                    arca->setActive(true);
                    arca->InterruptNonMeleeSpells(true);
                    arca->SetSpeed(MOVE_FLIGHT, 2.0f);
                }
                return 10000;
            case 13:
                me->Yell(SAY_DIALOG_MEDIVH_9, LANG_UNIVERSAL);
                return 10000;
            case 14:
                me->SetVisible(false);
                me->ClearInCombat();

                if (map->IsDungeon())
                {
                    InstanceMap::PlayerList const &PlayerList = map->GetPlayers();
                    for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
                    {
                        if (i->GetSource()->IsAlive())
                        {
                            if (i->GetSource()->GetQuestStatus(9645) == QUEST_STATUS_INCOMPLETE)
                                i->GetSource()->CompleteQuest(9645);
                        }
                    }
                }
                return 50000;
            case 15:
                if (arca)
                    arca->DealDamage(arca, arca->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                return 5000;
            default : return 9999999;
            }
        }
Пример #8
0
        void UpdateAI(const uint32 diff)
        {
            if (!EventBegun) return;

            if (EndEventTimer)
            {
                if (EndEventTimer <= diff)
                {
                    if (DeathCount > 3)
                    {
                        if (pInstance)
                        {
                            if (Creature* VoiceTrigger = (Unit::GetCreature(*me, pInstance->GetData64(DATA_BLOOD_ELF_COUNCIL_VOICE))))
                                VoiceTrigger->DealDamage(VoiceTrigger, VoiceTrigger->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                            pInstance->SetData(DATA_ILLIDARICOUNCILEVENT, DONE);
                            //me->SummonCreature(AKAMAID, 746.466980f, 304.394989f, 311.90208f, 6.272870f, TEMPSUMMON_DEAD_DESPAWN, 0);
                        }
                        me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                        return;
                    }

                    Creature* pMember = (Unit::GetCreature(*me, Council[DeathCount]));
                    if (pMember && pMember->isAlive())
                        pMember->DealDamage(pMember, pMember->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                    ++DeathCount;
                    EndEventTimer = 1500;
                } else EndEventTimer -= diff;
            }

            if (CheckTimer)
            {
                if (CheckTimer <= diff)
                {
                    uint8 EvadeCheck = 0;
                    for (uint8 i = 0; i < 4; ++i)
                    {
                        if (Council[i])
                        {
                            if (Creature* Member = (Unit::GetCreature((*me), Council[i])))
                            {
                                // This is the evade/death check.
                                if (Member->isAlive() && !Member->getVictim())
                                    ++EvadeCheck;                   //If all members evade, we reset so that players can properly reset the event
                                else if (!Member->isAlive())         // If even one member dies, kill the rest, set instance data, and kill self.
                                {
                                    EndEventTimer = 1000;
                                    CheckTimer = 0;
                                    return;
                                }
                            }
                        }
                    }

                    if (EvadeCheck > 3)
                        Reset();

                    CheckTimer = 2000;
                } else CheckTimer -= diff;
            }

        }
Пример #9
0
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (!DrainingCrystal)
        {
            uint32 maxPowerMana = m_creature->GetMaxPower(POWER_MANA);
            if (maxPowerMana && ((m_creature->GetPower(POWER_MANA)*100 / maxPowerMana) < 10))
            {
                if (DrainLifeTimer < diff)
                {
                    if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                        DoCastSpellIfCan(pTarget, SPELL_DRAIN_LIFE);

                    DrainLifeTimer = 10000;
                }else DrainLifeTimer -= diff;

                // Heroic only
                if (!m_bIsRegularMode)
                {
                    if (DrainManaTimer < diff)
                    {
                        if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1))
                            DoCastSpellIfCan(pTarget, SPELL_DRAIN_MANA);

                        DrainManaTimer = 10000;
                    }else DrainManaTimer -= diff;
                }
            }

            if (FelExplosionTimer < diff)
            {
                if (!m_creature->IsNonMeleeSpellCasted(false))
                {
                    DoCastSpellIfCan(m_creature, SPELL_FEL_EXPLOSION);
                    FelExplosionTimer = 2000;
                }
            }else FelExplosionTimer -= diff;

            // If below 10% mana, start recharging
            maxPowerMana = m_creature->GetMaxPower(POWER_MANA);
            if (maxPowerMana && ((m_creature->GetPower(POWER_MANA)*100 / maxPowerMana) < 10))
            {
                if (DrainCrystalTimer < diff)
                {
                    SelectNearestCrystal();

                    if (m_bIsRegularMode)
                        DrainCrystalTimer = urand(20000, 25000);
                    else
                        DrainCrystalTimer = urand(10000, 15000);

                }else DrainCrystalTimer -= diff;
            }

        }else
        {
            if (IsDraining)
            {
                if (EmpowerTimer < diff)
                {
                    IsDraining = false;
                    DrainingCrystal = false;

                    DoScriptText(SAY_EMPOWERED, m_creature);

                    Creature* CrystalChosen = m_creature->GetMap()->GetCreature(CrystalGUID);
                    if (CrystalChosen && CrystalChosen->isAlive())
                        // Use Deal Damage to kill it, not SetDeathState.
                        CrystalChosen->DealDamage(CrystalChosen, CrystalChosen->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);

                    CrystalGUID = 0;

                    m_creature->GetMotionMaster()->Clear();
                    m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                }else EmpowerTimer -= diff;
            }
        }

        DoMeleeAttackIfReady();                             // No need to check if we are draining crystal here, as the spell has a stun.
    }
Пример #10
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (!m_pInstance || m_pInstance->GetData(TYPE_KELTHUZAD) != IN_PROGRESS)
            return;

        if (m_uiPhase == PHASE_INTRO)
        {
            if (m_uiIntroPackCount < 7)
            {
                if (m_uiSummonIntroTimer < uiDiff)
                {
                    if (!m_uiIntroPackCount)
                        DoScriptText(SAY_SUMMON_MINIONS, m_creature);

                    SummonIntroCreatures(m_uiIntroPackCount);
                    ++m_uiIntroPackCount;
                    m_uiSummonIntroTimer = 2000;
                }
                else
                    m_uiSummonIntroTimer -= uiDiff;
            }
            else
            {
                if (m_uiPhase1Timer < uiDiff)
                {
                    m_uiPhase = PHASE_NORMAL;
                    DespawnIntroCreatures();

                    m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    SetCombatMovement(true);
                    m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());

                    DoScriptText(EMOTE_PHASE2, m_creature);

                    switch(urand(0, 2))
                    {
                        case 0: DoScriptText(SAY_AGGRO1, m_creature); break;
                        case 1: DoScriptText(SAY_AGGRO2, m_creature); break;
                        case 2: DoScriptText(SAY_AGGRO3, m_creature); break;
                    };
                }
                else
                    m_uiPhase1Timer -= uiDiff;

                if (m_uiSoldierCount < MAX_SOLDIER_COUNT)
                {
                    if (m_uiSoldierTimer < uiDiff)
                    {
                        SummonMob(NPC_SOLDIER_FROZEN);
                        ++m_uiSoldierCount;
                        m_uiSoldierTimer = 3000;
                    }
                    else
                        m_uiSoldierTimer -= uiDiff;
                }

                if (m_uiAbominationCount < MAX_ABOMINATION_COUNT)
                {
                    if (m_uiAbominationTimer < uiDiff)
                    {
                        SummonMob(NPC_UNSTOPPABLE_ABOM);
                        ++m_uiAbominationCount;
                        m_uiAbominationTimer = 25000;
                    }
                    else
                        m_uiAbominationTimer -= uiDiff;
                }

                if (m_uiBansheeCount < MAX_BANSHEE_COUNT)
                {
                    if (m_uiBansheeTimer < uiDiff)
                    {
                        SummonMob(NPC_SOUL_WEAVER);
                        ++m_uiBansheeCount;
                        m_uiBansheeTimer = 25000;
                    }
                    else
                        m_uiBansheeTimer -= uiDiff;
                }
            }
        }
        else // normal or guardian phase
        {
            if (m_uiFrostBoltTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature->getVictim(), m_bIsRegularMode ? SPELL_FROST_BOLT : SPELL_FROST_BOLT_H) == CAST_OK)
                    m_uiFrostBoltTimer = urand(1000, 60000);
            }
            else
                m_uiFrostBoltTimer -= uiDiff;

            if (m_uiFrostBoltNovaTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature->getVictim(), m_bIsRegularMode ? SPELL_FROST_BOLT_NOVA : SPELL_FROST_BOLT_NOVA_H) == CAST_OK)
                    m_uiFrostBoltNovaTimer = 15000;
            }
            else
                m_uiFrostBoltNovaTimer -= uiDiff;

                        //Check for Mana Detonation
            if (m_uiManaDetonationTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,1))
                    if (pTarget->getPowerType() == POWER_MANA)
                    {
                        int32 curPower = pTarget->GetPower(POWER_MANA);
                        if (curPower < (m_bIsRegularMode ? 4000 : 5500))
                            return;

                        m_creature->CastSpell(pTarget,SPELL_MANA_DETONATION, true);
                        int32 manareduction = m_bIsRegularMode ? urand(2500,4000) : urand(3500,5500);
                        int32 mana = curPower - manareduction;
                        pTarget->SetPower(POWER_MANA, mana);

                        Map *map = m_creature->GetMap();
                        if (map->IsDungeon())
                        {
                            Map::PlayerList const &PlayerList = map->GetPlayers();

                            if (!PlayerList.isEmpty())

                                for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
                                {
                                    if (i->getSource()->isAlive() && pTarget->GetDistance2d(i->getSource()->GetPositionX(), i->getSource()->GetPositionY()) < 15)
                                        i->getSource()->DealDamage(i->getSource(), manareduction, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, true);
                                }
                        }
                    }

                if (rand()%2)
                    DoScriptText(SAY_SPECIAL1_MANA_DET, m_creature);

                m_uiManaDetonationTimer = 15000;
            }else m_uiManaDetonationTimer -= uiDiff;

            if (m_uiShadowFissureTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                {
                        m_creature->CastSpell(pTarget,SPELL_SHADOW_FISSURE,true);
                        m_uiShadowFissureActiveTimer = 3000;
                        if (urand(0, 1))
                            DoScriptText(SAY_SPECIAL3_MANA_DET, m_creature);
                }
                m_uiShadowFissureTimer = 25000;
            }
            else
                m_uiShadowFissureTimer -= uiDiff;

            if(m_uiShadowFissureActiveTimer)
                if(m_uiShadowFissureActiveTimer < uiDiff)
                {
                    // hack for shadow fissure
                    // TODO: find energy beam visual spell
                    m_uiShadowFissureActiveTimer = 0;

                    Creature* pFissure = GetClosestCreatureWithEntry(m_creature, NPC_SHADOW_FISSURE, 100.0f);

                    if(!pFissure)
                        return;

                    Map::PlayerList const& pPlayers = m_creature->GetMap()->GetPlayers();
                    for (Map::PlayerList::const_iterator itr = pPlayers.begin(); itr != pPlayers.end(); ++itr)
                        if(itr->getSource()->GetDistance2d(pFissure) < 2.0f)
                            pFissure->DealDamage(itr->getSource(),itr->getSource()->GetHealth(),NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                }
                else 
                    m_uiShadowFissureActiveTimer -= uiDiff;

            if (m_uiFrostBlastTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_FROST_BLAST) == CAST_OK)
                {
                    if (urand(0, 1))
                        DoScriptText(SAY_FROST_BLAST, m_creature);

                    m_uiFrostBlastTimer = urand(30000, 60000);
                }
            }
            else
                m_uiFrostBlastTimer -= uiDiff;

            // not sure if this is right
            //if (!m_bIsRegularMode)
            //{
                if (m_uiChainsTimer < uiDiff)
                {
                    if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_CHAINS_OF_KELTHUZAD) == CAST_OK)
                    {
                        DoScriptText(urand(0, 1) ? SAY_CHAIN1 : SAY_CHAIN2, m_creature);

                        m_uiChainsTimer = urand(30000, 60000);
                    }
                }
                else
                    m_uiChainsTimer -= uiDiff;
            //}

            if (m_uiPhase == PHASE_NORMAL)
            {
                if (m_creature->GetHealthPercent() < 45.0f)
                {
                    m_uiPhase = PHASE_GUARDIANS;
                    DoScriptText(SAY_REQUEST_AID, m_creature);

                    // here Lich King should respond to Kel'Thuzad but I don't know which creature to make talk
                    // so for now just make Kel'Thuzad says it.
                    DoScriptText(SAY_ANSWER_REQUEST, m_creature);
                }
            }
            else if (m_uiPhase == PHASE_GUARDIANS && m_uiGuardiansCount < m_uiGuardiansCountMax)
            {
                if (m_uiGuardiansTimer < uiDiff)
                {
                    // Summon a Guardian of Icecrown in a random alcove
                    SummonMob(NPC_GUARDIAN);
                    m_uiGuardiansTimer = 5000;
                }
                else
                    m_uiGuardiansTimer -= uiDiff;
            }

            DoMeleeAttackIfReady();
        }
    }
Пример #11
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (step)
        {
            if (timer < uiDiff)
            {
                Creature* curr = NULL;
                switch (step)
                {
                    case 1:
                        float fX, fY, fZ;
                        if (GameObject* pKeg = me->FindNearestGameObject(GO_TAINTED_KEG, 10.000000))
                        {
                            std::list<Creature*> lCrea;
                            me->GetCreatureListWithEntryInGrid(lCrea, NPC_CAPTURED_FARMER, 30.0f);
                            for (std::list<Creature*>::iterator it = lCrea.begin(); it != lCrea.end(); ++it)
                            {
                                if ((*it)->isAlive())
                                {
                                    Farmers.push_back((*it)->GetGUID());
                                    pKeg->GetContactPoint((*it), fX, fY, fZ, CONTACT_DISTANCE);
                                    (*it)->GetMotionMaster()->MovePoint(1, fX, fY, fZ, MOVE_PATHFINDING);
                                }
                            }
                        }
                        timer = 4500;
                        step++;
                        break;
                    case 2:
                        if (curr = me->GetMap()->GetCreature(Farmers.front()))
                            curr->SetStandState(UNIT_STAND_STATE_KNEEL);
                        timer = 2000;
                        step++;
                        break;
                    case 3:
                        if (GameObject* pBaril = me->FindNearestGameObject(GO_TAINTED_KEG, 10.000000))
                        {
                            float fX, fY, fZ;
                            pBaril->GetPosition(fX, fY, fZ);
                            me->SummonGameObject(GO_TAINTED_KEG_SMOKE, fX, fY, fZ + 1, 0, 0, 0, 0, 0, 120);
                        }
                        if (curr = me->GetMap()->GetCreature(Farmers.front()))
                            curr->SetStandState(UNIT_STAND_STATE_STAND);
                        curr = NULL;
                        while (!Farmers.empty())
                        {
                            if (curr = me->GetMap()->GetCreature(Farmers.front()))
                                curr->DealDamage(curr, curr->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                            Farmers.pop_front();
                            curr = NULL;
                        }

                        timer = 20000;
                        step++;
                        break;
                    case 4:
                        timer = 0;
                        step = 0;
                        break;
                }
            }
            else
                timer -= uiDiff;
        }
    }