public void Release() { Creature = null; Npc = null; Projectile = null; TargetPosition = null; }
public static short GetHeading(WorldPosition fromWorldPosition, Point3D toPoint3D) { return (short) (Math.Atan2(toPoint3D.Y - fromWorldPosition.Y, toPoint3D.X - fromWorldPosition.X) * 32768 / Math.PI); }
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); }
public Point3D Add(Point3D point3D) { X += point3D.X; Y += point3D.Y; Z += point3D.Z; return this; }
public NpcMoveController(Creature creature) { Creature = creature; Npc = creature as Npc; Projectile = creature as Projectile; TargetPosition = new Point3D(); MoveVector = new Point3D(); }
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; }
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(); }
public void CopyTo(Point3D p) { p.X = X; p.Y = Y; p.Z = Z; }
public List<Creature> FindTargets(Creature creature, Point3D position, double distance, TargetingAreaType type) { return FindTargets(creature, position.X, position.Y, position.Z, distance, type); }
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(); }
public static short GetHeading(Point3D fromPoint3D, Point3D toPoint3D) { return (short) (Math.Atan2(toPoint3D.Y - fromPoint3D.Y, toPoint3D.X - fromPoint3D.X)*32768/Math.PI); }
public void MoveTo(Point3D position, int distance = 0) { position.CopyTo(TargetPosition); TargetDistance = distance; Move(); }
public static short GetHeading(Point3D fromPoint3D, WorldPosition toWorldPosition) { return (short)(Math.Atan2(toWorldPosition.Y - fromPoint3D.Y, toWorldPosition.X - fromPoint3D.X) * 32768 / Math.PI); }
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); }
public static short GetHeading(Point3D point3D) { return (short) (Math.Atan2(point3D.Y, point3D.X)*32768/Math.PI); }
public void CopyTo(Point3D point) { point.X = X; point.Y = Y; point.Z = Z; }
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); }