public override void EnterCombat(Unit victim) { if (Spells.Empty()) { return; } int spell = (int)(RandomHelper.Rand32() % Spells.Count); uint count = 0; foreach (var id in Spells) { AISpellInfoType info = GetAISpellInfo(id, me.GetMap().GetDifficultyID()); if (info.condition == AICondition.Aggro) { me.CastSpell(victim, id, false); } else if (info.condition == AICondition.Combat) { uint cooldown = info.realCooldown; if (count == spell) { DoCast(Spells[spell]); cooldown += (uint)me.GetCurrentSpellCastTime(id); } _events.ScheduleEvent(id, cooldown); } } }
public override void UpdateAI(uint diff) { if (!UpdateVictim()) { return; } _events.Update(diff); if (me.GetVictim().HasBreakableByDamageCrowdControlAura(me)) { me.InterruptNonMeleeSpells(false); return; } if (me.HasUnitState(UnitState.Casting)) { return; } uint spellId = _events.ExecuteEvent(); if (spellId != 0) { DoCast(spellId); uint casttime = (uint)me.GetCurrentSpellCastTime(spellId); AISpellInfoType info = GetAISpellInfo(spellId, me.GetMap().GetDifficultyID()); _events.ScheduleEvent(spellId, (casttime != 0 ? casttime : 500) + info.realCooldown); } }
public override void InitializeAI() { base.InitializeAI(); _attackDist = 30.0f; foreach (var id in Spells) { AISpellInfoType info = GetAISpellInfo(id, me.GetMap().GetDifficultyID()); if (info.condition == AICondition.Combat && _attackDist > info.maxRange) { _attackDist = info.maxRange; } } if (_attackDist == 30.0f) { _attackDist = SharedConst.MeleeRange; } }