示例#1
0
        public override void DoFollow(object sender = null, System.Timers.ElapsedEventArgs e = null)
        {
            if (_summon.CantMove())
            {
                return;
            }

            double dis = Calcs.CalculateDistance(_summon, _summon.Owner, true);

            if (!(dis > 120))
            {
                return;
            }

            if ((_lastOwnerX == _summon.Owner.X) || (_lastOwnerY == _summon.Owner.Y) || (_lastOwnerZ == _summon.Owner.Z))
            {
                return;
            }

            Character.MoveTo(_summon.Owner.X, _summon.Owner.Y, _summon.Owner.Z);

            _lastOwnerX = _summon.Owner.X;
            _lastOwnerY = _summon.Owner.Y;
            _lastOwnerZ = _summon.Owner.Z;
        }
示例#2
0
        private void ValidateSpawnLocation()
        {
            if (Character.CantMove())
            {
                return;
            }

            switch (_moveHome)
            {
            case 1:
                double dis = Calcs.CalculateDistance(Character.X, Character.Y, Character.Z, Character.SpawnX, Character.SpawnZ, Character.SpawnZ, true);
                if (dis > 100)
                {
                    _moveHome = 2;
                    Character.MoveTo(Character.SpawnX, Character.SpawnY, Character.SpawnZ);
                }
                else
                {
                    _moveHome = 3;
                }
                break;

            case 3:
                if (AttackMove != null)
                {
                    AttackMove.Enabled = false;
                }

                break;
            }
        }
示例#3
0
文件: Skill.cs 项目: temukaa/develop
        public SortedList <int, L2Object> GetAffectedTargets(L2Character actor)
        {
            SortedList <int, L2Object> targets = new SortedList <int, L2Object>();

            switch (AffectScope)
            {
            case SkillScope.Single:
            {
                switch (TargetType)
                {
                case SkillTarget.Self:
                    targets.Add(actor.ObjId, actor);
                    break;

                case SkillTarget.Friend:
                case SkillTarget.Enemy:
                case SkillTarget.Any:
                case SkillTarget.Target:
                    if (actor.CurrentTarget != null)
                    {
                        targets.Add(actor.CurrentTarget.ObjId, actor.CurrentTarget);
                    }
                    break;

                case SkillTarget.Master:
                    if (actor is L2Summon)
                    {
                        targets.Add(((L2Summon)actor).Owner.ObjId, ((L2Summon)actor).Owner);
                    }
                    break;

                case SkillTarget.Unlockable:
                {
                    if (actor.CurrentTarget is L2Door)
                    {
                        targets.Add(actor.CurrentTarget.ObjId, actor.CurrentTarget);
                    }
                }
                break;
                }
            }

            break;

            case SkillScope.Party:
                L2Character[] members = actor.GetPartyCharacters();
                targets = members.Where(member => Calcs.CalculateDistance(actor, member, true) < CastRange).ToSortedList(member => member.ObjId, member => (L2Object)member);
                break;
            }

            return(targets);
        }
示例#4
0
        private void AttackMoveTask(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (_player.IsAttacking())
            {
                return;
            }

            if (_player.Target == null)
            {
                AttackMove.Enabled = false;
                return;
            }

            double dis = Calcs.CalculateDistance(_player, Character.Target, true);

            if (dis < 80)
            {
                L2Character target = _player.Target;
                if (!target.Dead)
                {
                    _player.DoAttack(target);
                }
            }
            else
            {
                if (_player.CantMove())
                {
                    return;
                }

                if ((_lastx != _player.Target.X) || (_lasty != _player.Target.Y) || (_lastz != _player.Target.Z))
                {
                    _moveTarget = 0;
                }

                if (_moveTarget != 0)
                {
                    return;
                }

                _player.MoveTo(_player.Target.X, _player.Target.Y, _player.Target.Z);
                _moveTarget = 1;
                _lastx      = Character.Target.X;
                _lasty      = Character.Target.Y;
                _lastz      = Character.Target.Z;
            }
        }
示例#5
0
        private void CheckSit(L2Player player)
        {
            if (!player.CharMovement.CanMove() || player.IsSittingInProgress())
            {
                player.SendActionFailedAsync();
                return;
            }

            if (player.IsSitting())
            {
                player.StandAsync();
                return;
            }

            int staticId = 0;

            if (player.Target is L2Chair)
            {
                L2Chair chair = (L2Chair)player.Target;
                if (!chair.IsUsedAlready)
                {
                    double dis = Calcs.CalculateDistance(player, chair, true);
                    if (dis < 150)
                    {
                        staticId = chair.StaticId;
                    }
                }

                if (player.Builder == 1)
                {
                    double dis = Calcs.CalculateDistance(player, chair, true);
                    if (dis < 150)
                    {
                        staticId = chair.StaticId;
                    }
                }

                if (staticId > 0)
                {
                    player.SetChair(chair);
                }
            }

            player.SitAsync();
        }
示例#6
0
        private void CheckSit(L2Player player)
        {
            if (player.IsCastingNow() || player.CantMove() || player.IsSittingInProgress())
            {
                player.SendActionFailed();
                return;
            }

            if (player.IsSitting())
            {
                player.Stand();
                return;
            }

            int staticId = 0;

            if (player.CurrentTarget is L2Chair)
            {
                L2Chair chair = (L2Chair)player.CurrentTarget;
                if (!chair.IsUsedAlready && (chair.ClanID != -1) && (player.ClanId == chair.ClanID))
                {
                    double dis = Calcs.CalculateDistance(player, chair, true);
                    if (dis < 150)
                    {
                        staticId = chair.StaticId;
                    }
                }

                if (player.Builder == 1)
                {
                    double dis = Calcs.CalculateDistance(player, chair, true);
                    if (dis < 150)
                    {
                        staticId = chair.StaticId;
                    }
                }

                if (staticId > 0)
                {
                    player.SetChair(chair);
                }
            }

            player.Sit();
        }
示例#7
0
        private void AttackMoveTask(object sender, ElapsedEventArgs e)
        {
            if (_moveHome > 0)
            {
                ValidateSpawnLocation();
                return;
            }

            if (Character.IsAttacking())
            {
                return;
            }

            double dis = Calcs.CalculateDistance(Character, Character.Target, true);

            if (dis < 80)
            {
                _moveTarget = 0;
                L2Character target = Character.Target;
                Character.DoAttack(target);
            }
            else
            {
                if (Character.CantMove())
                {
                    return;
                }

                if ((Lastx != Character.Target.X) || (Lasty != Character.Target.Y) || (Lastz != Character.Target.Z))
                {
                    _moveTarget = 0;
                }

                if (_moveTarget != 0)
                {
                    return;
                }

                _moveTarget = 1;
                Character.MoveTo(Character.Target.X, Character.Target.Y, Character.Target.Z);
                Lastx = Character.Target.X;
                Lasty = Character.Target.Y;
                Lastz = Character.Target.Z;
            }
        }
示例#8
0
        public virtual void Move()
        {
            if (Owner.CurrentTarget == null)
            {
                return;
            }

            double dis = Calcs.CalculateDistance(this, Owner.CurrentTarget, true);

            if (!(dis > 40) || !(dis < 2300))
            {
                return;
            }

            if (!CantMove())
            {
                MoveTo(Owner.CurrentTarget.X, Owner.CurrentTarget.Y, Owner.CurrentTarget.Z);
            }
        }
示例#9
0
        public override void OnAction(L2Player player)
        {
            double dis = Calcs.CalculateDistance(this, player, true);

            player.SendMessage($"{AsString()} dis {(int)dis}");
            if (dis < 80)
            {
                foreach (L2Player o in KnownObjects.Values.OfType <L2Player>())
                {
                    o.SendPacket(new GetItem(player.ObjId, ObjId, X, Y, Z));
                    o.SendPacket(new DeleteObject(ObjId));
                }

                player.OnPickUp(this);

                L2World.Instance.RemoveObject(this);
            }
            else
            {
                player.TryMoveTo(X, Y, Z);
            }
        }
示例#10
0
        public override async Task OnActionAsync(L2Player player)
        {
            double dis = Calcs.CalculateDistance(this, player, true);
            await player.SendMessageAsync($"{AsString()} dis {(int)dis}");

            if (dis < 80)
            {
                foreach (L2Player p in Region.GetAllNeighbourPlayers())
                {
                    p.SendPacketAsync(new GetItem(p.ObjectId, ObjectId, X, Y, Z));
                    p.SendPacketAsync(new DeleteObject(ObjectId));
                }

                player.OnPickUp(this);

                L2World.RemoveObject(this);
            }
            else // TODO: Rework this
            {
                await player.Movement.MoveTo(X, Y, Z);
            }
        }
示例#11
0
        public override async Task OnActionAsync(L2Player player)
        {
            double dis = Calcs.CalculateDistance(this, player, true);
            await player.SendMessageAsync($"{AsString()} dis {(int)dis}");

            if (dis < 80)
            {
                foreach (L2Player o in KnownObjects.Values.OfType <L2Player>())
                {
                    await o.SendPacketAsync(new GetItem(player.ObjectId, ObjectId, X, Y, Z));

                    await o.SendPacketAsync(new DeleteObject(ObjectId));
                }

                player.OnPickUp(this);

                L2World.RemoveObject(this);
            }
            else
            {
                await player.CharMovement.MoveTo(X, Y, Z);
            }
        }
示例#12
0
 public override async Task NotifyActionAsync(L2Player player)
 {
     double dis = Calcs.CalculateDistance(player, this, true);
     await Movement.MoveTo(X, Y, Z);
 }
示例#13
0
        //public virtual void setTemplate(NpcTemplate template)
        //{
        //    Template = template;
        //    ObjID = IdFactory.Instance.nextId();
        //    CStatsInit();
        //    CharacterStat.setTemplate(template);
        //    CurHP = CharacterStat.getStat(skills2.TEffectType.b_max_hp);
        //    Name = template.Name;
        //    AIProcessor = new citizen();
        //    AIProcessor.dialog = new Dictionary<string, string>();
        //    AIProcessor.dialog.Add("fnHi", "lector001.htm");
        //    AIProcessor.dialog.Add("fnFeudInfo", "gludio_feud_manager001.htm");
        //    AIProcessor.dialog.Add("fnNoFeudInfo", "farm_messenger002.htm");
        //    AIProcessor.myself = this;
        //}

        public override void NotifyAction(L2Player player)
        {
            double dis = Calcs.CalculateDistance(player, this, true);

            TryMoveTo(X, Y, Z);
        }