Core/Creatures: Moved autoattack handling from scripts to game

Port From (https://github.com/TrinityCore/TrinityCore/commit/605e5f94c0d71cad8e83fa5a07eaec4e6bed9cc3)
This commit is contained in:
hondacrx
2024-02-05 18:18:30 -05:00
parent aa696fb176
commit 437fe2d8fd
94 changed files with 192 additions and 358 deletions
+4 -10
View File
@@ -71,8 +71,6 @@ namespace Game.AI
if (info != null) if (info != null)
_events.ScheduleEvent(spellId, info.cooldown, info.cooldown * 2); _events.ScheduleEvent(spellId, info.cooldown, info.cooldown * 2);
} }
else
DoMeleeAttackIfReady();
} }
public override void SpellInterrupted(uint spellId, uint unTimeMs) public override void SpellInterrupted(uint spellId, uint unTimeMs)
@@ -87,10 +85,7 @@ namespace Game.AI
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
{ {
if (!UpdateVictim()) UpdateVictim();
return;
DoMeleeAttackIfReady();
} }
} }
@@ -193,6 +188,7 @@ namespace Game.AI
_minRange = spellInfo != null ? spellInfo.GetMinRange(false) : 0; _minRange = spellInfo != null ? spellInfo.GetMinRange(false) : 0;
creature.m_CombatDistance = spellInfo != null ? spellInfo.GetMaxRange(false) : 0; creature.m_CombatDistance = spellInfo != null ? spellInfo.GetMaxRange(false) : 0;
creature.m_SightDistance = creature.m_CombatDistance; creature.m_SightDistance = creature.m_CombatDistance;
creature.SetCanMelee(false);
} }
public override bool CanAIAttack(Unit victim) public override bool CanAIAttack(Unit victim)
@@ -234,6 +230,7 @@ namespace Game.AI
LoadConditions(); LoadConditions();
_doDismiss = false; _doDismiss = false;
_dismissTimer = VEHICLE_DISMISS_TIME; _dismissTimer = VEHICLE_DISMISS_TIME;
me.SetCanMelee(false);
} }
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
@@ -315,10 +312,7 @@ namespace Game.AI
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
{ {
if (!UpdateVictim()) UpdateVictim();
return;
DoMeleeAttackIfReady();
} }
} }
} }
+1 -4
View File
@@ -12,10 +12,7 @@ namespace Game.AI
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
{ {
if (!UpdateVictim()) UpdateVictim();
return;
DoMeleeAttackIfReady();
} }
public override bool CanSeeAlways(WorldObject obj) public override bool CanSeeAlways(WorldObject obj)
+2 -3
View File
@@ -11,7 +11,8 @@ namespace Game.AI
{ {
public PassiveAI(Creature creature) : base(creature) public PassiveAI(Creature creature) : base(creature)
{ {
creature.SetReactState(ReactStates.Passive); me.SetReactState(ReactStates.Passive);
me.SetCanMelee(false);
} }
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
@@ -43,8 +44,6 @@ namespace Game.AI
{ {
if (!me.IsValidAttackTarget(me.GetVictim())) if (!me.IsValidAttackTarget(me.GetVictim()))
me.AttackStop(); me.AttackStop();
else
DoMeleeAttackIfReady();
} }
} }
-9
View File
@@ -50,15 +50,6 @@ namespace Game.AI
StopAttack(); StopAttack();
return; return;
} }
// Check before attacking to prevent pets from leaving stay position
if (me.GetCharmInfo().HasCommandState(CommandStates.Stay))
{
if (me.GetCharmInfo().IsCommandAttack() || (me.GetCharmInfo().IsAtStay() && me.IsWithinMeleeRange(me.GetVictim())))
DoMeleeAttackIfReady();
}
else
DoMeleeAttackIfReady();
} }
else else
{ {
-35
View File
@@ -52,41 +52,6 @@ namespace Game.AI
targets.Sort(new ObjectDistanceOrderPred(me, ascending)); targets.Sort(new ObjectDistanceOrderPred(me, ascending));
} }
public void DoMeleeAttackIfReady()
{
if (me.IsCreature() && !me.ToCreature().CanMelee())
return;
if (me.HasUnitState(UnitState.Casting))
{
Spell channeledSpell = me.GetCurrentSpell(CurrentSpellTypes.Channeled);
if (channeledSpell == null || !channeledSpell.GetSpellInfo().HasAttribute(SpellAttr5.AllowActionsDuringChannel))
return;
}
Unit victim = me.GetVictim();
if (!me.IsWithinMeleeRange(victim))
return;
// Check that the victim is in front of the unit
if (!me.HasInArc(2 * MathF.PI / 3, victim))
return;
//Make sure our attack is ready and we aren't currently casting before checking distance
if (me.IsAttackReady())
{
me.AttackerStateUpdate(victim);
me.ResetAttackTimer();
}
if (me.HaveOffhandWeapon() && me.IsAttackReady(WeaponAttackType.OffAttack))
{
me.AttackerStateUpdate(victim, WeaponAttackType.OffAttack);
me.ResetAttackTimer(WeaponAttackType.OffAttack);
}
}
public bool DoSpellAttackIfReady(uint spellId) public bool DoSpellAttackIfReady(uint spellId)
{ {
if (me.HasUnitState(UnitState.Casting) || !me.IsAttackReady()) if (me.HasUnitState(UnitState.Casting) || !me.IsAttackReady())
-2
View File
@@ -573,8 +573,6 @@ namespace Game.AI
{ {
if (IsRangedAttacker()) if (IsRangedAttacker())
DoRangedAttackIfReady(); DoRangedAttackIfReady();
else
DoMeleeAttackIfReady();
} }
public void CancelAllShapeshifts() public void CancelAllShapeshifts()
+1 -8
View File
@@ -45,10 +45,7 @@ namespace Game.AI
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
{ {
//Check if we have a current target //Check if we have a current target
if (!UpdateVictim()) UpdateVictim();
return;
DoMeleeAttackIfReady();
} }
//Start movement toward victim //Start movement toward victim
@@ -655,8 +652,6 @@ namespace Game.AI
if (me.HasUnitState(UnitState.Casting)) if (me.HasUnitState(UnitState.Casting))
return; return;
}); });
DoMeleeAttackIfReady();
} }
public void _DespawnAtEvade() public void _DespawnAtEvade()
@@ -766,8 +761,6 @@ namespace Game.AI
if (me.HasUnitState(UnitState.Casting)) if (me.HasUnitState(UnitState.Casting))
return; return;
}); });
DoMeleeAttackIfReady();
} }
// Hook used to execute events scheduled into EventMap without the need // Hook used to execute events scheduled into EventMap without the need
@@ -261,10 +261,7 @@ namespace Game.AI
public virtual void UpdateEscortAI(uint diff) public virtual void UpdateEscortAI(uint diff)
{ {
if (!UpdateVictim()) UpdateVictim();
return;
DoMeleeAttackIfReady();
} }
public override void MovementInform(MovementGeneratorType moveType, uint Id) public override void MovementInform(MovementGeneratorType moveType, uint Id)
@@ -158,10 +158,7 @@ namespace Game.AI
void UpdateFollowerAI(uint diff) void UpdateFollowerAI(uint diff)
{ {
if (!UpdateVictim()) UpdateVictim();
return;
DoMeleeAttackIfReady();
} }
public void StartFollow(Player player, uint factionForFollower = 0, Quest quest = null) public void StartFollow(Player player, uint factionForFollower = 0, Quest quest = null)
+1 -9
View File
@@ -310,21 +310,13 @@ namespace Game.AI
CheckConditions(diff); CheckConditions(diff);
bool hasVictim = UpdateVictim(); UpdateVictim();
GetScript().OnUpdate(diff); GetScript().OnUpdate(diff);
UpdatePath(diff); UpdatePath(diff);
UpdateFollow(diff); UpdateFollow(diff);
UpdateDespawn(diff); UpdateDespawn(diff);
if (!IsAIControlled())
return;
if (!hasVictim)
return;
DoMeleeAttackIfReady();
} }
bool IsEscortInvokerInRange() bool IsEscortInvokerInRange()
@@ -554,6 +554,10 @@ namespace Game.Entities
AIUpdateTick(diff); AIUpdateTick(diff);
DoMeleeAttackIfReady();
// creature can be dead after UpdateAI call
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
if (!IsAlive()) if (!IsAlive())
break; break;
+1 -1
View File
@@ -144,7 +144,7 @@ namespace Game.Entities
uint m_titanGripPenaltySpellId; uint m_titanGripPenaltySpellId;
uint m_deathTimer; uint m_deathTimer;
long m_deathExpireTime; long m_deathExpireTime;
byte m_swingErrorMsg; AttackSwingErr? m_swingErrorMsg;
DateTime m_regenInterruptTimestamp; DateTime m_regenInterruptTimestamp;
uint m_regenTimerCount; uint m_regenTimerCount;
uint m_foodEmoteTimerCount; uint m_foodEmoteTimerCount;
+14 -68
View File
@@ -421,69 +421,7 @@ namespace Game.Entities
m_achievementSys.UpdateTimedCriteria(TimeSpan.FromMilliseconds(diff)); m_achievementSys.UpdateTimedCriteria(TimeSpan.FromMilliseconds(diff));
if (HasUnitState(UnitState.MeleeAttacking) && !HasUnitState(UnitState.Casting | UnitState.Charging)) DoMeleeAttackIfReady();
{
Unit victim = GetVictim();
if (victim != null)
{
// default combat reach 10
// TODO add weapon, skill check
if (IsAttackReady(WeaponAttackType.BaseAttack))
{
if (!IsWithinMeleeRange(victim))
{
SetAttackTimer(WeaponAttackType.BaseAttack, 100);
if (m_swingErrorMsg != 1) // send single time (client auto repeat)
{
SendAttackSwingNotInRange();
m_swingErrorMsg = 1;
}
}
//120 degrees of radiant range, if player is not in boundary radius
else if (!IsWithinBoundaryRadius(victim) && !HasInArc(2 * MathFunctions.PI / 3, victim))
{
SetAttackTimer(WeaponAttackType.BaseAttack, 100);
if (m_swingErrorMsg != 2) // send single time (client auto repeat)
{
SendAttackSwingBadFacingAttack();
m_swingErrorMsg = 2;
}
}
else
{
m_swingErrorMsg = 0; // reset swing error state
// prevent base and off attack in same time, delay attack at 0.2 sec
if (HaveOffhandWeapon())
if (GetAttackTimer(WeaponAttackType.OffAttack) < SharedConst.AttackDisplayDelay)
SetAttackTimer(WeaponAttackType.OffAttack, SharedConst.AttackDisplayDelay);
// do attack
AttackerStateUpdate(victim, WeaponAttackType.BaseAttack);
ResetAttackTimer(WeaponAttackType.BaseAttack);
}
}
if (!IsInFeralForm() && HaveOffhandWeapon() && IsAttackReady(WeaponAttackType.OffAttack))
{
if (!IsWithinMeleeRange(victim))
SetAttackTimer(WeaponAttackType.OffAttack, 100);
else if (!IsWithinBoundaryRadius(victim) && !HasInArc(2 * MathFunctions.PI / 3, victim))
SetAttackTimer(WeaponAttackType.BaseAttack, 100);
else
{
// prevent base and off attack in same time, delay attack at 0.2 sec
if (GetAttackTimer(WeaponAttackType.BaseAttack) < SharedConst.AttackDisplayDelay)
SetAttackTimer(WeaponAttackType.BaseAttack, SharedConst.AttackDisplayDelay);
// do attack
AttackerStateUpdate(victim, WeaponAttackType.OffAttack);
ResetAttackTimer(WeaponAttackType.OffAttack);
}
}
}
}
if (HasPlayerFlag(PlayerFlags.Resting)) if (HasPlayerFlag(PlayerFlags.Resting))
_restMgr.Update(diff); _restMgr.Update(diff);
@@ -7707,11 +7645,19 @@ namespace Game.Entities
public bool CanTameExoticPets() { return IsGameMaster() || HasAuraType(AuraType.AllowTamePetType); } public bool CanTameExoticPets() { return IsGameMaster() || HasAuraType(AuraType.AllowTamePetType); }
void SendAttackSwingCantAttack() { SendPacket(new AttackSwingError(AttackSwingErr.CantAttack)); } public void SendAttackSwingCancelAttack()
public void SendAttackSwingCancelAttack() { SendPacket(new CancelCombat()); } {
void SendAttackSwingDeadTarget() { SendPacket(new AttackSwingError(AttackSwingErr.DeadTarget)); } SendPacket(new CancelCombat());
public void SendAttackSwingNotInRange() { SendPacket(new AttackSwingError(AttackSwingErr.NotInRange)); } }
void SendAttackSwingBadFacingAttack() { SendPacket(new AttackSwingError(AttackSwingErr.BadFacing)); }
public void SetAttackSwingError(AttackSwingErr? err)
{
if (err.HasValue && err.Value != m_swingErrorMsg)
SendPacket(new AttackSwingError(err.Value));
m_swingErrorMsg = err;
}
public void SendAutoRepeatCancel(Unit target) public void SendAutoRepeatCancel(Unit target)
{ {
CancelAutoRepeat cancelAutoRepeat = new(); CancelAutoRepeat cancelAutoRepeat = new();
+72 -11
View File
@@ -281,14 +281,8 @@ namespace Game.Entities
Creature creature = ToCreature(); Creature creature = ToCreature();
// creatures cannot attack while evading // creatures cannot attack while evading
if (creature != null) if (creature != null && creature.IsInEvadeMode())
{ return false;
if (creature.IsInEvadeMode())
return false;
if (creature.CanMelee())
meleeAttack = false;
}
// nobody can attack GM in GM-mode // nobody can attack GM in GM-mode
if (victim.IsTypeId(TypeId.Player)) if (victim.IsTypeId(TypeId.Player))
@@ -522,12 +516,15 @@ namespace Game.Entities
return m_baseAttackSpeed[(int)att]; return m_baseAttackSpeed[(int)att];
} }
public void AttackerStateUpdate(Unit victim, WeaponAttackType attType = WeaponAttackType.BaseAttack, bool extra = false) public void DoMeleeAttackIfReady()
{ {
if (HasUnitFlag(UnitFlags.Pacified)) if (!HasUnitState(UnitState.MeleeAttacking))
return; return;
if (HasUnitState(UnitState.CannotAutoattack) && !extra) if (HasUnitState(UnitState.Charging))
return;
if (IsCreature() && !ToCreature().CanMelee())
return; return;
if (HasUnitState(UnitState.Casting)) if (HasUnitState(UnitState.Casting))
@@ -537,6 +534,70 @@ namespace Game.Entities
return; return;
} }
Unit victim = GetVictim();
if (victim == null)
return;
AttackSwingErr? getAutoAttackError()
{
if (!IsWithinMeleeRange(victim))
return AttackSwingErr.NotInRange;
//120 degrees of radiant range, if player is not in boundary radius
if (!IsWithinBoundaryRadius(victim) && !HasInArc(2 * MathF.PI / 3, victim))
return AttackSwingErr.BadFacing;
return null;
};
if (IsAttackReady(WeaponAttackType.BaseAttack))
{
AttackSwingErr? autoAttackError = getAutoAttackError();
if (!autoAttackError.HasValue)
{
// prevent base and off attack in same time, delay attack at 0.2 sec
if (HaveOffhandWeapon())
if (GetAttackTimer(WeaponAttackType.OffAttack) < SharedConst.AttackDisplayDelay)
SetAttackTimer(WeaponAttackType.OffAttack, SharedConst.AttackDisplayDelay);
// do attack
AttackerStateUpdate(victim, WeaponAttackType.BaseAttack);
ResetAttackTimer(WeaponAttackType.BaseAttack);
}
else
SetAttackTimer(WeaponAttackType.BaseAttack, 100);
Player attackerPlayer = ToPlayer();
if (attackerPlayer != null)
attackerPlayer.SetAttackSwingError(autoAttackError);
}
if (!IsInFeralForm() && HaveOffhandWeapon() && IsAttackReady(WeaponAttackType.OffAttack))
{
AttackSwingErr? autoAttackError = getAutoAttackError();
if (!autoAttackError.HasValue)
{
// prevent base and off attack in same time, delay attack at 0.2 sec
if (GetAttackTimer(WeaponAttackType.BaseAttack) < SharedConst.AttackDisplayDelay)
SetAttackTimer(WeaponAttackType.BaseAttack, SharedConst.AttackDisplayDelay);
// do attack
AttackerStateUpdate(victim, WeaponAttackType.OffAttack);
ResetAttackTimer(WeaponAttackType.OffAttack);
}
else
SetAttackTimer(WeaponAttackType.OffAttack, 100);
}
}
public void AttackerStateUpdate(Unit victim, WeaponAttackType attType = WeaponAttackType.BaseAttack, bool extra = false)
{
if (HasUnitFlag(UnitFlags.Pacified))
return;
if (HasUnitState(UnitState.CannotAutoattack) && !extra)
return;
if (HasAuraType(AuraType.DisableAttackingExceptAbilities)) if (HasAuraType(AuraType.DisableAttackingExceptAbilities))
return; return;
@@ -1236,7 +1236,6 @@ namespace Game.Entities
case UnitState.Confused: case UnitState.Confused:
if (!HasUnitState(UnitState.Stunned)) if (!HasUnitState(UnitState.Stunned))
{ {
ClearUnitState(UnitState.MeleeAttacking);
SendMeleeAttackStop(); SendMeleeAttackStop();
// SendAutoRepeatCancel ? // SendAutoRepeatCancel ?
SetConfused(true); SetConfused(true);
@@ -1245,7 +1244,6 @@ namespace Game.Entities
case UnitState.Fleeing: case UnitState.Fleeing:
if (!HasUnitState(UnitState.Stunned | UnitState.Confused)) if (!HasUnitState(UnitState.Stunned | UnitState.Confused))
{ {
ClearUnitState(UnitState.MeleeAttacking);
SendMeleeAttackStop(); SendMeleeAttackStop();
// SendAutoRepeatCancel ? // SendAutoRepeatCancel ?
SetFeared(true); SetFeared(true);
+1 -1
View File
@@ -672,7 +672,7 @@ namespace Game.Entities
public void RemoveAllDynObjects() public void RemoveAllDynObjects()
{ {
while (!m_dynObj.Empty()) while (!m_dynObj.Empty())
m_dynObj.First().Remove(); m_dynObj.Last().Remove();
} }
public GameObject GetGameObject(uint spellId) public GameObject GetGameObject(uint spellId)
@@ -408,9 +408,7 @@ namespace Scripts.Argus.AntorusTheBurningThrone.Argus
}); });
if (me.GetVictim() != null && me.GetVictim().IsWithinMeleeRange(me)) if (me.GetVictim() == null && !me.GetVictim().IsWithinMeleeRange(me))
DoMeleeAttackIfReady();
else
DoSpellAttackIfReady(SpellIds.Carnage); DoSpellAttackIfReady(SpellIds.Carnage);
} }
-2
View File
@@ -538,8 +538,6 @@ namespace Scripts.BrokenIsles.ZoneMardum
if (me.HasUnitState(UnitState.Casting)) if (me.HasUnitState(UnitState.Casting))
return; return;
DoMeleeAttackIfReady();
} }
} }
@@ -144,7 +144,7 @@ namespace Scripts.DragonIsles.AzureVault.Leymor
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
{ {
_scheduler.Update(diff, DoMeleeAttackIfReady); _scheduler.Update(diff);
} }
} }
@@ -203,7 +203,7 @@ namespace Scripts.DragonIsles.AzureVault.Leymor
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, DoMeleeAttackIfReady); _scheduler.Update(diff);
} }
} }
@@ -131,10 +131,7 @@ namespace Scripts.EasternKingdoms.AlteracValley
_scheduler.Update(diff); _scheduler.Update(diff);
if (me.HasUnitState(UnitState.Casting)) if (me.HasUnitState(UnitState.Casting))
return; return;
DoMeleeAttackIfReady();
} }
} }
} }
@@ -141,8 +141,7 @@ namespace Scripts.EasternKingdoms.AlteracValley.Balinda
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -91,8 +91,7 @@ namespace Scripts.EasternKingdoms.AlteracValley.Drekthar
if (!UpdateVictim() || !CheckInRoom()) if (!UpdateVictim() || !CheckInRoom())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -92,8 +92,7 @@ namespace Scripts.EasternKingdoms.AlteracValley.Galvangar
if (!UpdateVictim() || !CheckInRoom()) if (!UpdateVictim() || !CheckInRoom())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -75,8 +75,7 @@ namespace Scripts.EasternKingdoms.AlteracValley.Vanndar
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -248,8 +248,6 @@ namespace Scripts.EasternKingdoms.BaradinHold.Alizabal
break; break;
} }
}); });
DoMeleeAttackIfReady();
} }
} }
} }
@@ -125,8 +125,6 @@ namespace Scripts.EasternKingdoms.BaradinHold.Occuthar
break; break;
} }
}); });
DoMeleeAttackIfReady();
} }
} }
@@ -70,7 +70,7 @@ namespace Scripts.EasternKingdoms.BaradinHold.PitLordArgaloth
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -66,7 +66,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockCaverns.AscendantLo
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -69,7 +69,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockCaverns.Beauty
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -78,8 +78,6 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockCaverns.Corla
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
{ {
_scheduler.Update(diff); _scheduler.Update(diff);
DoMeleeAttackIfReady();
} }
} }
} }
@@ -64,8 +64,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockCaverns.KarshSteelb
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -102,7 +102,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockCaverns.RomoggBonec
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -50,7 +50,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.AmbassadorFl
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -237,7 +237,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.CorenDirebre
if (!UpdateVictim() && phase != DirebrewPhases.Intro) if (!UpdateVictim() && phase != DirebrewPhases.Intro)
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -283,7 +283,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.CorenDirebre
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
{ {
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -513,5 +513,4 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.CorenDirebre
OnEffectApply.Add(new EffectApplyHandler(OnApply, 1, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); OnEffectApply.Add(new EffectApplyHandler(OnApply, 1, AuraType.PeriodicDummy, AuraEffectHandleModes.Real));
} }
} }
} }
@@ -79,7 +79,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.Draganthauri
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -93,7 +93,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.GeneralAnger
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -60,7 +60,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.HighInterrog
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -71,7 +71,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.Magmus
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
public override void JustDied(Unit killer) public override void JustDied(Unit killer)
@@ -189,7 +189,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.TombOfSeven
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
public override bool OnGossipSelect(Player player, uint menuId, uint gossipListId) public override bool OnGossipSelect(Player player, uint menuId, uint gossipListId)
@@ -61,7 +61,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.Drakkisath
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -61,7 +61,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.GizrulTheSlav
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -118,7 +118,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.Gyth
SummonedRend = true; SummonedRend = true;
} }
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -72,7 +72,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.Halycon
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -50,7 +50,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.HighlordOmokk
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -94,9 +94,6 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire
frenzy15 = true; frenzy15 = true;
} }
} }
DoMeleeAttackIfReady();
} }
} }
} }
@@ -58,8 +58,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.MotherSmolder
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -98,8 +98,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.OverlordWyrmt
} }
} }
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -214,8 +214,6 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.PyroguardEmbe
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
DoMeleeAttackIfReady();
} }
} }
@@ -261,7 +259,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.PyroguardEmbe
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -52,7 +52,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.Quartermaster
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -502,7 +502,6 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.RendBlackhand
if (me.HasUnitState(UnitState.Casting)) if (me.HasUnitState(UnitState.Casting))
return; return;
}); });
DoMeleeAttackIfReady();
} }
} }
} }
@@ -60,7 +60,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.ShadowHunterV
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -59,7 +59,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.Thebeast
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -59,7 +59,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.UrokDoomhowl
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -74,7 +74,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.WarmasterVoon
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -95,7 +95,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.Broodlord
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -156,8 +156,6 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair
Breath2_Spell = SpellIds.Igniteflesh; Breath2_Spell = SpellIds.Igniteflesh;
break; break;
} }
EnterEvadeMode();
} }
void Initialize() void Initialize()
@@ -243,8 +241,6 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair
DoCast(me, SpellIds.Enrage); DoCast(me, SpellIds.Enrage);
Enraged = true; Enraged = true;
} }
DoMeleeAttackIfReady();
} }
} }
@@ -46,7 +46,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.Ebonroc
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -48,7 +48,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.Firemaw
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -54,7 +54,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.Flamegor
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -570,9 +570,6 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.VictorNefarius
Phase3 = true; Phase3 = true;
Talk(TextIds.SayRaiseSkeletons); Talk(TextIds.SayRaiseSkeletons);
} }
DoMeleeAttackIfReady();
} }
} }
} }
@@ -123,7 +123,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.Razorgore
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -164,8 +164,6 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.Vaelastrasz
Talk(TextIds.SayHalflife); Talk(TextIds.SayHalflife);
HasYelled = true; HasYelled = true;
} }
DoMeleeAttackIfReady();
} }
public override bool OnGossipSelect(Player player, uint menuId, uint gossipListId) public override bool OnGossipSelect(Player player, uint menuId, uint gossipListId)
@@ -72,8 +72,6 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.BaronGeddon
if (me.HasUnitState(UnitState.Casting)) if (me.HasUnitState(UnitState.Casting))
return; return;
DoMeleeAttackIfReady();
} }
} }
@@ -49,7 +49,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Garr
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -110,7 +110,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Garr
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -51,7 +51,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Gehennas
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -70,7 +70,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Golemagg
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -120,7 +120,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Golemagg
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -46,7 +46,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Lucifron
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -63,7 +63,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Magmadar
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -103,8 +103,6 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Majordomo
if (HealthBelowPct(50)) if (HealthBelowPct(50))
DoCast(me, SpellIds.AegisOfRagnaros, new CastSpellExtraArgs(true)); DoCast(me, SpellIds.AegisOfRagnaros, new CastSpellExtraArgs(true));
DoMeleeAttackIfReady();
} }
} }
@@ -294,9 +294,6 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore
break; break;
} }
}); });
DoMeleeAttackIfReady();
} }
} }
} }
@@ -315,14 +312,6 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore
{ {
instance.SetData(MCMiscConst.DataRagnarosAdds, 1); instance.SetData(MCMiscConst.DataRagnarosAdds, 1);
} }
public override void UpdateAI(uint diff)
{
if (!UpdateVictim())
return;
DoMeleeAttackIfReady();
}
} }
} }
@@ -96,9 +96,6 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Shazzrah
if (me.HasUnitState(UnitState.Casting)) if (me.HasUnitState(UnitState.Casting))
return; return;
}); });
DoMeleeAttackIfReady();
} }
} }
@@ -72,7 +72,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Sulfuron
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -125,7 +125,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Sulfuron
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -175,8 +175,6 @@ namespace Scripts.EasternKingdoms.Deadmines
} }
else uiTimer -= uiDiff; else uiTimer -= uiDiff;
} }
DoMeleeAttackIfReady();
} }
public override void MovementInform(MovementGeneratorType uiType, uint uiId) public override void MovementInform(MovementGeneratorType uiType, uint uiId)
@@ -112,7 +112,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Curator
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
{ {
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
bool _infused; bool _infused;
@@ -81,7 +81,7 @@ namespace Scripts.EasternKingdoms.Karazhan.MaidenOfVirtue
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -206,7 +206,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Midnight
if (!UpdateVictim() && _phase != Phases.None) if (!UpdateVictim() && _phase != Phases.None)
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
public override void SpellHit(WorldObject caster, SpellInfo spellInfo) public override void SpellHit(WorldObject caster, SpellInfo spellInfo)
@@ -346,7 +346,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Midnight
if (!UpdateVictim() || _phase == Phases.Mounted) if (!UpdateVictim() || _phase == Phases.Mounted)
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -137,6 +137,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
_scheduler.Schedule(TimeSpan.FromSeconds(30), MiscConst.GroupNonEnrage, task => _scheduler.Schedule(TimeSpan.FromSeconds(30), MiscConst.GroupNonEnrage, task =>
{ {
DoCast(me, SpellIds.Vanish); DoCast(me, SpellIds.Vanish);
me.SetCanMelee(false);
InVanish = true; InVanish = true;
task.Schedule(TimeSpan.FromSeconds(5), garroteTask => task.Schedule(TimeSpan.FromSeconds(5), garroteTask =>
@@ -148,6 +149,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
target.CastSpell(target, SpellIds.Garrote, true); target.CastSpell(target, SpellIds.Garrote, true);
InVanish = false; InVanish = false;
me.SetCanMelee(true);
}); });
task.Repeat(); task.Repeat();
@@ -263,11 +265,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
_scheduler.CancelGroup(MiscConst.GroupNonEnrage); _scheduler.CancelGroup(MiscConst.GroupNonEnrage);
} }
_scheduler.Update(diff, () => _scheduler.Update(diff);
{
if (!InVanish)
DoMeleeAttackIfReady();
});
} }
} }
@@ -318,8 +316,6 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
{ {
if (instance.GetBossState(DataTypes.Moroes) != EncounterState.InProgress) if (instance.GetBossState(DataTypes.Moroes) != EncounterState.InProgress)
EnterEvadeMode(); EnterEvadeMode();
DoMeleeAttackIfReady();
} }
} }
@@ -337,8 +337,6 @@ namespace Scripts.EasternKingdoms.Karazhan.Netherspite
} }
else PhaseTimer -= diff; else PhaseTimer -= diff;
} }
DoMeleeAttackIfReady();
} }
} }
} }
@@ -318,7 +318,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Nightbane
if (!UpdateVictim() && phase != NightbanePhases.Intro) if (!UpdateVictim() && phase != NightbanePhases.Intro)
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -284,8 +284,6 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
SummonTito(); SummonTito();
else SummonTitoTimer -= diff; else SummonTitoTimer -= diff;
} }
DoMeleeAttackIfReady();
} }
void SummonTito() void SummonTito()
@@ -350,8 +348,6 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
YipTimer = 10000; YipTimer = 10000;
} }
else YipTimer -= diff; else YipTimer -= diff;
DoMeleeAttackIfReady();
} }
} }
@@ -456,8 +452,6 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
BrainWipeTimer = 20000; BrainWipeTimer = 20000;
} }
else BrainWipeTimer -= diff; else BrainWipeTimer -= diff;
DoMeleeAttackIfReady();
} }
} }
@@ -563,8 +557,6 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
} }
else RustTimer -= diff; else RustTimer -= diff;
} }
DoMeleeAttackIfReady();
} }
} }
@@ -671,8 +663,6 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
ScreamTimer = RandomHelper.URand(20000, 30000); ScreamTimer = RandomHelper.URand(20000, 30000);
} }
else ScreamTimer -= diff; else ScreamTimer -= diff;
DoMeleeAttackIfReady();
} }
} }
@@ -749,8 +739,6 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
ChainLightningTimer = 15000; ChainLightningTimer = 15000;
} }
else ChainLightningTimer -= diff; else ChainLightningTimer -= diff;
DoMeleeAttackIfReady();
} }
} }
@@ -880,8 +868,6 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
DoMeleeAttackIfReady();
if (ChaseTimer <= diff) if (ChaseTimer <= diff)
{ {
if (!IsChasing) if (!IsChasing)
@@ -1235,8 +1221,6 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
EternalAffectionTimer = RandomHelper.URand(45000, 60000); EternalAffectionTimer = RandomHelper.URand(45000, 60000);
} }
else EternalAffectionTimer -= diff; else EternalAffectionTimer -= diff;
DoMeleeAttackIfReady();
} }
} }
@@ -1432,8 +1416,6 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
PoisonThrustTimer = RandomHelper.URand(10000, 20000); PoisonThrustTimer = RandomHelper.URand(10000, 20000);
} }
else PoisonThrustTimer -= diff; else PoisonThrustTimer -= diff;
DoMeleeAttackIfReady();
} }
} }
} }
@@ -513,8 +513,6 @@ namespace Scripts.EasternKingdoms.Karazhan.PrinceMalchezaar
if (phase == 2) if (phase == 2)
DoMeleeAttacksIfReady(); DoMeleeAttacksIfReady();
else
DoMeleeAttackIfReady();
} }
void DoMeleeAttacksIfReady() void DoMeleeAttacksIfReady()
@@ -138,6 +138,7 @@ namespace Scripts.EasternKingdoms.Karazhan.ShadeOfAran
public override void Reset() public override void Reset()
{ {
Initialize(); Initialize();
me.SetCanMelee(true);
// Not in progress // Not in progress
instance.SetBossState(DataTypes.Aran, EncounterState.NotStarted); instance.SetBossState(DataTypes.Aran, EncounterState.NotStarted);
@@ -462,8 +463,7 @@ namespace Scripts.EasternKingdoms.Karazhan.ShadeOfAran
else FlameWreathCheckTime -= diff; else FlameWreathCheckTime -= diff;
} }
if (ArcaneCooldown != 0 && FireCooldown != 0 && FrostCooldown != 0) me.SetCanMelee(ArcaneCooldown != 0 && FireCooldown != 0 && FrostCooldown != 0);
DoMeleeAttackIfReady();
} }
public override void DamageTaken(Unit pAttacker, ref uint damage, DamageEffectType damageType, SpellInfo spellInfo = null) public override void DamageTaken(Unit pAttacker, ref uint damage, DamageEffectType damageType, SpellInfo spellInfo = null)
@@ -124,7 +124,7 @@ namespace Scripts.EasternKingdoms.Karazhan.TerestianIllhoof
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
{ {
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -153,10 +153,7 @@ namespace Scripts.EasternKingdoms.Karazhan.TerestianIllhoof
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => _scheduler.Update(diff);
{
DoMeleeAttackIfReady();
});
} }
} }
@@ -239,7 +236,7 @@ namespace Scripts.EasternKingdoms.Karazhan.TerestianIllhoof
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -430,7 +430,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.FelbloodKaelthas
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -340,7 +340,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -497,6 +497,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
AddThreat(unit, 1000.0f); AddThreat(unit, 1000.0f);
InVanish = true; InVanish = true;
me.SetCanMelee(false);
task.Repeat(TimeSpan.FromSeconds(30)); task.Repeat(TimeSpan.FromSeconds(30));
task.Schedule(TimeSpan.FromSeconds(10), waitTask => task.Schedule(TimeSpan.FromSeconds(10), waitTask =>
{ {
@@ -505,6 +506,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
DoCastVictim(SpellIds.Backstab, new CastSpellExtraArgs(true)); DoCastVictim(SpellIds.Backstab, new CastSpellExtraArgs(true));
DoCastVictim(SpellIds.KidneyShot, new CastSpellExtraArgs(true)); DoCastVictim(SpellIds.KidneyShot, new CastSpellExtraArgs(true));
me.SetVisible(true); // ...? Hacklike me.SetVisible(true); // ...? Hacklike
me.SetCanMelee(true);
InVanish = false; InVanish = false;
} }
waitTask.Repeat(); waitTask.Repeat();
@@ -523,6 +525,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
{ {
Initialize(); Initialize();
me.SetVisible(true); me.SetVisible(true);
me.SetCanMelee(true);
base.Reset(); base.Reset();
} }
@@ -535,9 +538,6 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
base.UpdateAI(diff); base.UpdateAI(diff);
_scheduler.Update(diff); _scheduler.Update(diff);
if (!InVanish)
DoMeleeAttackIfReady();
} }
} }
@@ -608,7 +608,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
base.UpdateAI(diff); base.UpdateAI(diff);
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -649,7 +649,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
base.UpdateAI(diff); base.UpdateAI(diff);
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -740,7 +740,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
HasIceBlocked = true; HasIceBlocked = true;
} }
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -823,7 +823,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
base.UpdateAI(diff); base.UpdateAI(diff);
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -908,7 +908,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
base.UpdateAI(diff); base.UpdateAI(diff);
if (me.IsWithinDistInMap(me.GetVictim(), SharedConst.AttackDistance)) if (me.IsWithinDistInMap(me.GetVictim(), SharedConst.AttackDistance))
_meleeScheduler.Update(diff, () => DoMeleeAttackIfReady()); _meleeScheduler.Update(diff);
else else
_scheduler.Update(diff); _scheduler.Update(diff);
} }
@@ -973,7 +973,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
base.UpdateAI(diff); base.UpdateAI(diff);
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
@@ -1037,7 +1037,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
base.UpdateAI(diff); base.UpdateAI(diff);
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
} }
@@ -231,8 +231,6 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.SelinFireheart
_events.ScheduleEvent(EventIds.DrainCrystal, TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(25), 0, PhaseIds.Normal); _events.ScheduleEvent(EventIds.DrainCrystal, TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(25), 0, PhaseIds.Normal);
} }
} }
DoMeleeAttackIfReady();
} }
} }
@@ -252,5 +250,4 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.SelinFireheart
} }
} }
} }
} }
@@ -136,7 +136,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.Vexallus
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, () => DoMeleeAttackIfReady()); _scheduler.Update(diff);
} }
} }
+1 -1
View File
@@ -361,7 +361,7 @@ namespace Scripts.Events.LunarFestival
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, DoMeleeAttackIfReady); _scheduler.Update(diff);
} }
} }
+1 -1
View File
@@ -206,7 +206,7 @@ namespace Scripts.Events.ZalazaneFall
if (_tigerGuid.IsEmpty()) if (_tigerGuid.IsEmpty())
return; return;
_scheduler.Update(diff, DoMeleeAttackIfReady); _scheduler.Update(diff);
} }
} }
-2
View File
@@ -97,8 +97,6 @@ namespace Scripts.Pets.Hunter
else else
_spellTimer -= diff; _spellTimer -= diff;
} }
DoMeleeAttackIfReady();
} }
} }
} }
+1 -3
View File
@@ -32,8 +32,6 @@ namespace Scripts.Pets.Shaman
return; return;
_scheduler.Update(diff); _scheduler.Update(diff);
DoMeleeAttackIfReady();
} }
} }
@@ -74,7 +72,7 @@ namespace Scripts.Pets.Shaman
if (me.HasUnitState(UnitState.Casting)) if (me.HasUnitState(UnitState.Casting))
return; return;
_scheduler.Update(diff, DoMeleeAttackIfReady); _scheduler.Update(diff);
} }
} }
} }
-2
View File
@@ -134,8 +134,6 @@ namespace Scripts.World.Achievements
Unit target = SelectTarget(SelectTargetMethod.MaxThreat, 0, -50.0f, true); Unit target = SelectTarget(SelectTargetMethod.MaxThreat, 0, -50.0f, true);
if (target != null) if (target != null)
DoCast(target, SpellIds.SummonPlayer); DoCast(target, SpellIds.SummonPlayer);
DoMeleeAttackIfReady();
} }
} }
+1 -4
View File
@@ -107,12 +107,9 @@ namespace Scripts.World.NpcGuard
{ {
me.ResetAttackTimer(); me.ResetAttackTimer();
DoCastVictim(spellInfo.Id); DoCastVictim(spellInfo.Id);
meleeContext.Repeat();
return; return;
} }
} }
me.AttackerStateUpdate(victim);
me.ResetAttackTimer();
meleeContext.Repeat(); meleeContext.Repeat();
}).Schedule(TimeSpan.FromSeconds(5), spellContext => }).Schedule(TimeSpan.FromSeconds(5), spellContext =>
{ {
@@ -183,7 +180,7 @@ namespace Scripts.World.NpcGuard
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
_scheduler.Update(diff, DoMeleeAttackIfReady); _scheduler.Update(diff);
} }
void ScheduleVanish() void ScheduleVanish()
+1 -2
View File
@@ -207,8 +207,7 @@ namespace Scripts.World.NpcsSpecial
ResetFlagTimer -= diff; ResetFlagTimer -= diff;
} }
if (UpdateVictim()) UpdateVictim();
DoMeleeAttackIfReady();
} }
public override void ReceiveEmote(Player player, TextEmotes emote) public override void ReceiveEmote(Player player, TextEmotes emote)