void UpdateAI(const uint32 diff)
        {
            if (ghost)
            {
                if (instance && instance->GetData(DATA_SKARVALD_DALRONN_EVENT) != IN_PROGRESS)
                    me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
            }

            if (!UpdateVictim())
                return;

            if (AggroYell_Timer)
            {
                if (AggroYell_Timer <= diff)
                {
                    DoScriptText(YELL_DALRONN_AGGRO, me);

                    AggroYell_Timer = 0;
                } else AggroYell_Timer -= diff;
            }

            if (!ghost)
            {
                if (Check_Timer)
                {
                    if (Check_Timer <= diff)
                    {
                        Check_Timer = 5000;
                        Unit* skarvald = Unit::GetUnit(*me, instance ? instance->GetData64(DATA_SKARVALD) : 0);
                        if (skarvald && skarvald->isDead())
                        {
                            Skarvald_isDead = true;
                            Response_Timer = 2000;
                            Check_Timer = 0;
                        }
                    } else Check_Timer -= diff;
                }

                if (Response_Timer && Skarvald_isDead)
                {
                    if (Response_Timer <= diff)
                    {
                        DoScriptText(YELL_DALRONN_SKA_DIEDFIRST, me);
                        Response_Timer = 0;
                    } else Response_Timer -= diff;
                }
            }

            if (ShadowBolt_Timer <= diff)
            {
                if (!me->IsNonMeleeSpellCasted(false))
                {
                    DoCast(SelectTarget(SELECT_TARGET_RANDOM, 0), SPELL_SHADOW_BOLT);
                    ShadowBolt_Timer = 2100;//give a 100ms pause to try cast other spells
                }
            } else ShadowBolt_Timer -= diff;

            if (Debilitate_Timer <= diff)
            {
                if (!me->IsNonMeleeSpellCasted(false))
                {
                    DoCast(SelectTarget(SELECT_TARGET_RANDOM, 0), SPELL_DEBILITATE);
                    Debilitate_Timer = 5000+rand()%5000;
                }
            } else Debilitate_Timer -= diff;

            if (IsHeroic())
            {
                if (Summon_Timer <= diff)
                {
                    if (!me->IsNonMeleeSpellCasted(false))
                    {
                        DoCast(me, H_SPELL_SUMMON_SKELETONS);
                        Summon_Timer = (rand()%10000) + 20000;
                    }
                } else Summon_Timer -= diff;
            }

            DoMeleeAttackIfReady();
        }
Example #2
0
        void UpdateAI(uint32 diff)
        {
            if (!IsRunning)
                return;

            if (EventProgress_Timer <= diff)
            {
                if (instance)
                {
                    if (instance->GetData(TYPE_HARBINGERSKYRISS) == FAIL)
                    {
                        Reset();
                        return;
                    }
                }

                if (CanSpawn)
                {
                    //continue beam omega pod, unless we are about to summon skyriss
                    if (Phase != 7)
                        DoCast(me, SPELL_TARGET_OMEGA);

                    switch (Phase)
                    {
                    case 2:
                        switch (urand(0, 1))
                        {
                        case 0:
                            me->SummonCreature(ENTRY_TRICKSTER, 478.326f, -148.505f, 42.56f, 3.19f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
                            break;
                        case 1:
                            me->SummonCreature(ENTRY_PH_HUNTER, 478.326f, -148.505f, 42.56f, 3.19f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
                            break;
                        }
                        break;
                    case 3:
                        me->SummonCreature(ENTRY_MILLHOUSE, 413.292f, -148.378f, 42.56f, 6.27f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
                        break;
                    case 4:
                        Talk(YELL_RELEASE2B);
                        break;
                    case 5:
                        switch (urand(0, 1))
                        {
                        case 0:
                            me->SummonCreature(ENTRY_AKKIRIS, 420.179f, -174.396f, 42.58f, 0.02f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
                            break;
                        case 1:
                            me->SummonCreature(ENTRY_SULFURON, 420.179f, -174.396f, 42.58f, 0.02f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
                            break;
                        }
                        break;
                    case 6:
                        switch (urand(0, 1))
                        {
                        case 0:
                            me->SummonCreature(ENTRY_TW_DRAK, 471.795f, -174.58f, 42.58f, 3.06f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
                            break;
                        case 1:
                            me->SummonCreature(ENTRY_BL_DRAK, 471.795f, -174.58f, 42.58f, 3.06f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
                            break;
                        }
                        break;
                    case 7:
                        me->SummonCreature(ENTRY_SKYRISS, 445.763f, -191.639f, 44.64f, 1.60f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
                        Talk(YELL_WELCOME);
                        break;
                    }
                    CanSpawn = false;
                    ++Phase;
                }
                if (CanProgress())
                {
                    switch (Phase)
                    {
                    case 1:
                        Talk(YELL_INTRO2);
                        EventProgress_Timer = 10000;
                        ++Phase;
                        break;
                    case 2:
                        Talk(YELL_RELEASE1);
                        DoPrepareForPhase();
                        EventProgress_Timer = 7000;
                        break;
                    case 3:
                        Talk(YELL_RELEASE2A);
                        DoPrepareForPhase();
                        EventProgress_Timer = 10000;
                        break;
                    case 4:
                        DoPrepareForPhase();
                        EventProgress_Timer = 15000;
                        break;
                    case 5:
                        Talk(YELL_RELEASE3);
                        DoPrepareForPhase();
                        EventProgress_Timer = 15000;
                        break;
                    case 6:
                        Talk(YELL_RELEASE4);
                        DoPrepareForPhase();
                        EventProgress_Timer = 15000;
                        break;
                    case 7:
                        DoPrepareForPhase();
                        EventProgress_Timer = 15000;
                        break;
                    }
                }
            }
            else
                EventProgress_Timer -= diff;
        }
 void JustDied(Unit* pKiller)
 {
         if (pInstance)
         pInstance->SetData(DATA_ARGENT_SOLDIER_DEFEATED, pInstance->GetData(DATA_ARGENT_SOLDIER_DEFEATED) + 1);
 }
Example #4
0
            void UpdateAI(const uint32 diff)
            {
                if (!UpdateVictim())
                    return;

                if (me->getVictim() && me->isAlive())
                {
                    if (!CombatStart)
                    {
                        //At combat Start Mandokir is mounted so we must unmount it first
                        me->Dismount();

                        //And summon his raptor
                        me->SummonCreature(14988, me->getVictim()->GetPositionX(), me->getVictim()->GetPositionY(), me->getVictim()->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 35000);
                        CombatStart = true;
                    }

                    if (Watch_Timer <= diff)                         //Every 20 Sec Mandokir will check this
                    {
                        if (WatchTarget)                             //If someone is watched and If the Position of the watched target is different from the one stored, or are attacking, mandokir will charge him
                        {
                            Unit* unit = Unit::GetUnit(*me, WatchTarget);

                            if (unit && (
                                targetX != unit->GetPositionX() ||
                                targetY != unit->GetPositionY() ||
                                targetZ != unit->GetPositionZ() ||
                                unit->isInCombat()))
                            {
                                if (me->IsWithinMeleeRange(unit))
                                {
                                    DoCast(unit, 24316);
                                }
                                else
                                {
                                    DoCast(unit, SPELL_CHARGE);
                                    //me->SendMonsterMove(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), 0, true, 1);
                                    AttackStart(unit);
                                }
                            }
                        }
                        someWatched = false;
                        Watch_Timer = 20000;
                    } else Watch_Timer -= diff;

                    if ((Watch_Timer < 8000) && !someWatched)       //8 sec(cast time + expire time) before the check for the watch effect mandokir will cast watch debuff on a random target
                    {
                        if (Unit* p = SelectTarget(SELECT_TARGET_RANDOM, 0))
                        {
                            DoScriptText(SAY_WATCH, me, p);
                            DoCast(p, SPELL_WATCH);
                            WatchTarget = p->GetGUID();
                            someWatched = true;
                            endWatch = true;
                        }
                    }

                    if ((Watch_Timer < 1000) && endWatch)           //1 sec before the debuf expire, store the target position
                    {
                        Unit* unit = Unit::GetUnit(*me, WatchTarget);
                        if (unit)
                        {
                            targetX = unit->GetPositionX();
                            targetY = unit->GetPositionY();
                            targetZ = unit->GetPositionZ();
                        }
                        endWatch = false;
                    }

                    if (!someWatched)
                    {
                        //Cleave
                        if (Cleave_Timer <= diff)
                        {
                            DoCast(me->getVictim(), SPELL_CLEAVE);
                            Cleave_Timer = 7000;
                        } else Cleave_Timer -= diff;

                        //Whirlwind
                        if (Whirlwind_Timer <= diff)
                        {
                            DoCast(me, SPELL_WHIRLWIND);
                            Whirlwind_Timer = 18000;
                        } else Whirlwind_Timer -= diff;

                        //If more then 3 targets in melee range mandokir will cast fear
                        if (Fear_Timer <= diff)
                        {
                            TargetInRange = 0;

                            std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin();
                            for (; i != me->getThreatManager().getThreatList().end(); ++i)
                            {
                                Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid());
                                if (unit && me->IsWithinMeleeRange(unit))
                                    ++TargetInRange;
                            }

                            if (TargetInRange > 3)
                                DoCast(me->getVictim(), SPELL_FEAR);

                            Fear_Timer = 4000;
                        } else Fear_Timer -=diff;

                        //Mortal Strike if target below 50% hp
                        if (me->getVictim() && me->getVictim()->HealthBelowPct(50))
                        {
                            if (MortalStrike_Timer <= diff)
                            {
                                DoCast(me->getVictim(), SPELL_MORTAL_STRIKE);
                                MortalStrike_Timer = 15000;
                            } else MortalStrike_Timer -= diff;
                        }
                    }
                    //Checking if Ohgan is dead. If yes Mandokir will enrage.
                    if (Check_Timer <= diff)
                    {
                        if (instance)
                        {
                            if (instance->GetData(DATA_OHGAN) == DONE)
                            {
                                if (!RaptorDead)
                                {
                                    DoCast(me, SPELL_ENRAGE);
                                    RaptorDead = true;
                                }
                            }
                        }

                        Check_Timer = 1000;
                    } else Check_Timer -= diff;

                    DoMeleeAttackIfReady();
                }
            }
Example #5
0
        void UpdateEscortAI(const uint32 uiDiff)
        {
            if (uiPhaseTimer <= uiDiff)
            {
                switch (uiStep)
                {
                    case 1:
                        if (instance)
                        {
                            if (instance->GetData(DATA_BRANN_EVENT) != NOT_STARTED)
                                return;
                            instance->SetData(DATA_BRANN_EVENT, IN_PROGRESS);
                        }
                        bIsBattle = false;
                        Talk(SAY_ESCORT_START);
                        SetRun(true);
                        JumpToNextStep(0);
                        break;
                    case 3:
                        SetEscortPaused(false);
                        JumpToNextStep(0);
                        break;
                    case 5:
                        if (instance)
                            if (Creature* temp = (Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM))))
                                temp->AI()->Talk(SAY_EVENT_INTRO_3_ABED);
                            JumpToNextStep(8500);
                        break;
                    case 6:
                        Talk(SAY_EVENT_A_1);
                        JumpToNextStep(6500);
                        break;
                    case 7:
                        if (instance)
                            if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_KADDRAK)))
                                temp->AI()->Talk(SAY_EVENT_A_2_KADD);
                            JumpToNextStep(12500);
                        break;
                    case 8:
                        Talk(SAY_EVENT_A_3);
                        if (instance)
                            instance->HandleGameObject(instance->GetData64(DATA_GO_KADDRAK), true);
                        if (Creature* temp = Unit::GetCreature(*me, uiControllerGUID))
                            CAST_AI(npc_tribuna_controller::npc_tribuna_controllerAI, temp->AI())->bKaddrakActivated = true;
                        JumpToNextStep(5000);
                        break;
                    case 9:
                        me->SetReactState(REACT_PASSIVE);
                        SpawnDwarf(1);
                        JumpToNextStep(20000);
                        break;
                    case 10:
                        Talk(SAY_EVENT_B_1);
                        JumpToNextStep(6000);
                        break;
                    case 11:
                        if (instance)
                            if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_MARNAK)))
                                temp->AI()->Talk(SAY_EVENT_B_2_MARN);
                        SpawnDwarf(1);
                        JumpToNextStep(20000);
                        break;
                    case 12:
                        Talk(SAY_EVENT_B_3);
                        if (instance)
                            instance->HandleGameObject(instance->GetData64(DATA_GO_MARNAK), true);
                        if (Creature* temp = Unit::GetCreature(*me, uiControllerGUID))
                            CAST_AI(npc_tribuna_controller::npc_tribuna_controllerAI, temp->AI())->bMarnakActivated = true;
                        JumpToNextStep(10000);
                        break;
                    case 13:
                        SpawnDwarf(1);
                        JumpToNextStep(10000);
                        break;
                    case 14:
                        SpawnDwarf(2);
                        JumpToNextStep(20000);
                        break;
                    case 15:
                        Talk(SAY_EVENT_C_1);
                        SpawnDwarf(1);
                        JumpToNextStep(10000);
                        break;
                    case 16:
                        SpawnDwarf(2);
                        JumpToNextStep(20000);
                        break;
                    case 17:
                        if (instance)
                            if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
                                temp->AI()->Talk(SAY_EVENT_C_2_ABED);
                            SpawnDwarf(1);
                        JumpToNextStep(20000);
                        break;
                    case 18:
                        Talk(SAY_EVENT_C_3);
                        if (instance)
                            instance->HandleGameObject(instance->GetData64(DATA_GO_ABEDNEUM), true);
                        if (Creature* temp = Unit::GetCreature(*me, uiControllerGUID))
                            CAST_AI(npc_tribuna_controller::npc_tribuna_controllerAI, temp->AI())->bAbedneumActivated = true;
                        JumpToNextStep(5000);
                        break;
                    case 19:
                        SpawnDwarf(2);
                        JumpToNextStep(10000);
                        break;
                    case 20:
                        SpawnDwarf(1);
                        JumpToNextStep(15000);
                        break;
                    case 21:
                        Talk(SAY_EVENT_D_1);
                        SpawnDwarf(3);
                        JumpToNextStep(20000);
                        break;
                    case 22:
                        if (instance)
                            if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
                                temp->AI()->Talk(SAY_EVENT_D_2_ABED);
                        SpawnDwarf(1);
                        JumpToNextStep(5000);
                        break;
                    case 23:
                        SpawnDwarf(2);
                        JumpToNextStep(15000);
                        break;
                    case 24:
                        Talk(SAY_EVENT_D_3);
                        SpawnDwarf(3);
                        JumpToNextStep(5000);
                        break;
                    case 25:
                        SpawnDwarf(1);
                        JumpToNextStep(5000);
                        break;
                    case 26:
                        SpawnDwarf(2);
                        JumpToNextStep(10000);
                        break;
                    case 27:
                        if (instance)
                            if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
                                temp->AI()->Talk(SAY_EVENT_D_4_ABED);
                        SpawnDwarf(1);
                        JumpToNextStep(10000);
                        break;
                    case 28:
                        me->SetReactState(REACT_DEFENSIVE);
                        Talk(SAY_EVENT_END_01);
                        me->SetStandState(UNIT_STAND_STATE_STAND);
                        if (instance)
                            instance->HandleGameObject(instance->GetData64(DATA_GO_SKY_FLOOR), true);
                        if (Creature* temp = Unit::GetCreature(*me, uiControllerGUID))
                            temp->DealDamage(temp, temp->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                        bIsBattle = true;
                        SetEscortPaused(false);
                        JumpToNextStep(6500);
                        break;
                    case 29:
                        Talk(SAY_EVENT_END_02);
                        if (instance)
                            instance->SetData(DATA_BRANN_EVENT, DONE);
                        me->CastSpell(me, SPELL_REWARD_ACHIEVEMENT, true);
                        JumpToNextStep(5500);
                        break;
                    case 30:
                        if (instance)
                            if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
                                temp->AI()->Talk(SAY_EVENT_END_03_ABED);
                        JumpToNextStep(8500);
                        break;
                    case 31:
                        Talk(SAY_EVENT_END_04);
                        JumpToNextStep(11500);
                        break;
                    case 32:
                        if (instance)
                            if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
                                temp->AI()->Talk(SAY_EVENT_END_05_ABED);
                            JumpToNextStep(11500);
                        break;
                    case 33:
                        Talk(SAY_EVENT_END_06);
                        JumpToNextStep(4500);
                        break;
                    case 34:
                        if (instance)
                            if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
                                temp->AI()->Talk(SAY_EVENT_END_07_ABED);
                            JumpToNextStep(22500);
                        break;
                    case 35:
                        Talk(SAY_EVENT_END_08);
                        JumpToNextStep(7500);
                        break;
                    case 36:
                        if (instance)
                            if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_KADDRAK)))
                                temp->AI()->Talk(SAY_EVENT_END_09_KADD);
                        JumpToNextStep(18500);
                        break;
                    case 37:
                        Talk(SAY_EVENT_END_10);
                        JumpToNextStep(5500);
                        break;
                    case 38:
                        if (instance)
                            if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_KADDRAK)))
                                temp->AI()->Talk(SAY_EVENT_END_11_KADD);
                            JumpToNextStep(20500);
                        break;
                    case 39:
                        Talk(SAY_EVENT_END_12);
                        JumpToNextStep(2500);
                        break;
                    case 40:
                        if (instance)
                            if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_KADDRAK)))
                                temp->AI()->Talk(SAY_EVENT_END_13_KADD);
                        JumpToNextStep(19500);
                        break;
                    case 41:
                        Talk(SAY_EVENT_END_14);
                        JumpToNextStep(10500);
                        break;
                    case 42:
                        if (instance)
                            if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_MARNAK)))
                                temp->AI()->Talk(SAY_EVENT_END_15_MARN);
                            JumpToNextStep(6500);
                        break;
                    case 43:
                        Talk(SAY_EVENT_END_16);
                        JumpToNextStep(6500);
                        break;
                    case 44:
                        if (instance)
                            if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_MARNAK)))
                                temp->AI()->Talk(SAY_EVENT_END_17_MARN);
                            JumpToNextStep(25500);
                        break;
                    case 45:
                        Talk(SAY_EVENT_END_18);
                        JumpToNextStep(23500);
                        break;
                    case 46:
                        if (instance)
                            if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_MARNAK)))
                                temp->AI()->Talk(SAY_EVENT_END_19_MARN);
                            JumpToNextStep(3500);
                        break;
                    case 47:
                        Talk(SAY_EVENT_END_20);
                        JumpToNextStep(8500);
                        break;
                    case 48:
                        if (instance)
                            if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
                                temp->AI()->Talk(SAY_EVENT_END_21_ABED);
                            JumpToNextStep(5500);
                        break;
                    case 49:
                    {
                        if (instance)
                        {
                            instance->HandleGameObject(instance->GetData64(DATA_GO_KADDRAK), false);
                            instance->HandleGameObject(instance->GetData64(DATA_GO_MARNAK), false);
                            instance->HandleGameObject(instance->GetData64(DATA_GO_ABEDNEUM), false);
                            instance->HandleGameObject(instance->GetData64(DATA_GO_SKY_FLOOR), false);
                        }
                        Player* player = GetPlayerForEscort();
                        if (player)
                            player->GroupEventHappens(QUEST_HALLS_OF_STONE, me);
                        me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                        JumpToNextStep(180000);
                        break;
                    }
                    case 50:
                        SetEscortPaused(false);
                        break;
                }
            } else uiPhaseTimer -= uiDiff;

            if (!bIsLowHP && HealthBelowPct(30))
            {
                Talk(SAY_LOW_HEALTH);
                bIsLowHP = true;
            }
            else if (bIsLowHP && !HealthBelowPct(30))
                bIsLowHP = false;

            if (!UpdateVictim())
                return;

            DoMeleeAttackIfReady();
        }
Example #6
0
            void UpdateAI(const uint32 diff)
            {
                if (!UpdateVictim())
                    return;

                    //Check_Timer for the death of LorKhan and Zath.
                    if (!WasDead && Check_Timer <= diff)
                    {
                        if (m_pInstance)
                        {
                            if (m_pInstance->GetData(DATA_LORKHAN) == SPECIAL)
                            {
                                //Resurrect LorKhan
                                if (Unit* pLorKhan = Unit::GetUnit((*me), m_pInstance->GetData64(DATA_LORKHAN)))
                                {
                                    pLorKhan->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
                                    pLorKhan->setFaction(14);
                                    pLorKhan->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                    pLorKhan->SetFullHealth();

                                    m_pInstance->SetData(DATA_LORKHAN, DONE);
                                }
                            }

                            if (m_pInstance->GetData(DATA_ZATH) == SPECIAL)
                            {
                                //Resurrect Zath
                                Unit* pZath = Unit::GetUnit((*me), m_pInstance->GetData64(DATA_ZATH));
                                if (pZath)
                                {
                                    pZath->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
                                    pZath->setFaction(14);
                                    pZath->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                    pZath->SetFullHealth();

                                    m_pInstance->SetData(DATA_ZATH, DONE);
                                }
                            }
                        }

                        Check_Timer = 5000;
                    } else Check_Timer -= diff;

                    if (!PhaseTwo && MortalCleave_Timer <= diff)
                    {
                        DoCast(me->getVictim(), SPELL_MORTALCLEAVE);
                        MortalCleave_Timer = 15000 + rand()%5000;
                    } else MortalCleave_Timer -= diff;

                    if (!PhaseTwo && Silence_Timer <= diff)
                    {
                        DoCast(me->getVictim(), SPELL_SILENCE);
                        Silence_Timer = 20000 + rand()%5000;
                    } else Silence_Timer -= diff;

                    if (!PhaseTwo && !WasDead && !HealthAbovePct(5))
                    {
                        me->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE_PERCENT);
                        me->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE);
                        me->RemoveAurasByType(SPELL_AURA_PERIODIC_LEECH);
                        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                        me->SetStandState(UNIT_STAND_STATE_SLEEP);
                        me->AttackStop();

                        if (m_pInstance)
                            m_pInstance->SetData(DATA_THEKAL, SPECIAL);

                        WasDead=true;
                    }

                    //Thekal will transform to Tiger if he died and was not resurrected after 10 seconds.
                    if (!PhaseTwo && WasDead)
                    {
                        if (Resurrect_Timer <= diff)
                        {
                            DoCast(me, SPELL_TIGER_FORM);
                            me->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.00f);
                            me->SetStandState(UNIT_STAND_STATE_STAND);
                            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                            me->SetFullHealth();
                            const CreatureTemplate *cinfo = me->GetCreatureInfo();
                            me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 40)));
                            me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 40)));
                            me->UpdateDamagePhysical(BASE_ATTACK);
                            DoResetThreat();
                            PhaseTwo = true;
                        } else Resurrect_Timer -= diff;
                    }

                    if (me->IsFullHealth() && WasDead)
                    {
                        WasDead = false;
                    }

                    if (PhaseTwo)
                    {
                        if (Charge_Timer <= diff)
                        {
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                            {
                                DoCast(target, SPELL_CHARGE);
                                DoResetThreat();
                                AttackStart(target);
                            }

                            Charge_Timer = 15000 + rand()%7000;
                        } else Charge_Timer -= diff;

                        if (Frenzy_Timer <= diff)
                        {
                            DoCast(me, SPELL_FRENZY);
                            Frenzy_Timer = 30000;
                        } else Frenzy_Timer -= diff;

                        if (ForcePunch_Timer <= diff)
                        {
                            DoCast(me->getVictim(), SPELL_SILENCE);
                            ForcePunch_Timer = 16000 + rand()%5000;
                        } else ForcePunch_Timer -= diff;

                        if (SummonTigers_Timer <= diff)
                        {
                            DoCast(me->getVictim(), SPELL_SUMMONTIGERS);
                            SummonTigers_Timer = 10000 + rand()%4000;
                        } else SummonTigers_Timer -= diff;

                        if (HealthBelowPct(11) && !Enraged)
                        {
                            DoCast(me, SPELL_ENRAGE);
                            Enraged = true;
                        }
                    }

                    DoMeleeAttackIfReady();

            }
Example #7
0
            void UpdateAI (const uint32 diff)
            {
                if (!UpdateVictim())
                    return;

                //SweepingStrikes_Timer
                if (SweepingStrikes_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_SWEEPINGSTRIKES);
                    SweepingStrikes_Timer = 22000+rand()%4000;
                } else SweepingStrikes_Timer -= diff;

                //SinisterStrike_Timer
                if (SinisterStrike_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_SINISTERSTRIKE);
                    SinisterStrike_Timer = 8000+rand()%8000;
                } else SinisterStrike_Timer -= diff;

                //Gouge_Timer
                if (Gouge_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_GOUGE);

                    if (DoGetThreat(me->getVictim()))
                        DoModifyThreatPercent(me->getVictim(), -100);

                    Gouge_Timer = 17000+rand()%10000;
                } else Gouge_Timer -= diff;

                //Kick_Timer
                if (Kick_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_KICK);
                    Kick_Timer = 15000+rand()%10000;
                } else Kick_Timer -= diff;

                //Blind_Timer
                if (Blind_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_BLIND);
                    Blind_Timer = 10000+rand()%10000;
                } else Blind_Timer -= diff;

                //Check_Timer for the death of LorKhan and Zath.
                if (!FakeDeath && Check_Timer <= diff)
                {
                    if (m_pInstance)
                    {
                        if (m_pInstance->GetData(DATA_LORKHAN) == SPECIAL)
                        {
                            //Resurrect LorKhan
                            if (Unit* pLorKhan = Unit::GetUnit((*me), m_pInstance->GetData64(DATA_LORKHAN)))
                            {
                                pLorKhan->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
                                pLorKhan->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                pLorKhan->setFaction(14);
                                pLorKhan->SetFullHealth();
                            }
                        }

                        if (m_pInstance->GetData(DATA_THEKAL) == SPECIAL)
                        {
                            //Resurrect Thekal
                            if (Unit* pThekal = Unit::GetUnit((*me), m_pInstance->GetData64(DATA_THEKAL)))
                            {
                                pThekal->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
                                pThekal->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                pThekal->setFaction(14);
                                pThekal->SetFullHealth();
                            }
                        }
                    }

                    Check_Timer = 5000;
                } else Check_Timer -= diff;

                if (!HealthAbovePct(5))
                {
                    me->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE_PERCENT);
                    me->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE);
                    me->RemoveAurasByType(SPELL_AURA_PERIODIC_LEECH);
                    me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    me->SetStandState(UNIT_STAND_STATE_SLEEP);
                    me->setFaction(35);
                    me->AttackStop();

                    if (m_pInstance)
                        m_pInstance->SetData(DATA_ZATH, SPECIAL);

                    FakeDeath = true;
                }

                DoMeleeAttackIfReady();
            }
        void UpdateAI(const uint32 diff)
        {
            //Only if not incombat check if the event is started
            if (!me->isInCombat() && instance && instance->GetData(DATA_MAULGAREVENT))
            {
                Unit* target = Unit::GetUnit(*me, instance->GetData64(DATA_MAULGAREVENT_TANK));

                if (target)
                {
                    AttackStart(target);
                }
            }

            //Return since we have no target
            if (!UpdateVictim())
                return;

            //someone evaded!
            if (instance && !instance->GetData(DATA_MAULGAREVENT))
            {
                EnterEvadeMode();
                return;
            }

            //GreaterFireball_Timer
            if (GreaterFireball_Timer < diff || me->IsWithinDist(me->GetVictim(), 30))
            {
                DoCastVictim(SPELL_GREATER_FIREBALL);
                GreaterFireball_Timer = 2000;
            } else GreaterFireball_Timer -= diff;

            //SpellShield_Timer
            if (SpellShield_Timer <= diff)
            {
                me->InterruptNonMeleeSpells(false);
                DoCastVictim(SPELL_SPELLSHIELD);
                SpellShield_Timer = 30000;
            } else SpellShield_Timer -= diff;

            //BlastWave_Timer
            if (BlastWave_Timer <= diff)
            {
                Unit* target = NULL;
                std::list<HostileReference*> t_list = me->getThreatManager().getThreatList();
                std::vector<Unit*> target_list;
                for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
                {
                    target = Unit::GetUnit(*me, (*itr)->getUnitGuid());
                                                                //15 yard radius minimum
                    if (target && target->IsWithinDist(me, 15, false))
                        target_list.push_back(target);
                    target = NULL;
                }
                if (!target_list.empty())
                    target = *(target_list.begin()+rand()%target_list.size());

                me->InterruptNonMeleeSpells(false);
                DoCast(target, SPELL_BLAST_WAVE);
                BlastWave_Timer = 60000;
            } else BlastWave_Timer -= diff;
        }
Example #9
0
        void UpdateAI(uint32 diff)
        {
            //Only if not incombat check if the event is started
            if (!me->IsInCombat() && instance && instance->GetData(DATA_KARATHRESSEVENT))
            {
                if (Unit* target = Unit::GetUnit(*me, instance->GetData64(DATA_KARATHRESSEVENT_STARTER)))
                {
                    AttackStart(target);
                    GetAdvisors();
                }
            }

            //Return since we have no target
            if (!UpdateVictim())
                return;

            //someone evaded!
            if (instance && !instance->GetData(DATA_KARATHRESSEVENT))
            {
                EnterEvadeMode();
                return;
            }

            //CataclysmicBolt_Timer
            if (CataclysmicBolt_Timer <= diff)
            {
                //select a random unit other than the main tank
                Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1);

                //if there aren't other units, cast on the tank
                if (!target)
                    target = me->GetVictim();

                if (target)
                    DoCast(target, SPELL_CATACLYSMIC_BOLT);
                CataclysmicBolt_Timer = 10000;
            } else CataclysmicBolt_Timer -= diff;

            //SearNova_Timer
            if (SearNova_Timer <= diff)
            {
                DoCastVictim(SPELL_SEAR_NOVA);
                SearNova_Timer = 20000+rand()%40000;
            } else SearNova_Timer -= diff;

            //Enrage_Timer
            if (Enrage_Timer <= diff)
            {
                DoCast(me, SPELL_ENRAGE);
                Enrage_Timer = 90000;
            } else Enrage_Timer -= diff;

            //Blessing of Tides Trigger
            if (!HealthAbovePct(75) && !BlessingOfTides)
            {
                BlessingOfTides = true;
                bool continueTriggering = false;
                Creature* Advisor;
                for (uint8 i = 0; i < MAX_ADVISORS; ++i)
                    if (Advisors[i])
                    {
                        Advisor = (Unit::GetCreature(*me, Advisors[i]));
                        if (Advisor && Advisor->IsAlive())
                        {
                            continueTriggering = true;
                            break;
                        }
                    }
                if (continueTriggering)
                {
                    DoCast(me, SPELL_BLESSING_OF_THE_TIDES);
                    me->MonsterYell(SAY_GAIN_BLESSING_OF_TIDES, LANG_UNIVERSAL, 0);
                    DoPlaySoundToSet(me, SOUND_GAIN_BLESSING_OF_TIDES);
                }
            }

            DoMeleeAttackIfReady();
        }
Example #10
0
            void UpdateAI(const uint32 diff)
            {
                if (!UpdateVictim())
                    return;

                //BloodSiphon_Timer
                if (BloodSiphon_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_BLOODSIPHON);
                    BloodSiphon_Timer = 90000;
                } else BloodSiphon_Timer -= diff;

                //CorruptedBlood_Timer
                if (CorruptedBlood_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_CORRUPTEDBLOOD);
                    CorruptedBlood_Timer = 30000 + rand()%15000;
                } else CorruptedBlood_Timer -= diff;

                //CauseInsanity_Timer
                /*if (CauseInsanity_Timer <= diff)
                {
                if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                DoCast(pTarget, SPELL_CAUSEINSANITY);

                CauseInsanity_Timer = 35000 + rand()%8000;
                } else CauseInsanity_Timer -= diff;*/

                //WillOfHakkar_Timer
                if (WillOfHakkar_Timer <= diff)
                {
                    if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                        DoCast(pTarget, SPELL_WILLOFHAKKAR);

                    WillOfHakkar_Timer = 25000 + rand()%10000;
                } else WillOfHakkar_Timer -= diff;

                if (!Enraged && Enrage_Timer <= diff)
                {
                    DoCast(me, SPELL_ENRAGE);
                    Enraged = true;
                } else Enrage_Timer -= diff;

                //Checking if Jeklik is dead. If not we cast her Aspect
                if (CheckJeklik_Timer <= diff)
                {
                    if (m_pInstance)
                    {
                        if (m_pInstance->GetData(TYPE_JEKLIK) != DONE)
                        {
                            if (AspectOfJeklik_Timer <= diff)
                            {
                                DoCast(me->getVictim(), SPELL_ASPECT_OF_JEKLIK);
                                AspectOfJeklik_Timer = 10000 + rand()%4000;
                            } else AspectOfJeklik_Timer -= diff;
                        }
                    }
                    CheckJeklik_Timer = 1000;
                } else CheckJeklik_Timer -= diff;

                //Checking if Venoxis is dead. If not we cast his Aspect
                if (CheckVenoxis_Timer <= diff)
                {
                    if (m_pInstance)
                    {
                        if (m_pInstance->GetData(TYPE_VENOXIS) != DONE)
                        {
                            if (AspectOfVenoxis_Timer <= diff)
                            {
                                DoCast(me->getVictim(), SPELL_ASPECT_OF_VENOXIS);
                                AspectOfVenoxis_Timer = 8000;
                            } else AspectOfVenoxis_Timer -= diff;
                        }
                    }
                    CheckVenoxis_Timer = 1000;
                } else CheckVenoxis_Timer -= diff;

                //Checking if Marli is dead. If not we cast her Aspect
                if (CheckMarli_Timer <= diff)
                {
                    if (m_pInstance)
                    {
                        if (m_pInstance->GetData(TYPE_MARLI) != DONE)
                        {
                            if (AspectOfMarli_Timer <= diff)
                            {
                                DoCast(me->getVictim(), SPELL_ASPECT_OF_MARLI);
                                AspectOfMarli_Timer = 10000;
                            } else AspectOfMarli_Timer -= diff;

                        }
                    }
                    CheckMarli_Timer = 1000;
                } else CheckMarli_Timer -= diff;

                //Checking if Thekal is dead. If not we cast his Aspect
                if (CheckThekal_Timer <= diff)
                {
                    if (m_pInstance)
                    {
                        if (m_pInstance->GetData(TYPE_THEKAL) != DONE)
                        {
                            if (AspectOfThekal_Timer <= diff)
                            {
                                DoCast(me, SPELL_ASPECT_OF_THEKAL);
                                AspectOfThekal_Timer = 15000;
                            } else AspectOfThekal_Timer -= diff;
                        }
                    }
                    CheckThekal_Timer = 1000;
                } else CheckThekal_Timer -= diff;

                //Checking if Arlokk is dead. If yes we cast her Aspect
                if (CheckArlokk_Timer <= diff)
                {
                    if (m_pInstance)
                    {
                        if (m_pInstance->GetData(TYPE_ARLOKK) != DONE)
                        {
                            if (AspectOfArlokk_Timer <= diff)
                            {
                                DoCast(me, SPELL_ASPECT_OF_ARLOKK);
                                DoResetThreat();

                                AspectOfArlokk_Timer = 10000 + rand()%5000;
                            } else AspectOfArlokk_Timer -= diff;
                        }
                    }
                    CheckArlokk_Timer = 1000;
                } else CheckArlokk_Timer -= diff;

                DoMeleeAttackIfReady();
            }
        void UpdateAI(const uint32 diff)
        {
            //Only if not incombat check if the event is started
            if (!me->isInCombat() && instance && instance->GetData(DATA_MAULGAREVENT))
            {
                Unit* target = Unit::GetUnit(*me, instance->GetData64(DATA_MAULGAREVENT_TANK));

                if (target)
                {
                    AttackStart(target);
                    GetCouncil();
                }
            }

            //Return since we have no target
            if (!UpdateVictim())
                return;

            //someone evaded!
            if (instance && !instance->GetData(DATA_MAULGAREVENT))
            {
                EnterEvadeMode();
                return;
            }

            //ArcingSmash_Timer
            if (ArcingSmash_Timer <= diff)
            {
                DoCastVictim(SPELL_ARCING_SMASH);
                ArcingSmash_Timer = 10000;
            } else ArcingSmash_Timer -= diff;

            //Whirlwind_Timer
                   if (Whirlwind_Timer <= diff)
                   {
                        DoCastVictim(SPELL_WHIRLWIND);
                        Whirlwind_Timer = 55000;
                   } else Whirlwind_Timer -= diff;

            //MightyBlow_Timer
            if (MightyBlow_Timer <= diff)
            {
                DoCastVictim(SPELL_MIGHTY_BLOW);
                MightyBlow_Timer = 30000+rand()%10000;
            } else MightyBlow_Timer -= diff;

            //Entering Phase 2
            if (!Phase2 && HealthBelowPct(50))
            {
                Phase2 = true;
                Talk(SAY_ENRAGE);

                DoCast(me, SPELL_DUAL_WIELD, true);
                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, 0);
                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, 0);
            }

            if (Phase2)
            {
                //Charging_Timer
                if (Charging_Timer <= diff)
                {
                    Unit* target = NULL;
                    target = SelectTarget(SELECT_TARGET_RANDOM, 0);
                    if (target)
                    {
                        AttackStart(target);
                        DoCast(target, SPELL_BERSERKER_C);
                    }
                    Charging_Timer = 20000;
                } else Charging_Timer -= diff;

                //Intimidating Roar
                if (Roar_Timer <= diff)
                {
                    DoCast(me, SPELL_ROAR);
                    Roar_Timer = 40000+(rand()%10000);
                } else Roar_Timer -= diff;
            }

            DoMeleeAttackIfReady();
        }
        void UpdateAI(const uint32 diff)
        {
            events.Update(diff);
            switch (events.ExecuteEvent())
            {
                case EVENT_START_INTRO:
                    me->GetMotionMaster()->MovePoint(0, MoveThronePos);
                    // Begining of intro is differents between factions as the speech sequence and timers are differents.
                    if (instance->GetData(DATA_TEAM_IN_INSTANCE) == ALLIANCE)
                        events.ScheduleEvent(EVENT_INTRO_A2_1, 0);
                    else
                        events.ScheduleEvent(EVENT_INTRO_H2_1, 0);
                    break;

            // A2 Intro Events
                case EVENT_INTRO_A2_1:
                    DoScriptText(SAY_JAINA_INTRO_3, me);
                    events.ScheduleEvent(EVENT_INTRO_A2_2, 5000);
                    break;
                case EVENT_INTRO_A2_2:
                    DoScriptText(SAY_JAINA_INTRO_4, me);
                    events.ScheduleEvent(EVENT_INTRO_A2_3, 10000);
                    break;
                case EVENT_INTRO_A2_3:
                    // TODO: she's doing some kind of spell casting emote
                    instance->HandleGameObject(instance->GetData64(DATA_FROSTMOURNE), true);
                    events.ScheduleEvent(EVENT_INTRO_A2_4, 10000);
                    break;
                case EVENT_INTRO_A2_4:
                    // spawn UTHER during speach 2
                    if (Creature* pUther = me->SummonCreature(NPC_UTHER, UtherSpawnPos, TEMPSUMMON_MANUAL_DESPAWN))
                    {
                        pUther->GetMotionMaster()->MoveIdle();
                        pUther->SetReactState(REACT_PASSIVE); // be sure he will not aggro arthas
                        uiUther = pUther->GetGUID();
                    }
                    events.ScheduleEvent(EVENT_INTRO_A2_5, 2000);
                    break;
                case EVENT_INTRO_A2_5:
                    if (Creature* pUther = me->GetCreature(*me, uiUther))
                        DoScriptText(SAY_UTHER_INTRO_A2_1, pUther);
                    events.ScheduleEvent(EVENT_INTRO_A2_6, 3000);
                    break;
                case EVENT_INTRO_A2_6:
                    DoScriptText(SAY_JAINA_INTRO_5, me);
                    events.ScheduleEvent(EVENT_INTRO_A2_7, 6000);
                    break;
                case EVENT_INTRO_A2_7:
                    if (Creature* pUther = me->GetCreature(*me, uiUther))
                        DoScriptText(SAY_UTHER_INTRO_A2_2, pUther);
                    events.ScheduleEvent(EVENT_INTRO_A2_8, 6500);
                    break;
                case EVENT_INTRO_A2_8:
                    DoScriptText(SAY_JAINA_INTRO_6, me);
                    events.ScheduleEvent(EVENT_INTRO_A2_9, 2000);
                    break;
                case EVENT_INTRO_A2_9:
                    if (Creature* pUther = me->GetCreature(*me, uiUther))
                        DoScriptText(SAY_UTHER_INTRO_A2_3, pUther);
                    events.ScheduleEvent(EVENT_INTRO_A2_10, 9000);
                    break;
                case EVENT_INTRO_A2_10:
                    DoScriptText(SAY_JAINA_INTRO_7, me);
                    events.ScheduleEvent(EVENT_INTRO_A2_11, 5000);
                    break;
                case EVENT_INTRO_A2_11:
                    if (Creature* pUther = me->GetCreature(*me, uiUther))
                        DoScriptText(SAY_UTHER_INTRO_A2_4, pUther);
                    events.ScheduleEvent(EVENT_INTRO_A2_12, 11000);
                    break;
                case EVENT_INTRO_A2_12:
                    DoScriptText(SAY_JAINA_INTRO_8, me);
                    events.ScheduleEvent(EVENT_INTRO_A2_13, 4000);
                    break;
                case EVENT_INTRO_A2_13:
                    if (Creature* pUther = me->GetCreature(*me, uiUther))
                        DoScriptText(SAY_UTHER_INTRO_A2_5, pUther);
                    events.ScheduleEvent(EVENT_INTRO_A2_14, 12500);
                    break;
                case EVENT_INTRO_A2_14:
                    DoScriptText(SAY_JAINA_INTRO_9, me);
                    events.ScheduleEvent(EVENT_INTRO_A2_15, 10000);
                    break;
                case EVENT_INTRO_A2_15:
                    if (Creature* pUther = me->GetCreature(*me, uiUther))
                        DoScriptText(SAY_UTHER_INTRO_A2_6, pUther);
                    events.ScheduleEvent(EVENT_INTRO_A2_16, 22000);
                    break;
                case EVENT_INTRO_A2_16:
                    if (Creature* pUther = me->GetCreature(*me, uiUther))
                        DoScriptText(SAY_UTHER_INTRO_A2_7, pUther);
                    events.ScheduleEvent(EVENT_INTRO_A2_17, 4000);
                    break;
                case EVENT_INTRO_A2_17:
                    DoScriptText(SAY_JAINA_INTRO_10, me);
                    events.ScheduleEvent(EVENT_INTRO_A2_18, 2000);
                    break;
                case EVENT_INTRO_A2_18:
                    if (Creature* pUther = me->GetCreature(*me, uiUther))
                    {
                        pUther->HandleEmoteCommand(EMOTE_ONESHOT_NO);
                        DoScriptText(SAY_UTHER_INTRO_A2_8, pUther);
                    }
                    events.ScheduleEvent(EVENT_INTRO_A2_19, 11000);
                    break;
                case EVENT_INTRO_A2_19:
                    DoScriptText(SAY_JAINA_INTRO_11, me);
                    events.ScheduleEvent(EVENT_INTRO_LK_1, 2000);
                    break;

            // H2 Intro Events
                case EVENT_INTRO_H2_1:
                    DoScriptText(SAY_SYLVANAS_INTRO_1, me);
                    events.ScheduleEvent(EVENT_INTRO_H2_2, 8000);
                    break;
                case EVENT_INTRO_H2_2:
                    DoScriptText(SAY_SYLVANAS_INTRO_2, me);
                    events.ScheduleEvent(EVENT_INTRO_H2_3, 6000);
                    break;
                case EVENT_INTRO_H2_3:
                    DoScriptText(SAY_SYLVANAS_INTRO_3, me);
                    // TODO: she's doing some kind of spell casting emote
                    events.ScheduleEvent(EVENT_INTRO_H2_4, 6000);
                    break;
                case EVENT_INTRO_H2_4:
                    // spawn UTHER during speach 2
                    if (Creature* pUther = me->SummonCreature(NPC_UTHER, UtherSpawnPos, TEMPSUMMON_MANUAL_DESPAWN))
                    {
                        pUther->GetMotionMaster()->MoveIdle();
                        pUther->SetReactState(REACT_PASSIVE); // be sure he will not aggro arthas
                        uiUther = pUther->GetGUID();
                    }
                    events.ScheduleEvent(EVENT_INTRO_H2_5, 2000);
                    break;
                case EVENT_INTRO_H2_5:
                    if (Creature* pUther = me->GetCreature(*me, uiUther))
                        DoScriptText(SAY_UTHER_INTRO_H2_1, pUther);
                    events.ScheduleEvent(EVENT_INTRO_H2_6, 11000);
                    break;
                case EVENT_INTRO_H2_6:
                    DoScriptText(SAY_SYLVANAS_INTRO_4, me);
                    events.ScheduleEvent(EVENT_INTRO_H2_7, 3000);
                    break;
                case EVENT_INTRO_H2_7:
                    if (Creature* pUther = me->GetCreature(*me, uiUther))
                        DoScriptText(SAY_UTHER_INTRO_H2_2, pUther);
                    events.ScheduleEvent(EVENT_INTRO_H2_8, 6000);
                    break;
                case EVENT_INTRO_H2_8:
                    DoScriptText(SAY_SYLVANAS_INTRO_5, me);
                    events.ScheduleEvent(EVENT_INTRO_H2_9, 5000);
                    break;
                case EVENT_INTRO_H2_9:
                    if (Creature* pUther = me->GetCreature(*me, uiUther))
                        DoScriptText(SAY_UTHER_INTRO_H2_3, pUther);
                    events.ScheduleEvent(EVENT_INTRO_H2_10, 19000);
                    break;
                case EVENT_INTRO_H2_10:
                    DoScriptText(SAY_SYLVANAS_INTRO_6, me);
                    events.ScheduleEvent(EVENT_INTRO_H2_11, 1500);
                    break;
                case EVENT_INTRO_H2_11:
                    if (Creature* pUther = me->GetCreature(*me, uiUther))
                        DoScriptText(SAY_UTHER_INTRO_H2_4, pUther);
                    events.ScheduleEvent(EVENT_INTRO_H2_12, 19500);
                    break;
                case EVENT_INTRO_H2_12:
                    DoScriptText(SAY_SYLVANAS_INTRO_7, me);
                    events.ScheduleEvent(EVENT_INTRO_H2_13, 2000);
                    break;
                case EVENT_INTRO_H2_13:
                    if (Creature* pUther = me->GetCreature(*me, uiUther))
                    {
                        pUther->HandleEmoteCommand(EMOTE_ONESHOT_NO);
                        DoScriptText(SAY_UTHER_INTRO_H2_5, pUther);
                    }
                    events.ScheduleEvent(EVENT_INTRO_H2_14, 12000);
                    break;
                case EVENT_INTRO_H2_14:
                    if (Creature* pUther = me->GetCreature(*me, uiUther))
                        DoScriptText(SAY_UTHER_INTRO_H2_6, pUther);
                    events.ScheduleEvent(EVENT_INTRO_H2_15, 8000);
                    break;
                case EVENT_INTRO_H2_15:
                    DoScriptText(SAY_SYLVANAS_INTRO_8, me);
                    events.ScheduleEvent(EVENT_INTRO_LK_1, 2000);
                    break;

            // Remaining Intro Events common for both faction
                case EVENT_INTRO_LK_1:
                    // Spawn LK in front of door, and make him move to the sword.
                    if (Creature* pLichKing = me->SummonCreature(NPC_LICH_KING_EVENT, LichKingSpawnPos, TEMPSUMMON_MANUAL_DESPAWN))
                    {
                        pLichKing->GetMotionMaster()->MovePoint(0, LichKingMoveThronePos);
                        pLichKing->SetReactState(REACT_PASSIVE);
                        uiLichKing = pLichKing->GetGUID();
                    }

                    if (Creature* pUther = me->GetCreature(*me, uiUther))
                    {
                        if (instance->GetData(DATA_TEAM_IN_INSTANCE) == ALLIANCE)
                            DoScriptText(SAY_UTHER_INTRO_A2_9, pUther);
                        else
                            DoScriptText(SAY_UTHER_INTRO_H2_7, pUther);
                    }

                    events.ScheduleEvent(EVENT_INTRO_LK_2, 11000);
                    break;

                case EVENT_INTRO_LK_2:
                     if (Creature* pLichKing = me->GetCreature(*me, uiLichKing))
                         DoScriptText(SAY_LK_INTRO_1, pLichKing);
                     events.ScheduleEvent(EVENT_INTRO_LK_3, 2000);
                     break;

                case EVENT_INTRO_LK_3:
                     // The Lich King banishes Uther to the abyss.
                     if (Creature* pUther = me->GetCreature(*me, uiUther))
                     {
                         pUther->DisappearAndDie();
                         uiUther = 0;
                     }

                     // He steps forward and removes the runeblade from the heap of skulls.

                     events.ScheduleEvent(EVENT_INTRO_LK_4, 4000);
                     break;

                case EVENT_INTRO_LK_4:
                      if (Creature* pLichKing = me->GetCreature(*me, uiLichKing))
                          DoScriptText(SAY_LK_INTRO_2, pLichKing);
                    events.ScheduleEvent(EVENT_INTRO_LK_5, 10000);
                    break;

                case EVENT_INTRO_LK_5:
                    // summon Falric and Marwyn. then go back to the door
                    if (Creature* pFalric = me->GetCreature(*me, instance->GetData64(DATA_FALRIC)))
                        pFalric->SetVisible(true);
                    if (Creature* pMarwyn = me->GetCreature(*me, instance->GetData64(DATA_MARWYN)))
                        pMarwyn->SetVisible(true);

                    if (Creature* pLichKing = me->GetCreature(*me, uiLichKing))
                    {
                        pLichKing->GetMotionMaster()->MovePoint(0, LichKingSpawnPos);
                        DoScriptText(SAY_LK_INTRO_3, pLichKing);
                    }

                    events.ScheduleEvent(EVENT_INTRO_LK_6, 8000);
                    break;

                case EVENT_INTRO_LK_6:
                    if (Creature* pFalric = me->GetCreature(*me, instance->GetData64(DATA_FALRIC)))
                        DoScriptText(SAY_FALRIC_INTRO_1, pFalric);

                    events.ScheduleEvent(EVENT_INTRO_LK_7, 2000);
                    break;

                case EVENT_INTRO_LK_7:
                    if (Creature* pMarwyn = me->GetCreature(*me, instance->GetData64(DATA_MARWYN)))
                        DoScriptText(SAY_MARWYN_INTRO_1, pMarwyn);

                    events.ScheduleEvent(EVENT_INTRO_LK_8, 2000);
                    break;

                case EVENT_INTRO_LK_8:
                    if (Creature* pFalric = me->GetCreature(*me, instance->GetData64(DATA_FALRIC)))
                        DoScriptText(SAY_FALRIC_INTRO_2, pFalric);

                    events.ScheduleEvent(EVENT_INTRO_LK_9, 5000);
                    break;

                case EVENT_INTRO_LK_9:
                    if (instance->GetData(DATA_TEAM_IN_INSTANCE) == ALLIANCE)
                        DoScriptText(SAY_JAINA_INTRO_END, me);
                    else
                        DoScriptText(SAY_SYLVANAS_INTRO_END, me);

                    me->GetMotionMaster()->MovePoint(0, LichKingSpawnPos);
                    // TODO: Loralen/Koreln shall run also
                    events.ScheduleEvent(EVENT_INTRO_END, 10000);
                    break;

                case EVENT_INTRO_END:
                    if (instance)
                        instance->SetData(DATA_WAVE_COUNT, SPECIAL);   // start first wave

                    // Loralen or Koreln disappearAndDie()
                    me->DisappearAndDie();
                    break;

                case EVENT_SKIP_INTRO:
                    // TODO: implement

                    if (Creature* pFalric = me->GetCreature(*me, instance->GetData64(DATA_FALRIC)))
                        pFalric->SetVisible(true);
                    if (Creature* pMarwyn = me->GetCreature(*me, instance->GetData64(DATA_MARWYN)))
                        pMarwyn->SetVisible(true);

                    me->GetMotionMaster()->MovePoint(0, LichKingSpawnPos);
                    // TODO: Loralen/Koreln shall run also

                    events.ScheduleEvent(EVENT_INTRO_END, 15000);
                    break;
            }
        }
    bool OnUse(Player* pPlayer, Item* /*_Item*/, SpellCastTargets const& targets)
    {
        InstanceScript *pInstance = pPlayer->GetInstanceScript();

        if (!pInstance)
        {
            pPlayer->GetSession()->SendNotification(TEXT_NOT_INITIALIZED);
            return true;
        }

        Creature *Vashj = NULL;
        Vashj = (Unit::GetCreature((*pPlayer), pInstance->GetData64(DATA_LADYVASHJ)));
        if (Vashj && (CAST_AI(boss_lady_vashj::boss_lady_vashjAI, Vashj->AI())->Phase == 2))
        {
            if (targets.GetGOTarget() && targets.GetGOTarget()->GetTypeId() == TYPEID_GAMEOBJECT)
            {
                uint32 identifier;
                uint8 channel_identifier;
                switch(targets.GetGOTarget()->GetEntry())
                {
                    case 185052:
                        identifier = DATA_SHIELDGENERATOR1;
                        channel_identifier = 0;
                        break;
                    case 185053:
                        identifier = DATA_SHIELDGENERATOR2;
                        channel_identifier = 1;
                        break;
                    case 185051:
                        identifier = DATA_SHIELDGENERATOR3;
                        channel_identifier = 2;
                        break;
                    case 185054:
                        identifier = DATA_SHIELDGENERATOR4;
                        channel_identifier = 3;
                        break;
                    default:
                        return true;
                }

                if (pInstance->GetData(identifier))
                {
                    pPlayer->GetSession()->SendNotification(TEXT_ALREADY_DEACTIVATED);
                    return true;
                }

                //get and remove channel
                Unit *Channel = NULL;
                Channel = Unit::GetCreature(*Vashj, CAST_AI(boss_lady_vashj::boss_lady_vashjAI, Vashj->AI())->ShieldGeneratorChannel[channel_identifier]);
                if (Channel)
                {
                    //call Unsummon()
                    Channel->setDeathState(JUST_DIED);
                }

                pInstance->SetData(identifier, 1);

                //remove this item
                pPlayer->DestroyItemCount(31088, 1, true);
                return true;
            }
            else if (targets.GetUnitTarget()->GetTypeId() == TYPEID_UNIT)
                return false;
            else if (targets.GetUnitTarget()->GetTypeId() == TYPEID_PLAYER)
            {
                pPlayer->DestroyItemCount(31088, 1, true);
                pPlayer->CastSpell(targets.GetUnitTarget(), 38134, true);
                return true;
            }
        }
        return true;
    }
        void UpdateAI(const uint32 diff)
        {
            if (!CanAttack && Intro)
            {
                if (AggroTimer <= diff)
                {
                    CanAttack = true;
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    AggroTimer=19000;
                }else
                {
                    AggroTimer-=diff;
                    return;
                }
            }
            //to prevent abuses during phase 2
            if (Phase == 2 && !me->getVictim() && me->isInCombat())
            {
                EnterEvadeMode();
                return;
            }
            //Return since we have no target
            if (!UpdateVictim())
                return;

            if (Phase == 1 || Phase == 3)
            {
                //ShockBlast_Timer
                if (ShockBlast_Timer <= diff)
                {
                    //Shock Burst
                    //Randomly used in Phases 1 and 3 on Vashj's target, it's a Shock spell doing 8325-9675 nature damage and stunning the target for 5 seconds, during which she will not attack her target but switch to the next person on the aggro list.
                    DoCast(me->getVictim(), SPELL_SHOCK_BLAST);
                    me->TauntApply(me->getVictim());

                    ShockBlast_Timer = 1000+rand()%14000;       //random cooldown
                } else ShockBlast_Timer -= diff;

                //StaticCharge_Timer
                if (StaticCharge_Timer <= diff)
                {
                    //Static Charge
                    //Used on random people (only 1 person at any given time) in Phases 1 and 3, it's a debuff doing 2775 to 3225 Nature damage to the target and everybody in about 5 yards around it, every 1 seconds for 30 seconds. It can be removed by Cloak of Shadows, Iceblock, Divine Shield, etc, but not by Cleanse or Dispel Magic.
                    Unit *pTarget = NULL;
                    pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 200, true);

                    if (pTarget && !pTarget->HasAura(SPELL_STATIC_CHARGE_TRIGGER))
                                                                //cast Static Charge every 2 seconds for 20 seconds
                            DoCast(pTarget, SPELL_STATIC_CHARGE_TRIGGER);

                    StaticCharge_Timer = 10000+rand()%20000;    //blizzlike
                } else StaticCharge_Timer -= diff;

                //Entangle_Timer
                if (Entangle_Timer <= diff)
                {
                    if (!Entangle)
                    {
                        //Entangle
                        //Used in Phases 1 and 3, it casts Entangling Roots on everybody in a 15 yard radius of Vashj, immobilzing them for 10 seconds and dealing 500 damage every 2 seconds. It's not a magic effect so it cannot be dispelled, but is removed by various buffs such as Cloak of Shadows or Blessing of Freedom.
                        DoCast(me->getVictim(), SPELL_ENTANGLE);
                        Entangle = true;
                        Entangle_Timer = 10000;
                    }
                    else
                    {
                        CastShootOrMultishot();
                        Entangle = false;
                        Entangle_Timer = 20000+rand()%5000;
                    }
                } else Entangle_Timer -= diff;

                //Phase 1
                if (Phase == 1)
                {
                    //Start phase 2
                    if (HealthBelowPct(70))
                    {
                        //Phase 2 begins when Vashj hits 70%. She will run to the middle of her platform and surround herself in a shield making her invulerable.
                        Phase = 2;

                        me->GetMotionMaster()->Clear();
                        DoTeleportTo(MIDDLE_X, MIDDLE_Y, MIDDLE_Z);

                        Creature *pCreature;
                        for (uint8 i = 0; i < 4; ++i)
                        {
                            pCreature = me->SummonCreature(SHIED_GENERATOR_CHANNEL, ShieldGeneratorChannelPos[i][0],  ShieldGeneratorChannelPos[i][1],  ShieldGeneratorChannelPos[i][2],  ShieldGeneratorChannelPos[i][3], TEMPSUMMON_CORPSE_DESPAWN, 0);
                            if (pCreature)
                                ShieldGeneratorChannel[i] = pCreature->GetGUID();
                        }
                        DoScriptText(SAY_PHASE2, me);
                    }
                }
                //Phase 3
                else
                {
                    //SummonSporebat_Timer
                    if (SummonSporebat_Timer <= diff)
                    {
                        Creature *Sporebat = NULL;
                        Sporebat = me->SummonCreature(TOXIC_SPOREBAT, SPOREBAT_X, SPOREBAT_Y, SPOREBAT_Z, SPOREBAT_O, TEMPSUMMON_CORPSE_DESPAWN, 0);

                        if (Sporebat)
                        {
                            Unit *pTarget = NULL;
                            pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0);
                            if (pTarget)
                                Sporebat->AI()->AttackStart(pTarget);
                        }

                        //summon sporebats faster and faster
                        if (SummonSporebat_StaticTimer > 1000)
                            SummonSporebat_StaticTimer -= 1000;

                        SummonSporebat_Timer = SummonSporebat_StaticTimer;

                        if (SummonSporebat_Timer < 5000)
                            SummonSporebat_Timer = 5000;

                    } else SummonSporebat_Timer -= diff;
                }

                //Melee attack
                DoMeleeAttackIfReady();

                //Check_Timer - used to check if somebody is in melee range
                if (Check_Timer <= diff)
                {
                    bool InMeleeRange = false;
                    Unit *pTarget;
                    std::list<HostileReference *> t_list = me->getThreatManager().getThreatList();
                    for (std::list<HostileReference *>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
                    {
                        pTarget = Unit::GetUnit(*me, (*itr)->getUnitGuid());
                                                                //if in melee range
                        if (pTarget && pTarget->IsWithinDistInMap(me, 5))
                        {
                            InMeleeRange = true;
                            break;
                        }
                    }

                    //if nobody is in melee range
                    if (!InMeleeRange)
                        CastShootOrMultishot();

                    Check_Timer = 5000;
                } else Check_Timer -= diff;
            }
            //Phase 2
            else
            {
                //ForkedLightning_Timer
                if (ForkedLightning_Timer <= diff)
                {
                    //Forked Lightning
                    //Used constantly in Phase 2, it shoots out completely randomly targeted bolts of lightning which hit everybody in a roughtly 60 degree cone in front of Vashj for 2313-2687 nature damage.
                    Unit *pTarget = NULL;
                    pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0);

                    if (!pTarget)
                        pTarget = me->getVictim();

                    DoCast(pTarget, SPELL_FORKED_LIGHTNING);

                    ForkedLightning_Timer = 2000+rand()%6000;   //blizzlike
                } else ForkedLightning_Timer -= diff;

                //EnchantedElemental_Timer
                if (EnchantedElemental_Timer <= diff)
                {
                    me->SummonCreature(ENCHANTED_ELEMENTAL, ElementPos[EnchantedElemental_Pos][0], ElementPos[EnchantedElemental_Pos][1], ElementPos[EnchantedElemental_Pos][2], ElementPos[EnchantedElemental_Pos][3], TEMPSUMMON_CORPSE_DESPAWN, 0);

                    if (EnchantedElemental_Pos == 7)
                        EnchantedElemental_Pos = 0;
                    else
                        ++EnchantedElemental_Pos;

                    EnchantedElemental_Timer = 10000+rand()%5000;
                } else EnchantedElemental_Timer -= diff;

                //TaintedElemental_Timer
                if (TaintedElemental_Timer <= diff)
                {
                    uint32 pos = rand()%8;
                    me->SummonCreature(TAINTED_ELEMENTAL, ElementPos[pos][0], ElementPos[pos][1], ElementPos[pos][2], ElementPos[pos][3], TEMPSUMMON_DEAD_DESPAWN, 0);

                    TaintedElemental_Timer = 120000;
                } else TaintedElemental_Timer -= diff;

                //CoilfangElite_Timer
                if (CoilfangElite_Timer <= diff)
                {
                    uint32 pos = rand()%3;
                    Creature* CoilfangElite = NULL;
                    CoilfangElite = me->SummonCreature(COILFANG_ELITE, CoilfangElitePos[pos][0], CoilfangElitePos[pos][1], CoilfangElitePos[pos][2], CoilfangElitePos[pos][3], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    if (CoilfangElite)
                    {
                        Unit *pTarget = NULL;
                        pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0);
                        if (pTarget)
                            CoilfangElite->AI()->AttackStart(pTarget);
                        else if (me->getVictim())
                            CoilfangElite->AI()->AttackStart(me->getVictim());
                    }
                    CoilfangElite_Timer = 45000+rand()%5000;
                } else CoilfangElite_Timer -= diff;

                //CoilfangStrider_Timer
                if (CoilfangStrider_Timer <= diff)
                {
                    uint32 pos = rand()%3;
                    Creature* CoilfangStrider = NULL;
                    CoilfangStrider = me->SummonCreature(COILFANG_STRIDER, CoilfangStriderPos[pos][0], CoilfangStriderPos[pos][1], CoilfangStriderPos[pos][2], CoilfangStriderPos[pos][3], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     if (CoilfangStrider)
                    {
                        Unit *pTarget = NULL;
                        pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0);
                        if (pTarget)
                            CoilfangStrider->AI()->AttackStart(pTarget);
                        else if (me->getVictim())
                            CoilfangStrider->AI()->AttackStart(me->getVictim());
                    }
                    CoilfangStrider_Timer = 60000+rand()%10000;
                } else CoilfangStrider_Timer -= diff;

                //Check_Timer
                if (Check_Timer <= diff)
                {
                    //Start Phase 3
                    if (pInstance && pInstance->GetData(DATA_CANSTARTPHASE3))
                    {
                        //set life 50%
                        me->SetHealth(me->CountPctFromMaxHealth(50));

                        me->RemoveAurasDueToSpell(SPELL_MAGIC_BARRIER);

                        DoScriptText(SAY_PHASE3, me);

                        Phase = 3;

                        //return to the tank
                        me->GetMotionMaster()->MoveChase(me->getVictim());
                    }
                    Check_Timer = 1000;
                } else Check_Timer -= diff;
            }
        }
Example #15
0
        void UpdateAI(uint32 diff) override
        {
            //Check if we have a target
            if (!UpdateVictim())
                return;

            uint32 currentPhase = instance->GetData(DATA_CTHUN_PHASE);
            if (currentPhase == PHASE_EYE_GREEN_BEAM || currentPhase == PHASE_EYE_RED_BEAM)
            {
                // EyeTentacleTimer
                if (EyeTentacleTimer <= diff)
                {
                    //Spawn the 8 Eye Tentacles in the corret spots
                    SpawnEyeTentacle(0, 20);                //south
                    SpawnEyeTentacle(10, 10);               //south west
                    SpawnEyeTentacle(20, 0);                //west
                    SpawnEyeTentacle(10, -10);              //north west

                    SpawnEyeTentacle(0, -20);               //north
                    SpawnEyeTentacle(-10, -10);             //north east
                    SpawnEyeTentacle(-20, 0);               // east
                    SpawnEyeTentacle(-10, 10);              // south east

                    EyeTentacleTimer = 45000;
                } else EyeTentacleTimer -= diff;
            }

            switch (currentPhase)
            {
                case PHASE_EYE_GREEN_BEAM:
                    //BeamTimer
                    if (BeamTimer <= diff)
                    {
                        //SPELL_GREEN_BEAM
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                        {
                            me->InterruptNonMeleeSpells(false);
                            DoCast(target, SPELL_GREEN_BEAM);

                            //Correctly update our target
                            me->SetTarget(target->GetGUID());
                        }

                        //Beam every 3 seconds
                        BeamTimer = 3000;
                    } else BeamTimer -= diff;

                    //ClawTentacleTimer
                    if (ClawTentacleTimer <= diff)
                    {
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                        {
                            Creature* Spawned = NULL;

                            //Spawn claw tentacle on the random target
                            Spawned = me->SummonCreature(NPC_CLAW_TENTACLE, *target, TEMPSUMMON_CORPSE_DESPAWN, 500);

                            if (Spawned && Spawned->AI())
                                Spawned->AI()->AttackStart(target);
                        }

                        //One claw tentacle every 12.5 seconds
                        ClawTentacleTimer = 12500;
                    } else ClawTentacleTimer -= diff;

                    //PhaseTimer
                    if (PhaseTimer <= diff)
                    {
                        //Switch to Dark Beam
                        instance->SetData(DATA_CTHUN_PHASE, PHASE_EYE_RED_BEAM);

                        me->InterruptNonMeleeSpells(false);
                        me->SetReactState(REACT_PASSIVE);

                        //Remove any target
                        me->SetTarget(ObjectGuid::Empty);

                        //Select random target for dark beam to start on
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                        {
                            //Face our target
                            DarkGlareAngle = me->GetAngle(target);
                            DarkGlareTickTimer = 1000;
                            DarkGlareTick = 0;
                            ClockWise = RAND(true, false);
                        }

                        //Add red coloration to C'thun
                        DoCast(me, SPELL_RED_COLORATION, true);

                        //Freeze animation
                        DoCast(me, SPELL_FREEZE_ANIM);
                        me->SetOrientation(DarkGlareAngle);
                        me->StopMoving();

                        //Darkbeam for 35 seconds
                        PhaseTimer = 35000;
                    } else PhaseTimer -= diff;

                    break;

                case PHASE_EYE_RED_BEAM:
                    if (DarkGlareTick < 35)
                    {
                        if (DarkGlareTickTimer <= diff)
                        {
                            //Set angle and cast
                            if (ClockWise)
                                me->SetOrientation(DarkGlareAngle + DarkGlareTick * float(M_PI) / 35);
                            else
                                me->SetOrientation(DarkGlareAngle - DarkGlareTick * float(M_PI) / 35);

                            me->StopMoving();

                            //Actual dark glare cast, maybe something missing here?
                            DoCast(me, SPELL_DARK_GLARE, false);

                            //Increase tick
                            ++DarkGlareTick;

                            //1 second per tick
                            DarkGlareTickTimer = 1000;
                        } else DarkGlareTickTimer -= diff;
                    }

                    //PhaseTimer
                    if (PhaseTimer <= diff)
                    {
                        //Switch to Eye Beam
                        instance->SetData(DATA_CTHUN_PHASE, PHASE_EYE_GREEN_BEAM);

                        BeamTimer = 3000;
                        ClawTentacleTimer = 12500;              //4 per Eye beam phase (unsure if they spawn during Dark beam)

                        me->InterruptNonMeleeSpells(false);

                        //Remove Red coloration from c'thun
                        me->RemoveAurasDueToSpell(SPELL_RED_COLORATION);
                        me->RemoveAurasDueToSpell(SPELL_FREEZE_ANIM);

                        //set it back to aggressive
                        me->SetReactState(REACT_AGGRESSIVE);

                        //Eye Beam for 50 seconds
                        PhaseTimer = 50000;
                    } else PhaseTimer -= diff;

                    break;

                //Transition phase
                case PHASE_CTHUN_TRANSITION:
                    //Remove any target
                    me->SetTarget(ObjectGuid::Empty);
                    me->SetHealth(0);
                    me->SetVisible(false);
                    break;

                //Dead phase
                case PHASE_CTHUN_DONE:
                    Creature* pPortal= me->FindNearestCreature(NPC_CTHUN_PORTAL, 10);
                    if (pPortal)
                        pPortal->DespawnOrUnsummon();

                    me->DespawnOrUnsummon();
                    break;
            }
        }
Example #16
0
        void UpdateAI(uint32 diff)
        {
            //Only if not incombat check if the event is started
            if (!me->IsInCombat() && instance && instance->GetData(DATA_KARATHRESSEVENT))
            {
                if (Unit* target = Unit::GetUnit(*me, instance->GetData64(DATA_KARATHRESSEVENT_STARTER)))
                    AttackStart(target);
            }

            //Return since we have no target
            if (!UpdateVictim())
                return;

            //someone evaded!
            if (instance && !instance->GetData(DATA_KARATHRESSEVENT))
            {
                EnterEvadeMode();
                return;
            }

            //LeechingThrow_Timer
            if (LeechingThrow_Timer <= diff)
            {
                DoCastVictim(SPELL_LEECHING_THROW);
                LeechingThrow_Timer = 20000;
            } else LeechingThrow_Timer -= diff;

            //Multishot_Timer
            if (Multishot_Timer <= diff)
            {
                DoCastVictim(SPELL_MULTISHOT);
                Multishot_Timer = 20000;
            } else Multishot_Timer -= diff;

            //TheBeastWithin_Timer
            if (TheBeastWithin_Timer <= diff)
            {
                DoCast(me, SPELL_THE_BEAST_WITHIN);
                Creature* Pet = Unit::GetCreature(*me, SummonedPet);
                if (Pet && Pet->IsAlive())
                {
                    Pet->CastSpell(Pet, SPELL_PET_ENRAGE, true);
                }
                TheBeastWithin_Timer = 30000;
            } else TheBeastWithin_Timer -= diff;

            //Pet_Timer
            if (Pet_Timer < diff && pet == false)
            {
                pet = true;
                //uint32 spell_id;
                uint32 pet_id;
                if (!urand(0, 1))
                {
                    //spell_id = SPELL_SUMMON_FATHOM_LURKER;
                    pet_id = CREATURE_FATHOM_LURKER;
                }
                else
                {
                    //spell_id = SPELL_SUMMON_FATHOM_SPOREBAT;
                    pet_id = CREATURE_FATHOM_SPOREBAT;
                }
                //DoCast(me, spell_id, true);
                if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                {
                    if (Creature* Pet = DoSpawnCreature(pet_id, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000))
                    {
                        Pet->AI()->AttackStart(target);
                        SummonedPet = Pet->GetGUID();
                    }
                }
            } else Pet_Timer -= diff;

            DoMeleeAttackIfReady();
        }
Example #17
0
        void UpdateAI(uint32 diff) override
        {
            //Check if we have a target
            if (!UpdateVictim())
            {
                //No target so we'll use this section to do our random wispers instance wide
                //WisperTimer
                if (WisperTimer <= diff)
                {
                    Map* map = me->GetMap();
                    if (!map->IsDungeon())
                        return;

                    //Play random sound to the zone
                    Map::PlayerList const &PlayerList = map->GetPlayers();

                    if (!PlayerList.isEmpty())
                    {
                        for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
                        {
                            if (Player* pPlr = itr->GetSource())
                                pPlr->PlayDirectSound(RANDOM_SOUND_WHISPER, pPlr);
                        }
                    }

                    //One random wisper every 90 - 300 seconds
                    WisperTimer = urand(90000, 300000);
                } else WisperTimer -= diff;

                return;
            }

            me->SetTarget(ObjectGuid::Empty);

            uint32 currentPhase = instance->GetData(DATA_CTHUN_PHASE);
            if (currentPhase == PHASE_CTHUN_STOMACH || currentPhase == PHASE_CTHUN_WEAK)
            {
                // EyeTentacleTimer
                if (EyeTentacleTimer <= diff)
                {
                    //Spawn the 8 Eye Tentacles in the corret spots
                    SpawnEyeTentacle(0, 20);                //south
                    SpawnEyeTentacle(10, 10);               //south west
                    SpawnEyeTentacle(20, 0);                //west
                    SpawnEyeTentacle(10, -10);              //north west

                    SpawnEyeTentacle(0, -20);               //north
                    SpawnEyeTentacle(-10, -10);             //north east
                    SpawnEyeTentacle(-20, 0);               // east
                    SpawnEyeTentacle(-10, 10);              // south east

                    EyeTentacleTimer = 30000; // every 30sec in phase 2
                } else EyeTentacleTimer -= diff;
            }

            switch (currentPhase)
            {
                //Transition phase
                case PHASE_CTHUN_TRANSITION:
                    //PhaseTimer
                    if (PhaseTimer <= diff)
                    {
                        //Switch
                        instance->SetData(DATA_CTHUN_PHASE, PHASE_CTHUN_STOMACH);

                        //Switch to c'thun model
                        me->InterruptNonMeleeSpells(false);
                        DoCast(me, SPELL_TRANSFORM, false);
                        me->SetFullHealth();

                        me->SetVisible(true);
                        me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);

                        //Emerging phase
                        //AttackStart(ObjectAccessor::GetUnit(*me, HoldpPlayer));
                        DoZoneInCombat();

                        //Place all units in threat list on outside of stomach
                        Stomach_Map.clear();

                        for (std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); i != me->getThreatManager().getThreatList().end(); ++i)
                            Stomach_Map[(*i)->getUnitGuid()] = false;   //Outside stomach

                        //Spawn 2 flesh tentacles
                        FleshTentaclesKilled = 0;

                        //Spawn flesh tentacle
                        for (uint8 i = 0; i < 2; i++)
                        {
                            Creature* spawned = me->SummonCreature(NPC_FLESH_TENTACLE, FleshTentaclePos[i], TEMPSUMMON_CORPSE_DESPAWN);
                            if (!spawned)
                                ++FleshTentaclesKilled;
                        }

                        PhaseTimer = 0;
                    } else PhaseTimer -= diff;

                    break;

                //Body Phase
                case PHASE_CTHUN_STOMACH:
                    //Remove Target field
                    me->SetTarget(ObjectGuid::Empty);

                    //Weaken
                    if (FleshTentaclesKilled > 1)
                    {
                        instance->SetData(DATA_CTHUN_PHASE, PHASE_CTHUN_WEAK);

                        Talk(EMOTE_WEAKENED);
                        PhaseTimer = 45000;

                        DoCast(me, SPELL_PURPLE_COLORATION, true);

                        std::unordered_map<ObjectGuid, bool>::iterator i = Stomach_Map.begin();

                        //Kick all players out of stomach
                        while (i != Stomach_Map.end())
                        {
                            //Check for valid player
                            Unit* unit = ObjectAccessor::GetUnit(*me, i->first);

                            //Only move units in stomach
                            if (unit && i->second == true)
                            {
                                //Teleport each player out
                                DoTeleportPlayer(unit, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ() + 10, float(rand32() % 6));

                                //Cast knockback on them
                                DoCast(unit, SPELL_EXIT_STOMACH_KNOCKBACK, true);

                                //Remove the acid debuff
                                unit->RemoveAurasDueToSpell(SPELL_DIGESTIVE_ACID);

                                i->second = false;
                            }
                            ++i;
                        }

                        return;
                    }

                    //Stomach acid
                    if (StomachAcidTimer <= diff)
                    {
                        //Apply aura to all players in stomach
                        std::unordered_map<ObjectGuid, bool>::iterator i = Stomach_Map.begin();

                        while (i != Stomach_Map.end())
                        {
                            //Check for valid player
                            Unit* unit = ObjectAccessor::GetUnit(*me, i->first);

                            //Only apply to units in stomach
                            if (unit && i->second == true)
                            {
                                //Cast digestive acid on them
                                DoCast(unit, SPELL_DIGESTIVE_ACID, true);

                                //Check if player should be kicked from stomach
                                if (unit->IsWithinDist3d(&KickPos, 15.0f))
                                {
                                    //Teleport each player out
                                    DoTeleportPlayer(unit, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ() + 10, float(rand32() % 6));

                                    //Cast knockback on them
                                    DoCast(unit, SPELL_EXIT_STOMACH_KNOCKBACK, true);

                                    //Remove the acid debuff
                                    unit->RemoveAurasDueToSpell(SPELL_DIGESTIVE_ACID);

                                    i->second = false;
                                }
                            }
                            ++i;
                        }

                        StomachAcidTimer = 4000;
                    } else StomachAcidTimer -= diff;

                    //Stomach Enter Timer
                    if (StomachEnterTimer <= diff)
                    {
                        if (Unit* target = SelectRandomNotStomach())
                        {
                            //Set target in stomach
                            Stomach_Map[target->GetGUID()] = true;
                            target->InterruptNonMeleeSpells(false);
                            target->CastSpell(target, SPELL_MOUTH_TENTACLE, true, NULL, NULL, me->GetGUID());
                            StomachEnterTarget = target->GetGUID();
                            StomachEnterVisTimer = 3800;
                        }

                        StomachEnterTimer = 13800;
                    } else StomachEnterTimer -= diff;

                    if (StomachEnterVisTimer && StomachEnterTarget)
                    {
                        if (StomachEnterVisTimer <= diff)
                        {
                            //Check for valid player
                            Unit* unit = ObjectAccessor::GetUnit(*me, StomachEnterTarget);

                            if (unit)
                            {
                                DoTeleportPlayer(unit, STOMACH_X, STOMACH_Y, STOMACH_Z, STOMACH_O);
                            }

                            StomachEnterTarget.Clear();
                            StomachEnterVisTimer = 0;
                        } else StomachEnterVisTimer -= diff;
                    }

                    //GientClawTentacleTimer
                    if (GiantClawTentacleTimer <= diff)
                    {
                        if (Unit* target = SelectRandomNotStomach())
                        {
                            //Spawn claw tentacle on the random target
                            if (Creature* spawned = me->SummonCreature(NPC_GIANT_CLAW_TENTACLE, *target, TEMPSUMMON_CORPSE_DESPAWN, 500))
                                if (spawned->AI())
                                    spawned->AI()->AttackStart(target);
                        }

                        //One giant claw tentacle every minute
                        GiantClawTentacleTimer = 60000;
                    } else GiantClawTentacleTimer -= diff;

                    //GiantEyeTentacleTimer
                    if (GiantEyeTentacleTimer <= diff)
                    {
                        if (Unit* target = SelectRandomNotStomach())
                        {
                            //Spawn claw tentacle on the random target
                            if (Creature* spawned = me->SummonCreature(NPC_GIANT_EYE_TENTACLE, *target, TEMPSUMMON_CORPSE_DESPAWN, 500))
                                if (spawned->AI())
                                    spawned->AI()->AttackStart(target);
                        }

                        //One giant eye tentacle every minute
                        GiantEyeTentacleTimer = 60000;
                    } else GiantEyeTentacleTimer -= diff;

                    break;

                //Weakened state
                case PHASE_CTHUN_WEAK:
                    //PhaseTimer
                    if (PhaseTimer <= diff)
                    {
                        //Switch
                        instance->SetData(DATA_CTHUN_PHASE, PHASE_CTHUN_STOMACH);

                        //Remove purple coloration
                        me->RemoveAurasDueToSpell(SPELL_PURPLE_COLORATION);

                        //Spawn 2 flesh tentacles
                        FleshTentaclesKilled = 0;

                        //Spawn flesh tentacle
                        for (uint8 i = 0; i < 2; i++)
                        {
                            Creature* spawned = me->SummonCreature(NPC_FLESH_TENTACLE, FleshTentaclePos[i], TEMPSUMMON_CORPSE_DESPAWN);
                            if (!spawned)
                                ++FleshTentaclesKilled;
                        }

                        PhaseTimer = 0;
                    } else PhaseTimer -= diff;

                    break;
            }
        }
Example #18
0
        void UpdateAI(uint32 diff)
        {
            //Only if not incombat check if the event is started
            if (!me->IsInCombat() && instance && instance->GetData(DATA_KARATHRESSEVENT))
            {
                if (Unit* target = Unit::GetUnit(*me, instance->GetData64(DATA_KARATHRESSEVENT_STARTER)))
                    AttackStart(target);
            }

            //Return since we have no target
            if (!UpdateVictim())
                return;

            //someone evaded!
            if (instance && !instance->GetData(DATA_KARATHRESSEVENT))
            {
                EnterEvadeMode();
                return;
            }

            if (!me->HasAura(SPELL_WINDFURY_WEAPON))
            {
                DoCast(me, SPELL_WINDFURY_WEAPON);
            }

            //FrostShock_Timer
            if (FrostShock_Timer <= diff)
            {
                DoCastVictim(SPELL_FROST_SHOCK);
                FrostShock_Timer = 25000+rand()%5000;
            } else FrostShock_Timer -= diff;

            //Spitfire_Timer
            if (Spitfire_Timer <= diff)
            {
                DoCast(me, SPELL_SPITFIRE_TOTEM);
                if (Unit* SpitfireTotem = Unit::GetUnit(*me, CREATURE_SPITFIRE_TOTEM))
                    SpitfireTotem->ToCreature()->AI()->AttackStart(me->GetVictim());

                Spitfire_Timer = 60000;
            }
            else
                Spitfire_Timer -= diff;

            //PoisonCleansing_Timer
            if (PoisonCleansing_Timer <= diff)
            {
                DoCast(me, SPELL_POISON_CLEANSING_TOTEM);
                PoisonCleansing_Timer = 30000;
            }
            else
                PoisonCleansing_Timer -= diff;

            //Earthbind_Timer
            if (Earthbind_Timer <= diff)
            {
                DoCast(me, SPELL_EARTHBIND_TOTEM);
                Earthbind_Timer = 45000;
            }
            else
                Earthbind_Timer -= diff;

            DoMeleeAttackIfReady();
        }
Example #19
0
            void UpdateAI (const uint32 diff)
            {
                if (!UpdateVictim())
                    return;

                //Shield_Timer
                if (Shield_Timer <= diff)
                {
                    DoCast(me, SPELL_SHIELD);
                    Shield_Timer = 61000;
                } else Shield_Timer -= diff;

                //BloodLust_Timer
                if (BloodLust_Timer <= diff)
                {
                    DoCast(me, SPELL_BLOODLUST);
                    BloodLust_Timer = 20000+rand()%8000;
                } else BloodLust_Timer -= diff;

                //Casting Greaterheal to Thekal or Zath if they are in meele range.
                if (GreaterHeal_Timer <= diff)
                {
                    if (m_pInstance)
                    {
                        Unit* pThekal = Unit::GetUnit((*me), m_pInstance->GetData64(DATA_THEKAL));
                        Unit* pZath = Unit::GetUnit((*me), m_pInstance->GetData64(DATA_ZATH));

                        if (!pThekal || !pZath)
                            return;

                        switch (urand(0, 1))
                        {
                            case 0:
                                if (me->IsWithinMeleeRange(pThekal))
                                    DoCast(pThekal, SPELL_GREATERHEAL);
                                break;
                            case 1:
                                if (me->IsWithinMeleeRange(pZath))
                                    DoCast(pZath, SPELL_GREATERHEAL);
                                break;
                        }
                    }

                    GreaterHeal_Timer = 15000+rand()%5000;
                } else GreaterHeal_Timer -= diff;

                //Disarm_Timer
                if (Disarm_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_DISARM);
                    Disarm_Timer = 15000+rand()%10000;
                } else Disarm_Timer -= diff;

                //Check_Timer for the death of LorKhan and Zath.
                if (!FakeDeath && Check_Timer <= diff)
                {
                    if (m_pInstance)
                    {
                        if (m_pInstance->GetData(DATA_THEKAL) == SPECIAL)
                        {
                            //Resurrect Thekal
                            if (Unit* pThekal = Unit::GetUnit((*me), m_pInstance->GetData64(DATA_THEKAL)))
                            {
                                pThekal->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
                                pThekal->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                pThekal->setFaction(14);
                                pThekal->SetFullHealth();
                            }
                        }

                        if (m_pInstance->GetData(DATA_ZATH) == SPECIAL)
                        {
                            //Resurrect Zath
                            if (Unit* pZath = Unit::GetUnit((*me), m_pInstance->GetData64(DATA_ZATH)))
                            {
                                pZath->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
                                pZath->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                pZath->setFaction(14);
                                pZath->SetFullHealth();
                            }
                        }
                    }

                    Check_Timer = 5000;
                } else Check_Timer -= diff;

                if (!HealthAbovePct(5))
                {
                    me->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE_PERCENT);
                    me->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE);
                    me->RemoveAurasByType(SPELL_AURA_PERIODIC_LEECH);
                    me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    me->SetStandState(UNIT_STAND_STATE_SLEEP);
                    me->setFaction(35);
                    me->AttackStop();

                    if (m_pInstance)
                        m_pInstance->SetData(DATA_LORKHAN, SPECIAL);

                    FakeDeath = true;
                }

                DoMeleeAttackIfReady();
            }
Example #20
0
        void UpdateAI(uint32 diff)
        {
            //Only if not incombat check if the event is started
            if (!me->IsInCombat() && instance && instance->GetData(DATA_KARATHRESSEVENT))
            {
                if (Unit* target = Unit::GetUnit(*me, instance->GetData64(DATA_KARATHRESSEVENT_STARTER)))
                    AttackStart(target);
            }

            //Return since we have no target
            if (!UpdateVictim())
                return;

            //someone evaded!
            if (instance && !instance->GetData(DATA_KARATHRESSEVENT))
            {
                EnterEvadeMode();
                return;
            }

            //WaterBoltVolley_Timer
            if (WaterBoltVolley_Timer <= diff)
            {
                DoCastVictim(SPELL_WATER_BOLT_VOLLEY);
                WaterBoltVolley_Timer = 30000;
            } else WaterBoltVolley_Timer -= diff;

            //TidalSurge_Timer
            if (TidalSurge_Timer <= diff)
            {
                DoCastVictim(SPELL_TIDAL_SURGE);
                // Hacky way to do it - won't trigger elseways
                me->GetVictim()->CastSpell(me->GetVictim(), SPELL_TIDAL_SURGE_FREEZE, true);
                TidalSurge_Timer = 15000+rand()%5000;
            } else TidalSurge_Timer -= diff;

            //Cyclone_Timer
            if (Cyclone_Timer <= diff)
            {
                //DoCast(me, SPELL_SUMMON_CYCLONE); // Doesn't work
                Cyclone_Timer = 30000+rand()%10000;

                if (Creature* Cyclone = me->SummonCreature(CREATURE_CYCLONE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), float(rand()%5), TEMPSUMMON_TIMED_DESPAWN, 15000))
                {
                    Cyclone->SetObjectScale(3.0f);
                    Cyclone->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    Cyclone->setFaction(me->getFaction());
                    Cyclone->CastSpell(Cyclone, SPELL_CYCLONE_CYCLONE, true);
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                        Cyclone->AI()->AttackStart(target);
                }
            }
            else
                Cyclone_Timer -= diff;

            //Heal_Timer
            if (Heal_Timer <= diff)
            {
                // It can be cast on any of the mobs
                Unit* unit = NULL;

                while (unit == NULL || !unit->IsAlive())
                    unit = selectAdvisorUnit();

                if (unit && unit->IsAlive())
                    DoCast(unit, SPELL_HEAL);
                Heal_Timer = 60000;
            }
            else
                Heal_Timer -= diff;

            DoMeleeAttackIfReady();
        }
Example #21
0
 void JustDied(Unit* /*killer*/)
 {
     if (me->isSummon()) //we are not a normal spawn.
         if (instance)
             instance->SetData(DATA_EVENT, instance->GetData(DATA_EVENT) + 1);
 }
Example #22
0
        void UpdateAI(const uint32 diff)
        {
            if (!pInstance)
                return;

            if (SpellCorrupt_Timer)
            {
                if (SpellCorrupt_Timer <= diff)
                {
                    pInstance->SetData(TYPE_MEDIVH,SPECIAL);

                    if (me->HasAura(SPELL_CORRUPT_AEONUS))
                        SpellCorrupt_Timer = 1000;
                    else if (me->HasAura(SPELL_CORRUPT))
                        SpellCorrupt_Timer = 3000;
                    else
                        SpellCorrupt_Timer = 0;
                } else SpellCorrupt_Timer -= diff;
            }

            if (Check_Timer)
            {
                if (Check_Timer <= diff)
                {
                    uint32 pct = pInstance->GetData(DATA_SHIELD);

                    Check_Timer = 5000;

                    if (Life25 && pct <= 25)
                    {
                        DoScriptText(SAY_WEAK25, me);
                        Life25 = false;
                    }
                    else if (Life50 && pct <= 50)
                    {
                        DoScriptText(SAY_WEAK50, me);
                        Life50 = false;
                    }
                    else if (Life75 && pct <= 75)
                    {
                        DoScriptText(SAY_WEAK75, me);
                        Life75 = false;
                    }

                    //if we reach this it means event was running but at some point reset.
                    if (pInstance->GetData(TYPE_MEDIVH) == NOT_STARTED)
                    {
                        me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                        me->RemoveCorpse();
                        me->Respawn();
                        return;
                    }

                    if (pInstance->GetData(TYPE_RIFT) == DONE)
                    {
                        DoScriptText(SAY_WIN, me);
                        Check_Timer = 0;

                        if (me->HasAura(SPELL_CHANNEL))
                            me->RemoveAura(SPELL_CHANNEL);

                        //TODO: start the post-event here
                        pInstance->SetData(TYPE_MEDIVH,DONE);
                    }
                } else Check_Timer -= diff;
            }

            //if (!UpdateVictim())
            //return;

            //DoMeleeAttackIfReady();
        }
Example #23
0
        void UpdateAI(const uint32 diff)
        {
            if(!pInstance) return;

            if(pInstance->GetData(TYPE_EVENT_NPC) == NPC_XERESTRASZA)
            {
                UpdateTimer = pInstance->GetData(TYPE_EVENT_TIMER);
                if(UpdateTimer <= diff)
                {
                    switch(pInstance->GetData(TYPE_EVENT))
                    {
// Xerestrasza intro
                        case 10:
                            UpdateTimer = 7000;
                            pInstance->SetData(TYPE_EVENT, 20);
                            break;
                        case 20:
                            DoScriptText(-1666000,me);
                            pInstance->SetData(TYPE_EVENT, 0);
                            break;
// Xerestrasza event
                        case 30:
                             DoScriptText(-1666001,me);
                             StartMovement(1, 40);
                             break;
                        case 40:
                             DoScriptText(-1666002,me);
                             StartMovement(2, 50);
                             break;
                        case 50:
                            DoScriptText(-1666003,me);
                            UpdateTimer = 12000;
                            pInstance->SetData(TYPE_EVENT, 60);
                            break;
                        case 60:
                            DoScriptText(-1666004,me);
                            UpdateTimer = 12000;
                            pInstance->SetData(TYPE_EVENT, 70);
                            break;
                        case 70:
                            DoScriptText(-1666005,me);
                            UpdateTimer = 10000;
                            pInstance->SetData(TYPE_EVENT, 80);
                            break;
                        case 80:
                            DoScriptText(-1666006,me);
                            UpdateTimer = 10000;
                            pInstance->SetData(TYPE_EVENT, 90);
                            break;
                        case 90:
                            DoScriptText(-1666007,me);
                            UpdateTimer = 10000;
                            pInstance->SetData(TYPE_EVENT, 100);
                            break;
                        case 100:
                            DoScriptText(-1666008,me);
                            UpdateTimer = 4000;
                            pInstance->SetData(TYPE_EVENT, 110);
                            break;
                        case 110:
                            UpdateTimer = 2000;
                            pInstance->SetData(TYPE_XERESTRASZA, DONE);
                            me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
                            me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                            {
                                Creature* pHalion = me->GetMap()->GetCreature(pInstance->GetData64(NPC_HALION_REAL));
                                if(pInstance->GetData(TYPE_HALION) != DONE)
                                {
                                    if(!pHalion)
                                        pHalion = me->SummonCreature(NPC_HALION_REAL, SpawnLocXer[3].x, SpawnLocXer[3].y, SpawnLocXer[3].z, 6.23f, TEMPSUMMON_MANUAL_DESPAWN, HOUR*IN_MILLISECONDS);
                                    if(pHalion && !pHalion->isAlive())
                                        pHalion->Respawn();
                                    if(pHalion)
                                        pHalion->SetCreatorGUID(0);
                                }
                            }
                            UpdateTimer = 4000;
                            pInstance->SetData(TYPE_EVENT, 210);
                            break;
                        case 210:
                            UpdateTimer = 2000;
                            pInstance->SetData(TYPE_EVENT, 0);
                            break;
                        default:
                            break;
                    }
                } else UpdateTimer -= diff;

                pInstance->SetData(TYPE_EVENT_TIMER, UpdateTimer);
            }
        }
 void JustDied(Unit* /*killer*/) override
 {
     instance->SetData(DATA_ARGENT_SOLDIER_DEFEATED, instance->GetData(DATA_ARGENT_SOLDIER_DEFEATED) + 1);
 }
Example #25
0
        void UpdateAI(const uint32 diff)
        {
            if (!me->isInCombat())
            {
                if (instance)
                {
                    // Do not let the raid skip straight to Archimonde. Visible and hostile ONLY if Azagalor is finished.
                    if ((instance->GetData(DATA_AZGALOREVENT) < DONE) && (me->IsVisible() || (me->getFaction() != 35)))
                    {
                        me->SetVisible(false);
                        me->setFaction(35);
                    }
                    else if ((instance->GetData(DATA_AZGALOREVENT) >= DONE) && (!me->IsVisible() || (me->getFaction() == 35)))
                    {
                        me->setFaction(1720);
                        me->SetVisible(true);
                    }
                }

                if (DrainNordrassilTimer <= diff)
                {
                    if (!IsChanneling)
                    {
                        Creature* temp = me->SummonCreature(CREATURE_CHANNEL_TARGET, NordrassilLoc, TEMPSUMMON_TIMED_DESPAWN, 1200000);

                        if (temp)
                            WorldTreeGUID = temp->GetGUID();

                        if (Unit* Nordrassil = Unit::GetUnit(*me, WorldTreeGUID))
                        {
                            Nordrassil->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                            Nordrassil->SetDisplayId(11686);
                            DoCast(Nordrassil, SPELL_DRAIN_WORLD_TREE);
                            IsChanneling = true;
                        }
                    }

                    if (Unit* Nordrassil = Unit::GetUnit(*me, WorldTreeGUID))
                    {
                        Nordrassil->CastSpell(me, SPELL_DRAIN_WORLD_TREE_2, true);
                        DrainNordrassilTimer = 1000;
                    }
                } else DrainNordrassilTimer -= diff;
            }

            if (!UpdateVictim())
                return;

            if (me->HealthBelowPct(10) && !BelowTenPercent && !Enraged)
                BelowTenPercent = true;

            if (!Enraged)
            {
                if (EnrageTimer <= diff)
                {
                    if (HealthAbovePct(10))
                    {
                        me->GetMotionMaster()->Clear(false);
                        me->GetMotionMaster()->MoveIdle();
                        Enraged = true;
                        Talk(SAY_ENRAGE);
                    }
                } else EnrageTimer -= diff;

                if (CheckDistanceTimer <= diff)
                {
                    // To simplify the check, we simply summon a Creature in the location and then check how far we are from the creature
                    Creature* Check = me->SummonCreature(CREATURE_CHANNEL_TARGET, NordrassilLoc, TEMPSUMMON_TIMED_DESPAWN, 2000);
                    if (Check)
                    {
                        Check->SetVisible(false);

                        if (me->IsWithinDistInMap(Check, 75))
                        {
                            me->GetMotionMaster()->Clear(false);
                            me->GetMotionMaster()->MoveIdle();
                            Enraged = true;
                            Talk(SAY_ENRAGE);
                        }
                    }
                    CheckDistanceTimer = 5000;
                } else CheckDistanceTimer -= diff;
            }

            if (BelowTenPercent)
            {
                if (!HasProtected)
                {
                    me->GetMotionMaster()->Clear(false);
                    me->GetMotionMaster()->MoveIdle();

                    //all members of raid must get this buff
                    DoCastVictim(SPELL_PROTECTION_OF_ELUNE, true);
                    HasProtected = true;
                    Enraged = true;
                }

                if (SummonWispTimer <= diff)
                {
                    DoSpawnCreature(CREATURE_ANCIENT_WISP, float(rand()%40), float(rand()%40), 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                    SummonWispTimer = 1500;
                    ++WispCount;
                } else SummonWispTimer -= diff;

                if (WispCount >= 30)
                    me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
            }

            if (Enraged)
            {
                if (HandOfDeathTimer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_HAND_OF_DEATH);
                    HandOfDeathTimer = 2000;
                } else HandOfDeathTimer -= diff;
                return;                                         // Don't do anything after this point.
            }

            if (SoulChargeCount)
            {
                if (SoulChargeTimer <= diff)
                    UnleashSoulCharge();
                else SoulChargeTimer -= diff;
            }

            if (GripOfTheLegionTimer <= diff)
            {
                DoCast(SelectTarget(SELECT_TARGET_RANDOM, 0), SPELL_GRIP_OF_THE_LEGION);
                GripOfTheLegionTimer = urand(5000, 25000);
            } else GripOfTheLegionTimer -= diff;

            if (AirBurstTimer <= diff)
            {
                Talk(SAY_AIR_BURST);
                DoCast(SelectTarget(SELECT_TARGET_RANDOM, 1), SPELL_AIR_BURST);//not on tank
                AirBurstTimer = urand(25000, 40000);
            } else AirBurstTimer -= diff;

            if (FearTimer <= diff)
            {
                DoCast(me->getVictim(), SPELL_FEAR);
                FearTimer = 42000;
            } else FearTimer -= diff;

            if (DoomfireTimer <= diff)
            {
                Talk(SAY_DOOMFIRE);
                Unit* temp = SelectTarget(SELECT_TARGET_RANDOM, 1);
                if (!temp)
                    temp = me->getVictim();

                //replace with spell cast 31903 once implicitTarget 73 implemented
                SummonDoomfire(temp);

                //supposedly three doomfire can be up at the same time
                DoomfireTimer = 20000;
            } else DoomfireTimer -= diff;

            if (MeleeRangeCheckTimer <= diff)
            {
                if (CanUseFingerOfDeath())
                {
                    DoCast(SelectTarget(SELECT_TARGET_RANDOM, 0), SPELL_FINGER_OF_DEATH);
                    MeleeRangeCheckTimer = 1000;
                }

                MeleeRangeCheckTimer = 5000;
            } else MeleeRangeCheckTimer -= diff;

            DoMeleeAttackIfReady();
        }
Example #26
0
 void JustDied(Unit* /*killer*/) override
 {
     instance->SetData(TYPE_FENRUS, instance->GetData(TYPE_FENRUS) + 1);
 }
 void JustDied(Unit* /*pKiller*/)
 {
     if (pInstance)
         pInstance->SetData(TYPE_FENRUS, pInstance->GetData(TYPE_FENRUS) + 1);
 }
Example #28
0
        void UpdateAI(const uint32 diff)
        {
            if (phase == PHASE_OUTRO)
            {
                if (!pInstance)
                    return;

                events.Update(diff);
                switch(events.ExecuteEvent())
                {
                    case EVENT_OUTRO_1:
                    {
                        DoScriptText(SAY_KRICK_OUTRO_1, me);
                        events.ScheduleEvent(EVENT_OUTRO_2, 14000);
                        break;
                    }
                    case EVENT_OUTRO_2:
                    {
                        Creature* pNpcDialog = me->GetCreature(*me, uiNpcOutroDialog);
                        if (pNpcDialog)
                        {
                            if (pInstance->GetData(DATA_TEAM_IN_INSTANCE) == TEAM_ALLIANCE)
                                DoScriptText(SAY_JAYNA_OUTRO_2, pNpcDialog);
                            else
                                DoScriptText(SAY_SYLVANAS_OUTRO_2, pNpcDialog);
                        }
                        events.ScheduleEvent(EVENT_OUTRO_3, 8500);
                        break;
                    }
                    case EVENT_OUTRO_3:
                        DoScriptText(SAY_KRICK_OUTRO_3, me);
                        events.ScheduleEvent(EVENT_OUTRO_4, 12000);
                        break;
                    case EVENT_OUTRO_4:
                    {
                        Creature* pNpcDialog = me->GetCreature(*me, uiNpcOutroDialog);
                        if (pNpcDialog)
                        {
                            if (pInstance->GetData(DATA_TEAM_IN_INSTANCE) == TEAM_ALLIANCE)
                                DoScriptText(SAY_JAYNA_OUTRO_4, pNpcDialog);
                            else
                                DoScriptText(SAY_SYLVANAS_OUTRO_4, pNpcDialog);
                        }
                        events.ScheduleEvent(EVENT_OUTRO_5, 8000);
                        break;
                    }
                    case EVENT_OUTRO_5:
                        DoScriptText(SAY_KRICK_OUTRO_5, me);
                        events.ScheduleEvent(EVENT_OUTRO_6, 4000);
                        break;
                    case EVENT_OUTRO_6:
                        // TODO spawn Tyrannus at some distance and MovePoint near-by (flying on rimefang)
                        // store uiTyrannus
                        // Adjust timer so tyrannus has time to come
                        uiTyrannus = (pInstance ? pInstance->GetData64(DATA_TYRANNUS) : 0);
                        events.ScheduleEvent(EVENT_OUTRO_7, 1);
                        break;
                    case EVENT_OUTRO_7:
                        if (Creature *pTyrannus = me->GetCreature(*me, uiTyrannus))
                            DoScriptText(SAY_TYRANNUS_OUTRO_7, pTyrannus);
                        events.ScheduleEvent(EVENT_OUTRO_8, 7000);
                        break;
                    case EVENT_OUTRO_8:
                        DoScriptText(SAY_KRICK_OUTRO_8, me);
                        // TODO: Tyrannus starts killing Krick.
                        // there shall be some visual spell effect
                        events.ScheduleEvent(EVENT_OUTRO_9, 6000);
                        break;
                    case EVENT_OUTRO_9:
                        // tyrannus kills krick
                        me->SetStandState(UNIT_STAND_STATE_DEAD);
                        me->SetHealth(0);

                        if (Creature *pTyrannus = me->GetCreature(*me, uiTyrannus))
                            DoScriptText(SAY_TYRANNUS_OUTRO_9, pTyrannus);

                        events.ScheduleEvent(EVENT_OUTRO_10, 12000);
                        break;
                    case EVENT_OUTRO_10:
                    {
                        Creature* pNpcDialog = me->GetCreature(*me, uiNpcOutroDialog);
                        if (pNpcDialog)
                        {
                            if (pInstance->GetData(DATA_TEAM_IN_INSTANCE) == TEAM_ALLIANCE)
                                DoScriptText(SAY_JAYNA_OUTRO_10, pNpcDialog);
                            else
                                DoScriptText(SAY_SYLVANAS_OUTRO_10, pNpcDialog);
                        }

                        // End of OUTRO. for now...
                        events.ScheduleEvent(EVENT_OUTRO_END, 8000);
                        break;
                    }
                    case EVENT_OUTRO_END:
                    {
                        Creature* pNpcDialog = me->GetCreature(*me, uiNpcOutroDialog);
                        if (pNpcDialog)
                            pNpcDialog->DisappearAndDie();

                        me->DisappearAndDie();
                        break;
                    }
                }
                return;
            }
        }
Example #29
0
        void Reset() override
        {
            Initialize();

            m_uiEventId = instance->GetData(DATA_OPERA_PERFORMANCE);
        }
Example #30
0
        void UpdateAI(const uint32 diff)
        {
            if (!UpdateVictim())
                return;

            if (pInstance && !pInstance->GetData(TYPE_MOROES))
            {
                EnterEvadeMode();
                return;
            }

            if (!Enrage && HealthBelowPct(30))
            {
                DoCast(me, SPELL_FRENZY);
                Enrage = true;
            }

            if (CheckAdds_Timer <= diff)
            {
                for (uint8 i = 0; i < 4; ++i)
                {
                    Creature* Temp = NULL;
                    if (AddGUID[i])
                    {
                        Temp = Unit::GetCreature((*me), AddGUID[i]);
                        if (Temp && Temp->isAlive())
                            if (!Temp->getVictim())
                                Temp->AI()->AttackStart(me->getVictim());
                    }
                }
                CheckAdds_Timer = 5000;
            } else CheckAdds_Timer -= diff;

            if (!Enrage)
            {
                //Cast Vanish, then Garrote random victim
                if (Vanish_Timer <= diff)
                {
                    DoCast(me, SPELL_VANISH);
                    InVanish = true;
                    Vanish_Timer = 30000;
                    Wait_Timer = 5000;
                } else Vanish_Timer -= diff;

                if (Gouge_Timer <= diff)
                {
                    DoCastVictim(SPELL_GOUGE);
                    Gouge_Timer = 40000;
                } else Gouge_Timer -= diff;

                if (Blind_Timer <= diff)
                {
                    std::list<Unit*> pTargets;
                    SelectTargetList(pTargets, 5, SELECT_TARGET_RANDOM, me->GetMeleeReach()*5, true);
                    for (std::list<Unit*>::const_iterator i = pTargets.begin(); i != pTargets.end(); ++i)
                        if (!me->IsWithinMeleeRange(*i))
                        {
                            DoCast(*i, SPELL_BLIND);
                            break;
                        }
                    Blind_Timer = 40000;
                } else Blind_Timer -= diff;
            }

            if (InVanish)
            {
                if (Wait_Timer <= diff)
                {
                    DoScriptText(RAND(SAY_SPECIAL_1, SAY_SPECIAL_2), me);

                    if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                        pTarget->CastSpell(pTarget, SPELL_GARROTE, true);

                    InVanish = false;
                } else Wait_Timer -= diff;
            }

            if (!InVanish)
                DoMeleeAttackIfReady();
        }