Beispiel #1
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 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();
        }