From f4c89e8fb5b910923c7e0229cd99195e40cb95a3 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Mon, 23 Aug 2021 21:38:41 +0000 Subject: [PATCH] Changed getRandomPoint calculation for ZoneCylinder. --- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- .../model/zone/form/ZoneCylinder.java | 18 +++++++++++++----- 23 files changed, 299 insertions(+), 115 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_9.2_ReturnOfTheQueenAnt_Ch2/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_9.2_ReturnOfTheQueenAnt_Ch2/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_9.2_ReturnOfTheQueenAnt_Ch2/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_9.2_ReturnOfTheQueenAnt_Ch2/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index eb89b925a6..6a922b69d4 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -138,11 +138,19 @@ public class ZoneCylinder extends ZoneForm @Override public Location getRandomPoint() { - final int q = (int) (Rnd.nextDouble() * 2 * Math.PI); - final int r = (int) Math.sqrt(Rnd.nextDouble()); - final int x = (int) ((_rad * r * Math.cos(q)) + _x); - final int y = (int) ((_rad * r * Math.sin(q)) + _y); + int x = 0; + int y = 0; + final int x2 = _x - _rad; + final int y2 = _y - _rad; + final int x3 = _x + _rad; + final int y3 = _y + _rad; + final int z = (_z1 + _z2) / 2; + while ((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) + { + x = Rnd.get(x2, x3); + y = Rnd.get(y2, y3); + } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, z)); } }