Dropped knownlists.
This commit is contained in:
parent
3f20f04fd3
commit
b1fc2fa47d
@ -253,17 +253,6 @@ MinMonsterAnimation = 5
|
||||
# Default: 20
|
||||
MaxMonsterAnimation = 20
|
||||
|
||||
# Knownlist (the list of things a character sees) update method. Default is currently time based updating, which also makes it possible to use config options for guards to see moving monsters. Alternatively move based update can be used but guards cannot track mobs with that option but otherwise it should work well.
|
||||
# Default: False
|
||||
MoveBasedKnownlist = False
|
||||
|
||||
# Interval (in milliseconds) in which the knownlist does full updates.
|
||||
# For move based updates its used for intermediate updates.
|
||||
# WARNING!
|
||||
# Useful interval is between 300 - 2000. Too small value may kill your CPU, too high value may not update knownlists properly. The default value is chosen experimentally.
|
||||
# Default: 1250
|
||||
KnownListUpdateInterval = 1250
|
||||
|
||||
# Grid options: Grids can turn themselves on and off. This also affects the loading and processing of all AI tasks and (in the future) geodata within this grid.
|
||||
# Turn on for a grid with a person in it is immediate, but it then turns on the 8 neighboring grids based on the specified number of seconds.
|
||||
# Turn off for a grid and neighbors occurs after the specified number of seconds have passed during which a grid has had no players in or in any of its neighbors.
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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])
|
||||
{
|
||||
|
@ -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":
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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()))
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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()));
|
||||
}
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
160
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/ai/others/SiegeGuards.java
vendored
Normal file
160
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/ai/others/SiegeGuards.java
vendored
Normal 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();
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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())
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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.");
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 + "");
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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())
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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())
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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())
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -1904,8 +1904,6 @@ public final class Config
|
||||
MAX_NPC_ANIMATION = General.getInt("MaxNPCAnimation", 20);
|
||||
MIN_MONSTER_ANIMATION = General.getInt("MinMonsterAnimation", 5);
|
||||
MAX_MONSTER_ANIMATION = General.getInt("MaxMonsterAnimation", 20);
|
||||
MOVE_BASED_KNOWNLIST = General.getBoolean("MoveBasedKnownlist", false);
|
||||
KNOWNLIST_UPDATE_INTERVAL = General.getLong("KnownListUpdateInterval", 1250);
|
||||
GRIDS_ALWAYS_ON = General.getBoolean("GridsAlwaysOn", false);
|
||||
GRID_NEIGHBOR_TURNON_TIME = General.getInt("GridNeighborTurnOnTime", 1);
|
||||
GRID_NEIGHBOR_TURNOFF_TIME = General.getInt("GridNeighborTurnOffTime", 90);
|
||||
|
@ -215,4 +215,57 @@ public final class CommonUtil
|
||||
}
|
||||
return sj.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param <T>
|
||||
* @param array - the array to look into
|
||||
* @param obj - the object to search for
|
||||
* @return {@code true} if the {@code array} contains the {@code obj}, {@code false} otherwise.
|
||||
*/
|
||||
public static <T> boolean contains(T[] array, T obj)
|
||||
{
|
||||
for (T element : array)
|
||||
{
|
||||
if (element == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array - the array to look into
|
||||
* @param obj - the integer to search for
|
||||
* @return {@code true} if the {@code array} contains the {@code obj}, {@code false} otherwise
|
||||
*/
|
||||
public static boolean contains(int[] array, int obj)
|
||||
{
|
||||
for (int element : array)
|
||||
{
|
||||
if (element == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array - the array to look into
|
||||
* @param obj - the object to search for
|
||||
* @param ignoreCase
|
||||
* @return {@code true} if the {@code array} contains the {@code obj}, {@code false} otherwise.
|
||||
*/
|
||||
public static boolean contains(String[] array, String obj, boolean ignoreCase)
|
||||
{
|
||||
for (String element : array)
|
||||
{
|
||||
if (element.equals(obj) || (ignoreCase && element.equalsIgnoreCase(obj)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,6 @@ import com.l2jmobius.gameserver.network.ClientNetworkManager;
|
||||
import com.l2jmobius.gameserver.network.loginserver.LoginServerNetworkManager;
|
||||
import com.l2jmobius.gameserver.network.telnet.TelnetServer;
|
||||
import com.l2jmobius.gameserver.scripting.ScriptEngineManager;
|
||||
import com.l2jmobius.gameserver.taskmanager.KnownListUpdateTaskManager;
|
||||
import com.l2jmobius.gameserver.taskmanager.TaskManager;
|
||||
|
||||
public final class GameServer
|
||||
@ -370,7 +369,6 @@ public final class GameServer
|
||||
LOGGER.info("IdFactory: Free ObjectID's remaining: " + IdFactory.getInstance().size());
|
||||
|
||||
TvTManager.getInstance();
|
||||
KnownListUpdateTaskManager.getInstance();
|
||||
|
||||
if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS)
|
||||
{
|
||||
|
@ -348,7 +348,7 @@ public abstract class AbstractAI implements Ctrl
|
||||
@Override
|
||||
public final void notifyEvent(CtrlEvent evt, Object... args)
|
||||
{
|
||||
if ((!_actor.isVisible() && !_actor.isTeleporting()) || !_actor.hasAI())
|
||||
if ((!_actor.isSpawned() && !_actor.isTeleporting()) || !_actor.hasAI())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -20,10 +20,10 @@ import static com.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
||||
import static com.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||
import static com.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.concurrent.ThreadPool;
|
||||
@ -36,6 +36,7 @@ import com.l2jmobius.gameserver.enums.AIType;
|
||||
import com.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||
import com.l2jmobius.gameserver.instancemanager.DimensionalRiftManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
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;
|
||||
@ -68,6 +69,8 @@ import com.l2jmobius.gameserver.util.Util;
|
||||
*/
|
||||
public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(L2AttackableAI.class.getName());
|
||||
|
||||
/**
|
||||
* Fear task.
|
||||
* @author Zoey76
|
||||
@ -335,7 +338,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
if (!npc.isAlikeDead())
|
||||
{
|
||||
// If its _knownPlayer isn't empty set the Intention to AI_INTENTION_ACTIVE
|
||||
if (!npc.getKnownList().getKnownPlayers().isEmpty())
|
||||
if (!L2World.getInstance().getVisibleObjects(npc, L2PcInstance.class).isEmpty())
|
||||
{
|
||||
intention = AI_INTENTION_ACTIVE;
|
||||
}
|
||||
@ -465,27 +468,23 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
// A L2Attackable isn't aggressive during 10s after its spawn because _globalAggro is set to -10
|
||||
if (_globalAggro >= 0)
|
||||
{
|
||||
// Get all visible objects inside its Aggro Range
|
||||
final Collection<L2Object> objs = npc.getKnownList().getKnownObjects().values();
|
||||
|
||||
for (L2Object obj : objs)
|
||||
L2World.getInstance().forEachVisibleObject(npc, L2Character.class, target ->
|
||||
{
|
||||
if (!(obj instanceof L2Character) || (obj instanceof L2StaticObjectInstance))
|
||||
if ((target instanceof L2StaticObjectInstance))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
final L2Character target = (L2Character) obj;
|
||||
|
||||
/*
|
||||
* Check to see if this is a festival mob spawn. If it is, then check to see if the aggro trigger is a festival participant...if so, move to attack it.
|
||||
*/
|
||||
if ((npc instanceof L2FestivalMonsterInstance) && (obj instanceof L2PcInstance))
|
||||
if ((npc instanceof L2FestivalMonsterInstance) && (target instanceof L2PcInstance))
|
||||
{
|
||||
final L2PcInstance targetPlayer = (L2PcInstance) obj;
|
||||
final L2PcInstance targetPlayer = (L2PcInstance) target;
|
||||
|
||||
if (!(targetPlayer.isFestivalParticipant()))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -497,16 +496,16 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(new OnAttackableHate(getActiveChar(), target.getActingPlayer(), target.isSummon()), getActiveChar(), TerminateReturn.class);
|
||||
if ((term != null) && term.terminate())
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (npc.getHating(target) == 0)
|
||||
{
|
||||
npc.addDamageHate(target, 0, 0);
|
||||
npc.addDamageHate(target, 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Chose a target from its aggroList
|
||||
final L2Character hated = npc.isConfused() ? getAttackTarget() : npc.getMostHated();
|
||||
@ -696,12 +695,17 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Character originalAttackTarget = getAttackTarget();
|
||||
L2Character target = npc.getMostHated();
|
||||
if (getTarget() != target)
|
||||
{
|
||||
setTarget(target);
|
||||
}
|
||||
|
||||
// Check if target is dead or if timeout is expired to stop this attack
|
||||
if ((originalAttackTarget == null) || originalAttackTarget.isAlikeDead())
|
||||
if ((target == null) || target.isAlikeDead())
|
||||
{
|
||||
// Stop hating this target after the attack timeout or if target is dead
|
||||
npc.stopHating(originalAttackTarget);
|
||||
npc.stopHating(target);
|
||||
|
||||
// Set the AI Intention to AI_INTENTION_ACTIVE
|
||||
setIntention(AI_INTENTION_ACTIVE);
|
||||
@ -736,50 +740,49 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
// Go through all L2Object that belong to its faction
|
||||
try
|
||||
{
|
||||
for (L2Object obj : npc.getKnownList().getKnownCharactersInRadius(factionRange))
|
||||
final L2Character finalTarget = target;
|
||||
L2World.getInstance().forEachVisibleObjectInRange(npc, L2Npc.class, factionRange, called ->
|
||||
{
|
||||
if (obj instanceof L2Npc)
|
||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||
{
|
||||
final L2Npc called = (L2Npc) obj;
|
||||
|
||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the L2Object is inside the Faction Range of the actor
|
||||
if (called.hasAI())
|
||||
{
|
||||
if ((Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if the L2Object is inside the Faction Range of the actor
|
||||
if (called.hasAI() && (Math.abs(originalAttackTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().contains(originalAttackTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)) && (called.getInstanceId() == npc.getInstanceId()))
|
||||
{
|
||||
if (originalAttackTarget.isPlayable())
|
||||
if (finalTarget.isPlayable())
|
||||
{
|
||||
if (originalAttackTarget.isInParty() && originalAttackTarget.getParty().isInDimensionalRift())
|
||||
if (target.isInParty() && target.getParty().isInDimensionalRift())
|
||||
{
|
||||
final byte riftType = originalAttackTarget.getParty().getDimensionalRift().getType();
|
||||
final byte riftRoom = originalAttackTarget.getParty().getDimensionalRift().getCurrentRoom();
|
||||
final byte riftType = target.getParty().getDimensionalRift().getType();
|
||||
final byte riftRoom = target.getParty().getDimensionalRift().getCurrentRoom();
|
||||
|
||||
if ((npc instanceof L2RiftInvaderInstance) && !DimensionalRiftManager.getInstance().getRoom(riftType, riftRoom).checkIfInZone(npc.getX(), npc.getY(), npc.getZ()))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||
// Notify the AI with EVT_AGGRESSION
|
||||
called.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, originalAttackTarget, 1);
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnAttackableFactionCall(called, getActiveChar(), originalAttackTarget.getActingPlayer(), originalAttackTarget.isSummon()), called);
|
||||
called.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, finalTarget, 1);
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnAttackableFactionCall(called, getActiveChar(), finalTarget.getActingPlayer(), finalTarget.isSummon()), called);
|
||||
}
|
||||
else if ((called instanceof L2Attackable) && (getAttackTarget() != null) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ATTACK))
|
||||
else if (called.isAttackable() && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ATTACK))
|
||||
{
|
||||
((L2Attackable) called).addDamageHate(getAttackTarget(), 0, npc.getHating(getAttackTarget()));
|
||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, getAttackTarget());
|
||||
((L2Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
// _log.warning(getClass().getSimpleName() + ": There has been a problem trying to think the attack!");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": thinkAttack() faction call failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -818,9 +821,9 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
// around player without any sense, so decrease chance for now
|
||||
if (!npc.isMovementDisabled() && (Rnd.nextInt(100) <= 3))
|
||||
{
|
||||
for (L2Object nearby : npc.getKnownList().getKnownObjects().values())
|
||||
for (L2Attackable nearby : L2World.getInstance().getVisibleObjects(npc, L2Attackable.class))
|
||||
{
|
||||
if ((nearby instanceof L2Attackable) && npc.isInsideRadius(nearby, collision, false, false) && (nearby != mostHate))
|
||||
if (npc.isInsideRadius(nearby, collision, false, false) && (nearby != mostHate))
|
||||
{
|
||||
int newX = combinedCollision + Rnd.get(40);
|
||||
newX = Rnd.nextBoolean() ? mostHate.getX() + newX : mostHate.getX() - newX;
|
||||
@ -845,8 +848,8 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
int posX = npc.getX();
|
||||
int posY = npc.getY();
|
||||
final int posZ = npc.getZ() + 30;
|
||||
posX = originalAttackTarget.getX() < posX ? posX + 300 : posX - 300;
|
||||
posY = originalAttackTarget.getY() < posY ? posY + 300 : posY - 300;
|
||||
posX = target.getX() < posX ? posX + 300 : posX - 300;
|
||||
posY = target.getY() < posY ? posY + 300 : posY - 300;
|
||||
if (GeoEngine.getInstance().canMoveToTarget(npc.getX(), npc.getY(), npc.getZ(), posX, posY, posZ, npc.getInstanceId()))
|
||||
{
|
||||
setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(posX, posY, posZ, 0));
|
||||
@ -926,7 +929,6 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
if (GeoEngine.getInstance().canSeeTarget(npc, leader))
|
||||
{
|
||||
clientStopMoving(null);
|
||||
final L2Object target = npc.getTarget();
|
||||
npc.setTarget(leader);
|
||||
npc.doCast(healSkill);
|
||||
npc.setTarget(target);
|
||||
@ -946,7 +948,6 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
}
|
||||
|
||||
clientStopMoving(null);
|
||||
final L2Object target = npc.getTarget();
|
||||
npc.setTarget(npc);
|
||||
npc.doCast(sk);
|
||||
npc.setTarget(target);
|
||||
@ -964,25 +965,23 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
|
||||
if (sk.getTargetType() == L2TargetType.ONE)
|
||||
{
|
||||
for (L2Character obj : npc.getKnownList().getKnownCharactersInRadius(sk.getCastRange() + collision))
|
||||
for (L2Attackable targets : L2World.getInstance().getVisibleObjects(npc, L2Attackable.class, sk.getCastRange() + collision))
|
||||
{
|
||||
if (!(obj instanceof L2Attackable) || obj.isDead())
|
||||
if (targets.isDead())
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Attackable targets = (L2Attackable) obj;
|
||||
if (!targets.isInMyClan(npc))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
percentage = (targets.getCurrentHp() / targets.getMaxHp()) * 100;
|
||||
if ((Rnd.get(100) < ((100 - percentage) / 10)) && GeoEngine.getInstance().canSeeTarget(npc, targets))
|
||||
{
|
||||
clientStopMoving(null);
|
||||
final L2Object target = npc.getTarget();
|
||||
npc.setTarget(obj);
|
||||
npc.setTarget(targets);
|
||||
npc.doCast(sk);
|
||||
npc.setTarget(target);
|
||||
return;
|
||||
@ -1023,7 +1022,6 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
if (GeoEngine.getInstance().canSeeTarget(npc, leader))
|
||||
{
|
||||
clientStopMoving(null);
|
||||
final L2Object target = npc.getTarget();
|
||||
npc.setTarget(leader);
|
||||
npc.doCast(sk);
|
||||
npc.setTarget(target);
|
||||
@ -1041,14 +1039,13 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
}
|
||||
if (sk.getTargetType() == L2TargetType.ONE)
|
||||
{
|
||||
for (L2Character obj : npc.getKnownList().getKnownCharactersInRadius(sk.getCastRange() + collision))
|
||||
for (L2Attackable targets : L2World.getInstance().getVisibleObjects(npc, L2Attackable.class, sk.getCastRange() + collision))
|
||||
{
|
||||
if (!(obj instanceof L2Attackable) || !obj.isDead())
|
||||
if (!targets.isDead())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2Attackable targets = (L2Attackable) obj;
|
||||
if (!npc.isInMyClan(targets))
|
||||
{
|
||||
continue;
|
||||
@ -1056,8 +1053,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
if ((Rnd.get(100) < 10) && GeoEngine.getInstance().canSeeTarget(npc, targets))
|
||||
{
|
||||
clientStopMoving(null);
|
||||
final L2Object target = npc.getTarget();
|
||||
npc.setTarget(obj);
|
||||
npc.setTarget(targets);
|
||||
npc.doCast(sk);
|
||||
npc.setTarget(target);
|
||||
return;
|
||||
@ -1068,7 +1064,6 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
if (isParty(sk))
|
||||
{
|
||||
clientStopMoving(null);
|
||||
final L2Object target = npc.getTarget();
|
||||
npc.setTarget(npc);
|
||||
npc.doCast(sk);
|
||||
npc.setTarget(target);
|
||||
@ -1137,15 +1132,11 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Character target = getAttackTarget();
|
||||
if (target != null)
|
||||
if (target.isMoving())
|
||||
{
|
||||
if (target.isMoving())
|
||||
{
|
||||
range -= 100;
|
||||
}
|
||||
moveToPawn(target, Math.max(range, 5));
|
||||
range -= 100;
|
||||
}
|
||||
moveToPawn(target, Math.max(range, 5));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1317,21 +1308,20 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
|
||||
if (sk.getTargetType() == L2TargetType.ONE)
|
||||
{
|
||||
for (L2Character obj : caster.getKnownList().getKnownCharactersInRadius(sk.getCastRange() + caster.getTemplate().getCollisionRadius()))
|
||||
for (L2Attackable obj : L2World.getInstance().getVisibleObjects(caster, L2Attackable.class, sk.getCastRange() + caster.getTemplate().getCollisionRadius()))
|
||||
{
|
||||
if (!(obj instanceof L2Attackable) || obj.isDead())
|
||||
if (obj.isDead())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2Attackable targets = (L2Attackable) obj;
|
||||
if (!caster.isInMyClan(targets))
|
||||
if (!caster.isInMyClan(obj))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
percentage = (targets.getCurrentHp() / targets.getMaxHp()) * 100;
|
||||
if ((Rnd.get(100) < ((100 - percentage) / 10)) && GeoEngine.getInstance().canSeeTarget(caster, targets))
|
||||
percentage = (obj.getCurrentHp() / obj.getMaxHp()) * 100;
|
||||
if ((Rnd.get(100) < ((100 - percentage) / 10)) && GeoEngine.getInstance().canSeeTarget(caster, obj))
|
||||
{
|
||||
clientStopMoving(null);
|
||||
caster.setTarget(obj);
|
||||
@ -1343,14 +1333,9 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
}
|
||||
if (isParty(sk))
|
||||
{
|
||||
for (L2Character obj : caster.getKnownList().getKnownCharactersInRadius(sk.getAffectRange() + caster.getTemplate().getCollisionRadius()))
|
||||
for (L2Attackable obj : L2World.getInstance().getVisibleObjects(caster, L2Attackable.class, sk.getAffectRange() + caster.getTemplate().getCollisionRadius()))
|
||||
{
|
||||
if (!(obj instanceof L2Attackable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((L2Npc) obj).isInMyClan(caster) && (obj.getCurrentHp() < obj.getMaxHp()) && (Rnd.get(100) <= 20))
|
||||
if (obj.isInMyClan(caster) && (obj.getCurrentHp() < obj.getMaxHp()) && (Rnd.get(100) <= 20))
|
||||
{
|
||||
clientStopMoving(null);
|
||||
caster.setTarget(caster);
|
||||
@ -1487,20 +1472,19 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
for (L2Character obj : caster.getKnownList().getKnownCharactersInRadius(sk.getCastRange() + caster.getTemplate().getCollisionRadius()))
|
||||
for (L2Attackable obj : L2World.getInstance().getVisibleObjects(caster, L2Attackable.class, sk.getCastRange() + caster.getTemplate().getCollisionRadius()))
|
||||
{
|
||||
if (!(obj instanceof L2Attackable) || !obj.isDead())
|
||||
if (!obj.isDead())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2Attackable targets = (L2Attackable) obj;
|
||||
if (!caster.isInMyClan(targets))
|
||||
if (!caster.isInMyClan(obj))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((Rnd.get(100) < 10) && GeoEngine.getInstance().canSeeTarget(caster, targets))
|
||||
if ((Rnd.get(100) < 10) && GeoEngine.getInstance().canSeeTarget(caster, obj))
|
||||
{
|
||||
clientStopMoving(null);
|
||||
caster.setTarget(obj);
|
||||
@ -1512,7 +1496,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
}
|
||||
else if (isParty(sk))
|
||||
{
|
||||
for (L2Character obj : caster.getKnownList().getKnownCharactersInRadius(sk.getAffectRange() + caster.getTemplate().getCollisionRadius()))
|
||||
for (L2Character obj : L2World.getInstance().getVisibleObjects(caster, L2Character.class, sk.getAffectRange() + caster.getTemplate().getCollisionRadius()))
|
||||
{
|
||||
if (!(obj instanceof L2Attackable))
|
||||
{
|
||||
@ -1810,7 +1794,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// If there is nearby Target with aggro, start going on random target that is attackable
|
||||
for (L2Character obj : actor.getKnownList().getKnownCharactersInRadius(range))
|
||||
for (L2Character obj : L2World.getInstance().getVisibleObjects(actor, L2Character.class, range))
|
||||
{
|
||||
if (obj.isDead() || !GeoEngine.getInstance().canSeeTarget(actor, obj))
|
||||
{
|
||||
@ -1843,14 +1827,13 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
double dist = 0;
|
||||
double dist2 = 0;
|
||||
int range = 0;
|
||||
for (L2Character obj : actor.getKnownList().getKnownCharactersInRadius(range))
|
||||
for (L2Attackable targets : L2World.getInstance().getVisibleObjects(actor, L2Attackable.class, range))
|
||||
{
|
||||
if (!(obj instanceof L2Attackable) || obj.isDead() || !GeoEngine.getInstance().canSeeTarget(actor, obj))
|
||||
if (targets.isDead() || !GeoEngine.getInstance().canSeeTarget(actor, targets))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2Attackable targets = (L2Attackable) obj;
|
||||
if (targets.isInMyClan(actor))
|
||||
{
|
||||
continue;
|
||||
@ -1859,10 +1842,10 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
try
|
||||
{
|
||||
actor.setTarget(getAttackTarget());
|
||||
dist = actor.calculateDistance(obj, false, false);
|
||||
dist = actor.calculateDistance(targets, false, false);
|
||||
dist2 = dist - actor.getTemplate().getCollisionRadius();
|
||||
range = sk.getCastRange() + actor.getTemplate().getCollisionRadius() + obj.getTemplate().getCollisionRadius();
|
||||
if (obj.isMoving())
|
||||
range = sk.getCastRange() + actor.getTemplate().getCollisionRadius() + targets.getTemplate().getCollisionRadius();
|
||||
if (targets.isMoving())
|
||||
{
|
||||
dist2 = dist2 - 70;
|
||||
}
|
||||
@ -1871,9 +1854,9 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ((dist2 <= range) && !obj.isAffectedBySkill(sk.getId()))
|
||||
if ((dist2 <= range) && !targets.isAffectedBySkill(sk.getId()))
|
||||
{
|
||||
return obj;
|
||||
return targets;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1883,9 +1866,9 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
double dist = 0;
|
||||
double dist2 = 0;
|
||||
int range = sk.getCastRange() + actor.getTemplate().getCollisionRadius() + getAttackTarget().getTemplate().getCollisionRadius();
|
||||
for (L2Character obj : actor.getKnownList().getKnownCharactersInRadius(range))
|
||||
for (L2Character obj : L2World.getInstance().getVisibleObjects(actor, L2Character.class, range))
|
||||
{
|
||||
if ((obj == null) || obj.isDead() || !GeoEngine.getInstance().canSeeTarget(actor, obj))
|
||||
if (obj.isDead() || !GeoEngine.getInstance().canSeeTarget(actor, obj))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -1950,7 +1933,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
|
||||
if (!(actor instanceof L2GuardInstance))
|
||||
{
|
||||
for (L2Object target : actor.getKnownList().getKnownObjects().values())
|
||||
for (L2Object target : L2World.getInstance().getVisibleObjects(actor, L2Object.class))
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -2032,12 +2015,11 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
}
|
||||
if (!(actor instanceof L2GuardInstance))
|
||||
{
|
||||
for (L2Object target : actor.getKnownList().getKnownObjects().values())
|
||||
L2World.getInstance().forEachVisibleObject(actor, L2Character.class, obj ->
|
||||
{
|
||||
final L2Character obj = target instanceof L2Character ? (L2Character) target : null;
|
||||
if ((obj == null) || !GeoEngine.getInstance().canSeeTarget(actor, obj) || obj.isDead() || (obj != MostHate) || (obj == actor) || (obj == getAttackTarget()))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
if (obj instanceof L2PcInstance)
|
||||
{
|
||||
@ -2051,7 +2033,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
{
|
||||
if (((L2Attackable) obj).isInMyClan(actor))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
actor.addDamageHate(obj, 0, MostHate != null ? actor.getHating(MostHate) : 2000);
|
||||
actor.setTarget(obj);
|
||||
@ -2064,7 +2046,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
actor.setTarget(obj);
|
||||
setAttackTarget(obj);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -2106,17 +2088,11 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
|
||||
if (!(actor instanceof L2GuardInstance))
|
||||
{
|
||||
for (L2Object target : actor.getKnownList().getKnownObjects().values())
|
||||
L2World.getInstance().forEachVisibleObject(actor, L2Character.class, obj ->
|
||||
{
|
||||
L2Character obj = null;
|
||||
if (!(target instanceof L2Character))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
obj = (L2Character) target;
|
||||
if (!GeoEngine.getInstance().canSeeTarget(actor, obj) || obj.isDead() || (obj != MostHate) || (obj == actor))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
if (obj instanceof L2PcInstance)
|
||||
{
|
||||
@ -2130,7 +2106,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
{
|
||||
if (((L2Attackable) obj).isInMyClan(actor))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
actor.addDamageHate(obj, 0, MostHate != null ? actor.getHating(MostHate) : 2000);
|
||||
actor.setTarget(obj);
|
||||
@ -2143,7 +2119,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
|
||||
actor.setTarget(obj);
|
||||
setAttackTarget(obj);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ import com.l2jmobius.gameserver.enums.ItemLocation;
|
||||
import com.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||
import com.l2jmobius.gameserver.instancemanager.WalkingManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
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;
|
||||
@ -207,7 +208,7 @@ public class L2CharacterAI extends AbstractAI
|
||||
// This is only for mobs - town npcs are handled in their constructor
|
||||
if (_actor instanceof L2Attackable)
|
||||
{
|
||||
((L2Npc) _actor).startRandomAnimationTimer();
|
||||
((L2Npc) _actor).startRandomAnimationTask();
|
||||
}
|
||||
|
||||
// Launch the Think Event
|
||||
@ -1429,7 +1430,7 @@ public class L2CharacterAI extends AbstractAI
|
||||
{
|
||||
if ((sk.getTargetType() == L2TargetType.AURA) || (sk.getTargetType() == L2TargetType.BEHIND_AURA) || (sk.getTargetType() == L2TargetType.FRONT_AURA) || (sk.getTargetType() == L2TargetType.AURA_CORPSE_MOB))
|
||||
{
|
||||
for (L2Object target : _actor.getKnownList().getKnownCharactersInRadius(sk.getAffectRange()))
|
||||
for (L2Object target : L2World.getInstance().getVisibleObjects(_actor, L2Character.class, sk.getAffectRange()))
|
||||
{
|
||||
if (target == getAttackTarget())
|
||||
{
|
||||
@ -1447,7 +1448,7 @@ public class L2CharacterAI extends AbstractAI
|
||||
if ((sk.getTargetType() == L2TargetType.AURA) || (sk.getTargetType() == L2TargetType.BEHIND_AURA) || (sk.getTargetType() == L2TargetType.FRONT_AURA) || (sk.getTargetType() == L2TargetType.AURA_CORPSE_MOB))
|
||||
{
|
||||
boolean cancast = true;
|
||||
for (L2Character target : _actor.getKnownList().getKnownCharactersInRadius(sk.getAffectRange()))
|
||||
for (L2Character target : L2World.getInstance().getVisibleObjects(_actor, L2Character.class, sk.getAffectRange()))
|
||||
{
|
||||
if (!GeoEngine.getInstance().canSeeTarget(_actor, target) || ((target instanceof L2Attackable) && !((L2Npc) _actor).isChaos()))
|
||||
{
|
||||
@ -1466,7 +1467,7 @@ public class L2CharacterAI extends AbstractAI
|
||||
else if ((sk.getTargetType() == L2TargetType.AREA) || (sk.getTargetType() == L2TargetType.BEHIND_AREA) || (sk.getTargetType() == L2TargetType.FRONT_AREA))
|
||||
{
|
||||
boolean cancast = true;
|
||||
for (L2Character target : getAttackTarget().getKnownList().getKnownCharactersInRadius(sk.getAffectRange()))
|
||||
for (L2Character target : L2World.getInstance().getVisibleObjects(getAttackTarget(), L2Character.class, sk.getAffectRange()))
|
||||
{
|
||||
if (!GeoEngine.getInstance().canSeeTarget(_actor, target) || (target == null) || ((target instanceof L2Attackable) && !((L2Npc) _actor).isChaos()))
|
||||
{
|
||||
@ -1486,7 +1487,7 @@ public class L2CharacterAI extends AbstractAI
|
||||
else if ((sk.getTargetType() == L2TargetType.AURA) || (sk.getTargetType() == L2TargetType.BEHIND_AURA) || (sk.getTargetType() == L2TargetType.FRONT_AURA) || (sk.getTargetType() == L2TargetType.AURA_CORPSE_MOB))
|
||||
{
|
||||
boolean cancast = false;
|
||||
for (L2Character target : _actor.getKnownList().getKnownCharactersInRadius(sk.getAffectRange()))
|
||||
for (L2Character target : L2World.getInstance().getVisibleObjects(_actor, L2Character.class, sk.getAffectRange()))
|
||||
{
|
||||
if (!GeoEngine.getInstance().canSeeTarget(_actor, target) || ((target instanceof L2Attackable) && !((L2Npc) _actor).isChaos()))
|
||||
{
|
||||
@ -1505,7 +1506,7 @@ public class L2CharacterAI extends AbstractAI
|
||||
else if ((sk.getTargetType() == L2TargetType.AREA) || (sk.getTargetType() == L2TargetType.BEHIND_AREA) || (sk.getTargetType() == L2TargetType.FRONT_AREA))
|
||||
{
|
||||
boolean cancast = true;
|
||||
for (L2Character target : getAttackTarget().getKnownList().getKnownCharactersInRadius(sk.getAffectRange()))
|
||||
for (L2Character target : L2World.getInstance().getVisibleObjects(getAttackTarget(), L2Character.class, sk.getAffectRange()))
|
||||
{
|
||||
if (!GeoEngine.getInstance().canSeeTarget(_actor, target) || ((target instanceof L2Attackable) && !((L2Npc) _actor).isChaos()))
|
||||
{
|
||||
@ -1530,13 +1531,13 @@ public class L2CharacterAI extends AbstractAI
|
||||
{
|
||||
int count = 0;
|
||||
int ccount = 0;
|
||||
for (L2Character target : _actor.getKnownList().getKnownCharactersInRadius(sk.getAffectRange()))
|
||||
for (L2Attackable target : L2World.getInstance().getVisibleObjects(_actor, L2Attackable.class, sk.getAffectRange()))
|
||||
{
|
||||
if (!(target instanceof L2Attackable) || !GeoEngine.getInstance().canSeeTarget(_actor, target))
|
||||
if (!GeoEngine.getInstance().canSeeTarget(_actor, target))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (((L2Npc) target).isInMyClan((L2Npc) _actor))
|
||||
if (target.isInMyClan((L2Npc) _actor))
|
||||
{
|
||||
count++;
|
||||
if (target.isAffectedBySkill(sk.getId()))
|
||||
|
@ -19,11 +19,11 @@ package com.l2jmobius.gameserver.ai;
|
||||
import static com.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
||||
import static com.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.MobGroup;
|
||||
import com.l2jmobius.gameserver.model.MobGroupTable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Attackable;
|
||||
@ -285,22 +285,17 @@ public final class L2ControllableMobAI extends L2AttackableAI
|
||||
// notify aggression
|
||||
if (((L2Npc) _actor).getTemplate().getClans() != null)
|
||||
{
|
||||
for (L2Object obj : _actor.getKnownList().getKnownObjects().values())
|
||||
L2World.getInstance().forEachVisibleObject(_actor, L2Npc.class, npc ->
|
||||
{
|
||||
if (!(obj instanceof L2Npc))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final L2Npc npc = (L2Npc) obj;
|
||||
if (!npc.isInMyClan((L2Npc) _actor))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
if (_actor.isInsideRadius(npc, npc.getTemplate().getClanHelpRange(), false, true) && (Math.abs(getAttackTarget().getZ() - npc.getZ()) < 200))
|
||||
if (_actor.isInsideRadius(npc, npc.getTemplate().getClanHelpRange(), true, true))
|
||||
{
|
||||
npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, getAttackTarget(), 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_actor.setTarget(getAttackTarget());
|
||||
@ -416,8 +411,17 @@ public final class L2ControllableMobAI extends L2AttackableAI
|
||||
|
||||
private L2Character findNextRndTarget()
|
||||
{
|
||||
final List<L2Character> potentialTarget = _actor.getKnownList().getKnownCharactersInRadius(getActiveChar().getAggroRange()).stream().filter(this::checkAutoAttackCondition).collect(Collectors.toList());
|
||||
return potentialTarget.isEmpty() ? null : potentialTarget.get(Rnd.nextInt(potentialTarget.size()));
|
||||
final List<L2Character> potentialTarget = new ArrayList<>();
|
||||
L2World.getInstance().forEachVisibleObject(_actor, L2Character.class, target ->
|
||||
{
|
||||
if (Util.checkIfInShortRange(((L2Attackable) _actor).getAggroRange(), _actor, target, true) && checkAutoAttackCondition(target))
|
||||
{
|
||||
potentialTarget.add(target);
|
||||
}
|
||||
});
|
||||
|
||||
return !potentialTarget.isEmpty() ? potentialTarget.get(Rnd.nextInt(potentialTarget.size())) : null;
|
||||
|
||||
}
|
||||
|
||||
private L2ControllableMobInstance findNextGroupTarget()
|
||||
|
@ -18,6 +18,7 @@ package com.l2jmobius.gameserver.ai;
|
||||
|
||||
import com.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
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.instance.L2DefenderInstance;
|
||||
@ -164,13 +165,13 @@ public class L2DoorAI extends L2CharacterAI
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for (L2DefenderInstance guard : _door.getKnownDefenders())
|
||||
L2World.getInstance().forEachVisibleObject(_door, L2DefenderInstance.class, guard ->
|
||||
{
|
||||
if (_actor.isInsideRadius(guard, guard.getTemplate().getClanHelpRange(), false, true) && (Math.abs(_attacker.getZ() - guard.getZ()) < 200))
|
||||
if (_actor.isInsideRadius(guard, guard.getTemplate().getClanHelpRange(), true, true))
|
||||
{
|
||||
guard.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, _attacker, 15);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.GameTimeController;
|
||||
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;
|
||||
@ -171,7 +172,17 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
|
||||
// Check if actor is not dead
|
||||
if (!_actor.isAlikeDead())
|
||||
{
|
||||
intention = ((L2Attackable) _actor).getKnownList().getKnownPlayers().isEmpty() ? AI_INTENTION_IDLE : AI_INTENTION_ACTIVE;
|
||||
L2Attackable npc = (L2Attackable) _actor;
|
||||
|
||||
// If its _knownPlayer isn't empty set the Intention to AI_INTENTION_ACTIVE
|
||||
if (!L2World.getInstance().getVisibleObjects(npc, L2PcInstance.class).isEmpty())
|
||||
{
|
||||
intention = AI_INTENTION_ACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
intention = AI_INTENTION_IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
if (intention == AI_INTENTION_IDLE)
|
||||
@ -248,17 +259,13 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
|
||||
// A L2Attackable isn't aggressive during 10s after its spawn because _globalAggro is set to -10
|
||||
if (_globalAggro >= 0)
|
||||
{
|
||||
for (L2Character target : npc.getKnownList().getKnownCharactersInRadius(_attackRange))
|
||||
L2World.getInstance().forEachVisibleObjectInRange(npc, L2Character.class, _attackRange, target ->
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (autoAttackCondition(target) && (npc.getHating(target) == 0)) // check aggression
|
||||
{
|
||||
npc.addDamageHate(target, 0, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Chose a target from its aggroList
|
||||
final L2Character hated = _actor.isConfused() ? getAttackTarget() : npc.getMostHated();
|
||||
@ -346,12 +353,8 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
|
||||
|
||||
// Go through all L2Character that belong to its faction
|
||||
// for (L2Character cha : _actor.getKnownList().getKnownCharactersInRadius(((L2NpcInstance) _actor).getFactionRange()+_actor.getTemplate().collisionRadius))
|
||||
for (L2Character cha : _actor.getKnownList().getKnownCharactersInRadius(1000))
|
||||
for (L2Character cha : L2World.getInstance().getVisibleObjects(_actor, L2Character.class, 1000))
|
||||
{
|
||||
if (cha == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!(cha instanceof L2Npc))
|
||||
{
|
||||
if (_selfAnalysis.hasHealOrResurrect && (cha instanceof L2PcInstance) && ((L2Npc) _actor).getFort().getSiege().checkIsDefender(((L2PcInstance) cha).getClan())//
|
||||
@ -503,10 +506,9 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
|
||||
}
|
||||
|
||||
// Check if the L2SiegeGuardInstance is attacking, knows the target and can't run
|
||||
if (!_actor.isAttackingNow() && (_actor.getRunSpeed() == 0) && _actor.getKnownList().knowsObject(attackTarget))
|
||||
if (!(_actor.isAttackingNow()) && (_actor.getRunSpeed() == 0) && (_actor.isInSurroundingRegion(attackTarget)))
|
||||
{
|
||||
// Cancel the target
|
||||
_actor.getKnownList().removeKnownObject(attackTarget);
|
||||
_actor.setTarget(null);
|
||||
setIntention(AI_INTENTION_IDLE, null, null);
|
||||
}
|
||||
@ -519,10 +521,10 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
|
||||
final double homeY = attackTarget.getY() - sGuard.getSpawn().getY();
|
||||
|
||||
// Check if the L2SiegeGuardInstance isn't too far from it's home location
|
||||
if ((((dx * dx) + (dy * dy)) > 10000) && (((homeX * homeX) + (homeY * homeY)) > 3240000) && _actor.getKnownList().knowsObject(attackTarget))
|
||||
if ((((dx * dx) + (dy * dy)) > 10000) && (((homeX * homeX) + (homeY * homeY)) > 3240000) // 1800 * 1800
|
||||
&& (_actor.isInSurroundingRegion(attackTarget)))
|
||||
{
|
||||
// Cancel the target
|
||||
_actor.getKnownList().removeKnownObject(attackTarget);
|
||||
_actor.setTarget(null);
|
||||
setIntention(AI_INTENTION_IDLE, null, null);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.GameTimeController;
|
||||
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;
|
||||
@ -169,7 +170,17 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
|
||||
// Check if actor is not dead
|
||||
if (!_actor.isAlikeDead())
|
||||
{
|
||||
intention = ((L2Attackable) _actor).getKnownList().getKnownPlayers().isEmpty() ? AI_INTENTION_IDLE : AI_INTENTION_ACTIVE;
|
||||
L2Attackable npc = (L2Attackable) _actor;
|
||||
|
||||
// If its _knownPlayer isn't empty set the Intention to AI_INTENTION_ACTIVE
|
||||
if (!L2World.getInstance().getVisibleObjects(npc, L2PcInstance.class).isEmpty())
|
||||
{
|
||||
intention = AI_INTENTION_ACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
intention = AI_INTENTION_IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
if (intention == AI_INTENTION_IDLE)
|
||||
@ -246,17 +257,13 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
|
||||
// A L2Attackable isn't aggressive during 10s after its spawn because _globalAggro is set to -10
|
||||
if (_globalAggro >= 0)
|
||||
{
|
||||
for (L2Character target : npc.getKnownList().getKnownCharactersInRadius(_attackRange))
|
||||
L2World.getInstance().forEachVisibleObjectInRange(npc, L2Character.class, _attackRange, target ->
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (autoAttackCondition(target) && (npc.getHating(target) == 0)) // check aggression
|
||||
{
|
||||
npc.addDamageHate(target, 0, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Chose a target from its aggroList
|
||||
final L2Character hated = _actor.isConfused() ? getAttackTarget() : npc.getMostHated();
|
||||
@ -344,12 +351,8 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
|
||||
|
||||
// Go through all L2Character that belong to its faction
|
||||
// for (L2Character cha : _actor.getKnownList().getKnownCharactersInRadius(((L2NpcInstance) _actor).getFactionRange()+_actor.getTemplate().collisionRadius))
|
||||
for (L2Character cha : _actor.getKnownList().getKnownCharactersInRadius(1000))
|
||||
for (L2Character cha : L2World.getInstance().getVisibleObjects(_actor, L2Character.class, 1000))
|
||||
{
|
||||
if (cha == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!(cha instanceof L2Npc))
|
||||
{
|
||||
if (_selfAnalysis.hasHealOrResurrect && (cha instanceof L2PcInstance) && (((L2Npc) _actor).getCastle().getSiege().checkIsDefender(((L2PcInstance) cha).getClan()))//
|
||||
@ -512,10 +515,9 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
|
||||
}
|
||||
|
||||
// Check if the L2SiegeGuardInstance is attacking, knows the target and can't run
|
||||
if (!_actor.isAttackingNow() && (_actor.getRunSpeed() == 0) && _actor.getKnownList().knowsObject(attackTarget))
|
||||
if (!(_actor.isAttackingNow()) && (_actor.getRunSpeed() == 0) && (_actor.isInSurroundingRegion(attackTarget)))
|
||||
{
|
||||
// Cancel the target
|
||||
_actor.getKnownList().removeKnownObject(attackTarget);
|
||||
_actor.setTarget(null);
|
||||
setIntention(AI_INTENTION_IDLE, null, null);
|
||||
}
|
||||
@ -528,10 +530,10 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
|
||||
final double homeY = attackTarget.getY() - sGuard.getSpawn().getY();
|
||||
|
||||
// Check if the L2SiegeGuardInstance isn't too far from it's home location
|
||||
if ((((dx * dx) + (dy * dy)) > 10000) && (((homeX * homeX) + (homeY * homeY)) > 3240000) && _actor.getKnownList().knowsObject(attackTarget))
|
||||
if ((((dx * dx) + (dy * dy)) > 10000) && (((homeX * homeX) + (homeY * homeY)) > 3240000) // 1800 * 1800
|
||||
&& (_actor.isInSurroundingRegion(attackTarget)))
|
||||
{
|
||||
// Cancel the target
|
||||
_actor.getKnownList().removeKnownObject(attackTarget);
|
||||
_actor.setTarget(null);
|
||||
setIntention(AI_INTENTION_IDLE, null, null);
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ public class DoorData implements IGameXmlReader
|
||||
for (L2DoorInstance doorInst : allDoors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.getOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public class AirShipManager
|
||||
public boolean hasAirShip(int ownerId)
|
||||
{
|
||||
final L2AirShipInstance ship = _airShips.get(ownerId);
|
||||
return (ship != null) && (ship.isVisible() || ship.isTeleporting());
|
||||
return (ship != null) && (ship.isSpawned() || ship.isTeleporting());
|
||||
}
|
||||
|
||||
public void registerAirShipTeleportList(int dockId, int locationId, VehiclePathPoint[][] tp, int[] fuelConsumption)
|
||||
|
@ -230,7 +230,7 @@ public final class DayNightSpawnManager
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (!boss.isVisible())
|
||||
if (!boss.isSpawned())
|
||||
{
|
||||
boss.spawnMe();
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ public final class ItemsOnGroundManager implements Runnable
|
||||
final long dropTime = rs.getLong(8);
|
||||
item.setDropTime(dropTime);
|
||||
item.setProtected(dropTime == -1);
|
||||
item.setIsVisible(true);
|
||||
item.setSpawned(true);
|
||||
L2World.getInstance().addVisibleObject(item, item.getWorldRegion());
|
||||
_items.add(item);
|
||||
count++;
|
||||
|
@ -981,7 +981,7 @@ public final class TerritoryWarManager implements Siegable
|
||||
{
|
||||
if ((ward.getNpc() != null) && (t.getOwnerClan() != null))
|
||||
{
|
||||
if (!ward.getNpc().isVisible())
|
||||
if (!ward.getNpc().isSpawned())
|
||||
{
|
||||
ward.setNPC(ward.getNpc().getSpawn().doSpawn());
|
||||
}
|
||||
@ -1091,11 +1091,11 @@ public final class TerritoryWarManager implements Siegable
|
||||
{
|
||||
if (ward.getNpc() != null)
|
||||
{
|
||||
if (!ward.getNpc().isVisible() && SPAWN_WARDS_WHEN_TW_IS_NOT_IN_PROGRESS)
|
||||
if (!ward.getNpc().isSpawned() && SPAWN_WARDS_WHEN_TW_IS_NOT_IN_PROGRESS)
|
||||
{
|
||||
ward.setNPC(ward.getNpc().getSpawn().doSpawn());
|
||||
}
|
||||
else if (ward.getNpc().isVisible() && !SPAWN_WARDS_WHEN_TW_IS_NOT_IN_PROGRESS)
|
||||
else if (ward.getNpc().isSpawned() && !SPAWN_WARDS_WHEN_TW_IS_NOT_IN_PROGRESS)
|
||||
{
|
||||
ward.getNpc().decayMe();
|
||||
}
|
||||
|
@ -272,8 +272,6 @@ public final class WalkingManager implements IGameXmlReader
|
||||
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, node);
|
||||
walk.setWalkCheckTask(ThreadPool.scheduleAtFixedRate(new StartMovingTask(npc, routeName), 60000, 60000)); // start walk check task, for resuming walk after fight
|
||||
|
||||
npc.getKnownList().startTrackingTask();
|
||||
|
||||
_activeRoutes.put(npc.getObjectId(), walk); // register route
|
||||
}
|
||||
else
|
||||
@ -325,7 +323,6 @@ public final class WalkingManager implements IGameXmlReader
|
||||
return;
|
||||
}
|
||||
walk.getWalkCheckTask().cancel(true);
|
||||
npc.getKnownList().stopTrackingTask();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,9 +21,13 @@ import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
@ -32,13 +36,14 @@ import org.w3c.dom.Node;
|
||||
import com.l2jmobius.commons.util.IGameXmlReader;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.L2WorldRegion;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.interfaces.ILocational;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
||||
import com.l2jmobius.gameserver.model.zone.L2ZoneForm;
|
||||
import com.l2jmobius.gameserver.model.zone.L2ZoneRespawn;
|
||||
import com.l2jmobius.gameserver.model.zone.L2ZoneType;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneRegion;
|
||||
import com.l2jmobius.gameserver.model.zone.form.ZoneCuboid;
|
||||
import com.l2jmobius.gameserver.model.zone.form.ZoneCylinder;
|
||||
import com.l2jmobius.gameserver.model.zone.form.ZoneNPoly;
|
||||
@ -53,18 +58,35 @@ import com.l2jmobius.gameserver.model.zone.type.NpcSpawnTerritory;
|
||||
*/
|
||||
public final class ZoneManager implements IGameXmlReader
|
||||
{
|
||||
private static final Map<String, AbstractZoneSettings> _settings = new HashMap<>();
|
||||
private static final Logger LOGGER = Logger.getLogger(ZoneManager.class.getName());
|
||||
|
||||
private static final Map<String, AbstractZoneSettings> SETTINGS = new HashMap<>();
|
||||
|
||||
public static final int SHIFT_BY = 15;
|
||||
public static final int OFFSET_X = Math.abs(L2World.MAP_MIN_X >> SHIFT_BY);
|
||||
public static final int OFFSET_Y = Math.abs(L2World.MAP_MIN_Y >> SHIFT_BY);
|
||||
|
||||
private final Map<Class<? extends L2ZoneType>, Map<Integer, ? extends L2ZoneType>> _classZones = new HashMap<>();
|
||||
private final Map<String, NpcSpawnTerritory> _spawnTerritories = new HashMap<>();
|
||||
private int _lastDynamicId = 300000;
|
||||
private List<L2ItemInstance> _debugItems;
|
||||
|
||||
private final ZoneRegion[][] _zoneRegions = new ZoneRegion[(L2World.MAP_MAX_X >> SHIFT_BY) + OFFSET_X + 1][(L2World.MAP_MAX_Y >> SHIFT_BY) + OFFSET_Y + 1];
|
||||
|
||||
/**
|
||||
* Instantiates a new zone manager.
|
||||
*/
|
||||
protected ZoneManager()
|
||||
{
|
||||
for (int x = 0; x < _zoneRegions.length; x++)
|
||||
{
|
||||
for (int y = 0; y < _zoneRegions[x].length; y++)
|
||||
{
|
||||
_zoneRegions[x][y] = new ZoneRegion(x, y);
|
||||
}
|
||||
}
|
||||
LOGGER.info(getClass().getSimpleName() + " " + _zoneRegions.length + " by " + _zoneRegions[0].length + " Zone Region Grid set up.");
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
@ -75,7 +97,6 @@ public final class ZoneManager implements IGameXmlReader
|
||||
{
|
||||
// Get the world regions
|
||||
int count = 0;
|
||||
final L2WorldRegion[][] worldRegions = L2World.getInstance().getWorldRegions();
|
||||
|
||||
// Backup old zone settings
|
||||
for (Map<Integer, ? extends L2ZoneType> map : _classZones.values())
|
||||
@ -84,17 +105,17 @@ public final class ZoneManager implements IGameXmlReader
|
||||
{
|
||||
if (zone.getSettings() != null)
|
||||
{
|
||||
_settings.put(zone.getName(), zone.getSettings());
|
||||
SETTINGS.put(zone.getName(), zone.getSettings());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clear zones
|
||||
for (L2WorldRegion[] worldRegion : worldRegions)
|
||||
for (ZoneRegion[] zoneRegions : _zoneRegions)
|
||||
{
|
||||
for (L2WorldRegion element : worldRegion)
|
||||
for (ZoneRegion zoneRegion : zoneRegions)
|
||||
{
|
||||
element.getZones().clear();
|
||||
zoneRegion.getZones().clear();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@ -112,14 +133,13 @@ public final class ZoneManager implements IGameXmlReader
|
||||
((L2Character) obj).revalidateZone(true);
|
||||
}
|
||||
}
|
||||
_settings.clear();
|
||||
|
||||
SETTINGS.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
// Get the world regions
|
||||
final L2WorldRegion[][] worldRegions = L2World.getInstance().getWorldRegions();
|
||||
NamedNodeMap attrs;
|
||||
Node attribute;
|
||||
String zoneName;
|
||||
@ -232,7 +252,7 @@ public final class ZoneManager implements IGameXmlReader
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": ZoneData: Missing cuboid vertex in sql data for zone: " + zoneId + " in file: " + f.getName());
|
||||
LOGGER.warning(getClass().getSimpleName() + ": ZoneData: Missing cuboid vertex data for zone: " + zoneId + " in file: " + f.getName());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -348,21 +368,22 @@ public final class ZoneManager implements IGameXmlReader
|
||||
|
||||
addZone(zoneId, temp);
|
||||
|
||||
// Register the zone into any world region it intersects with...
|
||||
// Register the zone into any world region it
|
||||
// intersects with...
|
||||
// currently 11136 test for each zone :>
|
||||
int ax, ay, bx, by;
|
||||
for (int x = 0; x < worldRegions.length; x++)
|
||||
for (int x = 0; x < _zoneRegions.length; x++)
|
||||
{
|
||||
for (int y = 0; y < worldRegions[x].length; y++)
|
||||
for (int y = 0; y < _zoneRegions[x].length; y++)
|
||||
{
|
||||
ax = (x - L2World.OFFSET_X) << L2World.SHIFT_BY;
|
||||
bx = ((x + 1) - L2World.OFFSET_X) << L2World.SHIFT_BY;
|
||||
ay = (y - L2World.OFFSET_Y) << L2World.SHIFT_BY;
|
||||
by = ((y + 1) - L2World.OFFSET_Y) << L2World.SHIFT_BY;
|
||||
|
||||
final int ax = (x - OFFSET_X) << SHIFT_BY;
|
||||
final int bx = ((x + 1) - OFFSET_X) << SHIFT_BY;
|
||||
final int ay = (y - OFFSET_Y) << SHIFT_BY;
|
||||
final int by = ((y + 1) - OFFSET_Y) << SHIFT_BY;
|
||||
|
||||
if (temp.getZone().intersectsRectangle(ax, bx, ay, by))
|
||||
{
|
||||
worldRegions[x][y].addZone(temp);
|
||||
_zoneRegions[x][y].getZones().put(temp.getId(), temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -381,6 +402,8 @@ public final class ZoneManager implements IGameXmlReader
|
||||
parseDatapackDirectory("data/zones/spawnZones", false);
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _classZones.size() + " zone classes and " + getSize() + " zones.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _spawnTerritories.size() + " NPC spawn territoriers.");
|
||||
final OptionalInt maxId = _classZones.values().stream().flatMap(map -> map.keySet().stream()).mapToInt(Integer.class::cast).filter(value -> value < 300000).max();
|
||||
LOGGER.info(getClass().getSimpleName() + ": Last static id: " + maxId.getAsInt());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -441,16 +464,16 @@ public final class ZoneManager implements IGameXmlReader
|
||||
* @return zones
|
||||
* @see #getAllZones(Class)
|
||||
*/
|
||||
@Deprecated
|
||||
public Collection<L2ZoneType> getAllZones()
|
||||
{
|
||||
final List<L2ZoneType> zones = new ArrayList<>();
|
||||
for (Map<Integer, ? extends L2ZoneType> map : _classZones.values())
|
||||
{
|
||||
zones.addAll(map.values());
|
||||
}
|
||||
return zones;
|
||||
}
|
||||
// @Deprecated
|
||||
// public Collection<L2ZoneType> getAllZones()
|
||||
// {
|
||||
// final List<L2ZoneType> zones = new ArrayList<>();
|
||||
// for (Map<Integer, ? extends L2ZoneType> map : _classZones.values())
|
||||
// {
|
||||
// zones.addAll(map.values());
|
||||
// }
|
||||
// return zones;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Return all zones by class type.
|
||||
@ -482,6 +505,24 @@ public final class ZoneManager implements IGameXmlReader
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get zone by name.
|
||||
* @param name the zone name
|
||||
* @return the zone by name
|
||||
*/
|
||||
public L2ZoneType getZoneByName(String name)
|
||||
{
|
||||
for (Map<Integer, ? extends L2ZoneType> map : _classZones.values())
|
||||
{
|
||||
final Optional<? extends L2ZoneType> zoneType = map.values().stream().filter(z -> (z.getName() != null) && z.getName().equals(name)).findAny();
|
||||
if (zoneType.isPresent())
|
||||
{
|
||||
return zoneType.get();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get zone by ID and zone class.
|
||||
* @param <T> the generic type
|
||||
@ -495,30 +536,48 @@ public final class ZoneManager implements IGameXmlReader
|
||||
return (T) _classZones.get(zoneType).get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get zone by name.
|
||||
* @param <T> the generic type
|
||||
* @param name the zone name
|
||||
* @param zoneType the zone type
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends L2ZoneType> T getZoneByName(String name, Class<T> zoneType)
|
||||
{
|
||||
final Optional<? extends L2ZoneType> zone = _classZones.get(zoneType).values().stream().filter(z -> (z.getName() != null) && z.getName().equals(name)).findAny();
|
||||
if (zone.isPresent())
|
||||
{
|
||||
return (T) zone.get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all zones from where the object is located.
|
||||
* @param object the object
|
||||
* @param locational the locational
|
||||
* @return zones
|
||||
*/
|
||||
public List<L2ZoneType> getZones(L2Object object)
|
||||
public List<L2ZoneType> getZones(ILocational locational)
|
||||
{
|
||||
return getZones(object.getX(), object.getY(), object.getZ());
|
||||
return getZones(locational.getX(), locational.getY(), locational.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the zone.
|
||||
* @param <T> the generic type
|
||||
* @param object the object
|
||||
* @param locational the locational
|
||||
* @param type the type
|
||||
* @return zone from where the object is located by type
|
||||
*/
|
||||
public <T extends L2ZoneType> T getZone(L2Object object, Class<T> type)
|
||||
public <T extends L2ZoneType> T getZone(ILocational locational, Class<T> type)
|
||||
{
|
||||
if (object != null)
|
||||
if (locational == null)
|
||||
{
|
||||
return getZone(object.getX(), object.getY(), object.getZ(), type);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
return getZone(locational.getX(), locational.getY(), locational.getZ(), type);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -529,9 +588,8 @@ public final class ZoneManager implements IGameXmlReader
|
||||
*/
|
||||
public List<L2ZoneType> getZones(int x, int y)
|
||||
{
|
||||
final L2WorldRegion region = L2World.getInstance().getRegion(x, y);
|
||||
final List<L2ZoneType> temp = new ArrayList<>();
|
||||
for (L2ZoneType zone : region.getZones())
|
||||
for (L2ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
if (zone.isInsideZone(x, y))
|
||||
{
|
||||
@ -550,9 +608,8 @@ public final class ZoneManager implements IGameXmlReader
|
||||
*/
|
||||
public List<L2ZoneType> getZones(int x, int y, int z)
|
||||
{
|
||||
final L2WorldRegion region = L2World.getInstance().getRegion(x, y);
|
||||
final List<L2ZoneType> temp = new ArrayList<>();
|
||||
for (L2ZoneType zone : region.getZones())
|
||||
for (L2ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
if (zone.isInsideZone(x, y, z))
|
||||
{
|
||||
@ -574,8 +631,7 @@ public final class ZoneManager implements IGameXmlReader
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends L2ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
final L2WorldRegion region = L2World.getInstance().getRegion(x, y);
|
||||
for (L2ZoneType zone : region.getZones())
|
||||
for (L2ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
if (zone.isInsideZone(x, y, z) && type.isInstance(zone))
|
||||
{
|
||||
@ -706,17 +762,37 @@ public final class ZoneManager implements IGameXmlReader
|
||||
{
|
||||
if (_debugItems != null)
|
||||
{
|
||||
for (L2ItemInstance item : _debugItems)
|
||||
final Iterator<L2ItemInstance> it = _debugItems.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
final L2ItemInstance item = it.next();
|
||||
if (item != null)
|
||||
{
|
||||
item.decayMe();
|
||||
}
|
||||
_debugItems.remove(item);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ZoneRegion getRegion(int x, int y)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _zoneRegions[(x >> SHIFT_BY) + OFFSET_X][(y >> SHIFT_BY) + OFFSET_Y];
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e)
|
||||
{
|
||||
// LOGGER.warning(getClass().getSimpleName() + ": Incorrect zone region X: " + ((x >> SHIFT_BY) + OFFSET_X) + " Y: " + ((y >> SHIFT_BY) + OFFSET_Y) + " for coordinates x: " + x + " y: " + y);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ZoneRegion getRegion(ILocational point)
|
||||
{
|
||||
return getRegion(point.getX(), point.getY());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the settings.
|
||||
* @param name the name
|
||||
@ -724,7 +800,7 @@ public final class ZoneManager implements IGameXmlReader
|
||||
*/
|
||||
public static AbstractZoneSettings getSettings(String name)
|
||||
{
|
||||
return _settings.get(name);
|
||||
return SETTINGS.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,7 +44,7 @@ public final class AggroInfo
|
||||
|
||||
public int checkHate(L2Character owner)
|
||||
{
|
||||
if (_attacker.isAlikeDead() || !_attacker.isVisible() || !owner.getKnownList().knowsObject(_attacker))
|
||||
if (_attacker.isAlikeDead() || !_attacker.isSpawned() || !owner.isInSurroundingRegion(_attacker))
|
||||
{
|
||||
_hate = 0;
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ import com.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||
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.actor.knownlist.ObjectKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.poly.ObjectPoly;
|
||||
import com.l2jmobius.gameserver.model.entity.Instance;
|
||||
import com.l2jmobius.gameserver.model.events.ListenersContainer;
|
||||
@ -63,7 +62,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
private L2WorldRegion _worldRegion;
|
||||
/** Instance type */
|
||||
private InstanceType _instanceType = null;
|
||||
private volatile Map<String, Object> _scripts = new ConcurrentHashMap<>();
|
||||
private volatile Map<String, Object> _scripts;
|
||||
/** X coordinate */
|
||||
private final AtomicInteger _x = new AtomicInteger(0);
|
||||
/** Y coordinate */
|
||||
@ -74,15 +73,13 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
private final AtomicInteger _heading = new AtomicInteger(0);
|
||||
/** Instance id of object. 0 - Global */
|
||||
private final AtomicInteger _instanceId = new AtomicInteger(0);
|
||||
private boolean _isVisible;
|
||||
private boolean _isSpawned;
|
||||
private boolean _isInvisible;
|
||||
private ObjectKnownList _knownList;
|
||||
|
||||
public L2Object(int objectId)
|
||||
{
|
||||
setInstanceType(InstanceType.L2Object);
|
||||
_objectId = objectId;
|
||||
initKnownList();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,27 +144,21 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
|
||||
public void onSpawn()
|
||||
{
|
||||
broadcastInfo(); // Tempfix for invisible spawns.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean decayMe()
|
||||
{
|
||||
assert getWorldRegion() != null;
|
||||
|
||||
final L2WorldRegion reg = getWorldRegion();
|
||||
|
||||
synchronized (this)
|
||||
{
|
||||
_isVisible = false;
|
||||
_isSpawned = false;
|
||||
setWorldRegion(null);
|
||||
}
|
||||
|
||||
// this can synchronize on others instances, so it's out of
|
||||
// synchronized, to avoid deadlocks
|
||||
// Remove the L2Object from the world
|
||||
L2World.getInstance().removeVisibleObject(this, reg);
|
||||
L2World.getInstance().removeObject(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -181,12 +172,10 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
@Override
|
||||
public final boolean spawnMe()
|
||||
{
|
||||
assert (getWorldRegion() == null) && (getLocation().getX() != 0) && (getLocation().getY() != 0) && (getLocation().getZ() != 0);
|
||||
|
||||
synchronized (this)
|
||||
{
|
||||
// Set the x,y,z position of the L2Object spawn and update its _worldregion
|
||||
_isVisible = true;
|
||||
_isSpawned = true;
|
||||
setWorldRegion(L2World.getInstance().getRegion(getLocation()));
|
||||
|
||||
// Add the L2Object spawn in the _allobjects of L2World
|
||||
@ -207,13 +196,8 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
|
||||
public final void spawnMe(int x, int y, int z)
|
||||
{
|
||||
assert getWorldRegion() == null;
|
||||
|
||||
synchronized (this)
|
||||
{
|
||||
// Set the x,y,z position of the L2Object spawn and update its _worldregion
|
||||
_isVisible = true;
|
||||
|
||||
if (x > L2World.MAP_MAX_X)
|
||||
{
|
||||
x = L2World.MAP_MAX_X - 5000;
|
||||
@ -230,25 +214,21 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
{
|
||||
y = L2World.MAP_MIN_Y + 5000;
|
||||
}
|
||||
if (z > L2World.MAP_MAX_Z)
|
||||
{
|
||||
z = L2World.MAP_MAX_Z - 1000;
|
||||
}
|
||||
if (z < L2World.MAP_MIN_Z)
|
||||
{
|
||||
z = L2World.MAP_MIN_Z + 1000;
|
||||
}
|
||||
|
||||
// Set the x,y,z position of the WorldObject. If flagged with _isSpawned, setXYZ will automatically update world region, so avoid that.
|
||||
setXYZ(x, y, z);
|
||||
setWorldRegion(L2World.getInstance().getRegion(getLocation()));
|
||||
|
||||
// Add the L2Object spawn in the _allobjects of L2World
|
||||
}
|
||||
|
||||
L2World.getInstance().addObject(this);
|
||||
|
||||
// these can synchronize on others instances, so they're out of
|
||||
// synchronized, to avoid deadlocks
|
||||
|
||||
// Add the L2Object spawn to _visibleObjects and if necessary to _allplayers of its L2WorldRegion
|
||||
getWorldRegion().addVisibleObject(this);
|
||||
|
||||
// Add the L2Object spawn in the world as a visible object
|
||||
L2World.getInstance().addVisibleObject(this, getWorldRegion());
|
||||
|
||||
onSpawn();
|
||||
// Spawn and update its _worldregion
|
||||
spawnMe();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -262,47 +242,20 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
|
||||
public abstract boolean isAutoAttackable(L2Character attacker);
|
||||
|
||||
public final boolean isVisible()
|
||||
public final boolean isSpawned()
|
||||
{
|
||||
return getWorldRegion() != null;
|
||||
}
|
||||
|
||||
public final void setIsVisible(boolean value)
|
||||
public final void setSpawned(boolean value)
|
||||
{
|
||||
_isVisible = value;
|
||||
if (!_isVisible)
|
||||
_isSpawned = value;
|
||||
if (!_isSpawned)
|
||||
{
|
||||
setWorldRegion(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleVisible()
|
||||
{
|
||||
if (isVisible())
|
||||
{
|
||||
decayMe();
|
||||
}
|
||||
else
|
||||
{
|
||||
spawnMe();
|
||||
}
|
||||
}
|
||||
|
||||
public ObjectKnownList getKnownList()
|
||||
{
|
||||
return _knownList;
|
||||
}
|
||||
|
||||
public void initKnownList()
|
||||
{
|
||||
_knownList = new ObjectKnownList(this);
|
||||
}
|
||||
|
||||
public final void setKnownList(ObjectKnownList value)
|
||||
{
|
||||
_knownList = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
@ -520,6 +473,17 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
*/
|
||||
public final <T> T addScript(T script)
|
||||
{
|
||||
if (_scripts == null)
|
||||
{
|
||||
// Double-checked locking
|
||||
synchronized (this)
|
||||
{
|
||||
if (_scripts == null)
|
||||
{
|
||||
_scripts = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_scripts.put(script.getClass().getName(), script);
|
||||
return script;
|
||||
}
|
||||
@ -532,7 +496,11 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <T> T removeScript(Class<T> script)
|
||||
{
|
||||
return _scripts == null ? null : (T) _scripts.remove(script.getName());
|
||||
if (_scripts == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (T) _scripts.remove(script.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -543,29 +511,20 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <T> T getScript(Class<T> script)
|
||||
{
|
||||
return _scripts == null ? null : (T) _scripts.get(script.getName());
|
||||
if (_scripts == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (T) _scripts.get(script.getName());
|
||||
}
|
||||
|
||||
public void removeStatusListener(L2Character object)
|
||||
{
|
||||
}
|
||||
|
||||
protected void badCoords()
|
||||
{
|
||||
if (isCharacter())
|
||||
{
|
||||
decayMe();
|
||||
}
|
||||
else if (isPlayer())
|
||||
{
|
||||
((L2Character) this).teleToLocation(new Location(0, 0, 0), false);
|
||||
((L2Character) this).sendMessage("Error with your coords, Please ask a GM for help!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final void setXYZInvisible(int x, int y, int z)
|
||||
{
|
||||
assert getWorldRegion() == null;
|
||||
if (x > L2World.MAP_MAX_X)
|
||||
{
|
||||
x = L2World.MAP_MAX_X - 5000;
|
||||
@ -584,7 +543,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
}
|
||||
|
||||
setXYZ(x, y, z);
|
||||
setIsVisible(false);
|
||||
setSpawned(false);
|
||||
}
|
||||
|
||||
public final void setLocationInvisible(ILocational loc)
|
||||
@ -592,25 +551,6 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
setXYZInvisible(loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
public void updateWorldRegion()
|
||||
{
|
||||
if (!isVisible())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2WorldRegion newRegion = L2World.getInstance().getRegion(getLocation());
|
||||
if (newRegion == getWorldRegion())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getWorldRegion().removeVisibleObject(this);
|
||||
setWorldRegion(newRegion);
|
||||
// Add the L2Oject spawn to _visibleObjects and if necessary to _allplayers of its L2WorldRegion
|
||||
getWorldRegion().addVisibleObject(this);
|
||||
}
|
||||
|
||||
public final L2WorldRegion getWorldRegion()
|
||||
{
|
||||
return _worldRegion;
|
||||
@ -618,18 +558,6 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
|
||||
public void setWorldRegion(L2WorldRegion value)
|
||||
{
|
||||
if ((getWorldRegion() != null) && isCharacter()) // confirm revalidation of old region's zones
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
getWorldRegion().revalidateZones((L2Character) this); // at world region change
|
||||
}
|
||||
else
|
||||
{
|
||||
getWorldRegion().removeFromZones((L2Character) this); // at world region change
|
||||
}
|
||||
}
|
||||
|
||||
_worldRegion = value;
|
||||
}
|
||||
|
||||
@ -730,25 +658,27 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
* @param newZ the Z coordinate
|
||||
*/
|
||||
@Override
|
||||
public final void setXYZ(int newX, int newY, int newZ)
|
||||
public void setXYZ(int newX, int newY, int newZ)
|
||||
{
|
||||
assert getWorldRegion() != null;
|
||||
|
||||
setX(newX);
|
||||
setY(newY);
|
||||
setZ(newZ);
|
||||
|
||||
try
|
||||
if (_isSpawned)
|
||||
{
|
||||
if (L2World.getInstance().getRegion(getLocation()) != getWorldRegion())
|
||||
final L2WorldRegion oldRegion = getWorldRegion();
|
||||
final L2WorldRegion newRegion = L2World.getInstance().getRegion(this);
|
||||
if ((newRegion != null) && (newRegion != oldRegion))
|
||||
{
|
||||
updateWorldRegion();
|
||||
if (oldRegion != null)
|
||||
{
|
||||
oldRegion.removeVisibleObject(this);
|
||||
}
|
||||
newRegion.addVisibleObject(this);
|
||||
L2World.getInstance().switchRegion(this, newRegion);
|
||||
setWorldRegion(newRegion);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
badCoords();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -830,7 +760,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
}
|
||||
|
||||
_instanceId.set(instanceId);
|
||||
if (_isVisible && (_knownList != null))
|
||||
if (_isSpawned)
|
||||
{
|
||||
// We don't want some ugly looking disappear/appear effects, so don't update
|
||||
// the knownlist here, but players usually enter instancezones through teleporting
|
||||
@ -843,6 +773,25 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an instance update for player.
|
||||
* @param instance the instance to update
|
||||
* @param hide if {@code true} hide the player
|
||||
*/
|
||||
private final void sendInstanceUpdate(Instance instance, boolean hide)
|
||||
{
|
||||
final int startTime = (int) ((System.currentTimeMillis() - instance.getInstanceStartTime()) / 1000);
|
||||
final int endTime = (int) ((instance.getInstanceEndTime() - instance.getInstanceStartTime()) / 1000);
|
||||
if (instance.isTimerIncrease())
|
||||
{
|
||||
sendPacket(new ExSendUIEvent(getActingPlayer(), hide, true, startTime, endTime, instance.getTimerText()));
|
||||
}
|
||||
else
|
||||
{
|
||||
sendPacket(new ExSendUIEvent(getActingPlayer(), hide, false, endTime - startTime, 0, instance.getTimerText()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets location of object.
|
||||
* @param loc the location object
|
||||
@ -901,25 +850,6 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
return Util.convertHeadingToDegree(heading);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an instance update for player.
|
||||
* @param instance the instance to update
|
||||
* @param hide if {@code true} hide the player
|
||||
*/
|
||||
private final void sendInstanceUpdate(Instance instance, boolean hide)
|
||||
{
|
||||
final int startTime = (int) ((System.currentTimeMillis() - instance.getInstanceStartTime()) / 1000);
|
||||
final int endTime = (int) ((instance.getInstanceEndTime() - instance.getInstanceStartTime()) / 1000);
|
||||
if (instance.isTimerIncrease())
|
||||
{
|
||||
sendPacket(new ExSendUIEvent(getActingPlayer(), hide, true, startTime, endTime, instance.getTimerText()));
|
||||
}
|
||||
else
|
||||
{
|
||||
sendPacket(new ExSendUIEvent(getActingPlayer(), hide, false, endTime - startTime, 0, instance.getTimerText()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if this object is invisible, {@code false} otherwise.
|
||||
*/
|
||||
@ -938,13 +868,13 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
if (invis)
|
||||
{
|
||||
final DeleteObject deletePacket = new DeleteObject(this);
|
||||
for (L2Object obj : getKnownList().getKnownObjects().values())
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, player ->
|
||||
{
|
||||
if ((obj != null) && obj.isPlayer() && !isVisibleFor(obj.getActingPlayer()))
|
||||
if (!isVisibleFor(player))
|
||||
{
|
||||
obj.sendPacket(deletePacket);
|
||||
player.sendPacket(deletePacket);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Broadcast information regarding the object to those which are suppose to see.
|
||||
@ -965,13 +895,35 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
*/
|
||||
public void broadcastInfo()
|
||||
{
|
||||
for (L2Object obj : getKnownList().getKnownObjects().values())
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, player ->
|
||||
{
|
||||
if ((obj != null) && obj.isPlayer() && isVisibleFor(obj.getActingPlayer()))
|
||||
if (isVisibleFor(player))
|
||||
{
|
||||
sendInfo(obj.getActingPlayer());
|
||||
sendInfo(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isInSurroundingRegion(L2Object worldObject)
|
||||
{
|
||||
if (worldObject == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2WorldRegion worldRegion1 = worldObject.getWorldRegion();
|
||||
if (worldRegion1 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2WorldRegion worldRegion2 = getWorldRegion();
|
||||
if (worldRegion2 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return worldRegion1.isSurroundingRegion(worldRegion2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,23 +16,30 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.gameserver.ai.CtrlEvent;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.ai.L2CharacterAI;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
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.actor.instance.L2PetInstance;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcCreatureSee;
|
||||
import com.l2jmobius.gameserver.model.interfaces.ILocational;
|
||||
import com.l2jmobius.gameserver.network.Disconnection;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.DeleteObject;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
public final class L2World
|
||||
{
|
||||
@ -42,10 +49,11 @@ public final class L2World
|
||||
public static final int GRACIA_MAX_Z = 6105;
|
||||
public static final int GRACIA_MIN_Z = -895;
|
||||
|
||||
/** Biteshift, defines number of regions note, shifting by 15 will result in regions corresponding to map tiles shifting by 12 divides one tile to 8x8 regions. */
|
||||
public static final int SHIFT_BY = 12;
|
||||
/** Bit shift, defines number of regions note, shifting by 15 will result in regions corresponding to map tiles shifting by 11 divides one tile to 16x16 regions. */
|
||||
public static final int SHIFT_BY = 11;
|
||||
public static final int SHIFT_BY_Z = 10;
|
||||
|
||||
private static final int TILE_SIZE = 32768;
|
||||
public static final int TILE_SIZE = 32768;
|
||||
|
||||
/** Map dimensions */
|
||||
public static final int TILE_X_MIN = 11;
|
||||
@ -56,17 +64,23 @@ public final class L2World
|
||||
public static final int TILE_ZERO_COORD_Y = 18;
|
||||
public static final int MAP_MIN_X = (TILE_X_MIN - TILE_ZERO_COORD_X) * TILE_SIZE;
|
||||
public static final int MAP_MIN_Y = (TILE_Y_MIN - TILE_ZERO_COORD_Y) * TILE_SIZE;
|
||||
public static final int MAP_MIN_Z = -TILE_SIZE / 2;
|
||||
|
||||
public static final int MAP_MAX_X = ((TILE_X_MAX - TILE_ZERO_COORD_X) + 1) * TILE_SIZE;
|
||||
public static final int MAP_MAX_Y = ((TILE_Y_MAX - TILE_ZERO_COORD_Y) + 1) * TILE_SIZE;
|
||||
public static final int MAP_MAX_Z = TILE_SIZE / 2;
|
||||
|
||||
/** calculated offset used so top left region is 0,0 */
|
||||
public static final int OFFSET_X = Math.abs(MAP_MIN_X >> SHIFT_BY);
|
||||
public static final int OFFSET_Y = Math.abs(MAP_MIN_Y >> SHIFT_BY);
|
||||
public static final int OFFSET_Z = Math.abs(MAP_MIN_Z >> SHIFT_BY_Z);
|
||||
|
||||
/** number of regions */
|
||||
private static final int REGIONS_X = (MAP_MAX_X >> SHIFT_BY) + OFFSET_X;
|
||||
private static final int REGIONS_Y = (MAP_MAX_Y >> SHIFT_BY) + OFFSET_Y;
|
||||
private static final int REGIONS_Z = (MAP_MAX_Z >> SHIFT_BY_Z) + OFFSET_Z;
|
||||
|
||||
public static final int REGION_MIN_DIMENSION = Math.min(TILE_SIZE / (TILE_SIZE >> SHIFT_BY_Z), TILE_SIZE / (TILE_SIZE >> SHIFT_BY));
|
||||
|
||||
/** Map containing all the players in game. */
|
||||
private final Map<Integer, L2PcInstance> _allPlayers = new ConcurrentHashMap<>();
|
||||
@ -75,12 +89,23 @@ public final class L2World
|
||||
/** Map with the pets instances and their owner ID. */
|
||||
private final Map<Integer, L2PetInstance> _petsInstance = new ConcurrentHashMap<>();
|
||||
|
||||
private L2WorldRegion[][] _worldRegions;
|
||||
private final L2WorldRegion[][][] _worldRegions = new L2WorldRegion[REGIONS_X + 1][REGIONS_Y + 1][REGIONS_Z + 1];
|
||||
|
||||
/** Constructor of L2World. */
|
||||
protected L2World()
|
||||
{
|
||||
initRegions();
|
||||
for (int x = 0; x <= REGIONS_X; x++)
|
||||
{
|
||||
for (int y = 0; y <= REGIONS_Y; y++)
|
||||
{
|
||||
for (int z = 0; z <= REGIONS_Z; z++)
|
||||
{
|
||||
_worldRegions[x][y][z] = new L2WorldRegion(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.info(getClass().getSimpleName() + ": (" + REGIONS_X + " by " + REGIONS_Y + " by " + REGIONS_Z + ") World Region Grid set up.");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,37 +193,11 @@ public final class L2World
|
||||
return _allObjects.size();
|
||||
}
|
||||
|
||||
public List<L2PcInstance> getAllGMs()
|
||||
{
|
||||
return AdminData.getInstance().getAllGms(true);
|
||||
}
|
||||
|
||||
public Collection<L2PcInstance> getPlayers()
|
||||
{
|
||||
return _allPlayers.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all players sorted by the given comparator.
|
||||
* @param comparator the comparator
|
||||
* @return the players sorted by the comparator
|
||||
*/
|
||||
public L2PcInstance[] getPlayersSortedBy(Comparator<L2PcInstance> comparator)
|
||||
{
|
||||
final L2PcInstance[] players = _allPlayers.values().toArray(new L2PcInstance[_allPlayers.values().size()]);
|
||||
Arrays.sort(players, comparator);
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return how many players are online.
|
||||
* @return number of online players.
|
||||
*/
|
||||
public int getAllPlayersCount()
|
||||
{
|
||||
return _allPlayers.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* <B>If you have access to player objectId use {@link #getPlayer(int playerObjId)}</B>
|
||||
* @param name Name of the player to get Instance
|
||||
@ -247,15 +246,6 @@ public final class L2World
|
||||
_petsInstance.remove(ownerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given pet instance.
|
||||
* @param pet the pet to remove
|
||||
*/
|
||||
public void removePet(L2PetInstance pet)
|
||||
{
|
||||
_petsInstance.remove(pet.getOwner().getObjectId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a L2Object in the world. <B><U> Concept</U> :</B> L2Object (including L2PcInstance) are identified in <B>_visibleObjects</B> of his current L2WorldRegion and in <B>_knownObjects</B> of other surrounding L2Characters <BR>
|
||||
* L2PcInstance are identified in <B>_allPlayers</B> of L2World, in <B>_allPlayers</B> of his current L2WorldRegion and in <B>_knownPlayer</B> of other surrounding L2Characters <B><U> Actions</U> :</B>
|
||||
@ -278,35 +268,63 @@ public final class L2World
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Get all visible objects contained in the _visibleObjects of L2WorldRegions
|
||||
// in a circular area of 2000 units
|
||||
final List<L2Object> visibles = getVisibleObjects(object, 2000);
|
||||
|
||||
// tell the player about the surroundings
|
||||
// Go through the visible objects contained in the circular area
|
||||
for (L2Object visible : visibles)
|
||||
forEachVisibleObject(object, L2Object.class, 1, wo ->
|
||||
{
|
||||
if (visible == null)
|
||||
if (object.isPlayer() && wo.isVisibleFor((L2PcInstance) object))
|
||||
{
|
||||
continue;
|
||||
wo.sendInfo((L2PcInstance) object);
|
||||
if (wo.isCharacter())
|
||||
{
|
||||
final L2CharacterAI ai = ((L2Character) wo).getAI();
|
||||
if (ai != null)
|
||||
{
|
||||
ai.describeStateToPlayer((L2PcInstance) object);
|
||||
if (wo.isMonster())
|
||||
{
|
||||
if (ai.getIntention() == CtrlIntention.AI_INTENTION_IDLE)
|
||||
{
|
||||
ai.setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the object in L2ObjectHashSet(L2Object) _knownObjects of the visible L2Character according to conditions :
|
||||
// - L2Character is visible
|
||||
// - object is not already known
|
||||
// - object is in the watch distance
|
||||
// If L2Object is a L2PcInstance, add L2Object in L2ObjectHashSet(L2PcInstance) _knownPlayer of the visible L2Character
|
||||
visible.getKnownList().addKnownObject(object);
|
||||
if (wo.isPlayer() && object.isVisibleFor((L2PcInstance) wo))
|
||||
{
|
||||
object.sendInfo((L2PcInstance) wo);
|
||||
if (object.isCharacter())
|
||||
{
|
||||
final L2CharacterAI ai = ((L2Character) object).getAI();
|
||||
if (ai != null)
|
||||
{
|
||||
ai.describeStateToPlayer((L2PcInstance) wo);
|
||||
if (object.isMonster())
|
||||
{
|
||||
if (ai.getIntention() == CtrlIntention.AI_INTENTION_IDLE)
|
||||
{
|
||||
ai.setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the visible L2Object in L2ObjectHashSet(L2Object) _knownObjects of the object according to conditions
|
||||
// If visible L2Object is a L2PcInstance, add visible L2Object in L2ObjectHashSet(L2PcInstance) _knownPlayer of the object
|
||||
object.getKnownList().addKnownObject(visible);
|
||||
}
|
||||
if (wo.isNpc() && object.isCharacter())
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcCreatureSee((L2Npc) wo, (L2Character) object, object.isSummon()), (L2Npc) wo);
|
||||
}
|
||||
|
||||
if (object.isNpc() && wo.isCharacter())
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcCreatureSee((L2Npc) object, (L2Character) wo, wo.isSummon()), (L2Npc) object);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an object from the world.<br>
|
||||
* <B><U> Concept</U> :</B> L2Object (including L2PcInstance) are identified in <B>_visibleObjects</B> of his current L2WorldRegion and in <B>_knownObjects</B> of other surrounding L2Characters <BR>
|
||||
* Remove a L2Object from the world. <B><U> Concept</U> :</B> L2Object (including L2PcInstance) are identified in <B>_visibleObjects</B> of his current L2WorldRegion and in <B>_knownObjects</B> of other surrounding L2Characters <BR>
|
||||
* L2PcInstance are identified in <B>_allPlayers</B> of L2World, in <B>_allPlayers</B> of his current L2WorldRegion and in <B>_knownPlayer</B> of other surrounding L2Characters <B><U> Actions</U> :</B>
|
||||
* <li>Remove the L2Object object from _allPlayers* of L2World</li>
|
||||
* <li>Remove the L2Object object from _visibleObjects and _allPlayers* of L2WorldRegion</li>
|
||||
@ -317,179 +335,334 @@ public final class L2World
|
||||
* <li>Pickup an Item</li>
|
||||
* <li>Decay a L2Character</li>
|
||||
* @param object L2object to remove from the world
|
||||
* @param oldWorldRegion L2WorldRegion in which the object was before removing
|
||||
* @param oldRegion L2WorldRegion in which the object was before removing
|
||||
*/
|
||||
public void removeVisibleObject(L2Object object, L2WorldRegion oldWorldRegion)
|
||||
public void removeVisibleObject(L2Object object, L2WorldRegion oldRegion)
|
||||
{
|
||||
if ((object == null) || (oldWorldRegion == null))
|
||||
if (object == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Removes the object from the visible objects of world region.
|
||||
// If object is a player, removes it from the players map of this world region.
|
||||
oldWorldRegion.removeVisibleObject(object);
|
||||
|
||||
// Goes through all surrounding world region's creatures.
|
||||
// And removes the object from their known lists.
|
||||
for (L2WorldRegion worldRegion : oldWorldRegion.getSurroundingRegions())
|
||||
if (oldRegion != null)
|
||||
{
|
||||
for (L2Object obj : worldRegion.getVisibleObjects().values())
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding L2WorldRegion L2Characters
|
||||
oldRegion.forEachSurroundingRegion(w ->
|
||||
{
|
||||
if (obj != null)
|
||||
for (L2Object wo : w.getVisibleObjects().values())
|
||||
{
|
||||
obj.getKnownList().removeKnownObject(object);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (object.isCharacter())
|
||||
{
|
||||
final L2Character objectCreature = (L2Character) object;
|
||||
final L2CharacterAI ai = objectCreature.getAI();
|
||||
if (ai != null)
|
||||
{
|
||||
ai.notifyEvent(CtrlEvent.EVT_FORGET_OBJECT, wo);
|
||||
}
|
||||
|
||||
if (objectCreature.getTarget() == wo)
|
||||
{
|
||||
objectCreature.setTarget(null);
|
||||
}
|
||||
|
||||
if (object.isPlayer())
|
||||
{
|
||||
object.sendPacket(new DeleteObject(wo));
|
||||
}
|
||||
}
|
||||
|
||||
if (wo.isCharacter())
|
||||
{
|
||||
final L2Character woCreature = (L2Character) wo;
|
||||
final L2CharacterAI ai = woCreature.getAI();
|
||||
if (ai != null)
|
||||
{
|
||||
ai.notifyEvent(CtrlEvent.EVT_FORGET_OBJECT, object);
|
||||
}
|
||||
|
||||
if (woCreature.getTarget() == object)
|
||||
{
|
||||
woCreature.setTarget(null);
|
||||
}
|
||||
|
||||
if (wo.isPlayer())
|
||||
{
|
||||
wo.sendPacket(new DeleteObject(object));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
// Removes all objects from the object's known list.
|
||||
object.getKnownList().removeAllKnownObjects();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all visible objects of the L2WorldRegion object's and of its surrounding L2WorldRegion. <B><U> Concept</U> :</B> All visible object are identified in <B>_visibleObjects</B> of their current L2WorldRegion <BR>
|
||||
* All surrounding L2WorldRegion are identified in <B>_surroundingRegions</B> of the selected L2WorldRegion in order to scan a large area around a L2Object <B><U> Example of use </U> :</B>
|
||||
* <li>Find Close Objects for L2Character</li><BR>
|
||||
* @param object L2object that determine the current L2WorldRegion
|
||||
* @return
|
||||
*/
|
||||
public List<L2Object> getVisibleObjects(L2Object object)
|
||||
public void switchRegion(L2Object object, L2WorldRegion newRegion)
|
||||
{
|
||||
final L2WorldRegion reg = object.getWorldRegion();
|
||||
|
||||
if (reg == null)
|
||||
final L2WorldRegion oldRegion = object.getWorldRegion();
|
||||
if ((oldRegion == null) || (oldRegion == newRegion))
|
||||
{
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a list in order to contain all visible objects.
|
||||
final List<L2Object> result = new LinkedList<>();
|
||||
for (L2WorldRegion regi : reg.getSurroundingRegions())
|
||||
oldRegion.forEachSurroundingRegion(w ->
|
||||
{
|
||||
// Go through visible objects of the selected region
|
||||
for (L2Object _object : regi.getVisibleObjects().values())
|
||||
if (!newRegion.isSurroundingRegion(w))
|
||||
{
|
||||
if ((_object == null) || _object.equals(object) || !_object.isVisible())
|
||||
for (L2Object wo : w.getVisibleObjects().values())
|
||||
{
|
||||
continue;
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (object.isCharacter())
|
||||
{
|
||||
final L2Character objectCreature = (L2Character) object;
|
||||
final L2CharacterAI ai = objectCreature.getAI();
|
||||
if (ai != null)
|
||||
{
|
||||
ai.notifyEvent(CtrlEvent.EVT_FORGET_OBJECT, wo);
|
||||
}
|
||||
|
||||
if (objectCreature.getTarget() == wo)
|
||||
{
|
||||
objectCreature.setTarget(null);
|
||||
}
|
||||
|
||||
if (object.isPlayer())
|
||||
{
|
||||
object.sendPacket(new DeleteObject(wo));
|
||||
}
|
||||
}
|
||||
|
||||
if (wo.isCharacter())
|
||||
{
|
||||
final L2Character woCreature = (L2Character) wo;
|
||||
final L2CharacterAI ai = woCreature.getAI();
|
||||
if (ai != null)
|
||||
{
|
||||
ai.notifyEvent(CtrlEvent.EVT_FORGET_OBJECT, object);
|
||||
}
|
||||
|
||||
if (woCreature.getTarget() == object)
|
||||
{
|
||||
woCreature.setTarget(null);
|
||||
}
|
||||
|
||||
if (wo.isPlayer())
|
||||
{
|
||||
wo.sendPacket(new DeleteObject(object));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
newRegion.forEachSurroundingRegion(w ->
|
||||
{
|
||||
if (!oldRegion.isSurroundingRegion(w))
|
||||
{
|
||||
for (L2Object wo : w.getVisibleObjects().values())
|
||||
{
|
||||
if ((wo == object) || (wo.getInstanceId() != object.getInstanceId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (object.isPlayer() && wo.isVisibleFor((L2PcInstance) object))
|
||||
{
|
||||
wo.sendInfo((L2PcInstance) object);
|
||||
if (wo.isCharacter())
|
||||
{
|
||||
final L2CharacterAI ai = ((L2Character) wo).getAI();
|
||||
if (ai != null)
|
||||
{
|
||||
ai.describeStateToPlayer((L2PcInstance) object);
|
||||
if (wo.isMonster())
|
||||
{
|
||||
if (ai.getIntention() == CtrlIntention.AI_INTENTION_IDLE)
|
||||
{
|
||||
ai.setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (wo.isPlayer() && object.isVisibleFor((L2PcInstance) wo))
|
||||
{
|
||||
object.sendInfo((L2PcInstance) wo);
|
||||
if (object.isCharacter())
|
||||
{
|
||||
final L2CharacterAI ai = ((L2Character) object).getAI();
|
||||
if (ai != null)
|
||||
{
|
||||
ai.describeStateToPlayer((L2PcInstance) wo);
|
||||
if (object.isMonster())
|
||||
{
|
||||
if (ai.getIntention() == CtrlIntention.AI_INTENTION_IDLE)
|
||||
{
|
||||
ai.setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (wo.isNpc() && object.isCharacter())
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcCreatureSee((L2Npc) wo, (L2Character) object, object.isSummon()), (L2Npc) wo);
|
||||
}
|
||||
|
||||
if (object.isNpc() && wo.isCharacter())
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcCreatureSee((L2Npc) object, (L2Character) wo, wo.isSummon()), (L2Npc) object);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public <T extends L2Object> void forEachVisibleObject(L2Object object, Class<T> clazz, int depth, Consumer<T> c)
|
||||
{
|
||||
if (object == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int x = Math.max(centerWorldRegion.getRegionX() - depth, 0); x <= Math.min(centerWorldRegion.getRegionX() + depth, REGIONS_X); x++)
|
||||
{
|
||||
for (int y = Math.max(centerWorldRegion.getRegionY() - depth, 0); y <= Math.min(centerWorldRegion.getRegionY() + depth, REGIONS_Y); y++)
|
||||
{
|
||||
for (int z = Math.max(centerWorldRegion.getRegionZ() - depth, 0); z <= Math.min(centerWorldRegion.getRegionZ() + depth, REGIONS_Z); z++)
|
||||
{
|
||||
for (L2Object visibleObject : _worldRegions[x][y][z].getVisibleObjects().values())
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceId() != object.getInstanceId())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
}
|
||||
}
|
||||
result.add(_object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends L2Object> void forEachVisibleObject(L2Object object, Class<T> clazz, Consumer<T> c)
|
||||
{
|
||||
forEachVisibleObject(object, clazz, 1, c);
|
||||
}
|
||||
|
||||
public <T extends L2Object> void forEachVisibleObjectInRange(L2Object object, Class<T> clazz, int range, Consumer<T> c)
|
||||
{
|
||||
if (object == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final int depth = (range / REGION_MIN_DIMENSION) + 1;
|
||||
for (int x = Math.max(centerWorldRegion.getRegionX() - depth, 0); x <= Math.min(centerWorldRegion.getRegionX() + depth, REGIONS_X); x++)
|
||||
{
|
||||
for (int y = Math.max(centerWorldRegion.getRegionY() - depth, 0); y <= Math.min(centerWorldRegion.getRegionY() + depth, REGIONS_Y); y++)
|
||||
{
|
||||
for (int z = Math.max(centerWorldRegion.getRegionZ() - depth, 0); z <= Math.min(centerWorldRegion.getRegionZ() + depth, REGIONS_Z); z++)
|
||||
{
|
||||
final int x1 = (x - OFFSET_X) << SHIFT_BY;
|
||||
final int y1 = (y - OFFSET_Y) << SHIFT_BY;
|
||||
final int z1 = (z - OFFSET_Z) << SHIFT_BY_Z;
|
||||
final int x2 = ((x + 1) - OFFSET_X) << SHIFT_BY;
|
||||
final int y2 = ((y + 1) - OFFSET_Y) << SHIFT_BY;
|
||||
final int z2 = ((z + 1) - OFFSET_Z) << SHIFT_BY_Z;
|
||||
if (Util.cubeIntersectsSphere(x1, y1, z1, x2, y2, z2, object.getX(), object.getY(), object.getZ(), range))
|
||||
{
|
||||
for (L2Object visibleObject : _worldRegions[x][y][z].getVisibleObjects().values())
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceId() != object.getInstanceId())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance(object, true, false) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends L2Object> List<T> getVisibleObjects(L2Object object, Class<T> clazz)
|
||||
{
|
||||
final List<T> result = new LinkedList<>();
|
||||
forEachVisibleObject(object, clazz, result::add);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all visible objects of the L2WorldRegions in the circular area (radius) centered on the object. <B><U> Concept</U> :</B> All visible object are identified in <B>_visibleObjects</B> of their current L2WorldRegion <BR>
|
||||
* All surrounding L2WorldRegion are identified in <B>_surroundingRegions</B> of the selected L2WorldRegion in order to scan a large area around a L2Object <B><U> Example of use </U> :</B>
|
||||
* <li>Define the aggrolist of monster</li>
|
||||
* <li>Define visible objects of a L2Object</li>
|
||||
* <li>Skill : Confusion...</li><BR>
|
||||
* @param object L2object that determine the center of the circular area
|
||||
* @param radius Radius of the circular area
|
||||
* @return
|
||||
*/
|
||||
public List<L2Object> getVisibleObjects(L2Object object, int radius)
|
||||
public <T extends L2Object> List<T> getVisibleObjects(L2Object object, Class<T> clazz, Predicate<T> predicate)
|
||||
{
|
||||
if ((object == null) || !object.isVisible())
|
||||
final List<T> result = new LinkedList<>();
|
||||
forEachVisibleObject(object, clazz, o ->
|
||||
{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
final int sqRadius = radius * radius;
|
||||
|
||||
// Create a list in order to contain all visible objects.
|
||||
final List<L2Object> result = new LinkedList<>();
|
||||
for (L2WorldRegion regi : object.getWorldRegion().getSurroundingRegions())
|
||||
{
|
||||
// Go through visible objects of the selected region
|
||||
for (L2Object _object : regi.getVisibleObjects().values())
|
||||
if (predicate.test(o))
|
||||
{
|
||||
if ((_object == null) || _object.equals(object))
|
||||
{
|
||||
continue; // skip our own character
|
||||
}
|
||||
|
||||
if (sqRadius > object.calculateDistance(_object, false, true))
|
||||
{
|
||||
result.add(_object);
|
||||
}
|
||||
result.add(o);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all visible objects of the L2WorldRegions in the spheric area (radius) centered on the object. <B><U> Concept</U> :</B> All visible object are identified in <B>_visibleObjects</B> of their current L2WorldRegion <BR>
|
||||
* All surrounding L2WorldRegion are identified in <B>_surroundingRegions</B> of the selected L2WorldRegion in order to scan a large area around a L2Object <B><U> Example of use </U> :</B>
|
||||
* <li>Define the target list of a skill</li>
|
||||
* <li>Define the target list of a polearme attack</li>
|
||||
* @param object L2object that determine the center of the circular area
|
||||
* @param radius Radius of the spheric area
|
||||
* @return
|
||||
*/
|
||||
public List<L2Object> getVisibleObjects3D(L2Object object, int radius)
|
||||
public <T extends L2Object> List<T> getVisibleObjects(L2Object object, Class<T> clazz, int range)
|
||||
{
|
||||
if ((object == null) || !object.isVisible())
|
||||
{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
final int sqRadius = radius * radius;
|
||||
|
||||
// Create a list in order to contain all visible objects.
|
||||
final List<L2Object> result = new LinkedList<>();
|
||||
for (L2WorldRegion regi : object.getWorldRegion().getSurroundingRegions())
|
||||
{
|
||||
for (L2Object _object : regi.getVisibleObjects().values())
|
||||
{
|
||||
if ((_object == null) || _object.equals(object))
|
||||
{
|
||||
continue; // skip our own character
|
||||
}
|
||||
|
||||
if (sqRadius > object.calculateDistance(_object, true, true))
|
||||
{
|
||||
result.add(_object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final List<T> result = new LinkedList<>();
|
||||
forEachVisibleObjectInRange(object, clazz, range, result::add);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* <B><U> Concept</U> :</B> All visible object are identified in <B>_visibleObjects</B> of their current L2WorldRegion <BR>
|
||||
* All surrounding L2WorldRegion are identified in <B>_surroundingRegions</B> of the selected L2WorldRegion in order to scan a large area around a L2Object <B><U> Example of use </U> :</B>
|
||||
* <li>Find Close Objects for L2Character</li><BR>
|
||||
* @param object L2object that determine the current L2WorldRegion
|
||||
* @return all visible players of the L2WorldRegion object's and of its surrounding L2WorldRegion.
|
||||
*/
|
||||
public List<L2Playable> getVisiblePlayable(L2Object object)
|
||||
public <T extends L2Object> List<T> getVisibleObjects(L2Object object, Class<T> clazz, int range, Predicate<T> predicate)
|
||||
{
|
||||
final L2WorldRegion reg = object.getWorldRegion();
|
||||
if (reg == null)
|
||||
final List<T> result = new LinkedList<>();
|
||||
forEachVisibleObjectInRange(object, clazz, range, o ->
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create a list in order to contain all visible objects.
|
||||
final List<L2Playable> result = new LinkedList<>();
|
||||
for (L2WorldRegion regi : reg.getSurroundingRegions())
|
||||
{
|
||||
for (L2Playable _object : regi.getVisiblePlayable().values())
|
||||
if (predicate.test(o))
|
||||
{
|
||||
if ((_object == null) || _object.equals(object) || !_object.isVisible())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.add(_object);
|
||||
result.add(o);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -500,21 +673,30 @@ public final class L2World
|
||||
* @param point position of the object
|
||||
* @return
|
||||
*/
|
||||
public L2WorldRegion getRegion(Location point)
|
||||
public L2WorldRegion getRegion(ILocational point)
|
||||
{
|
||||
return _worldRegions[(point.getX() >> SHIFT_BY) + OFFSET_X][(point.getY() >> SHIFT_BY) + OFFSET_Y];
|
||||
return getRegion(point.getX(), point.getY(), point.getZ());
|
||||
}
|
||||
|
||||
public L2WorldRegion getRegion(int x, int y)
|
||||
public L2WorldRegion getRegion(int x, int y, int z)
|
||||
{
|
||||
return _worldRegions[(x >> SHIFT_BY) + OFFSET_X][(y >> SHIFT_BY) + OFFSET_Y];
|
||||
try
|
||||
{
|
||||
return _worldRegions[(x >> SHIFT_BY) + OFFSET_X][(y >> SHIFT_BY) + OFFSET_Y][(z >> SHIFT_BY_Z) + OFFSET_Z];
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e)
|
||||
{
|
||||
// TODO: Find when this can be null. (Bad geodata? Check GeoEngine hasGeoPos method.)
|
||||
// LOGGER.warning(getClass().getSimpleName() + ": Incorrect world region X: " + ((x >> SHIFT_BY) + OFFSET_X) + " Y: " + ((y >> SHIFT_BY) + OFFSET_Y) + " Z: " + ((z >> SHIFT_BY_Z) + OFFSET_Z) + " for coordinates x: " + x + " y: " + y + " z: " + z);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the whole 2d array containing the world regions used by ZoneData.java to setup zones inside the world regions
|
||||
* Returns the whole 3d array containing the world regions used by ZoneData.java to setup zones inside the world regions
|
||||
* @return
|
||||
*/
|
||||
public L2WorldRegion[][] getWorldRegions()
|
||||
public L2WorldRegion[][][] getWorldRegions()
|
||||
{
|
||||
return _worldRegions;
|
||||
}
|
||||
@ -524,46 +706,12 @@ public final class L2World
|
||||
* <li>Init L2WorldRegions</li><BR>
|
||||
* @param x X position of the object
|
||||
* @param y Y position of the object
|
||||
* @param z Z position of the object
|
||||
* @return True if the L2WorldRegion is valid
|
||||
*/
|
||||
private boolean validRegion(int x, int y)
|
||||
public static boolean validRegion(int x, int y, int z)
|
||||
{
|
||||
return (x >= 0) && (x <= REGIONS_X) && (y >= 0) && (y <= REGIONS_Y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the world regions.
|
||||
*/
|
||||
private void initRegions()
|
||||
{
|
||||
_worldRegions = new L2WorldRegion[REGIONS_X + 1][REGIONS_Y + 1];
|
||||
|
||||
for (int i = 0; i <= REGIONS_X; i++)
|
||||
{
|
||||
for (int j = 0; j <= REGIONS_Y; j++)
|
||||
{
|
||||
_worldRegions[i][j] = new L2WorldRegion(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x <= REGIONS_X; x++)
|
||||
{
|
||||
for (int y = 0; y <= REGIONS_Y; y++)
|
||||
{
|
||||
for (int a = -1; a <= 1; a++)
|
||||
{
|
||||
for (int b = -1; b <= 1; b++)
|
||||
{
|
||||
if (validRegion(x + a, y + b))
|
||||
{
|
||||
_worldRegions[x + a][y + b].addSurroundingRegion(_worldRegions[x][y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.info("L2World: (" + REGIONS_X + " by " + REGIONS_Y + ") World Region Grid set up.");
|
||||
return ((x >= 0) && (x <= REGIONS_X) && (y >= 0) && (y <= REGIONS_Y)) && (z >= 0) && (z <= REGIONS_Z);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -571,15 +719,18 @@ public final class L2World
|
||||
*/
|
||||
public void deleteVisibleNpcSpawns()
|
||||
{
|
||||
LOGGER.info("Deleting all visible NPCs.");
|
||||
for (int i = 0; i <= REGIONS_X; i++)
|
||||
LOGGER.info(getClass().getSimpleName() + ": Deleting all visible NPCs.");
|
||||
for (int x = 0; x <= REGIONS_X; x++)
|
||||
{
|
||||
for (int j = 0; j <= REGIONS_Y; j++)
|
||||
for (int y = 0; y <= REGIONS_Y; y++)
|
||||
{
|
||||
_worldRegions[i][j].deleteVisibleNpcSpawns();
|
||||
for (int z = 0; z <= REGIONS_Z; z++)
|
||||
{
|
||||
_worldRegions[x][y][z].deleteVisibleNpcSpawns();
|
||||
}
|
||||
}
|
||||
}
|
||||
LOGGER.info("All visible NPCs deleted.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": All visible NPCs deleted.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,10 +17,12 @@
|
||||
package com.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
@ -29,7 +31,6 @@ import com.l2jmobius.gameserver.datatables.SpawnTable;
|
||||
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.L2Vehicle;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.zone.L2ZoneType;
|
||||
@ -37,28 +38,22 @@ import com.l2jmobius.gameserver.model.zone.type.L2PeaceZone;
|
||||
|
||||
public final class L2WorldRegion
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(L2WorldRegion.class.getName());
|
||||
|
||||
/** Map containing all playable characters in game in this world region. */
|
||||
private final Map<Integer, L2Playable> _allPlayable;
|
||||
private static final Logger LOGGER = Logger.getLogger(L2WorldRegion.class.getName());
|
||||
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, L2Object> _visibleObjects;
|
||||
|
||||
private final List<L2WorldRegion> _surroundingRegions;
|
||||
private final int _tileX, _tileY;
|
||||
private volatile Map<Integer, L2Object> _visibleObjects;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
private final int _regionZ;
|
||||
private boolean _active = false;
|
||||
private ScheduledFuture<?> _neighborsTask = null;
|
||||
private final List<L2ZoneType> _zones;
|
||||
|
||||
public L2WorldRegion(int pTileX, int pTileY)
|
||||
public L2WorldRegion(int regionX, int regionY, int regionZ)
|
||||
{
|
||||
_allPlayable = new ConcurrentHashMap<>();
|
||||
_visibleObjects = new ConcurrentHashMap<>();
|
||||
_surroundingRegions = new ArrayList<>();
|
||||
|
||||
_tileX = pTileX;
|
||||
_tileY = pTileY;
|
||||
_regionX = regionX;
|
||||
_regionY = regionY;
|
||||
_regionZ = regionZ;
|
||||
|
||||
// default a newly initialized region to inactive, unless always on is specified
|
||||
_active = Config.GRIDS_ALWAYS_ON;
|
||||
@ -175,35 +170,24 @@ public final class L2WorldRegion
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_isActivating)
|
||||
forEachSurroundingRegion(w ->
|
||||
{
|
||||
// for each neighbor, if it's not active, activate.
|
||||
for (L2WorldRegion neighbor : getSurroundingRegions())
|
||||
if (_isActivating || w.areNeighborsEmpty())
|
||||
{
|
||||
neighbor.setActive(true);
|
||||
w.setActive(_isActivating);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (areNeighborsEmpty())
|
||||
{
|
||||
setActive(false);
|
||||
}
|
||||
|
||||
// check and deactivate
|
||||
for (L2WorldRegion neighbor : getSurroundingRegions())
|
||||
{
|
||||
if (neighbor.areNeighborsEmpty())
|
||||
{
|
||||
neighbor.setActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void switchAI(boolean isOn)
|
||||
{
|
||||
if (_visibleObjects == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int c = 0;
|
||||
if (!isOn)
|
||||
{
|
||||
@ -225,7 +209,6 @@ public final class L2WorldRegion
|
||||
|
||||
mob.clearAggroList();
|
||||
mob.getAttackByList().clear();
|
||||
mob.getKnownList().removeAllKnownObjects();
|
||||
|
||||
// stop the ai tasks
|
||||
if (mob.hasAI())
|
||||
@ -237,11 +220,9 @@ public final class L2WorldRegion
|
||||
else if (o instanceof L2Vehicle)
|
||||
{
|
||||
c++;
|
||||
((L2Vehicle) o).getKnownList().removeAllKnownObjects();
|
||||
}
|
||||
}
|
||||
|
||||
_log.fine(c + " mobs were turned off");
|
||||
LOGGER.finer(c + " mobs were turned off");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -255,11 +236,10 @@ public final class L2WorldRegion
|
||||
}
|
||||
else if (o instanceof L2Npc)
|
||||
{
|
||||
((L2Npc) o).startRandomAnimationTimer();
|
||||
((L2Npc) o).startRandomAnimationTask();
|
||||
}
|
||||
}
|
||||
|
||||
_log.fine(c + " mobs were turned on");
|
||||
LOGGER.finer(c + " mobs were turned on");
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,27 +248,9 @@ public final class L2WorldRegion
|
||||
return _active;
|
||||
}
|
||||
|
||||
// check if all 9 neighbors (including self) are inactive or active but with no players.
|
||||
// returns true if the above condition is met.
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
// if this region is occupied, return false.
|
||||
if (isActive() && !_allPlayable.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// if any one of the neighbors is occupied, return false
|
||||
for (L2WorldRegion neighbor : _surroundingRegions)
|
||||
{
|
||||
if (neighbor.isActive() && !neighbor._allPlayable.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// in all other cases, return true.
|
||||
return true;
|
||||
return forEachSurroundingRegion(w -> !(w.isActive() && w.getVisibleObjects().values().stream().anyMatch(L2Object::isPlayable)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -307,9 +269,7 @@ public final class L2WorldRegion
|
||||
// turn the AI on or off to match the region's activation.
|
||||
switchAI(value);
|
||||
|
||||
// TODO
|
||||
// turn the geodata on or off to match the region's activation.
|
||||
_log.fine(value ? "Starting Grid " + _tileX + "," + _tileY : "Stoping Grid " + _tileX + "," + _tileY);
|
||||
LOGGER.finer((value ? "Starting" : "Stopping") + " Grid " + this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -369,14 +329,22 @@ public final class L2WorldRegion
|
||||
|
||||
assert object.getWorldRegion() == this;
|
||||
|
||||
if (_visibleObjects == null)
|
||||
{
|
||||
synchronized (object)
|
||||
{
|
||||
if (_visibleObjects == null)
|
||||
{
|
||||
_visibleObjects = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
|
||||
if (object instanceof L2Playable)
|
||||
if (object.isPlayable())
|
||||
{
|
||||
_allPlayable.put(object.getObjectId(), (L2Playable) object);
|
||||
|
||||
// if this is the first player to enter the region, activate self & neighbors
|
||||
if ((_allPlayable.size() == 1) && !Config.GRIDS_ALWAYS_ON)
|
||||
if (!isActive() && (!Config.GRIDS_ALWAYS_ON))
|
||||
{
|
||||
startActivation();
|
||||
}
|
||||
@ -396,46 +364,24 @@ public final class L2WorldRegion
|
||||
}
|
||||
|
||||
assert (object.getWorldRegion() == this) || (object.getWorldRegion() == null);
|
||||
|
||||
if (_visibleObjects == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
if (object instanceof L2Playable)
|
||||
if (object.isPlayable())
|
||||
{
|
||||
_allPlayable.remove(object.getObjectId());
|
||||
|
||||
if (_allPlayable.isEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
if (areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addSurroundingRegion(L2WorldRegion region)
|
||||
{
|
||||
_surroundingRegions.add(region);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ArrayList _surroundingRegions containing all L2WorldRegion around the current L2WorldRegion
|
||||
*/
|
||||
public List<L2WorldRegion> getSurroundingRegions()
|
||||
{
|
||||
return _surroundingRegions;
|
||||
}
|
||||
|
||||
public Map<Integer, L2Playable> getVisiblePlayable()
|
||||
{
|
||||
return _allPlayable;
|
||||
}
|
||||
|
||||
public Map<Integer, L2Object> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return "(" + _tileX + ", " + _tileY + ")";
|
||||
return _visibleObjects != null ? _visibleObjects : Collections.emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -443,7 +389,12 @@ public final class L2WorldRegion
|
||||
*/
|
||||
public void deleteVisibleNpcSpawns()
|
||||
{
|
||||
_log.fine("Deleting all visible NPCs in Region: " + getName());
|
||||
if (_visibleObjects == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LOGGER.info("Deleting all visible NPCs in Region: " + this);
|
||||
for (L2Object obj : _visibleObjects.values())
|
||||
{
|
||||
if (obj instanceof L2Npc)
|
||||
@ -456,9 +407,57 @@ public final class L2WorldRegion
|
||||
spawn.stopRespawn();
|
||||
SpawnTable.getInstance().deleteSpawn(spawn, false);
|
||||
}
|
||||
_log.finest("Removed NPC " + target.getObjectId());
|
||||
LOGGER.finest("Removed NPC " + target.getObjectId());
|
||||
}
|
||||
}
|
||||
_log.info("All visible NPCs deleted in Region: " + getName());
|
||||
LOGGER.info("All visible NPCs deleted in Region: " + this);
|
||||
}
|
||||
|
||||
public boolean forEachSurroundingRegion(Predicate<L2WorldRegion> p)
|
||||
{
|
||||
for (int x = _regionX - 1; x <= (_regionX + 1); x++)
|
||||
{
|
||||
for (int y = _regionY - 1; y <= (_regionY + 1); y++)
|
||||
{
|
||||
for (int z = _regionZ - 1; z <= (_regionZ + 1); z++)
|
||||
{
|
||||
if (L2World.validRegion(x, y, z))
|
||||
{
|
||||
final L2WorldRegion worldRegion = L2World.getInstance().getWorldRegions()[x][y][z];
|
||||
if (!p.test(worldRegion))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getRegionX()
|
||||
{
|
||||
return _regionX;
|
||||
}
|
||||
|
||||
public int getRegionY()
|
||||
{
|
||||
return _regionY;
|
||||
}
|
||||
|
||||
public int getRegionZ()
|
||||
{
|
||||
return _regionZ;
|
||||
}
|
||||
|
||||
public boolean isSurroundingRegion(L2WorldRegion region)
|
||||
{
|
||||
return (region != null) && (getRegionX() >= (region.getRegionX() - 1)) && (getRegionX() <= (region.getRegionX() + 1)) && (getRegionY() >= (region.getRegionY() - 1)) && (getRegionY() <= (region.getRegionY() + 1)) && (getRegionZ() >= (region.getRegionZ() - 1)) && (getRegionZ() <= (region.getRegionZ() + 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "(" + _regionX + ", " + _regionY + ", " + _regionZ + ")";
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,6 @@ import com.l2jmobius.gameserver.model.actor.instance.L2GrandBossInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ServitorInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.AttackableKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.status.AttackableStatus;
|
||||
import com.l2jmobius.gameserver.model.actor.tasks.attackable.CommandChannelTimer;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
@ -119,18 +118,6 @@ public class L2Attackable extends L2Npc
|
||||
_mustGiveExpSp = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttackableKnownList getKnownList()
|
||||
{
|
||||
return (AttackableKnownList) super.getKnownList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new AttackableKnownList(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttackableStatus getStatus()
|
||||
{
|
||||
@ -454,7 +441,7 @@ public class L2Attackable extends L2Npc
|
||||
if (attackerParty == null)
|
||||
{
|
||||
// Calculate Exp and SP rewards
|
||||
if (attacker.getKnownList().knowsObject(this))
|
||||
if (isInSurroundingRegion(attacker))
|
||||
{
|
||||
// Calculate the difference of level between this attacker (player or servitor owner) and the L2Attackable
|
||||
// mob = 24, atk = 10, diff = -14 (full xp)
|
||||
@ -906,7 +893,7 @@ public class L2Attackable extends L2Npc
|
||||
}
|
||||
}
|
||||
|
||||
if (!ai.getAttacker().isVisible() || ai.getAttacker().isInvisible())
|
||||
if (!ai.getAttacker().isSpawned() || ai.getAttacker().isInvisible())
|
||||
{
|
||||
_aggroList.remove(target);
|
||||
return 0;
|
||||
|
@ -68,7 +68,6 @@ import com.l2jmobius.gameserver.model.TeleportWhereType;
|
||||
import com.l2jmobius.gameserver.model.TimeStamp;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.CharKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.stat.CharStat;
|
||||
import com.l2jmobius.gameserver.model.actor.status.CharStatus;
|
||||
import com.l2jmobius.gameserver.model.actor.tasks.character.FlyToLocationTask;
|
||||
@ -267,6 +266,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
protected Future<?> _skillCast;
|
||||
protected Future<?> _skillCast2;
|
||||
|
||||
private final Map<Integer, Integer> _knownRelations = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Creates a creature.
|
||||
* @param template the creature template
|
||||
@ -536,14 +537,13 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
*/
|
||||
public void broadcastPacket(IClientOutgoingPacket mov)
|
||||
{
|
||||
final Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
|
||||
for (L2PcInstance player : plrs)
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, player ->
|
||||
{
|
||||
if (player != null)
|
||||
if (isVisibleFor(player))
|
||||
{
|
||||
player.sendPacket(mov);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -556,14 +556,13 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
*/
|
||||
public void broadcastPacket(IClientOutgoingPacket mov, int radiusInKnownlist)
|
||||
{
|
||||
final Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
|
||||
for (L2PcInstance player : plrs)
|
||||
L2World.getInstance().forEachVisibleObjectInRange(this, L2PcInstance.class, radiusInKnownlist, player ->
|
||||
{
|
||||
if ((player != null) && isInsideRadius(player, radiusInKnownlist, false, false))
|
||||
if (isVisibleFor(player))
|
||||
{
|
||||
player.sendPacket(mov);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -666,7 +665,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
doRevive();
|
||||
}
|
||||
|
||||
stopMove(null, false);
|
||||
stopMove(null);
|
||||
abortAttack();
|
||||
abortCast();
|
||||
|
||||
@ -878,7 +877,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
|
||||
if (!isAlikeDead())
|
||||
{
|
||||
if ((isNpc() && target.isAlikeDead()) || !getKnownList().knowsObject(target))
|
||||
if ((isNpc() && target.isAlikeDead()) || !isInSurroundingRegion(target))
|
||||
{
|
||||
getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
@ -970,8 +969,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
return;
|
||||
}
|
||||
|
||||
target.getKnownList().addKnownObject(this);
|
||||
|
||||
final L2Weapon weaponItem = getActiveWeaponItem();
|
||||
final int timeAtk = calculateTimeBetweenAttacks();
|
||||
final int timeToHit = timeAtk / 2;
|
||||
@ -1353,64 +1350,45 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
|
||||
boolean hitted = doAttackHitSimple(attack, target, 100, sAtk);
|
||||
double attackpercent = 85;
|
||||
L2Character temp;
|
||||
final Collection<L2Object> objs = getKnownList().getKnownObjects().values();
|
||||
|
||||
for (L2Object obj : objs)
|
||||
for (L2Character obj : L2World.getInstance().getVisibleObjects(this, L2Character.class, maxRadius))
|
||||
{
|
||||
if (obj == target)
|
||||
{
|
||||
continue; // do not hit twice
|
||||
}
|
||||
// Check if the L2Object is a L2Character
|
||||
if (obj instanceof L2Character)
|
||||
|
||||
if (obj.isPet() && isPlayer() && (((L2PetInstance) obj).getOwner() == getActingPlayer()))
|
||||
{
|
||||
if (obj.isPet() && isPlayer() && (((L2PetInstance) obj).getOwner() == getActingPlayer()))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isFacing(obj, maxAngleDiff))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isAttackable() && obj.isPlayer() && getTarget().isAttackable())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isAttackable() && obj.isAttackable() && !((L2Attackable) this).isChaos())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Launch a simple attack against the L2Character targeted
|
||||
if (!obj.isAlikeDead())
|
||||
{
|
||||
if ((obj == getAI().getAttackTarget()) || obj.isAutoAttackable(this))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Util.checkIfInRange(maxRadius, this, obj, false))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// otherwise hit too high/low. 650 because mob z coord
|
||||
// sometimes wrong on hills
|
||||
if (Math.abs(obj.getZ() - getZ()) > 650)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!isFacing(obj, maxAngleDiff))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isAttackable() && obj.isPlayer() && getTarget().isAttackable())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isAttackable() && obj.isAttackable() && !((L2Attackable) this).isChaos())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
temp = (L2Character) obj;
|
||||
|
||||
// Launch a simple attack against the L2Character targeted
|
||||
if (!temp.isAlikeDead())
|
||||
{
|
||||
if ((temp == getAI().getAttackTarget()) || temp.isAutoAttackable(this))
|
||||
hitted |= doAttackHitSimple(attack, obj, attackpercent, sAtk);
|
||||
attackpercent /= 1.15;
|
||||
|
||||
attackcount++;
|
||||
if (attackcount > attackRandomCountMax)
|
||||
{
|
||||
hitted |= doAttackHitSimple(attack, temp, attackpercent, sAtk);
|
||||
attackpercent /= 1.15;
|
||||
|
||||
attackcount++;
|
||||
if (attackcount > attackRandomCountMax)
|
||||
{
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2851,14 +2829,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
else if (isNpc())
|
||||
{
|
||||
final Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
|
||||
for (L2PcInstance player : plrs)
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, player ->
|
||||
{
|
||||
if ((player == null) || !isVisibleFor(player))
|
||||
if (!isVisibleFor(player))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
else if (getRunSpeed() == 0)
|
||||
|
||||
if (getRunSpeed() == 0)
|
||||
{
|
||||
player.sendPacket(new ServerObjectInfo((L2Npc) this, player));
|
||||
}
|
||||
@ -2866,7 +2844,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
{
|
||||
player.sendPacket(new AbstractNpcInfo.NpcInfo((L2Npc) this, player));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -2941,18 +2919,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
_isFlying = mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharKnownList getKnownList()
|
||||
{
|
||||
return ((CharKnownList) super.getKnownList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new CharKnownList(this));
|
||||
}
|
||||
|
||||
public CharStat getStat()
|
||||
{
|
||||
return _stat;
|
||||
@ -3465,23 +3431,13 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
*/
|
||||
public final void addStatFuncs(List<AbstractFunction> functions)
|
||||
{
|
||||
if (!isPlayer() && getKnownList().getKnownPlayers().isEmpty())
|
||||
final List<Stats> modifiedStats = new ArrayList<>();
|
||||
for (AbstractFunction f : functions)
|
||||
{
|
||||
for (AbstractFunction f : functions)
|
||||
{
|
||||
addStatFunc(f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final List<Stats> modifiedStats = new ArrayList<>();
|
||||
for (AbstractFunction f : functions)
|
||||
{
|
||||
modifiedStats.add(f.getStat());
|
||||
addStatFunc(f);
|
||||
}
|
||||
broadcastModifiedStats(modifiedStats);
|
||||
modifiedStats.add(f.getStat());
|
||||
addStatFunc(f);
|
||||
}
|
||||
broadcastModifiedStats(modifiedStats);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3560,24 +3516,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
*/
|
||||
public final void removeStatFuncs(AbstractFunction[] functions)
|
||||
{
|
||||
if (!isPlayer() && getKnownList().getKnownPlayers().isEmpty())
|
||||
final List<Stats> modifiedStats = new ArrayList<>();
|
||||
for (AbstractFunction f : functions)
|
||||
{
|
||||
for (AbstractFunction f : functions)
|
||||
{
|
||||
removeStatFunc(f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final List<Stats> modifiedStats = new ArrayList<>();
|
||||
for (AbstractFunction f : functions)
|
||||
{
|
||||
modifiedStats.add(f.getStat());
|
||||
removeStatFunc(f);
|
||||
}
|
||||
|
||||
broadcastModifiedStats(modifiedStats);
|
||||
modifiedStats.add(f.getStat());
|
||||
removeStatFunc(f);
|
||||
}
|
||||
|
||||
broadcastModifiedStats(modifiedStats);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3710,13 +3656,13 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
{
|
||||
if (broadcastFull)
|
||||
{
|
||||
final Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
|
||||
for (L2PcInstance player : plrs)
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, player ->
|
||||
{
|
||||
if ((player == null) || !isVisibleFor(player))
|
||||
if (!isVisibleFor(player))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
if (getRunSpeed() == 0)
|
||||
{
|
||||
player.sendPacket(new ServerObjectInfo((L2Npc) this, player));
|
||||
@ -3725,7 +3671,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
{
|
||||
player.sendPacket(new AbstractNpcInfo.NpcInfo((L2Npc) this, player));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (su.hasAttributes())
|
||||
{
|
||||
@ -3943,7 +3889,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isVisible())
|
||||
if (!isSpawned())
|
||||
{
|
||||
_move = null;
|
||||
return true;
|
||||
@ -4050,23 +3996,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
|
||||
if (distFraction > 1)
|
||||
{
|
||||
ThreadPool.execute(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Config.MOVE_BASED_KNOWNLIST)
|
||||
{
|
||||
getKnownList().findObjects();
|
||||
}
|
||||
|
||||
getAI().notifyEvent(CtrlEvent.EVT_ARRIVED);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
_log.log(Level.WARNING, "", e);
|
||||
}
|
||||
});
|
||||
|
||||
ThreadPool.execute(() -> getAI().notifyEvent(CtrlEvent.EVT_ARRIVED));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -4075,11 +4005,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
|
||||
public void revalidateZone(boolean force)
|
||||
{
|
||||
if (getWorldRegion() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// This function is called too often from movement code
|
||||
if (force)
|
||||
{
|
||||
@ -4114,11 +4039,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
* @param loc
|
||||
*/
|
||||
public void stopMove(Location loc)
|
||||
{
|
||||
stopMove(loc, false);
|
||||
}
|
||||
|
||||
public void stopMove(Location loc, boolean updateKnownObjects)
|
||||
{
|
||||
// Delete movement data of the L2Character
|
||||
_move = null;
|
||||
@ -4132,10 +4052,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
revalidateZone(true);
|
||||
}
|
||||
broadcastPacket(new StopMove(this));
|
||||
if (Config.MOVE_BASED_KNOWNLIST && updateKnownObjects)
|
||||
{
|
||||
getKnownList().findObjects();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4169,17 +4085,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
*/
|
||||
public void setTarget(L2Object object)
|
||||
{
|
||||
if ((object != null) && !object.isVisible())
|
||||
if ((object != null) && !object.isSpawned())
|
||||
{
|
||||
object = null;
|
||||
}
|
||||
|
||||
if ((object != null) && (object != _target))
|
||||
{
|
||||
getKnownList().addKnownObject(object);
|
||||
object.getKnownList().addKnownObject(this);
|
||||
}
|
||||
|
||||
_target = object;
|
||||
}
|
||||
|
||||
@ -4727,7 +4637,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
return;
|
||||
}
|
||||
|
||||
if ((isNpc() && target.isAlikeDead()) || target.isDead() || (!getKnownList().knowsObject(target) && !isDoor()))
|
||||
if ((isNpc() && target.isAlikeDead()) || target.isDead() || (!isInSurroundingRegion(target) && !isDoor()))
|
||||
{
|
||||
// getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE, null);
|
||||
// Some times attack is processed but target die before the hit
|
||||
@ -5815,52 +5725,43 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
|
||||
// Mobs in range 1000 see spell
|
||||
final Collection<L2Object> objs = player.getKnownList().getKnownObjects().values();
|
||||
for (L2Object spMob : objs)
|
||||
L2World.getInstance().forEachVisibleObjectInRange(player, L2Npc.class, 1000, npcMob ->
|
||||
{
|
||||
if ((spMob != null) && spMob.isNpc())
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcSkillSee(npcMob, player, skill, targets, isSummon()), npcMob);
|
||||
|
||||
// On Skill See logic
|
||||
if (npcMob.isAttackable())
|
||||
{
|
||||
final L2Npc npcMob = (L2Npc) spMob;
|
||||
if ((npcMob.isInsideRadius(player, 1000, true, true)))
|
||||
final L2Attackable attackable = (L2Attackable) npcMob;
|
||||
|
||||
int skillEffectPoint = skill.getEffectPoint();
|
||||
|
||||
if (player.hasSummon())
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcSkillSee(npcMob, player, skill, targets, isSummon()), npcMob);
|
||||
|
||||
// On Skill See logic
|
||||
if (npcMob.isAttackable())
|
||||
if ((targets.length == 1) && Util.contains(targets, player.getSummon()))
|
||||
{
|
||||
final L2Attackable attackable = (L2Attackable) npcMob;
|
||||
|
||||
int skillEffectPoint = skill.getEffectPoint();
|
||||
|
||||
if (player.hasSummon())
|
||||
skillEffectPoint = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (skillEffectPoint > 0)
|
||||
{
|
||||
if (attackable.hasAI() && (attackable.getAI().getIntention() == AI_INTENTION_ATTACK))
|
||||
{
|
||||
L2Object npcTarget = attackable.getTarget();
|
||||
for (L2Object skillTarget : targets)
|
||||
{
|
||||
if ((targets.length == 1) && Util.contains(targets, player.getSummon()))
|
||||
if ((npcTarget == skillTarget) || (npcMob == skillTarget))
|
||||
{
|
||||
skillEffectPoint = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (skillEffectPoint > 0)
|
||||
{
|
||||
if (attackable.hasAI() && (attackable.getAI().getIntention() == AI_INTENTION_ATTACK))
|
||||
{
|
||||
final L2Object npcTarget = attackable.getTarget();
|
||||
for (L2Object skillTarget : targets)
|
||||
{
|
||||
if ((npcTarget == skillTarget) || (npcMob == skillTarget))
|
||||
{
|
||||
final L2Character originalCaster = isSummon() ? getSummon() : player;
|
||||
attackable.addDamageHate(originalCaster, 0, (skillEffectPoint * 150) / (attackable.getLevel() + 7));
|
||||
}
|
||||
}
|
||||
L2Character originalCaster = isSummon() ? this : player;
|
||||
attackable.addDamageHate(originalCaster, 0, (skillEffectPoint * 150) / (attackable.getLevel() + 7));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Notify AI
|
||||
if (skill.isBad() && !skill.hasEffectType(L2EffectType.HATE))
|
||||
{
|
||||
@ -6853,6 +6754,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final Map<Integer, Integer> getKnownRelations()
|
||||
{
|
||||
return _knownRelations;
|
||||
}
|
||||
|
||||
public int getMinShopDistance()
|
||||
{
|
||||
return 0;
|
||||
|
@ -17,6 +17,7 @@
|
||||
package com.l2jmobius.gameserver.model.actor;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2CharTemplate;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
@ -55,13 +56,13 @@ public abstract class L2Decoy extends L2Character
|
||||
@Override
|
||||
public void updateAbnormalEffect()
|
||||
{
|
||||
for (L2PcInstance player : getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, player ->
|
||||
{
|
||||
if (player != null)
|
||||
if (isVisibleFor(player))
|
||||
{
|
||||
player.sendPacket(new CharInfo(this, false));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void stopDecay()
|
||||
@ -120,13 +121,12 @@ public abstract class L2Decoy extends L2Character
|
||||
public void deleteMe(L2PcInstance owner)
|
||||
{
|
||||
decayMe();
|
||||
getKnownList().removeAllKnownObjects();
|
||||
owner.setDecoy(null);
|
||||
}
|
||||
|
||||
public synchronized void unSummon(L2PcInstance owner)
|
||||
{
|
||||
if (!isVisible() || isDead())
|
||||
if (!isSpawned() || isDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -136,7 +136,6 @@ public abstract class L2Decoy extends L2Character
|
||||
}
|
||||
owner.setDecoy(null);
|
||||
decayMe();
|
||||
getKnownList().removeAllKnownObjects();
|
||||
}
|
||||
|
||||
public final L2PcInstance getOwner()
|
||||
|
@ -63,7 +63,6 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2TeleporterInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2TrainerInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2WarehouseInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.NpcKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.stat.NpcStat;
|
||||
import com.l2jmobius.gameserver.model.actor.status.NpcStatus;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
@ -273,7 +272,7 @@ public class L2Npc extends L2Character
|
||||
_npc.onRandomAnimation(Rnd.get(2, 3));
|
||||
}
|
||||
|
||||
_npc.startRandomAnimationTimer();
|
||||
_npc.startRandomAnimationTask();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -299,7 +298,7 @@ public class L2Npc extends L2Character
|
||||
/**
|
||||
* Create a RandomAnimation Task that will be launched after the calculated delay.
|
||||
*/
|
||||
public void startRandomAnimationTimer()
|
||||
public void startRandomAnimationTask()
|
||||
{
|
||||
if (!hasRandomAnimation())
|
||||
{
|
||||
@ -342,18 +341,6 @@ public class L2Npc extends L2Character
|
||||
return _isRandomAnimationEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NpcKnownList getKnownList()
|
||||
{
|
||||
return (NpcKnownList) super.getKnownList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new NpcKnownList(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NpcStat getStat()
|
||||
{
|
||||
@ -446,14 +433,13 @@ public class L2Npc extends L2Character
|
||||
@Override
|
||||
public void updateAbnormalEffect()
|
||||
{
|
||||
// Send a Server->Client packet NpcInfo with state of abnormal effect to all L2PcInstance in the _KnownPlayers of the L2NpcInstance
|
||||
final Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
|
||||
for (L2PcInstance player : plrs)
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, player ->
|
||||
{
|
||||
if ((player == null) || !isVisibleFor(player))
|
||||
if (!isVisibleFor(player))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
if (getRunSpeed() == 0)
|
||||
{
|
||||
player.sendPacket(new ServerObjectInfo(this, player));
|
||||
@ -462,7 +448,7 @@ public class L2Npc extends L2Character
|
||||
{
|
||||
player.sendPacket(new AbstractNpcInfo.NpcInfo(this, player));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isEventMob()
|
||||
@ -1365,16 +1351,6 @@ public class L2Npc extends L2Character
|
||||
oldRegion.removeFromZones(this);
|
||||
}
|
||||
|
||||
// Remove all L2Object from _knownObjects and _knownPlayer of the L2Character then cancel Attack or Cast and notify AI
|
||||
try
|
||||
{
|
||||
getKnownList().removeAllKnownObjects();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Failed removing cleaning knownlist.", e);
|
||||
}
|
||||
|
||||
// Remove L2Object object from _allObjects of L2World
|
||||
L2World.getInstance().removeObject(this);
|
||||
|
||||
@ -1747,13 +1723,13 @@ public class L2Npc extends L2Character
|
||||
*/
|
||||
public void broadcastEvent(String eventName, int radius, L2Object reference)
|
||||
{
|
||||
for (L2Object obj : L2World.getInstance().getVisibleObjects(this, radius))
|
||||
L2World.getInstance().forEachVisibleObjectInRange(this, L2Npc.class, radius, obj ->
|
||||
{
|
||||
if (obj.isNpc() && obj.hasListener(EventType.ON_NPC_EVENT_RECEIVED))
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcEventReceived(eventName, this, (L2Npc) obj, reference), obj);
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcEventReceived(eventName, this, obj, reference), obj);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,6 @@ import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.PlayableKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.stat.PlayableStat;
|
||||
import com.l2jmobius.gameserver.model.actor.status.PlayableStatus;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2CharTemplate;
|
||||
@ -67,18 +66,6 @@ public abstract class L2Playable extends L2Character
|
||||
setIsInvul(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayableKnownList getKnownList()
|
||||
{
|
||||
return (PlayableKnownList) super.getKnownList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new PlayableKnownList(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayableStat getStat()
|
||||
{
|
||||
|
@ -34,10 +34,10 @@ import com.l2jmobius.gameserver.instancemanager.TerritoryWarManager;
|
||||
import com.l2jmobius.gameserver.model.AggroInfo;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Party;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.L2WorldRegion;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.SummonKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.stat.SummonStat;
|
||||
import com.l2jmobius.gameserver.model.actor.status.SummonStatus;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
@ -118,10 +118,10 @@ public abstract class L2Summon extends L2Playable
|
||||
setFollowStatus(true);
|
||||
updateAndBroadcastStatus(0);
|
||||
sendPacket(new RelationChanged(this, getOwner().getRelation(getOwner()), false));
|
||||
for (L2PcInstance player : getOwner().getKnownList().getKnownPlayersInRadius(800))
|
||||
L2World.getInstance().forEachVisibleObjectInRange(getOwner(), L2PcInstance.class, 800, player ->
|
||||
{
|
||||
player.sendPacket(new RelationChanged(this, getOwner().getRelation(player), isAutoAttackable(player)));
|
||||
}
|
||||
});
|
||||
final L2Party party = getOwner().getParty();
|
||||
if (party != null)
|
||||
{
|
||||
@ -137,18 +137,6 @@ public abstract class L2Summon extends L2Playable
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSummonSpawn(this), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SummonKnownList getKnownList()
|
||||
{
|
||||
return (SummonKnownList) super.getKnownList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new SummonKnownList(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SummonStat getStat()
|
||||
{
|
||||
@ -205,10 +193,10 @@ public abstract class L2Summon extends L2Playable
|
||||
@Override
|
||||
public void updateAbnormalEffect()
|
||||
{
|
||||
for (L2PcInstance player : getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, player ->
|
||||
{
|
||||
player.sendPacket(new SummonInfo(this, player, 1));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -314,23 +302,19 @@ public abstract class L2Summon extends L2Playable
|
||||
final L2PcInstance owner = getOwner();
|
||||
if (owner != null)
|
||||
{
|
||||
for (L2Character TgMob : getKnownList().getKnownCharacters())
|
||||
L2World.getInstance().forEachVisibleObject(this, L2Attackable.class, TgMob ->
|
||||
{
|
||||
// get the mobs which have aggro on the this instance
|
||||
if (TgMob instanceof L2Attackable)
|
||||
if (TgMob.isDead())
|
||||
{
|
||||
if (TgMob.isDead())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final AggroInfo info = ((L2Attackable) TgMob).getAggroList().get(this);
|
||||
if (info != null)
|
||||
{
|
||||
((L2Attackable) TgMob).addDamageHate(owner, info.getDamage(), info.getHate());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AggroInfo info = TgMob.getAggroList().get(this);
|
||||
if (info != null)
|
||||
{
|
||||
TgMob.addDamageHate(owner, info.getDamage(), info.getHate());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
DecayTaskManager.getInstance().add(this);
|
||||
@ -386,7 +370,6 @@ public abstract class L2Summon extends L2Playable
|
||||
getInventory().destroyAllItems("pet deleted", getOwner(), this);
|
||||
}
|
||||
decayMe();
|
||||
getKnownList().removeAllKnownObjects();
|
||||
if (owner != null)
|
||||
{
|
||||
owner.setPet(null);
|
||||
@ -396,7 +379,7 @@ public abstract class L2Summon extends L2Playable
|
||||
|
||||
public void unSummon(L2PcInstance owner)
|
||||
{
|
||||
if (isVisible() && !isDead())
|
||||
if (isSpawned() && !isDead())
|
||||
{
|
||||
getAI().stopFollow();
|
||||
if (owner != null)
|
||||
@ -440,7 +423,7 @@ public abstract class L2Summon extends L2Playable
|
||||
{
|
||||
oldRegion.removeFromZones(this);
|
||||
}
|
||||
getKnownList().removeAllKnownObjects();
|
||||
|
||||
setTarget(null);
|
||||
if (owner != null)
|
||||
{
|
||||
@ -861,7 +844,7 @@ public abstract class L2Summon extends L2Playable
|
||||
|
||||
sendPacket(new PetInfo(this, val));
|
||||
sendPacket(new PetStatusUpdate(this));
|
||||
if (isVisible())
|
||||
if (isSpawned())
|
||||
{
|
||||
broadcastNpcInfo(val);
|
||||
}
|
||||
@ -875,14 +858,14 @@ public abstract class L2Summon extends L2Playable
|
||||
|
||||
public void broadcastNpcInfo(int val)
|
||||
{
|
||||
for (L2PcInstance player : getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, player ->
|
||||
{
|
||||
if ((player == null) || (player == getOwner()))
|
||||
if ((player == getOwner()))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
player.sendPacket(new SummonInfo(this, player, val));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isHungry()
|
||||
|
@ -16,12 +16,10 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.actor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import com.l2jmobius.gameserver.GameTimeController;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
@ -33,7 +31,6 @@ import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.TeleportWhereType;
|
||||
import com.l2jmobius.gameserver.model.VehiclePathPoint;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.VehicleKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.stat.VehicleStat;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2CharTemplate;
|
||||
import com.l2jmobius.gameserver.model.interfaces.ILocational;
|
||||
@ -181,12 +178,6 @@ public abstract class L2Vehicle extends L2Character
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new VehicleKnownList(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VehicleStat getStat()
|
||||
{
|
||||
@ -290,38 +281,26 @@ public abstract class L2Vehicle extends L2Character
|
||||
*/
|
||||
public void payForRide(int itemId, int count, int oustX, int oustY, int oustZ)
|
||||
{
|
||||
final Collection<L2PcInstance> passengers = getKnownList().getKnownPlayersInRadius(1000);
|
||||
if ((passengers == null) || passengers.isEmpty())
|
||||
L2World.getInstance().forEachVisibleObjectInRange(this, L2PcInstance.class, 1000, player ->
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2ItemInstance ticket;
|
||||
InventoryUpdate iu;
|
||||
for (L2PcInstance player : passengers)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (player.isInBoat() && (player.getBoat() == this))
|
||||
{
|
||||
if (itemId > 0)
|
||||
{
|
||||
ticket = player.getInventory().getItemByItemId(itemId);
|
||||
L2ItemInstance ticket = player.getInventory().getItemByItemId(itemId);
|
||||
if ((ticket == null) || (player.getInventory().destroyItem("Boat", ticket, count, player, this) == null))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_POSSESS_THE_CORRECT_TICKET_TO_BOARD_THE_BOAT);
|
||||
player.teleToLocation(new Location(oustX, oustY, oustZ), true);
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
iu = new InventoryUpdate();
|
||||
InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addModifiedItem(ticket);
|
||||
player.sendPacket(iu);
|
||||
}
|
||||
addPassenger(player);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -346,7 +325,7 @@ public abstract class L2Vehicle extends L2Character
|
||||
{
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(null, false);
|
||||
stopMove(null);
|
||||
}
|
||||
|
||||
setIsTeleporting(true);
|
||||
@ -362,7 +341,7 @@ public abstract class L2Vehicle extends L2Character
|
||||
}
|
||||
|
||||
decayMe();
|
||||
setXYZ(loc.getX(), loc.getY(), loc.getZ());
|
||||
setXYZ(loc);
|
||||
|
||||
// temporary fix for heading on teleports
|
||||
if (loc.getHeading() != 0)
|
||||
@ -375,20 +354,15 @@ public abstract class L2Vehicle extends L2Character
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopMove(Location loc, boolean updateKnownObjects)
|
||||
public void stopMove(Location loc)
|
||||
{
|
||||
_move = null;
|
||||
if (loc != null)
|
||||
{
|
||||
setXYZ(loc.getX(), loc.getY(), loc.getZ());
|
||||
setXYZ(loc);
|
||||
setHeading(loc.getHeading());
|
||||
revalidateZone(true);
|
||||
}
|
||||
|
||||
if (Config.MOVE_BASED_KNOWNLIST && updateKnownObjects)
|
||||
{
|
||||
getKnownList().findObjects();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -417,7 +391,7 @@ public abstract class L2Vehicle extends L2Character
|
||||
_log.log(Level.SEVERE, "Failed oustPlayers().", e);
|
||||
}
|
||||
|
||||
final L2WorldRegion oldRegion = getWorldRegion();
|
||||
final L2WorldRegion oldZoneRegion = getWorldRegion();
|
||||
|
||||
try
|
||||
{
|
||||
@ -428,18 +402,9 @@ public abstract class L2Vehicle extends L2Character
|
||||
_log.log(Level.SEVERE, "Failed decayMe().", e);
|
||||
}
|
||||
|
||||
if (oldRegion != null)
|
||||
if (oldZoneRegion != null)
|
||||
{
|
||||
oldRegion.removeFromZones(this);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
getKnownList().removeAllKnownObjects();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Failed cleaning knownlist.", e);
|
||||
oldZoneRegion.removeFromZones(this);
|
||||
}
|
||||
|
||||
// Remove L2Object object from _allObjects of L2World
|
||||
|
@ -131,7 +131,6 @@ public class L2AirShipInstance extends L2Vehicle
|
||||
player.setVehicle(this);
|
||||
player.setInVehiclePosition(new Location(0, 0, 0));
|
||||
player.broadcastPacket(new ExGetOnAirShip(player, this));
|
||||
player.getKnownList().removeAllKnownObjects();
|
||||
player.setXYZ(getX(), getY(), getZ());
|
||||
player.revalidateZone(true);
|
||||
player.stopMove(null);
|
||||
@ -146,7 +145,6 @@ public class L2AirShipInstance extends L2Vehicle
|
||||
if (player.isOnline())
|
||||
{
|
||||
player.broadcastPacket(new ExGetOffAirShip(player, this, loc.getX(), loc.getY(), loc.getZ()));
|
||||
player.getKnownList().removeAllKnownObjects();
|
||||
player.setXYZ(loc.getX(), loc.getY(), loc.getZ());
|
||||
player.revalidateZone(true);
|
||||
}
|
||||
@ -169,9 +167,9 @@ public class L2AirShipInstance extends L2Vehicle
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopMove(Location loc, boolean updateKnownObjects)
|
||||
public void stopMove(Location loc)
|
||||
{
|
||||
super.stopMove(loc, updateKnownObjects);
|
||||
super.stopMove(loc);
|
||||
|
||||
broadcastPacket(new ExStopMoveAirShip(this));
|
||||
}
|
||||
|
@ -86,9 +86,9 @@ public class L2BoatInstance extends L2Vehicle
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopMove(Location loc, boolean updateKnownObjects)
|
||||
public void stopMove(Location loc)
|
||||
{
|
||||
super.stopMove(loc, updateKnownObjects);
|
||||
super.stopMove(loc);
|
||||
|
||||
broadcastPacket(new VehicleStarted(this, 0));
|
||||
broadcastPacket(new VehicleInfo(this));
|
||||
|
@ -327,7 +327,7 @@ public class L2ControllableAirShipInstance extends L2AirShipInstance
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (isVisible() && isEmpty() && !isInDock())
|
||||
if (isSpawned() && isEmpty() && !isInDock())
|
||||
{
|
||||
// deleteMe() can't be called from CheckTask because task should not cancel itself
|
||||
ThreadPool.execute(new DecayTask());
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user