void JustReachedHome()
            {
                if (!me->isInCombat())
                {
                    for (int i = 0; i < 2; ++i)
                        if (Creature* totem = ObjectAccessor::GetCreature(*me, TotemGUID[i]))
                            totem->CastSpell(me, TotemSpell[i], false);
                }
                else
                {
                    for (SummonList::iterator itr = AcridTears.begin(); itr != AcridTears.end(); ++itr)
                    {
                        if (Creature* acrid = ObjectAccessor::GetCreature(*me, *itr))
                        {
                            acrid->CastSpell(acrid, 96634, false);
                            acrid->RemoveAllAuras();
                            acrid->DespawnOrUnsummon(2000);
                        }
                    }

                    Talk(SAY_BLOODVENOM);
                    Talk(EMOTE_BLOODVENOM);
                    me->CastSpell((Unit*)NULL, 96842, false);
                    events.ScheduleEvent(EVENT_VENOM_WITHDRAWAL, 15000);
                    events.ScheduleEvent(EVENT_SET_BLOODVENOM_PLAYER, 4000);
                }
            }
		bool CheckPhaseMinions()
		{
			summons.RemoveNotExisting();
			if (summons.empty())
			{
				ResetPlayersPhaseMask();
                return true;
			}

			uint16 phase = 1;
			for (std::list<uint64>::iterator itr = summons.begin(); itr != summons.end(); ++itr)
			{
				if (Creature *summon = ObjectAccessor::GetCreature(*me, *itr))
					phase |= summon->GetPhaseMask();
			}

			Map::PlayerList const &players = me->GetMap()->GetPlayers();
            for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
            {
                if (Player* pPlayer = i->GetSource())
					if ((pPlayer->GetPhaseMask() & phase) == 0)
						pPlayer->RemoveAurasDueToSpell(GetSpellForPhaseMask(pPlayer->GetPhaseMask()));
            }

			return false;
		}
        void SummonedCreatureDespawn(Creature* summon) override
        {
            uint32 nextPhase = 0;
            Summons.Despawn(summon);

            // Check if all summons in this phase killed
            for (SummonList::const_iterator iter = Summons.begin(); iter != Summons.end(); ++iter)
            {
                if (Creature* visage = ObjectAccessor::GetCreature(*me, *iter))
                {
                    // Not all are dead
                    if (visage->IsInPhase(summon))
                        return;
                    else
                    {
                        nextPhase = *visage->GetPhases().begin();
                        break;
                    }
                }
            }

            // Roll Insanity
            Map::PlayerList const& players = me->GetMap()->GetPlayers();
            for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
            {
                if (Player* player = i->GetSource())
                {
                    for (uint32 index = 0; index <= 4; ++index)
                        player->RemoveAurasDueToSpell(SPELL_INSANITY_TARGET + index);
                    player->CastSpell(player, SPELL_INSANITY_TARGET + nextPhase - 173, true);
                }
            }
        }
		void JustSummoned(Creature* summon)
		{
			for (SummonList::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
				if (*itr == summon->GetGUID())
					return;
			summons.Summon(summon);
		}
            void scheduleThirdPhase()
            {
                if (!me->isInCombat())
                {
                    for (int i = 0; i < 2; ++i)
                        if (Creature* totem = ObjectAccessor::GetCreature(*me, TotemGUID[i]))
                            totem->CastSpell(me, TotemSpell[i], false);
                }
                else
                {
                    for (SummonList::iterator itr = AcridTears.begin(); itr != AcridTears.end(); ++itr)
                    {
                        if (Creature* acrid = ObjectAccessor::GetCreature(*me, *itr))
                        {
                            acrid->CastSpell(acrid, SPELL_VENOXIS_ULT_COSMETIC, false);
                            acrid->RemoveAllAuras();
                            acrid->DespawnOrUnsummon(2000);
                        }
                    }

                    Talk(SAY_BLOODVENOM);
                    Talk(EMOTE_BLOODVENOM);
                    me->CastSpell((Unit*)NULL, SPELL_BLOODVENOM_TRIGGERED, false);
                    events.ScheduleEvent(EVENT_VENOM_WITHDRAWAL, 15000);
					events.ScheduleEvent(EVENT_VENOMOUS_EFFUSION, 1000);
                    events.ScheduleEvent(EVENT_SET_BLOODVENOM_PLAYER, 4000);
                }
            }
        void MovementInform(uint32 type, uint32 id)
        {
            if (type != ESCORT_MOTION_TYPE)
                return;

            // Xinef: we can rely here on internal counting
            if (id == 1)
            {
                me->SummonCreature(NPC_DURNHOLDE_MAGE, 2038.549f, 273.303f, 63.420f, 5.30f, TEMPSUMMON_MANUAL_DESPAWN);
                me->SummonCreature(NPC_DURNHOLDE_VETERAN, 2032.810f, 269.416f, 63.561f, 5.30f, TEMPSUMMON_MANUAL_DESPAWN);
            }
            else if (id == 2)
            {
                me->SummonCreature(NPC_SKARLOC_MOUNT, 2049.12f, 252.31f, 62.855f, me->GetOrientation(), TEMPSUMMON_MANUAL_DESPAWN);
                me->Dismount();
                me->SetWalk(true);
                for (SummonList::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
                    if (Creature* summon = ObjectAccessor::GetCreature(*me, *itr))
                        summon->SetWalk(true);
            }

            if (me->movespline->Finalized())
            {
                events2.ScheduleEvent(EVENT_INITIAL_TALK, 500);
                events2.ScheduleEvent(EVENT_START_FIGHT, 8000);
            }
        }
		void EnterCombat(Unit* /*who*/)
		{
			me->setActive(true);
			events.Reset();
			events.RescheduleEvent(EVENT_ENRAGE, 600000);
			events.RescheduleEvent(EVENT_SPELL_FREEZING_SLASH, urand(7000,15000));
			events.RescheduleEvent(EVENT_SPELL_PENETRATING_COLD, urand(15000,20000));
			events.RescheduleEvent(EVENT_SUMMON_NERUBIAN, urand(5000,8000));
			events.RescheduleEvent(EVENT_SUBMERGE, SUBMERGE_INTERVAL);
			if( !IsHeroic() )
				events.RescheduleEvent(EVENT_RESPAWN_SPHERE, 4000);

			for( std::list<uint64>::iterator itr = summons.begin(); itr != summons.end(); ++itr )
				if( Creature* c = pInstance->instance->GetCreature(*itr) )
				{
					c->GetMotionMaster()->MoveIdle();
					c->StopMoving();
					c->CastSpell(c, SPELL_SUBMERGE, false);
					c->AI()->DoAction(1);
				}
			summons.clear();
			for( uint8 i=0; i<4; ++i )
				if( Creature* c = me->SummonCreature(NPC_BURROW, AnubLocs[i+1]) )
					BurrowGUID[i] = c->GetGUID();
			for( uint8 i=0; i<6; ++i )
				if( Creature* c = me->SummonCreature(NPC_FROST_SPHERE, AnubLocs[i+5]) )
					SphereGUID[i] = c->GetGUID();

			Talk(SAY_AGGRO);
			DoZoneInCombat();
			if( pInstance )
				pInstance->SetData(TYPE_ANUBARAK, IN_PROGRESS);
		}
        void ExplodeAliveGhouls()
        {
            if (summons.empty())
                return;

            for (SummonList::iterator itr = summons.begin(); itr != summons.end(); ++itr)
                if (Creature* ghoul = me->GetCreature(*me, *itr))
                    ghoul->CastSpell(ghoul, SPELL_EXPLODE);
        }
        void UpdateAI(uint32 diff)
        {
            events2.Update(diff);
            switch (events2.ExecuteEvent())
            {
            case EVENT_INITIAL_TALK:
                Talk(SAY_ENTER);
                break;
            case EVENT_START_FIGHT:
                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC|UNIT_FLAG_IMMUNE_TO_NPC);
                me->SetInCombatWithZone();
                for (SummonList::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
                    if (Creature* summon = ObjectAccessor::GetCreature(*me, *itr))
                        if (summon->GetEntry() != NPC_SKARLOC_MOUNT)
                        {
                            summon->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC|UNIT_FLAG_IMMUNE_TO_NPC);
                            summon->SetInCombatWithZone();
                        }
                break;
            }

            if (!UpdateVictim())
                return;

            events.Update(diff);
            if (me->HasUnitState(UNIT_STATE_CASTING))
                return;

            switch (events.ExecuteEvent())
            {
            case EVENT_SPELL_HOLY_LIGHT:
                me->CastSpell(me, SPELL_HOLY_LIGHT, false);
                events.ScheduleEvent(EVENT_SPELL_HOLY_LIGHT, 20000);
                break;
            case EVENT_SPELL_CLEANSE:
                if (roll_chance_i(33))
                    Talk(SAY_TAUNT);
                me->CastSpell(me, SPELL_CLEANSE, false);
                events.ScheduleEvent(EVENT_SPELL_CLEANSE, 10000);
                break;
            case EVENT_SPELL_HAMMER:
                me->CastSpell(me->GetVictim(), SPELL_HAMMER_OF_JUSTICE, false);
                events.ScheduleEvent(EVENT_SPELL_HAMMER, 30000);
                break;
            case EVENT_SPELL_HOLY_SHIELD:
                me->CastSpell(me, SPELL_CLEANSE, false);
                events.ScheduleEvent(SPELL_HOLY_SHIELD, 30000);
                break;
            case EVENT_SPELL_CONSECRATION:
                me->CastSpell(me, SPELL_CONSECRATION, false);
                events.ScheduleEvent(EVENT_SPELL_CONSECRATION, 20000);
                break;

            }

            DoMeleeAttackIfReady();
        }
        void DoAction(int32 action)
        {
            if (action == ACTION_REPENTANCE_DONE)
            {
                lSummons.DespawnEntry(NPC_SOUL_FRAGMENT);

                for (SummonList::const_iterator itr = lSummons.begin(); itr != lSummons.end(); ++itr)
					if (Creature* pSummon = ObjectAccessor::GetCreature(*me, (*itr)))
                        if (pSummon->GetEntry() == NPC_REPENTANCE_MIRROR && pSummon->IsAIEnabled)
                            pSummon->AI()->DoAction(ACTION_REPENTANCE_DONE);
                    
                events.ScheduleEvent(EVENT_REPENTANCE, 1500, 0, PHASE_REPENTANCE);
            }
        }
        void SendLavaWaves(bool start)
        {
            Unit* cr = NULL;
            for (SummonList::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
            {
                cr = ObjectAccessor::GetUnit(*me, *itr);
                if (!cr || cr->GetEntry() != NPC_FLAME_TSUNAMI)
                    continue;

                if (start)
                    cr->GetMotionMaster()->MovePoint(0, ((cr->GetPositionX() < 3250.0f) ? 3283.44f : 3208.44f), cr->GetPositionY(), cr->GetPositionZ());
                else
                    cr->SetObjectScale(0.1f);
            }
        }
            void SetBloodvenomTarget()
            {
                ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList();
                ThreatContainer::StorageType::const_iterator hostileReference = threatList.begin();
                SummonList::const_iterator bloodvenomGUID = BloodVenoms.begin();

                while (bloodvenomGUID != BloodVenoms.end() && hostileReference != threatList.end())
                {
                    if (Creature* bloodvenom = ObjectAccessor::GetCreature(*me, *bloodvenomGUID))
                        bloodvenom->AI()->SetGUID((*hostileReference)->getUnitGuid());

                    ++hostileReference;
                    ++bloodvenomGUID;
                }
            }
Exemple #13
0
            void UpdateAI(uint32 diff)
            {
                if (!UpdateVictim())
                    return;

                events.Update(diff);
                if (me->HasUnitState(UNIT_STATE_CASTING))
                    return;

                switch (events.GetEvent())
                {
					case EVENT_FREEZING_GROUND:
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1))
							me->CastSpell(target, SPELL_FREEZING_GROUND, false);
                        events.RepeatEvent(20000);
                        break;
                    case EVENT_FROZEN_ORB_STALKER:
                        me->CastCustomSpell(SPELL_FROZEN_ORB, SPELLVALUE_MAX_TARGETS, RAID_MODE(1, 3), me, false);
                        events.RepeatEvent(35000);
						events.ScheduleEvent(EVENT_CHECK_SUMMONS, 10000);
                        break;
					case EVENT_CHECK_SUMMONS:
						for (SummonList::iterator i = summons.begin(); i != summons.end();)
						{
							if (Creature* cr = ObjectAccessor::GetCreature(*me, *i))
							{
								if (!cr->IsAlive())
									summons.erase(i++);
								else
									++i;
							}
							else
								summons.erase(i++);
						}
						if (summons.empty())
						{
							events.PopEvent();
							me->CastSpell(me, SPELL_WHITEOUT, false);
							break;
						}
						events.RepeatEvent(2000);
						break;
                }

                DoMeleeAttackIfReady();
            }
        void JustDied(Unit* /*killer*/)
        {
            Talk(SAY_DEATH);
            for (SummonList::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
                if (Creature* cr = ObjectAccessor::GetCreature(*me, (*itr)))
                {
                    if (cr->GetEntry() == NPC_TIME_RIFT)
                        cr->DespawnOrUnsummon(1000);
                    else
                    {
                        cr->DespawnOrUnsummon(5000);
                        cr->RemoveAllAuras();
                        cr->MonsterSay("You have my thanks for saving my existence in this timeline. Now i must report back to my superiors. They must know immediately of what i just experienced.", LANG_UNIVERSAL, 0);
                    }
                }

            if (InstanceScript* pInstance = me->GetInstanceScript())
                pInstance->SetData(DATA_SHOW_INFINITE_TIMER, 0);
        }
        void SummonedCreatureDespawn(Creature* summon)
        {
            uint32 phase= summon->GetPhaseMask();
            uint32 nextPhase = 0;
            Summons.Despawn(summon);

            // Check if all summons in this phase killed
            for (SummonList::const_iterator iter = Summons.begin(); iter != Summons.end(); ++iter)
            {
                if (Creature* visage = Unit::GetCreature(*me, *iter))
                {
                    // Not all are dead
                    if (phase == visage->GetPhaseMask())
                        return;
                    else
                        nextPhase = visage->GetPhaseMask();
                }
            }

            // Roll Insanity
            uint32 spell = GetSpellForPhaseMask(phase);
            uint32 spell2 = GetSpellForPhaseMask(nextPhase);
            Map* map = me->GetMap();
            if (!map)
                return;

            Map::PlayerList const &PlayerList = map->GetPlayers();
            if (!PlayerList.isEmpty())
            {
                for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
                {
                    if (Player* player = i->getSource())
                    {
                        if (player->HasAura(spell))
                        {
                            player->RemoveAurasDueToSpell(spell);
                            if (spell2) // if there is still some different mask cast spell for it
                                player->CastSpell(player, spell2, true);
                        }
                    }
                }
            }
        }
 void ChannelersAction(int32 action)
 {   
     for (SummonList::const_iterator i = summonsChanneler.begin(); i != summonsChanneler.end(); ++i)
         if (Creature* summon = ObjectAccessor::GetCreature(*me, *i))
         {
             if (action == ACTION_CHANNELERS_START_CHANNEL)
             {
                 summon->CastSpell(me, SPELL_SHADE_SOUL_CHANNEL, true);
                 summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
             }
             else if (action == ACTION_START_ENCOUNTER)
             {
                 summon->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
             }
             else if (action == ACTION_KILL_CHANNELERS)
             {
                 Unit::Kill(me, summon);
             }
         }
 }
        void SelectNearestCrystal()
        {
			if (summons.empty())
				return;

            CrystalGUID = 0;
            Unit* crystal = NULL;
			for (SummonList::const_iterator i = summons.begin(); i != summons.end(); )
				if (Creature* summon = ObjectAccessor::GetCreature(*me, *i++))
                    if (!crystal || me->GetDistanceOrder(summon, crystal, false))
						crystal = summon;

            if (crystal)
            {
                Talk(SAY_ENERGY);
                float x, y, z;
                crystal->GetClosePoint(x, y, z, me->GetObjectSize(), CONTACT_DISTANCE);
				CrystalGUID = crystal->GetGUID();
                me->GetMotionMaster()->MovePoint(2, x, y, z);
            }
        }
Exemple #18
0
        void CallBackSparks()
        {
            if (lSparkList.empty())
                return;

            Position pos;
            me->GetPosition(&pos);

            for (std::list<uint64>::const_iterator itr = lSparkList.begin(); itr != lSparkList.end(); ++itr)
            {
                if (Creature* pSpark = Unit::GetCreature(*me, *itr))
                {
                    if (pSpark->isAlive())
                    {
                        pSpark->SetSpeed(MOVE_RUN, 2.0f);
                        pSpark->GetMotionMaster()->Clear();
                        pSpark->GetMotionMaster()->MovePoint(DATA_POINT_CALLBACK, pos);
                    } else pSpark->DespawnOrUnsummon();
                }
            }
        }
Exemple #19
0
        //make sparks come back
        void CallBackSparks()
        {
            //should never be empty here, but check
            if (lSparkList.empty())
                return;

            Position pos = me->GetPosition();

            for (std::list<uint64>::const_iterator itr = lSparkList.begin(); itr != lSparkList.end(); ++itr)
            {
                if (Creature* pSpark = ObjectAccessor::GetCreature(*me, *itr))
                {
                    if (pSpark->IsAlive())
                    {
                        pSpark->SetSpeed(MOVE_RUN, 2.0f);
                        pSpark->GetMotionMaster()->Clear();
                        pSpark->GetMotionMaster()->MovePoint(DATA_POINT_CALLBACK, pos);
                    }
                    else
                        pSpark->DespawnOrUnsummon();
                }
            }
        }
        void UpdateAI(uint32 diff)
        {
            // Call speach
            if (timer)
            {
                timer += diff;
                if (timer >= 4000)
                {
                    Talk(SAY_TENEBRON_RESPOND);
                    me->SetCanFly(true);
                    me->SetSpeed(MOVE_FLIGHT, 3.0f);
                    me->GetMotionMaster()->MovePath(me->GetEntry()*10, false);
                    timer = 0;
                }
            }

            if (!UpdateVictim())
                return;

            events.Update(diff);
            if (me->HasUnitState(UNIT_STATE_CASTING))
                return;

            switch (events.GetEvent())
            {
                case EVENT_MINIBOSS_SHADOW_BREATH:
                    if (!urand(0,10))
                        Talk(SAY_TENEBRON_BREATH);
                    me->CastSpell(me->GetVictim(), SPELL_SHADOW_BREATH, false);
                    events.RepeatEvent(17500);
                    break;
                case EVENT_MINIBOSS_SHADOW_FISSURE:
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
                        me->CastSpell(target, SPELL_SHADOW_FISSURE, false);
                    events.RepeatEvent(22500);
                    break;
                case EVENT_MINIBOSS_OPEN_PORTAL:
                    Talk(WHISPER_OPEN_PORTAL);
                    Talk(SAY_TENEBRON_SPECIAL);
                    
                    if (!isSartharion)
                    {
                        if (GameObject* Portal = me->GetVictim()->SummonGameObject(GO_TWILIGHT_PORTAL, portalPos[BOSS_TENEBRON_EVENT].GetPositionX(), portalPos[BOSS_TENEBRON_EVENT].GetPositionY(), portalPos[BOSS_TENEBRON_EVENT].GetPositionZ(), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0))
                            portalGUID = Portal->GetGUID();
                    }
                    else if (pInstance)
                        pInstance->SetData(DATA_ADD_PORTAL, 0);

                        
                    events.ScheduleEvent(EVENT_MINIBOSS_SPAWN_HELPERS, 2000);
                    events.RepeatEvent(60000);
                    break;
                case EVENT_MINIBOSS_SPAWN_HELPERS:
                {
                    Talk(WHISPER_HATCH_EGGS);
                    Creature* cr = NULL;
                    for (uint8 i = 0; i < 6; ++i)
                    {
                        if (cr = me->SummonCreature(NPC_TWILIGHT_EGG, EggsPos[isSartharion ? i+6 : i].GetPositionX(), EggsPos[isSartharion ? i+6 : i].GetPositionY(), EggsPos[isSartharion ? i+6 : i].GetPositionZ(), EggsPos[isSartharion ? i+6 : i].GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000))
                        {
                            summons.Summon(cr);
                            cr->SetPhaseMask(16, true);
                        }
                        if (cr = me->SummonCreature(NPC_TWILIGHT_WHELP, EggsPos[isSartharion ? i+6 : i].GetPositionX(), EggsPos[isSartharion ? i+6 : i].GetPositionY(), EggsPos[isSartharion ? i+6 : i].GetPositionZ(), EggsPos[isSartharion ? i+6 : i].GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000))
                        {
                            summons.Summon(cr);
                            cr->SetPhaseMask(16, true);
                        }
                    }

                    events.ScheduleEvent(EVENT_MINIBOSS_HATCH_EGGS, 25000);
                    events.PopEvent();
                    break;
                }
                case EVENT_MINIBOSS_HATCH_EGGS:
                {
                    Creature* cr = NULL;
                    summons.RemoveNotExisting();
                    summons.DespawnEntry(NPC_TWILIGHT_WHELP);
                    for (SummonList::iterator i = summons.begin(); i != summons.end(); ++i)
                    {
                        if (cr = ObjectAccessor::GetCreature(*me, *i))
                        {
                            if (!cr->IsAlive())
                                continue;

                            if (cr->GetEntry() == NPC_TWILIGHT_EGG)
                                if (cr = me->SummonCreature(NPC_TWILIGHT_WHELP, cr->GetPositionX(), cr->GetPositionY(), cr->GetPositionZ(), cr->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000))
                                    summons2.Summon(cr);
                        }
                    }

                    if (!isSartharion)
                    {
                        // Remove phase shift
                        if (InstanceScript* instance = me->GetInstanceScript())
                            instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_TWILIGHT_SHIFT);

                        RemoveTwilightPortal();
                    }
                    else if (pInstance)
                        pInstance->SetData(DATA_CLEAR_PORTAL, 0);

                    EntryCheckPredicate pred(NPC_TWILIGHT_EGG);
                    summons.DoAction(ACTION_SWITCH_PHASE, pred);
                    events.PopEvent();
                    break;
                }
            }

            DoMeleeAttackIfReady();
        }
        void UpdateAI(uint32 diff)
        {
            if (!pInstance)
                return;

            events.Update(diff);

            switch(events.GetEvent())
            {
                case 0:
                    break;
                case EVENT_SUMMON_KEEPER_OR_GUARDIAN:
                    bKorG = true;
                    spawned = true;
                    if (Creature *c = DoSummon(RAND(NPC_PORTAL_GUARDIAN, NPC_PORTAL_KEEPER), me, 2.0f, 0, TEMPSUMMON_DEAD_DESPAWN))
                        me->CastSpell(c, SPELL_PORTAL_CHANNEL, false);
                    events.PopEvent();
                    events.RescheduleEvent(EVENT_SUMMON_KEEPER_TRASH, 20000);
                    break;
                case EVENT_SUMMON_KEEPER_TRASH:
                    for (uint8 i=0; i<3+addValue; ++i)
                    {
                        uint32 entry = RAND(NPC_AZURE_INVADER_1, NPC_AZURE_INVADER_2, NPC_AZURE_SPELLBREAKER_1, NPC_AZURE_SPELLBREAKER_2, NPC_AZURE_MAGE_SLAYER_1, NPC_AZURE_MAGE_SLAYER_2, NPC_AZURE_BINDER_1, NPC_AZURE_BINDER_2);
                        DoSummon(entry, me, 2.0f, 20000, TEMPSUMMON_DEAD_DESPAWN);
                    }
                    events.RepeatEvent(20000);
                    break;
                case EVENT_SUMMON_ELITES:
                    spawned = true;
                    for (uint8 i=0; i<2+addValue; ++i)
                    {
                        uint32 entry = RAND(NPC_AZURE_CAPTAIN, NPC_AZURE_RAIDER, NPC_AZURE_STALKER, NPC_AZURE_SORCEROR);
                        DoSummon(entry, me, 2.0f, 20000, TEMPSUMMON_DEAD_DESPAWN);
                    }
                    me->SetVisible(false);
                    events.PopEvent();
                    break;
                case EVENT_SUMMON_SABOTEOUR:
                    DoSummon(NPC_SABOTEOUR, me, 2.0f, 0, TEMPSUMMON_CORPSE_DESPAWN);
                    me->DespawnOrUnsummon(3000);
                    events.PopEvent();
                    break;
            }

            if (!spawned)
                return;

            if (bKorG)
            {
                if (!me->IsNonMeleeSpellCast(false)) // keeper/guardian died => channeled spell interrupted
                {
                    // if keeper/guard lost all victims, in enterevademode linking aura is removed, restore it:
                    if (pInstance)
                        for (SummonList::iterator itr = listOfMobs.begin(); itr != listOfMobs.end(); ++itr)
                            if (Creature* c = pInstance->instance->GetCreature(*itr))
                                if (c->IsAlive() && (c->GetEntry() == NPC_PORTAL_GUARDIAN || c->GetEntry() == NPC_PORTAL_KEEPER))
                                {
                                    me->CastSpell(c, SPELL_PORTAL_CHANNEL, false);
                                    return;
                                }
                    Unit::Kill(me, me, false);
                }
            }
            else
            {
                if (listOfMobs.empty())
                    Unit::Kill(me, me, false);
            }
        }
        void UpdateAI(uint32 diff)
        {
            if (!me->isActiveObject())
                return;

            UpdateVictim();

            events.Update(diff);

            if (me->HasUnitState(UNIT_STATE_CASTING))
                return;

            switch (uint32 evId = events.GetEvent())
            {
                case 0:
                    break;
                case EVENT_CHECK_PLAYER:
                    if (Player* p = ObjectAccessor::GetPlayer(*me, playerGUID))
                        if (p->GetExactDist(me) <= 50.0f)
                        {
                            events.RepeatEvent(5000);
                            break;
                        }
                    events.PopEvent();
                    me->setActive(false);
                    EnterEvadeMode();
                    return;
                case EVENT_SUMMON_SOLDIERS:
                    for (uint8 i=0; i<SUNWELL_DEFENDER_NUM; ++i)
                        me->SummonCreature(NPC_SUNWELL_DEFENDER, SunwellDefenderPos[i], TEMPSUMMON_TIMED_DESPAWN, 33000+(i/5)*5000);
                    events.PopEvent();
                    break;
                case EVENT_TALK_INTRO_0:
                case EVENT_TALK_INTRO_1:
                case EVENT_TALK_INTRO_2:
                case EVENT_TALK_INTRO_3:
                    Talk(SAY_INTRO_0 + (evId-EVENT_TALK_INTRO_0));
                    events.PopEvent();
                    break;
                case EVENT_SALUTE:
                    me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
                    for (SummonList::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
                        if (Creature* c = ObjectAccessor::GetCreature(*me, *itr))
                            c->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
                    events.PopEvent();
                    break;
                case EVENT_SOLDIERS_RUN_AWAY:
                    {
                        uint8 count = 0;
                        for (SummonList::iterator itr = summons.begin(); itr != summons.end();)
                        {
                            ++count;
                            if (Creature* c = ObjectAccessor::GetCreature(*me, *itr))
                            {
                                c->SetWalk(false);
                                c->GetMotionMaster()->MovePoint(0, 11863.35f, -7073.44f, 27.40f);
                            }
                            SummonList::iterator itr2 = itr++;
                            summons.erase(itr2);
                            if (count >= 5)
                            {
                                if (!summons.empty())
                                {
                                    events.RepeatEvent(5000);
                                    return;
                                }
                                else
                                {
                                    events.PopEvent();
                                    return;
                                }
                            }
                        }
                    }
                    events.PopEvent();
                    break;
                case EVENT_GO_FIGHTPOINT:
                    me->SetWalk(true);
                    me->GetMotionMaster()->MovePoint(0, 11779.30f, -7065.43f, 24.92f);
                    me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_READY2H);
                    events.PopEvent();
                    break;
                case EVENT_TALK_SPAWN_0:
                case EVENT_TALK_SPAWN_1:
                    Talk(SAY_SPAWN_0 + (evId-EVENT_TALK_SPAWN_0));
                    events.PopEvent();
                    break;
                case EVENT_SUMMON_MORLEN:
                    if (Creature* c = me->SummonCreature(NPC_MORLEN_COLDGRIP, 11766.70f, -7050.57f, 25.17f, 5.56f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 5000))
                        morlenGUID = c->GetGUID();
                    events.PopEvent();
                    break;
                case EVENT_TALK_MORLEN_0:
                case EVENT_TALK_MORLEN_1:
                    if (Creature* c = ObjectAccessor::GetCreature(*me, morlenGUID))
                        c->AI()->Talk(SAY_MORLEN_0 + (evId-EVENT_TALK_MORLEN_0));
                    events.PopEvent();
                    break;
                case EVENT_SPAWN_WAVE_1:
                case EVENT_SPAWN_WAVE_2:
                case EVENT_SPAWN_WAVE_3:
                    if (Creature* c = ObjectAccessor::GetCreature(*me, morlenGUID))
                    {
                        c->AI()->Talk(SAY_MORLEN_1 + (evId-EVENT_SPAWN_WAVE_1));
                        switch (evId)
                        {
                            // emerge cast tr false 66947
                            case EVENT_SPAWN_WAVE_1:
                                {
                                    Position spawnPos;
                                    c->GetPosition(&spawnPos);
                                    spawnPos.m_orientation = 5.80f;
                                    spawnPos.m_positionX += 5.0f*cos(4.5f);
                                    spawnPos.m_positionY += 5.0f*sin(4.5f);
                                    for (uint8 i=0; i<5; ++i)
                                        if (Creature* s = me->SummonCreature(NPC_SCOURGE_ZOMBIE, spawnPos, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 2000))
                                        {
                                            spawnPos.m_positionX += 2.5f*cos(4.5f);
                                            spawnPos.m_positionY += 2.5f*sin(4.5f);
                                        }
                                }
                                break;
                            case EVENT_SPAWN_WAVE_2:
                                {
                                    Position spawnPos;
                                    c->GetPosition(&spawnPos);
                                    spawnPos.m_orientation = 5.80f;
                                    spawnPos.m_positionX += 7.0f*cos(4.0f);
                                    spawnPos.m_positionY += 7.0f*sin(4.0f);
                                    for (uint8 i=0; i<3; ++i)
                                        if (Creature* s = me->SummonCreature(NPC_GHOUL_INVADER, spawnPos, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 2000))
                                        {
                                            s->CastSpell(s, 66947, false); // emerge effect
                                            spawnPos.m_positionX += 4.0f*cos(4.5f);
                                            spawnPos.m_positionY += 4.0f*sin(4.5f);
                                        }
                                }
                                break;
                            case EVENT_SPAWN_WAVE_3:
                                {
                                    Position spawnPos;
                                    c->GetPosition(&spawnPos);
                                    spawnPos.m_orientation = 5.80f;
                                    spawnPos.m_positionX += 8.0f*cos(4.0f);
                                    spawnPos.m_positionY += 8.0f*sin(4.0f);
                                    for (uint8 i=0; i<3; ++i)
                                        if (Creature* s = me->SummonCreature(NPC_CRYPT_RAIDER, spawnPos, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 2000))
                                        {
                                            s->CastSpell(s, 66947, false); // emerge effect
                                            spawnPos.m_positionX += 4.0f*cos(4.5f);
                                            spawnPos.m_positionY += 4.0f*sin(4.5f);
                                        }
                                }
                                break;
                        }
                    }
                    events.PopEvent();
                    events.ScheduleEvent(EVENT_SUMMONS_ATTACK, 3000);
                    break;
                case EVENT_SUMMONS_ATTACK:
                    for (SummonList::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
                        if (Creature* c = ObjectAccessor::GetCreature(*me, *itr))
                        {
                            if (c->GetEntry() == NPC_MORLEN_COLDGRIP && summons.size() != 1)
                                continue;
                            else
                                c->AI()->Talk(SAY_MORLEN_4);
                            c->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
                            c->AI()->AttackStart(me);
                        }
                    events.PopEvent();
                    break;
                case EVENT_OUTRO_0:
                case EVENT_OUTRO_1:
                case EVENT_OUTRO_2:
                case EVENT_OUTRO_3:
                    Talk(SAY_OUTRO_0 + (evId-EVENT_OUTRO_0));
                    events.PopEvent();
                    if (evId == EVENT_OUTRO_3)
                        events.ScheduleEvent(EVENT_OUTRO_KNEEL, 6000);
                    break;
                case EVENT_OUTRO_KNEEL:
                    if (Player* p = ObjectAccessor::GetPlayer(*me, playerGUID))
                        p->KilledMonsterCredit(NPC_THALORIEN_KILL_CREDIT, 0);
                    me->SetStandState(UNIT_STAND_STATE_KNEEL);
                    events.PopEvent();
                    events.ScheduleEvent(EVENT_DISAPPEAR, 6000);
                    break;
                case EVENT_DISAPPEAR:
                    events.PopEvent();
                    me->SetVisible(false);
                    me->setActive(false);
                    EnterEvadeMode();
                    break;
                case EVENT_SET_FACING:
                    me->SetFacingTo(2.45f);
                    events.PopEvent();
                    break;

                case EVENT_SPELL_BLADESTORM:
                    if (me->GetVictim() && me->IsWithinMeleeRange(me->GetVictim()))
                        me->CastSpell(me->GetVictim(), 67541, false);
                    events.RepeatEvent(urand(25000, 35000));
                    break;
                case EVENT_SPELL_MORTAL_STRIKE:
                    if (me->GetVictim() && me->IsWithinMeleeRange(me->GetVictim()))
                        me->CastSpell(me->GetVictim(), 67542, false);
                    events.RepeatEvent(urand(7000, 12000));
                    break;
                case EVENT_SPELL_HEROIC_STRIKE:
                    if (me->GetVictim() && me->IsWithinMeleeRange(me->GetVictim()))
                        me->CastSpell(me->GetVictim(), 57846, false);
                    events.RepeatEvent(urand(5000, 10000));
                    break;
            }

            DoMeleeAttackIfReady();
        }
Exemple #23
0
		void OozesMeetCheck()
		{
			if (summons.empty() || summons.size()==1)
				return;

			for (SummonList::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
			{
				Creature* ooze = ObjectAccessor::GetCreatureOrPetOrVehicle((*me), (*itr));
				if (!ooze || !ooze->isAlive())
					continue;
				if (ooze->GetEntry() != CREATURE_LITTLE_OOZE && ooze->GetEntry() != CREATURE_OOZE_BIG)
					continue;

				bool little = (ooze->GetEntry() == CREATURE_LITTLE_OOZE);

				for(SummonList::const_iterator itr2 = summons.begin(); itr2 != summons.end(); ++itr2)
				{
					Creature* ooze2 = ObjectAccessor::GetCreatureOrPetOrVehicle((*me), (*itr2));
					if (!ooze2 || !ooze2->isAlive())
						continue;
					if (ooze2->GetEntry() != CREATURE_LITTLE_OOZE && ooze2->GetEntry() != CREATURE_OOZE_BIG)
						continue;
					if (ooze2 == ooze)
						continue;

					if (ooze->GetDistance2d(ooze2) > 5.0f)
						continue;

					bool little2 = (ooze2->GetEntry() == CREATURE_LITTLE_OOZE);

					//if first ooze is big ooze
					if (!little)
					{
						//and if second ooze is little
						if (little2)
						{
							ooze->CastSpell(ooze, SPELL_UNSTABLE_OOZE, false);

							if (ooze->GetAura(SPELL_UNSTABLE_OOZE) && ooze->GetAura(SPELL_UNSTABLE_OOZE)->GetStackAmount() >= 5)
								ooze->CastSpell(ooze2->getVictim(), SPELL_UNSTABLE_EXPLOSION, true);

							continue;
						}
						else //big ooze meet another big ooze, check wich one have more buff stack and despawn second one
						{
							uint8 stack1, stack2 = 0;
							if (Aura* aura = ooze->GetAura(SPELL_UNSTABLE_OOZE))
								stack1 = aura->GetStackAmount();
							if (Aura* aura = ooze2->GetAura(SPELL_UNSTABLE_OOZE))
								stack2 = aura->GetStackAmount();

							if (stack1 < stack2)
							{
								ooze2->CastSpell(ooze, SPELL_UNSTABLE_OOZE, false);
								ooze->ForcedDespawn();
								if (ooze2->GetAura(SPELL_UNSTABLE_OOZE) && ooze2->GetAura(SPELL_UNSTABLE_OOZE)->GetStackAmount() >= 5)
								{
									ooze2->CastSpell(ooze2->getVictim(), SPELL_UNSTABLE_EXPLOSION, true);
									ooze2->ForcedDespawn();
								}

								break;
							}
							else
							{
								ooze->CastSpell(ooze, SPELL_UNSTABLE_OOZE, false);
								ooze2->ForcedDespawn();
								if (ooze->GetAura(SPELL_UNSTABLE_OOZE) && ooze->GetAura(SPELL_UNSTABLE_OOZE)->GetStackAmount() >= 5)
								{
									ooze->CastSpell(ooze2->getVictim(), SPELL_UNSTABLE_EXPLOSION, true);
									ooze->ForcedDespawn();
								}
								continue;
							}
						}
					}
					else  //if first ooze is little
					{
						if (little2) //and second ooze is little, despawn both and summon big ooze
						{
							DoSummon(CREATURE_OOZE_BIG, (*ooze));
							ooze->ForcedDespawn();
							ooze2->ForcedDespawn();
							break;
						}
						else
						{
							ooze2->CastSpell(ooze, SPELL_UNSTABLE_OOZE, false);
							ooze->ForcedDespawn();
							if (ooze2->GetAura(SPELL_UNSTABLE_OOZE) && ooze2->GetAura(SPELL_UNSTABLE_OOZE)->GetStackAmount() >= 5)
							{
								ooze2->CastSpell(ooze2->getVictim(), SPELL_UNSTABLE_EXPLOSION, true);
								ooze2->ForcedDespawn();
							}
							break;
						}
					}
				}
			}
		}
Exemple #24
0
        void UpdateAI(const uint32 uiDiff)
        {
            if (!UpdateVictim())
                return;

            if (!bIsFrenzy && HealthBelowPct(25) && !bIsExploded)
            {
                DoScriptText(SAY_ENRAGE, me);
                DoCast(me, SPELL_FRENZY, true);
                bIsFrenzy = true;
            }

            if (!bIsFrenzy)
            {
                if (uiBubbleCheckerTimer <= uiDiff)
                {
                    if (!bIsExploded)
                    {
                        if (!me->HasAura(SPELL_PROTECTIVE_BUBBLE, 0))
                        {
                            DoScriptText(SAY_SHATTER, me);
                            DoCast(me, SPELL_WATER_BLAST);
                            DoCast(me, SPELL_DRAINED);
                            bIsExploded = true;
                            me->AttackStop();
                            me->SetVisible(false);
                            for (uint8 i = 0; i < 10; i++)
                            {
                                int tmp = urand(0, MAX_SPAWN_LOC-1);
                                me->SummonCreature(NPC_ICHOR_GLOBULE, SpawnLoc[tmp], TEMPSUMMON_CORPSE_DESPAWN);
                            }
                        }
                    }
                    else
                    {
                        bool bIsWaterElementsAlive = false;
                        if (!m_waterElements.empty())
                        {
                            for (std::list<uint64>::const_iterator itr = m_waterElements.begin(); itr != m_waterElements.end(); ++itr)
                                if (Creature* temp = Unit::GetCreature(*me, *itr))
                                    if (temp->isAlive())
                                    {
                                        bIsWaterElementsAlive = true;
                                        break;
                                    }
                        }

                        if (!bIsWaterElementsAlive)
                            DoExplodeCompleted();
                    }
                    uiBubbleCheckerTimer = 1000;
                }
                else uiBubbleCheckerTimer -= uiDiff;
            }

            if (!bIsExploded)
            {
                if (uiWaterBoltVolleyTimer <= uiDiff)
                {
                    DoCast(me, SPELL_WATER_BOLT_VOLLEY);
                    uiWaterBoltVolleyTimer = urand(10000, 15000);
                }
                else uiWaterBoltVolleyTimer -= uiDiff;

                DoMeleeAttackIfReady();
            }
        }
Exemple #25
0
        void UpdateAI(uint32 uiDiff)
        {
            if (!UpdateVictim())
                return;

            if (!bIsFrenzy && !bIsExploded && HealthBelowPct(25))
            {
                Talk(SAY_ENRAGE);
                me->CastSpell(me, SPELL_FRENZY, true);
                bIsFrenzy = true;
            }

            if (!bIsFrenzy)
            {
                if (!bIsExploded)
                {
                    if (!me->HasAura(SPELL_PROTECTIVE_BUBBLE))
                    {
                        me->InterruptNonMeleeSpells(false);
                        Talk(SAY_SHATTER);
                        DoZoneInCombat();
                        IchoronDoCastToAllHostilePlayers(SPELL_WATER_BLAST, true);
                        me->CastSpell(me, SPELL_DRAINED, true);
                        bIsExploded = true;
                        uiDrainedTimer = 15000;
                        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                        me->SetDisplayId(11686);
                        for (uint8 i=0; i<MAX_SPAWN_LOC; ++i)
                        {
                            float angle = rand_norm()*2*M_PI;
                            Position p1(SpawnLoc[i]), p2(SpawnLoc[i]);
                            p1.m_positionX += 2.5f*cos(angle);
                            p1.m_positionY += 2.5f*sin(angle);
                            p2.m_positionX -= 2.5f*cos(angle);
                            p2.m_positionY -= 2.5f*sin(angle);
                            DoSummon(NPC_ICHOR_GLOBULE, p1, 60000, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN);
                            DoSummon(NPC_ICHOR_GLOBULE, p2, 60000, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN);
                        }
                    }
                }
                else
                {
                    if (uiDrainedTimer <= uiDiff)
                        DoExplodeCompleted();
                    else
                    {
                        uiDrainedTimer -= uiDiff;

                        bool bIsWaterElementsAlive = false;
                        if (!globules.empty())
                        {
                            for (std::list<uint64>::const_iterator itr = globules.begin(); itr != globules.end(); ++itr)
                                if (Creature* pTemp = ObjectAccessor::GetCreature(*me, *itr))
                                    if (pTemp->IsAlive())
                                    {
                                        bIsWaterElementsAlive = true;
                                        break;
                                    }
                        }

                        if (!bIsWaterElementsAlive)
                            DoExplodeCompleted();
                    }
                }
            }

            if (!bIsExploded)
            {
                if (uiWaterBoltVolleyTimer <= uiDiff)
                {
                    me->CastSpell((Unit*)NULL, SPELL_WATER_BOLT_VOLLEY, false);
                    uiWaterBoltVolleyTimer = urand(10000, 15000);
                }
                else uiWaterBoltVolleyTimer -= uiDiff;
            }

            DoMeleeAttackIfReady();
        }
            void UpdateAI(uint32 diff)
            {
                events2.Update(diff);
                switch (events2.ExecuteEvent())
                {
                    case EVENT_AKAMA_START_ENCOUNTER:
                        me->RemoveAura(SPELL_STEALTH);
                        me->SetWalk(true);
                        me->GetMotionMaster()->MovePoint(POINT_START, 517.4877f, 400.7993f, 112.7837f, false);
                        events2.ScheduleEvent(EVENT_AKAMA_START_CHANNEL, 11000);
                        break;
                    case EVENT_AKAMA_START_CHANNEL:
                        me->CastSpell(me, SPELL_AKAMA_SOUL_CHANNEL, false);
                        if (Creature* shade = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_SHADE_OF_AKAMA)))
                        {
                            shade->AI()->AttackStart(me);
                            shade->GetMotionMaster()->Clear();
                            shade->AI()->DoAction(ACTION_START_ENCOUNTER);
                        }
                        break;
                    case EVENT_AKAMA_SCENE0:
                        me->SetWalk(true);
                        me->GetMotionMaster()->MovePoint(POINT_CHANNEL_SOUL, 467.0f, 400.7993f, 118.537f);
                        break;
                    case EVENT_AKAMA_SCENE1:
                        me->CastSpell(me, SPELL_AKAMA_SOUL_RETRIEVE, true);
                        break;
                    case EVENT_AKAMA_SCENE2:
                        Talk(SAY_BROKEN_FREE_0);
                        break;
                    case EVENT_AKAMA_SCENE3:
                        me->SummonCreatureGroup(SUMMON_GROUP_BROKENS);
                        break;
                    case EVENT_AKAMA_SCENE4:
                        Talk(SAY_BROKEN_FREE_1);
                        break;
                    case EVENT_AKAMA_SCENE5:
                        for (SummonList::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
                            if (Creature* broken = ObjectAccessor::GetCreature(*me, *itr))
                                broken->SetStandState(UNIT_STAND_STATE_KNEEL);
                        Talk(SAY_BROKEN_FREE_2);
                        break;
                    case EVENT_AKAMA_SCENE6:
                        if (Creature* broken = summons.GetCreatureWithEntry(NPC_ASHTONGUE_BROKEN))
                            broken->AI()->Talk(SAY_BROKEN_S1);
                        break;
                    case EVENT_AKAMA_SCENE7:
                        for (SummonList::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
                            if (Creature* broken = ObjectAccessor::GetCreature(*me, *itr))
                                broken->AI()->Talk(SAY_BROKEN_S2);
                        break;
                }

                if (!UpdateVictim())
                    return;

                events.Update(diff);
                if (me->HasUnitState(UNIT_STATE_CASTING))
                    return;

                switch (events.ExecuteEvent())
                {
                    case EVENT_SPELL_CHAIN_LIGHTNING:
                        me->CastSpell(me->GetVictim(), SPELL_CHAIN_LIGHTNING, false);
                        events.ScheduleEvent(EVENT_SPELL_CHAIN_LIGHTNING, urand(10000, 15000));
                        break;
                    case EVENT_SPELL_DESTRUCTIVE_POISON:
                        me->CastSpell(me, SPELL_DESTRUCTIVE_POISON, false);
                        events.ScheduleEvent(EVENT_SPELL_DESTRUCTIVE_POISON, urand(4000, 5000));
                        break;
                }

                DoMeleeAttackIfReady();
            }