void UpdateAI(const uint32 diff) { if (nextWP && movementStarted && !movementCompleted && !nextMovementStarted) { nextMovementStarted = true; me->GetMotionMaster()->MovePoint(nextWP, WaypointPositions[nextWP]); } if (!UpdateVictim() || !CheckInRoom() || !movementCompleted) return; events.Update(diff); if (me->HasUnitState(UNIT_STATE_CASTING)) return; while (uint32 eventId = events.ExecuteEvent()) { switch (eventId) { case EVENT_MARK: Talk(SAY_SPECIAL); DoCastAOE(SPELL_MARK[id]); events.ScheduleEvent(EVENT_MARK, 15000); break; case EVENT_CAST: Talk(SAY_TAUNT); if (caster) { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 45.0f)) DoCast(target, SPELL_PRIMARY(id)); } else DoCast(me->getVictim(), SPELL_PRIMARY(id)); events.ScheduleEvent(EVENT_CAST, 15000); break; case EVENT_BERSERK: Talk(SAY_SPECIAL); DoCast(me, EVENT_BERSERK); break; } } if (punishTimer <= diff) { if (doDelayPunish) { DoCastAOE(SPELL_PUNISH[id], true); doDelayPunish = false; } punishTimer = 2000; } else punishTimer -= diff; if (!caster) DoMeleeAttackIfReady(); else if ((!DoSpellAttackIfReady(SPELL_SECONDARY(id)) || !me->IsWithinLOSInMap(me->getVictim())) && movementCompleted && !doDelayPunish) doDelayPunish = true; }
void UpdateAI(const uint32 diff) { if (!UpdateVictim() || !CheckInRoom()) return; events.Update(diff); if (me->hasUnitState(UNIT_STAT_CASTING)) return; while(uint32 eventId = events.ExecuteEvent()) { switch(eventId) { case EVENT_MARK: if (!(rand()%5)) DoScriptText(SAY_SPECIAL[id], me); DoCastAOE(SPELL_MARK[id]); events.ScheduleEvent(EVENT_MARK, 15000); return; case EVENT_CAST: if (!(rand()%5)) DoScriptText(SAY_TAUNT[rand()%3][id], me); DoCast(SPELL_PRIMARY(id)); events.ScheduleEvent(EVENT_CAST, 15000); return; case EVENT_BERSERK: DoScriptText(SAY_SPECIAL[id], me); DoCast(me, EVENT_BERSERK); return; } } if (!caster) DoMeleeAttackIfReady(); else if (!DoSpellAttackIfReady(SPELL_SECONDARY(id))) DoCastAOE(SPELL_PUNISH[id]); }