void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
        {
            if (me->HealthBelowPctDamaged(5, uiDamage))
            {
                if (lifei)
                {
                    lifei->UnSummon();
                    lifei = NULL;
                }

                uiDamage = 0;
                me->MonsterSay("I can't meditate!", LANG_UNIVERSAL, 0);
                me->SetFullHealth();
                me->SetReactState(REACT_DEFENSIVE);

                std::list<Creature*> unitlist;
                GetCreatureListWithEntryInGrid(unitlist, me, 59637, 50.0f);
                for (auto creature: unitlist)
                    me->Kill(creature);

                events.ScheduleEvent(EVENT_START, 20000);
                events.CancelEvent(EVENT_SPAWN_MOBS);
                events.CancelEvent(EVENT_PROGRESS);
                events.CancelEvent(EVENT_END);
            }
        }
Example #2
0
    void UpdateAI(const uint32 diff)
    {
        if (Phase != INTRO)
            return;

        if (uiIntroTimer <= diff)
        {
            if (!pArthas)
                return;

            switch (uiIntroPhase)
            {
                case 0:
                    DoScriptText(SAY_DIALOG_WITH_ARTHAS_1, m_creature);
                    ++uiIntroPhase;
                    uiIntroTimer = 3500;
                    break;
                case 1:
                    DoScriptText(SAY_DIALOG_OF_ARTHAS_1, pArthas);
                    ++uiIntroPhase;
                    uiIntroTimer = 3500;
                    break;
                case 2:
                    DoScriptText(SAY_DIALOG_WITH_ARTHAS_2, m_creature);
                    ++uiIntroPhase;
                    uiIntroTimer = 3500;
                    break;
                case 3:
                    DoScriptText(SAY_DIALOG_OF_ARTHAS_2, pArthas);
                    ++uiIntroPhase;
                    uiIntroTimer = 3500;
                    break;
                case 4:
                    DoScriptText(SAY_DIALOG_WITH_ARTHAS_3, m_creature);
                    DoCast(m_creature, SPELL_SVALA_TRANSFORMING1);
                    ++uiIntroPhase;
                    uiIntroTimer = 2800;
                    break;
                case 5:
                    DoCast(m_creature, SPELL_SVALA_TRANSFORMING2);
                    ++uiIntroPhase;
                    uiIntroTimer = 200;
                    break;
                case 6:
                    if (Creature* pSvalaSorrowgrave = m_creature->SummonCreature(CREATURE_SVALA_SORROWGRAVE, 296.632, -346.075, 90.6307, 1.58, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000))
                    {
                        m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE);
                        m_creature->SetDisplayId(DATA_SVALA_DISPLAY_ID);
                        pArthas->UnSummon();
                        pArthas = NULL;
                        Phase = FINISHED;
                    }
                    else 
                        Reset();
                    break;
            }
        } else uiIntroTimer -= diff;
    }
        void UpdateAI(uint32 diff) override
        {
            events.Update(diff);
            while (uint32 eventId = events.ExecuteEvent())
            {
                switch(eventId)
                {
                case EVENT_START: //Begin script if playersInvolved is not empty
                {
                    updatePlayerList();
                    if (playersInvolved.empty())
                        events.ScheduleEvent(1, 600);
                    else
                    {
                        me->MonsterSay("Keep those creatures at bay while I meditate. We'll soon have the answers we seek...", LANG_UNIVERSAL, 0);
                        me->SetReactState(REACT_PASSIVE);
                        timer = 0;
                        events.ScheduleEvent(EVENT_SPAWN_MOBS, 5000); //spawn mobs
                        events.ScheduleEvent(EVENT_PROGRESS, 1000); //update time
                        events.ScheduleEvent(EVENT_END, 90000); //end quest
                    }
                    break;
                }
                case EVENT_SPAWN_MOBS: //Spawn 3 mobs
                {
                    updatePlayerList();
                    for(int i = 0; i < std::max((int)playersInvolved.size()*3,3); i++)
                    {
                        if (TempSummon* temp = me->SummonCreature(59637, 1144.55f, 3435.65f, 104.97f, 3.3f,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000))
                        {
                            if (temp->AI())
                                temp->AI()->AttackStart(me);

                            temp->AddThreat(me, 250.0f);
                            temp->GetMotionMaster()->Clear();
                            temp->GetMotionMaster()->MoveChase(me);
                        }
                    }
                    events.ScheduleEvent(EVENT_SPAWN_MOBS, 20000); //spawn mobs
                    break;
                }
                case EVENT_PROGRESS: //update energy
                {
                    timer++;

                    if (timer == 25 && !lifei)
                    {
                        if (lifei = me->SummonCreature(54856, 1130.162231f, 3435.905518f, 105.496597f, 0.0f,TEMPSUMMON_MANUAL_DESPAWN))
                            lifei->MonsterSay("The way of the Tushui... enlightenment through patience and mediation... the principled life", LANG_UNIVERSAL, 0);
                    }

                    if (timer == 30)
                        if (lifei)
                            lifei->MonsterSay("It is good to see you again, Aysa. You've come with respect, and so I shall give you the answers you seek.", LANG_UNIVERSAL, 0);

                    if (timer == 42)
                        if (lifei)
                            lifei->MonsterSay("Huo, the spirit of fire, is known for his hunger. He wants for tinder to eat. He needs the caress of the wind to rouse him.", LANG_UNIVERSAL, 0);

                    if (timer == 54)
                        if (lifei)
                            lifei->MonsterSay("If you find these things and bring them to his cave, on the far side of Wu-Song Village, you will face a challenge within.", LANG_UNIVERSAL, 0);

                    if (timer == 66)
                        if (lifei)
                            lifei->MonsterSay("Overcome that challenge, and you shall be graced by Huo's presence. Rekindle his flame, and if your spirit is pure, he shall follow you.", LANG_UNIVERSAL, 0);

                    if (timer == 78)
                        if (lifei)
                            lifei->MonsterSay("Go, children. We shall meet again very soon.", LANG_UNIVERSAL, 0);

                    if (timer == 85)
                    {
                        if (lifei)
                            lifei->UnSummon();

                        lifei = NULL;
                    }

                    updatePlayerList();
                    for (auto player: playersInvolved)
                    {
                        if (!player->HasAura(116421))
                            player->CastSpell(player, 116421);

                        player->ModifyPower(POWER_ALTERNATE_POWER, timer/25);
                        player->SetMaxPower(POWER_ALTERNATE_POWER, 90);
                    }

                    events.ScheduleEvent(EVENT_PROGRESS, 1000);
                    break;
                }
                case EVENT_END: //script end
                {
                    if (lifei)
                    {
                        lifei->UnSummon();
                        lifei = NULL;
                    }
                    events.ScheduleEvent(EVENT_START, 10000);
                    events.CancelEvent(EVENT_SPAWN_MOBS);
                    events.CancelEvent(EVENT_PROGRESS);
                    me->MonsterSay("And so our path lays before us. Speak to Master Shang Xi, he will tell you what comes next.", LANG_UNIVERSAL, 0);
                    updatePlayerList();
                    me->SetReactState(REACT_DEFENSIVE);
                    for(auto player: playersInvolved)
                    {
                        player->KilledMonsterCredit(54856, 0);
                        player->RemoveAura(116421);
                    }
                    break;
                }
                }
            }
        }