diff --git a/GameServer/GameClient.cs b/GameServer/GameClient.cs
index 640f195a..c4c23f41 100644
--- a/GameServer/GameClient.cs
+++ b/GameServer/GameClient.cs
@@ -27,6 +27,7 @@
using DOL.Database;
using DOL.Events;
+using DOL.GS.Geometry;
using DOL.GS.PacketHandler;
using DOL.GS.ServerProperties;
using DOL.Language;
diff --git a/GameServer/Geometry/Coordinate.cs b/GameServer/Geometry/Coordinate.cs
index 2c6961ae..9ff4b0d9 100644
--- a/GameServer/Geometry/Coordinate.cs
+++ b/GameServer/Geometry/Coordinate.cs
@@ -8,6 +8,8 @@ public struct Coordinate
public int Y => coordinate.Y;
public int Z => coordinate.Z;
+ public static Coordinate Create(System.Numerics.Vector3 v) => new () { coordinate = Vector.Create((int)v.X, (int)v.Y, (int)v.Z) };
+
public static Coordinate Create(int x = 0, int y = 0, int z = 0)
=> new() { coordinate = Vector.Create(x, y, z) };
diff --git a/GameServer/Geometry/CoordinateTransitionExtensions.cs b/GameServer/Geometry/CoordinateTransitionExtensions.cs
index b23ed72d..1d6976bc 100644
--- a/GameServer/Geometry/CoordinateTransitionExtensions.cs
+++ b/GameServer/Geometry/CoordinateTransitionExtensions.cs
@@ -15,5 +15,5 @@ public static Point2D ToPoint2D(this Coordinate coordinate)
[Obsolete("This extension is transitional and going to be removed.")]
public static Coordinate ToCoordinate(this IPoint3D point)
- => Coordinate.Create(point.X, point.Y, point.Z);
+ => Coordinate.Create((int)point.Position.X, (int)point.Position.Y, (int)point.Position.Z);
}
\ No newline at end of file
diff --git a/GameServer/Geometry/Vector.cs b/GameServer/Geometry/Vector.cs
index 5526ddad..c5aa54d5 100644
--- a/GameServer/Geometry/Vector.cs
+++ b/GameServer/Geometry/Vector.cs
@@ -70,6 +70,12 @@ public override int GetHashCode()
public static Vector operator *(double factor, Vector vec)
=> vec * factor;
+ public static Vector operator /(Vector vec, double factor)
+ => Create((int)(vec.X / factor), (int)(vec.Y / factor), (int)(vec.Z / factor));
+
+ public static Vector operator /(double factor, Vector vec)
+ => vec / factor;
+
public static Vector operator +(Vector vecA, Vector vecB)
=> Create(vecA.X + vecB.X, vecA.Y + vecB.Y, vecA.Z + vecB.Z);
diff --git a/GameServer/Territory/AreaCoordinate.cs b/GameServer/Territory/AreaCoordinate.cs
deleted file mode 100644
index 49d8f354..00000000
--- a/GameServer/Territory/AreaCoordinate.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DOL.Territories
-{
- public class AreaCoordinate
- {
- public float X
- {
- get;
- set;
- }
-
- public float Y
- {
- get;
- set;
- }
-
- public float Z
- {
- get;
- set;
- }
- }
-}
\ No newline at end of file
diff --git a/GameServer/Territory/RvRTerritory.cs b/GameServer/Territory/RvRTerritory.cs
index 3fac75de..b0ef5572 100644
--- a/GameServer/Territory/RvRTerritory.cs
+++ b/GameServer/Territory/RvRTerritory.cs
@@ -1,5 +1,6 @@
using DOL.Database;
using DOL.GS;
+using DOL.GS.Geometry;
using DOL.GS.Keeps;
using DOL.MobGroups;
using DOLDatabase.Tables;
@@ -16,7 +17,7 @@ public class RvRTerritory
: Territory
{
///
- public RvRTerritory(Zone zone, List areas, string name, GameNPC boss, Vector3? portalPosition, ushort regionID, MobGroup group) : base(eType.Normal, zone, areas, name, boss, portalPosition, regionID, group)
+ public RvRTerritory(Zone zone, List areas, string name, GameNPC boss, Coordinate? portalCoordinate, ushort regionID, MobGroup group) : base(eType.Normal, zone, areas, name, boss, portalCoordinate, regionID, group)
{
//add new areas to region
//only in memory
@@ -50,7 +51,7 @@ public void Reset()
{
OwnerGuild = null;
// reset keep
- AbstractGameKeep keep = GameServer.KeepManager.GetKeepCloseToSpot(RegionId, Boss.Position, 100000);
+ AbstractGameKeep keep = GameServer.KeepManager.GetKeepCloseToSpot(Boss.Position, 100000);
keep.TempRealm = eRealm.None;
keep.Reset(keep.TempRealm);
// reset all doors
diff --git a/GameServer/Territory/Territory.cs b/GameServer/Territory/Territory.cs
index 3a4befcb..17310f74 100644
--- a/GameServer/Territory/Territory.cs
+++ b/GameServer/Territory/Territory.cs
@@ -3,6 +3,7 @@
using DOL.GameEvents;
using DOL.gameobjects.CustomNPC;
using DOL.GS;
+using DOL.GS.Geometry;
using DOL.GS.PacketHandler;
using DOL.GS.PropertyCalc;
using DOL.GS.ServerProperties;
@@ -37,11 +38,11 @@ public Territory(Zone zone, List areas, GameNPC boss, TerritoryDb db)
this.Areas = areas;
if (db.PortalX == null || db.PortalY == null || db.PortalZ == null)
{
- this.PortalPosition = null;
+ this.PortalCoordinate = null;
}
else
{
- this.PortalPosition = new Vector3(db.PortalX.Value, db.PortalY.Value, db.PortalZ.Value);
+ this.PortalCoordinate = Coordinate.Create(db.PortalX.Value, db.PortalY.Value, db.PortalZ.Value);
}
this.Zone = zone;
this.RegionId = db.RegionId;
@@ -106,11 +107,11 @@ public Territory(Zone zone, List areas, GameNPC boss, TerritoryDb db)
}
}
- public Territory(eType type, Zone zone, List areas, string name, GameNPC boss, Vector3? portalPosition, ushort regionID, MobGroup group = null)
+ public Territory(eType type, Zone zone, List areas, string name, GameNPC boss, Coordinate? portalCoordinate, ushort regionID, MobGroup group = null)
{
this.Type = type;
this.Areas = areas;
- this.PortalPosition = portalPosition;
+ this.PortalCoordinate = portalCoordinate;
this.Zone = zone;
this.RegionId = regionID;
this.Name = name;
@@ -207,7 +208,7 @@ public List Areas
get;
}
- public Vector3? PortalPosition
+ public Coordinate? PortalCoordinate
{
get;
set;
@@ -624,7 +625,7 @@ private void ToggleBannerUnsafe(bool add)
if (area is Circle circle)
{
- Zone.GetObjectsInRadius(Zone.eGameObjectType.ITEM, circle.Position.X, circle.Position.Y, circle.Position.Z, (ushort)circle.Radius, new ArrayList(), true).OfType().ForEach(i => i.Emblem = add && m_ownerGuild != null ? m_ownerGuild.Emblem : i.OriginalEmblem);
+ Zone.GetObjectsInRadius(Zone.eGameObjectType.ITEM, circle.Coordinate, (ushort)circle.Radius, new ArrayList(), true).OfType().ForEach(i => i.Emblem = add && m_ownerGuild != null ? m_ownerGuild.Emblem : i.OriginalEmblem);
}
else
{
@@ -1168,11 +1169,11 @@ protected virtual void SaveIntoDatabaseUnsafe()
db.ClaimedTime = ClaimedTime;
db.Expiration = Expiration;
db.Type = (int)Type;
- if (this.PortalPosition != null)
+ if (this.PortalCoordinate != null)
{
- db.PortalX = (int)this.PortalPosition.Value.X;
- db.PortalY = (int)this.PortalPosition.Value.Y;
- db.PortalZ = (int)this.PortalPosition.Value.Z;
+ db.PortalX = (int)this.PortalCoordinate.Value.X;
+ db.PortalY = (int)this.PortalCoordinate.Value.Y;
+ db.PortalZ = (int)this.PortalCoordinate.Value.Z;
}
else
{
diff --git a/GameServer/Territory/TerritoryManager.cs b/GameServer/Territory/TerritoryManager.cs
index 9f113051..d172b79f 100644
--- a/GameServer/Territory/TerritoryManager.cs
+++ b/GameServer/Territory/TerritoryManager.cs
@@ -4,6 +4,7 @@
using DOL.GameEvents;
using DOL.GS;
using DOL.GS.Commands;
+using DOL.GS.Geometry;
using DOL.GS.PacketHandler;
using DOL.GS.PropertyCalc;
using DOL.GS.ServerProperties;
@@ -428,18 +429,18 @@ public Territory AddTerritory(Territory.eType type, IArea area, string areaId, u
}
var coords = GetCoordinates(area);
- if (coords == null)
+ if (coords == Coordinate.Nowhere)
{
return null;
}
- var zone = region.GetZone(coords.X, coords.Y);
+ var zone = region.GetZone(coords);
if (zone == null)
{
return null;
}
- var territory = new Territory(type, zone, new List{area}, (area as AbstractArea)?.Description ?? "New territory", boss, new Vector3(coords.X, coords.Y, coords.Z), regionId, group);
+ var territory = new Territory(type, zone, new List{area}, (area as AbstractArea)?.Description ?? "New territory", boss, coords, regionId, group);
try
{
@@ -455,14 +456,14 @@ public Territory AddTerritory(Territory.eType type, IArea area, string areaId, u
return territory;
}
- public static AreaCoordinate GetCoordinates(IArea area)
+ public static Coordinate GetCoordinates(IArea area)
{
return area switch
{
- DOL.GS.Area.Circle circle => new AreaCoordinate() { X = circle.Position.X, Y = circle.Position.Y, Z = circle.Position.Z },
- Square sq => new AreaCoordinate() { X = sq.Position.X, Y = sq.Position.Y, Z = sq.Position.Z },
- Polygon poly => new AreaCoordinate() { X = poly.Position.X, Y = poly.Position.Y, Z = poly.Position.Z },
- _ => null
+ DOL.GS.Area.Circle circle => circle.Coordinate,
+ Square sq => sq.Coordinate,
+ Polygon poly => poly.Coordinate,
+ _ => Coordinate.Nowhere
};
}
diff --git a/GameServer/_scripts/AmteScripts/GameObjects/Coffre/CoffrexPlayer.cs b/GameServer/_scripts/AmteScripts/GameObjects/Coffre/CoffrexPlayer.cs
index 8774ac61..dcda774c 100644
--- a/GameServer/_scripts/AmteScripts/GameObjects/Coffre/CoffrexPlayer.cs
+++ b/GameServer/_scripts/AmteScripts/GameObjects/Coffre/CoffrexPlayer.cs
@@ -56,20 +56,6 @@ public string CoffreID
}
}
- [DataElement(AllowDbNull = false)]
- public DateTime LastTimeRowUpdated
- {
- get
- {
- return m_lasttimerowupdated;
- }
- set
- {
- Dirty = true;
- m_lasttimerowupdated = value;
- }
- }
-
public CoffrexPlayer()
{
}
diff --git a/GameServer/_scripts/AmteScripts/GameObjects/Coffre/GameCoffre.cs b/GameServer/_scripts/AmteScripts/GameObjects/Coffre/GameCoffre.cs
index 62ba0978..048015a0 100644
--- a/GameServer/_scripts/AmteScripts/GameObjects/Coffre/GameCoffre.cs
+++ b/GameServer/_scripts/AmteScripts/GameObjects/Coffre/GameCoffre.cs
@@ -13,6 +13,7 @@
using DOL.MobGroups;
using DOL.Events;
using DOL.GS.GameEvents;
+using DOL.GS.Geometry;
namespace DOL.GS.Scripts
{
@@ -486,7 +487,7 @@ private TPPoint GetSmartNextTPPoint(IList tpPoints)
foreach (var tpPoint in tpPoints)
{
- int playerCount = WorldMgr.GetPlayersCloseToSpot(tpPoint.Region, (float)tpPoint.X, (float)tpPoint.Y, (float)tpPoint.Z, 1500).OfType().Count(); // Using 1500 directly
+ int playerCount = WorldMgr.GetPlayersCloseToSpot(Position.Create(tpPoint.Region, tpPoint.X, tpPoint.Y, tpPoint.Z), 1500).OfType().Count(); // Using 1500 directly
if (playerCount > maxPlayerCount)
{
maxPlayerCount = playerCount;
@@ -820,10 +821,7 @@ private void HandlePopMob()
{
var mob = new AmteMob(new NpcTemplate(template))
{
- Position = new Vector3(Position.X, Position.Y, Position.Z),
- Heading = Heading,
- CurrentRegionID = CurrentRegionID,
- CurrentRegion = CurrentRegion,
+ Position = this.Position,
Size = 50,
Name = template.Name
};
@@ -1022,10 +1020,8 @@ public override void LoadFromDatabase(DataObject obj)
DBCoffre coffre = obj as DBCoffre;
if (coffre == null) return;
Name = coffre.Name;
- Position = new Vector3(coffre.X, coffre.Y, coffre.Z);
- Heading = (ushort)(coffre.Heading & 0xFFF);
+ Position = Position.Create(coffre.Region, coffre.X, coffre.Y, coffre.Z, coffre.Heading);
HasPickableAnim = coffre.HasPickableAnim;
- CurrentRegionID = coffre.Region;
Model = coffre.Model;
LastOpen = coffre.LastOpen;
ItemInterval = coffre.ItemInterval;
diff --git a/GameServer/_scripts/AmteScripts/GameObjects/CustomVault.cs b/GameServer/_scripts/AmteScripts/GameObjects/CustomVault.cs
index de66b799..7afbd24b 100644
--- a/GameServer/_scripts/AmteScripts/GameObjects/CustomVault.cs
+++ b/GameServer/_scripts/AmteScripts/GameObjects/CustomVault.cs
@@ -59,7 +59,7 @@ public override bool Interact(GamePlayer player)
return true;
}
- protected void AddObserver(GamePlayer player)
+ public override void AddObserver(GamePlayer player)
{
lock (_vaultLock)
{
diff --git a/GameServer/_scripts/AmteScripts/GameObjects/FollowingFriendMob.cs b/GameServer/_scripts/AmteScripts/GameObjects/FollowingFriendMob.cs
index 9fe0ce0c..c0bd2fb9 100644
--- a/GameServer/_scripts/AmteScripts/GameObjects/FollowingFriendMob.cs
+++ b/GameServer/_scripts/AmteScripts/GameObjects/FollowingFriendMob.cs
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Numerics;
using System.Timers;
using DOL.AI.Brain;
using DOL.Database;
using DOL.Events;
using DOL.GS;
+using DOL.GS.Geometry;
using DOL.GS.PacketHandler;
using DOL.GS.Scripts;
using DOL.MobGroups;
@@ -59,7 +59,7 @@ public override bool Interact(GamePlayer player)
{
if (!base.Interact(player) && (IsPeaceful || WaitingInArea ||
(((StandardMobBrain)Brain).AggroLevel == 0 && ((StandardMobBrain)Brain).AggroRange == 0))
- && CurrentRegion.GetAreasOfSpot(Position).OfType().FirstOrDefault(a => a.DbArea != null && a.DbArea.ObjectId == AreaToEnter) != null)
+ && CurrentRegion.GetAreasOfSpot(Coordinate).OfType().FirstOrDefault(a => a.DbArea != null && a.DbArea.ObjectId == AreaToEnter) != null)
return false;
if (PlayerFollow != null && PlayerFollow == player)
{
@@ -248,7 +248,7 @@ public void ResetFriendMob()
AddToWorld();
}
- public void Reset()
+ public override void Reset()
{
ResetFriendMobs();
}
@@ -346,14 +346,14 @@ protected override int FollowTimerCallback(RegionTimer callingTimer)
}
//Calculate the difference between our position and the players position
- var diff = followTarget.Position - Position;
-
+ var diff = followTarget.Coordinate - Coordinate;
+
//SH: Removed Z checks when one of the two Z values is zero(on ground)
float distanceToTarget;
if (followTarget.Position.Z == 0 || Position.Z == 0)
- distanceToTarget = (float)Math.Sqrt(diff.X * diff.X + diff.Y * diff.Y);
+ distanceToTarget = GetDistance2DTo(followTarget);
else
- distanceToTarget = (float)Math.Sqrt(diff.X * diff.X + diff.Y * diff.Y + diff.Z * diff.Z);
+ distanceToTarget = GetDistanceTo(followTarget);
//Are we in range still?
if (followTarget == PlayerFollow)
@@ -405,10 +405,10 @@ protected override int FollowTimerCallback(RegionTimer callingTimer)
if (area != null && !WaitingInArea)
{
StopFollowing();
- var targetPos = new Vector3(area.DbArea.X, area.DbArea.Y, area.DbArea.Z);
+ var targetPos = Coordinate.Create(area.DbArea.X, area.DbArea.Y, area.DbArea.Z);
var angle = Math.Atan2(targetPos.Y - Position.Y, targetPos.X - Position.X);
- targetPos.X = area.DbArea.X + (float)Math.Cos(angle) * Util.Random(200, 300);
- targetPos.Y = area.DbArea.Y + (float)Math.Sin(angle) * Util.Random(200, 300);
+
+ targetPos += Vector.Create(Angle.Radians(angle), Util.Random(200, 300));
WaitingInArea = true;
followTarget.Notify(GameLivingEvent.BringAFriend, followTarget, new BringAFriendArgs(this, true));
PathTo(targetPos, 130);
@@ -421,12 +421,12 @@ protected override int FollowTimerCallback(RegionTimer callingTimer)
// follow on distance
diff = (diff / distanceToTarget) * m_followMinDist;
- var newPos = followTarget.Position - diff;
+ var newPos = followTarget.Coordinate - diff;
if (followTarget == PlayerFollow)
{
var speed = MaxSpeed;
- if (GameMath.GetDistance2D(Position, followTarget.Position) < 200)
+ if (IsWithinRadius(followTarget, 200))
speed = 0;
PathTo(newPos, speed);
}
diff --git a/GameServer/_scripts/AmteScripts/GameObjects/FollowingMob.cs b/GameServer/_scripts/AmteScripts/GameObjects/FollowingMob.cs
index fd67a1a6..58c80012 100644
--- a/GameServer/_scripts/AmteScripts/GameObjects/FollowingMob.cs
+++ b/GameServer/_scripts/AmteScripts/GameObjects/FollowingMob.cs
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
-using System.Numerics;
using DOL.AI.Brain;
using DOL.Database;
using DOL.Events;
using DOL.GS;
+using DOL.GS.Geometry;
using DOL.GS.Scripts;
namespace DOL.GS.Scripts
@@ -130,14 +130,15 @@ protected override int FollowTimerCallback(RegionTimer callingTimer)
}
//Calculate the difference between our position and the players position
- var diff = followTarget.Position - Position;
+ var diff = followTarget.Coordinate - Coordinate;
//SH: Removed Z checks when one of the two Z values is zero(on ground)
float distance;
if (followTarget.Position.Z == 0 || Position.Z == 0)
- distance = (float)Math.Sqrt(diff.X * diff.X + diff.Y * diff.Y);
+ distance = GetDistance2DTo(followTarget);
else
- distance = (float)Math.Sqrt(diff.X * diff.X + diff.Y * diff.Y + diff.Z * diff.Z);
+ distance = GetDistanceTo(followTarget);
+
//if distance is greater then the max follow distance, stop following and return home
if (distance > m_followMaxDist)
@@ -188,22 +189,21 @@ protected override int FollowTimerCallback(RegionTimer callingTimer)
// follow on distance
diff = (diff / distance) * m_followMinDist;
- var newPos = followTarget.Position - diff;
+ var newCoordinate = followTarget.Coordinate - diff;
if (followTarget == MobFollow)
{
var angle = (m_Angle + followTarget.Heading / GameMath.RADIAN_TO_HEADING) % (Math.PI * 2);
+ Vector direction = Vector.Create(Angle.Radians(angle), m_DistMob);
- newPos.X = followTarget.Position.X + (float)Math.Cos(angle) * m_DistMob;
- newPos.Y = followTarget.Position.Y + (float)Math.Sin(angle) * m_DistMob;
-
+ newCoordinate += direction;
var speed = MaxSpeed;
- if (GameMath.GetDistance2D(Position, newPos) < 500)
+ if (GameMath.GetDistance2D(Coordinate, newCoordinate) < 500)
speed = (short)Math.Min(MaxSpeed, MobFollow.CurrentSpeed + 6);
- PathTo(newPos, speed);
+ PathTo(newCoordinate, speed);
}
else
- PathTo(newPos, MaxSpeed);
+ PathTo(newCoordinate, MaxSpeed);
return ServerProperties.Properties.GAMENPC_FOLLOWCHECK_TIME;
}
diff --git a/GameServer/_scripts/AmteScripts/GameObjects/GameBoatAmte.cs b/GameServer/_scripts/AmteScripts/GameObjects/GameBoatAmte.cs
index 56ee031e..87f1d23f 100644
--- a/GameServer/_scripts/AmteScripts/GameObjects/GameBoatAmte.cs
+++ b/GameServer/_scripts/AmteScripts/GameObjects/GameBoatAmte.cs
@@ -1,8 +1,8 @@
-using System.Numerics;
using DOL.AI.Brain;
using DOL.Database;
using DOL.GS.PacketHandler;
using DOL.GS.Movement;
+using DOL.GS.Geometry;
namespace DOL.GS
{
@@ -79,11 +79,10 @@ public override bool AddToWorld()
{
if (!base.AddToWorld()) return false;
SetOwnBrain(new BlankBrain());
- Reset();
return true;
}
- public void Reset()
+ public override void Reset()
{
if (IsMoving)
StopMoving();
@@ -104,13 +103,11 @@ public override void LoadFromDatabase(DataObject obj)
Mob npc = (Mob)obj;
Name = npc.Name;
GuildName = npc.Guild;
- Position = new Vector3(npc.X, npc.Y, npc.Z);
- m_Heading = (ushort)(npc.Heading & 0xFFF);
+ Position = Position.Create(npc.Region, npc.X, npc.Y, npc.Z, npc.Heading);
m_maxSpeedBase = (short)npc.Speed; // TODO db has currently senseless information here, mob type db required
if (m_maxSpeedBase == 0)
m_maxSpeedBase = 600;
m_currentSpeed = 0;
- CurrentRegionID = npc.Region;
Realm = (eRealm)npc.Realm;
Model = npc.Model;
Size = npc.Size;
diff --git a/GameServer/_scripts/AmteScripts/GameObjects/MageMob/MageMobBrain.cs b/GameServer/_scripts/AmteScripts/GameObjects/MageMob/MageMobBrain.cs
index f45e3621..16052ab9 100644
--- a/GameServer/_scripts/AmteScripts/GameObjects/MageMob/MageMobBrain.cs
+++ b/GameServer/_scripts/AmteScripts/GameObjects/MageMob/MageMobBrain.cs
@@ -4,6 +4,7 @@
using DOL.GS;
using DOL.GS.Scripts;
using System.Numerics;
+using DOL.GS.Geometry;
namespace DOL.AI.Brain
{
@@ -38,13 +39,13 @@ public override void Think()
///The target to flee.
protected virtual void CalculateFleeTarget(GameLiving target)
{
- ushort TargetAngle = (ushort)((Body.GetHeading(target) + 2048) % 4096);
+ ushort TargetAngle = Body.GetAngleTo(target.Coordinate).InHeading;
var fleePoint = Body.GetPointFromHeading(TargetAngle, 300);
- var point = PathingMgr.Instance.GetClosestPoint(Body.CurrentZone, new Vector3(fleePoint, Body.Position.Z), 128, 128, 256);
+ var point = PathingMgr.Instance.GetClosestPointAsync(Body.CurrentZone, Coordinate.Create(fleePoint.X, fleePoint.Y, Body.Position.Z), 128, 128, 256);
Body.StopFollowing();
Body.StopAttack();
- Body.PathTo(point.HasValue ? point.Value : new Vector3(fleePoint, Body.Position.Z), Body.MaxSpeed);
+ Body.PathTo(point.HasValue ? Coordinate.Create(point.Value) : Coordinate.Create(fleePoint.X, fleePoint.Y, Body.Position.Z), Body.MaxSpeed);
}
}
diff --git a/GameServer/_scripts/AmteScripts/GameObjects/PlaceAssise.cs b/GameServer/_scripts/AmteScripts/GameObjects/PlaceAssise.cs
index 37648682..82b601cf 100644
--- a/GameServer/_scripts/AmteScripts/GameObjects/PlaceAssise.cs
+++ b/GameServer/_scripts/AmteScripts/GameObjects/PlaceAssise.cs
@@ -3,6 +3,7 @@
using DOL.Database;
using DOL.GS.PacketHandler;
using DOL.Language;
+using DOL.GS.Geometry;
namespace DOL.GS.Scripts
{
@@ -59,8 +60,7 @@ public override void LoadFromDatabase(DataObject obj)
Mob npc = (Mob)obj;
Name = npc.Name;
GuildName = npc.Guild;
- Position = new Vector3(npc.X, npc.Y, npc.Z);
- m_Heading = (ushort)(npc.Heading & 0xFFF);
+ Position = Position.Create(npc.Region, npc.X, npc.Y, npc.Z, (ushort)(npc.Heading & 0xFFF));
m_maxSpeedBase = (short)npc.Speed; // TODO db has currently senseless information here, mob type db required
if (m_maxSpeedBase == 0)
m_maxSpeedBase = 600;
@@ -86,7 +86,7 @@ public override void SaveIntoDatabase()
mob.X = (int)Position.X;
mob.Y = (int)Position.Y;
mob.Z = (int)Position.Z;
- mob.Heading = Heading;
+ mob.Heading = Position.Orientation.InHeading;
mob.Speed = MaxSpeedBase;
mob.Region = CurrentRegionID;
mob.Realm = (byte)Realm;
diff --git a/GameServer/_scripts/AmteScripts/GameObjects/SplitMob.cs b/GameServer/_scripts/AmteScripts/GameObjects/SplitMob.cs
index dc188af6..a32f1cbe 100644
--- a/GameServer/_scripts/AmteScripts/GameObjects/SplitMob.cs
+++ b/GameServer/_scripts/AmteScripts/GameObjects/SplitMob.cs
@@ -8,6 +8,7 @@
using DOL.Events;
using DOL.Database;
using DOL.GS.PacketHandler;
+using DOL.GS.Geometry;
using log4net;
namespace DOL.GS.Scripts
@@ -56,11 +57,10 @@ public void Split(GamePlayer player)
}
+
public void SetVariables(GameNPC mob)
{
- mob.Position = new System.Numerics.Vector3(this.Position.X + 10, this.Position.Y + 10, this.Position.Z);
- mob.CurrentRegion = this.CurrentRegion;
- mob.Heading = this.Heading;
+ mob.Position = Position.With(Coordinate.Create(this.Coordinate.X + 10, this.Coordinate.Y + 10, this.Coordinate.Z));
mob.Level = this.Level;
mob.Realm = this.Realm;
mob.Name = "Split's Minion";
diff --git a/GameServer/_scripts/AmteScripts/Managers/AmtenaelRules.cs b/GameServer/_scripts/AmteScripts/Managers/AmtenaelRules.cs
index eb078b73..a747c447 100644
--- a/GameServer/_scripts/AmteScripts/Managers/AmtenaelRules.cs
+++ b/GameServer/_scripts/AmteScripts/Managers/AmtenaelRules.cs
@@ -156,15 +156,15 @@ public override void OnRegionChanged(DOLEvent e, object sender, EventArgs args)
///
///
///
- public override void OnPlayerTeleport(GamePlayer player, GameLocation source, Teleport destination)
+ public override void OnPlayerTeleport(GamePlayer player, Teleport destination)
{
// Since region change already starts an immunity timer we only want to do this if a player
// is teleporting within the same region
- if (source.RegionID == destination.RegionID)
+ if (player.CurrentRegionID == destination.RegionID)
{
StartPVEImmunityTimer(player, Properties.TIMER_PVE_TELEPORT * 1000);
}
- base.OnPlayerTeleport(player, source, destination);
+ base.OnPlayerTeleport(player, destination);
}
///
@@ -1073,7 +1073,7 @@ public override void OnPlayerKilled(GamePlayer killedPlayer, GameObject killer)
if (!BG && living is GamePlayer)
{
- AbstractGameKeep keep = GameServer.KeepManager.GetKeepCloseToSpot(living.CurrentRegionID, living.Position, 16000);
+ AbstractGameKeep keep = GameServer.KeepManager.GetKeepCloseToSpot(living.Position, 16000);
if (keep != null)
{
byte bonus = 0;
diff --git a/GameServer/_scripts/AmteScripts/PvP/PvpManager.cs b/GameServer/_scripts/AmteScripts/PvP/PvpManager.cs
index a29bc591..44a81d7e 100644
--- a/GameServer/_scripts/AmteScripts/PvP/PvpManager.cs
+++ b/GameServer/_scripts/AmteScripts/PvP/PvpManager.cs
@@ -7,6 +7,7 @@
using DOL.Database;
using DOL.Events;
using DOL.GS;
+using DOL.GS.Geometry;
using DOL.GS.PacketHandler;
using log4net;
@@ -17,7 +18,7 @@ public class PvpManager
private static readonly TimeSpan _startTime = new TimeSpan(14, 0, 0);
private static readonly TimeSpan _endTime = _startTime.Add(TimeSpan.FromHours(8));
private const int _checkInterval = 30 * 1000; // 30 seconds
- private static readonly GameLocation _stuckSpawn = new GameLocation("", 51, 434303, 493165, 3088, 1069);
+ private static readonly Position _stuckSpawn = Position.Create(51, 434303, 493165, 3088, 1069);
#region Static part
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -57,7 +58,7 @@ public static void OnServerStopped(DOLEvent e, object sender, EventArgs args)
///
/// <regionID, Tuple<TPs, spawnAlb, spawnMid, spawnHib>>
///
- private readonly Dictionary> _maps = new Dictionary>();
+ private readonly Dictionary> _maps = new();
private PvpManager()
{
@@ -83,7 +84,7 @@ public IEnumerable FindPvPMaps()
var spawn = WorldMgr.GetNPCsByNameFromRegion("SPAWN", id, eRealm.None).FirstOrDefault();
if (spawn == null)
continue;
- _maps.Add(id, new Tuple(spawn, new GameLocation("Spawn", spawn)));
+ _maps.Add(id, new Tuple(spawn, spawn.Position));
}
return (from m in _maps select m.Key);
}
diff --git a/GameServer/_scripts/AmteScripts/RvR/RvrManager.cs b/GameServer/_scripts/AmteScripts/RvR/RvrManager.cs
index f04649ae..b77157b1 100644
--- a/GameServer/_scripts/AmteScripts/RvR/RvrManager.cs
+++ b/GameServer/_scripts/AmteScripts/RvR/RvrManager.cs
@@ -8,6 +8,7 @@
using DOL.Database;
using DOL.Events;
using DOL.GS;
+using DOL.GS.Geometry;
using DOL.GS.PacketHandler;
using DOL.GS.ServerProperties;
using DOL.Language;
@@ -51,7 +52,7 @@ public class RvrManager
private static DateTime _startTime = DateTime.Today.AddHours(23D).Add(TimeSpan.FromMinutes(5)); //20H00
private static DateTime _endTime = _startTime.Add(TimeSpan.FromMinutes(20)); //2H00 + 1
private const int _checkInterval = 30 * 1000; // 30 seconds
- private static readonly GameLocation _stuckSpawn = new GameLocation("", 51, 434303, 493165, 3088, 1069);
+ private static readonly Position _stuckSpawn = Position.Create(51, 434303, 493165, 3088, 1069);
private Dictionary> RvrStats = new Dictionary>();
private Dictionary Scores = new Dictionary();
private Dictionary kills = new Dictionary();
@@ -172,7 +173,7 @@ public void OnControlChange(string lordId, Guild guild)
m.Realm = guild.Realm;
});
map.RvRTerritory.Boss.Realm = guild.Realm;
- AbstractGameKeep keep = GameServer.KeepManager.GetKeepCloseToSpot(map.RvRTerritory.RegionId, map.RvRTerritory.Boss.Position, 100000);
+ AbstractGameKeep keep = GameServer.KeepManager.GetKeepCloseToSpot(map.RvRTerritory.Boss.Position, 100000);
keep.TempRealm = guild.Realm;
keep.Reset(guild.Realm);
keep.Guild = guild;
@@ -186,7 +187,7 @@ public void OnControlChange(string lordId, Guild guild)
public RvRTerritory GetRvRTerritory(ushort regionId)
{
- var map = this._maps.Values.FirstOrDefault(v => v.RvRTerritory != null && v.Location.RegionID.Equals(regionId));
+ var map = this._maps.Values.FirstOrDefault(v => v.RvRTerritory != null && v.Position.RegionID.Equals(regionId));
if (map == null)
{
@@ -348,16 +349,16 @@ public IEnumerable InitMapsAndTerritories()
// _maps.Add(name, map);
//});
- _regions = _maps.Values.GroupBy(v => v.Location.RegionID).Select(v => v.Key).OrderBy(v => v);
+ _regions = _maps.Values.GroupBy(v => v.Position.RegionID).Select(v => v.Key).OrderBy(v => v);
_regions.Foreach(r => this.RvrStats.Add(r, new string[] { }));
- return from m in _maps select m.Value.Location.RegionID;
+ return from m in _maps select m.Value.Position.RegionID;
}
private RvRMap BuildRvRMap(GameNPC initNpc)
{
RvRTerritory rvrTerritory = null;
- if (!_maps.Values.Any(v => v.Location.RegionID.Equals(initNpc.CurrentRegionID)))
+ if (!_maps.Values.Any(v => v.Position.RegionID.Equals(initNpc.CurrentRegionID)))
{
var lord = (LordRvR)(initNpc.CurrentRegion.Objects.FirstOrDefault(o => o is LordRvR));
@@ -369,12 +370,12 @@ private RvRMap BuildRvRMap(GameNPC initNpc)
var areaName = string.IsNullOrEmpty(lord.GuildName) ? initNpc.Name : lord.GuildName;
var area = new Area.Circle(areaName, lord.Position.X, lord.Position.Y, lord.Position.Z, RVR_RADIUS);
- rvrTerritory = new RvRTerritory(lord.CurrentZone, new List{area}, area.Description, lord, area.Position, lord.CurrentRegionID, null);
+ rvrTerritory = new RvRTerritory(lord.CurrentZone, new List{area}, area.Description, lord, area.Coordinate, lord.CurrentRegionID, null);
}
return new RvRMap()
{
- Location = new GameLocation(initNpc.Name, initNpc.CurrentRegionID, initNpc.Position.X, initNpc.Position.Y, initNpc.Position.Z),
+ Position = initNpc.Position,
RvRTerritory = rvrTerritory
};
}
@@ -610,7 +611,7 @@ public bool Close()
m.RvRTerritory.Reset();
});
- this._maps.Values.GroupBy(v => v.Location.RegionID).ForEach(region =>
+ this._maps.Values.GroupBy(v => v.Position.RegionID).ForEach(region =>
{
var characters = GameServer.Database.SelectObjects(c => c.Region == +region.Key);
foreach (DOLCharacters chr in characters)
@@ -815,7 +816,7 @@ private bool AddPlayerToCorrectZone(GamePlayer player, string realm)
// }
//}
- player.MoveTo(_maps[key].Location);
+ player.MoveTo(_maps[key].Position);
player.Bind(true);
return true;
}
@@ -922,7 +923,7 @@ public IList GetStatistics(GamePlayer player)
long prHib = clients.Where(c => c.Player.Realm == eRealm.Hibernia).Sum(c => c.Player.Guild.RealmPoints);
long prMid = clients.Where(c => c.Player.Realm == eRealm.Midgard).Sum(c => c.Player.Guild.RealmPoints);
- var maps = this._maps.Values.Where(m => m.RvRTerritory != null && m.Location.RegionID.Equals(player.CurrentRegionID));
+ var maps = this._maps.Values.Where(m => m.RvRTerritory != null && m.Position.RegionID.Equals(player.CurrentRegionID));
if (maps != null)
{
@@ -977,7 +978,7 @@ public bool IsAllowedToAttack(GameLiving attacker, GameLiving defender, bool qui
public bool IsRvRRegion(ushort id)
{
- return _maps.Values.Any(v => v.Location.RegionID.Equals(id));
+ return _maps.Values.Any(v => v.Position.RegionID.Equals(id));
}
private static void _MessageToLiving(GameLiving living, string message)
@@ -990,6 +991,6 @@ private static void _MessageToLiving(GameLiving living, string message)
public class RvRMap
{
public RvRTerritory RvRTerritory { get; set; }
- public GameLocation Location { get; set; }
+ public Position Position { get; set; }
}
}
diff --git a/GameServer/_scripts/AmteScripts/SpecialItems/FeuArtificeItem.cs b/GameServer/_scripts/AmteScripts/SpecialItems/FeuArtificeItem.cs
index 1b59e479..1570d1e7 100644
--- a/GameServer/_scripts/AmteScripts/SpecialItems/FeuArtificeItem.cs
+++ b/GameServer/_scripts/AmteScripts/SpecialItems/FeuArtificeItem.cs
@@ -14,6 +14,7 @@
using DOL.Database;
using DOL.Events;
using DOL.Language;
+using Vector = DOL.GS.Geometry.Vector;
namespace DOL.GS.Scripts
{
@@ -158,7 +159,7 @@ private static Dictionary CreateMobs(GameObject obj)
Level = 1,
Model = 1,
Realm = 0,
- Position = obj.Position + new Vector3(0, 0, 800),
+ Position = obj.Position + Vector.Create(0, 0, 800),
CurrentRegion = obj.CurrentRegion
};
@@ -171,26 +172,26 @@ private static Dictionary CreateMobs(GameObject obj)
//Pyramide:
//Base
- mobs[2].Position += new Vector3(250, 250, 0);
- mobs[3].Position += new Vector3(250, 0, 0);
- mobs[4].Position += new Vector3(250, -250, 0);
- mobs[5].Position += new Vector3(0, -250, 0);
- mobs[6].Position -= new Vector3(250, 250, 0);
- mobs[7].Position -= new Vector3(250, 0, 0);
- mobs[8].Position += new Vector3(-250, 250, 0);
- mobs[9].Position += new Vector3(0, 250, 0);
+ mobs[2].Position += Vector.Create(250, 250, 0);
+ mobs[3].Position += Vector.Create(250, 0, 0);
+ mobs[4].Position += Vector.Create(250, -250, 0);
+ mobs[5].Position += Vector.Create(0, -250, 0);
+ mobs[6].Position -= Vector.Create(250, 250, 0);
+ mobs[7].Position -= Vector.Create(250, 0, 0);
+ mobs[8].Position += Vector.Create(-250, 250, 0);
+ mobs[9].Position += Vector.Create(0, 250, 0);
//2e étage
- mobs[10].Position += new Vector3(+125, +125, 250);
- mobs[11].Position += new Vector3(+125, -125, 250);
- mobs[12].Position += new Vector3(-125, -125, 250);
- mobs[13].Position += new Vector3(-125, +125, 250);
+ mobs[10].Position += Vector.Create(+125, +125, 250);
+ mobs[11].Position += Vector.Create(+125, -125, 250);
+ mobs[12].Position += Vector.Create(-125, -125, 250);
+ mobs[13].Position += Vector.Create(-125, +125, 250);
- mobs[14].Position += new Vector3(0, 0, 250);
+ mobs[14].Position += Vector.Create(0, 0, 250);
mobs[14].Size = 75;
//Sommet
- mobs[15].Position += new Vector3(0, 0, 500);
+ mobs[15].Position += Vector.Create(0, 0, 500);
mobs[15].Size = 100;
foreach (KeyValuePair mob in mobs)
diff --git a/GameServer/_scripts/AmteScripts/Spells/GuarksTeleport.cs b/GameServer/_scripts/AmteScripts/Spells/GuarksTeleport.cs
index 1529ee9b..b997349b 100644
--- a/GameServer/_scripts/AmteScripts/Spells/GuarksTeleport.cs
+++ b/GameServer/_scripts/AmteScripts/Spells/GuarksTeleport.cs
@@ -22,7 +22,6 @@
using DOL.Language;
using DOL.GS.PacketHandler;
using AmteScripts.Managers;
-using DOL.Language;
namespace DOL.GS.Spells
{
diff --git a/GameServer/behaviour/Actions/MoveToAction.cs b/GameServer/behaviour/Actions/MoveToAction.cs
index 0dd0adde..479faebd 100644
--- a/GameServer/behaviour/Actions/MoveToAction.cs
+++ b/GameServer/behaviour/Actions/MoveToAction.cs
@@ -23,27 +23,28 @@
using DOL.Events;
using DOL.GS.Behaviour.Attributes;
using DOL.GS.Behaviour;
+using DOL.GS.Geometry;
namespace DOL.GS.Behaviour.Actions
{
[ActionAttribute(ActionType = eActionType.MoveTo)]
- public class MoveToAction : AbstractAction
+ public class MoveToAction : AbstractAction
{
public MoveToAction(GameNPC defaultNPC, Object p, Object q)
: base(defaultNPC, eActionType.MoveTo, p, q)
{ }
- public MoveToAction(GameNPC defaultNPC, GameLocation location, GameLiving npc)
- : this(defaultNPC, (object)location, (object)npc) { }
+ public MoveToAction(GameNPC defaultNPC, Position position, GameLiving npc)
+ : this(defaultNPC, (object)position, (object)npc) { }
public override void Perform(DOLEvent e, object sender, EventArgs args)
{
GameLiving npc = Q;
- if (P is GameLocation location)
+ if (P is Position position)
{
- npc.MoveTo(location.Position);
+ npc.MoveTo(position);
}
else
{
diff --git a/GameServer/behaviour/Actions/TeleportAction.cs b/GameServer/behaviour/Actions/TeleportAction.cs
index f922ec1b..01c1b13f 100644
--- a/GameServer/behaviour/Actions/TeleportAction.cs
+++ b/GameServer/behaviour/Actions/TeleportAction.cs
@@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
+using DOL.Database;
using System;
using System.Collections.Generic;
using System.Text;
@@ -29,7 +30,7 @@
namespace DOL.GS.Behaviour.Actions
{
[ActionAttribute(ActionType = eActionType.Teleport, DefaultValueQ = 0)]
- public class TeleportAction : AbstractAction
+ public class TeleportAction : AbstractAction
{
public TeleportAction(GameNPC defaultNPC, Object p, Object q)
@@ -38,7 +39,7 @@ public TeleportAction(GameNPC defaultNPC, Object p, Object q)
}
- public TeleportAction(GameNPC defaultNPC, GameLocation location, int fuzzyRadius)
+ public TeleportAction(GameNPC defaultNPC, Teleport location, int fuzzyRadius)
: this(defaultNPC, (object)location, (object)fuzzyRadius) { }
@@ -46,16 +47,16 @@ public TeleportAction(GameNPC defaultNPC, GameLocation location, int fuzzyRadius
public override void Perform(DOLEvent e, object sender, EventArgs args)
{
GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);
- GameLocation location = P;
+ Teleport location = P;
int radius = Q;
- if (location.Name != null)
+ if (location.TeleportID != null)
{
- player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Behaviour.TeleportAction.TeleportedToLoc", player, location.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
+ player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Behaviour.TeleportAction.TeleportedToLoc", player, location.TeleportID), eChatType.CT_System, eChatLoc.CL_SystemWindow);
}
var randomOffset = Vector.Create(x: Util.Random(-radius, radius), y: Util.Random(-radius, radius));
- player.MoveTo(location.Position + randomOffset);
+ player.MoveTo(location.GetPosition() + randomOffset);
}
}
}
diff --git a/GameServer/commands/gmcommands/GMTerritories.cs b/GameServer/commands/gmcommands/GMTerritories.cs
index 7420c68c..852d711e 100644
--- a/GameServer/commands/gmcommands/GMTerritories.cs
+++ b/GameServer/commands/gmcommands/GMTerritories.cs
@@ -3,6 +3,7 @@
using DOL.Geometry;
using DOL.GS;
using DOL.GS.Commands;
+using DOL.GS.Geometry;
using DOL.GS.PacketHandler;
using DOL.Language;
using DOL.MobGroups;
@@ -409,12 +410,12 @@ public void OnCommand(GameClient client, string[] args)
return;
}
}
- Vector3 position;
+ Coordinate position;
if (args.Length > arg)
{
if (string.Equals(args[arg], "remove"))
{
- territory.PortalPosition = null;
+ territory.PortalCoordinate = null;
client.SendTranslation("Commands.GM.GMTerritories.PortalRemoved", eChatType.CT_System, eChatLoc.CL_SystemWindow, territory.Name);
return;
}
@@ -438,14 +439,13 @@ public void OnCommand(GameClient client, string[] args)
client.SendTranslation("Commands.GM.GMTerritories.BadCoordinate", eChatType.CT_System, eChatLoc.CL_SystemWindow, args[arg + 2]);
return;
}
- position = new Vector3(x, y, z);
+ position = Coordinate.Create(x, y, z);
}
else
{
- var playerPosition = client.Player.Position;
- position = new Vector3((int)playerPosition.X, (int)playerPosition.Y, (int)playerPosition.Z);
+ position = client.Player.Coordinate;
}
- territory.PortalPosition = position;
+ territory.PortalCoordinate = position;
territory.SaveIntoDatabase();
client.SendTranslation("Commands.GM.GMTerritories.PortalSet", eChatType.CT_System, eChatLoc.CL_SystemWindow, territory.Name, position.X, position.Y, position.Z);
}
diff --git a/GameServer/commands/gmcommands/Instance.cs b/GameServer/commands/gmcommands/Instance.cs
index 6915d9c2..a1e60c64 100644
--- a/GameServer/commands/gmcommands/Instance.cs
+++ b/GameServer/commands/gmcommands/Instance.cs
@@ -306,8 +306,7 @@ public void OnCommand(GameClient client, string[] args)
}
// save current position for use with /instance exit
- GameLocation saveLocation = new GameLocation(player.Name + "_exit", player.CurrentRegionID, player.Position, player.Heading);
- player.TempProperties.setProperty(saveLocation.Name, saveLocation);
+ player.TempProperties.setProperty(player.Name + "_exit", player.Position);
bool success = true;
diff --git a/GameServer/commands/gmcommands/KeepComponent.cs b/GameServer/commands/gmcommands/KeepComponent.cs
index db2f6881..2c6018dc 100644
--- a/GameServer/commands/gmcommands/KeepComponent.cs
+++ b/GameServer/commands/gmcommands/KeepComponent.cs
@@ -166,14 +166,8 @@ so must find an other way to find it....
.With(Angle.Heading(component.ComponentHeading * 1024) + myKeep.Orientation);
component.ComponentHeading = (client.Player.Orientation - myKeep.Orientation).InDegrees / 90;
component.Keep = myKeep;
- //todo good formula
- //component.ComponentX = (component.X - myKeep.X) / 148;
- //component.ComponentY = (myKeep.Y - component.Y) / 148;
-
- //component.ComponentX = (int)((148 * Math.Sin(angle) * myKeep.X - 148 * Math.Sin(angle) * client.Player.X + client.Player.Y - myKeep.Y)
- // / (148 * Math.Sin(angle) - 148 * 148 * 2 * Math.Sin(angle) * Math.Cos(angle)));
- //component.ComponentY = (int)((myKeep.Y - client.Player.Y + 148 * Math.Sin(angle) * component.ComponentX) / (148 * Math.Cos(angle)));
-
+
+ var angle = myKeep.Orientation.InRadians;
component.ComponentX = CalcCX(client.Player, myKeep, angle);
component.ComponentY = CalcCY(client.Player, myKeep, angle);
@@ -357,5 +351,4 @@ public int CalcCY(GamePlayer player, AbstractGameKeep myKeep, double angle)
}
}
}
- }
-}
\ No newline at end of file
+}
diff --git a/GameServer/commands/gmcommands/earthquake.cs b/GameServer/commands/gmcommands/earthquake.cs
index 4b5e26bd..605119e8 100644
--- a/GameServer/commands/gmcommands/earthquake.cs
+++ b/GameServer/commands/gmcommands/earthquake.cs
@@ -2,6 +2,7 @@
using DOL.GS.PacketHandler;
using DOL.GS.Commands;
using DOL.Geometry;
+using DOL.GS.Geometry;
using DOL.Language;
namespace DOL.GS.Scripts
@@ -31,7 +32,7 @@ public void OnCommand(GameClient client, string[] args)
}
else
{
- var tempGroundTarget = client.Player.GroundTarget ?? System.Numerics.Vector3.Zero;// as System.Numerics.Vector3;
+ var tempGroundTarget = client.Player.GroundTargetPosition;// as System.Numerics.Vector3;
x = (int)tempGroundTarget.X;
y = (int)tempGroundTarget.Y;
z = (int)tempGroundTarget.Z;
@@ -97,7 +98,7 @@ public void OnCommand(GameClient client, string[] args)
pakBis.WriteIntLowEndian((uint)y);
pakBis.WriteIntLowEndian((uint)z);
pakBis.Write(BitConverter.GetBytes(radius), 0, sizeof(System.Single));
- int distance = (int)System.Numerics.(int)player.Coordinate.DistanceTo(client.Player.Position);
+ int distance = (int)player.Coordinate.DistanceTo(client.Player.Position);
float newIntensity = intensity * (1 - distance / radius);
pakBis.Write(BitConverter.GetBytes(newIntensity), 0, sizeof(System.Single));
pakBis.Write(BitConverter.GetBytes(duration), 0, sizeof(System.Single));
diff --git a/GameServer/commands/gmcommands/jump.cs b/GameServer/commands/gmcommands/jump.cs
index c127ea96..80dae7ea 100644
--- a/GameServer/commands/gmcommands/jump.cs
+++ b/GameServer/commands/gmcommands/jump.cs
@@ -344,7 +344,7 @@ public void OnCommand(GameClient client, string[] args)
{
Stack positions;
- positions = client.Player.TempProperties.getProperty
///The target to flee.
- protected virtual void CalculateFleeTarget(GameLiving target)
+ protected override void CalculateFleeTarget(GameLiving target)
{
- ushort TargetAngle = (ushort)((Body.GetHeading(target) + 2048) % 4096);
+ ushort TargetAngle = Body.GetAngleTo(target.Coordinate).InHeading;
var fleePoint = Body.GetPointFromHeading(TargetAngle, 450);
- var point = PathingMgr.Instance.GetClosestPoint(Body.CurrentZone, new Vector3(fleePoint, Body.Position.Z), 128, 128, 256);
+ var point = PathingMgr.Instance.GetClosestPointAsync(Body.CurrentZone, Coordinate.Create(fleePoint.X, fleePoint.Y, Body.Position.Z), 128, 128, 256);
Body.StopFollowing();
Body.StopAttack();
- Body.PathTo(point.HasValue ? point.Value : new Vector3(fleePoint, Body.Position.Z), Body.MaxSpeed);
+ Body.PathTo(point.HasValue ? Coordinate.Create(point.Value) : Coordinate.Create(fleePoint.X, fleePoint.Y, Body.Position.Z), Body.MaxSpeed);
//set speed to 130%
m_maxSpeedBuff = (short)(Body.MaxSpeedBase * 0.3);
Body.MaxSpeedBase = (short)(Body.MaxSpeedBase * 1.3);
diff --git a/GameServer/world/WorldMgr.cs b/GameServer/world/WorldMgr.cs
index 3aaa28f2..0f44ae70 100644
--- a/GameServer/world/WorldMgr.cs
+++ b/GameServer/world/WorldMgr.cs
@@ -1277,145 +1277,6 @@ public static void RemoveSessionID(int id)
return;
}
- //Various functions to get a list of players/mobs/items
- #region getdistance
- ///
- /// Get's the distance of two GameObjects
- ///
- /// Object1
- /// Object2
- /// The distance in units or -1 if they are not the same Region
- [Obsolete("Use Point3D.GetDistance")]
- public static float GetDistance(GameObject obj1, GameObject obj2)
- {
- if (obj1 == null || obj2 == null || obj1.CurrentRegion != obj2.CurrentRegion)
- return -1;
- return GetDistance(obj1.X, obj1.Y, obj1.Z, obj2.X, obj2.Y, obj2.Z);
- }
-
- ///
- /// Get's the distance of two GameObjects
- ///
- /// Object1
- /// Object2
- /// Factor for Z distance use lower 0..1 to lower Z influence
- /// The distance in units or -1 if they are not the same Region
- [Obsolete("Use Point3D.GetDistance")]
- public static float GetDistance(GameObject obj1, GameObject obj2, float zfactor)
- {
- if (obj1 == null || obj2 == null || obj1.CurrentRegion != obj2.CurrentRegion)
- return -1;
- return GetDistance(obj1.X, obj1.Y, obj1.Z, obj2.X, obj2.Y, obj2.Z, zfactor);
- }
-
- ///
- /// Gets the distance of two arbitary points in space
- ///
- /// X of Point1
- /// Y of Point1
- /// Z of Point1
- /// X of Point2
- /// Y of Point2
- /// Z of Point2
- /// The distance
- [Obsolete("Use Point3D.GetDistance")]
- public static float GetDistance(float x1, float y1, float z1, float x2, float y2, float z2)
- {
- var xdiff = x1 - x2;
- var ydiff = y1 - y2;
- var zdiff = z1 - z2;
- return (float)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
- }
-
- ///
- /// Gets the distance of two arbitary points in space
- ///
- /// X of Point1
- /// Y of Point1
- /// Z of Point1
- /// X of Point2
- /// Y of Point2
- /// Z of Point2
- /// Factor for Z distance use lower 0..1 to lower Z influence
- /// The distance
- [Obsolete("Use Point3D.GetDistance")]
- public static float GetDistance(float x1, float y1, float z1, float x2, float y2, float z2, float zfactor)
- {
- var xdiff = x1 - x2;
- var ydiff = y1 - y2;
- var zdiff = ((z1 - z2) * zfactor);
- return (float)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
- }
-
- ///
- /// Gets the distance of an Object to an arbitary point
- ///
- /// GameObject used as Point1
- /// X of Point2
- /// Y of Point2
- /// Z of Point2
- /// The distance
- [Obsolete("Use Point3D.GetDistance")]
- public static float GetDistance(GameObject obj, float x, float y, float z)
- {
- return GetDistance(obj.X, obj.Y, obj.Z, x, y, z);
- }
- #endregion get distance
-
- #region check distance
- [Obsolete("Use Point3D.IsWithinRadius")]
- public static bool CheckDistance(float x1, float y1, float z1, float x2, float y2, float z2, int radius)
- {
- return CheckSquareDistance(x1, y1, z1, x2, y2, z2, radius * radius);
- }
- [Obsolete("Use Point3D.IsWithinRadius")]
- public static bool CheckDistance(Vector3 obj, Vector3 obj2, int radius)
- {
- return CheckDistance(obj.X, obj.Y, obj.Z, obj2.X, obj2.Y, obj2.Z, radius);
- }
- [Obsolete("Use Point3D.IsWithinRadius")]
- public static bool CheckDistance(GameObject obj, float x2, float y2, float z2, int radius)
- {
- return CheckDistance(obj.X, obj.Y, obj.Z, x2, y2, z2, radius);
- }
- [Obsolete("Use Point3D.IsWithinRadius")]
- public static bool CheckDistance(GameObject obj, GameObject obj2, int radius)
- {
- if (obj == null || obj2 == null)
- return false;
- if (obj.CurrentRegion != obj2.CurrentRegion)
- return false;
- return CheckDistance(obj.X, obj.Y, obj.Z, obj2.X, obj2.Y, obj2.Z, radius);
- }
- #endregion
- #region check square distance
- [Obsolete("Use Point3D.IsWithinRadius")]
- private static bool CheckSquareDistance(float x1, float y1, float z1, float x2, float y2, float z2, int squareRadius)
- {
- var xdiff = x1 - x2;
- var ydiff = y1 - y2;
- var zdiff = z1 - z2;
- return (xdiff * xdiff + ydiff * ydiff + zdiff * zdiff <= squareRadius);
- }
- [Obsolete("Use Point3D.IsWithinRadius")]
- private static bool CheckSquareDistance(Vector3 obj, Vector3 obj2, int squareRadius)
- {
- return CheckSquareDistance(obj.X, obj.Y, obj.Z, obj2.X, obj2.Y, obj2.Z, squareRadius);
- }
- [Obsolete("Use Point3D.IsWithinRadius")]
- private static bool CheckSquareDistance(GameObject obj, float x2, float y2, float z2, int squareRadius)
- {
- return CheckSquareDistance(obj.X, obj.Y, obj.Z, x2, y2, z2, squareRadius);
- }
- [Obsolete("Use Point3D.IsWithinRadius")]
- private static bool CheckSquareDistance(GameObject obj, GameObject obj2, int squareRadius)
- {
- if (obj.CurrentRegion != obj2.CurrentRegion)
- return false;
- return CheckSquareDistance(obj.X, obj.Y, obj.Z, obj2.X, obj2.Y, obj2.Z, squareRadius);
- }
- #endregion
-
///
/// Returns the number of playing Clients inside a realm
///
diff --git a/GameServer/world/geometry/AABoundingBox.cs b/GameServer/world/geometry/AABoundingBox.cs
index 6fd2c4e6..9b36196c 100644
--- a/GameServer/world/geometry/AABoundingBox.cs
+++ b/GameServer/world/geometry/AABoundingBox.cs
@@ -6,7 +6,7 @@ namespace DOL.GS.Geometry
public readonly struct AABoundingBox : ICollider
{
public readonly Vector3 Min;
- public readonly Vector3 Max;
+ public readonly System.Numerics.Vector3 Max;
public AABoundingBox Box => this;
public AABoundingBox(Vector3 min, Vector3 max)
diff --git a/GameServer/world/pathing/GamePath.cs b/GameServer/world/pathing/GamePath.cs
index 32e831fc..77223358 100644
--- a/GameServer/world/pathing/GamePath.cs
+++ b/GameServer/world/pathing/GamePath.cs
@@ -1,5 +1,5 @@
-using System.Collections.Generic;
-using System.Numerics;
+using DOL.GS.Geometry;
+using System.Collections.Generic;
namespace DOL.GS
{
@@ -17,7 +17,7 @@ public enum MarkerModel
public string Name;
public Region Region;
public bool HasLavaEffect = false;
- public List<(GameLocation point, short speed, MarkerModel model)> Points = new List<(GameLocation point, short speed, MarkerModel model)>();
+ public List<(Coordinate point, short speed, MarkerModel model)> Points = new List<(Coordinate point, short speed, MarkerModel model)>();
public List DebugObjs = new List();
@@ -27,7 +27,7 @@ public GamePath(string name, Region region)
Region = region;
}
- public void Append(GameLocation point, short speed, MarkerModel model = MarkerModel.Brown)
+ public void Append(Coordinate point, short speed, MarkerModel model = MarkerModel.Brown)
{
Points.Add((point, speed, model));
}
@@ -40,10 +40,9 @@ public void Show()
{
//Create a new object
var obj = new GameStaticItem();
- obj.Position = pt.Position + Vector3.UnitZ;
+ obj.Position = Position.Create(Region.ID, pt);
obj.CurrentRegion = Region;
- obj.Heading = pt.Heading;
- obj.Name = $"{pt.Name}--{speed} spd";
+ obj.Name = $"{pt.ToString()}--{speed} spd";
obj.Model = 2965;
switch (model)
{
diff --git a/GameServer/world/pathing/IPathingMgr.cs b/GameServer/world/pathing/IPathingMgr.cs
index 08c561c4..0ff2583d 100644
--- a/GameServer/world/pathing/IPathingMgr.cs
+++ b/GameServer/world/pathing/IPathingMgr.cs
@@ -25,7 +25,7 @@ public interface IPathingMgr
/// Returns the closest point on the navmesh, if available, or no point found.
/// Returns the input position if no navmesh is available
///
- Vector3? GetClosestPointAsync(Zone zone, Vector3 position, float xRange = 256f, float yRange = 256f, float zRange = 256f);
+ Vector3? GetClosestPointAsync(Zone zone, Coordinate position, float xRange = 256f, float yRange = 256f, float zRange = 256f);
///
/// True if pathing is enabled for the specified zone
diff --git a/GameServer/world/pathing/LocalPathingMgr.cs b/GameServer/world/pathing/LocalPathingMgr.cs
index e2ee3ab0..f9baf1ed 100644
--- a/GameServer/world/pathing/LocalPathingMgr.cs
+++ b/GameServer/world/pathing/LocalPathingMgr.cs
@@ -270,10 +270,10 @@ private static float[] CoordinateToRecastFloatArray(Coordinate loc)
///
/// Returns the closest point on the navmesh (UNTESTED! EXPERIMENTAL! WILL GO SUPERNOVA ON USE! MAYBE!?)
///
- public Vector3? GetClosestPointAsync(Zone zone, Vector3 position, float xRange = 256f, float yRange = 256f, float zRange = 256f)
+ public Vector3? GetClosestPointAsync(Zone zone, Coordinate position, float xRange = 256f, float yRange = 256f, float zRange = 256f)
{
if (!_navmeshPtrs.ContainsKey(zone.ID))
- return position; // Assume the point is safe if we don't have a navmesh
+ return position.ToSysVector3(); // Assume the point is safe if we don't have a navmesh
//GSStatistics.Paths.Inc();
Vector3? result = null;
@@ -284,7 +284,7 @@ private static float[] CoordinateToRecastFloatArray(Coordinate loc)
_navmeshQueries.Value.Add(zone.ID, query);
}
var ptrs = _navmeshPtrs[zone.ID];
- var center = ToRecastFloats(position + Vector3.UnitZ * 8);
+ var center = ToRecastFloats(position.ToSysVector3() + Vector3.UnitZ * 8);
var outVec = new float[3];
var defaultInclude = (dtPolyFlags.ALL ^ dtPolyFlags.DISABLED);
diff --git a/GameServer/world/pathing/NullPathingMgr.cs b/GameServer/world/pathing/NullPathingMgr.cs
index 9ad0aadf..e5a2e931 100644
--- a/GameServer/world/pathing/NullPathingMgr.cs
+++ b/GameServer/world/pathing/NullPathingMgr.cs
@@ -23,9 +23,9 @@ public void Stop()
public Vector3? GetRandomPointAsync(Zone zone, Coordinate center, float radius)
=> null;
- public Vector3? GetClosestPointAsync(Zone zone, Vector3 position, float xRange = 256, float yRange = 256, float zRange = 256)
+ public Vector3? GetClosestPointAsync(Zone zone, Coordinate position, float xRange = 256, float yRange = 256, float zRange = 256)
{
- return position;
+ return position.ToSysVector3();
}
public bool HasNavmesh(Zone zone)
diff --git a/GameServer/world/pathing/PathCalculator.cs b/GameServer/world/pathing/PathCalculator.cs
index aa96fe44..07098fda 100644
--- a/GameServer/world/pathing/PathCalculator.cs
+++ b/GameServer/world/pathing/PathCalculator.cs
@@ -74,6 +74,11 @@ public static bool IsSupported(GameNPC o)
///
public bool DidFindPath { get; private set; }
+ ///
+ /// True if this path should be visualized
+ ///
+ public bool VisualizePath { get; set; }
+
///
/// Creates a path calculator for the given NPC
///
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
index 2b88eaee..3730a606 100644
--- a/Tests/Tests.csproj
+++ b/Tests/Tests.csproj
@@ -46,7 +46,7 @@
-
+