public CharacterMovement(L2Character character)
 {
     _character    = character;
     _attackTarget = null;
 }
Exemple #2
0
        public virtual void DoAttack(L2Character target)
        {
            if (target == null)
            {
                return;
            }

            if (target.Dead)
            {
                return;
            }

            if ((AttackToHit != null) && AttackToHit.Enabled)
            {
                return;
            }

            if ((AttackToEnd != null) && AttackToEnd.Enabled)
            {
                return;
            }

            double dist  = 60,
                   reqMp = 0;

            L2Item weapon  = ActiveWeapon;
            double timeAtk = 100;//attackspeed
            bool   dual    = false,
                   ranged  = false,
                   ss      = false;

            if (weapon != null)
            {
            }
            else
            {
                timeAtk = (1362 * 345) / timeAtk;
            }

            if (!Calcs.CheckIfInRange((int)dist, this, target, true))
            {
                TryMoveTo(target.X, target.Y, target.Z);
                return;
            }

            if ((reqMp > 0) && (reqMp > CharStatus.CurrentMp))
            {
                SendMessage($"no mp {CharStatus.CurrentMp} {reqMp}");
                return;
            }

            Attack atk = new Attack(this, target, ss, 5);

            if (dual)
            {
                Hit1 = GenHitSimple(true, ss);
                atk.AddHit(target.ObjId, (int)Hit1.Damage, Hit1.Miss, Hit1.Crit, Hit1.ShieldDef > 0);

                Hit2 = GenHitSimple(true, ss);
                atk.AddHit(target.ObjId, (int)Hit2.Damage, Hit2.Miss, Hit2.Crit, Hit2.ShieldDef > 0);
            }
            else
            {
                Hit1 = GenHitSimple(false, ss);
                atk.AddHit(target.ObjId, (int)Hit1.Damage, Hit1.Miss, Hit1.Crit, Hit1.ShieldDef > 0);
            }

            Target = target;

            if (AttackToHit == null)
            {
                AttackToHit          = new Timer();
                AttackToHit.Elapsed += AttackDoHit;
            }

            double timeToHit = ranged ? timeAtk * 0.5 : timeAtk * 0.6;

            AttackToHit.Interval = timeToHit;
            AttackToHit.Enabled  = true;

            if (dual)
            {
                if (AttackToHitBonus == null)
                {
                    AttackToHitBonus          = new Timer();
                    AttackToHitBonus.Elapsed += AttackDoHit2Nd;
                }

                AttackToHitBonus.Interval = timeAtk * 0.78;
                AttackToHitBonus.Enabled  = true;
            }

            if (AttackToEnd == null)
            {
                AttackToEnd          = new Timer();
                AttackToEnd.Elapsed += AttackDoEnd;
            }

            AttackToEnd.Interval = timeAtk;
            AttackToEnd.Enabled  = true;

            BroadcastPacket(atk);
        }
        public virtual async Task MoveToAndHit(L2Character target, int radiusOffset = 150)
        {
            await MoveTo(target.X, target.Y, target.Z, target, radiusOffset);

            Task.Factory.StartNew(BroadcastDestinationChanged);
        }