Distinguish getVisibleObjectsInRange from getVisibleObjects.
This commit is contained in:
@@ -314,7 +314,7 @@ public final class Antharas extends AbstractNpcAI
|
||||
}
|
||||
case "START_MOVE":
|
||||
{
|
||||
for (L2PcInstance players : L2World.getInstance().getVisibleObjects(npc, L2PcInstance.class, 4000))
|
||||
for (L2PcInstance players : L2World.getInstance().getVisibleObjectsInRange(npc, L2PcInstance.class, 4000))
|
||||
{
|
||||
if (players.isHero())
|
||||
{
|
||||
|
||||
@@ -301,7 +301,7 @@ public final class Baium extends AbstractNpcAI
|
||||
}
|
||||
else
|
||||
{
|
||||
for (L2Character creature : L2World.getInstance().getVisibleObjects(npc, L2PcInstance.class, 2000))
|
||||
for (L2Character creature : L2World.getInstance().getVisibleObjectsInRange(npc, L2PcInstance.class, 2000))
|
||||
{
|
||||
if (zone.isInsideZone(creature) && !creature.isDead())
|
||||
{
|
||||
@@ -336,7 +336,7 @@ public final class Baium extends AbstractNpcAI
|
||||
else
|
||||
{
|
||||
boolean found = false;
|
||||
for (L2Playable creature : L2World.getInstance().getVisibleObjects(mob, L2Playable.class, 1000))
|
||||
for (L2Playable creature : L2World.getInstance().getVisibleObjectsInRange(mob, L2Playable.class, 1000))
|
||||
{
|
||||
if (zone.isInsideZone(creature) && !creature.isDead())
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ public class SiegeGuards extends AbstractNpcAI
|
||||
final L2Object target = npc.getTarget();
|
||||
if (!npc.isInCombat() || (target == null) || (npc.calculateDistance2D(target) > npc.getAggroRange()) || target.isInvul())
|
||||
{
|
||||
for (L2Character nearby : L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange()))
|
||||
for (L2Character nearby : L2World.getInstance().getVisibleObjectsInRange(npc, L2Character.class, npc.getAggroRange()))
|
||||
{
|
||||
if (nearby.isPlayable() && GeoEngine.getInstance().canSeeTarget(npc, nearby))
|
||||
{
|
||||
|
||||
@@ -144,7 +144,7 @@ public final class AdminPcCafePoints implements IAdminCommandHandler
|
||||
}
|
||||
else if (range > 0)
|
||||
{
|
||||
final int count = increaseForAll(L2World.getInstance().getVisibleObjects(activeChar, L2PcInstance.class, range), value);
|
||||
final int count = increaseForAll(L2World.getInstance().getVisibleObjectsInRange(activeChar, L2PcInstance.class, range), value);
|
||||
BuilderUtil.sendSysMessage(activeChar, "You increased PC Cafe point(s) of all players (" + count + ") in range " + range + " by " + value + ".");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -129,7 +129,7 @@ public final class AdminPrimePoints implements IAdminCommandHandler
|
||||
}
|
||||
else if (range > 0)
|
||||
{
|
||||
final int count = increaseForAll(L2World.getInstance().getVisibleObjects(activeChar, L2PcInstance.class, range), value);
|
||||
final int count = increaseForAll(L2World.getInstance().getVisibleObjectsInRange(activeChar, L2PcInstance.class, range), value);
|
||||
BuilderUtil.sendSysMessage(activeChar, "You increased Prime Point(s) of all players (" + count + ") in range " + range + " by " + value + ".");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -175,7 +175,7 @@ public class AdminScan implements IAdminCommandHandler
|
||||
html.setFile(activeChar, "data/html/admin/scan.htm");
|
||||
|
||||
//@formatter:off
|
||||
final PageResult result = PageBuilder.newBuilder(L2World.getInstance().getVisibleObjects(activeChar, L2Npc.class, radius, condition), 15, bypassParser.toString())
|
||||
final PageResult result = PageBuilder.newBuilder(L2World.getInstance().getVisibleObjectsInRange(activeChar, L2Npc.class, radius, condition), 15, bypassParser.toString())
|
||||
.currentPage(page)
|
||||
.pageHandler(NextPrevPageHandler.INSTANCE)
|
||||
.formatter(BypassParserFormatter.INSTANCE)
|
||||
|
||||
@@ -45,7 +45,7 @@ public class OpExistNpcSkillCondition implements ISkillCondition
|
||||
@Override
|
||||
public boolean canUse(L2Character caster, Skill skill, L2Object target)
|
||||
{
|
||||
final List<L2Npc> npcs = L2World.getInstance().getVisibleObjects(caster, L2Npc.class, _range);
|
||||
final List<L2Npc> npcs = L2World.getInstance().getVisibleObjectsInRange(caster, L2Npc.class, _range);
|
||||
return _isAround == npcs.stream().anyMatch(npc -> _npcIds.contains(npc.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class RangeSortByHp implements IAffectScopeHandler
|
||||
return true;
|
||||
};
|
||||
|
||||
final List<L2Character> result = L2World.getInstance().getVisibleObjects(target, L2Character.class, affectRange, filter);
|
||||
final List<L2Character> result = L2World.getInstance().getVisibleObjectsInRange(target, L2Character.class, affectRange, filter);
|
||||
|
||||
// Add object of origin since its skipped in the getVisibleObjects method.
|
||||
if (target.isCharacter() && filter.test((L2Character) target))
|
||||
|
||||
@@ -310,7 +310,7 @@ public class Q00255_Tutorial extends Quest
|
||||
{
|
||||
// check for too many gems on ground
|
||||
int counter = 0;
|
||||
for (L2ItemInstance item : L2World.getInstance().getVisibleObjects(killer, L2ItemInstance.class, 1500))
|
||||
for (L2ItemInstance item : L2World.getInstance().getVisibleObjectsInRange(killer, L2ItemInstance.class, 1500))
|
||||
{
|
||||
if (item.getId() == BLUE_GEM)
|
||||
{
|
||||
|
||||
@@ -358,7 +358,7 @@ public class L2AttackableAI extends L2CharacterAI
|
||||
{
|
||||
L2Character nearestTarget = null;
|
||||
double closestDistance = Double.MAX_VALUE;
|
||||
for (L2Character t : L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange()))
|
||||
for (L2Character t : L2World.getInstance().getVisibleObjectsInRange(npc, L2Character.class, npc.getAggroRange()))
|
||||
{
|
||||
if ((t == _actor) || (t == null) || t.isDead())
|
||||
{
|
||||
@@ -1118,7 +1118,7 @@ public class L2AttackableAI extends L2CharacterAI
|
||||
}
|
||||
else
|
||||
{
|
||||
stream = L2World.getInstance().getVisibleObjects(npc, L2Character.class, range, c -> checkSkillTarget(skill, c)).stream();
|
||||
stream = L2World.getInstance().getVisibleObjectsInRange(npc, L2Character.class, range, c -> checkSkillTarget(skill, c)).stream();
|
||||
|
||||
// Maybe add self to the list of targets since getVisibleObjects doesn't return yourself.
|
||||
if (checkSkillTarget(skill, npc))
|
||||
@@ -1149,7 +1149,7 @@ public class L2AttackableAI extends L2CharacterAI
|
||||
// If npc is aggressive, add characters within aggro range too
|
||||
if (npc.isAggressive())
|
||||
{
|
||||
stream = Stream.concat(stream, L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange(), this::checkTarget).stream());
|
||||
stream = Stream.concat(stream, L2World.getInstance().getVisibleObjectsInRange(npc, L2Character.class, npc.getAggroRange(), this::checkTarget).stream());
|
||||
}
|
||||
|
||||
return stream.findAny().orElse(null);
|
||||
@@ -1161,7 +1161,7 @@ public class L2AttackableAI extends L2CharacterAI
|
||||
.sorted(Comparator.comparingInt(AggroInfo::getHate))
|
||||
.map(AggroInfo::getAttacker)
|
||||
.findFirst()
|
||||
.orElse(npc.isAggressive() ? L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange(), this::checkTarget).stream().findAny().orElse(null) : null);
|
||||
.orElse(npc.isAggressive() ? L2World.getInstance().getVisibleObjectsInRange(npc, L2Character.class, npc.getAggroRange(), this::checkTarget).stream().findAny().orElse(null) : null);
|
||||
//@formatter:on
|
||||
}
|
||||
|
||||
|
||||
@@ -648,14 +648,14 @@ public final class L2World
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends L2Object> List<T> getVisibleObjects(L2Object object, Class<T> clazz, int range)
|
||||
public <T extends L2Object> List<T> getVisibleObjectsInRange(L2Object object, Class<T> clazz, int range)
|
||||
{
|
||||
final List<T> result = new ArrayList<>();
|
||||
forEachVisibleObjectInRange(object, clazz, range, result::add);
|
||||
return result;
|
||||
}
|
||||
|
||||
public <T extends L2Object> List<T> getVisibleObjects(L2Object object, Class<T> clazz, int range, Predicate<T> predicate)
|
||||
public <T extends L2Object> List<T> getVisibleObjectsInRange(L2Object object, Class<T> clazz, int range, Predicate<T> predicate)
|
||||
{
|
||||
final List<T> result = new ArrayList<>();
|
||||
forEachVisibleObjectInRange(object, clazz, range, o ->
|
||||
|
||||
@@ -1173,7 +1173,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
final double headingAngle = Util.convertHeadingToDegree(getHeading());
|
||||
final int maxRadius = _stat.getPhysicalAttackRadius();
|
||||
final int physicalAttackAngle = _stat.getPhysicalAttackAngle();
|
||||
for (L2Character obj : L2World.getInstance().getVisibleObjects(this, L2Character.class, maxRadius))
|
||||
for (L2Character obj : L2World.getInstance().getVisibleObjectsInRange(this, L2Character.class, maxRadius))
|
||||
{
|
||||
// Skip main target.
|
||||
if (obj == target)
|
||||
|
||||
@@ -173,7 +173,7 @@ public class L2DefenderInstance extends L2Attackable
|
||||
{
|
||||
L2Character target = this;
|
||||
double lowestHpValue = Double.MAX_VALUE;
|
||||
for (L2Character nearby : L2World.getInstance().getVisibleObjects(this, L2Character.class, skill.getCastRange()))
|
||||
for (L2Character nearby : L2World.getInstance().getVisibleObjectsInRange(this, L2Character.class, skill.getCastRange()))
|
||||
{
|
||||
if ((nearby == null) || nearby.isDead() || !GeoEngine.getInstance().canSeeTarget(this, nearby))
|
||||
{
|
||||
|
||||
@@ -4549,7 +4549,7 @@ public final class L2PcInstance extends L2Playable
|
||||
{
|
||||
if ((Config.SHOP_MIN_RANGE_FROM_NPC > 0) || (Config.SHOP_MIN_RANGE_FROM_PLAYER > 0))
|
||||
{
|
||||
for (L2Character cha : L2World.getInstance().getVisibleObjects(this, L2Character.class, 1000))
|
||||
for (L2Character cha : L2World.getInstance().getVisibleObjectsInRange(this, L2Character.class, 1000))
|
||||
{
|
||||
if (Util.checkIfInRange(cha.getMinShopDistance(), this, cha, true))
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ConditionPlayerRangeFromNpc extends Condition
|
||||
boolean existNpc = false;
|
||||
if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0))
|
||||
{
|
||||
for (L2Npc target : L2World.getInstance().getVisibleObjects(effector, L2Npc.class, _radius))
|
||||
for (L2Npc target : L2World.getInstance().getVisibleObjectsInRange(effector, L2Npc.class, _radius))
|
||||
{
|
||||
if (CommonUtil.contains(_npcIds, target.getId()))
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition
|
||||
boolean existNpc = false;
|
||||
if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0))
|
||||
{
|
||||
for (L2Npc target : L2World.getInstance().getVisibleObjects(effector, L2Npc.class, _radius))
|
||||
for (L2Npc target : L2World.getInstance().getVisibleObjectsInRange(effector, L2Npc.class, _radius))
|
||||
{
|
||||
if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner()))
|
||||
{
|
||||
|
||||
@@ -173,7 +173,7 @@ public class CubicInstance
|
||||
Stream<L2Character> stream;
|
||||
if (party != null)
|
||||
{
|
||||
stream = L2World.getInstance().getVisibleObjects(_owner, L2Character.class, Config.ALT_PARTY_RANGE, c -> (c.getParty() == party) && _template.validateConditions(this, _owner, c) && cubicSkill.validateConditions(this, _owner, c)).stream();
|
||||
stream = L2World.getInstance().getVisibleObjectsInRange(_owner, L2Character.class, Config.ALT_PARTY_RANGE, c -> (c.getParty() == party) && _template.validateConditions(this, _owner, c) && cubicSkill.validateConditions(this, _owner, c)).stream();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@ public final class RequestDuelStart implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
boolean npcInRange = false;
|
||||
for (L2Npc npc : L2World.getInstance().getVisibleObjects(activeChar, L2Npc.class, 250))
|
||||
for (L2Npc npc : L2World.getInstance().getVisibleObjectsInRange(activeChar, L2Npc.class, 250))
|
||||
{
|
||||
if (npc.getName().equals(name))
|
||||
{
|
||||
|
||||
@@ -112,7 +112,7 @@ public final class TradeRequest implements IClientIncomingPacket
|
||||
{
|
||||
final String name = FakePlayerData.getInstance().getProperName(target.getName());
|
||||
boolean npcInRange = false;
|
||||
for (L2Npc npc : L2World.getInstance().getVisibleObjects(player, L2Npc.class, 150))
|
||||
for (L2Npc npc : L2World.getInstance().getVisibleObjectsInRange(player, L2Npc.class, 150))
|
||||
{
|
||||
if (npc.getName().equals(name))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user