void UpdateAI(uint32 diff)
        {
			if (talkTimer)
			{
				talkTimer += diff;
				if (talkTimer >= 1000 && talkTimer < 10000)
				{
					Talk(SAY_ANZU_INTRO1);
					talkTimer = 10000;
				}
				else if (talkTimer >= 16000)
				{
					me->SetUInt32Value(UNIT_FIELD_FLAGS, 0);
					me->RemoveAurasDueToSpell(SPELL_SHADOWFORM);
					Talk(SAY_ANZU_INTRO2);
					talkTimer = 0;
				}
			}

            if (!UpdateVictim())
                return;

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

			switch (events.GetEvent())
			{
				case EVENT_SPELL_SCREECH:
					me->CastSpell(me, SPELL_PARALYZING_SCREECH, false);
					events.RepeatEvent(23000);
					events.DelayEvents(3000);
					break;
				case EVENT_SPELL_BOMB:
					if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 50.0f, true))
						me->CastSpell(target, SPELL_SPELL_BOMB, false);
					events.RepeatEvent(urand(16000, 24500));
					events.DelayEvents(3000);
					break;
				case EVENT_SPELL_CYCLONE:
					if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 45.0f, true))
						me->CastSpell(target, SPELL_CYCLONE, false);
					events.RepeatEvent(urand(22000, 27000));
					events.DelayEvents(3000);
					break;
				case EVENT_ANZU_HEALTH1:
					if (me->HealthBelowPct(66))
					{
						SummonBroods();
						events.PopEvent();
						events.DelayEvents(10000);
						return;
					}
					events.RepeatEvent(1000);
					break;
				case EVENT_ANZU_HEALTH2:
					if (me->HealthBelowPct(33))
					{
						SummonBroods();
						events.PopEvent();
						events.DelayEvents(10000);
						return;
					}
					events.RepeatEvent(1000);
					break;
            }

            DoMeleeAttackIfReady();
        }
Example #2
0
        void UpdateAI(const uint32 diff)
        {
            if (!UpdateVictim())
                return;
            
            events.Update(diff);
        
            if (me->hasUnitState(UNIT_STAT_CASTING))
                return;

            while (uint32 eventId = events.ExecuteEvent())
            {
                switch(eventId)
                {
                    case EVENT_MOVE_POS:
                        MovePos();
                        events.RescheduleEvent(EVENT_MOVE_POS, 10000);
                    break;        
                    case EVENT_ENRAGE:
                        DoScriptText(SAY_BRUNDIR_BERSERK, me);
                        DoCast(SPELL_BERSERK);
                    break;
                    case EVENT_CHAIN_LIGHTNING:
                        if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                            DoCast(pTarget, SPELL_CHAIN_LIGHTNING);
                        events.ScheduleEvent(EVENT_CHAIN_LIGHTNING, urand(4000, 6000));
                    break;
                    case EVENT_OVERLOAD:
                        me->MonsterTextEmote(EMOTE_OVERLOAD, 0, true);
                        DoScriptText(SAY_BRUNDIR_SPECIAL, me);
                        me->GetMotionMaster()->Clear(true);
                        DoCast(SPELL_OVERLOAD);
                        events.ScheduleEvent(EVENT_OVERLOAD, urand(60000, 120000));
                    break;
                    case EVENT_LIGHTNING_WHIRL:
                        me->GetMotionMaster()->Clear(true);
                        DoCast(SPELL_LIGHTNING_WHIRL);
                        events.ScheduleEvent(EVENT_LIGHTNING_WHIRL, urand(15000, 20000));
                    break;
                    case EVENT_LIGHTNING_TENDRILS:
                        DoScriptText(SAY_BRUNDIR_FLIGHT, me);
                        DoCast(SPELL_LIGHTNING_TENDRILS);
                        me->AttackStop();
                        me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
                        DoCast(SPELL_LIGHTNING_TENDRILS_SELF_VISUAL);
                        me->GetMotionMaster()->Clear(true);
                        me->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), 440);
                        events.DelayEvents(35000);
                        events.ScheduleEvent(EVENT_FLIGHT, 2500);
                        events.ScheduleEvent(EVENT_ENDFLIGHT, 28000);
                        events.ScheduleEvent(EVENT_LIGHTNING_TENDRILS, 90000);
                    break;
                    case EVENT_FLIGHT:
                        if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                            me->GetMotionMaster()->MovePoint(0, pTarget->GetPositionX(), pTarget->GetPositionY(), 440);
                        events.ScheduleEvent(EVENT_FLIGHT, 6000);
                    break;
                    case EVENT_ENDFLIGHT:
                        me->GetMotionMaster()->Clear(true);
                        me->GetMotionMaster()->MovePoint(0, 1586.920166, 119.848984, 440);
                        events.CancelEvent(EVENT_FLIGHT);
                        events.CancelEvent(EVENT_ENDFLIGHT);
                        events.ScheduleEvent(EVENT_LAND, 4000);
                    break;
                    case EVENT_LAND:
                        me->GetMotionMaster()->Clear(true);
                        me->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), 427.28);
                        events.CancelEvent(EVENT_LAND);
                        events.ScheduleEvent(EVENT_GROUND, 2500);
                    break;
                    case EVENT_GROUND:
                        me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
                        me->RemoveAurasDueToSpell(SPELL_LIGHTNING_TENDRILS);
                        me->RemoveAurasDueToSpell(SPELL_LIGHTNING_TENDRILS_SELF_VISUAL);
                        events.CancelEvent(EVENT_GROUND);
                    break;
                }
            }
        }
 void KilledUnit(Unit* /*victim*/)
 {
     Talk(SAY_SLAY);
     events.DelayEvents(5000, GCD_YELL);
 }
Example #4
0
        void UpdateAI(uint32 diff)
        {
            if (!UpdateVictim())
                return;

            if (me->GetVictim())
            {
                float x,y,z;
                me->GetVictim()->GetPosition(x, y, z);
                if (KrickCenterPos.GetExactDist(x,y,z) > 80.0f || z > KrickCenterPos.GetPositionZ()+20.0f || z < KrickCenterPos.GetPositionZ()-20.0f)
                {
                    me->SetHealth(me->GetMaxHealth());
                    EnterEvadeMode();
                    return;
                }
            }

            events.Update(diff);

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

            switch(events.GetEvent())
            {
                case 0:
                    break;
                case EVENT_SPELL_TOXIC_WASTE:
                    if (Creature* k = GetKrick())
                        if (!k->HasUnitState(UNIT_STATE_CASTING))
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 40.0f, true))
                            {
                                k->CastSpell(target, SPELL_TOXIC_WASTE);
                                events.RepeatEvent(urand(7000,10000));
                                break;
                            }
                    events.RepeatEvent(2500);
                    break;
                case EVENT_SPELL_MIGHTY_KICK:
                    me->CastSpell(me->GetVictim(), SPELL_MIGHTY_KICK, false);
                    events.RepeatEvent(urand(20000,25000));
                    break;
                case EVENT_SPELL_SHADOW_BOLT:
                    if (Creature* k = GetKrick())
                        if (!k->HasUnitState(UNIT_STATE_CASTING))
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 35.0f, true))
                            {
                                k->CastSpell(target, SPELL_SHADOW_BOLT);
                                events.RepeatEvent(14000);
                                break;
                            }
                    events.RepeatEvent(2500);
                    break;
                case EVENT_SET_REACT_AGGRESSIVE:
                    me->SetReactState(REACT_AGGRESSIVE);
                    if (!UpdateVictim())
                        return;
                    events.PopEvent();
                    break;
                case EVENT_SPECIAL:
                    switch(urand(0,2))
                    {
                        case 0: // Pursuit
                            if (Creature* k = GetKrick())
                                k->AI()->Talk(RAND(SAY_TARGET_1, SAY_TARGET_2, SAY_TARGET_3));
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 70.0f, true))
                                me->CastSpell(target, SPELL_PURSUIT, false);
                            break;
                        case 1: // Poison Nova
                            if (Creature* k = GetKrick())
                            {
                                k->AI()->Talk(SAY_ORDER_BLOW);
                                Talk(EMOTE_ICK_POISON);
                            }
                            me->CastSpell(me, SPELL_POISON_NOVA, false);
                            break;
                        case 2: // Explosive Barrage
                            if (Creature* k = GetKrick())
                            {
                                k->AI()->Talk(SAY_ORDER_STOP);
                                k->AI()->Talk(EMOTE_KRICK_MINES);
                                k->InterruptNonMeleeSpells(false);
                                me->InterruptNonMeleeSpells(false);
                                k->CastSpell(k, SPELL_EXPLOSIVE_BARRAGE_KRICK, false);
                                me->CastSpell(me, SPELL_EXPLOSIVE_BARRAGE_ICK, false);
                            }
                            events.DelayEvents(20000);
                            break;
                    }
                    events.RepeatEvent(urand(25000,30000));
                    break;
            }

            DoMeleeAttackIfReady();
        }
Example #5
0
        void UpdateAI(uint32 diff)
        {
            if( releaseLockTimer )
            {
                if( releaseLockTimer >= 5000 )
                {
                    lock = false;
                    if (me->IsInCombat())
                    {
                        LeaveCombat();
                        me->CastSpell(me, SPELL_EVOCATION, true);
                    }
                    releaseLockTimer = 0;
                }
                else
                    releaseLockTimer += diff;
            }

            if( !UpdateVictim() )
                return;

            events.Update(diff);

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

            DoMeleeAttackIfReady();

            switch( events.GetEvent() )
            {
                case 0:
                    break;
                case EVENT_FROSTBOMB:
                    if( Unit* v = me->GetVictim() )
                        me->CastSpell(v, SPELL_FROSTBOMB, false);
                    events.RepeatEvent(urand(7000,11000));
                    break;
                case EVENT_TIME_BOMB:
                    if( Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true) )
                        me->CastSpell(target, SPELL_TIME_BOMB, false);
                    events.RepeatEvent(urand(20000, 25000));
                    break;
                case EVENT_TELEPORT_TO_CENTER:
                    x = me->GetPositionX();
                    y = me->GetPositionY();
                    z = me->GetPositionZ();
                    me->CastSpell(me, SPELL_TELEPORT, false);
                    events.RepeatEvent(urand(25000,30000));
                    events.DelayEvents(10000);
                    break;
                case EVENT_TELE_BACK:
                    me->GetMotionMaster()->MoveIdle();
                    me->DisableSpline();
                    me->SetCanFly(false);
                    me->SetDisableGravity(false);
                    me->NearTeleportTo(x, y, z, 0.0f);
                    me->SetControlled(false, UNIT_STATE_ROOT);
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    me->GetMotionMaster()->MoveChase(me->GetVictim());
                    events.PopEvent();
                    break;
            }
        }
Example #6
0
        void UpdateAI(uint32 diff)
        {
            if (!UpdateVictim() || me->HasUnitState(UNIT_STATE_CASTING))
                return;

            events.Update(diff);
            switch (events.GetEvent())
            {
                case EVENT_SPELL_SONIC_BOOM:
                    Talk(EMOTE_SONIC_BOOM);
                    me->CastSpell(me, DUNGEON_MODE(SPELL_SONIC_BOOM_CAST_N, SPELL_SONIC_BOOM_CAST_H), false);
                    events.RepeatEvent(28500);
                    events.DelayEvents(1500);
                    events.ScheduleEvent(EVENT_SPELL_SONIC_BOOM_EFFECT, 0);
                    return;
                case EVENT_SPELL_SONIC_BOOM_EFFECT:
                    me->CastSpell(me, DUNGEON_MODE(SPELL_SONIC_BOOM_EFFECT_N, SPELL_SONIC_BOOM_EFFECT_H), true);
                    events.PopEvent();
                    break;
                case EVENT_SPELL_MURMURS_TOUCH:
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 80.0f, true))
                        me->CastSpell(target, DUNGEON_MODE(SPELL_MURMURS_TOUCH_N, SPELL_MURMURS_TOUCH_H), false);
                    events.RepeatEvent(urand(25000, 35000));
                    break;
                case EVENT_SPELL_RESONANCE:
                    if (!me->IsWithinMeleeRange(me->GetVictim()))
                        me->CastSpell(me, SPELL_RESONANCE, false);
                    events.RepeatEvent(5000);
                    break;
                case EVENT_SPELL_MAGNETIC:
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 80.0f, true))
                    {
                        me->CastSpell(target, SPELL_MAGNETIC_PULL, false);
                        events.RepeatEvent(urand(15000, 30000));
                        return;
                    }
                    events.RepeatEvent(500);
                    break;
                case EVENT_SPELL_THUNDERING:
                    me->CastSpell(me, SPELL_THUNDERING_STORM, true);
                    events.RepeatEvent(15000);
                    break;
                case EVENT_SPELL_SONIC_SHOCK:
                    me->CastSpell(me->GetVictim(), SPELL_SONIC_SHOCK, false);
                    events.RepeatEvent(urand(10000, 20000));
                    break;
            }

            if (!me->isAttackReady())
                return;

            if (!me->IsWithinMeleeRange(me->GetVictim()))
            {
                ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList();
                for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i)
                    if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
                        if (target->IsAlive() && me->IsWithinMeleeRange(target))
                        {
                            me->TauntApply(target);
                            break;
                        }
            }

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

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

			switch (events.GetEvent())
			{
				case EVENT_YMIRON_HEALTH_CHECK:
				{
					if (me->GetHealth() < std::max(0.0f, float(me->GetMaxHealth()*(1.0f-(IsHeroic() ? 0.2f : 0.334f)*float(BoatNum+1)))))
					{
						events.DelayEvents(12000);
						me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
						me->InterruptNonMeleeSpells(true);
						me->CastSpell(me, SPELL_SCREAMS_OF_THE_DEAD, true);
						me->GetMotionMaster()->Clear();
						me->GetMotionMaster()->MovePoint(0, BoatStructure[BoatOrder[BoatNum]].MoveX, BoatStructure[BoatOrder[BoatNum]].MoveY, BoatStructure[BoatOrder[BoatNum]].MoveZ);
						me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
						summons.DespawnAll();

						// Spawn flames in previous boat if any
						if (BoatNum) // different than 0
							if (Creature *cr = me->SummonTrigger(BoatStructure[BoatOrder[BoatNum-1]].SpawnX, BoatStructure[BoatOrder[BoatNum-1]].SpawnY, BoatStructure[BoatOrder[BoatNum-1]].SpawnZ, 0, 1800000))
							{
								cr->AddAura(SPELL_FLAMES, cr);
								summons2.Summon(cr);
							}

						BoatNum++;
					}

					events.RepeatEvent(1000);
					break;
				}
				case EVENT_YMIRON_BANE:
				{
					me->CastSpell(me, IsHeroic() ? SPELL_BANE_H : SPELL_BANE_N, false);
					events.RepeatEvent(20000+rand()%5000);
					break;
				}
				case EVENT_YMIRON_FETID_ROT:
				{
					me->CastSpell(me->GetVictim(), IsHeroic() ? SPELL_FETID_ROT_H : SPELL_FETID_ROT_N, false);
					events.RepeatEvent(10000+rand()%3000);
					break;
				}
				case EVENT_YMIRON_DARK_SLASH:
				{
					int32 dmg = me->GetVictim()->GetHealth() / 2;
					me->CastCustomSpell(me->GetVictim(), SPELL_DARK_SLASH, &dmg, 0, 0, false);
					events.RepeatEvent(30000+rand()%5000);
					break;
				}
				case EVENT_YMIRON_ACTIVATE_BOAT:
				{
					// Spawn it!
					if (Creature* king = me->SummonCreature(BoatStructure[BoatOrder[BoatNum-1]].npc, BoatStructure[BoatOrder[BoatNum-1]].SpawnX, BoatStructure[BoatOrder[BoatNum-1]].SpawnY, BoatStructure[BoatOrder[BoatNum-1]].SpawnZ, BoatStructure[BoatOrder[BoatNum-1]].SpawnO, TEMPSUMMON_CORPSE_DESPAWN, 0))
					{
						me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
						king->CastSpell(me, SPELL_CHANNEL_SPIRIT_TO_YMIRON, true);
						summons.Summon(king);
						king->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
						king->SetDisableGravity(true);
						me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
						me->GetMotionMaster()->MoveChase(me->GetVictim());
						switch(BoatOrder[BoatNum-1])
						{
							case 0: events.ScheduleEvent(EVENT_YMIRON_RANULF_ABILITY, 3000, 1); break;
							case 1: events.ScheduleEvent(EVENT_YMIRON_TORGYN_ABILITY, 3000, 1); break;
							case 2: events.ScheduleEvent(EVENT_YMIRON_BJORN_ABILITY, 3000, 1); break;
							case 3: events.ScheduleEvent(EVENT_YMIRON_HALDOR_ABILITY, 3000, 1); break;
						}
					}

					events.PopEvent();
					break;
				}
				case EVENT_YMIRON_BJORN_ABILITY:
				{
					if (Creature* sf = me->SummonCreature(NPC_SPIRIT_FOUNT, 385+rand()%10, -330+rand()%10, 104.756f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 180000))
					{
						summons.Summon(sf);
						sf->SetSpeed(MOVE_RUN, 0.4f);
						sf->AddAura(IsHeroic() ? SPELL_SPIRIT_FOUNT_H : SPELL_SPIRIT_FOUNT_N, sf);
						sf->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
						sf->GetMotionMaster()->MoveFollow(me->GetVictim(), 0, rand_norm()*M_PI*2);
					}
					events.PopEvent();
					break;
				}
				case EVENT_YMIRON_HALDOR_ABILITY:
				{
					me->CastSpell(me->GetVictim(), IsHeroic() ? SPELL_SPIRIT_STRIKE_H : SPELL_SPIRIT_STRIKE_N, false);
					events.RepeatEvent(5000);
					break;
				}
				case EVENT_YMIRON_RANULF_ABILITY:
				{
					me->CastSpell(me, IsHeroic() ? SPELL_SPIRIT_BURST_H : SPELL_SPIRIT_BURST_N, false);
					events.RepeatEvent(10000);
					break;
				}
				case EVENT_YMIRON_TORGYN_ABILITY:
				{
					for(uint8 i = 0; i < 4; ++i)
					{
						if (Creature* as = me->SummonCreature(NPC_AVENGING_SPIRIT, me->GetPositionX()+rand()%10, me->GetPositionY()+rand()%10, me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000))
						{
							summons.Summon(as);
							as->SetInCombatWithZone();
						}
					}
					events.RepeatEvent(15000);
					break;
				}

			}

			DoMeleeAttackIfReady();  
		}
 void KilledUnit(Unit* /*victim*/)
 {
     DoScriptText(urand(0, 1) ? SAY_SLAY1 : SAY_SLAY2, me);
     events.DelayEvents(5000, GCD_YELL);
 }
Example #9
0
    void UpdateAI(const uint32 diff)
    {
        // Return since we have no target
        if (!UpdateVictim())
            return;

        events.Update(diff);

        if (me->hasUnitState(UNIT_STAT_CASTING))
            return;

        while (uint32 eventId = events.ExecuteEvent())
        {
            switch(eventId)
            {
                case EVENT_PHANTOM_BLAST:
                    if (Unit *pTarget = SelectUnit(SELECT_TARGET_TOPAGGRO, 0))
                        DoCast(pTarget, SPELL_PHANTOM_BLAST);
                    events.ScheduleEvent(EVENT_PHANTOM_BLAST, 5000);
                    break;
                case EVENT_MIRRORED_SOUL:
                    if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 0, true))
                    {
                        uiMirroredSoulTarget = pTarget->GetGUID();
                        DoCast(pTarget, SPELL_MIRRORED_SOUL);
                        DoScriptText(EMOTE_MIRRORED_SOUL, me);
                    }
                    events.ScheduleEvent(EVENT_MIRRORED_SOUL, urand(15000,30000));
                    break;
                case EVENT_WELL_OF_SOULS:
                    if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                        DoCast(pTarget, SPELL_WELL_OF_SOULS);
                    events.ScheduleEvent(EVENT_WELL_OF_SOULS, 20000);
                    break;
                case EVENT_UNLEASHED_SOULS:
                    if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                        DoCast(pTarget, SPELL_UNLEASHED_SOULS);
                    me->SetDisplayId(DISPLAY_SORROW);
                    DoScriptText(RAND(SAY_FACE_ANGER_UNLEASH_SOUL,SAY_FACE_SORROW_UNLEASH_SOUL,SAY_FACE_DESIRE_UNLEASH_SOUL), me);
                    DoScriptText(EMOTE_UNLEASH_SOUL, me);
                    events.ScheduleEvent(EVENT_UNLEASHED_SOULS, 30000);
                    events.ScheduleEvent(EVENT_FACE_ANGER, 5000);
                    break;
                case EVENT_FACE_ANGER:
                    me->SetDisplayId(DISPLAY_ANGER);
                    break;

                case EVENT_WAILING_SOULS:
                    me->SetDisplayId(DISPLAY_DESIRE);
                    DoScriptText(RAND(SAY_FACE_ANGER_WAILING_SOUL,SAY_FACE_DESIRE_WAILING_SOUL), me);
                    DoScriptText(EMOTE_WAILING_SOUL, me);
                    DoCast(me, SPELL_WAILING_SOULS_STARTING);

                    if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                    {
                        me->SetOrientation(me->GetAngle(pTarget));
                        DoCast(me, SPELL_WAILING_SOULS_BEAM);
                    }

                    beamAngle = me->GetOrientation();

                    beamAngleDiff = PI/30.0f; // PI/2 in 15 sec = PI/30 per tick
                    if (RAND(true,false))
                        beamAngleDiff = -beamAngleDiff;

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

                    //Remove any target
                    me->SetUInt64Value(UNIT_FIELD_TARGET, 0);

                    me->GetMotionMaster()->Clear();
                    me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);

                    wailingSoulTick = 15;
                    events.DelayEvents(18000); // no other events during wailing souls
                    events.ScheduleEvent(EVENT_WAILING_SOULS_TICK, 3000); // first one after 3 secs.
                    break;

                case EVENT_WAILING_SOULS_TICK:
                    beamAngle += beamAngleDiff;
                    me->SetOrientation(beamAngle);
                    me->StopMoving();

                    DoCast(me, SPELL_WAILING_SOULS);

                    if (--wailingSoulTick)
                        events.ScheduleEvent(EVENT_WAILING_SOULS_TICK, 1000);
                    else
                    {
                        me->SetReactState(REACT_AGGRESSIVE);
                        me->SetDisplayId(DISPLAY_ANGER);
                        me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
                        me->GetMotionMaster()->MoveChase(me->getVictim());
                        events.ScheduleEvent(EVENT_WAILING_SOULS, urand(60000,70000));
                    }
                    break;
            }
        }

        DoMeleeAttackIfReady();
    }
Example #10
0
		void UpdateAI(uint32 diff)
		{
			events2.Update(diff);
			switch (events2.ExecuteEvent())
			{
				case EVENT_SVALA_START:
					Talk(TALK_INTRO_S1);
					events2.ScheduleEvent(EVENT_SVALA_TALK1, 8000);
					break;
				case EVENT_SVALA_TALK1:
					if (Creature* Arthas = ObjectAccessor::GetCreature(*me, ArthasGUID))
						Arthas->AI()->Talk(TALK_INTRO_A1);
					events2.ScheduleEvent(EVENT_SVALA_TALK2, 9000);
					break;
				case EVENT_SVALA_TALK2:
					if (Creature* Arthas = ObjectAccessor::GetCreature(*me, ArthasGUID))
						Arthas->CastSpell(me, SPELL_ARTHAS_TRANSFORMING_SVALA, false);
					me->CastSpell(me, SPELL_SVALA_TRANSFORMING2, true);
					events2.ScheduleEvent(EVENT_SVALA_TALK3, 3000);
					break;
				case EVENT_SVALA_TALK3:
					me->SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 6.0f);
					me->SetHover(true);
					me->AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
					events2.ScheduleEvent(30, 1000);
					events2.ScheduleEvent(EVENT_SVALA_TALK4, 9000);
					break;
				case 30:
				{
					WorldPacket data(SMSG_SPLINE_MOVE_SET_HOVER, 9);
					data.append(me->GetPackGUID());
					me->SendMessageToSet(&data, false);
					break;
				}
				case EVENT_SVALA_TALK4:
				{
					me->CastSpell(me, SPELL_SVALA_TRANSFORMING1, true);
					me->UpdateEntry(NPC_SVALA_SORROWGRAVE);
					me->SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 6.0f);
					me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC|UNIT_FLAG_IMMUNE_TO_NPC);
					if (Creature* Arthas = ObjectAccessor::GetCreature(*me, ArthasGUID))
						Arthas->InterruptNonMeleeSpells(false);
					me->RemoveAllAuras();
					me->SetWalk(false);
					events2.ScheduleEvent(EVENT_SVALA_TALK5, 2000);

					std::list<Creature*> creatureList;
					me->GetCreaturesWithEntryInRange(creatureList, 100.0f, NPC_DRAGONFLAYER_SPECTATOR);
					for (std::list<Creature*>::const_iterator itr = creatureList.begin(); itr != creatureList.end(); ++itr)
						(*itr)->AI()->SetData(1, 2);

					break;
				}
				case EVENT_SVALA_TALK5:
					Talk(TALK_INTRO_S2);
					events2.ScheduleEvent(EVENT_SVALA_TALK6, 12000);
					break;
				case EVENT_SVALA_TALK6:
					if (Creature *Arthas = ObjectAccessor::GetCreature(*me, ArthasGUID))
						Arthas->AI()->Talk(TALK_INTRO_A2);
					events2.ScheduleEvent(EVENT_SVALA_TALK7, 9000);
					break;
				case EVENT_SVALA_TALK7:
					me->SetFacingTo(M_PI/2.0f);
					Talk(TALK_INTRO_S3);
					if (GameObject* mirror = ObjectAccessor::GetGameObject(*me, instance->GetData64(GO_SVALA_MIRROR)))
						mirror->SetGoState(GO_STATE_ACTIVE);
					events2.ScheduleEvent(EVENT_SVALA_TALK8, 13000);
					break;
				case EVENT_SVALA_TALK8:
					me->GetMotionMaster()->MoveFall(0, true);
					events2.ScheduleEvent(EVENT_SVALA_TALK9, 2000);
					break;
				case EVENT_SVALA_TALK9:
					me->SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 3.0f);
					me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC|UNIT_FLAG_IMMUNE_TO_NPC);
					me->LoadEquipment(1, true);
					me->setActive(false);
					if (Player* target = SelectTargetFromPlayerList(100.0f))
						AttackStart(target);
					return;
			}

			if (!UpdateVictim())
				return;

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

			switch (events.ExecuteEvent())
			{
				case EVENT_SORROWGRAVE_SS:
					me->CastSpell(me->GetVictim(), IsHeroic() ? SPELL_SINSTER_STRIKE_H : SPELL_SINSTER_STRIKE_N, false);
					events.ScheduleEvent(EVENT_SORROWGRAVE_SS, urand(3000, 5000));
					break;
				case EVENT_SORROWGRAVE_FLAMES:
					summons.DespawnAll();
					me->CastSpell(me, SPELL_CALL_FLAMES, false);
					events.ScheduleEvent(EVENT_SORROWGRAVE_FLAMES2, 500);
					events.ScheduleEvent(EVENT_SORROWGRAVE_FLAMES2, 1000);
					events.ScheduleEvent(EVENT_SORROWGRAVE_FLAMES, urand(8000, 12000));
					break;
				case EVENT_SORROWGRAVE_FLAMES2:
				{
					std::list<Creature*> braziers;
					me->GetCreaturesWithEntryInRange(braziers, 100.0f, NPC_FLAME_BRAZIER);
					if (!braziers.empty())
					{
						for (std::list<Creature*>::const_iterator itr = braziers.begin(); itr != braziers.end(); ++itr)
							(*itr)->CastCustomSpell(SPELL_BALL_OF_FLAME, SPELLVALUE_MAX_TARGETS, 1, (*itr), true);
					}
					break;
				}
				case EVENT_SORROWGRAVE_RITUAL:
					if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
            		{
						Talk(SAY_SACRIFICE_PLAYER);

						for (uint8 i = 0; i < 3; ++i)
							if (Creature* cr = me->SummonCreature(NPC_RITUAL_CHANNELER, RitualChannelerLoc[i], TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 360000))
								cr->AI()->AttackStart(target);

						me->GetMotionMaster()->MoveIdle();
						DoTeleportPlayer(target, 296.632f, -346.075f, 90.63f, 4.6f);
						me->NearTeleportTo(296.632f, -346.075f, 110.0f, 4.6f, false);
						me->SetControlled(true, UNIT_STATE_ROOT);
						me->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE);
						me->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE_PERCENT);
						me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
					}

					events.DelayEvents(25001); // +1 just to be sure
					events.ScheduleEvent(EVENT_SORROWGRAVE_RITUAL_SPELLS, 0);
					events.ScheduleEvent(EVENT_SORROWGRAVE_FINISH_RITUAL, 25000);
					return;
				case EVENT_SORROWGRAVE_RITUAL_SPELLS:
					//me->CastSpell(me, SPELL_RITUAL_OF_THE_SWORD, false);
					me->CastSpell(me, SPELL_RITUAL_STRIKE, true);
					return;
				case EVENT_SORROWGRAVE_FINISH_RITUAL:
					me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
					me->SetControlled(false, UNIT_STATE_ROOT);
					AttackStart(me->GetVictim());
					me->GetMotionMaster()->MoveFall(0, true);
					summons.DespawnAll();
					break;
			}

			DoMeleeAttackIfReady();
		}
Example #11
0
 void KilledUnit(Unit *victim)
 {
     DoScriptText(rand()%2 ? SAY_SLAY1 : SAY_SLAY2, m_creature);
     events.DelayEvents(5000, GCD_YELL);
 }
Example #12
0
        void UpdateAI(uint32 diff)
        {
            if (!UpdateVictim())
                return;

            events.Update(diff);
            switch (events.GetEvent())
            {
                case EVENT_CHECK:
                    float x, y, z, o;
                    me->GetHomePosition(x, y, z, o);
                    if (!me->IsWithinDist3d(x, y, z, 60))
                    {
                        EnterEvadeMode();
                        return;
                    }
                    events.RepeatEvent(5000);
                    break;
                case EVENT_SPELL_SPORES:
                    me->CastSpell(me, SPELL_SUMMON_SPORE_STRIDER, false);
                    events.RepeatEvent(urand(10000, 15000));
                    break;
                case EVENT_SPELL_CHAIN:
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                        me->CastSpell(target, SPELL_CHAIN_LIGHTNING, false);
                    events.DelayEvents(3000);
                    events.RepeatEvent(9000);
                    break;
                case EVENT_SPELL_STATIC:
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 30, true))
                        me->CastSpell(target, SPELL_STATIC_CHARGE, false);
                    events.RepeatEvent(10000);
                    break;
                case EVENT_LEVITATE:
                    events.RepeatEvent(15000);
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1))
                    {
                        me->CastSpell(target, SPELL_LEVITATE, false);
                        lTarget = target->GetGUID();
                        events.DelayEvents(5000);
                        events.ScheduleEvent(EVENT_LEVITATE_TARGET_1, 2000);
                    }
                    break;
                case EVENT_LEVITATE_TARGET_1:
                    if (Unit* target = ObjectAccessor::GetUnit(*me, lTarget))
                    {
                        if (!target->HasAura(SPELL_LEVITATE))
                            lTarget = 0;
                        else
                        {
                            target->CastSpell(target, SPELL_MAGNETIC_PULL, true);
                            events.ScheduleEvent(EVENT_LEVITATE_TARGET_2, 1500);
                        }
                    }
                    events.PopEvent();
                    break;
                case EVENT_LEVITATE_TARGET_2:
                    if (Unit* target = ObjectAccessor::GetUnit(*me, lTarget))
                    {
                        if (!target->HasAura(SPELL_LEVITATE))
                            lTarget = 0;
                        else
                        {
                            target->AddAura(SPELL_SUSPENSION, target);
                            lTarget = 0;
                        }
                    }
                    events.PopEvent();
                    break;
            }

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

		if(phase == 2 && boss_phase == 1)
		{
			events.RescheduleEvent(EVENT_CHAIN_LIGHTNING, urand(9000,17000));
			events.RescheduleEvent(EVENT_OVERLOAD, urand(60000,125000));
            events.RescheduleEvent(EVENT_LIGHTNING_WHIRL, urand(20000,40000));
			boss_phase++;

		}
		if(phase == 3 && boss_phase == 2)
		{
			events.RescheduleEvent(EVENT_CHAIN_LIGHTNING, urand(9000,17000));
			events.RescheduleEvent(EVENT_OVERLOAD, urand(60000,125000));
            events.RescheduleEvent(EVENT_LIGHTNING_WHIRL, urand(20000,40000));
			DoCast(me, SPELL_STORMSHIELD);
            events.RescheduleEvent(EVENT_LIGHTNING_TENDRILS, urand(40000,80000));
        }

        events.Update(diff);
		if(!me->HasAura(SPELL_OVERLOAD) && overload == true) 
		{
			DoCast(63480);
			overload = false;
		}

        while (uint32 eventId = events.ExecuteEvent())
        {
            switch(eventId)
            {
                case EVENT_ENRAGE:
                    DoScriptText(SAY_BRUNDIR_BERSERK, me);
                    DoCast(SPELL_BERSERK);
                    break;
                case EVENT_CHAIN_LIGHTNING:
                    if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM,0))
                        DoCast(pTarget, RAID_MODE(SPELL_CHAIN_LIGHTNING_N , SPELL_CHAIN_LIGHTNING_H));
                    events.ScheduleEvent(EVENT_CHAIN_LIGHTNING, urand(9000,17000));
                    break;
                case EVENT_OVERLOAD:
                    DoCast(SPELL_OVERLOAD);
					overload = true;
					events.ScheduleEvent(EVENT_OVERLOAD, urand(60000,125000));
                    break;
                case EVENT_LIGHTNING_WHIRL:
                    DoCast(RAID_MODE(SPELL_LIGHTNING_WHIRL , SPELL_LIGHTNING_WHIRL_H));
					DoCast(RAID_MODE(61916, 63482));
                    events.ScheduleEvent(EVENT_LIGHTNING_WHIRL, urand(20000,40000));
                    break;
                case EVENT_LIGHTNING_TENDRILS:
                    DoCast(RAID_MODE(SPELL_LIGHTNING_TENDRILS, SPELL_LIGHTNING_TENDRILS_H));
					DoCast(RAID_MODE(61886, 63485));
                    events.DelayEvents(15000, 5000);
                    DoResetThreat();
                    break;
            }
        }

        DoMeleeAttackIfReady();
    }
Example #14
0
        void UpdateAI(const uint32 diff)
        {
            if (!me->isInCombat())
                return;

            if (!me->getVictim() && me->getThreatManager().isThreatListEmpty())
            {
                EnterEvadeMode();
                return;
            }

            events.Update(diff);

            if (me->hasUnitState(UNIT_STAT_CASTING))
                return;

            switch(events.ExecuteEvent())
            {
                case EVENT_PURSUE:
                    if (Creature* pKrick = GetKrick())
                        DoScriptText(RAND(SAY_KRICK_CHASE_1,SAY_KRICK_CHASE_2,SAY_KRICK_CHASE_3), pKrick);

                    if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                    {
                        me->Attack(pTarget,false);
                        DoScriptText(SAY_ICK_CHASE_1, me, pTarget);
                        DoCast(pTarget, SPELL_PURSUED);
                    }

                    DoCast(SPELL_CONFUSION);
                    events.ScheduleEvent(EVENT_PURSUE, 30000, GCD_1);
                    return;

                case EVENT_MIGHTY_KICK:
                    DoCast(me->getVictim(), SPELL_MIGHTY_KICK);
                    events.ScheduleEvent(EVENT_MIGHTY_KICK, 25000, GCD_1);
                    return;

                case EVENT_POISON_NOVA:
                    if (Creature* pKrick = GetKrick())
                        DoScriptText(SAY_KRICK_POISON_NOVA, pKrick);

                    DoScriptText(SAY_ICK_POISON_NOVA, me);
                    DoCastAOE(SPELL_POISON_NOVA);
                    events.ScheduleEvent(EVENT_POISON_NOVA, 30000, GCD_1);
                    return;

                case EVENT_TOXIC_WASTE:
                    DoCast(me->getVictim(), SPELL_TOXIC_WASTE);
                    events.ScheduleEvent(EVENT_TOXIC_WASTE, 5000);
                    return;

                case EVENT_SHADOW_BOLT:
                    DoCast(me->getVictim(), SPELL_SHADOW_BOLT);
                    events.ScheduleEvent(EVENT_SHADOW_BOLT, 15000);
                    return;

                case EVENT_EXPLOSIVE_BARRAGE:
                    if (Creature *pKrick = GetKrick())
                    {
                        DoScriptText(SAY_KRICK_BARRAGE_1, pKrick);
                        DoScriptText(SAY_KRICK_BARRAGE_2, pKrick);
                    }

                    DoCastAOE(SPELL_EXPLOSIVE_BARRAGE);
                    me->GetMotionMaster()->MoveIdle();
                    events.DelayEvents(20000, GCD_1); // 2 sec cast + 18 sec
                    events.ScheduleEvent(EVENT_END_EXPLOSIVE_BARRAGE, 20000);
                    return;

                case EVENT_END_EXPLOSIVE_BARRAGE:
                    me->GetMotionMaster()->Clear();
                    me->GetMotionMaster()->MoveChase(me->getVictim());
                    events.ScheduleEvent(EVENT_EXPLOSIVE_BARRAGE, 25000);
                    break;
            }

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

				events.Update(diff);
				switch (events.ExecuteEvent())
				{
					case EVENT_SMITE_SLAM:
						me->CastSpell(me->GetVictim(), SPELL_SMITE_SLAM, false);
						events.ScheduleEvent(EVENT_SMITE_SLAM, 15000);
						break;
					case EVENT_CHECK_HEALTH1:
						if (me->HealthBelowPct(67))
						{
							me->CastSpell(me, SPELL_SMITE_STOMP, false);
							events.DelayEvents(10000);
							me->GetMotionMaster()->Clear();
							me->GetMotionMaster()->MovePoint(EQUIP_TWO_SWORDS, 1.859f, -780.72f, 9.831f);
							Talk(SAY_SWAP1);
							me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
							me->SetReactState(REACT_PASSIVE);
							break;
						}
						events.ScheduleEvent(EVENT_CHECK_HEALTH1, 500);
						break;
					case EVENT_CHECK_HEALTH2:
						if (me->HealthBelowPct(34))
						{
							me->CastSpell(me, SPELL_SMITE_STOMP, false);
							events.DelayEvents(10000);
							me->GetMotionMaster()->Clear();
							me->GetMotionMaster()->MovePoint(EQUIP_MACE, 1.859f, -780.72f, 9.831f);
							Talk(SAY_SWAP2);
							me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
							me->SetReactState(REACT_PASSIVE);
							break;
						}
						events.ScheduleEvent(EVENT_CHECK_HEALTH2, 500);
						break;
					case EVENT_SWAP_WEAPON1:
						me->LoadEquipment(EQUIP_TWO_SWORDS);
						me->SetCanDualWield(true);
						break;
					case EVENT_SWAP_WEAPON2:
						me->LoadEquipment(EQUIP_MACE);
						me->SetCanDualWield(false);
						break;
					case EVENT_RESTORE_COMBAT:
						me->SetReactState(REACT_AGGRESSIVE);
						me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
						me->SetStandState(UNIT_STAND_STATE_STAND);
						if (me->GetVictim())
						{
							me->GetMotionMaster()->MoveChase(me->GetVictim());
							me->SetTarget(me->GetVictim()->GetGUID());
						}
						break;
					case EVENT_KNEEL:
						me->SendMeleeAttackStop(me->GetVictim());
						me->SetStandState(UNIT_STAND_STATE_KNEEL);
						break;
				}

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

            events.Update(diff);

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

            while (uint32 eventId = events.ExecuteEvent())
            {
                switch(eventId)
                {
                    case EVENT_ENRAGE:
                        DoScriptText(SAY_BRUNDIR_BERSERK, me);
                        DoCast(SPELL_BERSERK);
                        break;
                    case EVENT_PULSE:
                        if (me->getVictim() && me->getVictim()->ToPlayer())
                            DoAttackerGroupInCombat(me->getVictim()->ToPlayer());
                        events.ScheduleEvent(EVENT_PULSE, 5000);
                        break;
                    case EVENT_CHAIN_LIGHTNING:
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
                            DoCast(target, RAID_MODE(SPELL_CHAIN_LIGHTNING_N, SPELL_CHAIN_LIGHTNING_H));
                        events.ScheduleEvent(EVENT_CHAIN_LIGHTNING, urand(3000, 5000), 1);
                        break;
                    case EVENT_OVERLOAD:
                        DoCast(RAID_MODE(SPELL_OVERLOAD, SPELL_OVERLOAD_H));
                        events.ScheduleEvent(EVENT_OVERLOAD, urand(60000, 80000), 1);
                        break;
                    case EVENT_LIGHTNING_WHIRL:
                        DoCast(RAID_MODE(SPELL_LIGHTNING_WHIRL, SPELL_LIGHTNING_WHIRL_H));
                        events.ScheduleEvent(EVENT_LIGHTNING_WHIRL, urand(20000, 40000), 1);
                        break;
                    case EVENT_THREAT_WIPE:
                        DoResetThreat();
                        events.ScheduleEvent(EVENT_THREAT_WIPE, 5000);
                        break;
                    case EVENT_LIGHTNING_TENDRILS_START:
                        me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
                        me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true);
                        DoCast(RAID_MODE(SPELL_LIGHTNING_TENDRILS, SPELL_LIGHTNING_TENDRILS_H));
                        me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
                        me->SendMovementFlagUpdate();
                        events.DelayEvents(35000, 1);
                        events.ScheduleEvent(EVENT_LIGHTNING_TENDRILS_END, 30000);
                        events.ScheduleEvent(EVENT_THREAT_WIPE, 0);
                        break;
                    case EVENT_LIGHTNING_TENDRILS_END:
                        me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, false);
                        me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, false);
                        me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
                        me->SendMovementFlagUpdate();
                        me->RemoveAurasDueToSpell(RAID_MODE(SPELL_LIGHTNING_TENDRILS, SPELL_LIGHTNING_TENDRILS_H));
                        events.ScheduleEvent(EVENT_LIGHTNING_TENDRILS_START, urand(40000, 80000));
                        events.CancelEvent(EVENT_THREAT_WIPE);
                        break;
                }
            }

            if (!me->HasAura(RAID_MODE(SPELL_LIGHTNING_TENDRILS, SPELL_LIGHTNING_TENDRILS_H)))
                DoMeleeAttackIfReady();
        }
            void UpdateAI(uint32 diff)
            {
                if (!pInstance || !UpdateVictim())
                    return;

                events.Update(diff);

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

                if (me->GetVictim())
                    if (me->GetVictim()->GetDistance2d(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY()) > 55.0f)
                    {
                        DoCastVictim(SPELL_LIGHTNING_BLAST);
                        return;
                    }

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                    case EVENT_CHILLING_BREATH:
                        if (Unit* target  = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
                            DoCast(target, SPELL_CHILLING_BREATH);
                        events.ScheduleEvent(EVENT_CHILLING_BREATH, urand(10000, 16000));
                        break;
                    case EVENT_RESET_WIND:
                        if (_aircurrent)
                            _aircurrent->DespawnOrUnsummon();
                        events.DelayEvents(1000);
                        events.ScheduleEvent(EVENT_CALL_OF_WIND, 800);
                        break;
                    case EVENT_CALL_OF_WIND:
                        _aircurrent = me->SummonCreature(NPC_AIR_CURRENT,
                            me->GetPositionX(),
                            me->GetPositionY(),
                            me->GetPositionZ(),
                            orientations[urand(0, 3)]);
                        events.ScheduleEvent(EVENT_RESET_WIND, 18000);
                        break;
                    case EVENT_CHECK_FACING:
                        if (me->GetMap()->GetPlayers().isEmpty() || !_aircurrent)
                            break;

                        for (Map::PlayerList::const_iterator itr = me->GetMap()->GetPlayers().begin(); itr != me->GetMap()->GetPlayers().end(); ++itr) 
                        {
                            if (CheckOrientation(itr->GetSource()->GetOrientation(), _aircurrent->GetOrientation()))
                            {
                                itr->GetSource()->RemoveAurasDueToSpell(SPELL_DOWNWIND_OF_ALTAIRUS);
                                me->AddAura(SPELL_UPWIND_OF_ALTAIRUS, itr->GetSource());
                            }
                            else
                            {
                                itr->GetSource()->RemoveAurasDueToSpell(SPELL_UPWIND_OF_ALTAIRUS);
                                me->AddAura(SPELL_DOWNWIND_OF_ALTAIRUS, itr->GetSource());
                            }
                        }
                        events.ScheduleEvent(EVENT_CHECK_FACING, 3000);
                        break;
                    }
                }
                DoMeleeAttackIfReady();
            }
Example #18
0
void npc_unworthy_initiateAI::UpdateAI(const uint32 diff)
{
    switch(phase)
    {
    case PHASE_CHAINED:
        if (!anchorGUID)
        {
            if (Creature *anchor = me->FindNearestCreature(29521, 30))
            {
                anchor->AI()->SetGUID(me->GetGUID());
                anchor->CastSpell(me, SPELL_SOUL_PRISON_CHAIN, true);
                anchorGUID = anchor->GetGUID();
            }
            else
                error_log("npc_unworthy_initiateAI: unable to find anchor!");

            float dist = 99.0f;
            GameObject *prison = NULL;

            for (uint8 i = 0; i < 12; ++i)
            {
                if (GameObject* temp_prison = me->FindNearestGameObject(acherus_soul_prison[i],30))
                {
                    if (me->IsWithinDist(temp_prison, dist, false))
                    {
                        dist = me->GetDistance2d(temp_prison);
                        prison = temp_prison;
                    }
                }
            }

            if (prison)
                prison->ResetDoorOrButton();
            else
                error_log("npc_unworthy_initiateAI: unable to find prison!");
        }
        return;
    case PHASE_TO_EQUIP:
        if (wait_timer)
        {
            if (wait_timer > diff)
                wait_timer -= diff;
            else
            {
                me->GetMotionMaster()->MovePoint(1, anchorX, anchorY, me->GetPositionZ());
                //debug_log("npc_unworthy_initiateAI: move to %f %f %f", anchorX, anchorY, me->GetPositionZ());
                phase = PHASE_EQUIPING;
                wait_timer = 0;
            }
        }
        return;
    case PHASE_TO_ATTACK:
        if (wait_timer)
        {
            if (wait_timer > diff)
                wait_timer -= diff;
            else
            {
                me->setFaction(14);
                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
                phase = PHASE_ATTACKING;

                if (Player *pTarget = Unit::GetPlayer(playerGUID))
                    me->AI()->AttackStart(pTarget);
                wait_timer = 0;
            }
        }
        return;
    case PHASE_ATTACKING:
        if (!UpdateVictim())
            return;

        events.Update(diff);

        while (uint32 eventId = events.ExecuteEvent())
        {
            switch(eventId)
            {
            case EVENT_ICY_TOUCH:
                DoCast(me->getVictim(), SPELL_ICY_TOUCH);
                events.DelayEvents(1000, GCD_CAST);
                events.ScheduleEvent(EVENT_ICY_TOUCH, 5000, GCD_CAST);
                break;
            case EVENT_PLAGUE_STRIKE:
                DoCast(me->getVictim(), SPELL_PLAGUE_STRIKE);
                events.DelayEvents(1000, GCD_CAST);
                events.ScheduleEvent(SPELL_PLAGUE_STRIKE, 5000, GCD_CAST);
                break;
            case EVENT_BLOOD_STRIKE:
                DoCast(me->getVictim(), SPELL_BLOOD_STRIKE);
                events.DelayEvents(1000, GCD_CAST);
                events.ScheduleEvent(EVENT_BLOOD_STRIKE, 5000, GCD_CAST);
                break;
            case EVENT_DEATH_COIL:
                DoCast(me->getVictim(), SPELL_DEATH_COIL);
                events.DelayEvents(1000, GCD_CAST);
                events.ScheduleEvent(EVENT_DEATH_COIL, 5000, GCD_CAST);
                break;
            }
        }

        DoMeleeAttackIfReady();
    }
}
Example #19
0
        void UpdateAI(uint32 diff)
        {
            if (!isActive)
            {
                IntroTimer += diff;
                if (IntroTimer > 5000 && IntroTimer < 10000)
                {
                    if (SelectTargetFromPlayerList(60))
                    {
                        Talk(SAY_INTRO_1);
                        IntroTimer = 10000;
                    }
                    else
                        IntroTimer = 0;
                }

                if (IntroTimer >= 30000 && IntroTimer < 40000)
                {
                    Talk(SAY_INTRO_2);
                    IntroTimer = 40000;
                }
                if (IntroTimer >= 60000)
                {
                    isActive = true;
                    if (m_pInstance)
                        m_pInstance->SetData(TYPE_LOKEN_INTRO, 1);

                    me->SetControlled(false, UNIT_STATE_STUNNED);
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);

                    if (Player* target = SelectTargetFromPlayerList(80))
                        AttackStart(target);
                }

                return;
            }

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

            events.Update(diff);

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

            switch (events.GetEvent())
            {
                case EVENT_CHECK_HEALTH:
                    if (HealthBelowPct(HealthCheck))
                    {
                        LokenSpeach(true);
                        HealthCheck -= 25;
                    }

                    events.RepeatEvent(1000);
                    break;
                case EVENT_LIGHTNING_NOVA:
                    events.RepeatEvent(15000);
                    me->CastSpell(me, SPELL_LIGHTNING_NOVA_VISUAL, true);
                    me->CastSpell(me, SPELL_LIGHTNING_NOVA_THUNDERS, true);

                    events.DelayEvents(5001);
                    events.ScheduleEvent(EVENT_AURA_REMOVE, me->GetMap()->IsHeroic() ? 4000 : 5000);

                    me->CastSpell(me, me->GetMap()->IsHeroic() ? SPELL_LIGHTNING_NOVA_H : SPELL_LIGHTNING_NOVA_N, false);
                    break;
                case EVENT_SHOCKWAVE:
                    me->CastSpell(me, me->GetMap()->IsHeroic() ? SPELL_PULSING_SHOCKWAVE_H : SPELL_PULSING_SHOCKWAVE_N, false);
                    events.PopEvent();
                    break;
                case EVENT_ARC_LIGHTNING:
                    if (Unit* target = SelectTargetFromPlayerList(100, SPELL_ARC_LIGHTNING))
                        me->CastSpell(target, SPELL_ARC_LIGHTNING, false);

                    events.RepeatEvent(12000);
                    break;
                case EVENT_AURA_REMOVE:
                    me->RemoveAura(SPELL_LIGHTNING_NOVA_THUNDERS);
                    events.PopEvent();
                    break;
            }

            DoMeleeAttackIfReady();
        }