Core/Creatures: Moved autoattack handling from scripts to game
Port From (https://github.com/TrinityCore/TrinityCore/commit/605e5f94c0d71cad8e83fa5a07eaec4e6bed9cc3)
This commit is contained in:
@@ -52,41 +52,6 @@ namespace Game.AI
|
||||
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)
|
||||
{
|
||||
if (me.HasUnitState(UnitState.Casting) || !me.IsAttackReady())
|
||||
|
||||
Reference in New Issue
Block a user