Exemplo n.º 1
0
 public void Release()
 {
     Creature = null;
     Npc = null;
     Projectile = null;
     TargetPosition = null;
 }
Exemplo n.º 2
0
 public static short GetHeading(WorldPosition fromWorldPosition, Point3D toPoint3D)
 {
     return
         (short)
         (Math.Atan2(toPoint3D.Y - fromWorldPosition.Y, toPoint3D.X - fromWorldPosition.X) * 32768 /
          Math.PI);
 }
Exemplo n.º 3
0
        public static float CheckIntersections(Creature creature, short heading, Point3D moveVector, float distance)
        {
            if (distance <= 0f)
                return 0f;

            WorldPosition targetPosition = moveVector.Clone().Add(creature.Position).ToWorldPosition();

            double minDistance = distance;

            List<Creature> around = Global.VisibleService.FindTargets(creature, creature.Position, distance + 40, TargetingAreaType.All);
            for (int x = 0; x < around.Count; x++)
            {
                if (around[x] == creature)
                    continue;

                short diff = Geom.GetAngleDiff(heading, Geom.GetHeading(creature.Position, around[x].Position));
                if (diff > 90)
                    continue;

                double d = Geom.DistanceToLine(around[x].Position, creature.Position, targetPosition);

                if (d > 40)
                    continue;

                d = creature.Position.DistanceTo(around[x].Position) - 40;

                if (d <= 0)
                    return 0f;

                if (d < minDistance)
                    minDistance = d;
            }

            return (float)(minDistance / distance);
        }
Exemplo n.º 4
0
        public Point3D Add(Point3D point3D)
        {
            X += point3D.X;
            Y += point3D.Y;
            Z += point3D.Z;

            return this;
        }
Exemplo n.º 5
0
        public NpcMoveController(Creature creature)
        {
            Creature = creature;
            Npc = creature as Npc;
            Projectile = creature as Projectile;

            TargetPosition = new Point3D();
            MoveVector = new Point3D();
        }
Exemplo n.º 6
0
        public bool Contains(Point3D point)
        {
            if (PointList.Count <= 2)
                return false;

            bool res = false;

            Point3D lastPoint = PointList[PointList.Count - 1];

            foreach (Point3D curPoint in PointList)
            {
                if ((((curPoint.Y <= point.Y) && (point.Y < lastPoint.Y)) ||
                     ((lastPoint.Y <= point.Y) && (point.Y < curPoint.Y))) &&
                    (point.X > (lastPoint.X - curPoint.X)*(point.Y - curPoint.Y)/(lastPoint.Y - curPoint.Y) + curPoint.X))
                    res = !res;

                lastPoint = curPoint;
            }
            return res;
        }
Exemplo n.º 7
0
        public static void DebugLine(Creature creature, Point3D start, Point3D end)
        {
            const int iterations = 3;

            Point3D vector = Geom.GetNormal(Geom.GetHeading(start, end))
                .Multiple((float)(start.DistanceTo(end) / (iterations - 1)));

            for (int i = 0; i < iterations; i++)
            {
                DropItem(creature, 20000001, 0, start.ToWorldPosition(), true);
                start.Add(vector);
            }

            Player player = creature as Player;
            if (player != null)
                player.Visible.Update();
        }
Exemplo n.º 8
0
 public void CopyTo(Point3D p)
 {
     p.X = X;
     p.Y = Y;
     p.Z = Z;
 }
Exemplo n.º 9
0
 public List<Creature> FindTargets(Creature creature, Point3D position, double distance, TargetingAreaType type)
 {
     return FindTargets(creature, position.X, position.Y, position.Z, distance, type);
 }
Exemplo n.º 10
0
        public static void DebugPoint(Creature creature, Point3D point)
        {
            DropItem(creature, 20000000, 0, point.ToWorldPosition(), true);

            Player player = creature as Player;
            if (player != null)
                player.Visible.Update();
        }
Exemplo n.º 11
0
 public static short GetHeading(Point3D fromPoint3D, Point3D toPoint3D)
 {
     return (short) (Math.Atan2(toPoint3D.Y - fromPoint3D.Y, toPoint3D.X - fromPoint3D.X)*32768/Math.PI);
 }
Exemplo n.º 12
0
 public void MoveTo(Point3D position, int distance = 0)
 {
     position.CopyTo(TargetPosition);
     TargetDistance = distance;
     Move();
 }
Exemplo n.º 13
0
 public static short GetHeading(Point3D fromPoint3D, WorldPosition toWorldPosition)
 {
     return (short)(Math.Atan2(toWorldPosition.Y - fromPoint3D.Y, toWorldPosition.X - fromPoint3D.X) * 32768 / Math.PI);
 }
Exemplo n.º 14
0
        public double DistanceTo(Point3D point3D)
        {
            double a = point3D.X - X;
            double b = point3D.Y - Y;
            double c = point3D.Z - Z;

            return Math.Sqrt(a*a + b*b + c*c);
        }
Exemplo n.º 15
0
 public static short GetHeading(Point3D point3D)
 {
     return (short) (Math.Atan2(point3D.Y, point3D.X)*32768/Math.PI);
 }
Exemplo n.º 16
0
 public void CopyTo(Point3D point)
 {
     point.X = X;
     point.Y = Y;
     point.Z = Z;
 }
Exemplo n.º 17
0
        public bool Equals(Point3D p)
        {
            if (ReferenceEquals(null, p))
                return false;

            if (ReferenceEquals(this, p))
                return true;

            return p.X.Equals(X) && p.Y.Equals(Y) && p.Z.Equals(Z);
        }