Dropped knownlists.

This commit is contained in:
MobiusDev
2018-04-09 08:32:40 +00:00
parent 3f20f04fd3
commit b1fc2fa47d
159 changed files with 1976 additions and 3835 deletions

View File

@@ -17,7 +17,8 @@
package ai.areas.GiantsCave;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.NpcStringId;
@@ -57,13 +58,13 @@ public final class GiantsCave extends AbstractNpcAI
npc.broadcastSay(ChatType.NPC_SHOUT, NpcStringId.OH_GIANTS_AN_INTRUDER_HAS_BEEN_DISCOVERED);
}
for (L2Character characters : npc.getKnownList().getKnownCharactersInRadius(450))
L2World.getInstance().forEachVisibleObjectInRange(npc, L2Attackable.class, 450, characters ->
{
if ((characters != null) && (characters.isAttackable()) && (getRandomBoolean()))
if ((getRandomBoolean()))
{
addAttackDesire((L2Npc) characters, player);
addAttackDesire(characters, player);
}
}
});
}
else if (event.equals("CLEAR") && (npc != null) && !npc.isDead())
{

View File

@@ -21,6 +21,7 @@ import java.util.GregorianCalendar;
import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.NpcStringId;
@@ -80,13 +81,13 @@ public class Lindvior extends AbstractNpcAI
{
if (npc != null)
{
for (L2PcInstance pl : npc.getKnownList().getKnownPlayersInRadius(4000))
L2World.getInstance().forEachVisibleObjectInRange(npc, L2PcInstance.class, 4000, pl ->
{
if ((pl.getZ() >= 1100) && (pl.getZ() <= 3100))
{
pl.showQuestMovie(LINDVIOR_SCENE_ID);
}
}
});
}
break;
}

View File

@@ -17,9 +17,11 @@
package ai.areas.Gracia.AI.NPC.ZealotOfShilen;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import ai.AbstractNpcAI;
@@ -56,13 +58,13 @@ public final class ZealotOfShilen extends AbstractNpcAI
startQuestTimer("WATCHING", 10000, npc, null, true);
if (event.equalsIgnoreCase("WATCHING") && !npc.isAttackingNow())
{
for (L2Character character : npc.getKnownList().getKnownCharacters())
for (L2Character monster : L2World.getInstance().getVisibleObjects(npc, L2MonsterInstance.class))
{
if (character.isMonster() && !character.isDead() && !((L2Attackable) character).isDecayed())
if (!monster.isDead() && !((L2Attackable) monster).isDecayed())
{
npc.setRunning();
((L2Attackable) npc).addDamageHate(character, 0, 999);
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, character, null);
((L2Attackable) npc).addDamageHate(monster, 0, 999);
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster, null);
}
}
}

View File

@@ -19,7 +19,6 @@ package ai.areas.Gracia.vehicles.AirShipGludioGracia;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.instancemanager.AirShipManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.VehiclePathPoint;
@@ -149,16 +148,13 @@ public final class AirShipGludioGracia extends AbstractNpcAI implements Runnable
private final L2Npc findController()
{
// check objects around the ship
for (L2Object obj : L2World.getInstance().getVisibleObjects(_ship, 600))
for (L2Npc obj : L2World.getInstance().getVisibleObjects(_ship, L2Npc.class, 600))
{
if (obj.isNpc())
for (int id : CONTROLLERS)
{
for (int id : CONTROLLERS)
if (obj.getId() == id)
{
if (obj.getId() == id)
{
return (L2Npc) obj;
}
return obj;
}
}
}

View File

@@ -16,6 +16,7 @@
*/
package ai.areas.Hellbound.AI;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -46,14 +47,14 @@ public final class HellboundCore extends AbstractNpcAI
{
if (event.equalsIgnoreCase("cast") && (HellboundEngine.getInstance().getLevel() <= 6))
{
for (L2Character naia : npc.getKnownList().getKnownCharactersInRadius(900))
L2World.getInstance().forEachVisibleObjectInRange(npc, L2Character.class, 900, naia ->
{
if ((naia != null) && naia.isMonster() && (naia.getId() == NAIA) && !naia.isDead() && !naia.isChanneling())
{
naia.setTarget(npc);
naia.doSimultaneousCast(BEAM.getSkill());
}
}
});
startQuestTimer("cast", 10000, npc, null);
}
return super.onAdvEvent(event, npc, player);

View File

@@ -16,10 +16,12 @@
*/
package ai.areas.Hellbound.AI;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -57,8 +59,8 @@ public final class Ranku extends AbstractNpcAI
{
if ((minion != null) && !minion.isDead() && MY_TRACKING_SET.contains(minion.getObjectId()))
{
final L2PcInstance[] players = minion.getKnownList().getKnownPlayers().values().toArray(new L2PcInstance[minion.getKnownList().getKnownPlayers().size()]);
final L2PcInstance killer = players[getRandom(players.length)];
final List<L2PcInstance> players = L2World.getInstance().getVisibleObjects(minion, L2PcInstance.class);
final L2PcInstance killer = players.get(getRandom(players.size()));
minion.reduceCurrentHp(minion.getMaxHp() / 100, killer, null);
}
}

View File

@@ -36,6 +36,7 @@ import com.l2jmobius.gameserver.instancemanager.RaidBossSpawnManager.StatusEnum;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
@@ -766,13 +767,13 @@ public final class TullyWorkshop extends AbstractNpcAI
}
else if (event.equalsIgnoreCase("despawn_agent_7"))
{
for (L2PcInstance pl : npc.getKnownList().getKnownPlayersInRadius(300))
L2World.getInstance().forEachVisibleObjectInRange(npc, L2PcInstance.class, 300, pl ->
{
if (pl != null)
{
pl.teleToLocation(-12176, 279696, -10492, true);
}
}
});
allowAgentSpawn_7th = true;
spawnedAgent = null;
@@ -780,13 +781,13 @@ public final class TullyWorkshop extends AbstractNpcAI
}
else if (event.equalsIgnoreCase("cube_68_despawn"))
{
for (L2PcInstance pl : npc.getKnownList().getKnownPlayersInRadius(500))
L2World.getInstance().forEachVisibleObjectInRange(npc, L2PcInstance.class, 500, pl ->
{
if (pl != null)
{
pl.teleToLocation(-12176, 279696, -10492, true);
}
}
});
npc.deleteMe();
startQuestTimer("start_7th_floor_spawn", 120000, null, null);

View File

@@ -106,7 +106,7 @@ public final class HellboundEngine extends AbstractNpcAI
{
spawn.stopRespawn();
if ((npc != null) && npc.isVisible())
if ((npc != null) && npc.isSpawned())
{
npc.deleteMe();
deleted++;
@@ -130,9 +130,9 @@ public final class HellboundEngine extends AbstractNpcAI
{
npc.doRevive();
}
if (!npc.isVisible())
if (!npc.isSpawned())
{
npc.setIsVisible(true);
npc.setSpawned(true);
added++;
}
@@ -265,7 +265,7 @@ public final class HellboundEngine extends AbstractNpcAI
try
{
final L2DoorInstance door = DoorData.getInstance().getDoor(doorData[0]);
if (door.getOpen())
if (door.isOpen())
{
if (newLevel < doorData[1])
{

View File

@@ -19,8 +19,8 @@ package ai.areas.MonasteryOfSilence;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.effects.L2EffectType;
@@ -87,16 +87,15 @@ public final class MonasteryOfSilence extends AbstractNpcAI
{
case "TRAINING":
{
for (L2Character character : npc.getKnownList().getKnownCharactersInRadius(400))
L2World.getInstance().forEachVisibleObjectInRange(npc, L2Npc.class, 400, character ->
{
if ((getRandom(100) < 30) && character.isNpc() && !character.isDead() && !character.isInCombat())
if ((getRandom(100) < 30) && !character.isDead() && !character.isInCombat())
{
if ((character.getId() == CAPTAIN) && (getRandom(100) < 10) && npc.isScriptValue(0))
{
final L2Npc captain = (L2Npc) character;
captain.broadcastSay(ChatType.NPC_GENERAL, SOLINA_KNIGHTS_MSG[getRandom(SOLINA_KNIGHTS_MSG.length)]);
captain.setScriptValue(1);
startQuestTimer("TIMER", 10000, captain, null);
character.broadcastSay(ChatType.NPC_GENERAL, SOLINA_KNIGHTS_MSG[getRandom(SOLINA_KNIGHTS_MSG.length)]);
character.setScriptValue(1);
startQuestTimer("TIMER", 10000, character, null);
}
else if (character.getId() == KNIGHT)
{
@@ -105,7 +104,7 @@ public final class MonasteryOfSilence extends AbstractNpcAI
character.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, npc, null);
}
}
}
});
break;
}
case "DO_CAST":

View File

@@ -16,13 +16,14 @@
*/
package ai.areas.PlainsOfDion;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.NpcStringId;
import com.l2jmobius.gameserver.util.Util;
import ai.AbstractNpcAI;
@@ -75,15 +76,14 @@ public final class PlainsOfDion extends AbstractNpcAI
npc.broadcastSay(ChatType.NPC_GENERAL, MONSTERS_MSG[i]);
}
for (L2Character obj : npc.getKnownList().getKnownCharactersInRadius(npc.getTemplate().getClanHelpRange()))
L2World.getInstance().forEachVisibleObjectInRange(npc, L2MonsterInstance.class, npc.getTemplate().getClanHelpRange(), obj ->
{
if (obj.isMonster() && Util.contains(DELU_LIZARDMEN, obj.getId()) && !obj.isAttackingNow() && !obj.isDead() && GeoEngine.getInstance().canSeeTarget(npc, obj))
if (CommonUtil.contains(DELU_LIZARDMEN, obj.getId()) && !obj.isAttackingNow() && !obj.isDead() && GeoEngine.getInstance().canSeeTarget(npc, obj))
{
final L2Npc monster = (L2Npc) obj;
addAttackDesire(monster, player);
monster.broadcastSay(ChatType.NPC_GENERAL, MONSTERS_ASSIST_MSG[getRandom(3)]);
addAttackDesire(obj, player);
obj.broadcastSay(ChatType.NPC_GENERAL, MONSTERS_ASSIST_MSG[getRandom(3)]);
}
}
});
npc.setScriptValue(1);
}
return super.onAttack(npc, player, damage, isSummon);

View File

@@ -17,9 +17,9 @@
package ai.areas.PlainsOfLizardman;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -100,16 +100,12 @@ public final class PlainsOfLizardman extends AbstractNpcAI
if (event.equals("fantasy_mushroom") && (npc != null) && (player != null))
{
npc.doCast(FANTASY_MUSHROOM_SKILL.getSkill());
for (L2Character target : npc.getKnownList().getKnownCharactersInRadius(200))
L2World.getInstance().forEachVisibleObjectInRange(npc, L2Attackable.class, 200, monster ->
{
if ((target != null) && target.isAttackable())
{
final L2Npc monster = (L2Npc) target;
npc.setTarget(monster);
npc.doCast(STUN_EFFECT.getSkill());
addAttackDesire(monster, player);
}
}
npc.setTarget(monster);
npc.doCast(STUN_EFFECT.getSkill());
addAttackDesire(monster, player);
});
npc.doDie(player);
}
return null;
@@ -152,18 +148,14 @@ public final class PlainsOfLizardman extends AbstractNpcAI
{
npc.setScriptValue(1);
npc.setIsInvul(true);
for (L2Character target : npc.getKnownList().getKnownCharactersInRadius(1000))
L2World.getInstance().forEachVisibleObjectInRange(npc, L2Attackable.class, 1000, monster ->
{
if ((target != null) && target.isAttackable())
if ((monster.getId() == TANTA_MAGICIAN) || (monster.getId() == TANTA_SCOUT))
{
final L2Attackable monster = (L2Attackable) target;
if ((monster.getId() == TANTA_MAGICIAN) || (monster.getId() == TANTA_SCOUT))
{
target.setRunning();
target.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(npc.getX(), npc.getY(), npc.getZ(), 0));
}
monster.setRunning();
monster.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(npc.getX(), npc.getY(), npc.getZ(), 0));
}
}
});
startQuestTimer("fantasy_mushroom", 4000, npc, attacker);
}
break;

View File

@@ -21,6 +21,7 @@ import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.handler.ItemHandler;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
@@ -324,14 +325,13 @@ public final class PrimevalIsle extends AbstractNpcAI
{
npc.setScriptValue(1);
final L2Playable playable = isSummon ? attacker.getSummon() : attacker;
for (L2Character characters : npc.getKnownList().getKnownCharactersInRadius(500))
L2World.getInstance().forEachVisibleObjectInRange(npc, L2Attackable.class, 500, monster ->
{
if ((characters != null) && (characters.isAttackable()) && (getRandomBoolean()))
if ((getRandomBoolean()))
{
final L2Attackable monster = (L2Attackable) characters;
addAttackDesire(monster, playable);
}
}
});
}
}
else if (Util.contains(TREX, npc.getId()))

View File

@@ -21,6 +21,7 @@ import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
@@ -203,9 +204,9 @@ public final class SelMahumDrill extends AbstractNpcAI
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
{
// group hate
for (L2Character ch : npc.getKnownList().getKnownCharacters())
for (L2Character ch : L2World.getInstance().getVisibleObjects(npc, L2MonsterInstance.class))
{
if (!ch.isInCombat() && ch.isMonster() && (((L2Npc) ch).getSpawn().getName() == npc.getSpawn().getName()))
if (!ch.isInCombat() && (((L2Npc) ch).getSpawn().getName() == npc.getSpawn().getName()))
{
((L2MonsterInstance) ch).addDamageHate(attacker, 0, 1000);
}

View File

@@ -103,7 +103,7 @@ public final class SelMahumSquad extends AbstractNpcAI
{
npc.setIsInvul(false);
npc.getVariables().remove("INVUL_REMOVE_TIMER_STARTED");
if ((player != null) && !player.isDead() && npc.getKnownList().knowsThePlayer(player))
if ((player != null) && !player.isDead() && npc.isInSurroundingRegion(player))
{
addAttackDesire(npc, player);
}

View File

@@ -17,9 +17,9 @@
package ai.bosses.Anais;
import java.util.ArrayList;
import java.util.Map;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@@ -85,13 +85,8 @@ public final class Anais extends AbstractNpcAI
}
if ((_current != null) || (_pot < 4))
{
final Map<Integer, L2PcInstance> players = npc.getKnownList().getKnownPlayers();
final L2PcInstance target = players.get(getRandom(players.size() - 1));
_nextTarget = target;
if (_nextTarget == null)
{
_nextTarget = (L2PcInstance) npc.getTarget();
}
final L2Object target = npc.getTarget();
_nextTarget = target instanceof L2PcInstance ? (L2PcInstance) target : null;
final L2Npc b = _divineBurners.get(_pot);
_pot = _pot + 1;
b.setDisplayEffect(1);

View File

@@ -26,6 +26,7 @@ import com.l2jmobius.gameserver.enums.MountType;
import com.l2jmobius.gameserver.instancemanager.GrandBossManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
@@ -311,7 +312,7 @@ public final class Antharas extends AbstractNpcAI
}
case "START_MOVE":
{
for (L2PcInstance players : npc.getKnownList().getKnownPlayersInRadius(4000))
for (L2PcInstance players : L2World.getInstance().getVisibleObjects(npc, L2PcInstance.class, 4000))
{
if (players.isHero())
{

View File

@@ -23,11 +23,13 @@ import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.enums.MountType;
import com.l2jmobius.gameserver.instancemanager.GrandBossManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2GrandBossInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
@@ -333,9 +335,9 @@ public final class Baium extends AbstractNpcAI
else
{
boolean found = false;
for (L2Character creature : mob.getKnownList().getKnownCharactersInRadius(1000))
for (L2Playable creature : L2World.getInstance().getVisibleObjects(mob, L2Playable.class, 1000))
{
if ((creature != null) && creature.isPlayable() && zone.isInsideZone(creature) && !creature.isDead())
if (zone.isInsideZone(creature) && !creature.isDead())
{
if (mob.getTarget() != creature)
{
@@ -775,9 +777,9 @@ public final class Baium extends AbstractNpcAI
private L2PcInstance getRandomPlayer(L2Npc npc)
{
for (L2Character creature : npc.getKnownList().getKnownCharactersInRadius(2000))
for (L2Character creature : L2World.getInstance().getVisibleObjects(npc, L2PcInstance.class, 2000))
{
if ((creature != null) && creature.isPlayer() && zone.isInsideZone(creature) && !creature.isDead())
if ((creature != null) && zone.isInsideZone(creature) && !creature.isDead())
{
return (L2PcInstance) creature;
}

View File

@@ -27,6 +27,7 @@ import com.l2jmobius.gameserver.instancemanager.GrandBossManager;
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.TeleportWhereType;
@@ -609,7 +610,7 @@ public final class Beleth extends AbstractNpcAI
{
if (!npc.isDead() && !npc.isCastingNow())
{
if ((getRandom(100) < 40) && !npc.getKnownList().getKnownPlayersInRadius(200).isEmpty())
if ((getRandom(100) < 40) && !L2World.getInstance().getVisibleObjects(npc, L2PcInstance.class, 200).isEmpty())
{
npc.doCast(BLEED.getSkill());
return null;
@@ -642,12 +643,12 @@ public final class Beleth extends AbstractNpcAI
}
return null;
}
if ((getRandom(100) < 40) && !npc.getKnownList().getKnownPlayersInRadius(200).isEmpty())
if ((getRandom(100) < 40) && !L2World.getInstance().getVisibleObjects(npc, L2PcInstance.class, 200).isEmpty())
{
npc.doCast(LIGHTENING.getSkill());
return null;
}
for (L2PcInstance plr : npc.getKnownList().getKnownPlayersInRadius(950))
for (L2PcInstance plr : L2World.getInstance().getVisibleObjects(npc, L2PcInstance.class, 950))
{
npc.setTarget(plr);
npc.doCast(FIREBALL.getSkill());
@@ -662,7 +663,7 @@ public final class Beleth extends AbstractNpcAI
public String onSpawn(L2Npc npc)
{
npc.setRunning();
if (!npc.getKnownList().getKnownPlayersInRadius(300).isEmpty() && (getRandom(100) < 60))
if (!L2World.getInstance().getVisibleObjects(npc, L2PcInstance.class, 300).isEmpty() && (getRandom(100) < 60))
{
npc.doCast(BLEED.getSkill());
}
@@ -727,7 +728,7 @@ public final class Beleth extends AbstractNpcAI
}
else if (!npc.isDead() && !npc.isCastingNow())
{
if (!npc.getKnownList().getKnownPlayersInRadius(200).isEmpty())
if (!L2World.getInstance().getVisibleObjects(npc, L2PcInstance.class, 200).isEmpty())
{
npc.doCast(LIGHTENING.getSkill());
return null;

View File

@@ -20,6 +20,7 @@ import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.instancemanager.GrandBossManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@@ -174,7 +175,7 @@ public class DrChaos extends AbstractNpcAI
{
if (GrandBossManager.getInstance().getBossStatus(CHAOS_GOLEM) == NORMAL)
{
for (L2PcInstance obj : npc.getKnownList().getKnownPlayersInRadius(500))
for (L2PcInstance obj : L2World.getInstance().getVisibleObjects(npc, L2PcInstance.class, 500))
{
if (obj.isDead())
{

View File

@@ -25,9 +25,9 @@ import com.l2jmobius.gameserver.datatables.SkillData;
import com.l2jmobius.gameserver.enums.MountType;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.instancemanager.GrandBossManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2GrandBossInstance;
@@ -459,7 +459,7 @@ public final class Valakas extends AbstractNpcAI
}
// Pickup a target if no or dead victim. 10% luck he decides to reconsiders his target.
if ((_actualVictim == null) || _actualVictim.isDead() || !npc.getKnownList().knowsObject(_actualVictim) || (getRandom(10) == 0))
if ((_actualVictim == null) || _actualVictim.isDead() || !(npc.isInSurroundingRegion(_actualVictim)) || (getRandom(10) == 0))
{
_actualVictim = getRandomTarget(npc);
}
@@ -519,7 +519,7 @@ public final class Valakas extends AbstractNpcAI
}
// Valakas will use mass spells if he feels surrounded.
if (Util.getPlayersCountInRadius(1200, npc, false, false) >= 20)
if (L2World.getInstance().getVisibleObjects(npc, L2PcInstance.class, 1200).size() >= 20)
{
return VALAKAS_AOE_SKILLS[getRandom(VALAKAS_AOE_SKILLS.length)];
}
@@ -541,17 +541,17 @@ public final class Valakas extends AbstractNpcAI
{
final List<L2Playable> result = new ArrayList<>();
for (L2Character obj : npc.getKnownList().getKnownCharacters())
L2World.getInstance().forEachVisibleObject(npc, L2Playable.class, obj ->
{
if ((obj == null) || obj.isPet())
{
continue;
return;
}
else if (!obj.isDead() && obj.isPlayable())
{
result.add((L2Playable) obj);
result.add(obj);
}
}
});
return result.isEmpty() ? null : result.get(getRandom(result.size()));
}

View File

@@ -17,6 +17,7 @@
package ai.others.NpcBuffers;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -42,7 +43,7 @@ public class NpcBufferAI implements Runnable
@Override
public void run()
{
if ((_npc == null) || !_npc.isVisible() || _npc.isDecayed() || _npc.isDead() || (_skillData == null) || (_skillData.getSkill() == null))
if ((_npc == null) || !_npc.isSpawned() || _npc.isDecayed() || _npc.isDead() || (_skillData == null) || (_skillData.getSkill() == null))
{
return;
}
@@ -80,7 +81,7 @@ public class NpcBufferAI implements Runnable
}
case RANGE:
{
for (L2Character target : _npc.getKnownList().getKnownCharactersInRadius(skill.getAffectRange()))
for (L2Character target : L2World.getInstance().getVisibleObjects(_npc, L2Character.class, skill.getAffectRange()))
{
switch (_skillData.getAffectObject())
{

View File

@@ -16,12 +16,11 @@
*/
package ai.others.NpcBuffers.impl;
import java.util.Collection;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.gameserver.SevenSigns;
import com.l2jmobius.gameserver.datatables.SkillData;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.BuffInfo;
@@ -117,7 +116,7 @@ public final class CabaleBuffer extends AbstractNpcAI
@Override
public void run()
{
if ((_npc == null) || !_npc.isVisible())
if ((_npc == null) || !_npc.isSpawned())
{
return;
}
@@ -137,8 +136,7 @@ public final class CabaleBuffer extends AbstractNpcAI
losingCabal = SevenSigns.CABAL_DAWN;
}
final Collection<L2PcInstance> plrs = _npc.getKnownList().getKnownPlayers().values();
for (L2PcInstance player : plrs)
for (L2PcInstance player : L2World.getInstance().getVisibleObjects(_npc, L2PcInstance.class))
{
if ((player == null) || player.isInvul())
{
@@ -244,7 +242,7 @@ public final class CabaleBuffer extends AbstractNpcAI
*/
private boolean handleCast(L2PcInstance player, int skillId)
{
if (player.isDead() || !player.isVisible() || !_npc.isInsideRadius(player, DISTANCE_TO_WATCH_OBJECT, false, false))
if (player.isDead() || !player.isSpawned() || !_npc.isInsideRadius(player, DISTANCE_TO_WATCH_OBJECT, false, false))
{
return false;
}

View File

@@ -85,7 +85,7 @@ public final class PolymorphingOnAttack extends AbstractNpcAI
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
{
if (npc.isVisible() && !npc.isDead())
if (npc.isSpawned() && !npc.isDead())
{
final List<Integer> tmp = MOBSPAWNS.get(npc.getId());
if (tmp != null)

View File

@@ -0,0 +1,160 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ai.others;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.Castle;
import com.l2jmobius.gameserver.model.entity.Fort;
import com.l2jmobius.gameserver.model.items.type.WeaponType;
import ai.AbstractNpcAI;
/**
* @author Mobius
*/
public class SiegeGuards extends AbstractNpcAI
{
//@formatter:off
// NPCs
private static final int[] CASTLE_GUARDS =
{
35064, 35065, 35066, 35067, 35068, 35069, 35071, 35072, 35079, 35080, 35081, 35082, 35083, 35084, 35085, // Gludio
35106, 35107, 35108, 35109, 35110, 35111, 35113, 35114, 35121, 35122, 35123,35124, 35125, 35126, 35127, // Dion
35150, 35151, 35152, 35153, 35155, 35156, 35163, 35164, 35165, 35166, 35167, 35168, 35169, // Giran
35192, 35193, 35194, 35195, 35197, 35198, 35205, 35206, 35207, 35208, 35209, 35210, 35211, // Oren
35234, 35239, 35240, 35248, 35249, 35250, 35251, 35252, 35253, 35254, // Aden
35280, 35281, 35282, 35283, 35284, 35285, 35287, 35288, 35295, 35296, 35297, 35298, 35299, 35300, 35301, // Innadril
35324, 35325, 35326, 35327, 35328, 35330, 35339, 35340, 35341, 35343, 35350, 35351, // Goddard
35475, 35477, 35480, 35484, 35486, 35487, 35488, 35489, 35490, // Rune
35516, 35517, 35518, 35519, 35520, 35522, 35531, 35532, 35533, 35535, 35542, 35543, // Schuttgart
};
private static final int[] FORT_GUARDS =
{
35670, 35671, 35672, 35673, 35674, 35678, 35679, 35681, 35682, 35684, 35685, // Shanty
35702, 35703, 35704, 35705, 35706, 35707, 35708, 35709, 35710, 35711, 35712, 35714, 35715, 35717, 35718, 35720, 35722, 35723, // Southern
35739, 35740, 35741, 35742, 35743, 35747, 35748, 35750, 35751, 35753, 35754, // Hive
35758, 35767, 35771, 35772, 35773, 35774, 35775, 35776, 35777, 35778, 35779, 35780, 35781, 35783, 35784, 35786, 35787, 35789, 35791, 35792, // Valley
35808, 35809, 35810, 35811, 35812, 35816, 35817, 35819, 35820, 35822, 35823, // Ivory
35839, 35840, 35841, 35842, 35843, 35847, 35848, 35850, 35851, 35853, 35854, // Narsell
35868, 35869, 35871, 35872, 35873, 35874, 35875, 35876, 35877, 35878, 35879, 35880, 35881, 35883, 35884, 35886, 35887, 35889, 35891, 35892, // Bayou
35908, 35909, 35910, 35911, 35912, 35916, 35917, 35919, 35920, 35922, 35923, // White Sands
35940, 35941, 35942, 35943, 35944, 35945, 35946, 35947, 35948, 35949, 35950, 35952, 35953, 35955, 35956, 35958, 35960, 35961, // Borderland
35978, 35979, 35980, 35981, 35982, 35983, 35984, 35985, 35986, 35987, 35988, 35990, 35991, 35993, 35994, 35996, 35998, 35999, // Swamp
36015, 36016, 36017, 36018, 36019, 36023, 36024, 36026, 36027, 36029, 36030, // Archaic
36047, 36048, 36049, 36050, 36051, 36052, 36053, 36054, 36055, 36056, 36057, 36059, 36060, 36062, 36063, 36065, 36067, 36068, 36468, // Floran
36079, 36085, 36086, 36087, 36088, 36089, 36090, 36091, 36092, 36093, 36094, 36095, 36097, 36098, 36100, 36101, 36103, 36105, 36106, // Removed on Helios (113)
36122, 36123, 36124, 36125, 36126, 36130, 36131, 36133, 36134, 36136, 36137, // Tanor
36153, 36154, 36155, 36156, 36157, 36161, 36162, 36164, 36165, 36167, 36168, // Dragonspine
36185, 36186, 36187, 36188, 36189, 36190, 36191, 36192, 36193, 36194, 36195, 36197, 36198, 36200, 36201, 36203, 36205, 36206, // Antharas
36223, 36224, 36225, 36226, 36227, 36228, 36229, 36230, 36231, 36232, 36233, 36235, 36236, 36238, 36239, 36241, 36243, 36244, // Western
36261, 36262, 36263, 36264, 36265, 36266, 36267, 36268, 36269, 36270, 36271, 36273, 36274, 36276, 36277, 36279, 36281, 36282, // Hunters
36298, 36299, 36300, 36301, 36302, 36306, 36307, 36309, 36310, 36312, 36313, // Aaru
36330, 36331, 36332, 36333, 36334, 36342, 36343, 36345, 36346, 36348, 36351, // Demon
36368, 36369, 36370, 36371, 36372, 36380, 36381, 36383, 36384, 36386, 36389 // Monastic
};
private static final int[] MERCENARIES =
{
35015, 35016, 35017, 35018, 35019, 35025, 35026, 35027, 35028, 35029, 35035, 35036, 35037, 35038, 35039, 35045, 35046, 35047, 35048, 35049, 35055, 35056, 35057, 35058, 35059, 35060, 35061
};
private static final int[] STATIONARY_MERCENARIES =
{
35010, 35011, 35012, 35013, 35014, 35020, 35021, 35022, 35023, 35024, 35030, 35031, 35032, 35033, 35034, 35040, 35041, 35042, 35043, 35044, 35050, 35051, 35052, 35053, 35054, 35092, 35093, 35094,
35134, 35135, 35136, 35176, 35177, 35178, 35218, 35219, 35220, 35261, 35262, 35263, 35264, 35265, 35308, 35309, 35310, 35352, 35353, 35354, 35497, 35498, 35499, 35500, 35501, 35544, 35545, 35546
};
//@formatter:on
public SiegeGuards()
{
addAttackId(CASTLE_GUARDS);
addAttackId(FORT_GUARDS);
addAttackId(MERCENARIES);
addAttackId(STATIONARY_MERCENARIES);
addSpawnId(CASTLE_GUARDS);
addSpawnId(FORT_GUARDS);
addSpawnId(MERCENARIES);
addSpawnId(STATIONARY_MERCENARIES);
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
if ((npc != null) && !npc.isDead())
{
final L2Object target = npc.getTarget();
if (!npc.isInCombat() || (target == null) || (npc.calculateDistance(target, false, false) > npc.getAggroRange()))
{
for (L2Character nearby : L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange()))
{
if (nearby.isPlayable() && GeoEngine.getInstance().canSeeTarget(npc, nearby))
{
final L2Summon summon = nearby.isSummon() ? (L2Summon) nearby : null;
final L2PcInstance pl = summon == null ? (L2PcInstance) nearby : summon.getOwner();
if (((pl.getSiegeState() != 2) || pl.isRegisteredOnThisSiegeField(npc.getScriptValue())) && ((pl.getSiegeState() != 0) || (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_IDLE)))
{
if (!pl.isInvisible() && !pl.isInvul()) // skip invisible players
{
addAttackDesire(npc, pl);
break; // no need to search more
}
}
}
}
}
startQuestTimer("AGGRO_CHECK" + npc.getId(), 3000, npc, null);
}
return super.onAdvEvent(event, npc, player);
}
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
{
if ((attacker.getSiegeState() == 2) && !attacker.isRegisteredOnThisSiegeField(npc.getScriptValue()))
{
((L2Attackable) npc).stopHating(attacker);
return null;
}
return super.onAttack(npc, attacker, damage, isSummon);
}
@Override
public String onSpawn(L2Npc npc)
{
// npc.setRandomWalking(false);
if ((npc.getTemplate().getBaseAttackType() != WeaponType.SWORD) && (npc.getTemplate().getBaseAttackType() != WeaponType.POLE))
{
npc.setIsImmobilized(true);
}
final Castle castle = npc.getCastle();
final Fort fortress = npc.getFort();
npc.setScriptValue(fortress != null ? fortress.getResidenceId() : (castle != null ? castle.getResidenceId() : 0));
startQuestTimer("AGGRO_CHECK" + npc.getId(), getRandom(1000, 10000), npc, null);
return super.onSpawn(npc);
}
public static void main(String[] args)
{
new SiegeGuards();
}
}

View File

@@ -59,7 +59,7 @@ public class L2DoorInstanceAction implements IActionHandler
else if (!door.getClanHall().isSiegableHall() || !((SiegableHall) door.getClanHall()).isInSiege())
{
activeChar.addScript(new DoorRequestHolder(door));
if (!door.getOpen())
if (!door.isOpen())
{
activeChar.sendPacket(new ConfirmDlg(1140));
}
@@ -78,7 +78,7 @@ public class L2DoorInstanceAction implements IActionHandler
else
{
activeChar.addScript(new DoorRequestHolder((L2DoorInstance) target));
if (!((L2DoorInstance) target).getOpen())
if (!((L2DoorInstance) target).isOpen())
{
activeChar.sendPacket(new ConfirmDlg(1140));
}

View File

@@ -136,13 +136,7 @@ public class AdminBuffs implements IAdminCommandHandler
{
final int radius = Integer.parseInt(val);
for (L2Character knownChar : activeChar.getKnownList().getKnownCharactersInRadius(radius))
{
if (knownChar.isPlayer() && !knownChar.equals(activeChar))
{
knownChar.stopAllEffects();
}
}
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2PcInstance.class, radius, L2Character::stopAllEffects);
activeChar.sendMessage("All effects canceled within radius " + radius);
return true;

View File

@@ -22,7 +22,7 @@ import com.l2jmobius.gameserver.data.xml.impl.DoorData;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.CastleManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.Castle;
@@ -140,31 +140,29 @@ public class AdminDoorControl implements IAdminCommandHandler
}
else if (command.equals("admin_showdoors"))
{
for (L2Character ch : activeChar.getKnownList().getKnownCharacters())
L2World.getInstance().forEachVisibleObject(activeChar, L2DoorInstance.class, door ->
{
final ExServerPrimitive packet = new ExServerPrimitive("door" + ch.getId(), activeChar.getX(), activeChar.getY(), -16000);
if (ch.isDoor())
{
final L2DoorInstance door = (L2DoorInstance) ch;
final Color color = door.getOpen() ? Color.GREEN : Color.RED;
// box 1
packet.addLine(color, door.getX(0), door.getY(0), door.getZMin(), door.getX(1), door.getY(1), door.getZMin());
packet.addLine(color, door.getX(1), door.getY(1), door.getZMin(), door.getX(2), door.getY(2), door.getZMax());
packet.addLine(color, door.getX(2), door.getY(2), door.getZMax(), door.getX(3), door.getY(3), door.getZMax());
packet.addLine(color, door.getX(3), door.getY(3), door.getZMax(), door.getX(0), door.getY(0), door.getZMin());
// box 2
packet.addLine(color, door.getX(0), door.getY(0), door.getZMax(), door.getX(1), door.getY(1), door.getZMax());
packet.addLine(color, door.getX(1), door.getY(1), door.getZMax(), door.getX(2), door.getY(2), door.getZMin());
packet.addLine(color, door.getX(2), door.getY(2), door.getZMin(), door.getX(3), door.getY(3), door.getZMin());
packet.addLine(color, door.getX(3), door.getY(3), door.getZMin(), door.getX(0), door.getY(0), door.getZMax());
// diagonals
packet.addLine(color, door.getX(0), door.getY(0), door.getZMin(), door.getX(1), door.getY(1), door.getZMax());
packet.addLine(color, door.getX(2), door.getY(2), door.getZMin(), door.getX(3), door.getY(3), door.getZMax());
packet.addLine(color, door.getX(0), door.getY(0), door.getZMax(), door.getX(1), door.getY(1), door.getZMin());
packet.addLine(color, door.getX(2), door.getY(2), door.getZMax(), door.getX(3), door.getY(3), door.getZMin());
}
final ExServerPrimitive packet = new ExServerPrimitive("door" + door.getId(), activeChar.getX(), activeChar.getY(), -16000);
final Color color = door.isOpen() ? Color.GREEN : Color.RED;
// box 1
packet.addLine(color, door.getX(0), door.getY(0), door.getZMin(), door.getX(1), door.getY(1), door.getZMin());
packet.addLine(color, door.getX(1), door.getY(1), door.getZMin(), door.getX(2), door.getY(2), door.getZMax());
packet.addLine(color, door.getX(2), door.getY(2), door.getZMax(), door.getX(3), door.getY(3), door.getZMax());
packet.addLine(color, door.getX(3), door.getY(3), door.getZMax(), door.getX(0), door.getY(0), door.getZMin());
// box 2
packet.addLine(color, door.getX(0), door.getY(0), door.getZMax(), door.getX(1), door.getY(1), door.getZMax());
packet.addLine(color, door.getX(1), door.getY(1), door.getZMax(), door.getX(2), door.getY(2), door.getZMin());
packet.addLine(color, door.getX(2), door.getY(2), door.getZMin(), door.getX(3), door.getY(3), door.getZMin());
packet.addLine(color, door.getX(3), door.getY(3), door.getZMin(), door.getX(0), door.getY(0), door.getZMax());
// diagonals
packet.addLine(color, door.getX(0), door.getY(0), door.getZMin(), door.getX(1), door.getY(1), door.getZMax());
packet.addLine(color, door.getX(2), door.getY(2), door.getZMin(), door.getX(3), door.getY(3), door.getZMax());
packet.addLine(color, door.getX(0), door.getY(0), door.getZMax(), door.getX(1), door.getY(1), door.getZMin());
packet.addLine(color, door.getX(2), door.getY(2), door.getZMax(), door.getX(3), door.getY(3), door.getZMin());
activeChar.sendPacket(packet);
}
// send message
activeChar.sendMessage("Found door " + door.getId());
});
}
}
catch (Exception e)

View File

@@ -950,7 +950,8 @@ public class AdminEditChar implements IAdminCommandHandler
private void listCharacters(L2PcInstance activeChar, int page)
{
final L2PcInstance[] players = L2World.getInstance().getPlayersSortedBy(Comparator.comparingLong(L2PcInstance::getUptime));
final List<L2PcInstance> players = new ArrayList<>(L2World.getInstance().getPlayers());
players.sort(Comparator.comparingLong(L2PcInstance::getUptime));
final NpcHtmlMessage html = new NpcHtmlMessage();
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/charlist.htm");
@@ -1151,7 +1152,9 @@ public class AdminEditChar implements IAdminCommandHandler
final StringBuilder replyMSG = new StringBuilder(1000);
for (L2PcInstance player : L2World.getInstance().getPlayersSortedBy(Comparator.comparingLong(L2PcInstance::getUptime)))
final List<L2PcInstance> players = new ArrayList<>(L2World.getInstance().getPlayers());
players.sort(Comparator.comparingLong(L2PcInstance::getUptime));
for (L2PcInstance player : players)
{ // Add player info into new Table row
name = player.getName();
if (name.toLowerCase().contains(CharacterToFind.toLowerCase()))
@@ -1226,7 +1229,10 @@ public class AdminEditChar implements IAdminCommandHandler
final StringBuilder replyMSG = new StringBuilder(1000);
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/ipfind.htm");
for (L2PcInstance player : L2World.getInstance().getPlayersSortedBy(Comparator.comparingLong(L2PcInstance::getUptime)))
final List<L2PcInstance> players = new ArrayList<>(L2World.getInstance().getPlayers());
players.sort(Comparator.comparingLong(L2PcInstance::getUptime));
for (L2PcInstance player : players)
{
client = player.getClient();
if (client == null)
@@ -1335,7 +1341,9 @@ public class AdminEditChar implements IAdminCommandHandler
L2GameClient client;
final Map<String, Integer> dualboxIPs = new HashMap<>();
for (L2PcInstance player : L2World.getInstance().getPlayersSortedBy(Comparator.comparingLong(L2PcInstance::getUptime)))
final List<L2PcInstance> players = new ArrayList<>(L2World.getInstance().getPlayers());
players.sort(Comparator.comparingLong(L2PcInstance::getUptime));
for (L2PcInstance player : players)
{
client = player.getClient();
if ((client == null) || client.isDetached())
@@ -1387,7 +1395,9 @@ public class AdminEditChar implements IAdminCommandHandler
L2GameClient client;
final Map<IpPack, Integer> dualboxIPs = new HashMap<>();
for (L2PcInstance player : L2World.getInstance().getPlayersSortedBy(Comparator.comparingLong(L2PcInstance::getUptime)))
final List<L2PcInstance> players = new ArrayList<>(L2World.getInstance().getPlayers());
players.sort(Comparator.comparingLong(L2PcInstance::getUptime));
for (L2PcInstance player : players)
{
client = player.getClient();
if ((client == null) || client.isDetached())

View File

@@ -16,7 +16,6 @@
*/
package handlers.admincommandhandlers;
import java.util.Collection;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.datatables.SkillData;
@@ -220,37 +219,24 @@ public class AdminEffects implements IAdminCommandHandler
}
else if (command.equals("admin_para_all"))
{
try
L2World.getInstance().forEachVisibleObject(activeChar, L2PcInstance.class, player ->
{
final Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
for (L2PcInstance player : plrs)
if (!player.isGM())
{
if (!player.isGM())
{
player.startAbnormalVisualEffect(true, AbnormalVisualEffect.PARALYZE);
player.setIsParalyzed(true);
player.startParalyze();
}
player.startAbnormalVisualEffect(true, AbnormalVisualEffect.PARALYZE);
player.setIsParalyzed(true);
player.startParalyze();
}
}
catch (Exception e)
{
}
});
}
else if (command.equals("admin_unpara_all"))
{
try
L2World.getInstance().forEachVisibleObject(activeChar, L2PcInstance.class, player ->
{
final Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
for (L2PcInstance player : plrs)
{
player.stopAbnormalVisualEffect(true, AbnormalVisualEffect.PARALYZE);
player.setIsParalyzed(false);
}
}
catch (Exception e)
{
}
player.stopAbnormalVisualEffect(true, AbnormalVisualEffect.PARALYZE);
player.setIsParalyzed(false);
});
}
else if (command.startsWith("admin_para")) // || command.startsWith("admin_para_menu"))
{
@@ -395,18 +381,11 @@ public class AdminEffects implements IAdminCommandHandler
}
else if (command.equals("admin_clearteams"))
{
try
L2World.getInstance().forEachVisibleObject(activeChar, L2PcInstance.class, player ->
{
final Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
for (L2PcInstance player : plrs)
{
player.setTeam(Team.NONE);
player.broadcastUserInfo();
}
}
catch (Exception e)
{
}
player.setTeam(Team.NONE);
player.broadcastUserInfo();
});
}
else if (command.startsWith("admin_setteam_close"))
{
@@ -419,12 +398,8 @@ public class AdminEffects implements IAdminCommandHandler
radius = Integer.parseInt(st.nextToken());
}
final Team team = Team.valueOf(val.toUpperCase());
final Collection<L2Character> plrs = activeChar.getKnownList().getKnownCharactersInRadius(radius);
for (L2Character player : plrs)
{
player.setTeam(team);
}
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2PcInstance.class, radius, player -> player.setTeam(team));
}
catch (Exception e)
{
@@ -477,14 +452,7 @@ public class AdminEffects implements IAdminCommandHandler
try
{
final int radius = Integer.parseInt(target);
final Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
for (L2Object object : objs)
{
if (activeChar.isInsideRadius(object, radius, false, false))
{
performSocial(social, object, activeChar);
}
}
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2Object.class, radius, object -> performSocial(social, object, activeChar));
activeChar.sendMessage(radius + " units radius affected by your request.");
}
catch (NumberFormatException nbe)
@@ -550,13 +518,7 @@ public class AdminEffects implements IAdminCommandHandler
if (radius > 0)
{
for (L2Object object : activeChar.getKnownList().getKnownObjects().values())
{
if (activeChar.isInsideRadius(object, radius, false, false))
{
performAbnormalVisualEffect(ave, object);
}
}
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2Object.class, radius, object -> performAbnormalVisualEffect(ave, object));
activeChar.sendMessage("Affected all characters in radius " + param2 + " by " + param1 + " abnormal visual effect.");
}
else

View File

@@ -16,7 +16,6 @@
*/
package handlers.admincommandhandlers;
import java.util.Collection;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@@ -93,19 +92,14 @@ public class AdminHeal implements IAdminCommandHandler
try
{
final int radius = Integer.parseInt(player);
final Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
for (L2Object object : objs)
L2World.getInstance().forEachVisibleObject(activeChar, L2Character.class, character ->
{
if (object instanceof L2Character)
character.setCurrentHpMp(character.getMaxHp(), character.getMaxMp());
if (character instanceof L2PcInstance)
{
final L2Character character = (L2Character) object;
character.setCurrentHpMp(character.getMaxHp(), character.getMaxMp());
if (object instanceof L2PcInstance)
{
character.setCurrentCp(character.getMaxCp());
}
character.setCurrentCp(character.getMaxCp());
}
}
});
activeChar.sendMessage("Healed within " + radius + " unit radius.");
return;

View File

@@ -59,15 +59,15 @@ public class AdminKill implements IAdminCommandHandler
try
{
final int radius = Integer.parseInt(st.nextToken());
for (L2Character knownChar : plyr.getKnownList().getKnownCharactersInRadius(radius))
L2World.getInstance().forEachVisibleObjectInRange(plyr, L2Character.class, radius, knownChar ->
{
if ((knownChar instanceof L2ControllableMobInstance) || (knownChar == activeChar))
{
continue;
return;
}
kill(activeChar, knownChar);
}
});
activeChar.sendMessage("Killed all characters within a " + radius + " unit radius.");
return true;
@@ -86,14 +86,14 @@ public class AdminKill implements IAdminCommandHandler
{
final int radius = Integer.parseInt(firstParam);
for (L2Character knownChar : activeChar.getKnownList().getKnownCharactersInRadius(radius))
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2Character.class, radius, wo ->
{
if ((knownChar instanceof L2ControllableMobInstance) || (knownChar == activeChar))
if ((wo instanceof L2ControllableMobInstance) || (wo == activeChar))
{
continue;
return;
}
kill(activeChar, knownChar);
}
kill(activeChar, wo);
});
activeChar.sendMessage("Killed all characters within a " + radius + " unit radius.");
return true;

View File

@@ -91,10 +91,10 @@ public class AdminRes implements IAdminCommandHandler
{
final int radius = Integer.parseInt(resParam);
for (L2PcInstance knownPlayer : activeChar.getKnownList().getKnownPlayersInRadius(radius))
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2PcInstance.class, radius, knownPlayer ->
{
doResurrect(knownPlayer);
}
});
activeChar.sendMessage("Resurrected all players within a " + radius + " unit radius.");
return;
@@ -138,13 +138,13 @@ public class AdminRes implements IAdminCommandHandler
{
radius = Integer.parseInt(radiusStr);
for (L2Character knownChar : activeChar.getKnownList().getKnownCharactersInRadius(radius))
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2Character.class, radius, knownChar ->
{
if (!(knownChar instanceof L2PcInstance) && !(knownChar instanceof L2ControllableMobInstance))
{
doResurrect(knownChar);
}
}
});
activeChar.sendMessage("Resurrected all non-players within a " + radius + " unit radius.");
}

View File

@@ -125,7 +125,7 @@ public class AdminScan implements IAdminCommandHandler
final NpcHtmlMessage html = new NpcHtmlMessage();
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/scan.htm");
final StringBuilder sb = new StringBuilder();
for (L2Character character : activeChar.getKnownList().getKnownCharactersInRadius(radius))
for (L2Character character : L2World.getInstance().getVisibleObjects(activeChar, L2Character.class, radius))
{
if (character instanceof L2Npc)
{

View File

@@ -29,12 +29,9 @@ import com.l2jmobius.gameserver.util.Util;
/**
* This class handles following admin commands: - server_shutdown [sec] = shows menu or shuts down server in sec seconds
* @version $Revision: 1.5.2.1.2.4 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminShutdown implements IAdminCommandHandler
{
// private static Logger _log = Logger.getLogger(AdminShutdown.class.getName());
private static final String[] ADMIN_COMMANDS =
{
"admin_server_shutdown",
@@ -110,7 +107,7 @@ public class AdminShutdown implements IAdminCommandHandler
cal.set(Calendar.HOUR_OF_DAY, h);
cal.set(Calendar.MINUTE, m);
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/shutdown.htm");
adminReply.replace("%count%", String.valueOf(L2World.getInstance().getAllPlayersCount()));
adminReply.replace("%count%", String.valueOf(L2World.getInstance().getPlayers().size()));
adminReply.replace("%used%", String.valueOf(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
adminReply.replace("%time%", format.format(cal.getTime()));
activeChar.sendPacket(adminReply);
@@ -125,5 +122,4 @@ public class AdminShutdown implements IAdminCommandHandler
{
Shutdown.getInstance().abort(activeChar);
}
}

View File

@@ -22,8 +22,6 @@ import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.L2WorldRegion;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.TeleportWhereType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -65,19 +63,23 @@ public class AdminZone implements IAdminCommandHandler
getGeoRegionXY(activeChar);
activeChar.sendMessage("Closest Town: " + MapRegionManager.getInstance().getClosestTownName(activeChar));
Location loc;
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.CASTLE);
activeChar.sendMessage("TeleToLocation (Castle): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.CLANHALL);
activeChar.sendMessage("TeleToLocation (ClanHall): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.SIEGEFLAG);
activeChar.sendMessage("TeleToLocation (SiegeFlag): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.TOWN);
activeChar.sendMessage("TeleToLocation (Town): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
// Prevent exit instance variable deletion.
if (activeChar.getInstanceId() == 0)
{
Location loc;
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.CASTLE);
activeChar.sendMessage("TeleToLocation (Castle): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.CLANHALL);
activeChar.sendMessage("TeleToLocation (ClanHall): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.SIEGEFLAG);
activeChar.sendMessage("TeleToLocation (SiegeFlag): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.TOWN);
activeChar.sendMessage("TeleToLocation (Town): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
}
}
else if (actualCommand.equalsIgnoreCase("admin_zone_visual"))
{
@@ -129,29 +131,26 @@ public class AdminZone implements IAdminCommandHandler
adminReply.replace("%DANGER%", (activeChar.isInsideZone(ZoneId.DANGER_AREA) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
adminReply.replace("%NOSTORE%", (activeChar.isInsideZone(ZoneId.NO_STORE) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
adminReply.replace("%SCRIPT%", (activeChar.isInsideZone(ZoneId.SCRIPT) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
final StringBuilder zones = new StringBuilder(100);
final L2WorldRegion region = L2World.getInstance().getRegion(activeChar.getX(), activeChar.getY());
for (L2ZoneType zone : region.getZones())
for (L2ZoneType zone : ZoneManager.getInstance().getZones(activeChar))
{
if (zone.isCharacterInZone(activeChar))
if (zone.getName() != null)
{
if (zone.getName() != null)
{
zones.append(zone.getName());
if (zone.getId() < 300000)
{
zones.append(" (");
zones.append(zone.getId());
zones.append(")");
}
zones.append("<br1>");
}
else
zones.append(zone.getName());
if (zone.getId() < 300000)
{
zones.append(" (");
zones.append(zone.getId());
zones.append(")");
}
zones.append(" ");
zones.append("<br1>");
}
else
{
zones.append(zone.getId());
}
zones.append(" ");
}
for (NpcSpawnTerritory territory : ZoneManager.getInstance().getSpawnTerritories(activeChar))
{
@@ -166,8 +165,8 @@ public class AdminZone implements IAdminCommandHandler
{
final int worldX = activeChar.getX();
final int worldY = activeChar.getY();
final int geoX = ((((worldX - (-327680)) >> 4) >> 11) + 10);
final int geoY = ((((worldY - (-262144)) >> 4) >> 11) + 10);
final int geoX = (((worldX - -327680) >> 4) >> 11) + 10;
final int geoY = (((worldY - -262144) >> 4) >> 11) + 10;
activeChar.sendMessage("GeoRegion: " + geoX + "_" + geoY + "");
}

View File

@@ -64,7 +64,7 @@ public class FindPvP implements IBypassHandler
}
int count = 0;
for (L2PcInstance pl : player.getKnownList().getKnownPlayers().values())
for (L2PcInstance pl : L2World.getInstance().getVisibleObjects(player, L2PcInstance.class))
{
if ((pl.getPvpFlag() > 0) && !pl.isInsideZone(ZoneId.PEACE))
{
@@ -91,7 +91,7 @@ public class FindPvP implements IBypassHandler
allyId = activeChar.getClanId();
}
clanNumbers.put(allyId, 1);
for (L2PcInstance known : mostPvP.getKnownList().getKnownPlayers().values())
for (L2PcInstance known : L2World.getInstance().getVisibleObjects(mostPvP, L2PcInstance.class))
{
int knownAllyId = known.getAllyId();
if (knownAllyId == 0)

View File

@@ -24,6 +24,7 @@ import com.l2jmobius.gameserver.handler.IChatHandler;
import com.l2jmobius.gameserver.handler.IVoicedCommandHandler;
import com.l2jmobius.gameserver.handler.VoicedCommandHandler;
import com.l2jmobius.gameserver.model.BlockList;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.PcCondOverride;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
@@ -86,13 +87,13 @@ public final class ChatGeneral implements IChatHandler
}
final CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getAppearance().getVisibleName(), text);
for (L2PcInstance player : activeChar.getKnownList().getKnownPlayers().values())
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2PcInstance.class, 1250, player ->
{
if ((player != null) && activeChar.isInsideRadius(player, 1250, false, true) && !BlockList.isBlocked(player, activeChar))
if ((player != null) && !BlockList.isBlocked(player, activeChar))
{
player.sendPacket(cs);
}
}
});
activeChar.sendPacket(cs);
}

View File

@@ -22,7 +22,7 @@ import java.util.List;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.ai.CtrlEvent;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.conditions.Condition;
@@ -80,13 +80,8 @@ public final class Confuse extends AbstractEffect
final List<L2Character> targetList = new ArrayList<>();
// Getting the possible targets
for (L2Object obj : info.getEffected().getKnownList().getKnownObjects().values())
{
if (((info.getEffected().isMonster() && obj.isAttackable()) || (obj instanceof L2Character)) && (obj != info.getEffected()))
{
targetList.add((L2Character) obj);
}
}
L2World.getInstance().forEachVisibleObject(info.getEffected(), L2Character.class, targetList::add);
// if there is no target, exit function
if (!targetList.isEmpty())

View File

@@ -17,6 +17,7 @@
package handlers.effecthandlers;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -61,7 +62,7 @@ public final class Hide extends AbstractEffect
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
}
for (L2Character target : activeChar.getKnownList().getKnownCharacters())
L2World.getInstance().forEachVisibleObject(activeChar, L2Character.class, target ->
{
if ((target != null) && (target.getTarget() == activeChar))
{
@@ -70,7 +71,7 @@ public final class Hide extends AbstractEffect
target.abortCast();
target.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
}
}
});
}
}
}

View File

@@ -90,7 +90,7 @@ public final class OpenDoor extends AbstractEffect
return;
}
if ((Rnd.get(100) < _chance) && !door.getOpen())
if ((Rnd.get(100) < _chance) && !door.isOpen())
{
door.openMe();
}

View File

@@ -16,14 +16,13 @@
*/
package handlers.effecthandlers;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.conditions.Condition;
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
import com.l2jmobius.gameserver.model.skills.BuffInfo;
import com.l2jmobius.gameserver.model.stats.Formulas;
import com.l2jmobius.gameserver.util.Util;
/**
* Transfer Hate effect implementation.
@@ -55,27 +54,21 @@ public final class TransferHate extends AbstractEffect
@Override
public void onStart(BuffInfo info)
{
if (!Util.checkIfInRange(info.getSkill().getEffectRange(), info.getEffector(), info.getEffected(), true))
L2World.getInstance().forEachVisibleObjectInRange(info.getEffector(), L2Attackable.class, info.getSkill().getAffectRange(), hater ->
{
return;
}
for (L2Character obj : info.getEffector().getKnownList().getKnownCharactersInRadius(info.getSkill().getAffectRange()))
{
if ((obj == null) || !obj.isAttackable() || obj.isDead())
if ((hater == null) || hater.isDead())
{
continue;
return;
}
final L2Attackable hater = ((L2Attackable) obj);
final int hate = hater.getHating(info.getEffector());
if (hate <= 0)
{
continue;
return;
}
hater.reduceHate(info.getEffector(), -hate);
hater.addDamageHate(info.getEffected(), 0, hate);
}
});
}
}

View File

@@ -19,6 +19,7 @@ package handlers.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager;
import com.l2jmobius.gameserver.model.ArenaParticipantsHolder;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2BlockInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -91,14 +92,14 @@ public class EventItem implements IItemHandler
if (holder != null)
{
final int team = holder.getPlayerTeam(castor);
for (L2PcInstance pc : block.getKnownList().getKnownPlayersInRadius(sk.getEffectRange()))
L2World.getInstance().forEachVisibleObjectInRange(block, L2PcInstance.class, sk.getEffectRange(), pc ->
{
final int enemyTeam = holder.getPlayerTeam(pc);
if ((enemyTeam != -1) && (enemyTeam != team))
{
sk.applyEffects(castor, pc);
}
}
});
return true;
}
_log.warning("Char: " + castor.getName() + "[" + castor.getObjectId() + "] has unknown block checker arena");

View File

@@ -17,11 +17,11 @@
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
@@ -71,34 +71,28 @@ public class Area implements ITargetTypeHandler
}
final int maxTargets = skill.getAffectLimit();
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharacters();
for (L2Character obj : objs)
L2World.getInstance().forEachVisibleObject(activeChar, L2Character.class, obj ->
{
if (!(obj.isAttackable() || obj.isPlayable()))
if (!(obj.isAttackable() || obj.isPlayable()) || (obj == origin))
{
continue;
}
if (obj == origin)
{
continue;
return;
}
if (Util.checkIfInRange(skill.getAffectRange(), origin, obj, true))
{
if (!Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
{
continue;
return;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
return;
}
targetList.add(obj);
}
}
});
if (targetList.isEmpty())
{

View File

@@ -17,11 +17,11 @@
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
@@ -55,21 +55,20 @@ public class AreaCorpseMob implements ITargetTypeHandler
targetList.add(target);
final boolean srcInArena = activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE);
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharacters();
for (L2Character obj : objs)
L2World.getInstance().forEachVisibleObject(activeChar, L2Character.class, obj ->
{
if (!(obj.isAttackable() || obj.isPlayable()) || !Util.checkIfInRange(skill.getAffectRange(), target, obj, true))
{
continue;
return;
}
if (!Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
{
continue;
return;
}
targetList.add(obj);
}
});
if (targetList.isEmpty())
{

View File

@@ -17,14 +17,13 @@
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2SiegeFlagInstance;
@@ -70,25 +69,20 @@ public class AreaFriendly implements ITargetTypeHandler
if (target != null)
{
final int maxTargets = skill.getAffectLimit();
final Collection<L2Character> objs = target.getKnownList().getKnownCharactersInRadius(skill.getAffectRange());
// TODO: Chain Heal - The recovery amount decreases starting from the most injured person.
Collections.sort(targetList, new CharComparator());
for (L2Character obj : objs)
L2World.getInstance().forEachVisibleObjectInRange(target, L2Character.class, skill.getAffectRange(), obj ->
{
if (!checkTarget(player, obj) || (obj == activeChar))
{
continue;
return;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
return;
}
targetList.add(obj);
}
});
}
if (targetList.isEmpty())

View File

@@ -17,16 +17,15 @@
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
@@ -52,38 +51,32 @@ public class AreaSummon implements ITargetTypeHandler
}
final boolean srcInArena = (activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE));
final Collection<L2Character> objs = target.getKnownList().getKnownCharacters();
final int maxTargets = skill.getAffectLimit();
for (L2Character obj : objs)
L2World.getInstance().forEachVisibleObjectInRange(target, L2Character.class, skill.getAffectRange(), obj ->
{
if ((obj == null) || (obj == target) || (obj == activeChar))
if (obj == activeChar)
{
continue;
}
if (!Util.checkIfInRange(skill.getAffectRange(), target, obj, true))
{
continue;
return;
}
if (!(obj.isAttackable() || obj.isPlayable()))
{
continue;
return;
}
if (!Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
{
continue;
return;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
return;
}
targetList.add(obj);
}
});
if (targetList.isEmpty())
{

View File

@@ -21,6 +21,7 @@ import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
@@ -38,7 +39,7 @@ public class Aura implements ITargetTypeHandler
{
final List<L2Character> targetList = new ArrayList<>();
final boolean srcInArena = (activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE));
for (L2Character obj : activeChar.getKnownList().getKnownCharactersInRadius(skill.getAffectRange()))
for (L2Character obj : L2World.getInstance().getVisibleObjects(activeChar, L2Character.class, skill.getAffectRange()))
{
if (obj.isDoor() || obj.isAttackable() || obj.isPlayable())
{

View File

@@ -17,11 +17,12 @@
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
@@ -36,11 +37,10 @@ public class AuraCorpseMob implements ITargetTypeHandler
{
final List<L2Character> targetList = new ArrayList<>();
// Go through the L2Character _knownList
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharactersInRadius(skill.getAffectRange());
final int maxTargets = skill.getAffectLimit();
for (L2Character obj : objs)
for (L2Attackable obj : L2World.getInstance().getVisibleObjects(activeChar, L2Attackable.class, skill.getAffectRange()))
{
if (obj.isAttackable() && obj.isDead())
if (obj.isDead())
{
if (onlyFirst)
{

View File

@@ -22,6 +22,7 @@ import java.util.List;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2SiegeFlagInstance;
@@ -41,20 +42,20 @@ public class AuraFriendly implements ITargetTypeHandler
List<L2Character> targetList = new ArrayList<>();
L2PcInstance player = activeChar.getActingPlayer();
int maxTargets = skill.getAffectLimit();
for (L2Character obj : player.getKnownList().getKnownCharactersInRadius(skill.getAffectRange()))
L2World.getInstance().forEachVisibleObject(player, L2Character.class, obj ->
{
if ((obj == activeChar) || !checkTarget(player, obj))
{
continue;
return;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
return;
}
targetList.add(obj);
}
});
if (targetList.isEmpty())
{

View File

@@ -17,11 +17,11 @@
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
@@ -70,40 +70,39 @@ public class BehindArea implements ITargetTypeHandler
origin = activeChar;
}
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharacters();
final int maxTargets = skill.getAffectLimit();
for (L2Character obj : objs)
L2World.getInstance().forEachVisibleObject(activeChar, L2Character.class, obj ->
{
if (!(obj.isAttackable() || obj.isPlayable()))
{
continue;
return;
}
if (obj == origin)
{
continue;
return;
}
if (Util.checkIfInRange(skill.getAffectRange(), origin, obj, true))
{
if (!obj.isBehind(activeChar))
{
continue;
return;
}
if (!Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
{
continue;
return;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
return;
}
targetList.add(obj);
}
}
});
if (targetList.isEmpty())
{

View File

@@ -17,11 +17,11 @@
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
@@ -37,9 +37,8 @@ public class BehindAura implements ITargetTypeHandler
{
final List<L2Character> targetList = new ArrayList<>();
final boolean srcInArena = (activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE));
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharactersInRadius(skill.getAffectRange());
final int maxTargets = skill.getAffectLimit();
for (L2Character obj : objs)
for (L2Character obj : L2World.getInstance().getVisibleObjects(activeChar, L2Character.class, skill.getAffectRange()))
{
if (obj.isAttackable() || obj.isPlayable())
{

View File

@@ -17,20 +17,19 @@
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2ClanMember;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.TvTEvent;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
@@ -148,23 +147,17 @@ public class Clan implements ITargetTypeHandler
targetList.add(activeChar);
final Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
final int maxTargets = skill.getAffectLimit();
for (L2Object newTarget : objs)
for (L2Npc newTarget : L2World.getInstance().getVisibleObjects(activeChar, L2Npc.class, skill.getCastRange()))
{
if (newTarget.isNpc() && npc.isInMyClan((L2Npc) newTarget))
if (newTarget.isNpc() && npc.isInMyClan(newTarget))
{
if (!Util.checkIfInRange(skill.getCastRange(), activeChar, newTarget, true))
{
continue;
}
final int maxTargets = skill.getAffectLimit();
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
targetList.add((L2Npc) newTarget);
targetList.add(newTarget);
}
}
}

View File

@@ -17,16 +17,15 @@
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
@@ -48,20 +47,11 @@ public class ClanMember implements ITargetTypeHandler
activeChar
};
}
final Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
for (L2Object newTarget : objs)
for (L2Npc newTarget : L2World.getInstance().getVisibleObjects(activeChar, L2Npc.class, skill.getCastRange()))
{
if (newTarget.isNpc() && npc.isInMyClan((L2Npc) newTarget))
if (newTarget.isNpc() && npc.isInMyClan(newTarget))
{
if (!Util.checkIfInRange(skill.getCastRange(), activeChar, newTarget, true))
{
continue;
}
if (((L2Npc) newTarget).isAffectedBySkill(skill.getId()))
{
continue;
}
targetList.add((L2Npc) newTarget);
targetList.add(newTarget);
break;
}
}

View File

@@ -17,13 +17,13 @@
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2ClanMember;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -31,7 +31,6 @@ import com.l2jmobius.gameserver.model.entity.TvTEvent;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
@@ -136,18 +135,11 @@ public class CorpseClan implements ITargetTypeHandler
targetList.add(activeChar);
final Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
final int maxTargets = skill.getAffectLimit();
for (L2Object newTarget : objs)
for (L2Npc newTarget : L2World.getInstance().getVisibleObjects(activeChar, L2Npc.class, skill.getCastRange()))
{
if (newTarget.isNpc() && npc.isInMyClan((L2Npc) newTarget))
if (npc.isInMyClan(newTarget))
{
if (!Util.checkIfInRange(skill.getCastRange(), activeChar, newTarget, true))
{
continue;
}
if (targetList.size() >= maxTargets)
if (targetList.size() >= skill.getAffectLimit())
{
break;
}

View File

@@ -17,11 +17,11 @@
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
@@ -76,40 +76,39 @@ public class FrontArea implements ITargetTypeHandler
activeChar.setHeading(Util.calculateHeadingFrom(activeChar, origin));
}
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharacters();
final int maxTargets = skill.getAffectLimit();
for (L2Character obj : objs)
L2World.getInstance().forEachVisibleObject(activeChar, L2Character.class, obj ->
{
if (!(obj.isAttackable() || obj.isPlayable()))
{
continue;
return;
}
if (obj == origin)
{
continue;
return;
}
if (Util.checkIfInRange(skill.getAffectRange(), origin, obj, true))
{
if (!obj.isInFrontOf(activeChar))
{
continue;
return;
}
if (!Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
{
continue;
return;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
return;
}
targetList.add(obj);
}
}
});
if (targetList.isEmpty())
{

View File

@@ -17,11 +17,11 @@
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
@@ -37,9 +37,8 @@ public class FrontAura implements ITargetTypeHandler
{
final List<L2Character> targetList = new ArrayList<>();
final boolean srcInArena = (activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE));
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharactersInRadius(skill.getAffectRange());
final int maxTargets = skill.getAffectLimit();
for (L2Character obj : objs)
for (L2Character obj : L2World.getInstance().getVisibleObjects(activeChar, L2Character.class, skill.getAffectRange()))
{
if (obj.isAttackable() || obj.isPlayable())
{

View File

@@ -21,6 +21,7 @@ import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.effects.L2EffectType;
@@ -41,27 +42,27 @@ public class Ground implements ITargetTypeHandler
final int maxTargets = skill.getAffectLimit();
final boolean srcInArena = (activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE));
for (L2Character character : activeChar.getKnownList().getKnownCharacters())
L2World.getInstance().forEachVisibleObject(activeChar, L2Character.class, character ->
{
if ((character != null) && character.isInsideRadius(player.getCurrentSkillWorldPosition(), skill.getAffectRange(), false, false))
{
if (!Skill.checkForAreaOffensiveSkills(activeChar, character, skill, srcInArena))
{
continue;
return;
}
if (character.isDoor())
{
continue;
return;
}
if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
return;
}
targetList.add(character);
}
}
});
if (targetList.isEmpty())
{

View File

@@ -17,11 +17,11 @@
package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.TvTEvent;
@@ -70,9 +70,8 @@ public class PartyClan implements ITargetTypeHandler
}
// Get all visible objects in a spherical area near the L2Character
final Collection<L2PcInstance> objs = activeChar.getKnownList().getKnownPlayersInRadius(radius);
final int maxTargets = skill.getAffectLimit();
for (L2PcInstance obj : objs)
for (L2PcInstance obj : L2World.getInstance().getVisibleObjects(activeChar, L2PcInstance.class, radius))
{
if (obj == null)
{

View File

@@ -1372,9 +1372,9 @@ public final class CrystalCaverns extends AbstractInstance
final CrystalGolem cryGolem = world.crystalGolems.get(npc);
int minDist = 300000;
for (L2Object object : L2World.getInstance().getVisibleObjects(npc, 300))
for (L2ItemInstance object : L2World.getInstance().getVisibleObjects(npc, L2ItemInstance.class, 300))
{
if (object.isItem() && (object.getId() == CRYSTALFOOD))
if (object.getId() == CRYSTALFOOD)
{
final int dx = npc.getX() - object.getX();
final int dy = npc.getY() - object.getY();
@@ -1382,7 +1382,7 @@ public final class CrystalCaverns extends AbstractInstance
if (d < minDist)
{
minDist = d;
cryGolem.foodItem = (L2ItemInstance) object;
cryGolem.foodItem = object;
}
}
}
@@ -1420,7 +1420,7 @@ public final class CrystalCaverns extends AbstractInstance
final CrystalGolem cryGolem = world.crystalGolems.get(npc);
int dx;
int dy;
if ((cryGolem.foodItem == null) || !cryGolem.foodItem.isVisible())
if ((cryGolem.foodItem == null) || !cryGolem.foodItem.isSpawned())
{
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, cryGolem.oldLoc);
cancelQuestTimers("reachFood");
@@ -2027,7 +2027,7 @@ public final class CrystalCaverns extends AbstractInstance
{
if (door.getId() == (room + 24220000))
{
if (door.getOpen())
if (door.isOpen())
{
return "";
}
@@ -2090,7 +2090,7 @@ public final class CrystalCaverns extends AbstractInstance
{
if (door.getId() == doorId)
{
if (door.getOpen() && (world.openedDoors.get(door) == character))
if (door.isOpen() && (world.openedDoors.get(door) == character))
{
door.closeMe();
world.openedDoors.remove(door);

View File

@@ -756,7 +756,6 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
break;
}
final L2MonsterInstance demon = (L2MonsterInstance) addSpawn(PORTRAIT_SPAWNS[i][0] + 2, PORTRAIT_SPAWNS[i][5], PORTRAIT_SPAWNS[i][6], PORTRAIT_SPAWNS[i][7], PORTRAIT_SPAWNS[i][8], false, 0, false, _world.getInstanceId());
updateKnownList(_world, demon);
_world.demons.add(demon);
}
ThreadPool.schedule(new DemonSpawnTask(_world), TIME_BETWEEN_DEMON_SPAWNS);
@@ -955,13 +954,11 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
_world.frintezza.setIsImmobilized(true);
_world.frintezza.setIsInvul(true);
_world.frintezza.disableAllSkills();
updateKnownList(_world, _world.frintezza);
for (int[] element : PORTRAIT_SPAWNS)
{
final L2MonsterInstance demon = (L2MonsterInstance) addSpawn(element[0] + 2, element[5], element[6], element[7], element[8], false, 0, false, _world.getInstanceId());
demon.setIsImmobilized(true);
demon.disableAllSkills();
updateKnownList(_world, demon);
_world.demons.add(demon);
}
ThreadPool.schedule(new IntroTask(_world, 4), 6500);
@@ -1074,7 +1071,6 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
_world.activeScarlet.setIsInvul(true);
_world.activeScarlet.setIsImmobilized(true);
_world.activeScarlet.disableAllSkills();
updateKnownList(_world, _world.activeScarlet);
broadCastPacket(_world, new SocialAction(_world.activeScarlet.getObjectId(), 3));
broadCastPacket(_world, new SpecialCamera(_world.scarletDummy, 800, 180, 10, 1000, 10000, 0, 0, 1, 0, 0));
ThreadPool.schedule(new IntroTask(_world, 19), 2100);
@@ -1098,7 +1094,6 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
for (int i = 0; i < PORTRAIT_SPAWNS.length; i++)
{
final L2MonsterInstance portrait = (L2MonsterInstance) addSpawn(PORTRAIT_SPAWNS[i][0], PORTRAIT_SPAWNS[i][1], PORTRAIT_SPAWNS[i][2], PORTRAIT_SPAWNS[i][3], PORTRAIT_SPAWNS[i][4], false, 0, false, _world.getInstanceId());
updateKnownList(_world, portrait);
_world.portraits.put(portrait, i);
}
_world.overheadDummy.deleteMe();
@@ -1197,7 +1192,6 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
_world.activeScarlet.setIsInvul(true);
_world.activeScarlet.setIsImmobilized(true);
_world.activeScarlet.disableAllSkills();
updateKnownList(_world, _world.activeScarlet);
broadCastPacket(_world, new SpecialCamera(_world.activeScarlet, 450, _world.scarlet_a, 12, 500, 14000, 0, 0, 1, 0, 0));
ThreadPool.schedule(new IntroTask(_world, 31), 8100);
break;
@@ -1403,19 +1397,6 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
}
}
protected void updateKnownList(FETWorld world, L2Npc npc)
{
final Map<Integer, L2PcInstance> npcKnownPlayers = npc.getKnownList().getKnownPlayers();
for (int objId : world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline() && (player.getInstanceId() == world.getInstanceId()))
{
npcKnownPlayers.put(player.getObjectId(), player);
}
}
}
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
{

View File

@@ -21,12 +21,12 @@ import static com.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_FOLLOW;
import static com.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
import java.util.ArrayList;
import java.util.Collection;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.datatables.SkillData;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2DecoyInstance;
@@ -209,58 +209,55 @@ public final class ScarletVanHalisha extends AbstractNpcAI
private L2Character getRandomTarget(L2Npc npc, Skill skill)
{
final Collection<L2Object> objs = npc.getKnownList().getKnownObjects().values();
final ArrayList<L2Character> result = new ArrayList<>();
for (L2Object obj : L2World.getInstance().getVisibleObjects(npc, L2Object.class))
{
for (L2Object obj : objs)
if (obj.isPlayable() || (obj instanceof L2DecoyInstance))
{
if (obj.isPlayable() || (obj instanceof L2DecoyInstance))
if (obj.isPlayer() && obj.getActingPlayer().isInvisible())
{
if (obj.isPlayer() && obj.getActingPlayer().isInvisible())
{
continue;
}
if (((((L2Character) obj).getZ() < (npc.getZ() - 100)) && (((L2Character) obj).getZ() > (npc.getZ() + 100))) || !GeoEngine.getInstance().canSeeTarget(obj, npc))
{
continue;
}
continue;
}
if (obj.isPlayable() || (obj instanceof L2DecoyInstance))
if (((((L2Character) obj).getZ() < (npc.getZ() - 100)) && (((L2Character) obj).getZ() > (npc.getZ() + 100))) || !GeoEngine.getInstance().canSeeTarget(obj, npc))
{
int skillRange = 150;
if (skill != null)
continue;
}
}
if (obj.isPlayable() || (obj instanceof L2DecoyInstance))
{
int skillRange = 150;
if (skill != null)
{
switch (skill.getId())
{
switch (skill.getId())
case 5014:
{
case 5014:
{
skillRange = 150;
break;
}
case 5015:
{
skillRange = 400;
break;
}
case 5016:
{
skillRange = 200;
break;
}
case 5018:
case 5019:
{
_lastRangedSkillTime = System.currentTimeMillis();
skillRange = 550;
break;
}
skillRange = 150;
break;
}
case 5015:
{
skillRange = 400;
break;
}
case 5016:
{
skillRange = 200;
break;
}
case 5018:
case 5019:
{
_lastRangedSkillTime = System.currentTimeMillis();
skillRange = 550;
break;
}
}
if (Util.checkIfInRange(skillRange, npc, obj, true) && !((L2Character) obj).isDead())
{
result.add((L2Character) obj);
}
}
if (Util.checkIfInRange(skillRange, npc, obj, true) && !((L2Character) obj).isDead())
{
result.add((L2Character) obj);
}
}
}

View File

@@ -19,6 +19,7 @@ package instances.IceQueensCastle;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
@@ -79,7 +80,7 @@ public final class IceQueensCastle extends AbstractInstance
{
case "ATTACK_KNIGHT":
{
for (L2Character character : npc.getKnownList().getKnownCharacters())
L2World.getInstance().forEachVisibleObject(npc, L2Character.class, character ->
{
if ((character.getId() == ARCHERY_KNIGHT) && !character.isDead() && !((L2Attackable) character).isDecayed())
{
@@ -87,7 +88,7 @@ public final class IceQueensCastle extends AbstractInstance
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, character);
((L2Attackable) npc).addDamageHate(character, 0, 999999);
}
}
});
startQuestTimer("ATTACK_KNIGHT", 3000, npc, null);
break;
}
@@ -140,7 +141,7 @@ public final class IceQueensCastle extends AbstractInstance
{
if (creature.isPlayer() && npc.isScriptValue(0))
{
for (L2Character character : npc.getKnownList().getKnownCharacters())
L2World.getInstance().forEachVisibleObject(npc, L2Character.class, character ->
{
if ((character.getId() == ARCHERY_KNIGHT) && !character.isDead() && !((L2Attackable) character).isDecayed())
{
@@ -150,7 +151,7 @@ public final class IceQueensCastle extends AbstractInstance
npc.setScriptValue(1);
startQuestTimer("ATTACK_KNIGHT", 5000, npc, null);
}
}
});
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.S1_MAY_THE_PROTECTION_OF_THE_GODS_BE_UPON_YOU, creature.getName());
}
return super.onSeeCreature(npc, creature, isSummon);

View File

@@ -27,6 +27,7 @@ import com.l2jmobius.gameserver.enums.MountType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2CommandChannel;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.PcCondOverride;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
@@ -652,13 +653,10 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
final L2Attackable mob = (L2Attackable) npc;
mob.clearAggroList();
for (L2Character characters : npc.getKnownList().getKnownPlayersInRadius(1000))
L2World.getInstance().forEachVisibleObjectInRange(npc, L2PcInstance.class, 1000, characters ->
{
if ((characters != null))
{
mob.addDamageHate(characters, 0, getRandom(10000, 20000));
}
}
mob.addDamageHate(characters, 0, getRandom(10000, 20000));
});
startQuestTimer("LEADER_RANDOMIZE", 25000, npc, null);
break;
}

View File

@@ -19,6 +19,7 @@ package instances.MithrilMine;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
@@ -108,9 +109,9 @@ public final class MithrilMine extends AbstractInstance
}
case "FINISH":
{
for (L2Character knownChar : npc.getKnownList().getKnownCharacters())
L2World.getInstance().forEachVisibleObject(npc, L2Character.class, knownChar ->
{
if ((knownChar != null) && (knownChar.getId() == KEGOR))
if (knownChar.getId() == KEGOR)
{
final L2Npc kegor = (L2Npc) knownChar;
kegor.setScriptValue(2);
@@ -119,7 +120,7 @@ public final class MithrilMine extends AbstractInstance
kegor.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player);
kegor.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.I_CAN_FINALLY_TAKE_A_BREATHER_BY_THE_WAY_WHO_ARE_YOU_HMM_I_THINK_I_KNOW_WHO_SENT_YOU);
}
}
});
InstanceManager.getInstance().getInstance(world.getInstanceId()).setDuration(3000);
break;
}

View File

@@ -21,11 +21,13 @@ import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
import com.l2jmobius.gameserver.model.instancezone.InstanceWorld;
@@ -184,16 +186,12 @@ public final class PailakaDevilsLegacy extends AbstractInstance
{
if ((damage > 0) && npc.isScriptValue(0))
{
for (L2Character characters : npc.getKnownList().getKnownCharactersInRadius(600))
L2World.getInstance().forEachVisibleObjectInRange(npc, L2MonsterInstance.class, 600, monster ->
{
if ((characters != null) && characters.isMonster())
{
final L2Attackable monster = (L2Attackable) characters;
monster.addDamageHate(npc, 0, 999);
monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, npc);
monster.reduceCurrentHp(500 + getRandom(0, 200), npc, BOOM.getSkill());
}
}
monster.addDamageHate(npc, 0, 999);
monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, npc);
monster.reduceCurrentHp(500 + getRandom(0, 200), npc, BOOM.getSkill());
});
npc.doCast(BOOM.getSkill());
npc.setScriptValue(1);
startQuestTimer("DELETE", 2000, npc, null);
@@ -310,7 +308,6 @@ public final class PailakaDevilsLegacy extends AbstractInstance
{
tigress.getAI().stopAITask();
}
tigress.getKnownList().removeAllKnownObjects();
tigress.setTarget(null);
}
tigress.decayMe();

View File

@@ -429,7 +429,7 @@ public abstract class AbstractSagaQuest extends Quest
case "Mob_3 Timer 1":
{
final L2Npc Mob_2 = FindSpawn(player, (L2Npc) L2World.getInstance().findObject(st.getInt("Mob_2")));
if (npc.getKnownList().knowsObject(Mob_2))
if (L2World.getInstance().getVisibleObjects(npc, L2Npc.class).contains(Mob_2))
{
((L2Attackable) npc).addDamageHate(Mob_2, 0, 99999);
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, Mob_2, null);

View File

@@ -27,6 +27,7 @@ import com.l2jmobius.gameserver.ai.CtrlEvent;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.datatables.SkillData;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@@ -642,9 +643,9 @@ public class Q00144_PailakaInjuredDragon extends Quest
final int[] zoneTeleport = NOEXIT_ZONES.get(zone.getId());
if (zoneTeleport != null)
{
for (L2Character npcs : character.getKnownList().getKnownCharactersInRadius(700))
for (L2Character npc : L2World.getInstance().getVisibleObjects(character, L2Npc.class, 700))
{
if (!(npcs instanceof L2Npc) || npcs.isDead())
if (npc.isDead())
{
continue;
}
@@ -670,7 +671,7 @@ public class Q00144_PailakaInjuredDragon extends Quest
// This function will check if there is other mob alive in this wall of mobs. If all mobs in the first row are dead then despawn the second row mobs, the mages.
private final void checkIfLastInWall(L2Npc npc)
{
final Collection<L2Character> knowns = npc.getKnownList().getKnownCharactersInRadius(700);
final Collection<L2Character> knowns = L2World.getInstance().getVisibleObjects(npc, L2Character.class, 700);
for (L2Character npcs : knowns)
{
if (!(npcs instanceof L2Npc) || npcs.isDead())

View File

@@ -17,7 +17,6 @@
package quests.Q00727_HopeWithinTheDarkness;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -28,6 +27,7 @@ import com.l2jmobius.gameserver.instancemanager.FortManager;
import com.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
@@ -244,8 +244,7 @@ public class Q00727_HopeWithinTheDarkness extends Quest
}
else if (event.equalsIgnoreCase("buff"))
{
final Collection<L2PcInstance> players = npc.getKnownList().getKnownPlayers().values();
for (L2PcInstance pl : players)
for (L2PcInstance pl : L2World.getInstance().getVisibleObjects(npc, L2PcInstance.class))
{
if ((pl != null) && Util.checkIfInRange(75, npc, pl, false) && (NPC_BUFFS.get(npc.getId()) != null))
{
@@ -260,7 +259,7 @@ public class Q00727_HopeWithinTheDarkness extends Quest
{
if (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ATTACK)
{
for (L2Character foe : npc.getKnownList().getKnownCharactersInRadius(npc.getAggroRange()))
for (L2Character foe : L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange()))
{
if ((foe instanceof L2Attackable) && !(foe instanceof L2QuestGuardInstance))
{