Пример #1
0
        public virtual void TryAttack()
        {
            Creature p = UnitOwner as Creature;

            if (p == null)
            {
                return;
            }

            //Added this to allow clearing NPC emote if combat starts
            if (p.Spawn.Emote != 0)
            {
                AnimateCreature(p, 0);
            }

            long tick = TCPManager.GetTimeStampMS();

            if (NextAttackTime >= tick || (CurrentTarget != null && CurrentTarget.IsStaggered))
            {
                return;
            }

            if (p.Ranged > 0)
            {
                if (!p.IsInCastRange(CurrentTarget, p.Ranged))
                {
                    return;
                }
                p.Strike(CurrentTarget, p.IsInCastRange(CurrentTarget, (uint)p.BaseRadius) ? EquipSlot.MAIN_HAND : EquipSlot.RANGED_WEAPON);
                NextAttackTime = tick + 1500 + StaticRandom.Instance.Next(0, 1000);
            }

            else
            {
                if (!p.IsInCastRange(CurrentTarget, (uint)(0.5f + p.BaseRadius)))
                {
                    return;
                }
                p.Strike(CurrentTarget);
                NextAttackTime = tick + 1500 + StaticRandom.Instance.Next(0, 1000);
            }
        }