Addition of newer radius calculation methods.

This commit is contained in:
MobiusDevelopment 2021-03-28 10:05:00 +00:00
parent d3c54bde15
commit 7a11ed6ffe
106 changed files with 267 additions and 275 deletions

View File

@ -214,7 +214,7 @@ public class Orfen extends Quest
npc.teleToLocation(43577, 15985, -4396, false);
startQuestTimer("ORFEN_REFRESH", 10000, npc, null);
}
else if (npc.isInsideRadius(attacker, 1000, false, false) && !npc.isInsideRadius(attacker, 300, false, false) && (Rnd.get(10) == 0))
else if (npc.isInsideRadius2D(attacker, 1000) && !npc.isInsideRadius2D(attacker, 300) && (Rnd.get(10) == 0))
{
attacker.teleToLocation(npc.getX(), npc.getY(), npc.getZ());
npc.setTarget(attacker);

View File

@ -247,7 +247,7 @@ public class QueenAnt extends Quest
for (int i = 0; i < _minions.size(); i++)
{
final Attackable mob = _minions.get(i);
if ((mob != null) && !mob.isInsideRadius(npc.getX(), npc.getY(), 700, false))/* !_Zone.isInsideZone(mob)) */
if ((mob != null) && !mob.isInsideRadius2D(npc.getX(), npc.getY(), npc.getZ(), 700)) /* !_Zone.isInsideZone(mob)) */
{
mob.teleToLocation(npc.getX(), npc.getY(), npc.getZ());
}
@ -407,7 +407,7 @@ public class QueenAnt extends Quest
public void getIntoPosition(MonsterInstance nurse, MonsterInstance caller)
{
if (!nurse.isInsideRadius(caller, 300, false, false))
if (!nurse.isInsideRadius2D(caller, 300))
{
nurse.getAI().moveToPawn(caller, 300);
}

View File

@ -148,7 +148,7 @@ public class AttackableAI extends CreatureAI
}
// Check if the target isn't dead, is in the Aggro range and is at the same height
if (target.isAlikeDead() || !me.isInsideRadius(target, me.getAggroRange(), false, false) || (Math.abs(_actor.getZ() - target.getZ()) > 300))
if (target.isAlikeDead() || !me.isInsideRadius2D(target, me.getAggroRange()) || (Math.abs(_actor.getZ() - target.getZ()) > 300))
{
return false;
}
@ -419,7 +419,7 @@ public class AttackableAI extends CreatureAI
if ((obj instanceof PlayerInstance) || (obj instanceof Summon))
{
if (!target.isAlikeDead() && !npc.isInsideRadius(obj, npc.getAggroRange(), true, false))
if (!target.isAlikeDead() && !npc.isInsideRadius3D(obj, npc.getAggroRange()))
{
final PlayerInstance targetPlayer = obj instanceof PlayerInstance ? (PlayerInstance) obj : ((Summon) obj).getOwner();
for (Quest quest : npc.getTemplate().getEventQuests(EventType.ON_AGGRO_RANGE_ENTER))
@ -571,7 +571,7 @@ public class AttackableAI extends CreatureAI
}
else
{
if ((Config.MONSTER_RETURN_DELAY > 0) && (npc instanceof MonsterInstance) && !npc.isAlikeDead() && !npc.isDead() && (npc.getSpawn() != null) && !npc.isInsideRadius(npc.getSpawn().getX(), npc.getSpawn().getY(), Config.MAX_DRIFT_RANGE, false))
if ((Config.MONSTER_RETURN_DELAY > 0) && (npc instanceof MonsterInstance) && !npc.isAlikeDead() && !npc.isDead() && (npc.getSpawn() != null) && !npc.isInsideRadius2D(npc.getSpawn().getX(), npc.getSpawn().getY(), npc.getSpawn().getZ(), Config.MAX_DRIFT_RANGE))
{
((MonsterInstance) _actor).returnHome();
}
@ -606,7 +606,7 @@ public class AttackableAI extends CreatureAI
if (Config.AGGRO_DISTANCE_CHECK_ENABLED && _actor.isMonster() && !(_actor instanceof NpcWalkerInstance) && !(_actor instanceof GrandBossInstance))
{
final Spawn spawn = ((NpcInstance) _actor).getSpawn();
if ((spawn != null) && !_actor.isInsideRadius(spawn.getX(), spawn.getY(), spawn.getZ(), (_actor.isRaid() ? Config.AGGRO_DISTANCE_CHECK_RAID_RANGE : Config.AGGRO_DISTANCE_CHECK_RANGE), true, false))
if ((spawn != null) && !_actor.isInsideRadius3D(spawn.getX(), spawn.getY(), spawn.getZ(), (_actor.isRaid() ? Config.AGGRO_DISTANCE_CHECK_RAID_RANGE : Config.AGGRO_DISTANCE_CHECK_RANGE)))
{
if ((Config.AGGRO_DISTANCE_CHECK_RAIDS || !_actor.isRaid()) && (Config.AGGRO_DISTANCE_CHECK_INSTANCES || (_actor.getInstanceId() == 0)))
{
@ -700,7 +700,7 @@ public class AttackableAI extends CreatureAI
}
// Check if the WorldObject is inside the Faction Range of the actor
if ((_actor.getAttackByList() != null) && _actor.isInsideRadius(npc, npc.getFactionRange(), true, false) && (npc.getAI() != null) && _actor.getAttackByList().contains(originalAttackTarget))
if ((_actor.getAttackByList() != null) && _actor.isInsideRadius3D(npc, npc.getFactionRange()) && (npc.getAI() != null) && _actor.getAttackByList().contains(originalAttackTarget))
{
if ((npc.getAI().getIntention() == AI_INTENTION_IDLE) || (npc.getAI().getIntention() == AI_INTENTION_ACTIVE))
{
@ -773,7 +773,7 @@ public class AttackableAI extends CreatureAI
{
for (WorldObject nearby : _actor.getKnownList().getKnownObjects().values())
{
if ((nearby instanceof Attackable) && _actor.isInsideRadius(nearby, collision, false, false) && (nearby != originalAttackTarget))
if ((nearby instanceof Attackable) && _actor.isInsideRadius2D(nearby, collision) && (nearby != originalAttackTarget))
{
int newX = combinedCollision + Rnd.get(40);
if (Rnd.nextBoolean())
@ -794,7 +794,7 @@ public class AttackableAI extends CreatureAI
newY = originalAttackTarget.getY() - newY;
}
if (!_actor.isInsideRadius(newX, newY, collision, false))
if (!_actor.isInsideRadius2D(newX, newY, originalAttackTarget.getZ(), collision))
{
final int newZ = _actor.getZ() + 30;
if (!Config.PATHFINDING || GeoEngine.getInstance().canMoveToTarget(_actor.getX(), _actor.getY(), _actor.getZ(), newX, newY, newZ, _actor.getInstanceId()))

View File

@ -284,7 +284,7 @@ public class ControllableMobAI extends AttackableAI
continue;
}
if (_actor.isInsideRadius(npc, npc.getFactionRange(), false, true) && (Math.abs(getAttackTarget().getZ() - npc.getZ()) < 200))
if (_actor.isInsideRadius2D(npc, npc.getFactionRange()) && (Math.abs(getAttackTarget().getZ() - npc.getZ()) < 200))
{
npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, getAttackTarget(), 1);
}
@ -384,7 +384,7 @@ public class ControllableMobAI extends AttackableAI
return false;
}
if (target.isAlikeDead() || !me.isInsideRadius(target, me.getAggroRange(), false, false) || (Math.abs(_actor.getZ() - target.getZ()) > 100))
if (target.isAlikeDead() || !me.isInsideRadius2D(target, me.getAggroRange()) || (Math.abs(_actor.getZ() - target.getZ()) > 100))
{
return false;
}

View File

@ -950,7 +950,7 @@ public class CreatureAI extends AbstractAI
offsetWithCollision += ((Creature) target).getTemplate().getCollisionRadius();
}
if (!_actor.isInsideRadius(target, offsetWithCollision, false, false))
if (!_actor.isInsideRadius2D(target, offsetWithCollision))
{
final Creature follow = getFollowTarget();
@ -970,14 +970,14 @@ public class CreatureAI extends AbstractAI
}
}
// if the target is too far (maybe also teleported)
if (!_actor.isInsideRadius(target, 2000, false, false))
if (!_actor.isInsideRadius2D(target, 2000))
{
stopFollow();
setIntention(AI_INTENTION_IDLE);
return true;
}
// allow larger hit range when the target is moving (check is run only once per second)
if (!_actor.isInsideRadius(target, offsetWithCollision + 100, false, false))
if (!_actor.isInsideRadius2D(target, offsetWithCollision + 100))
{
return true;
}

View File

@ -193,14 +193,14 @@ public class DoorAI extends CreatureAI
for (SiegeGuardInstance guard : _door.getKnownSiegeGuards())
{
if ((guard != null) && (guard.getAI() != null) && _actor.isInsideRadius(guard, guard.getFactionRange(), false, true) && (Math.abs(_attacker.getZ() - guard.getZ()) < 200))
if ((guard != null) && (guard.getAI() != null) && _actor.isInsideRadius2D(guard, guard.getFactionRange()) && (Math.abs(_attacker.getZ() - guard.getZ()) < 200))
{
guard.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, _attacker, 15);
}
}
for (FortSiegeGuardInstance guard : _door.getKnownFortSiegeGuards())
{
if ((guard != null) && (guard.getAI() != null) && _actor.isInsideRadius(guard, guard.getFactionRange(), false, true) && (Math.abs(_attacker.getZ() - guard.getZ()) < 200))
if ((guard != null) && (guard.getAI() != null) && _actor.isInsideRadius2D(guard, guard.getFactionRange()) && (Math.abs(_attacker.getZ() - guard.getZ()) < 200))
{
guard.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, _attacker, 15);
}

View File

@ -172,7 +172,7 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
if (currentTarget instanceof Summon)
{
final PlayerInstance owner = ((Summon) currentTarget).getOwner();
if (_actor.isInsideRadius(owner, 1000, true, false))
if (_actor.isInsideRadius3D(owner, 1000))
{
currentTarget = owner;
}
@ -182,7 +182,7 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
if (currentTarget instanceof PlayerInstance)
{
// Check if the target isn't in silent move mode AND too far (>100)
if (((PlayerInstance) currentTarget).isSilentMoving() && !_actor.isInsideRadius(currentTarget, 250, false, false))
if (((PlayerInstance) currentTarget).isSilentMoving() && !_actor.isInsideRadius2D(currentTarget, 250))
{
return false;
}
@ -533,7 +533,7 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
// && _actor.getAttackByList().contains(getAttackTarget())
&& ((npc.getAI().getIntention() == AI_INTENTION_IDLE) || (npc.getAI().getIntention() == AI_INTENTION_ACTIVE))
// limiting aggro for siege guards
&& target.isInsideRadius(npc, 1500, true, false) && GeoEngine.getInstance().canSeeTarget(npc, target))
&& target.isInsideRadius3D(npc, 1500) && GeoEngine.getInstance().canSeeTarget(npc, target))
{
// Notify the WorldObject AI with EVT_AGGRESSION
final CreatureAI ai = npc.getAI();

View File

@ -127,14 +127,14 @@ public class SiegeGuardAI extends CreatureAI implements Runnable
if (currentTarget instanceof Summon)
{
final PlayerInstance owner = ((Summon) currentTarget).getOwner();
if (_actor.isInsideRadius(owner, 1000, true, false))
if (_actor.isInsideRadius3D(owner, 1000))
{
currentTarget = owner;
}
}
// Check if the target is a PlayerInstance and if the target isn't in silent move mode AND too far (>100)
if ((currentTarget instanceof PlayerInstance) && ((PlayerInstance) currentTarget).isSilentMoving() && !_actor.isInsideRadius(currentTarget, 250, false, false))
if ((currentTarget instanceof PlayerInstance) && ((PlayerInstance) currentTarget).isSilentMoving() && !_actor.isInsideRadius2D(currentTarget, 250))
{
return false;
}
@ -600,7 +600,7 @@ public class SiegeGuardAI extends CreatureAI implements Runnable
}
// Check if the WorldObject is inside the Faction Range of the actor
if ((npc.getAI() != null) && ((npc.getAI().getIntention() == AI_INTENTION_IDLE) || (npc.getAI().getIntention() == AI_INTENTION_ACTIVE)) && actor.isInsideRadius(npc, npc.getFactionRange(), false, true) && target.isInsideRadius(npc, npc.getFactionRange(), false, true))
if ((npc.getAI() != null) && ((npc.getAI().getIntention() == AI_INTENTION_IDLE) || (npc.getAI().getIntention() == AI_INTENTION_ACTIVE)) && actor.isInsideRadius2D(npc, npc.getFactionRange()) && target.isInsideRadius2D(npc, npc.getFactionRange()))
{
if (Config.PATHFINDING)
{

View File

@ -348,7 +348,7 @@ public class AdminEffects implements IAdminCommandHandler
final int teamVal = Integer.parseInt(val);
for (PlayerInstance player : activeChar.getKnownList().getKnownPlayers().values())
{
if (activeChar.isInsideRadius(player, 400, false, true))
if (activeChar.isInsideRadius2D(player, 400))
{
player.setTeam(0);
@ -416,7 +416,7 @@ public class AdminEffects implements IAdminCommandHandler
final int radius = Integer.parseInt(target);
for (WorldObject object : activeChar.getKnownList().getKnownObjects().values())
{
if (activeChar.isInsideRadius(object, radius, false, false))
if (activeChar.isInsideRadius2D(object, radius))
{
performSocial(social, object, activeChar);
}
@ -506,7 +506,7 @@ public class AdminEffects implements IAdminCommandHandler
final int radius = Integer.parseInt(target);
for (WorldObject object : activeChar.getKnownList().getKnownObjects().values())
{
if (activeChar.isInsideRadius(object, radius, false, false))
if (activeChar.isInsideRadius2D(object, radius))
{
performAbnormal(abnormal, object);
}

View File

@ -50,7 +50,7 @@ public class BreakingArrow implements IItemHandler
return;
}
final GrandBossInstance frintezza = (GrandBossInstance) target;
if (!player.isInsideRadius(frintezza, 500, false, false))
if (!player.isInsideRadius2D(frintezza, 500))
{
player.sendMessage("The purpose is inaccessible");
player.sendPacket(ActionFailed.STATIC_PACKET);

View File

@ -58,7 +58,7 @@ public class MOSKey implements IItemHandler
return;
}
final DoorInstance door = (DoorInstance) target;
if (!player.isInsideRadius(door, INTERACTION_DISTANCE, false, false))
if (!player.isInsideRadius2D(door, INTERACTION_DISTANCE))
{
player.sendMessage("Door is to far.");
player.sendPacket(ActionFailed.STATIC_PACKET);

View File

@ -59,7 +59,7 @@ public class PaganKeys implements IItemHandler
return;
}
final DoorInstance door = (DoorInstance) target;
if (!player.isInsideRadius(door, INTERACTION_DISTANCE, false, false))
if (!player.isInsideRadius2D(door, INTERACTION_DISTANCE))
{
player.sendMessage("Too far.");
player.sendPacket(ActionFailed.STATIC_PACKET);

View File

@ -68,7 +68,7 @@ public class Mount implements IUserCommandHandler
// A pet cannot be ridden while player is in battle.
player.sendPacket(new SystemMessage(SystemMessageId.A_STRIDER_CANNOT_BE_RIDDEN_WHILE_IN_BATTLE));
}
else if (!player.isInsideRadius(pet, 60, true, false))
else if (!player.isInsideRadius3D(pet, 60))
{
player.sendMessage("Too far away from strider to mount.");
return false;

View File

@ -395,7 +395,7 @@ public class Attackable extends NpcInstance
return false;
}
if (target.isAlikeDead() || !isInsideRadius(target, getAggroRange(), false, false) || (Math.abs(getZ() - target.getZ()) > 100))
if (target.isAlikeDead() || !isInsideRadius2D(target, getAggroRange()) || (Math.abs(getZ() - target.getZ()) > 100))
{
return false;
}

View File

@ -380,7 +380,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
{
for (PlayerInstance player : getKnownList().getKnownPlayers().values())
{
if (!isInsideRadius(player, radius, true, false))
if (!isInsideRadius3D(player, radius))
{
continue;
}
@ -1841,7 +1841,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
mostHated = ((Attackable) this)._mostHated;
}
if ((mostHated != null) && isInsideRadius(mostHated, 200, false, false))
if ((mostHated != null) && isInsideRadius2D(mostHated, 200))
{
calculateRewards(mostHated);
}
@ -5798,63 +5798,59 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
}
/**
* Check if this object is inside the given radius around the given object. Warning: doesn't cover collision radius!
* @param object the target
* @param radius the radius around the target
* @param checkZ should we check Z axis also
* @param strictCheck true if (distance < radius), false if (distance <= radius)
* @return true is the Creature is inside the radius.
* Check if this object is inside the given 2D radius around the given WorldObject.
* @param object the target object
* @param radius the radius around the object
* @return true if the Creature is inside the radius.
*/
public boolean isInsideRadius(WorldObject object, int radius, boolean checkZ, boolean strictCheck)
public boolean isInsideRadius2D(WorldObject object, int radius)
{
if (object != null)
if (object == null)
{
return isInsideRadius(object.getX(), object.getY(), object.getZ(), radius, checkZ, strictCheck);
return false;
}
return false;
return isInsideRadius2D(object.getX(), object.getY(), object.getZ(), radius);
}
/**
* Check if this object is inside the given plan radius around the given point. Warning: doesn't cover collision radius!
* @param x X position of the target
* @param y Y position of the target
* @param radius the radius around the target
* @param strictCheck true if (distance < radius), false if (distance <= radius)
* @return true is the Creature is inside the radius.
*/
public boolean isInsideRadius(int x, int y, int radius, boolean strictCheck)
{
return isInsideRadius(x, y, 0, radius, false, strictCheck);
}
/**
* Check if this object is inside the given radius around the given point.
* Check if this object is inside the given 2D radius around the given point.
* @param x X position of the target
* @param y Y position of the target
* @param z Z position of the target
* @param radius the radius around the target
* @param checkZ should we check Z axis also
* @param strictCheck true if (distance < radius), false if (distance <= radius)
* @return true is the Creature is inside the radius.
* @return true if the Creature is inside the radius.
*/
public boolean isInsideRadius(int x, int y, int z, int radius, boolean checkZ, boolean strictCheck)
public boolean isInsideRadius2D(int x, int y, int z, int radius)
{
final double dx = x - getX();
final double dy = y - getY();
final double dz = z - getZ();
if (strictCheck)
return calculateDistanceSq2D(x, y, z) < (radius * radius);
}
/**
* Check if this object is inside the given 3D radius around the given WorldObject.
* @param object the target object
* @param radius the radius around the object
* @return true if the Creature is inside the radius.
*/
public boolean isInsideRadius3D(WorldObject object, int radius)
{
if (object == null)
{
if (checkZ)
{
return ((dx * dx) + (dy * dy) + (dz * dz)) < (radius * radius);
}
return ((dx * dx) + (dy * dy)) < (radius * radius);
return false;
}
if (checkZ)
{
return ((dx * dx) + (dy * dy) + (dz * dz)) <= (radius * radius);
}
return ((dx * dx) + (dy * dy)) <= (radius * radius);
return isInsideRadius3D(object.getX(), object.getY(), object.getZ(), radius);
}
/**
* Check if this object is inside the given 3D radius around the given point.
* @param x X position of the target
* @param y Y position of the target
* @param z Z position of the target
* @param radius the radius around the target
* @return true if the Creature is inside the radius.
*/
public boolean isInsideRadius3D(int x, int y, int z, int radius)
{
return calculateDistanceSq3D(x, y, z) < (radius * radius);
}
/**
@ -6050,7 +6046,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
}
// max allowed rage into take cursed is 3000
if ((bossInstance != null) && bossInstance.isInsideRadius(this, 3000, false, false))
if ((bossInstance != null) && bossInstance.isInsideRadius2D(this, 3000))
{
toBeCursed = true;
}
@ -7801,7 +7797,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
}
// max allowed rage into take cursed is 3000
if ((bossInstance != null/* && alive */) && bossInstance.isInsideRadius(this, 3000, false, false))
if ((bossInstance != null/* && alive */) && bossInstance.isInsideRadius2D(this, 3000))
{
toBeCursed = true;
}
@ -8055,7 +8051,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
if (spMob instanceof NpcInstance)
{
final NpcInstance npcMob = (NpcInstance) spMob;
if (npcMob.isInsideRadius(caster, 1000, true, true) && npcMob.hasAI() && (npcMob.getAI().getIntention() == AI_INTENTION_ATTACK))
if (npcMob.isInsideRadius3D(caster, 1000) && npcMob.hasAI() && (npcMob.getAI().getIntention() == AI_INTENTION_ATTACK))
{
final WorldObject npcTarget = npcMob.getTarget();
for (WorldObject target : targets)

View File

@ -153,7 +153,7 @@ public class CabaleBufferInstance extends NpcInstance
private boolean handleCast(PlayerInstance player, int skillId)
{
final int skillLevel = player.getLevel() > 40 ? 1 : 2;
if (player.isDead() || !player.isSpawned() || !isInsideRadius(player, getDistanceToWatchObject(player), false, false))
if (player.isDead() || !player.isSpawned() || !isInsideRadius2D(player, getDistanceToWatchObject(player)))
{
return false;
}

View File

@ -204,7 +204,7 @@ public class ChestInstance extends MonsterInstance
skillLevel = 6;
}
if (creature.isDead() || !creature.isSpawned() || !creature.isInsideRadius(this, getDistanceToWatchObject(creature), false, false))
if (creature.isDead() || !creature.isSpawned() || !creature.isInsideRadius2D(this, getDistanceToWatchObject(creature)))
{
return false;
}

View File

@ -114,7 +114,7 @@ public class CommanderInstance extends Attackable
*/
public void returnHome()
{
if (!isInsideRadius(_homeX, _homeY, 40, false))
if (!isInsideRadius2D(_homeX, _homeY, _homeZ, 40))
{
setReturningToSpawnPoint(true);
clearAggroList();

View File

@ -540,7 +540,7 @@ public class DoorInstance extends Creature
}
else if ((player.getClan() != null) && (_clanHall != null) && (player.getClanId() == _clanHall.getOwnerId()))
{
if (!isInsideRadius(player, NpcInstance.INTERACTION_DISTANCE, false, false))
if (!isInsideRadius2D(player, NpcInstance.INTERACTION_DISTANCE))
{
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
}

View File

@ -108,7 +108,7 @@ public class FortSiegeGuardInstance extends Attackable
{
return;
}
if (!isInsideRadius(getSpawn().getX(), getSpawn().getY(), 40, false))
if (!isInsideRadius2D(getSpawn().getX(), getSpawn().getY(), getSpawn().getZ(), 40))
{
setReturningToSpawnPoint(true);
clearAggroList();

View File

@ -101,7 +101,7 @@ public class GrandBossInstance extends MonsterInstance
rbLockRange = Config.RBS_SPECIFIC_LOCK_RAGE.get(bossSpawn.getNpcId());
}
if ((rbLockRange >= 100) && !isInsideRadius(bossSpawn.getX(), bossSpawn.getY(), bossSpawn.getZ(), rbLockRange, true, false))
if ((rbLockRange >= 100) && !isInsideRadius3D(bossSpawn.getX(), bossSpawn.getY(), bossSpawn.getZ(), rbLockRange))
{
teleToLocation(bossSpawn.getX(), bossSpawn.getY(), bossSpawn.getZ(), true);
// healFull(); // Prevents minor exploiting with it

View File

@ -122,7 +122,7 @@ public class GuardInstance extends Attackable
*/
public void returnHome()
{
if (!isInsideRadius(_homeX, _homeY, 150, false))
if (!isInsideRadius2D(_homeX, _homeY, _homeZ, 150))
{
clearAggroList();
getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(_homeX, _homeY, _homeZ, 0));

View File

@ -121,7 +121,7 @@ public class GuardNoHTMLInstance extends Attackable
*/
public void returnHome()
{
if (!isInsideRadius(_homeX, _homeY, 150, false))
if (!isInsideRadius2D(_homeX, _homeY, _homeZ, 150))
{
clearAggroList();
getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(_homeX, _homeY, _homeZ, 0));
@ -184,7 +184,7 @@ public class GuardNoHTMLInstance extends Attackable
player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);
}
else // Calculate the distance between the PlayerInstance and the NpcInstance
if (!isInsideRadius(player, INTERACTION_DISTANCE, false, false))
if (!isInsideRadius2D(player, INTERACTION_DISTANCE))
{
// Set the PlayerInstance Intention to AI_INTENTION_INTERACT
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);

View File

@ -73,7 +73,7 @@ public class MonsterInstance extends Attackable
ThreadPool.schedule(() ->
{
final Spawn mobSpawn = getSpawn();
if (!isInCombat() && !isAlikeDead() && !isDead() && (mobSpawn != null) && !isInsideRadius(mobSpawn.getX(), mobSpawn.getY(), Config.MAX_DRIFT_RANGE, false))
if (!isInCombat() && !isAlikeDead() && !isDead() && (mobSpawn != null) && !isInsideRadius2D(mobSpawn.getX(), mobSpawn.getY(), mobSpawn.getZ(), Config.MAX_DRIFT_RANGE))
{
teleToLocation(mobSpawn.getX(), mobSpawn.getY(), mobSpawn.getZ(), false);
}
@ -132,7 +132,7 @@ public class MonsterInstance extends Attackable
for (MinionInstance minion : _minionList.getSpawnedMinions())
{
// Get actual coords of the minion and check to see if it's too far away from this MonsterInstance
if (!isInsideRadius(minion, 200, false, false))
if (!isInsideRadius2D(minion, 200))
{
// Get the coords of the master to use as a base to move the minion to
final int masterX = getX();

View File

@ -589,7 +589,7 @@ public class NpcInstance extends Creature
{
return false;
}
else if (!isInsideRadius(player, INTERACTION_DISTANCE, false, false))
else if (!isInsideRadius2D(player, INTERACTION_DISTANCE))
{
return false;
}

View File

@ -1498,7 +1498,7 @@ public class PlayerInstance extends Playable
if ((qs != null) && (_questNpcObject > 0))
{
final WorldObject object = World.getInstance().findObject(_questNpcObject);
if ((object instanceof NpcInstance) && isInsideRadius(object, NpcInstance.INTERACTION_DISTANCE, false, false))
if ((object instanceof NpcInstance) && isInsideRadius2D(object, NpcInstance.INTERACTION_DISTANCE))
{
final NpcInstance npc = (NpcInstance) object;
final List<QuestState> states = getQuestsForTalk(npc.getNpcId());
@ -2234,7 +2234,7 @@ public class PlayerInstance extends Playable
*/
protected boolean canInteract(PlayerInstance player)
{
return isInsideRadius(player, 50, false, false);
return isInsideRadius2D(player, 50);
}
/**
@ -4929,7 +4929,7 @@ public class PlayerInstance extends Playable
for (PlayerInstance player : getKnownList().getKnownPlayers().values())
{
if (!isInsideRadius(player, radius, true, false))
if (!isInsideRadius3D(player, radius))
{
continue;
}
@ -8442,7 +8442,7 @@ public class PlayerInstance extends Playable
public synchronized void store(boolean force)
{
// update client coords, if these look like true
if (!force && isInsideRadius(getClientX(), getClientY(), 1000, true))
if (!force && isInsideRadius2D(getClientX(), getClientY(), getClientZ(), 1000))
{
setXYZ(getClientX(), getClientY(), getClientZ());
}
@ -10068,7 +10068,7 @@ public class PlayerInstance extends Playable
// Calculate the distance between the PlayerInstance and the target
if (sklTargetType == SkillTargetType.TARGET_GROUND)
{
if (!isInsideRadius(getCurrentSkillWorldPosition().getX(), getCurrentSkillWorldPosition().getY(), getCurrentSkillWorldPosition().getZ(), skill.getCastRange() + getTemplate().getCollisionRadius(), false, false))
if (!isInsideRadius2D(getCurrentSkillWorldPosition().getX(), getCurrentSkillWorldPosition().getY(), getCurrentSkillWorldPosition().getZ(), skill.getCastRange() + getTemplate().getCollisionRadius()))
{
// Send a System Message to the caster
sendPacket(SystemMessageId.YOUR_TARGET_IS_OUT_OF_RANGE);
@ -10078,7 +10078,7 @@ public class PlayerInstance extends Playable
return;
}
}
else if ((skill.getCastRange() > 0) && !isInsideRadius(target, skill.getCastRange() + getTemplate().getCollisionRadius(), false, false)) // Calculate the distance between the PlayerInstance and the target
else if ((skill.getCastRange() > 0) && !isInsideRadius2D(target, skill.getCastRange() + getTemplate().getCollisionRadius())) // Calculate the distance between the PlayerInstance and the target
{
// Send a System Message to the caster
sendPacket(SystemMessageId.YOUR_TARGET_IS_OUT_OF_RANGE);
@ -10089,7 +10089,7 @@ public class PlayerInstance extends Playable
}
}
// Check range for SIGNET skills
else if ((sklType == SkillType.SIGNET) && !isInsideRadius(getCurrentSkillWorldPosition().getX(), getCurrentSkillWorldPosition().getY(), getCurrentSkillWorldPosition().getZ(), skill.getCastRange() + getTemplate().getCollisionRadius(), false, false))
else if ((sklType == SkillType.SIGNET) && !isInsideRadius2D(getCurrentSkillWorldPosition().getX(), getCurrentSkillWorldPosition().getY(), getCurrentSkillWorldPosition().getZ(), skill.getCastRange() + getTemplate().getCollisionRadius()))
{
// Send a System Message to the caster
sendPacket(SystemMessageId.YOUR_TARGET_IS_OUT_OF_RANGE);

View File

@ -73,7 +73,7 @@ public class ProtectorInstance extends NpcInstance
// Cast for Player
private boolean handleCast(PlayerInstance player, int skillId, int skillLevel)
{
if (player.isGM() || player.isDead() || !player.isSpawned() || !isInsideRadius(player, Config.PROTECTOR_RADIUS_ACTION, false, false))
if (player.isGM() || player.isDead() || !player.isSpawned() || !isInsideRadius2D(player, Config.PROTECTOR_RADIUS_ACTION))
{
return false;
}
@ -94,7 +94,7 @@ public class ProtectorInstance extends NpcInstance
// Cast for pet
private boolean handleCastonPet(Summon player, int skillId, int skillLevel)
{
if (player.isDead() || !player.isSpawned() || !isInsideRadius(player, Config.PROTECTOR_RADIUS_ACTION, false, false))
if (player.isDead() || !player.isSpawned() || !isInsideRadius2D(player, Config.PROTECTOR_RADIUS_ACTION))
{
return false;
}

View File

@ -113,7 +113,7 @@ public class RaidBossInstance extends MonsterInstance
rbLockRange = Config.RBS_SPECIFIC_LOCK_RAGE.get(bossSpawn.getNpcId());
}
if ((rbLockRange != -1) && !isInsideRadius(bossSpawn.getX(), bossSpawn.getY(), bossSpawn.getZ(), rbLockRange, true, false))
if ((rbLockRange != -1) && !isInsideRadius3D(bossSpawn.getX(), bossSpawn.getY(), bossSpawn.getZ(), rbLockRange))
{
teleToLocation(bossSpawn.getX(), bossSpawn.getY(), bossSpawn.getZ(), true);
// healFull(); // Prevents minor exploiting with it

View File

@ -113,7 +113,7 @@ public class SiegeGuardInstance extends Attackable
*/
public void returnHome()
{
if (!isInsideRadius(_homeX, _homeY, 40, false))
if (!isInsideRadius2D(_homeX, _homeY, _homeZ, 40))
{
setReturningToSpawnPoint(true);
clearAggroList();

View File

@ -142,7 +142,7 @@ public class StaticObjectInstance extends WorldObject
player.sendPacket(new MyTargetSelected(getObjectId(), 0));
// Calculate the distance between the PlayerInstance and the NpcInstance
if (!player.isInsideRadius(this, INTERACTION_DISTANCE, false, false))
if (!player.isInsideRadius2D(this, INTERACTION_DISTANCE))
{
// Notify the PlayerInstance AI with AI_INTENTION_INTERACT
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);

View File

@ -279,7 +279,7 @@ public class TamedBeastInstance extends FeedableBeastInstance
*/
public boolean isTooFarFromHome()
{
return !isInsideRadius(_homeX, _homeY, _homeZ, MAX_DISTANCE_FROM_HOME, true, true);
return !isInsideRadius3D(_homeX, _homeY, _homeZ, MAX_DISTANCE_FROM_HOME);
}
/**
@ -311,7 +311,7 @@ public class TamedBeastInstance extends FeedableBeastInstance
}
// if the owner is too far away, stop anything else and immediately run towards the owner.
if (!_owner.isInsideRadius(this, MAX_DISTANCE_FROM_OWNER, true, true))
if (!_owner.isInsideRadius3D(this, MAX_DISTANCE_FROM_OWNER))
{
getAI().startFollow(_owner);
return;
@ -470,7 +470,7 @@ public class TamedBeastInstance extends FeedableBeastInstance
}
// if the owner is too far away, stop anything else and immediately run towards the owner.
if (!isInsideRadius(owner, MAX_DISTANCE_FROM_OWNER, true, true))
if (!isInsideRadius3D(owner, MAX_DISTANCE_FROM_OWNER))
{
getAI().startFollow(owner);
return;

View File

@ -271,7 +271,7 @@ public class Quest extends ManagedScript
{
// The sponsor is online, retrieve player instance and check distance.
final PlayerInstance sponsor = member.getPlayerInstance();
if ((sponsor != null) && player.isInsideRadius(sponsor, Config.ALT_PARTY_RANGE, true, false))
if ((sponsor != null) && player.isInsideRadius3D(sponsor, Config.ALT_PARTY_RANGE))
{
return true;
}
@ -306,7 +306,7 @@ public class Quest extends ManagedScript
{
// The apprentice is online, retrieve player instance and check distance.
final PlayerInstance academic = member.getPlayerInstance();
if ((academic != null) && player.isInsideRadius(academic, Config.ALT_PARTY_RANGE, true, false))
if ((academic != null) && player.isInsideRadius3D(academic, Config.ALT_PARTY_RANGE))
{
return academic;
}
@ -1268,7 +1268,7 @@ public class Quest extends ManagedScript
}
// Player is in range?
if (!player.isInsideRadius(npc, Config.ALT_PARTY_RANGE, true, false))
if (!player.isInsideRadius3D(npc, Config.ALT_PARTY_RANGE))
{
return null;
}
@ -1305,7 +1305,7 @@ public class Quest extends ManagedScript
}
// Player is in range?
if (!player.isInsideRadius(npc, Config.ALT_PARTY_RANGE, true, false))
if (!player.isInsideRadius3D(npc, Config.ALT_PARTY_RANGE))
{
return null;
}
@ -1479,7 +1479,7 @@ public class Quest extends ManagedScript
if (qs != null)
{
final Object sVar = qs.get(var);
if ((sVar != null) && ((String) sVar).equalsIgnoreCase(value) && partyMember.isInsideRadius(target, Config.ALT_PARTY_RANGE, true, false))
if ((sVar != null) && ((String) sVar).equalsIgnoreCase(value) && partyMember.isInsideRadius3D(target, Config.ALT_PARTY_RANGE))
{
candidates.add(partyMember);
}
@ -1594,7 +1594,7 @@ public class Quest extends ManagedScript
for (PlayerInstance partyMember : party.getPartyMembers())
{
temp = partyMember.getQuestState(getName());
if ((temp != null) && (temp.getState() == state) && partyMember.isInsideRadius(target, Config.ALT_PARTY_RANGE, true, false))
if ((temp != null) && (temp.getState() == state) && partyMember.isInsideRadius3D(target, Config.ALT_PARTY_RANGE))
{
candidates.add(partyMember);
}
@ -1782,7 +1782,7 @@ public class Quest extends ManagedScript
public QuestState getClanLeaderQuestState(PlayerInstance player, NpcInstance npc)
{
// If player is the leader, retrieves directly the qS and bypass others checks
if (player.isClanLeader() && player.isInsideRadius(npc, Config.ALT_PARTY_RANGE, true, false))
if (player.isClanLeader() && player.isInsideRadius3D(npc, Config.ALT_PARTY_RANGE))
{
return player.getQuestState(getName());
}
@ -1807,7 +1807,7 @@ public class Quest extends ManagedScript
}
// Verify if the player is on the radius of the leader. If true, send leader's quest state.
if (leader.isInsideRadius(npc, Config.ALT_PARTY_RANGE, true, false))
if (leader.isInsideRadius3D(npc, Config.ALT_PARTY_RANGE))
{
return leader.getQuestState(getName());
}

View File

@ -56,7 +56,7 @@ public class ChangeWaitType2 extends GameClientPacket
return;
}
if ((target != null) && !player.isSitting() && (target instanceof StaticObjectInstance) && (((StaticObjectInstance) target).getType() == 1) && (CastleManager.getInstance().getCastle(target) != null) && player.isInsideRadius(target, StaticObjectInstance.INTERACTION_DISTANCE, false, false))
if ((target != null) && !player.isSitting() && (target instanceof StaticObjectInstance) && (((StaticObjectInstance) target).getType() == 1) && (CastleManager.getInstance().getCastle(target) != null) && player.isInsideRadius2D(target, StaticObjectInstance.INTERACTION_DISTANCE))
{
final ChairSit cs = new ChairSit(player, ((StaticObjectInstance) target).getStaticObjectId());
player.sendPacket(cs);

View File

@ -88,7 +88,7 @@ public class MultiSellChoose extends GameClientPacket
final NpcInstance merchant = player.getTarget() instanceof NpcInstance ? (NpcInstance) player.getTarget() : null;
// Possible fix to Multisell Radius
if ((merchant == null) || !player.isInsideRadius(merchant, NpcInstance.INTERACTION_DISTANCE, false, false))
if ((merchant == null) || !player.isInsideRadius2D(merchant, NpcInstance.INTERACTION_DISTANCE))
{
player.setMultiSellId(-1);
return;

View File

@ -122,7 +122,7 @@ public class RequestActionUse extends GameClientPacket
{
break;
}
if ((target != null) && !player.isSitting() && (target instanceof StaticObjectInstance) && (((StaticObjectInstance) target).getType() == 1) && (CastleManager.getInstance().getCastle(target) != null) && player.isInsideRadius(target, StaticObjectInstance.INTERACTION_DISTANCE, false, false))
if ((target != null) && !player.isSitting() && (target instanceof StaticObjectInstance) && (((StaticObjectInstance) target).getType() == 1) && (CastleManager.getInstance().getCastle(target) != null) && player.isInsideRadius2D(target, StaticObjectInstance.INTERACTION_DISTANCE))
{
final ChairSit cs = new ChairSit(player, ((StaticObjectInstance) target).getStaticObjectId());
player.sendPacket(cs);

View File

@ -75,7 +75,7 @@ public class RequestAquireSkill extends GameClientPacket
}
final int npcid = trainer.getNpcId();
if (!player.isInsideRadius(trainer, NpcInstance.INTERACTION_DISTANCE, false, false) && !player.isGM())
if (!player.isInsideRadius2D(trainer, NpcInstance.INTERACTION_DISTANCE) && !player.isGM())
{
return;
}

View File

@ -57,7 +57,7 @@ public class RequestAquireSkillInfo extends GameClientPacket
return;
}
if (!player.isGM() && !player.isInsideRadius(trainer, NpcInstance.INTERACTION_DISTANCE, false, false))
if (!player.isGM() && !player.isInsideRadius2D(trainer, NpcInstance.INTERACTION_DISTANCE))
{
return;
}

View File

@ -114,7 +114,7 @@ public class RequestBuyItem extends GameClientPacket
final WorldObject target = player.getTarget();
if (!player.isGM() && ((target == null // No target (ie GM Shop)
) || (!(target instanceof MerchantInstance) && !(target instanceof FishermanInstance) && !(target instanceof MercManagerInstance) && !(target instanceof ClanHallManagerInstance) && !(target instanceof CastleChamberlainInstance)) // Target not a merchant, fisherman or mercmanager
|| !player.isInsideRadius(target, NpcInstance.INTERACTION_DISTANCE, false, false) // Distance is too far
|| !player.isInsideRadius2D(target, NpcInstance.INTERACTION_DISTANCE) // Distance is too far
))
{
return;

View File

@ -252,7 +252,7 @@ public class RequestBypassToServer extends GameClientPacket
final WorldObject object = World.getInstance().findObject(Integer.parseInt(id));
if ((Config.ALLOW_CLASS_MASTERS && Config.ALLOW_REMOTE_CLASS_MASTERS && (object instanceof ClassMasterInstance)) //
|| ((object instanceof NpcInstance) && (endOfId > 0) && player.isInsideRadius(object, NpcInstance.INTERACTION_DISTANCE, false, false)))
|| ((object instanceof NpcInstance) && (endOfId > 0) && player.isInsideRadius2D(object, NpcInstance.INTERACTION_DISTANCE)))
{
((NpcInstance) object).onBypassFeedback(player, _command.replace("npc_" + object.getObjectId() + "_", ""));
}
@ -320,7 +320,7 @@ public class RequestBypassToServer extends GameClientPacket
if ((object instanceof NpcInstance) && (player.getLastQuestNpcObject() != object.getObjectId()))
{
final WorldObject lastQuestNpc = World.getInstance().findObject(player.getLastQuestNpcObject());
if ((lastQuestNpc == null) || !player.isInsideRadius(lastQuestNpc, NpcInstance.INTERACTION_DISTANCE, false, false))
if ((lastQuestNpc == null) || !player.isInsideRadius2D(lastQuestNpc, NpcInstance.INTERACTION_DISTANCE))
{
player.setLastQuestNpcObject(object.getObjectId());
}

View File

@ -179,7 +179,7 @@ public class RequestDropItem extends GameClientPacket
return;
}
if (!player.isInsideRadius(_x, _y, 150, false) || (Math.abs(_z - player.getZ()) > 50))
if (!player.isInsideRadius2D(_x, _y, _z, 150) || (Math.abs(_z - player.getZ()) > 50))
{
player.sendPacket(SystemMessageId.THAT_IS_TOO_FAR_FROM_YOU_TO_DISCARD);
return;

View File

@ -68,7 +68,7 @@ public class RequestExEnchantSkill extends GameClientPacket
}
final int npcid = trainer.getNpcId();
if (!player.isInsideRadius(trainer, NpcInstance.INTERACTION_DISTANCE, false, false) && !player.isGM())
if (!player.isInsideRadius2D(trainer, NpcInstance.INTERACTION_DISTANCE) && !player.isGM())
{
return;
}

View File

@ -67,7 +67,7 @@ public class RequestExEnchantSkillInfo extends GameClientPacket
return;
}
if (!player.isInsideRadius(trainer, NpcInstance.INTERACTION_DISTANCE, false, false) && !player.isGM())
if (!player.isInsideRadius2D(trainer, NpcInstance.INTERACTION_DISTANCE) && !player.isGM())
{
return;
}

View File

@ -114,7 +114,7 @@ public class RequestPackageSend extends GameClientPacket
}
final FolkInstance manager = player.getLastFolkNPC();
if (((manager == null) || !player.isInsideRadius(manager, NpcInstance.INTERACTION_DISTANCE, false, false)) && !player.isGM())
if (((manager == null) || !player.isInsideRadius2D(manager, NpcInstance.INTERACTION_DISTANCE)) && !player.isGM())
{
return;
}

View File

@ -88,7 +88,7 @@ public class RequestProcureCropList extends GameClientPacket
target = player.getLastFolkNPC();
}
if (!player.isGM() && ((target == null) || !(target instanceof ManorManagerInstance) || !player.isInsideRadius(target, NpcInstance.INTERACTION_DISTANCE, false, false)))
if (!player.isGM() && ((target == null) || !(target instanceof ManorManagerInstance) || !player.isInsideRadius2D(target, NpcInstance.INTERACTION_DISTANCE)))
{
return;
}

View File

@ -92,7 +92,7 @@ public class RequestSellItem extends GameClientPacket
final WorldObject target = player.getTarget();
if (!player.isGM() && ((target == null) // No target (ie GM Shop)
|| !(target instanceof MerchantInstance) // Target not a merchant and not mercmanager
|| !player.isInsideRadius(target, NpcInstance.INTERACTION_DISTANCE, false, false)))
|| !player.isInsideRadius2D(target, NpcInstance.INTERACTION_DISTANCE)))
{
return; // Distance is too far
}

View File

@ -136,7 +136,7 @@ public class RequestWearItem extends GameClientPacket
final WorldObject target = player.getTarget();
if (!player.isGM() && ((target == null // No target (ie GM Shop)
) || (!(target instanceof MerchantInstance) && !(target instanceof MercManagerInstance)) // Target not a merchant and not mercmanager
|| !player.isInsideRadius(target, NpcInstance.INTERACTION_DISTANCE, false, false)))
|| !player.isInsideRadius2D(target, NpcInstance.INTERACTION_DISTANCE)))
{
return; // Distance is too far
}

View File

@ -427,7 +427,7 @@ public class Say2 extends GameClientPacket
}
for (PlayerInstance plr : player.getKnownList().getKnownPlayers().values())
{
if ((plr != null) && player.isInsideRadius(plr, 1250, false, true))
if ((plr != null) && player.isInsideRadius2D(plr, 1250))
{
// Like L2OFF if player is blocked can't read the message
if (!plr.getBlockList().isInBlockList(player))

View File

@ -88,7 +88,7 @@ public class SendWareHouseDepositList extends GameClientPacket
}
final FolkInstance manager = player.getLastFolkNPC();
if ((manager == null) || !player.isInsideRadius(manager, NpcInstance.INTERACTION_DISTANCE, false, false))
if ((manager == null) || !player.isInsideRadius2D(manager, NpcInstance.INTERACTION_DISTANCE))
{
return;
}

View File

@ -96,7 +96,7 @@ public class SendWareHouseWithDrawList extends GameClientPacket
}
final FolkInstance manager = player.getLastFolkNPC();
if (((manager == null) || !player.isInsideRadius(manager, NpcInstance.INTERACTION_DISTANCE, false, false)) && !player.isGM())
if (((manager == null) || !player.isInsideRadius2D(manager, NpcInstance.INTERACTION_DISTANCE)) && !player.isGM())
{
return;
}

View File

@ -97,9 +97,9 @@ public class CreatureFollowTaskManager
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
final int followRangeWithCollision = followRange + creature.getTemplate().getCollisionRadius() + ((Creature) followTarget).getTemplate().getCollisionRadius();
if (!creature.isInsideRadius(followTarget, followRangeWithCollision, true, false))
if (!creature.isInsideRadius3D(followTarget, followRangeWithCollision))
{
if (!creature.isInsideRadius(followTarget, 3000, true, false))
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())

View File

@ -122,7 +122,7 @@ public class Broadcast
continue;
}
if (creature.isInsideRadius(player, radius, false, false))
if (creature.isInsideRadius2D(player, radius))
{
player.sendPacket(mov);
}

View File

@ -1497,7 +1497,7 @@ public class Frintezza extends Quest
{
continue;
}
if (!member.isInsideRadius(npc, 700, false, false))
if (!member.isInsideRadius2D(npc, 700))
{
continue;
}
@ -1533,7 +1533,7 @@ public class Frintezza extends Quest
{
continue;
}
if (!member.isInsideRadius(npc, 700, false, false))
if (!member.isInsideRadius2D(npc, 700))
{
continue;
}
@ -1559,7 +1559,7 @@ public class Frintezza extends Quest
}
}
}
else if (player.isInsideRadius(npc, 700, false, false))
else if (player.isInsideRadius2D(npc, 700))
{
synchronized (_playersInside)
{
@ -1587,7 +1587,7 @@ public class Frintezza extends Quest
{
continue;
}
if (!member.isInsideRadius(npc, 700, false, false))
if (!member.isInsideRadius2D(npc, 700))
{
continue;
}

View File

@ -171,7 +171,7 @@ public class Gordon extends Quest
{
for (PlayerInstance pc : chars)
{
if (pc.isCursedWeaponEquipped() && pc.isInsideRadius(npc, 5000, false, false))
if (pc.isCursedWeaponEquipped() && pc.isInsideRadius2D(npc, 5000))
{
npc.setRunning();
((Attackable) npc).addDamageHate(pc, 0, 9999);

View File

@ -214,7 +214,7 @@ public class Orfen extends Quest
npc.teleToLocation(43577, 15985, -4396, false);
startQuestTimer("ORFEN_REFRESH", 10000, npc, null);
}
else if (npc.isInsideRadius(attacker, 1000, false, false) && !npc.isInsideRadius(attacker, 300, false, false) && (Rnd.get(10) == 0))
else if (npc.isInsideRadius2D(attacker, 1000) && !npc.isInsideRadius2D(attacker, 300) && (Rnd.get(10) == 0))
{
attacker.teleToLocation(npc.getX(), npc.getY(), npc.getZ());
npc.setTarget(attacker);

View File

@ -247,7 +247,7 @@ public class QueenAnt extends Quest
for (int i = 0; i < _minions.size(); i++)
{
final Attackable mob = _minions.get(i);
if ((mob != null) && !mob.isInsideRadius(npc.getX(), npc.getY(), 700, false))/* !_Zone.isInsideZone(mob)) */
if ((mob != null) && !mob.isInsideRadius2D(npc.getX(), npc.getY(), npc.getZ(), 700)) /* !_Zone.isInsideZone(mob)) */
{
mob.teleToLocation(npc.getX(), npc.getY(), npc.getZ());
}
@ -407,7 +407,7 @@ public class QueenAnt extends Quest
public void getIntoPosition(MonsterInstance nurse, MonsterInstance caller)
{
if (!nurse.isInsideRadius(caller, 300, false, false))
if (!nurse.isInsideRadius2D(caller, 300))
{
nurse.getAI().moveToPawn(caller, 300);
}

View File

@ -148,7 +148,7 @@ public class AttackableAI extends CreatureAI
}
// Check if the target isn't dead, is in the Aggro range and is at the same height
if (target.isAlikeDead() || !me.isInsideRadius(target, me.getAggroRange(), false, false) || (Math.abs(_actor.getZ() - target.getZ()) > 300))
if (target.isAlikeDead() || !me.isInsideRadius2D(target, me.getAggroRange()) || (Math.abs(_actor.getZ() - target.getZ()) > 300))
{
return false;
}
@ -419,7 +419,7 @@ public class AttackableAI extends CreatureAI
if ((obj instanceof PlayerInstance) || (obj instanceof Summon))
{
if (!target.isAlikeDead() && !npc.isInsideRadius(obj, npc.getAggroRange(), true, false))
if (!target.isAlikeDead() && !npc.isInsideRadius3D(obj, npc.getAggroRange()))
{
final PlayerInstance targetPlayer = obj instanceof PlayerInstance ? (PlayerInstance) obj : ((Summon) obj).getOwner();
for (Quest quest : npc.getTemplate().getEventQuests(EventType.ON_AGGRO_RANGE_ENTER))
@ -571,7 +571,7 @@ public class AttackableAI extends CreatureAI
}
else
{
if ((Config.MONSTER_RETURN_DELAY > 0) && (npc instanceof MonsterInstance) && !npc.isAlikeDead() && !npc.isDead() && (npc.getSpawn() != null) && !npc.isInsideRadius(npc.getSpawn().getX(), npc.getSpawn().getY(), Config.MAX_DRIFT_RANGE, false))
if ((Config.MONSTER_RETURN_DELAY > 0) && (npc instanceof MonsterInstance) && !npc.isAlikeDead() && !npc.isDead() && (npc.getSpawn() != null) && !npc.isInsideRadius2D(npc.getSpawn().getX(), npc.getSpawn().getY(), npc.getSpawn().getZ(), Config.MAX_DRIFT_RANGE))
{
((MonsterInstance) _actor).returnHome();
}
@ -606,7 +606,7 @@ public class AttackableAI extends CreatureAI
if (Config.AGGRO_DISTANCE_CHECK_ENABLED && _actor.isMonster() && !(_actor instanceof NpcWalkerInstance) && !(_actor instanceof GrandBossInstance))
{
final Spawn spawn = ((NpcInstance) _actor).getSpawn();
if ((spawn != null) && !_actor.isInsideRadius(spawn.getX(), spawn.getY(), spawn.getZ(), (_actor.isRaid() ? Config.AGGRO_DISTANCE_CHECK_RAID_RANGE : Config.AGGRO_DISTANCE_CHECK_RANGE), true, false))
if ((spawn != null) && !_actor.isInsideRadius3D(spawn.getX(), spawn.getY(), spawn.getZ(), (_actor.isRaid() ? Config.AGGRO_DISTANCE_CHECK_RAID_RANGE : Config.AGGRO_DISTANCE_CHECK_RANGE)))
{
if ((Config.AGGRO_DISTANCE_CHECK_RAIDS || !_actor.isRaid()) && (Config.AGGRO_DISTANCE_CHECK_INSTANCES || (_actor.getInstanceId() == 0)))
{
@ -700,7 +700,7 @@ public class AttackableAI extends CreatureAI
}
// Check if the WorldObject is inside the Faction Range of the actor
if ((_actor.getAttackByList() != null) && _actor.isInsideRadius(npc, npc.getFactionRange(), true, false) && (npc.getAI() != null) && _actor.getAttackByList().contains(originalAttackTarget))
if ((_actor.getAttackByList() != null) && _actor.isInsideRadius3D(npc, npc.getFactionRange()) && (npc.getAI() != null) && _actor.getAttackByList().contains(originalAttackTarget))
{
if ((npc.getAI().getIntention() == AI_INTENTION_IDLE) || (npc.getAI().getIntention() == AI_INTENTION_ACTIVE))
{
@ -773,7 +773,7 @@ public class AttackableAI extends CreatureAI
{
for (WorldObject nearby : _actor.getKnownList().getKnownObjects().values())
{
if ((nearby instanceof Attackable) && _actor.isInsideRadius(nearby, collision, false, false) && (nearby != originalAttackTarget))
if ((nearby instanceof Attackable) && _actor.isInsideRadius2D(nearby, collision) && (nearby != originalAttackTarget))
{
int newX = combinedCollision + Rnd.get(40);
if (Rnd.nextBoolean())
@ -794,7 +794,7 @@ public class AttackableAI extends CreatureAI
newY = originalAttackTarget.getY() - newY;
}
if (!_actor.isInsideRadius(newX, newY, collision, false))
if (!_actor.isInsideRadius2D(newX, newY, originalAttackTarget.getZ(), collision))
{
final int newZ = _actor.getZ() + 30;
if (!Config.PATHFINDING || GeoEngine.getInstance().canMoveToTarget(_actor.getX(), _actor.getY(), _actor.getZ(), newX, newY, newZ, _actor.getInstanceId()))

View File

@ -284,7 +284,7 @@ public class ControllableMobAI extends AttackableAI
continue;
}
if (_actor.isInsideRadius(npc, npc.getFactionRange(), false, true) && (Math.abs(getAttackTarget().getZ() - npc.getZ()) < 200))
if (_actor.isInsideRadius2D(npc, npc.getFactionRange()) && (Math.abs(getAttackTarget().getZ() - npc.getZ()) < 200))
{
npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, getAttackTarget(), 1);
}
@ -384,7 +384,7 @@ public class ControllableMobAI extends AttackableAI
return false;
}
if (target.isAlikeDead() || !me.isInsideRadius(target, me.getAggroRange(), false, false) || (Math.abs(_actor.getZ() - target.getZ()) > 100))
if (target.isAlikeDead() || !me.isInsideRadius2D(target, me.getAggroRange()) || (Math.abs(_actor.getZ() - target.getZ()) > 100))
{
return false;
}

View File

@ -950,7 +950,7 @@ public class CreatureAI extends AbstractAI
offsetWithCollision += ((Creature) target).getTemplate().getCollisionRadius();
}
if (!_actor.isInsideRadius(target, offsetWithCollision, false, false))
if (!_actor.isInsideRadius2D(target, offsetWithCollision))
{
final Creature follow = getFollowTarget();
@ -970,14 +970,14 @@ public class CreatureAI extends AbstractAI
}
}
// if the target is too far (maybe also teleported)
if (!_actor.isInsideRadius(target, 2000, false, false))
if (!_actor.isInsideRadius2D(target, 2000))
{
stopFollow();
setIntention(AI_INTENTION_IDLE);
return true;
}
// allow larger hit range when the target is moving (check is run only once per second)
if (!_actor.isInsideRadius(target, offsetWithCollision + 100, false, false))
if (!_actor.isInsideRadius2D(target, offsetWithCollision + 100))
{
return true;
}

View File

@ -193,14 +193,14 @@ public class DoorAI extends CreatureAI
for (SiegeGuardInstance guard : _door.getKnownSiegeGuards())
{
if ((guard != null) && (guard.getAI() != null) && _actor.isInsideRadius(guard, guard.getFactionRange(), false, true) && (Math.abs(_attacker.getZ() - guard.getZ()) < 200))
if ((guard != null) && (guard.getAI() != null) && _actor.isInsideRadius2D(guard, guard.getFactionRange()) && (Math.abs(_attacker.getZ() - guard.getZ()) < 200))
{
guard.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, _attacker, 15);
}
}
for (FortSiegeGuardInstance guard : _door.getKnownFortSiegeGuards())
{
if ((guard != null) && (guard.getAI() != null) && _actor.isInsideRadius(guard, guard.getFactionRange(), false, true) && (Math.abs(_attacker.getZ() - guard.getZ()) < 200))
if ((guard != null) && (guard.getAI() != null) && _actor.isInsideRadius2D(guard, guard.getFactionRange()) && (Math.abs(_attacker.getZ() - guard.getZ()) < 200))
{
guard.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, _attacker, 15);
}

View File

@ -172,7 +172,7 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
if (currentTarget instanceof Summon)
{
final PlayerInstance owner = ((Summon) currentTarget).getOwner();
if (_actor.isInsideRadius(owner, 1000, true, false))
if (_actor.isInsideRadius3D(owner, 1000))
{
currentTarget = owner;
}
@ -182,7 +182,7 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
if (currentTarget instanceof PlayerInstance)
{
// Check if the target isn't in silent move mode AND too far (>100)
if (((PlayerInstance) currentTarget).isSilentMoving() && !_actor.isInsideRadius(currentTarget, 250, false, false))
if (((PlayerInstance) currentTarget).isSilentMoving() && !_actor.isInsideRadius2D(currentTarget, 250))
{
return false;
}
@ -533,7 +533,7 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
// && _actor.getAttackByList().contains(getAttackTarget())
&& ((npc.getAI().getIntention() == AI_INTENTION_IDLE) || (npc.getAI().getIntention() == AI_INTENTION_ACTIVE))
// limiting aggro for siege guards
&& target.isInsideRadius(npc, 1500, true, false) && GeoEngine.getInstance().canSeeTarget(npc, target))
&& target.isInsideRadius3D(npc, 1500) && GeoEngine.getInstance().canSeeTarget(npc, target))
{
// Notify the WorldObject AI with EVT_AGGRESSION
final CreatureAI ai = npc.getAI();

View File

@ -127,14 +127,14 @@ public class SiegeGuardAI extends CreatureAI implements Runnable
if (currentTarget instanceof Summon)
{
final PlayerInstance owner = ((Summon) currentTarget).getOwner();
if (_actor.isInsideRadius(owner, 1000, true, false))
if (_actor.isInsideRadius3D(owner, 1000))
{
currentTarget = owner;
}
}
// Check if the target is a PlayerInstance and if the target isn't in silent move mode AND too far (>100)
if ((currentTarget instanceof PlayerInstance) && ((PlayerInstance) currentTarget).isSilentMoving() && !_actor.isInsideRadius(currentTarget, 250, false, false))
if ((currentTarget instanceof PlayerInstance) && ((PlayerInstance) currentTarget).isSilentMoving() && !_actor.isInsideRadius2D(currentTarget, 250))
{
return false;
}
@ -600,7 +600,7 @@ public class SiegeGuardAI extends CreatureAI implements Runnable
}
// Check if the WorldObject is inside the Faction Range of the actor
if ((npc.getAI() != null) && ((npc.getAI().getIntention() == AI_INTENTION_IDLE) || (npc.getAI().getIntention() == AI_INTENTION_ACTIVE)) && actor.isInsideRadius(npc, npc.getFactionRange(), false, true) && target.isInsideRadius(npc, npc.getFactionRange(), false, true))
if ((npc.getAI() != null) && ((npc.getAI().getIntention() == AI_INTENTION_IDLE) || (npc.getAI().getIntention() == AI_INTENTION_ACTIVE)) && actor.isInsideRadius2D(npc, npc.getFactionRange()) && target.isInsideRadius2D(npc, npc.getFactionRange()))
{
if (Config.PATHFINDING)
{

View File

@ -348,7 +348,7 @@ public class AdminEffects implements IAdminCommandHandler
final int teamVal = Integer.parseInt(val);
for (PlayerInstance player : activeChar.getKnownList().getKnownPlayers().values())
{
if (activeChar.isInsideRadius(player, 400, false, true))
if (activeChar.isInsideRadius2D(player, 400))
{
player.setTeam(0);
@ -416,7 +416,7 @@ public class AdminEffects implements IAdminCommandHandler
final int radius = Integer.parseInt(target);
for (WorldObject object : activeChar.getKnownList().getKnownObjects().values())
{
if (activeChar.isInsideRadius(object, radius, false, false))
if (activeChar.isInsideRadius2D(object, radius))
{
performSocial(social, object, activeChar);
}
@ -506,7 +506,7 @@ public class AdminEffects implements IAdminCommandHandler
final int radius = Integer.parseInt(target);
for (WorldObject object : activeChar.getKnownList().getKnownObjects().values())
{
if (activeChar.isInsideRadius(object, radius, false, false))
if (activeChar.isInsideRadius2D(object, radius))
{
performAbnormal(abnormal, object);
}

View File

@ -50,7 +50,7 @@ public class BreakingArrow implements IItemHandler
return;
}
final GrandBossInstance frintezza = (GrandBossInstance) target;
if (!player.isInsideRadius(frintezza, 500, false, false))
if (!player.isInsideRadius2D(frintezza, 500))
{
player.sendMessage("The purpose is inaccessible");
player.sendPacket(ActionFailed.STATIC_PACKET);

View File

@ -58,7 +58,7 @@ public class MOSKey implements IItemHandler
return;
}
final DoorInstance door = (DoorInstance) target;
if (!player.isInsideRadius(door, INTERACTION_DISTANCE, false, false))
if (!player.isInsideRadius2D(door, INTERACTION_DISTANCE))
{
player.sendMessage("Door is to far.");
player.sendPacket(ActionFailed.STATIC_PACKET);

View File

@ -59,7 +59,7 @@ public class PaganKeys implements IItemHandler
return;
}
final DoorInstance door = (DoorInstance) target;
if (!player.isInsideRadius(door, INTERACTION_DISTANCE, false, false))
if (!player.isInsideRadius2D(door, INTERACTION_DISTANCE))
{
player.sendMessage("Too far.");
player.sendPacket(ActionFailed.STATIC_PACKET);

View File

@ -68,7 +68,7 @@ public class Mount implements IUserCommandHandler
// A pet cannot be ridden while player is in battle.
player.sendPacket(new SystemMessage(SystemMessageId.A_STRIDER_CANNOT_BE_RIDDEN_WHILE_IN_BATTLE));
}
else if (!player.isInsideRadius(pet, 60, true, false))
else if (!player.isInsideRadius3D(pet, 60))
{
player.sendMessage("Too far away from strider to mount.");
return false;

View File

@ -968,7 +968,7 @@ public class Duel
}
// Are the players too far apart?
if (!_playerA.isInsideRadius(_playerB, 1600, false, false))
if (!_playerA.isInsideRadius2D(_playerB, 1600))
{
return DuelResultEnum.Canceled;
}

View File

@ -396,7 +396,7 @@ public class Attackable extends NpcInstance
return false;
}
if (target.isAlikeDead() || !isInsideRadius(target, getAggroRange(), false, false) || (Math.abs(getZ() - target.getZ()) > 100))
if (target.isAlikeDead() || !isInsideRadius2D(target, getAggroRange()) || (Math.abs(getZ() - target.getZ()) > 100))
{
return false;
}

View File

@ -382,7 +382,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
{
for (PlayerInstance player : getKnownList().getKnownPlayers().values())
{
if (!isInsideRadius(player, radius, true, false))
if (!isInsideRadius3D(player, radius))
{
continue;
}
@ -1884,7 +1884,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
mostHated = ((Attackable) this)._mostHated;
}
if ((mostHated != null) && isInsideRadius(mostHated, 200, false, false))
if ((mostHated != null) && isInsideRadius2D(mostHated, 200))
{
calculateRewards(mostHated);
}
@ -5844,63 +5844,59 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
}
/**
* Check if this object is inside the given radius around the given object. Warning: doesn't cover collision radius!
* @param object the target
* @param radius the radius around the target
* @param checkZ should we check Z axis also
* @param strictCheck true if (distance < radius), false if (distance <= radius)
* @return true is the Creature is inside the radius.
* Check if this object is inside the given 2D radius around the given WorldObject.
* @param object the target object
* @param radius the radius around the object
* @return true if the Creature is inside the radius.
*/
public boolean isInsideRadius(WorldObject object, int radius, boolean checkZ, boolean strictCheck)
public boolean isInsideRadius2D(WorldObject object, int radius)
{
if (object != null)
if (object == null)
{
return isInsideRadius(object.getX(), object.getY(), object.getZ(), radius, checkZ, strictCheck);
return false;
}
return false;
return isInsideRadius2D(object.getX(), object.getY(), object.getZ(), radius);
}
/**
* Check if this object is inside the given plan radius around the given point. Warning: doesn't cover collision radius!
* @param x X position of the target
* @param y Y position of the target
* @param radius the radius around the target
* @param strictCheck true if (distance < radius), false if (distance <= radius)
* @return true is the Creature is inside the radius.
*/
public boolean isInsideRadius(int x, int y, int radius, boolean strictCheck)
{
return isInsideRadius(x, y, 0, radius, false, strictCheck);
}
/**
* Check if this object is inside the given radius around the given point.
* Check if this object is inside the given 2D radius around the given point.
* @param x X position of the target
* @param y Y position of the target
* @param z Z position of the target
* @param radius the radius around the target
* @param checkZ should we check Z axis also
* @param strictCheck true if (distance < radius), false if (distance <= radius)
* @return true is the Creature is inside the radius.
* @return true if the Creature is inside the radius.
*/
public boolean isInsideRadius(int x, int y, int z, int radius, boolean checkZ, boolean strictCheck)
public boolean isInsideRadius2D(int x, int y, int z, int radius)
{
final double dx = x - getX();
final double dy = y - getY();
final double dz = z - getZ();
if (strictCheck)
return calculateDistanceSq2D(x, y, z) < (radius * radius);
}
/**
* Check if this object is inside the given 3D radius around the given WorldObject.
* @param object the target object
* @param radius the radius around the object
* @return true if the Creature is inside the radius.
*/
public boolean isInsideRadius3D(WorldObject object, int radius)
{
if (object == null)
{
if (checkZ)
{
return ((dx * dx) + (dy * dy) + (dz * dz)) < (radius * radius);
}
return ((dx * dx) + (dy * dy)) < (radius * radius);
return false;
}
if (checkZ)
{
return ((dx * dx) + (dy * dy) + (dz * dz)) <= (radius * radius);
}
return ((dx * dx) + (dy * dy)) <= (radius * radius);
return isInsideRadius3D(object.getX(), object.getY(), object.getZ(), radius);
}
/**
* Check if this object is inside the given 3D radius around the given point.
* @param x X position of the target
* @param y Y position of the target
* @param z Z position of the target
* @param radius the radius around the target
* @return true if the Creature is inside the radius.
*/
public boolean isInsideRadius3D(int x, int y, int z, int radius)
{
return calculateDistanceSq3D(x, y, z) < (radius * radius);
}
/**
@ -6097,7 +6093,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
}
// max allowed rage into take cursed is 3000
if ((bossInstance != null) && bossInstance.isInsideRadius(this, 3000, false, false))
if ((bossInstance != null) && bossInstance.isInsideRadius2D(this, 3000))
{
toBeCursed = true;
}
@ -7848,7 +7844,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
}
// max allowed rage into take cursed is 3000
if ((bossInstance != null/* && alive */) && bossInstance.isInsideRadius(this, 3000, false, false))
if ((bossInstance != null/* && alive */) && bossInstance.isInsideRadius2D(this, 3000))
{
toBeCursed = true;
}
@ -8102,7 +8098,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
if (spMob instanceof NpcInstance)
{
final NpcInstance npcMob = (NpcInstance) spMob;
if (npcMob.isInsideRadius(caster, 1000, true, true) && npcMob.hasAI() && (npcMob.getAI().getIntention() == AI_INTENTION_ATTACK))
if (npcMob.isInsideRadius3D(caster, 1000) && npcMob.hasAI() && (npcMob.getAI().getIntention() == AI_INTENTION_ATTACK))
{
final WorldObject npcTarget = npcMob.getTarget();
for (WorldObject target : targets)

View File

@ -153,7 +153,7 @@ public class CabaleBufferInstance extends NpcInstance
private boolean handleCast(PlayerInstance player, int skillId)
{
final int skillLevel = player.getLevel() > 40 ? 1 : 2;
if (player.isDead() || !player.isSpawned() || !isInsideRadius(player, getDistanceToWatchObject(player), false, false))
if (player.isDead() || !player.isSpawned() || !isInsideRadius2D(player, getDistanceToWatchObject(player)))
{
return false;
}

View File

@ -204,7 +204,7 @@ public class ChestInstance extends MonsterInstance
skillLevel = 6;
}
if (creature.isDead() || !creature.isSpawned() || !creature.isInsideRadius(this, getDistanceToWatchObject(creature), false, false))
if (creature.isDead() || !creature.isSpawned() || !creature.isInsideRadius2D(this, getDistanceToWatchObject(creature)))
{
return false;
}

View File

@ -114,7 +114,7 @@ public class CommanderInstance extends Attackable
*/
public void returnHome()
{
if (!isInsideRadius(_homeX, _homeY, 40, false))
if (!isInsideRadius2D(_homeX, _homeY, _homeZ, 40))
{
setReturningToSpawnPoint(true);
clearAggroList();

View File

@ -540,7 +540,7 @@ public class DoorInstance extends Creature
}
else if ((player.getClan() != null) && (_clanHall != null) && (player.getClanId() == _clanHall.getOwnerId()))
{
if (!isInsideRadius(player, NpcInstance.INTERACTION_DISTANCE, false, false))
if (!isInsideRadius2D(player, NpcInstance.INTERACTION_DISTANCE))
{
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
}

View File

@ -108,7 +108,7 @@ public class FortSiegeGuardInstance extends Attackable
{
return;
}
if (!isInsideRadius(getSpawn().getX(), getSpawn().getY(), 40, false))
if (!isInsideRadius2D(getSpawn().getX(), getSpawn().getY(), getSpawn().getZ(), 40))
{
setReturningToSpawnPoint(true);
clearAggroList();

View File

@ -101,7 +101,7 @@ public class GrandBossInstance extends MonsterInstance
rbLockRange = Config.RBS_SPECIFIC_LOCK_RAGE.get(bossSpawn.getNpcId());
}
if ((rbLockRange >= 100) && !isInsideRadius(bossSpawn.getX(), bossSpawn.getY(), bossSpawn.getZ(), rbLockRange, true, false))
if ((rbLockRange >= 100) && !isInsideRadius3D(bossSpawn.getX(), bossSpawn.getY(), bossSpawn.getZ(), rbLockRange))
{
teleToLocation(bossSpawn.getX(), bossSpawn.getY(), bossSpawn.getZ(), true);
// healFull(); // Prevents minor exploiting with it

View File

@ -122,7 +122,7 @@ public class GuardInstance extends Attackable
*/
public void returnHome()
{
if (!isInsideRadius(_homeX, _homeY, 150, false))
if (!isInsideRadius2D(_homeX, _homeY, _homeZ, 150))
{
clearAggroList();
getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(_homeX, _homeY, _homeZ, 0));

View File

@ -121,7 +121,7 @@ public class GuardNoHTMLInstance extends Attackable
*/
public void returnHome()
{
if (!isInsideRadius(_homeX, _homeY, 150, false))
if (!isInsideRadius2D(_homeX, _homeY, _homeZ, 150))
{
clearAggroList();
getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(_homeX, _homeY, _homeZ, 0));
@ -184,7 +184,7 @@ public class GuardNoHTMLInstance extends Attackable
player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);
}
else // Calculate the distance between the PlayerInstance and the NpcInstance
if (!isInsideRadius(player, INTERACTION_DISTANCE, false, false))
if (!isInsideRadius2D(player, INTERACTION_DISTANCE))
{
// Set the PlayerInstance Intention to AI_INTENTION_INTERACT
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);

View File

@ -73,7 +73,7 @@ public class MonsterInstance extends Attackable
ThreadPool.schedule(() ->
{
final Spawn mobSpawn = getSpawn();
if (!isInCombat() && !isAlikeDead() && !isDead() && (mobSpawn != null) && !isInsideRadius(mobSpawn.getX(), mobSpawn.getY(), Config.MAX_DRIFT_RANGE, false))
if (!isInCombat() && !isAlikeDead() && !isDead() && (mobSpawn != null) && !isInsideRadius2D(mobSpawn.getX(), mobSpawn.getY(), mobSpawn.getZ(), Config.MAX_DRIFT_RANGE))
{
teleToLocation(mobSpawn.getX(), mobSpawn.getY(), mobSpawn.getZ(), false);
}
@ -132,7 +132,7 @@ public class MonsterInstance extends Attackable
for (MinionInstance minion : _minionList.getSpawnedMinions())
{
// Get actual coords of the minion and check to see if it's too far away from this MonsterInstance
if (!isInsideRadius(minion, 200, false, false))
if (!isInsideRadius2D(minion, 200))
{
// Get the coords of the master to use as a base to move the minion to
final int masterX = getX();

View File

@ -591,7 +591,7 @@ public class NpcInstance extends Creature
{
return false;
}
else if (!isInsideRadius(player, INTERACTION_DISTANCE, false, false))
else if (!isInsideRadius2D(player, INTERACTION_DISTANCE))
{
return false;
}

View File

@ -1512,7 +1512,7 @@ public class PlayerInstance extends Playable
if ((qs != null) && (_questNpcObject > 0))
{
final WorldObject object = World.getInstance().findObject(_questNpcObject);
if ((object instanceof NpcInstance) && isInsideRadius(object, NpcInstance.INTERACTION_DISTANCE, false, false))
if ((object instanceof NpcInstance) && isInsideRadius2D(object, NpcInstance.INTERACTION_DISTANCE))
{
final NpcInstance npc = (NpcInstance) object;
final List<QuestState> states = getQuestsForTalk(npc.getNpcId());
@ -2301,7 +2301,7 @@ public class PlayerInstance extends Playable
*/
protected boolean canInteract(PlayerInstance player)
{
return isInsideRadius(player, 50, false, false);
return isInsideRadius2D(player, 50);
}
/**
@ -5021,7 +5021,7 @@ public class PlayerInstance extends Playable
for (PlayerInstance player : getKnownList().getKnownPlayers().values())
{
if (!isInsideRadius(player, radius, true, false))
if (!isInsideRadius3D(player, radius))
{
continue;
}
@ -8593,7 +8593,7 @@ public class PlayerInstance extends Playable
public synchronized void store(boolean force)
{
// update client coords, if these look like true
if (!force && isInsideRadius(getClientX(), getClientY(), 1000, true))
if (!force && isInsideRadius2D(getClientX(), getClientY(), getClientZ(), 1000))
{
setXYZ(getClientX(), getClientY(), getClientZ());
}
@ -10239,7 +10239,7 @@ public class PlayerInstance extends Playable
// Calculate the distance between the PlayerInstance and the target
if (sklTargetType == SkillTargetType.TARGET_GROUND)
{
if (!isInsideRadius(getCurrentSkillWorldPosition().getX(), getCurrentSkillWorldPosition().getY(), getCurrentSkillWorldPosition().getZ(), skill.getCastRange() + getTemplate().getCollisionRadius(), false, false))
if (!isInsideRadius2D(getCurrentSkillWorldPosition().getX(), getCurrentSkillWorldPosition().getY(), getCurrentSkillWorldPosition().getZ(), skill.getCastRange() + getTemplate().getCollisionRadius()))
{
// Send a System Message to the caster
sendPacket(SystemMessageId.YOUR_TARGET_IS_OUT_OF_RANGE);
@ -10249,7 +10249,7 @@ public class PlayerInstance extends Playable
return;
}
}
else if ((skill.getCastRange() > 0) && !isInsideRadius(target, skill.getCastRange() + getTemplate().getCollisionRadius(), false, false)) // Calculate the distance between the PlayerInstance and the target
else if ((skill.getCastRange() > 0) && !isInsideRadius2D(target, skill.getCastRange() + getTemplate().getCollisionRadius())) // Calculate the distance between the PlayerInstance and the target
{
// Send a System Message to the caster
sendPacket(SystemMessageId.YOUR_TARGET_IS_OUT_OF_RANGE);
@ -10260,7 +10260,7 @@ public class PlayerInstance extends Playable
}
}
// Check range for SIGNET skills
else if ((sklType == SkillType.SIGNET) && !isInsideRadius(getCurrentSkillWorldPosition().getX(), getCurrentSkillWorldPosition().getY(), getCurrentSkillWorldPosition().getZ(), skill.getCastRange() + getTemplate().getCollisionRadius(), false, false))
else if ((sklType == SkillType.SIGNET) && !isInsideRadius2D(getCurrentSkillWorldPosition().getX(), getCurrentSkillWorldPosition().getY(), getCurrentSkillWorldPosition().getZ(), skill.getCastRange() + getTemplate().getCollisionRadius()))
{
// Send a System Message to the caster
sendPacket(SystemMessageId.YOUR_TARGET_IS_OUT_OF_RANGE);

View File

@ -73,7 +73,7 @@ public class ProtectorInstance extends NpcInstance
// Cast for Player
private boolean handleCast(PlayerInstance player, int skillId, int skillLevel)
{
if (player.isGM() || player.isDead() || !player.isSpawned() || !isInsideRadius(player, Config.PROTECTOR_RADIUS_ACTION, false, false))
if (player.isGM() || player.isDead() || !player.isSpawned() || !isInsideRadius2D(player, Config.PROTECTOR_RADIUS_ACTION))
{
return false;
}
@ -94,7 +94,7 @@ public class ProtectorInstance extends NpcInstance
// Cast for pet
private boolean handleCastonPet(Summon player, int skillId, int skillLevel)
{
if (player.isDead() || !player.isSpawned() || !isInsideRadius(player, Config.PROTECTOR_RADIUS_ACTION, false, false))
if (player.isDead() || !player.isSpawned() || !isInsideRadius2D(player, Config.PROTECTOR_RADIUS_ACTION))
{
return false;
}

View File

@ -113,7 +113,7 @@ public class RaidBossInstance extends MonsterInstance
rbLockRange = Config.RBS_SPECIFIC_LOCK_RAGE.get(bossSpawn.getNpcId());
}
if ((rbLockRange != -1) && !isInsideRadius(bossSpawn.getX(), bossSpawn.getY(), bossSpawn.getZ(), rbLockRange, true, false))
if ((rbLockRange != -1) && !isInsideRadius3D(bossSpawn.getX(), bossSpawn.getY(), bossSpawn.getZ(), rbLockRange))
{
teleToLocation(bossSpawn.getX(), bossSpawn.getY(), bossSpawn.getZ(), true);
// healFull(); // Prevents minor exploiting with it

View File

@ -113,7 +113,7 @@ public class SiegeGuardInstance extends Attackable
*/
public void returnHome()
{
if (!isInsideRadius(_homeX, _homeY, 40, false))
if (!isInsideRadius2D(_homeX, _homeY, _homeZ, 40))
{
setReturningToSpawnPoint(true);
clearAggroList();

View File

@ -142,7 +142,7 @@ public class StaticObjectInstance extends WorldObject
player.sendPacket(new MyTargetSelected(getObjectId(), 0));
// Calculate the distance between the PlayerInstance and the NpcInstance
if (!player.isInsideRadius(this, INTERACTION_DISTANCE, false, false))
if (!player.isInsideRadius2D(this, INTERACTION_DISTANCE))
{
// Notify the PlayerInstance AI with AI_INTENTION_INTERACT
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);

View File

@ -279,7 +279,7 @@ public class TamedBeastInstance extends FeedableBeastInstance
*/
public boolean isTooFarFromHome()
{
return !isInsideRadius(_homeX, _homeY, _homeZ, MAX_DISTANCE_FROM_HOME, true, true);
return !isInsideRadius3D(_homeX, _homeY, _homeZ, MAX_DISTANCE_FROM_HOME);
}
/**
@ -311,7 +311,7 @@ public class TamedBeastInstance extends FeedableBeastInstance
}
// if the owner is too far away, stop anything else and immediately run towards the owner.
if (!_owner.isInsideRadius(this, MAX_DISTANCE_FROM_OWNER, true, true))
if (!_owner.isInsideRadius3D(this, MAX_DISTANCE_FROM_OWNER))
{
getAI().startFollow(_owner);
return;
@ -470,7 +470,7 @@ public class TamedBeastInstance extends FeedableBeastInstance
}
// if the owner is too far away, stop anything else and immediately run towards the owner.
if (!isInsideRadius(owner, MAX_DISTANCE_FROM_OWNER, true, true))
if (!isInsideRadius3D(owner, MAX_DISTANCE_FROM_OWNER))
{
getAI().startFollow(owner);
return;

View File

@ -271,7 +271,7 @@ public class Quest extends ManagedScript
{
// The sponsor is online, retrieve player instance and check distance.
final PlayerInstance sponsor = member.getPlayerInstance();
if ((sponsor != null) && player.isInsideRadius(sponsor, Config.ALT_PARTY_RANGE, true, false))
if ((sponsor != null) && player.isInsideRadius3D(sponsor, Config.ALT_PARTY_RANGE))
{
return true;
}
@ -306,7 +306,7 @@ public class Quest extends ManagedScript
{
// The apprentice is online, retrieve player instance and check distance.
final PlayerInstance academic = member.getPlayerInstance();
if ((academic != null) && player.isInsideRadius(academic, Config.ALT_PARTY_RANGE, true, false))
if ((academic != null) && player.isInsideRadius3D(academic, Config.ALT_PARTY_RANGE))
{
return academic;
}
@ -1268,7 +1268,7 @@ public class Quest extends ManagedScript
}
// Player is in range?
if (!player.isInsideRadius(npc, Config.ALT_PARTY_RANGE, true, false))
if (!player.isInsideRadius3D(npc, Config.ALT_PARTY_RANGE))
{
return null;
}
@ -1305,7 +1305,7 @@ public class Quest extends ManagedScript
}
// Player is in range?
if (!player.isInsideRadius(npc, Config.ALT_PARTY_RANGE, true, false))
if (!player.isInsideRadius3D(npc, Config.ALT_PARTY_RANGE))
{
return null;
}
@ -1479,7 +1479,7 @@ public class Quest extends ManagedScript
if (qs != null)
{
final Object sVar = qs.get(var);
if ((sVar != null) && ((String) sVar).equalsIgnoreCase(value) && partyMember.isInsideRadius(target, Config.ALT_PARTY_RANGE, true, false))
if ((sVar != null) && ((String) sVar).equalsIgnoreCase(value) && partyMember.isInsideRadius3D(target, Config.ALT_PARTY_RANGE))
{
candidates.add(partyMember);
}
@ -1594,7 +1594,7 @@ public class Quest extends ManagedScript
for (PlayerInstance partyMember : party.getPartyMembers())
{
temp = partyMember.getQuestState(getName());
if ((temp != null) && (temp.getState() == state) && partyMember.isInsideRadius(target, Config.ALT_PARTY_RANGE, true, false))
if ((temp != null) && (temp.getState() == state) && partyMember.isInsideRadius3D(target, Config.ALT_PARTY_RANGE))
{
candidates.add(partyMember);
}
@ -1782,7 +1782,7 @@ public class Quest extends ManagedScript
public QuestState getClanLeaderQuestState(PlayerInstance player, NpcInstance npc)
{
// If player is the leader, retrieves directly the qS and bypass others checks
if (player.isClanLeader() && player.isInsideRadius(npc, Config.ALT_PARTY_RANGE, true, false))
if (player.isClanLeader() && player.isInsideRadius3D(npc, Config.ALT_PARTY_RANGE))
{
return player.getQuestState(getName());
}
@ -1807,7 +1807,7 @@ public class Quest extends ManagedScript
}
// Verify if the player is on the radius of the leader. If true, send leader's quest state.
if (leader.isInsideRadius(npc, Config.ALT_PARTY_RANGE, true, false))
if (leader.isInsideRadius3D(npc, Config.ALT_PARTY_RANGE))
{
return leader.getQuestState(getName());
}

View File

@ -56,7 +56,7 @@ public class ChangeWaitType2 extends GameClientPacket
return;
}
if ((target != null) && !player.isSitting() && (target instanceof StaticObjectInstance) && (((StaticObjectInstance) target).getType() == 1) && (CastleManager.getInstance().getCastle(target) != null) && player.isInsideRadius(target, StaticObjectInstance.INTERACTION_DISTANCE, false, false))
if ((target != null) && !player.isSitting() && (target instanceof StaticObjectInstance) && (((StaticObjectInstance) target).getType() == 1) && (CastleManager.getInstance().getCastle(target) != null) && player.isInsideRadius2D(target, StaticObjectInstance.INTERACTION_DISTANCE))
{
final ChairSit cs = new ChairSit(player, ((StaticObjectInstance) target).getStaticObjectId());
player.sendPacket(cs);

View File

@ -89,7 +89,7 @@ public class MultiSellChoose extends GameClientPacket
final NpcInstance merchant = player.getTarget() instanceof NpcInstance ? (NpcInstance) player.getTarget() : null;
// Possible fix to Multisell Radius
if ((merchant == null) || !player.isInsideRadius(merchant, NpcInstance.INTERACTION_DISTANCE, false, false))
if ((merchant == null) || !player.isInsideRadius2D(merchant, NpcInstance.INTERACTION_DISTANCE))
{
player.setMultiSellId(-1);
return;

View File

@ -122,7 +122,7 @@ public class RequestActionUse extends GameClientPacket
{
break;
}
if ((target != null) && !player.isSitting() && (target instanceof StaticObjectInstance) && (((StaticObjectInstance) target).getType() == 1) && (CastleManager.getInstance().getCastle(target) != null) && player.isInsideRadius(target, StaticObjectInstance.INTERACTION_DISTANCE, false, false))
if ((target != null) && !player.isSitting() && (target instanceof StaticObjectInstance) && (((StaticObjectInstance) target).getType() == 1) && (CastleManager.getInstance().getCastle(target) != null) && player.isInsideRadius2D(target, StaticObjectInstance.INTERACTION_DISTANCE))
{
final ChairSit cs = new ChairSit(player, ((StaticObjectInstance) target).getStaticObjectId());
player.sendPacket(cs);

View File

@ -75,7 +75,7 @@ public class RequestAquireSkill extends GameClientPacket
}
final int npcid = trainer.getNpcId();
if (!player.isInsideRadius(trainer, NpcInstance.INTERACTION_DISTANCE, false, false) && !player.isGM())
if (!player.isInsideRadius2D(trainer, NpcInstance.INTERACTION_DISTANCE) && !player.isGM())
{
return;
}

View File

@ -57,7 +57,7 @@ public class RequestAquireSkillInfo extends GameClientPacket
return;
}
if (!player.isGM() && !player.isInsideRadius(trainer, NpcInstance.INTERACTION_DISTANCE, false, false))
if (!player.isGM() && !player.isInsideRadius2D(trainer, NpcInstance.INTERACTION_DISTANCE))
{
return;
}

View File

@ -114,7 +114,7 @@ public class RequestBuyItem extends GameClientPacket
final WorldObject target = player.getTarget();
if (!player.isGM() && ((target == null // No target (ie GM Shop)
) || (!(target instanceof MerchantInstance) && !(target instanceof FishermanInstance) && !(target instanceof MercManagerInstance) && !(target instanceof ClanHallManagerInstance) && !(target instanceof CastleChamberlainInstance)) // Target not a merchant, fisherman or mercmanager
|| !player.isInsideRadius(target, NpcInstance.INTERACTION_DISTANCE, false, false) // Distance is too far
|| !player.isInsideRadius2D(target, NpcInstance.INTERACTION_DISTANCE) // Distance is too far
))
{
return;

View File

@ -252,7 +252,7 @@ public class RequestBypassToServer extends GameClientPacket
final WorldObject object = World.getInstance().findObject(Integer.parseInt(id));
if ((Config.ALLOW_CLASS_MASTERS && Config.ALLOW_REMOTE_CLASS_MASTERS && (object instanceof ClassMasterInstance)) //
|| ((object instanceof NpcInstance) && (endOfId > 0) && player.isInsideRadius(object, NpcInstance.INTERACTION_DISTANCE, false, false)))
|| ((object instanceof NpcInstance) && (endOfId > 0) && player.isInsideRadius2D(object, NpcInstance.INTERACTION_DISTANCE)))
{
((NpcInstance) object).onBypassFeedback(player, _command.replace("npc_" + object.getObjectId() + "_", ""));
}
@ -320,7 +320,7 @@ public class RequestBypassToServer extends GameClientPacket
if ((object instanceof NpcInstance) && (player.getLastQuestNpcObject() != object.getObjectId()))
{
final WorldObject lastQuestNpc = World.getInstance().findObject(player.getLastQuestNpcObject());
if ((lastQuestNpc == null) || !player.isInsideRadius(lastQuestNpc, NpcInstance.INTERACTION_DISTANCE, false, false))
if ((lastQuestNpc == null) || !player.isInsideRadius2D(lastQuestNpc, NpcInstance.INTERACTION_DISTANCE))
{
player.setLastQuestNpcObject(object.getObjectId());
}

View File

@ -192,7 +192,7 @@ public class RequestDropItem extends GameClientPacket
return;
}
if (!player.isInsideRadius(_x, _y, 150, false) || (Math.abs(_z - player.getZ()) > 50))
if (!player.isInsideRadius2D(_x, _y, _z, 150) || (Math.abs(_z - player.getZ()) > 50))
{
player.sendPacket(SystemMessageId.THAT_IS_TOO_FAR_FROM_YOU_TO_DISCARD);
return;

View File

@ -71,7 +71,7 @@ public class RequestDuelStart extends GameClientPacket
return;
}
// Players may not be too far apart
else if (!player.isInsideRadius(targetChar, 250, false, false))
else if (!player.isInsideRadius2D(targetChar, 250))
{
final SystemMessage msg = new SystemMessage(SystemMessageId.S1_CANNOT_RECEIVE_A_DUEL_CHALLENGE_BECAUSE_S1_IS_TOO_FAR_AWAY);
msg.addString(targetChar.getName());

View File

@ -68,7 +68,7 @@ public class RequestExEnchantSkill extends GameClientPacket
}
final int npcid = trainer.getNpcId();
if (!player.isInsideRadius(trainer, NpcInstance.INTERACTION_DISTANCE, false, false) && !player.isGM())
if (!player.isInsideRadius2D(trainer, NpcInstance.INTERACTION_DISTANCE) && !player.isGM())
{
return;
}

View File

@ -67,7 +67,7 @@ public class RequestExEnchantSkillInfo extends GameClientPacket
return;
}
if (!player.isInsideRadius(trainer, NpcInstance.INTERACTION_DISTANCE, false, false) && !player.isGM())
if (!player.isInsideRadius2D(trainer, NpcInstance.INTERACTION_DISTANCE) && !player.isGM())
{
return;
}

View File

@ -114,7 +114,7 @@ public class RequestPackageSend extends GameClientPacket
}
final FolkInstance manager = player.getLastFolkNPC();
if (((manager == null) || !player.isInsideRadius(manager, NpcInstance.INTERACTION_DISTANCE, false, false)) && !player.isGM())
if (((manager == null) || !player.isInsideRadius2D(manager, NpcInstance.INTERACTION_DISTANCE)) && !player.isGM())
{
return;
}

View File

@ -88,7 +88,7 @@ public class RequestProcureCropList extends GameClientPacket
target = player.getLastFolkNPC();
}
if (!player.isGM() && ((target == null) || !(target instanceof ManorManagerInstance) || !player.isInsideRadius(target, NpcInstance.INTERACTION_DISTANCE, false, false)))
if (!player.isGM() && ((target == null) || !(target instanceof ManorManagerInstance) || !player.isInsideRadius2D(target, NpcInstance.INTERACTION_DISTANCE)))
{
return;
}

View File

@ -92,7 +92,7 @@ public class RequestSellItem extends GameClientPacket
final WorldObject target = player.getTarget();
if (!player.isGM() && ((target == null) // No target (ie GM Shop)
|| !(target instanceof MerchantInstance) // Target not a merchant and not mercmanager
|| !player.isInsideRadius(target, NpcInstance.INTERACTION_DISTANCE, false, false)))
|| !player.isInsideRadius2D(target, NpcInstance.INTERACTION_DISTANCE)))
{
return; // Distance is too far
}

Some files were not shown because too many files have changed in this diff Show More