void UpdateAI(const uint32 diff)
        {
            //Return since we have no target
            if (!UpdateVictim())
                return;

            //Earthquake_Timer
            if (Earthquake_Timer <= diff)
            {
                if (!Earthquake)
                {
                    DoCast(me->getVictim(), SPELL_EARTHQUAKE);
                    Earthquake = true;
                    Earthquake_Timer = 10000;
                }
                else
                {
                    DoScriptText(RAND(SAY_SUMMON1, SAY_SUMMON2), me);

                    for (uint8 i = 0; i < 10; ++i)
                    {
                        Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0);
                        Creature* Murloc = me->SummonCreature(NPC_TIDEWALKER_LURKER, MurlocCords[i][0], MurlocCords[i][1], MurlocCords[i][2], MurlocCords[i][3], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                        if (pTarget && Murloc)
                            Murloc->AI()->AttackStart(pTarget);
                    }
                    DoScriptText(EMOTE_EARTHQUAKE, me);
                    Earthquake = false;
                    Earthquake_Timer = 40000+rand()%5000;
                }
            } else Earthquake_Timer -= diff;

            //TidalWave_Timer
            if (TidalWave_Timer <= diff)
            {
                DoCast(me->getVictim(), SPELL_TIDAL_WAVE);
                TidalWave_Timer = 20000;
            } else TidalWave_Timer -= diff;

            if (!Phase2)
            {
                //WateryGrave_Timer
                if (WateryGrave_Timer <= diff)
                {
                    //Teleport 4 players under the waterfalls
                    Unit *pTarget;
                    std::set<uint64> list;
                    std::set<uint64>::const_iterator itr;
                    for (uint8 i = 0; i < 4; ++i)
                    {
                        counter = 0;
                        do
                        {
                            pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 50, true);    //target players only
                            if (counter < Playercount)
                                break;
                            if (pTarget)
                                itr = list.find(pTarget->GetGUID());
                            ++counter;
                        } while (itr != list.end());

                        if (pTarget)
                        {
                            list.insert(pTarget->GetGUID());
                            ApplyWateryGrave(pTarget, i);
                        }
                    }

                    DoScriptText(RAND(SAY_SUMMON_BUBL1, SAY_SUMMON_BUBL2), me);

                    DoScriptText(EMOTE_WATERY_GRAVE, me);
                    WateryGrave_Timer = 30000;
                } else WateryGrave_Timer -= diff;

                //Start Phase2
                if (HealthBelowPct(25))
                    Phase2 = true;
            }
            else
            {
                //WateryGlobules_Timer
                if (WateryGlobules_Timer <= diff)
                {
                    Unit* pGlobuleTarget;
                    std::set<uint64> globulelist;
                    std::set<uint64>::const_iterator itr;
                    for (uint8 g = 0; g < 4; g++)  //one unit can't cast more than one spell per update, so some players have to cast for us XD
                    {
                        counter = 0;
                        do
                        {
                            pGlobuleTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 50, true);
                            if (pGlobuleTarget)
                                itr = globulelist.find(pGlobuleTarget->GetGUID());
                            if (counter > Playercount)
                                break;
                            ++counter;
                        } while (itr != globulelist.end());
                        if (pGlobuleTarget)
                        {
                            globulelist.insert(pGlobuleTarget->GetGUID());
                            pGlobuleTarget->CastSpell(pGlobuleTarget, globulespell[g], true);
                        }
                    }
                    DoScriptText(EMOTE_WATERY_GLOBULES, me);
                    WateryGlobules_Timer = 25000;
                } else WateryGlobules_Timer -= diff;
            }

            DoMeleeAttackIfReady();
        }
Пример #2
0
    void UpdateAI(const uint32 diff)
    {
        //Return since we have no target
        if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() )
            return;

        //Earthquake_Timer
        if(Earthquake_Timer < diff)
        {
            if(!Earthquake)
            {
                DoCast(m_creature->getVictim(), SPELL_EARTHQUAKE);
                Earthquake = true;
                Earthquake_Timer = 10000;
            }
            else
            {
                switch(rand()%2)
                {
                    case 0:
                    DoPlaySoundToSet(m_creature, SOUND_SUMMON1);
                    DoYell(SAY_SUMMON1, LANG_UNIVERSAL, NULL);
                    break;

                    case 1:
                    DoPlaySoundToSet(m_creature, SOUND_SUMMON2);
                    DoYell(SAY_SUMMON2, LANG_UNIVERSAL, NULL);
                    break;
                }

                //north
                SummonMurloc(486.10, -723.64, -7.14);
                SummonMurloc(482.58, -723.78, -7.14);
                SummonMurloc(479.38, -723.91, -7.14);
                SummonMurloc(476.03, -723.86, -7.14);
                SummonMurloc(472.69, -723.69, -7.14);
                SummonMurloc(469.04, -723.63, -7.14);

                //south
                SummonMurloc(311.63, -725.04, -13.15);
                SummonMurloc(307.81, -725.34, -13.15);
                SummonMurloc(303.91, -725.64, -13.06);
                SummonMurloc(300.23, -726, -11.89);
                SummonMurloc(296.82, -726.33, -10.82);
                SummonMurloc(293.64, -726.64, -9.81);

                DoTextEmote(EMOTE_EARTHQUAKE, NULL);

                Earthquake = false;
                Earthquake_Timer = 40000+rand()%5000;
            }
        }else Earthquake_Timer -= diff;

        //TidalWave_Timer
        if(TidalWave_Timer < diff)
        {
            DoCast(m_creature->getVictim(), SPELL_TIDAL_WAVE);
            TidalWave_Timer = 20000;
        }else TidalWave_Timer -= diff;

        if(!Phase2)
        {
            //WateryGrave_Timer
            if(WateryGrave_Timer < diff)
            {
                //Teleport 4 players under the waterfalls
                Unit *target;
                for(uint8 i = 0; i < 4; i++)
                {
                    target = SelectUnit(SELECT_TARGET_RANDOM, 1);
                    if(target && (target->GetTypeId() == TYPEID_PLAYER) && !target->HasAura(SPELL_WATERY_GRAVE, 0) && target->IsWithinDistInMap(m_creature, 50))
                        ApplyWateryGrave(target, i);
                }

                switch(rand()%2)
                {
                case 0:
                    DoPlaySoundToSet(m_creature, SOUND_SUMMON_BUBL1);
                    DoYell(SAY_SUMMON_BUBL1, LANG_UNIVERSAL, NULL);
                    break;

                case 1:
                    DoPlaySoundToSet(m_creature, SOUND_SUMMON_BUBL2);
                    DoYell(SAY_SUMMON_BUBL2, LANG_UNIVERSAL, NULL);
                    break;

                case 2:
                    break;
                }

                DoTextEmote(EMOTE_WATERY_GRAVE, NULL);

                WateryGrave_Timer = 30000;
            }else WateryGrave_Timer -= diff;

            //Start Phase2
            if((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 25)
                Phase2 = true;
        }
        else
        {
            //WateryGlobules_Timer
            if(WateryGlobules_Timer < diff)
            {
                SummonWaterGlobule(WATERY_GRAVE_X1, WATERY_GRAVE_Y1, WATERY_GRAVE_Z1);
                SummonWaterGlobule(WATERY_GRAVE_X2, WATERY_GRAVE_Y2, WATERY_GRAVE_Z2);
                SummonWaterGlobule(WATERY_GRAVE_X3, WATERY_GRAVE_Y3, WATERY_GRAVE_Z3);
                SummonWaterGlobule(WATERY_GRAVE_X4, WATERY_GRAVE_Y4, WATERY_GRAVE_Z4);

                DoTextEmote(EMOTE_WATERY_GLOBULES, NULL);

                WateryGlobules_Timer = 25000;
            }else WateryGlobules_Timer -= diff;
        }

        DoMeleeAttackIfReady();
    }