Exemple #1
0
        public static WorldPosition ForwardPosition(WorldPosition position, int distance)
        {
            var result = position.Clone();

            double angle = position.Heading * Math.PI / 32768;
            result.X += (float) Math.Cos(angle)*distance;
            result.Y += (float) Math.Sin(angle)*distance;

            return result;
        }
Exemple #2
0
        public static void DebugPoint(Creature creature, WorldPosition position)
        {
            DropItem(creature, 20000000, 0, position.Clone(), true);

            Player player = creature as Player;
            if (player != null)
                player.Visible.Update();
        }
Exemple #3
0
        public Projectile(Creature.Creature owner, ProjectileSkill projectileSkill)
        {
            Player.Player player = owner as Player.Player;
            Npc.Npc npc = owner as Npc.Npc;

            Parent = owner;

            if (npc != null)
            {
                TargetPosition = new WorldPosition();
                npc.Target.Position.CopyTo(TargetPosition);
            }
            else
                TargetPosition = owner.Attack.Args.TargetPosition;

            Position = new WorldPosition
                           {
                               Heading = owner.Position.Heading,
                               X = owner.Position.X,
                               Y = owner.Position.Y,
                               Z = owner.Position.Z + projectileSkill.DetachHeight,
                           };

            double angle = Position.Heading * Math.PI / 32768;

            Position.X += projectileSkill.DetachDistance * (float)Math.Cos(angle);
            Position.Y += projectileSkill.DetachDistance * (float)Math.Sin(angle);

            Instance = owner.Instance;
            ProjectileSkill = projectileSkill;
            GameStats = new CreatureBaseStats {HpBase = 1};

            if (player != null)
            {
                Skill = Data.Skills[0][player.TemplateId][ProjectileSkill.Id];
                SkillId = Skill.Id;
            }
            else if (npc != null)
            {
                Skill = Data.Skills[npc.NpcTemplate.HuntingZoneId][npc.NpcTemplate.Id][ProjectileSkill.Id];
                SkillId = Skill.Id + 0x40000000 + (npc.NpcTemplate.HuntingZoneId << 16);
            }

            Lifetime = Skill.ProjectileData.LifeTime != 0
                           ? Skill.ProjectileData.LifeTime
                           : 1000;

            if (projectileSkill.FlyingDistance <= 0f)
                TargetPosition = null;
            else if (Skill != null)
            {
                if (TargetPosition.IsNull())
                {
                    TargetPosition = Position.Clone();

                    TargetPosition.X += projectileSkill.FlyingDistance * (float)Math.Cos(angle);
                    TargetPosition.Y += projectileSkill.FlyingDistance * (float)Math.Sin(angle);
                }

                Speed = (int) (projectileSkill.FlyingDistance*1000/Lifetime);
            }

            if (Skill != null)
            {
                if (Skill.TargetingList != null)
                {
                    for (int i = 0; i < Skill.TargetingList.Count; i++)
                    {
                        if (Skill.TargetingList[i].AreaList == null)
                            continue;

                        for (int j = 0; j < Skill.TargetingList[i].AreaList.Count; j++)
                        {
                            if (Skill.TargetingList[i].AreaList[j].MaxRadius > AttackDistance)
                            {
                                AttackDistance = Skill.TargetingList[i].AreaList[j].MaxRadius;
                                return;
                            }
                        }
                    }
                }
            }
        }