Use simplified Math hypot method to calculate distance.

This commit is contained in:
MobiusDevelopment
2022-07-23 11:01:04 +00:00
parent 9e41afee0a
commit a83ba35ebc
28 changed files with 56 additions and 56 deletions

View File

@@ -3513,7 +3513,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
m.geoPath = PathFinding.getInstance().findPath(curX, curY, curZ, originalX, originalY, originalZ, getInstanceWorld(), isPlayer());
boolean found = (m.geoPath != null) && (m.geoPath.size() > 1);
// If not found and it is an Attackable, attempt to find closest path to move location.
// If path not found and this is an Attackable, attempt to find closest path to destination.
if (!found && isAttackable())
{
int xMin = Math.min(curX, originalX);
@@ -3534,7 +3534,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
{
for (int sY = yMin; sY < yMax; sY += 500)
{
tempDistance = Math.sqrt(Math.pow(sX - originalX, 2) + Math.pow(sY - originalY, 2));
tempDistance = Math.hypot(sX - originalX, sY - originalY);
if (tempDistance < shortDistance)
{
tempPath = PathFinding.getInstance().findPath(curX, curY, curZ, sX, sY, originalZ, getInstanceWorld(), false);