From d26ae63e94db3553cfa99d47451b818c9da3eb07 Mon Sep 17 00:00:00 2001 From: Sergi Rosell <50594106+srosellj@users.noreply.github.com> Date: Mon, 5 Oct 2026 02:48:10 +0200 Subject: [PATCH] fix: duel teams start on their own arena points, in formation (#2686) * fix: duel teams start on their own arena points, in formation MoveInside clamped the team index with Math.Min instead of Math.Max, so every team started on the west edge point. The formation rotation also reused the already-rotated X when computing Y, stacking players on the north and south edges, and the SW/NE corners swapped axes, which leaves the corner formation pointing out of the arena. * refactor: one start point index clamp for GetBaseStartPoint and MoveInside The clamp was written twice, and only one copy was correct. * refactor: leave the placement loop as it was Only the rotation lines in the loop belong to the fix. --- Projects/UOContent/Engines/ConPVP/Arena.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Projects/UOContent/Engines/ConPVP/Arena.cs b/Projects/UOContent/Engines/ConPVP/Arena.cs index d31820339..5c0c3d6f0 100644 --- a/Projects/UOContent/Engines/ConPVP/Arena.cs +++ b/Projects/UOContent/Engines/ConPVP/Arena.cs @@ -226,8 +226,8 @@ namespace Server.Engines.ConPVP new[,] { { 0, -1 }, { -1, 0 } }, // south new[,] { { +1, 0 }, { 0, +1 } }, // nw new[,] { { -1, 0 }, { 0, -1 } }, // se - new[,] { { 0, +1 }, { +1, 0 } }, // sw - new[,] { { 0, -1 }, { -1, 0 } } // ne + new[,] { { +1, 0 }, { 0, -1 } }, // sw + new[,] { { -1, 0 }, { 0, +1 } } // ne }; private bool m_Active; @@ -535,11 +535,13 @@ namespace Server.Engines.ConPVP public override string ToString() => "..."; - public Point3D GetBaseStartPoint(int index) => Points.Points[Math.Max(index, 0) % Points.Points.Length]; + private int StartPointIndex(int index) => Math.Max(index, 0) % Points.Points.Length; + + public Point3D GetBaseStartPoint(int index) => Points.Points[StartPointIndex(index)]; public void MoveInside(DuelPlayer[] players, int index) { - index = Math.Min(index, 0) % Points.Points.Length; + index = StartPointIndex(index); var start = Points.Points[index]; @@ -570,10 +572,10 @@ namespace Server.Engines.ConPVP p = offsets[^1]; } - p.X = p.X * matrix[0, 0] + p.Y * matrix[0, 1]; - p.Y = p.X * matrix[1, 0] + p.Y * matrix[1, 1]; + var x = p.X * matrix[0, 0] + p.Y * matrix[0, 1]; + var y = p.X * matrix[1, 0] + p.Y * matrix[1, 1]; - mob.MoveToWorld(new Point3D(start.X + p.X, start.Y + p.Y, start.Z), m_Facet); + mob.MoveToWorld(new Point3D(start.X + x, start.Y + y, start.Z), m_Facet); mob.Direction = mob.GetDirectionTo(Wall); Players.Add(mob);