Consider max drift range configuration when random moving.
This commit is contained in:
parent
2fd0720946
commit
1621590a72
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -691,26 +691,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceId());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceId());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink).<br>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink).<br>
|
||||||
|
@ -691,26 +691,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceId());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceId());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink).<br>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink).<br>
|
||||||
|
@ -691,26 +691,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceId());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceId());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink).<br>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink).<br>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
@ -571,26 +571,28 @@ public class AttackableAI extends CreatureAI
|
|||||||
int x1 = npc.getSpawn().getX();
|
int x1 = npc.getSpawn().getX();
|
||||||
int y1 = npc.getSpawn().getY();
|
int y1 = npc.getSpawn().getY();
|
||||||
int z1 = npc.getSpawn().getZ();
|
int z1 = npc.getSpawn().getZ();
|
||||||
final int range = Config.MAX_DRIFT_RANGE;
|
if (!npc.isInsideRadius2D(x1, y1, 0, Config.MAX_DRIFT_RANGE))
|
||||||
if (!npc.isInsideRadius2D(x1, y1, 0, range))
|
|
||||||
{
|
{
|
||||||
npc.setReturningToSpawnPoint(true);
|
npc.setReturningToSpawnPoint(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int deltaX = Rnd.get(range * 2); // x
|
final int deltaX = Rnd.get(Config.MAX_DRIFT_RANGE * 2); // x
|
||||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
int deltaY = Rnd.get(deltaX, Config.MAX_DRIFT_RANGE * 2); // distance
|
||||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||||
x1 = (deltaX + x1) - range;
|
x1 = (deltaX + x1) - Config.MAX_DRIFT_RANGE;
|
||||||
y1 = (deltaY + y1) - range;
|
y1 = (deltaY + y1) - Config.MAX_DRIFT_RANGE;
|
||||||
z1 = npc.getZ();
|
z1 = npc.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
|
||||||
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceWorld());
|
||||||
|
if (Util.calculateDistance(npc.getSpawn(), moveLoc, false, false) <= Config.MAX_DRIFT_RANGE)
|
||||||
|
{
|
||||||
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
* Manage AI attack thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||||
|
Loading…
Reference in New Issue
Block a user