Dropped knownlists.
This commit is contained in:
@@ -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());
|
||||
|
@@ -470,7 +470,7 @@ public final class L2CubicInstance implements IIdentifiable
|
||||
{
|
||||
targetIt = false;
|
||||
}
|
||||
if (!enemy.isVisible())
|
||||
if (!enemy.isSpawned())
|
||||
{
|
||||
targetIt = false;
|
||||
}
|
||||
|
@@ -24,7 +24,6 @@ import com.l2jmobius.gameserver.datatables.SkillData;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Decoy;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.DecoyKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.taskmanager.DecayTaskManager;
|
||||
@@ -70,18 +69,6 @@ public class L2DecoyInstance extends L2Decoy
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DecoyKnownList getKnownList()
|
||||
{
|
||||
return (DecoyKnownList) super.getKnownList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new DecoyKnownList(this));
|
||||
}
|
||||
|
||||
static class DecoyLifetime implements Runnable
|
||||
{
|
||||
private final L2PcInstance _activeChar;
|
||||
|
@@ -28,7 +28,6 @@ import com.l2jmobius.gameserver.instancemanager.TerritoryWarManager;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.DefenderKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.gameserver.model.entity.Castle;
|
||||
import com.l2jmobius.gameserver.model.entity.Fort;
|
||||
@@ -51,18 +50,6 @@ public class L2DefenderInstance extends L2Attackable
|
||||
setInstanceType(InstanceType.L2DefenderInstance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefenderKnownList getKnownList()
|
||||
{
|
||||
return (DefenderKnownList) super.getKnownList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new DefenderKnownList(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected L2CharacterAI initAI()
|
||||
{
|
||||
|
@@ -16,9 +16,7 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.actor.instance;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
@@ -36,11 +34,10 @@ import com.l2jmobius.gameserver.instancemanager.FortManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.TerritoryWarManager;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
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.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.DoorKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.stat.DoorStat;
|
||||
import com.l2jmobius.gameserver.model.actor.status.DoorStatus;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2DoorTemplate;
|
||||
@@ -130,18 +127,6 @@ public class L2DoorInstance extends L2Character
|
||||
ThreadPool.schedule(new TimerOpen(), delay * 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DoorKnownList getKnownList()
|
||||
{
|
||||
return (DoorKnownList) super.getKnownList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new DoorKnownList(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public L2DoorTemplate getTemplate()
|
||||
{
|
||||
@@ -232,7 +217,7 @@ public class L2DoorInstance extends L2Character
|
||||
/**
|
||||
* @return Returns the open.
|
||||
*/
|
||||
public boolean getOpen()
|
||||
public boolean isOpen()
|
||||
{
|
||||
return _open;
|
||||
}
|
||||
@@ -433,7 +418,7 @@ public class L2DoorInstance extends L2Character
|
||||
@Override
|
||||
public void broadcastStatusUpdate()
|
||||
{
|
||||
final Collection<L2PcInstance> knownPlayers = getKnownList().getKnownPlayers().values();
|
||||
Collection<L2PcInstance> knownPlayers = L2World.getInstance().getVisibleObjects(this, L2PcInstance.class);
|
||||
if ((knownPlayers == null) || knownPlayers.isEmpty())
|
||||
{
|
||||
return;
|
||||
@@ -445,7 +430,7 @@ public class L2DoorInstance extends L2Character
|
||||
OnEventTrigger oe = null;
|
||||
if (getEmitter() > 0)
|
||||
{
|
||||
oe = new OnEventTrigger(this, getOpen());
|
||||
oe = new OnEventTrigger(this, isOpen());
|
||||
}
|
||||
|
||||
for (L2PcInstance player : knownPlayers)
|
||||
@@ -514,7 +499,7 @@ public class L2DoorInstance extends L2Character
|
||||
first = door;
|
||||
}
|
||||
|
||||
if (door.getOpen() != open)
|
||||
if (door.isOpen() != open)
|
||||
{
|
||||
door.setOpen(open);
|
||||
door.broadcastStatusUpdate();
|
||||
@@ -579,19 +564,6 @@ public class L2DoorInstance extends L2Character
|
||||
return getTemplate().getNodeZ() + getTemplate().getHeight();
|
||||
}
|
||||
|
||||
public List<L2DefenderInstance> getKnownDefenders()
|
||||
{
|
||||
final List<L2DefenderInstance> result = new ArrayList<>();
|
||||
for (L2Object obj : getKnownList().getKnownObjects().values())
|
||||
{
|
||||
if (obj instanceof L2DefenderInstance)
|
||||
{
|
||||
result.add((L2DefenderInstance) obj);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setMeshIndex(int mesh)
|
||||
{
|
||||
_meshindex = mesh;
|
||||
@@ -694,7 +666,7 @@ public class L2DoorInstance extends L2Character
|
||||
{
|
||||
if (getEmitter() > 0)
|
||||
{
|
||||
activeChar.sendPacket(new OnEventTrigger(this, getOpen()));
|
||||
activeChar.sendPacket(new OnEventTrigger(this, isOpen()));
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new StaticObject(this, activeChar.isGM()));
|
||||
@@ -759,7 +731,7 @@ public class L2DoorInstance extends L2Character
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (getOpen())
|
||||
if (isOpen())
|
||||
{
|
||||
closeMe();
|
||||
}
|
||||
@@ -771,7 +743,7 @@ public class L2DoorInstance extends L2Character
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final boolean open = getOpen();
|
||||
final boolean open = isOpen();
|
||||
if (open)
|
||||
{
|
||||
closeMe();
|
||||
|
@@ -19,7 +19,6 @@ package com.l2jmobius.gameserver.model.actor.instance;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.FriendlyMobKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
|
||||
/**
|
||||
@@ -38,18 +37,6 @@ public class L2FriendlyMobInstance extends L2Attackable
|
||||
setInstanceType(InstanceType.L2FriendlyMobInstance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final FriendlyMobKnownList getKnownList()
|
||||
{
|
||||
return (FriendlyMobKnownList) super.getKnownList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new FriendlyMobKnownList(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoAttackable(L2Character attacker)
|
||||
{
|
||||
|
@@ -16,20 +16,17 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.actor.instance;
|
||||
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.L2WorldRegion;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.GuardKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcFirstTalk;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SocialAction;
|
||||
|
||||
/**
|
||||
* This class manages all Guards in the world. It inherits all methods from L2Attackable and adds some more such as tracking PK and aggressive L2MonsterInstance.
|
||||
@@ -46,24 +43,16 @@ public class L2GuardInstance extends L2Attackable
|
||||
setInstanceType(InstanceType.L2GuardInstance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final GuardKnownList getKnownList()
|
||||
{
|
||||
return (GuardKnownList) super.getKnownList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new GuardKnownList(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return True if hte attacker is a L2MonsterInstance.
|
||||
*/
|
||||
@Override
|
||||
public boolean isAutoAttackable(L2Character attacker)
|
||||
{
|
||||
if (attacker.isPlayer())
|
||||
{
|
||||
return ((L2PcInstance) attacker).getKarma() > 0;
|
||||
}
|
||||
return attacker instanceof L2MonsterInstance;
|
||||
}
|
||||
|
||||
@@ -77,7 +66,7 @@ public class L2GuardInstance extends L2Attackable
|
||||
super.onSpawn();
|
||||
|
||||
// check the region where this mob is, do not activate the AI if region is inactive.
|
||||
final L2WorldRegion region = L2World.getInstance().getRegion(getX(), getY());
|
||||
final L2WorldRegion region = L2World.getInstance().getRegion(this);
|
||||
if ((region != null) && (!region.isActive()))
|
||||
{
|
||||
getAI().stopAITask();
|
||||
@@ -161,10 +150,6 @@ public class L2GuardInstance extends L2Attackable
|
||||
}
|
||||
else
|
||||
{
|
||||
// Send a Server->Client packet SocialAction to the all L2PcInstance on the _knownPlayer of the L2NpcInstance
|
||||
// to display a social action of the L2GuardInstance on their client
|
||||
broadcastPacket(new SocialAction(getObjectId(), Rnd.nextInt(8)));
|
||||
|
||||
player.setLastFolkNPC(this);
|
||||
|
||||
// Open a chat window on client with the text of the L2GuardInstance
|
||||
|
@@ -21,7 +21,6 @@ import java.util.concurrent.ScheduledFuture;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.MonsterKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.gameserver.util.MinionList;
|
||||
|
||||
@@ -55,18 +54,6 @@ public class L2MonsterInstance extends L2Attackable
|
||||
setAutoAttackable(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final MonsterKnownList getKnownList()
|
||||
{
|
||||
return (MonsterKnownList) super.getKnownList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new MonsterKnownList(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return True if the attacker is not another L2MonsterInstance.
|
||||
*/
|
||||
|
@@ -155,7 +155,6 @@ import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Summon;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Vehicle;
|
||||
import com.l2jmobius.gameserver.model.actor.appearance.PcAppearance;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.PcKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.stat.PcStat;
|
||||
import com.l2jmobius.gameserver.model.actor.status.PcStatus;
|
||||
import com.l2jmobius.gameserver.model.actor.tasks.player.DismountTask;
|
||||
@@ -1158,18 +1157,6 @@ public final class L2PcInstance extends L2Playable
|
||||
_mpUpdateDecCheck = getMaxMp() - _mpUpdateInterval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final PcKnownList getKnownList()
|
||||
{
|
||||
return (PcKnownList) super.getKnownList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new PcKnownList(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final PcStat getStat()
|
||||
{
|
||||
@@ -1692,16 +1679,14 @@ public final class L2PcInstance extends L2Playable
|
||||
sendPacket(new RelationChanged(getSummon(), getRelation(this), false));
|
||||
}
|
||||
|
||||
final Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
|
||||
|
||||
for (L2PcInstance target : plrs)
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, target ->
|
||||
{
|
||||
target.sendPacket(new RelationChanged(this, getRelation(target), isAutoAttackable(target)));
|
||||
if (hasSummon())
|
||||
{
|
||||
target.sendPacket(new RelationChanged(getSummon(), getRelation(target), isAutoAttackable(target)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1951,20 +1936,13 @@ public final class L2PcInstance extends L2Playable
|
||||
}
|
||||
if ((_karma == 0) && (karma > 0))
|
||||
{
|
||||
final Collection<L2Object> objs = getKnownList().getKnownObjects().values();
|
||||
|
||||
for (L2Object object : objs)
|
||||
L2World.getInstance().forEachVisibleObject(this, L2GuardInstance.class, object ->
|
||||
{
|
||||
if (!(object instanceof L2GuardInstance))
|
||||
if (object.getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE)
|
||||
{
|
||||
continue;
|
||||
object.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE, null);
|
||||
}
|
||||
|
||||
if (((L2GuardInstance) object).getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE)
|
||||
{
|
||||
((L2GuardInstance) object).getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else if ((_karma > 0) && (karma == 0))
|
||||
{
|
||||
@@ -4120,7 +4098,7 @@ public final class L2PcInstance extends L2Playable
|
||||
public final void broadcastCharInfo()
|
||||
{
|
||||
final CharInfo charInfo = new CharInfo(this, false);
|
||||
for (L2PcInstance player : getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, player ->
|
||||
{
|
||||
if (isVisibleFor(player))
|
||||
{
|
||||
@@ -4133,7 +4111,7 @@ public final class L2PcInstance extends L2Playable
|
||||
player.sendPacket(charInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public final void broadcastTitleInfo()
|
||||
@@ -4155,27 +4133,28 @@ public final class L2PcInstance extends L2Playable
|
||||
sendPacket(mov);
|
||||
}
|
||||
|
||||
for (L2PcInstance player : getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, player ->
|
||||
{
|
||||
if ((player == null) || !isVisibleFor(player))
|
||||
if (!isVisibleFor(player))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
player.sendPacket(mov);
|
||||
if (mov instanceof CharInfo)
|
||||
{
|
||||
final int relation = getRelation(player);
|
||||
final Integer oldrelation = getKnownList().getKnownRelations().get(player.getObjectId());
|
||||
Integer oldrelation = getKnownRelations().get(player.getObjectId());
|
||||
if ((oldrelation != null) && (oldrelation != relation))
|
||||
{
|
||||
player.sendPacket(new RelationChanged(this, relation, isAutoAttackable(player)));
|
||||
if (hasSummon())
|
||||
{
|
||||
player.sendPacket(new RelationChanged(getSummon(), relation, isAutoAttackable(player)));
|
||||
// getKnownRelations().put(player.getObjectId(), relation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -4186,30 +4165,29 @@ public final class L2PcInstance extends L2Playable
|
||||
sendPacket(mov);
|
||||
}
|
||||
|
||||
for (L2PcInstance player : getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, player ->
|
||||
{
|
||||
if (player == null)
|
||||
if (!isVisibleFor(player) || (calculateDistance(player, true, false) >= radiusInKnownlist))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
if (isInsideRadius(player, radiusInKnownlist, false, false))
|
||||
|
||||
player.sendPacket(mov);
|
||||
if (mov instanceof CharInfo)
|
||||
{
|
||||
player.sendPacket(mov);
|
||||
if (mov instanceof CharInfo)
|
||||
final int relation = getRelation(player);
|
||||
final Integer oldrelation = getKnownRelations().get(player.getObjectId());
|
||||
if ((oldrelation != null) && (oldrelation != relation))
|
||||
{
|
||||
final int relation = getRelation(player);
|
||||
final Integer oldrelation = getKnownList().getKnownRelations().get(player.getObjectId());
|
||||
if ((oldrelation != null) && (oldrelation != relation))
|
||||
player.sendPacket(new RelationChanged(this, relation, isAutoAttackable(player)));
|
||||
if (hasSummon())
|
||||
{
|
||||
player.sendPacket(new RelationChanged(this, relation, isAutoAttackable(player)));
|
||||
if (hasSummon())
|
||||
{
|
||||
player.sendPacket(new RelationChanged(getSummon(), relation, isAutoAttackable(player)));
|
||||
}
|
||||
player.sendPacket(new RelationChanged(getSummon(), relation, isAutoAttackable(player)));
|
||||
}
|
||||
getKnownRelations().put(player.getObjectId(), relation);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4374,7 +4352,7 @@ public final class L2PcInstance extends L2Playable
|
||||
synchronized (target)
|
||||
{
|
||||
// Check if the target to pick up is visible
|
||||
if (!target.isVisible())
|
||||
if (!target.isSpawned())
|
||||
{
|
||||
// Send a Server->Client packet ActionFailed to this L2PcInstance
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
@@ -4546,7 +4524,7 @@ public final class L2PcInstance extends L2Playable
|
||||
{
|
||||
if ((Config.SHOP_MIN_RANGE_FROM_NPC > 0) || (Config.SHOP_MIN_RANGE_FROM_PLAYER > 0))
|
||||
{
|
||||
for (L2Character cha : getKnownList().getKnownCharacters())
|
||||
for (L2Character cha : L2World.getInstance().getVisibleObjects(this, L2Character.class))
|
||||
{
|
||||
if (Util.checkIfInRange(cha.getMinShopDistance(), this, cha, true))
|
||||
{
|
||||
@@ -4749,7 +4727,7 @@ public final class L2PcInstance extends L2Playable
|
||||
}
|
||||
|
||||
// Check if the new target is visible
|
||||
if ((newTarget != null) && !isInParty && !newTarget.isVisible())
|
||||
if ((newTarget != null) && !isInParty && !newTarget.isSpawned())
|
||||
{
|
||||
newTarget = null;
|
||||
}
|
||||
@@ -6548,15 +6526,14 @@ public final class L2PcInstance extends L2Playable
|
||||
{
|
||||
sendPacket(new UserInfo(this));
|
||||
sendPacket(new ExBrExtraUserInfo(this));
|
||||
final Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
|
||||
for (L2PcInstance player : plrs)
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, player ->
|
||||
{
|
||||
player.sendPacket(new RelationChanged(this, getRelation(player), isAutoAttackable(player)));
|
||||
if (hasSummon())
|
||||
{
|
||||
player.sendPacket(new RelationChanged(getSummon(), getRelation(player), isAutoAttackable(player)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6568,14 +6545,14 @@ public final class L2PcInstance extends L2Playable
|
||||
su.addAttribute(StatusUpdate.KARMA, getKarma());
|
||||
sendPacket(su);
|
||||
|
||||
for (L2PcInstance player : getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, player ->
|
||||
{
|
||||
player.sendPacket(new RelationChanged(this, getRelation(player), isAutoAttackable(player)));
|
||||
if (hasSummon())
|
||||
{
|
||||
player.sendPacket(new RelationChanged(getSummon(), getRelation(player), isAutoAttackable(player)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -11451,16 +11428,6 @@ public final class L2PcInstance extends L2Playable
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all L2Object from _knownObjects and _knownPlayer of the L2Character then cancel Attak or Cast and notify AI
|
||||
try
|
||||
{
|
||||
getKnownList().removeAllKnownObjects();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "deleteMe()", e);
|
||||
}
|
||||
|
||||
if (getClanId() > 0)
|
||||
{
|
||||
getClan().broadcastToOtherOnlineMembers(new PledgeShowMemberListUpdate(this), this);
|
||||
@@ -13020,7 +12987,7 @@ public final class L2PcInstance extends L2Playable
|
||||
activeChar.sendPacket(new ExBrExtraUserInfo(this));
|
||||
final int relation1 = getRelation(activeChar);
|
||||
final int relation2 = activeChar.getRelation(this);
|
||||
Integer oldrelation = getKnownList().getKnownRelations().get(activeChar.getObjectId());
|
||||
Integer oldrelation = getKnownRelations().get(activeChar.getObjectId());
|
||||
if ((oldrelation != null) && (oldrelation != relation1))
|
||||
{
|
||||
activeChar.sendPacket(new RelationChanged(this, relation1, isAutoAttackable(activeChar)));
|
||||
@@ -13029,7 +12996,7 @@ public final class L2PcInstance extends L2Playable
|
||||
activeChar.sendPacket(new RelationChanged(getSummon(), relation1, isAutoAttackable(activeChar)));
|
||||
}
|
||||
}
|
||||
oldrelation = activeChar.getKnownList().getKnownRelations().get(getObjectId());
|
||||
oldrelation = activeChar.getKnownRelations().get(getObjectId());
|
||||
if ((oldrelation != null) && (oldrelation != relation2))
|
||||
{
|
||||
sendPacket(new RelationChanged(activeChar, relation2, activeChar.isAutoAttackable(this)));
|
||||
@@ -13047,7 +13014,7 @@ public final class L2PcInstance extends L2Playable
|
||||
activeChar.sendPacket(new ExBrExtraUserInfo(this));
|
||||
final int relation1 = getRelation(activeChar);
|
||||
final int relation2 = activeChar.getRelation(this);
|
||||
Integer oldrelation = getKnownList().getKnownRelations().get(activeChar.getObjectId());
|
||||
Integer oldrelation = getKnownRelations().get(activeChar.getObjectId());
|
||||
if ((oldrelation != null) && (oldrelation != relation1))
|
||||
{
|
||||
activeChar.sendPacket(new RelationChanged(this, relation1, isAutoAttackable(activeChar)));
|
||||
@@ -13056,7 +13023,7 @@ public final class L2PcInstance extends L2Playable
|
||||
activeChar.sendPacket(new RelationChanged(getSummon(), relation1, isAutoAttackable(activeChar)));
|
||||
}
|
||||
}
|
||||
oldrelation = activeChar.getKnownList().getKnownRelations().get(getObjectId());
|
||||
oldrelation = activeChar.getKnownRelations().get(getObjectId());
|
||||
if ((oldrelation != null) && (oldrelation != relation2))
|
||||
{
|
||||
sendPacket(new RelationChanged(activeChar, relation2, activeChar.isAutoAttackable(this)));
|
||||
@@ -13073,7 +13040,7 @@ public final class L2PcInstance extends L2Playable
|
||||
activeChar.sendPacket(new ExBrExtraUserInfo(this));
|
||||
final int relation1 = getRelation(activeChar);
|
||||
final int relation2 = activeChar.getRelation(this);
|
||||
Integer oldrelation = getKnownList().getKnownRelations().get(activeChar.getObjectId());
|
||||
Integer oldrelation = getKnownRelations().get(activeChar.getObjectId());
|
||||
if ((oldrelation != null) && (oldrelation != relation1))
|
||||
{
|
||||
activeChar.sendPacket(new RelationChanged(this, relation1, isAutoAttackable(activeChar)));
|
||||
@@ -13082,7 +13049,7 @@ public final class L2PcInstance extends L2Playable
|
||||
activeChar.sendPacket(new RelationChanged(getSummon(), relation1, isAutoAttackable(activeChar)));
|
||||
}
|
||||
}
|
||||
oldrelation = activeChar.getKnownList().getKnownRelations().get(getObjectId());
|
||||
oldrelation = activeChar.getKnownRelations().get(getObjectId());
|
||||
if ((oldrelation != null) && (oldrelation != relation2))
|
||||
{
|
||||
sendPacket(new RelationChanged(activeChar, relation2, activeChar.isAutoAttackable(this)));
|
||||
|
@@ -490,7 +490,7 @@ public class L2PetInstance extends L2Summon
|
||||
synchronized (target)
|
||||
{
|
||||
// Check if the target to pick up is visible
|
||||
if (!target.isVisible())
|
||||
if (!target.isSpawned())
|
||||
{
|
||||
// Send a Server->Client packet ActionFailed to this L2PcInstance
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
@@ -24,7 +24,6 @@ import com.l2jmobius.gameserver.MonsterRace;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.idfactory.IdFactory;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.RaceManagerKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
@@ -127,18 +126,6 @@ public class L2RaceManagerInstance extends L2Npc
|
||||
_managers.add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final RaceManagerKnownList getKnownList()
|
||||
{
|
||||
return (RaceManagerKnownList) super.getKnownList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new RaceManagerKnownList(this));
|
||||
}
|
||||
|
||||
class Announcement implements Runnable
|
||||
{
|
||||
private final SystemMessageId _type;
|
||||
|
@@ -380,7 +380,7 @@ public class L2SepulcherMonsterInstance extends L2MonsterInstance
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_activeChar.isVisible())
|
||||
if (!_activeChar.isSpawned())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -406,7 +406,7 @@ public class L2SepulcherMonsterInstance extends L2MonsterInstance
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_activeChar.isVisible())
|
||||
if (!_activeChar.isSpawned())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -401,7 +401,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
|
||||
final int usedtime = 5000;
|
||||
_lifeTimeRemaining -= usedtime;
|
||||
|
||||
if (isDead() || !isVisible())
|
||||
if (isDead() || !isSpawned())
|
||||
{
|
||||
if (_summonLifeTask != null)
|
||||
{
|
||||
|
@@ -20,7 +20,6 @@ import com.l2jmobius.gameserver.ai.L2CharacterAI;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.StaticObjectKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.stat.StaticObjStat;
|
||||
import com.l2jmobius.gameserver.model.actor.status.StaticObjStatus;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2CharTemplate;
|
||||
@@ -72,18 +71,6 @@ public final class L2StaticObjectInstance extends L2Character
|
||||
return _staticObjectId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final StaticObjectKnownList getKnownList()
|
||||
{
|
||||
return (StaticObjectKnownList) super.getKnownList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new StaticObjectKnownList(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final StaticObjStat getStat()
|
||||
{
|
||||
|
@@ -23,10 +23,10 @@ import java.util.concurrent.ScheduledFuture;
|
||||
import com.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.enums.TrapAction;
|
||||
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.knownlist.TrapKnownList;
|
||||
import com.l2jmobius.gameserver.model.actor.tasks.npc.trap.TrapTask;
|
||||
import com.l2jmobius.gameserver.model.actor.tasks.npc.trap.TrapTriggerTask;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
@@ -103,25 +103,25 @@ public final class L2TrapInstance extends L2Npc
|
||||
@Override
|
||||
public void broadcastPacket(IClientOutgoingPacket mov)
|
||||
{
|
||||
for (L2PcInstance player : getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObject(this, L2PcInstance.class, player ->
|
||||
{
|
||||
if ((player != null) && (_isTriggered || canBeSeen(player)))
|
||||
if (_isTriggered || canBeSeen(player))
|
||||
{
|
||||
player.sendPacket(mov);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastPacket(IClientOutgoingPacket mov, int radiusInKnownlist)
|
||||
{
|
||||
for (L2PcInstance player : getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObjectInRange(this, L2PcInstance.class, radiusInKnownlist, player ->
|
||||
{
|
||||
if ((player != null) && isInsideRadius(player, radiusInKnownlist, false, false) && (_isTriggered || canBeSeen(player)))
|
||||
if (_isTriggered || canBeSeen(player))
|
||||
{
|
||||
player.sendPacket(mov);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,12 +251,6 @@ public final class L2TrapInstance extends L2Npc
|
||||
return _owner != null ? _owner.getKarma() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrapKnownList getKnownList()
|
||||
{
|
||||
return (TrapKnownList) super.getKnownList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the owner of this trap.
|
||||
* @return the owner
|
||||
@@ -288,12 +282,6 @@ public final class L2TrapInstance extends L2Npc
|
||||
return _skill.getSkill();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new TrapKnownList(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoAttackable(L2Character attacker)
|
||||
{
|
||||
@@ -426,7 +414,7 @@ public final class L2TrapInstance extends L2Npc
|
||||
_owner = null;
|
||||
}
|
||||
|
||||
if (isVisible() && !isDead())
|
||||
if (isSpawned() && !isDead())
|
||||
{
|
||||
if (getWorldRegion() != null)
|
||||
{
|
||||
|
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public class AttackableKnownList extends NpcKnownList
|
||||
{
|
||||
public AttackableKnownList(L2Attackable activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean removeKnownObject(L2Object object, boolean forget)
|
||||
{
|
||||
if (!super.removeKnownObject(object, forget))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove the L2Object from the _aggrolist of the L2Attackable
|
||||
if (object instanceof L2Character)
|
||||
{
|
||||
getActiveChar().getAggroList().remove(object);
|
||||
}
|
||||
// Set the L2Attackable Intention to AI_INTENTION_IDLE
|
||||
final Collection<L2PcInstance> known = getKnownPlayers().values();
|
||||
|
||||
// FIXME: This is a temporary solution && support for Walking Manager
|
||||
if (getActiveChar().hasAI() && ((known == null) || known.isEmpty()) && !getActiveChar().isWalker())
|
||||
{
|
||||
getActiveChar().getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public L2Attackable getActiveChar()
|
||||
{
|
||||
return (L2Attackable) super.getActiveChar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToForgetObject(L2Object object)
|
||||
{
|
||||
return (int) (getDistanceToWatchObject(object) * 1.5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToWatchObject(L2Object object)
|
||||
{
|
||||
if (!(object instanceof L2Character))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (object.isPlayable())
|
||||
{
|
||||
return object.getKnownList().getDistanceToWatchObject(getActiveObject());
|
||||
}
|
||||
|
||||
return Math.max(300, Math.max(getActiveChar().getAggroRange(), getActiveChar().getTemplate().getClanHelpRange()));
|
||||
}
|
||||
}
|
@@ -1,256 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Summon;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
public class CharKnownList extends ObjectKnownList
|
||||
{
|
||||
private volatile Map<Integer, L2PcInstance> _knownPlayers = new ConcurrentHashMap<>();
|
||||
private volatile Map<Integer, L2Summon> _knownSummons = new ConcurrentHashMap<>();
|
||||
private volatile Map<Integer, Integer> _knownRelations = new ConcurrentHashMap<>();
|
||||
|
||||
public CharKnownList(L2Character activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addKnownObject(L2Object object)
|
||||
{
|
||||
if (!super.addKnownObject(object))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (object.isPlayer())
|
||||
{
|
||||
getKnownPlayers().put(object.getObjectId(), object.getActingPlayer());
|
||||
getKnownRelations().put(object.getObjectId(), -1);
|
||||
}
|
||||
else if (object.isSummon())
|
||||
{
|
||||
getKnownSummons().put(object.getObjectId(), (L2Summon) object);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player The L2PcInstance to search in _knownPlayer
|
||||
* @return {@code true} if the player is in _knownPlayer of the character, {@code false} otherwise
|
||||
*/
|
||||
public final boolean knowsThePlayer(L2PcInstance player)
|
||||
{
|
||||
return (getActiveChar() == player) || getKnownPlayers().containsKey(player.getObjectId());
|
||||
}
|
||||
|
||||
/** Remove all L2Object from _knownObjects and _knownPlayer of the L2Character then cancel Attack or Cast and notify AI. */
|
||||
@Override
|
||||
public final void removeAllKnownObjects()
|
||||
{
|
||||
super.removeAllKnownObjects();
|
||||
getKnownPlayers().clear();
|
||||
getKnownRelations().clear();
|
||||
getKnownSummons().clear();
|
||||
|
||||
// Set _target of the L2Character to null
|
||||
// Cancel Attack or Cast
|
||||
getActiveChar().setTarget(null);
|
||||
|
||||
// Cancel AI Task
|
||||
if (getActiveChar().hasAI())
|
||||
{
|
||||
getActiveChar().setAI(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean removeKnownObject(L2Object object, boolean forget)
|
||||
{
|
||||
if (!super.removeKnownObject(object, forget))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!forget) // on forget objects removed by iterator
|
||||
{
|
||||
if (object.isPlayer())
|
||||
{
|
||||
getKnownPlayers().remove(object.getObjectId());
|
||||
getKnownRelations().remove(object.getObjectId());
|
||||
}
|
||||
else if (object.isSummon())
|
||||
{
|
||||
getKnownSummons().remove(object.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
// If object is targeted by the L2Character, cancel Attack or Cast
|
||||
if (object == getActiveChar().getTarget())
|
||||
{
|
||||
getActiveChar().setTarget(null);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forgetObjects(boolean fullCheck)
|
||||
{
|
||||
if (!fullCheck)
|
||||
{
|
||||
final Iterator<L2PcInstance> pIter = getKnownPlayers().values().iterator();
|
||||
while (pIter.hasNext())
|
||||
{
|
||||
final L2PcInstance player = pIter.next();
|
||||
if (player == null)
|
||||
{
|
||||
pIter.remove();
|
||||
}
|
||||
else if (!player.isVisible() || !Util.checkIfInShortRange(getDistanceToForgetObject(player), getActiveObject(), player, true))
|
||||
{
|
||||
pIter.remove();
|
||||
removeKnownObject(player, true);
|
||||
getKnownRelations().remove(player.getObjectId());
|
||||
getKnownObjects().remove(player.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
final Iterator<L2Summon> sIter = getKnownSummons().values().iterator();
|
||||
while (sIter.hasNext())
|
||||
{
|
||||
final L2Summon summon = sIter.next();
|
||||
if (summon == null)
|
||||
{
|
||||
sIter.remove();
|
||||
}
|
||||
else if (getActiveChar().isPlayer() && (summon.getOwner() == getActiveChar()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (!summon.isVisible() || !Util.checkIfInShortRange(getDistanceToForgetObject(summon), getActiveObject(), summon, true))
|
||||
{
|
||||
sIter.remove();
|
||||
removeKnownObject(summon, true);
|
||||
getKnownObjects().remove(summon.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
// Go through knownObjects
|
||||
final Iterator<L2Object> oIter = getKnownObjects().values().iterator();
|
||||
while (oIter.hasNext())
|
||||
{
|
||||
final L2Object object = oIter.next();
|
||||
if (object == null)
|
||||
{
|
||||
oIter.remove();
|
||||
}
|
||||
else if (!object.isVisible() || !Util.checkIfInShortRange(getDistanceToForgetObject(object), getActiveObject(), object, true))
|
||||
{
|
||||
oIter.remove();
|
||||
removeKnownObject(object, true);
|
||||
|
||||
if (object.isPlayer())
|
||||
{
|
||||
getKnownPlayers().remove(object.getObjectId());
|
||||
getKnownRelations().remove(object.getObjectId());
|
||||
}
|
||||
else if (object.isSummon())
|
||||
{
|
||||
getKnownSummons().remove(object.getObjectId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public L2Character getActiveChar()
|
||||
{
|
||||
return (L2Character) super.getActiveObject();
|
||||
}
|
||||
|
||||
public List<L2Character> getKnownCharacters()
|
||||
{
|
||||
final List<L2Character> result = new LinkedList<>();
|
||||
for (L2Object obj : getKnownObjects().values())
|
||||
{
|
||||
if (obj instanceof L2Character)
|
||||
{
|
||||
result.add((L2Character) obj);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<L2Character> getKnownCharactersInRadius(long radius)
|
||||
{
|
||||
final List<L2Character> result = new LinkedList<>();
|
||||
for (L2Object obj : getKnownObjects().values())
|
||||
{
|
||||
if ((obj instanceof L2Character) && Util.checkIfInRange((int) radius, getActiveChar(), obj, true))
|
||||
{
|
||||
result.add((L2Character) obj);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public final List<L2PcInstance> getKnownPlayersInRadius(long radius)
|
||||
{
|
||||
final List<L2PcInstance> result = new LinkedList<>();
|
||||
for (L2PcInstance player : getKnownPlayers().values())
|
||||
{
|
||||
if (Util.checkIfInRange((int) radius, getActiveChar(), player, true))
|
||||
{
|
||||
result.add(player);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public final Map<Integer, L2PcInstance> getKnownPlayers()
|
||||
{
|
||||
return _knownPlayers;
|
||||
}
|
||||
|
||||
public final Map<Integer, Integer> getKnownRelations()
|
||||
{
|
||||
return _knownRelations;
|
||||
}
|
||||
|
||||
public final Map<Integer, L2Summon> getKnownSummons()
|
||||
{
|
||||
return _knownSummons;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString()
|
||||
{
|
||||
return getActiveChar() + " Known Objects " + getKnownObjects();
|
||||
}
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Decoy;
|
||||
|
||||
public class DecoyKnownList extends CharKnownList
|
||||
{
|
||||
public DecoyKnownList(L2Decoy activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final L2Decoy getActiveChar()
|
||||
{
|
||||
return (L2Decoy) super.getActiveChar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToForgetObject(L2Object object)
|
||||
{
|
||||
if ((object == getActiveChar().getOwner()) || (object == getActiveChar().getTarget()))
|
||||
{
|
||||
return 6000;
|
||||
}
|
||||
return 3000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToWatchObject(L2Object object)
|
||||
{
|
||||
return 1500;
|
||||
}
|
||||
}
|
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.instancemanager.TerritoryWarManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2DefenderInstance;
|
||||
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.entity.clanhall.SiegableHall;
|
||||
|
||||
public class DefenderKnownList extends AttackableKnownList
|
||||
{
|
||||
public DefenderKnownList(L2DefenderInstance activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addKnownObject(L2Object object)
|
||||
{
|
||||
if (!super.addKnownObject(object))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Castle castle = getActiveChar().getCastle();
|
||||
final Fort fortress = getActiveChar().getFort();
|
||||
final SiegableHall hall = getActiveChar().getConquerableHall();
|
||||
// Check if siege is in progress
|
||||
if (((fortress != null) && fortress.getZone().isActive()) || ((castle != null) && castle.getZone().isActive()) || ((hall != null) && hall.getSiegeZone().isActive()))
|
||||
{
|
||||
L2PcInstance player = null;
|
||||
if (object.isPlayable())
|
||||
{
|
||||
player = object.getActingPlayer();
|
||||
}
|
||||
final int activeSiegeId = fortress != null ? fortress.getResidenceId() : (castle != null ? castle.getResidenceId() : hall != null ? hall.getId() : 0);
|
||||
|
||||
// Check if player is an enemy of this defender npc
|
||||
if ((player != null) && (((player.getSiegeState() == 2) && !player.isRegisteredOnThisSiegeField(activeSiegeId)) || ((player.getSiegeState() == 1) && !TerritoryWarManager.getInstance().isAllyField(player, activeSiegeId)) || (player.getSiegeState() == 0)))
|
||||
{
|
||||
if (getActiveChar().getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE)
|
||||
{
|
||||
getActiveChar().getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final L2DefenderInstance getActiveChar()
|
||||
{
|
||||
return (L2DefenderInstance) super.getActiveChar();
|
||||
}
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2DefenderInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
|
||||
|
||||
public class DoorKnownList extends CharKnownList
|
||||
{
|
||||
public DoorKnownList(L2DoorInstance activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final L2DoorInstance getActiveChar()
|
||||
{
|
||||
return (L2DoorInstance) super.getActiveChar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToForgetObject(L2Object object)
|
||||
{
|
||||
if (object instanceof L2DefenderInstance)
|
||||
{
|
||||
return 800;
|
||||
}
|
||||
else if (!object.isPlayer())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 4000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToWatchObject(L2Object object)
|
||||
{
|
||||
if (object instanceof L2DefenderInstance)
|
||||
{
|
||||
return 600;
|
||||
}
|
||||
else if (!object.isPlayer())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 3500;
|
||||
}
|
||||
}
|
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlEvent;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2FriendlyMobInstance;
|
||||
|
||||
public class FriendlyMobKnownList extends AttackableKnownList
|
||||
{
|
||||
public FriendlyMobKnownList(L2FriendlyMobInstance activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addKnownObject(L2Object object)
|
||||
{
|
||||
if (!super.addKnownObject(object))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (object.isPlayer() && (getActiveChar().getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE))
|
||||
{
|
||||
getActiveChar().getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE, null);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean removeKnownObject(L2Object object, boolean forget)
|
||||
{
|
||||
if (!super.removeKnownObject(object, forget))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(object instanceof L2Character))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getActiveChar().hasAI())
|
||||
{
|
||||
getActiveChar().getAI().notifyEvent(CtrlEvent.EVT_FORGET_OBJECT, object);
|
||||
if (getActiveChar().getTarget() == object)
|
||||
{
|
||||
getActiveChar().setTarget(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (getActiveChar().isVisible() && getKnownPlayers().isEmpty() && getKnownSummons().isEmpty())
|
||||
{
|
||||
getActiveChar().clearAggroList();
|
||||
if (getActiveChar().hasAI())
|
||||
{
|
||||
getActiveChar().getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final L2FriendlyMobInstance getActiveChar()
|
||||
{
|
||||
return (L2FriendlyMobInstance) super.getActiveChar();
|
||||
}
|
||||
}
|
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2GuardInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
|
||||
|
||||
public class GuardKnownList extends AttackableKnownList
|
||||
{
|
||||
public GuardKnownList(L2GuardInstance activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addKnownObject(L2Object object)
|
||||
{
|
||||
if (!super.addKnownObject(object))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (object.isPlayer())
|
||||
{
|
||||
// Check if the object added is a L2PcInstance that owns Karma
|
||||
if (object.getActingPlayer().getKarma() > 0)
|
||||
{
|
||||
// Set the L2GuardInstance Intention to AI_INTENTION_ACTIVE
|
||||
if (getActiveChar().getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE)
|
||||
{
|
||||
getActiveChar().getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((Config.GUARD_ATTACK_AGGRO_MOB && getActiveChar().isInActiveRegion()) && object.isMonster())
|
||||
{
|
||||
// Check if the object added is an aggressive L2MonsterInstance
|
||||
if (((L2MonsterInstance) object).isAggressive())
|
||||
{
|
||||
// Set the L2GuardInstance Intention to AI_INTENTION_ACTIVE
|
||||
if (getActiveChar().getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE)
|
||||
{
|
||||
getActiveChar().getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean removeKnownObject(L2Object object, boolean forget)
|
||||
{
|
||||
if (!super.removeKnownObject(object, forget))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the aggression list of this guard is empty.
|
||||
if (getActiveChar().getAggroList().isEmpty())
|
||||
{
|
||||
// Set the L2GuardInstance to AI_INTENTION_IDLE
|
||||
if (getActiveChar().hasAI() && !getActiveChar().isWalker())
|
||||
{
|
||||
getActiveChar().getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final L2GuardInstance getActiveChar()
|
||||
{
|
||||
return (L2GuardInstance) super.getActiveChar();
|
||||
}
|
||||
}
|
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlEvent;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.ai.L2CharacterAI;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public class MonsterKnownList extends AttackableKnownList
|
||||
{
|
||||
public MonsterKnownList(L2MonsterInstance activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addKnownObject(L2Object object)
|
||||
{
|
||||
if (!super.addKnownObject(object))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2CharacterAI ai = getActiveChar().getAI(); // force AI creation
|
||||
|
||||
// Set the L2MonsterInstance Intention to AI_INTENTION_ACTIVE if the state was AI_INTENTION_IDLE
|
||||
if ((object instanceof L2PcInstance) && (ai != null) && (ai.getIntention() == CtrlIntention.AI_INTENTION_IDLE))
|
||||
{
|
||||
ai.setIntention(CtrlIntention.AI_INTENTION_ACTIVE, null);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean removeKnownObject(L2Object object, boolean forget)
|
||||
{
|
||||
if (!super.removeKnownObject(object, forget))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(object instanceof L2Character))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getActiveChar().hasAI())
|
||||
{
|
||||
// Notify the L2MonsterInstance AI with EVT_FORGET_OBJECT
|
||||
getActiveChar().getAI().notifyEvent(CtrlEvent.EVT_FORGET_OBJECT, object);
|
||||
}
|
||||
|
||||
if (getActiveChar().isVisible() && getKnownPlayers().isEmpty() && getKnownSummons().isEmpty())
|
||||
{
|
||||
// Clear the _aggroList of the L2MonsterInstance
|
||||
getActiveChar().clearAggroList();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final L2MonsterInstance getActiveChar()
|
||||
{
|
||||
return (L2MonsterInstance) super.getActiveChar();
|
||||
}
|
||||
}
|
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import com.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.instancemanager.WalkingManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
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.L2FestivalGuideInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcCreatureSee;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MoveToLocation;
|
||||
|
||||
public class NpcKnownList extends CharKnownList
|
||||
{
|
||||
private ScheduledFuture<?> _trackingTask = null;
|
||||
|
||||
public NpcKnownList(L2Npc activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addKnownObject(L2Object object)
|
||||
{
|
||||
if (!super.addKnownObject(object))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getActiveObject().isNpc() && (object instanceof L2Character))
|
||||
{
|
||||
// Broadcast correct walking NPC position.
|
||||
if (object.isPlayer() && getActiveChar().isMoving() && !getActiveChar().isInCombat())
|
||||
{
|
||||
((L2Character) object).broadcastPacket(new MoveToLocation(getActiveChar()));
|
||||
}
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcCreatureSee(getActiveChar(), (L2Character) object, object.isSummon()), getActiveChar());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public L2Npc getActiveChar()
|
||||
{
|
||||
return (L2Npc) super.getActiveChar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToForgetObject(L2Object object)
|
||||
{
|
||||
return 2 * getDistanceToWatchObject(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToWatchObject(L2Object object)
|
||||
{
|
||||
if (!(object instanceof L2Character))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (object instanceof L2FestivalGuideInstance)
|
||||
{
|
||||
return 4000;
|
||||
}
|
||||
|
||||
if (object.isPlayable())
|
||||
{
|
||||
return 1500;
|
||||
}
|
||||
|
||||
return 500;
|
||||
}
|
||||
|
||||
// Support for Walking monsters aggro
|
||||
public void startTrackingTask()
|
||||
{
|
||||
if ((_trackingTask == null) && (getActiveChar().getAggroRange() > 0))
|
||||
{
|
||||
_trackingTask = ThreadPool.scheduleAtFixedRate(new TrackingTask(), 2000, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
// Support for Walking monsters aggro
|
||||
public void stopTrackingTask()
|
||||
{
|
||||
if (_trackingTask == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_trackingTask.cancel(true);
|
||||
_trackingTask = null;
|
||||
}
|
||||
|
||||
// Support for Walking monsters aggro
|
||||
protected class TrackingTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!getActiveChar().isAttackable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Attackable monster = (L2Attackable) getActiveChar();
|
||||
if (monster.getAI().getIntention() != CtrlIntention.AI_INTENTION_MOVE_TO)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (L2PcInstance pl : getKnownPlayers().values())
|
||||
{
|
||||
if (!pl.isDead() && !pl.isInvul() && pl.isInsideRadius(monster, monster.getAggroRange(), true, false) && (monster.isMonster() || (monster.isInstanceTypes(InstanceType.L2GuardInstance) && (pl.getKarma() > 0))))
|
||||
{
|
||||
// Send aggroRangeEnter
|
||||
if (monster.getHating(pl) == 0)
|
||||
{
|
||||
monster.addDamageHate(pl, 0, 0);
|
||||
}
|
||||
|
||||
// Skip attack for other targets, if one is already chosen for attack
|
||||
if ((monster.getAI().getIntention() != CtrlIntention.AI_INTENTION_ATTACK) && !monster.isCoreAIDisabled())
|
||||
{
|
||||
WalkingManager.getInstance().stopMoving(getActiveChar(), false, true);
|
||||
monster.addDamageHate(pl, 0, 100);
|
||||
monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, pl, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
|
||||
public class NullKnownList extends ObjectKnownList
|
||||
{
|
||||
public NullKnownList(L2Object activeObject)
|
||||
{
|
||||
super(activeObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addKnownObject(L2Object object)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public L2Object getActiveObject()
|
||||
{
|
||||
return super.getActiveObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToForgetObject(L2Object object)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToWatchObject(L2Object object)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllKnownObjects()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean removeKnownObject(L2Object object, boolean forget)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -1,202 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2WorldRegion;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
public class ObjectKnownList
|
||||
{
|
||||
private final L2Object _activeObject;
|
||||
private volatile Map<Integer, L2Object> _knownObjects = new ConcurrentHashMap<>();
|
||||
|
||||
public ObjectKnownList(L2Object activeObject)
|
||||
{
|
||||
_activeObject = activeObject;
|
||||
}
|
||||
|
||||
public boolean addKnownObject(L2Object object)
|
||||
{
|
||||
if (object == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Instance -1 is for GMs that can see everything on all instances
|
||||
if ((getActiveObject().getInstanceId() != -1) && (object.getInstanceId() != getActiveObject().getInstanceId()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the object is an L2PcInstance in ghost mode
|
||||
if (object.isPlayer() && object.getActingPlayer().getAppearance().isGhost())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if already know object
|
||||
if (knowsObject(object))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if object is not inside distance to watch object
|
||||
if (!Util.checkIfInShortRange(getDistanceToWatchObject(object), getActiveObject(), object, true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (getKnownObjects().put(object.getObjectId(), object) == null);
|
||||
}
|
||||
|
||||
public final boolean knowsObject(L2Object object)
|
||||
{
|
||||
if (object == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (getActiveObject() == object) || getKnownObjects().containsKey(object.getObjectId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all L2Object from _knownObjects
|
||||
*/
|
||||
public void removeAllKnownObjects()
|
||||
{
|
||||
getKnownObjects().clear();
|
||||
}
|
||||
|
||||
public final boolean removeKnownObject(L2Object object)
|
||||
{
|
||||
return removeKnownObject(object, false);
|
||||
}
|
||||
|
||||
protected boolean removeKnownObject(L2Object object, boolean forget)
|
||||
{
|
||||
if (object == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (forget)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return getKnownObjects().remove(object.getObjectId()) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used only in Config.MOVE_BASED_KNOWNLIST and does not support guards seeing moving monsters
|
||||
*/
|
||||
public final void findObjects()
|
||||
{
|
||||
final L2WorldRegion worldRegion = getActiveObject().getWorldRegion();
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (getActiveObject().isPlayable())
|
||||
{
|
||||
for (L2WorldRegion surroundingRegion : worldRegion.getSurroundingRegions()) // offer members of this and surrounding regions
|
||||
{
|
||||
for (L2Object object : surroundingRegion.getVisibleObjects().values())
|
||||
{
|
||||
if (object != getActiveObject())
|
||||
{
|
||||
addKnownObject(object);
|
||||
if (object instanceof L2Character)
|
||||
{
|
||||
object.getKnownList().addKnownObject(getActiveObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (getActiveObject() instanceof L2Character)
|
||||
{
|
||||
for (L2WorldRegion surroundingRegion : worldRegion.getSurroundingRegions()) // offer members of this and surrounding regions
|
||||
{
|
||||
if (surroundingRegion.isActive())
|
||||
{
|
||||
for (L2Object object : surroundingRegion.getVisiblePlayable().values())
|
||||
{
|
||||
if (object != getActiveObject())
|
||||
{
|
||||
addKnownObject(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove invisible and too far L2Object from _knowObject and if necessary from _knownPlayers of the L2Character
|
||||
* @param fullCheck
|
||||
*/
|
||||
public void forgetObjects(boolean fullCheck)
|
||||
{
|
||||
final Iterator<L2Object> oIter = getKnownObjects().values().iterator();
|
||||
while (oIter.hasNext())
|
||||
{
|
||||
final L2Object object = oIter.next();
|
||||
if (!fullCheck && !object.isPlayable())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove all objects invisible or too far
|
||||
if (!object.isVisible() || !Util.checkIfInShortRange(getDistanceToForgetObject(object), getActiveObject(), object, true))
|
||||
{
|
||||
oIter.remove();
|
||||
removeKnownObject(object, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public L2Object getActiveObject()
|
||||
{
|
||||
return _activeObject;
|
||||
}
|
||||
|
||||
public int getDistanceToForgetObject(L2Object object)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getDistanceToWatchObject(L2Object object)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _knownObjects containing all L2Object known by the L2Character.
|
||||
*/
|
||||
public final Map<Integer, L2Object> getKnownObjects()
|
||||
{
|
||||
return _knownObjects;
|
||||
}
|
||||
}
|
@@ -1,162 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2AirShipInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.DeleteObject;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SpawnItem;
|
||||
|
||||
public class PcKnownList extends PlayableKnownList
|
||||
{
|
||||
public PcKnownList(L2PcInstance activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a visible L2Object to L2PcInstance _knownObjects and _knownPlayer (if necessary) and send Server-Client Packets needed to inform the L2PcInstance of its state and actions in progress.<BR>
|
||||
* <BR>
|
||||
* <B><U> object is a L2ItemInstance </U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Send Server-Client Packet DropItem/SpawnItem to the L2PcInstance</li><BR>
|
||||
* <BR>
|
||||
* <B><U> object is a L2DoorInstance </U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Send Server-Client Packets DoorInfo and DoorStatusUpdate to the L2PcInstance</li>
|
||||
* <li>Send Server->Client packet MoveToPawn/CharMoveToLocation and AutoAttackStart to the L2PcInstance</li><BR>
|
||||
* <BR>
|
||||
* <B><U> object is a L2NpcInstance </U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Send Server-Client Packet NpcInfo to the L2PcInstance</li>
|
||||
* <li>Send Server->Client packet MoveToPawn/CharMoveToLocation and AutoAttackStart to the L2PcInstance</li><BR>
|
||||
* <BR>
|
||||
* <B><U> object is a L2Summon </U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Send Server-Client Packet NpcInfo/PetItemList (if the L2PcInstance is the owner) to the L2PcInstance</li>
|
||||
* <li>Send Server->Client packet MoveToPawn/CharMoveToLocation and AutoAttackStart to the L2PcInstance</li><BR>
|
||||
* <BR>
|
||||
* <B><U> object is a L2PcInstance </U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Send Server-Client Packet CharInfo to the L2PcInstance</li>
|
||||
* <li>If the object has a private store, Send Server-Client Packet PrivateStoreMsgSell to the L2PcInstance</li>
|
||||
* <li>Send Server->Client packet MoveToPawn/CharMoveToLocation and AutoAttackStart to the L2PcInstance</li><BR>
|
||||
* <BR>
|
||||
* @param object The L2Object to add to _knownObjects and _knownPlayer
|
||||
*/
|
||||
@Override
|
||||
public boolean addKnownObject(L2Object object)
|
||||
{
|
||||
if (!super.addKnownObject(object))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (object.getPoly().isMorphed() && object.getPoly().getPolyType().equals("item"))
|
||||
{
|
||||
// if (object.getPolytype().equals("item"))
|
||||
getActiveChar().sendPacket(new SpawnItem(object));
|
||||
// else if (object.getPolytype().equals("npc"))
|
||||
// sendPacket(new NpcInfoPoly(object, this));
|
||||
}
|
||||
else if (object.isVisibleFor(getActiveChar()))
|
||||
{
|
||||
object.sendInfo(getActiveChar());
|
||||
|
||||
if ((object instanceof L2Character) && ((L2Character) object).hasAI())
|
||||
{
|
||||
((L2Character) object).getAI().describeStateToPlayer(getActiveChar());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a L2Object from L2PcInstance _knownObjects and _knownPlayer (if necessary) and send Server-Client Packet DeleteObject to the L2PcInstance.<BR>
|
||||
* <BR>
|
||||
* @param object The L2Object to remove from _knownObjects and _knownPlayer
|
||||
*/
|
||||
@Override
|
||||
protected boolean removeKnownObject(L2Object object, boolean forget)
|
||||
{
|
||||
if (!super.removeKnownObject(object, forget))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (object instanceof L2AirShipInstance)
|
||||
{
|
||||
if ((((L2AirShipInstance) object).getCaptainId() != 0) && (((L2AirShipInstance) object).getCaptainId() != getActiveChar().getObjectId()))
|
||||
{
|
||||
getActiveChar().sendPacket(new DeleteObject(((L2AirShipInstance) object).getCaptainId()));
|
||||
}
|
||||
if (((L2AirShipInstance) object).getHelmObjectId() != 0)
|
||||
{
|
||||
getActiveChar().sendPacket(new DeleteObject(((L2AirShipInstance) object).getHelmObjectId()));
|
||||
}
|
||||
}
|
||||
|
||||
// Send Server-Client Packet DeleteObject to the L2PcInstance
|
||||
getActiveChar().sendPacket(new DeleteObject(object));
|
||||
|
||||
if (Config.CHECK_KNOWN && (object instanceof L2Npc) && getActiveChar().isGM())
|
||||
{
|
||||
getActiveChar().sendMessage("Removed NPC: " + object.getName());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final L2PcInstance getActiveChar()
|
||||
{
|
||||
return (L2PcInstance) super.getActiveChar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToForgetObject(L2Object object)
|
||||
{
|
||||
if (object.isVehicle())
|
||||
{
|
||||
return 10000;
|
||||
}
|
||||
if (getKnownObjects().size() <= 70)
|
||||
{
|
||||
return 2700;
|
||||
}
|
||||
return 1900; // Siege, etc
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToWatchObject(L2Object object)
|
||||
{
|
||||
if (object.isVehicle())
|
||||
{
|
||||
return 9000;
|
||||
}
|
||||
if (getKnownObjects().size() <= 70)
|
||||
{
|
||||
return 2500; // Retail seems to have a larger value than this.
|
||||
}
|
||||
return 1700; // Siege, etc
|
||||
}
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
|
||||
public class PlayableKnownList extends CharKnownList
|
||||
{
|
||||
public PlayableKnownList(L2Playable activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public L2Playable getActiveChar()
|
||||
{
|
||||
return (L2Playable) super.getActiveChar();
|
||||
}
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import com.l2jmobius.gameserver.MonsterRace;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2RaceManagerInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.DeleteObject;
|
||||
|
||||
public class RaceManagerKnownList extends NpcKnownList
|
||||
{
|
||||
public RaceManagerKnownList(L2RaceManagerInstance activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean removeKnownObject(L2Object object, boolean forget)
|
||||
{
|
||||
if (!super.removeKnownObject(object, forget))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (object.isPlayer())
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
object.sendPacket(new DeleteObject(MonsterRace.getInstance().getMonsters()[i]));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public L2RaceManagerInstance getActiveChar()
|
||||
{
|
||||
return (L2RaceManagerInstance) super.getActiveChar();
|
||||
}
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2DefenderInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2StaticObjectInstance;
|
||||
|
||||
public class StaticObjectKnownList extends CharKnownList
|
||||
{
|
||||
public StaticObjectKnownList(L2StaticObjectInstance activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final L2StaticObjectInstance getActiveChar()
|
||||
{
|
||||
return (L2StaticObjectInstance) super.getActiveChar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToForgetObject(L2Object object)
|
||||
{
|
||||
if (object instanceof L2DefenderInstance)
|
||||
{
|
||||
return 800;
|
||||
}
|
||||
if (!object.isPlayer())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 4000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToWatchObject(L2Object object)
|
||||
{
|
||||
if (object instanceof L2DefenderInstance)
|
||||
{
|
||||
return 600;
|
||||
}
|
||||
if (!object.isPlayer())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 2000;
|
||||
}
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Summon;
|
||||
|
||||
public class SummonKnownList extends PlayableKnownList
|
||||
{
|
||||
public SummonKnownList(L2Summon activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final L2Summon getActiveChar()
|
||||
{
|
||||
return (L2Summon) super.getActiveChar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToForgetObject(L2Object object)
|
||||
{
|
||||
if ((object == getActiveChar().getOwner()) || (object == getActiveChar().getTarget()))
|
||||
{
|
||||
return 6000;
|
||||
}
|
||||
return 3000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToWatchObject(L2Object object)
|
||||
{
|
||||
return 1500;
|
||||
}
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2TrapInstance;
|
||||
|
||||
public class TrapKnownList extends NpcKnownList
|
||||
{
|
||||
public TrapKnownList(L2TrapInstance activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final L2TrapInstance getActiveChar()
|
||||
{
|
||||
return (L2TrapInstance) super.getActiveChar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToForgetObject(L2Object object)
|
||||
{
|
||||
if ((object == getActiveChar().getActingPlayer()) || (object == getActiveChar().getTarget()))
|
||||
{
|
||||
return 6000;
|
||||
}
|
||||
|
||||
return 3000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToWatchObject(L2Object object)
|
||||
{
|
||||
return 1500;
|
||||
}
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.knownlist;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
|
||||
public class VehicleKnownList extends CharKnownList
|
||||
{
|
||||
public VehicleKnownList(L2Character activeChar)
|
||||
{
|
||||
super(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToForgetObject(L2Object object)
|
||||
{
|
||||
if (!object.isPlayer())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return object.getKnownList().getDistanceToForgetObject(getActiveObject());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToWatchObject(L2Object object)
|
||||
{
|
||||
if (!object.isPlayer())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return object.getKnownList().getDistanceToWatchObject(getActiveObject());
|
||||
}
|
||||
}
|
@@ -18,6 +18,7 @@ package com.l2jmobius.gameserver.model.actor.tasks.npc.trap;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2TrapInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SocialAction;
|
||||
@@ -71,7 +72,7 @@ public class TrapTask implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
for (L2Character target : _trap.getKnownList().getKnownCharacters())
|
||||
for (L2Character target : L2World.getInstance().getVisibleObjects(_trap, L2Character.class))
|
||||
{
|
||||
if (_trap.checkTarget(target))
|
||||
{
|
||||
|
@@ -16,7 +16,9 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.conditions;
|
||||
|
||||
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.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
@@ -47,9 +49,9 @@ public class ConditionPlayerRangeFromNpc extends Condition
|
||||
boolean existNpc = false;
|
||||
if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0))
|
||||
{
|
||||
for (L2Character target : effector.getKnownList().getKnownCharactersInRadius(_radius))
|
||||
for (L2Npc target : L2World.getInstance().getVisibleObjects(effector, L2Npc.class, _radius))
|
||||
{
|
||||
if (target.isNpc() && Util.contains(_npcIds, target.getId()))
|
||||
if (Util.contains(_npcIds, target.getId()))
|
||||
{
|
||||
existNpc = true;
|
||||
break;
|
||||
|
@@ -584,7 +584,7 @@ public final class BlockCheckerEngine
|
||||
for (L2ItemInstance item : _drops)
|
||||
{
|
||||
// a player has it, it will be deleted later
|
||||
if (!item.isVisible() || (item.getOwnerId() != 0))
|
||||
if (!item.isSpawned() || (item.getOwnerId() != 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@@ -614,7 +614,7 @@ public final class Castle extends AbstractResidence
|
||||
door.setCurrentHp((isDoorWeak) ? (door.getMaxHp() / 2) : (door.getMaxHp()));
|
||||
}
|
||||
|
||||
if (door.getOpen())
|
||||
if (door.isOpen())
|
||||
{
|
||||
door.closeMe();
|
||||
}
|
||||
|
@@ -429,7 +429,7 @@ public class Duel
|
||||
// Open arena doors
|
||||
for (L2DoorInstance door : InstanceManager.getInstance().getInstance(getDueldInstanceId()).getDoors())
|
||||
{
|
||||
if ((door != null) && !door.getOpen())
|
||||
if ((door != null) && !door.isOpen())
|
||||
{
|
||||
door.openMe();
|
||||
}
|
||||
@@ -609,7 +609,7 @@ public class Duel
|
||||
// Remove Olympiad buffers
|
||||
for (L2Npc buffer : InstanceManager.getInstance().getInstance(getDueldInstanceId()).getNpcs())
|
||||
{
|
||||
if ((buffer instanceof L2OlympiadManagerInstance) && buffer.isVisible())
|
||||
if ((buffer instanceof L2OlympiadManagerInstance) && buffer.isSpawned())
|
||||
{
|
||||
buffer.decayMe();
|
||||
}
|
||||
|
@@ -519,7 +519,7 @@ public final class Fort extends AbstractResidence
|
||||
{
|
||||
for (L2DoorInstance door : _doors)
|
||||
{
|
||||
if (door.getOpen())
|
||||
if (door.isOpen())
|
||||
{
|
||||
door.closeMe();
|
||||
}
|
||||
|
@@ -409,7 +409,6 @@ public final class Instance
|
||||
region.removeVisibleObject(door);
|
||||
}
|
||||
|
||||
door.getKnownList().removeAllKnownObjects();
|
||||
L2World.getInstance().removeObject(door);
|
||||
}
|
||||
}
|
||||
|
@@ -384,13 +384,13 @@ public class L2Event
|
||||
spawnEventNpc(player);
|
||||
temp.add(player);
|
||||
}
|
||||
for (L2PcInstance playertemp : player.getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObject(player, L2PcInstance.class, playertemp ->
|
||||
{
|
||||
if ((Math.abs(playertemp.getX() - player.getX()) < 1000) && (Math.abs(playertemp.getY() - player.getY()) < 1000) && (Math.abs(playertemp.getZ() - player.getZ()) < 1000))
|
||||
{
|
||||
temp.add(playertemp);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@@ -45,6 +45,7 @@ import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2SiegeClan;
|
||||
import com.l2jmobius.gameserver.model.L2SiegeClan.SiegeClanType;
|
||||
import com.l2jmobius.gameserver.model.L2Spawn;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.PcCondOverride;
|
||||
import com.l2jmobius.gameserver.model.SiegeScheduleDate;
|
||||
import com.l2jmobius.gameserver.model.TeleportWhereType;
|
||||
@@ -588,11 +589,11 @@ public class Siege implements Siegable
|
||||
}
|
||||
member.sendPacket(new UserInfo(member));
|
||||
member.sendPacket(new ExBrExtraUserInfo(member));
|
||||
for (L2PcInstance player : member.getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObject(member, L2PcInstance.class, player ->
|
||||
{
|
||||
if (player == null)
|
||||
if (!member.isVisibleFor(player))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendPacket(new RelationChanged(member, member.getRelation(player), member.isAutoAttackable(player)));
|
||||
@@ -600,7 +601,7 @@ public class Siege implements Siegable
|
||||
{
|
||||
player.sendPacket(new RelationChanged(member.getSummon(), member.getRelation(player), member.isAutoAttackable(player)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
for (L2SiegeClan siegeclan : getDefenderClans())
|
||||
@@ -638,18 +639,18 @@ public class Siege implements Siegable
|
||||
member.sendPacket(new UserInfo(member));
|
||||
member.sendPacket(new ExBrExtraUserInfo(member));
|
||||
|
||||
for (L2PcInstance player : member.getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObject(member, L2PcInstance.class, player ->
|
||||
{
|
||||
if (player == null)
|
||||
if (!member.isVisibleFor(player))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
player.sendPacket(new RelationChanged(member, member.getRelation(player), member.isAutoAttackable(player)));
|
||||
if (member.hasSummon())
|
||||
{
|
||||
player.sendPacket(new RelationChanged(member.getSummon(), member.getRelation(player), member.isAutoAttackable(player)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -120,7 +120,7 @@ public final class SiegableHall extends ClanHall
|
||||
}
|
||||
}
|
||||
|
||||
if (door.getOpen())
|
||||
if (door.isOpen())
|
||||
{
|
||||
door.closeMe();
|
||||
}
|
||||
|
@@ -2698,7 +2698,7 @@ public abstract class AbstractScript extends ManagedScript
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": called openDoor(" + doorId + ", " + instanceId + "); but door wasnt found!", new NullPointerException());
|
||||
}
|
||||
else if (!door.getOpen())
|
||||
else if (!door.isOpen())
|
||||
{
|
||||
door.openMe();
|
||||
}
|
||||
@@ -2716,7 +2716,7 @@ public abstract class AbstractScript extends ManagedScript
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": called closeDoor(" + doorId + ", " + instanceId + "); but door wasnt found!", new NullPointerException());
|
||||
}
|
||||
else if (door.getOpen())
|
||||
else if (door.isOpen())
|
||||
{
|
||||
door.closeMe();
|
||||
}
|
||||
|
@@ -16,8 +16,7 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.items;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
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.L2Npc;
|
||||
@@ -422,16 +421,10 @@ public final class L2Weapon extends L2Item
|
||||
target
|
||||
};
|
||||
|
||||
//@formatter:off
|
||||
caster.getKnownList().getKnownObjects().values().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(npc -> npc.isNpc())
|
||||
.filter(npc -> Util.checkIfInRange(1000, npc, caster, false))
|
||||
.forEach(npc ->
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcSkillSee((L2Npc) npc, caster.getActingPlayer(), onMagicSkill, targets, false), npc);
|
||||
});
|
||||
//@formatter:on
|
||||
L2World.getInstance().forEachVisibleObjectInRange(caster, L2Npc.class, 1000, npc ->
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcSkillSee(npc, caster.getActingPlayer(), onMagicSkill, targets, false), npc);
|
||||
});
|
||||
}
|
||||
if (caster.isPlayer())
|
||||
{
|
||||
|
@@ -53,7 +53,6 @@ import com.l2jmobius.gameserver.model.L2WorldRegion;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.knownlist.NullKnownList;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerAugment;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.inventory.OnPlayerItemDrop;
|
||||
@@ -226,12 +225,6 @@ public final class L2ItemInstance extends L2Object
|
||||
this(IdFactory.getInstance().getNextId(), itemId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initKnownList()
|
||||
{
|
||||
setKnownList(new NullKnownList(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a L2ItemInstance from the world and send server->client GetItem packets.<BR>
|
||||
* <BR>
|
||||
@@ -264,7 +257,7 @@ public final class L2ItemInstance extends L2Object
|
||||
|
||||
synchronized (this)
|
||||
{
|
||||
setIsVisible(false);
|
||||
setSpawned(false);
|
||||
setWorldRegion(null);
|
||||
}
|
||||
|
||||
@@ -1558,7 +1551,7 @@ public final class L2ItemInstance extends L2Object
|
||||
synchronized (_itm)
|
||||
{
|
||||
// Set the x,y,z position of the L2ItemInstance dropped and update its _worldregion
|
||||
_itm.setIsVisible(true);
|
||||
_itm.setSpawned(true);
|
||||
_itm.setXYZ(_x, _y, _z);
|
||||
_itm.setWorldRegion(L2World.getInstance().getRegion(getLocation()));
|
||||
|
||||
|
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.zone;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2PeaceZone;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public class ZoneRegion
|
||||
{
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
private final Map<Integer, L2ZoneType> _zones = new ConcurrentHashMap<>();
|
||||
|
||||
public ZoneRegion(int regionX, int regionY)
|
||||
{
|
||||
_regionX = regionX;
|
||||
_regionY = regionY;
|
||||
}
|
||||
|
||||
public Map<Integer, L2ZoneType> getZones()
|
||||
{
|
||||
return _zones;
|
||||
}
|
||||
|
||||
public int getRegionX()
|
||||
{
|
||||
return _regionX;
|
||||
}
|
||||
|
||||
public int getRegionY()
|
||||
{
|
||||
return _regionY;
|
||||
}
|
||||
|
||||
public void revalidateZones(L2Character character)
|
||||
{
|
||||
// do NOT update the world region while the character is still in the process of teleporting
|
||||
// Once the teleport is COMPLETED, revalidation occurs safely, at that time.
|
||||
|
||||
if (character.isTeleporting())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (L2ZoneType z : getZones().values())
|
||||
{
|
||||
z.revalidateInZone(character);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFromZones(L2Character character)
|
||||
{
|
||||
for (L2ZoneType z : getZones().values())
|
||||
{
|
||||
z.removeCharacter(character);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkEffectRangeInsidePeaceZone(Skill skill, int x, int y, int z)
|
||||
{
|
||||
final int range = skill.getEffectRange();
|
||||
final int up = y + range;
|
||||
final int down = y - range;
|
||||
final int left = x + range;
|
||||
final int right = x - range;
|
||||
|
||||
for (L2ZoneType e : getZones().values())
|
||||
{
|
||||
if (e instanceof L2PeaceZone)
|
||||
{
|
||||
if (e.isInsideZone(x, up, z))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (e.isInsideZone(x, down, z))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (e.isInsideZone(left, y, z))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (e.isInsideZone(right, y, z))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (e.isInsideZone(x, y, z))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onDeath(L2Character character)
|
||||
{
|
||||
for (L2ZoneType z : getZones().values())
|
||||
{
|
||||
if (z.isInsideZone(character))
|
||||
{
|
||||
z.onDieInside(character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onRevive(L2Character character)
|
||||
{
|
||||
for (L2ZoneType z : getZones().values())
|
||||
{
|
||||
if (z.isInsideZone(character))
|
||||
{
|
||||
z.onReviveInside(character);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -29,7 +29,6 @@ import com.l2jmobius.gameserver.model.PcCondOverride;
|
||||
import com.l2jmobius.gameserver.model.TeleportWhereType;
|
||||
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.zone.AbstractZoneSettings;
|
||||
@@ -419,24 +418,24 @@ public class L2BossZone extends L2ZoneType
|
||||
getSettings().getPlayerAllowedReEntryTimes().remove(player.getObjectId());
|
||||
}
|
||||
|
||||
public void updateKnownList(L2Npc npc)
|
||||
{
|
||||
if ((_characterList == null) || _characterList.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Map<Integer, L2PcInstance> npcKnownPlayers = npc.getKnownList().getKnownPlayers();
|
||||
for (L2Character character : getCharactersInside())
|
||||
{
|
||||
if ((character != null) && character.isPlayer())
|
||||
{
|
||||
final L2PcInstance player = character.getActingPlayer();
|
||||
if (player.isOnline())
|
||||
{
|
||||
npcKnownPlayers.put(player.getObjectId(), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// public void updateKnownList(L2Npc npc)
|
||||
// {
|
||||
// if ((_characterList == null) || _characterList.isEmpty())
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// final Map<Integer, L2PcInstance> npcKnownPlayers = npc.getKnownList().getKnownPlayers();
|
||||
// for (L2Character character : getCharactersInside())
|
||||
// {
|
||||
// if ((character != null) && character.isPlayer())
|
||||
// {
|
||||
// final L2PcInstance player = character.getActingPlayer();
|
||||
// if (player.isOnline())
|
||||
// {
|
||||
// npcKnownPlayers.put(player.getObjectId(), player);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ public class L2OlympiadStadiumZone extends L2ZoneRespawn
|
||||
{
|
||||
for (L2DoorInstance door : InstanceManager.getInstance().getInstance(getInstanceId()).getDoors())
|
||||
{
|
||||
if ((door != null) && !door.getOpen())
|
||||
if ((door != null) && !door.isOpen())
|
||||
{
|
||||
door.openMe();
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public class L2OlympiadStadiumZone extends L2ZoneRespawn
|
||||
{
|
||||
for (L2DoorInstance door : InstanceManager.getInstance().getInstance(getInstanceId()).getDoors())
|
||||
{
|
||||
if ((door != null) && door.getOpen())
|
||||
if ((door != null) && door.isOpen())
|
||||
{
|
||||
door.closeMe();
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class L2OlympiadStadiumZone extends L2ZoneRespawn
|
||||
{
|
||||
for (L2Npc buffer : InstanceManager.getInstance().getInstance(getInstanceId()).getNpcs())
|
||||
{
|
||||
if ((buffer instanceof L2OlympiadManagerInstance) && !buffer.isVisible())
|
||||
if ((buffer instanceof L2OlympiadManagerInstance) && !buffer.isSpawned())
|
||||
{
|
||||
buffer.spawnMe();
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class L2OlympiadStadiumZone extends L2ZoneRespawn
|
||||
{
|
||||
for (L2Npc buffer : InstanceManager.getInstance().getInstance(getInstanceId()).getNpcs())
|
||||
{
|
||||
if ((buffer instanceof L2OlympiadManagerInstance) && buffer.isVisible())
|
||||
if ((buffer instanceof L2OlympiadManagerInstance) && buffer.isSpawned())
|
||||
{
|
||||
buffer.decayMe();
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.zone.type;
|
||||
|
||||
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;
|
||||
@@ -51,7 +52,7 @@ public class L2WaterZone extends L2ZoneType
|
||||
}
|
||||
else if (character.isNpc())
|
||||
{
|
||||
for (L2PcInstance player : character.getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObject(character, L2PcInstance.class, player ->
|
||||
{
|
||||
if (character.getRunSpeed() == 0)
|
||||
{
|
||||
@@ -61,7 +62,7 @@ public class L2WaterZone extends L2ZoneType
|
||||
{
|
||||
player.sendPacket(new AbstractNpcInfo.NpcInfo((L2Npc) character, player));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +83,7 @@ public class L2WaterZone extends L2ZoneType
|
||||
}
|
||||
else if (character.isNpc())
|
||||
{
|
||||
for (L2PcInstance player : character.getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObject(character, L2PcInstance.class, player ->
|
||||
{
|
||||
if (character.getRunSpeed() == 0)
|
||||
{
|
||||
@@ -92,7 +93,7 @@ public class L2WaterZone extends L2ZoneType
|
||||
{
|
||||
player.sendPacket(new AbstractNpcInfo.NpcInfo((L2Npc) character, player));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,6 @@ import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.enums.PlayerAction;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.BypassHandler;
|
||||
@@ -280,8 +279,8 @@ public final class RequestBypassToServer implements IClientIncomingPacket
|
||||
{
|
||||
if (bypassOriginId > 0)
|
||||
{
|
||||
final L2Object bypassOrigin = activeChar.getKnownList().getKnownObjects().get(bypassOriginId);
|
||||
if ((bypassOrigin != null) && bypassOrigin.isInstanceTypes(InstanceType.L2Character))
|
||||
L2Object bypassOrigin = L2World.getInstance().findObject(bypassOriginId);
|
||||
if ((bypassOrigin != null) && bypassOrigin.isCharacter())
|
||||
{
|
||||
handler.useBypass(_command, activeChar, (L2Character) bypassOrigin);
|
||||
}
|
||||
|
@@ -16,10 +16,9 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
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.network.L2GameClient;
|
||||
@@ -47,8 +46,7 @@ public class RequestRecordInfo implements IClientIncomingPacket
|
||||
activeChar.sendPacket(new UserInfo(activeChar));
|
||||
activeChar.sendPacket(new ExBrExtraUserInfo(activeChar));
|
||||
|
||||
final Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
|
||||
for (L2Object object : objs)
|
||||
L2World.getInstance().forEachVisibleObject(activeChar, L2Object.class, object ->
|
||||
{
|
||||
if (object.getPoly().isMorphed() && object.getPoly().getPolyType().equals("item"))
|
||||
{
|
||||
@@ -74,6 +72,6 @@ public class RequestRecordInfo implements IClientIncomingPacket
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -81,7 +81,7 @@ public final class TradeRequest implements IClientIncomingPacket
|
||||
// If there is no target, target is far away or
|
||||
// they are in different instances (except multiverse)
|
||||
// trade request is ignored and there is no system message.
|
||||
if ((target == null) || !player.getKnownList().knowsObject(target) || ((target.getInstanceId() != player.getInstanceId()) && (player.getInstanceId() != -1)))
|
||||
if ((target == null) || !player.isInSurroundingRegion(target) || ((target.getInstanceId() != player.getInstanceId()) && (player.getInstanceId() != -1)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ public final class DoorStatusUpdate implements IClientOutgoingPacket
|
||||
{
|
||||
OutgoingPackets.DOOR_STATUS_UPDATE.writeId(packet);
|
||||
packet.writeD(_door.getObjectId());
|
||||
packet.writeD(_door.getOpen() ? 0 : 1);
|
||||
packet.writeD(_door.isOpen() ? 0 : 1);
|
||||
packet.writeD(_door.getDamage());
|
||||
packet.writeD(_door.isEnemy() ? 1 : 0);
|
||||
packet.writeD(_door.getId());
|
||||
|
@@ -60,7 +60,7 @@ public class StaticObject implements IClientOutgoingPacket
|
||||
_type = 1;
|
||||
_isTargetable = door.isTargetable() || targetable;
|
||||
_meshIndex = door.getMeshIndex();
|
||||
_isClosed = !door.getOpen();
|
||||
_isClosed = !door.isOpen();
|
||||
_isEnemy = door.isEnemy();
|
||||
_maxHp = door.getMaxHp();
|
||||
_currentHp = (int) door.getCurrentHp();
|
||||
|
@@ -1,156 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.concurrent.ThreadPool;
|
||||
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.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2GuardInstance;
|
||||
|
||||
public class KnownListUpdateTaskManager
|
||||
{
|
||||
protected static final Logger _log = Logger.getLogger(KnownListUpdateTaskManager.class.getName());
|
||||
|
||||
private static final int FULL_UPDATE_TIMER = 100;
|
||||
public static boolean updatePass = true;
|
||||
|
||||
// Do full update every FULL_UPDATE_TIMER * KNOWNLIST_UPDATE_INTERVAL
|
||||
public static int _fullUpdateTimer = FULL_UPDATE_TIMER;
|
||||
|
||||
protected static final Set<L2WorldRegion> FAILED_REGIONS = ConcurrentHashMap.newKeySet(1);
|
||||
|
||||
protected KnownListUpdateTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(new KnownListUpdate(), 1000, Config.KNOWNLIST_UPDATE_INTERVAL);
|
||||
}
|
||||
|
||||
private class KnownListUpdate implements Runnable
|
||||
{
|
||||
public KnownListUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
boolean failed;
|
||||
for (L2WorldRegion regions[] : L2World.getInstance().getWorldRegions())
|
||||
{
|
||||
for (L2WorldRegion r : regions) // go through all world regions
|
||||
{
|
||||
// avoid stopping update if something went wrong in updateRegion()
|
||||
try
|
||||
{
|
||||
failed = FAILED_REGIONS.contains(r); // failed on last pass
|
||||
if (r.isActive()) // and check only if the region is active
|
||||
{
|
||||
updateRegion(r, (_fullUpdateTimer == FULL_UPDATE_TIMER) || failed, updatePass);
|
||||
}
|
||||
if (failed)
|
||||
{
|
||||
FAILED_REGIONS.remove(r); // if all ok, remove
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "KnownListUpdateTaskManager: updateRegion(" + _fullUpdateTimer + "," + updatePass + ") failed for region " + r.getName() + ". Full update scheduled. " + e.getMessage(), e);
|
||||
FAILED_REGIONS.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
updatePass = !updatePass;
|
||||
|
||||
if (_fullUpdateTimer > 0)
|
||||
{
|
||||
_fullUpdateTimer--;
|
||||
}
|
||||
else
|
||||
{
|
||||
_fullUpdateTimer = FULL_UPDATE_TIMER;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRegion(L2WorldRegion region, boolean fullUpdate, boolean forgetObjects)
|
||||
{
|
||||
for (L2Object object : region.getVisibleObjects().values())
|
||||
{
|
||||
if ((object == null) || !object.isVisible())
|
||||
{
|
||||
continue; // skip dying objects
|
||||
}
|
||||
|
||||
// Some mobs need faster knownlist update
|
||||
final boolean aggro = Config.GUARD_ATTACK_AGGRO_MOB && (object instanceof L2GuardInstance);
|
||||
|
||||
if (forgetObjects)
|
||||
{
|
||||
object.getKnownList().forgetObjects(aggro || fullUpdate);
|
||||
continue;
|
||||
}
|
||||
for (L2WorldRegion regi : region.getSurroundingRegions())
|
||||
{
|
||||
if ((object instanceof L2Playable) || (aggro && regi.isActive()) || fullUpdate)
|
||||
{
|
||||
for (L2Object obj : regi.getVisibleObjects().values())
|
||||
{
|
||||
if (obj != object)
|
||||
{
|
||||
object.getKnownList().addKnownObject(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((object instanceof L2Character) && regi.isActive())
|
||||
{
|
||||
for (L2Object obj : regi.getVisibleObjects().values())
|
||||
{
|
||||
if (obj != object)
|
||||
{
|
||||
object.getKnownList().addKnownObject(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static KnownListUpdateTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final KnownListUpdateTaskManager _instance = new KnownListUpdateTaskManager();
|
||||
}
|
||||
}
|
@@ -48,15 +48,13 @@ public final class Broadcast
|
||||
*/
|
||||
public static void toPlayersTargettingMyself(L2Character character, IClientOutgoingPacket mov)
|
||||
{
|
||||
for (L2PcInstance player : character.getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObject(character, L2PcInstance.class, player ->
|
||||
{
|
||||
if (player.getTarget() != character)
|
||||
if (player.getTarget() == character)
|
||||
{
|
||||
continue;
|
||||
player.sendPacket(mov);
|
||||
}
|
||||
|
||||
player.sendPacket(mov);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,19 +68,15 @@ public final class Broadcast
|
||||
*/
|
||||
public static void toKnownPlayers(L2Character character, IClientOutgoingPacket mov)
|
||||
{
|
||||
for (L2PcInstance player : character.getKnownList().getKnownPlayers().values())
|
||||
L2World.getInstance().forEachVisibleObject(character, L2PcInstance.class, player ->
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
player.sendPacket(mov);
|
||||
if ((mov instanceof CharInfo) && character.isPlayer())
|
||||
{
|
||||
final int relation = ((L2PcInstance) character).getRelation(player);
|
||||
final Integer oldrelation = character.getKnownList().getKnownRelations().get(player.getObjectId());
|
||||
final Integer oldrelation = character.getKnownRelations().get(player.getObjectId());
|
||||
if ((oldrelation != null) && (oldrelation != relation))
|
||||
{
|
||||
player.sendPacket(new RelationChanged((L2PcInstance) character, relation, character.isAutoAttackable(player)));
|
||||
@@ -97,7 +91,7 @@ public final class Broadcast
|
||||
{
|
||||
_log.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,13 +111,7 @@ public final class Broadcast
|
||||
radius = 1500;
|
||||
}
|
||||
|
||||
for (L2PcInstance player : character.getKnownList().getKnownPlayers().values())
|
||||
{
|
||||
if (character.isInsideRadius(player, radius, false, false))
|
||||
{
|
||||
player.sendPacket(mov);
|
||||
}
|
||||
}
|
||||
L2World.getInstance().forEachVisibleObjectInRange(character, L2PcInstance.class, radius, mov::sendTo);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,13 +145,7 @@ public final class Broadcast
|
||||
character.sendPacket(mov);
|
||||
}
|
||||
|
||||
for (L2PcInstance player : character.getKnownList().getKnownPlayers().values())
|
||||
{
|
||||
if ((player != null) && Util.checkIfInRange(radius, character, player, false))
|
||||
{
|
||||
player.sendPacket(mov);
|
||||
}
|
||||
}
|
||||
L2World.getInstance().forEachVisibleObjectInRange(character, L2PcInstance.class, radius, mov::sendTo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -228,7 +228,7 @@ public class MinionList
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_master.isAlikeDead() || !_master.isVisible() || _minion.isVisible())
|
||||
if (_master.isAlikeDead() || !_master.isSpawned() || _minion.isSpawned())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@ import java.text.DecimalFormatSymbols;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.StringJoiner;
|
||||
@@ -34,8 +33,8 @@ import com.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import com.l2jmobius.commons.util.file.filter.ExtFilter;
|
||||
import com.l2jmobius.gameserver.enums.HtmlActionScope;
|
||||
import com.l2jmobius.gameserver.enums.IllegalActionPunishmentType;
|
||||
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.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.tasks.player.IllegalPlayerActionTask;
|
||||
@@ -236,6 +235,50 @@ public final class Util
|
||||
return calculateDistance(obj1, obj2, includeZAxis, false) <= range;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the cube intersects the sphere.
|
||||
* @param x1 the cube's first point x
|
||||
* @param y1 the cube's first point y
|
||||
* @param z1 the cube's first point z
|
||||
* @param x2 the cube's second point x
|
||||
* @param y2 the cube's second point y
|
||||
* @param z2 the cube's second point z
|
||||
* @param sX the sphere's middle x
|
||||
* @param sY the sphere's middle y
|
||||
* @param sZ the sphere's middle z
|
||||
* @param radius the sphere's radius
|
||||
* @return {@code true} if cube intersects sphere, {@code false} otherwise
|
||||
*/
|
||||
public static boolean cubeIntersectsSphere(int x1, int y1, int z1, int x2, int y2, int z2, int sX, int sY, int sZ, int radius)
|
||||
{
|
||||
double d = radius * radius;
|
||||
if (sX < x1)
|
||||
{
|
||||
d -= Math.pow(sX - x1, 2);
|
||||
}
|
||||
else if (sX > x2)
|
||||
{
|
||||
d -= Math.pow(sX - x2, 2);
|
||||
}
|
||||
if (sY < y1)
|
||||
{
|
||||
d -= Math.pow(sY - y1, 2);
|
||||
}
|
||||
else if (sY > y2)
|
||||
{
|
||||
d -= Math.pow(sY - y2, 2);
|
||||
}
|
||||
if (sZ < z1)
|
||||
{
|
||||
d -= Math.pow(sZ - z1, 2);
|
||||
}
|
||||
else if (sZ > z2)
|
||||
{
|
||||
d -= Math.pow(sZ - z2, 2);
|
||||
}
|
||||
return d > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param str - the String to count
|
||||
* @return the number of "words" in a given string.
|
||||
@@ -630,42 +673,6 @@ public final class Util
|
||||
activeChar.sendPacket(new ShowBoard(Arrays.asList("0", "0", "0", "0", "0", "0", activeChar.getName(), Integer.toString(activeChar.getObjectId()), activeChar.getAccountName(), "9", " ", " ", text.replaceAll("<br>", Config.EOL), "0", "0", "0", "0")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of playable characters in a defined radius around the specified object.
|
||||
* @param range : the radius in which to look for players
|
||||
* @param npc : the object whose knownlist to check
|
||||
* @param playable : if {@code true}, count summons and pets aswell
|
||||
* @param invisible : if {@code true}, count invisible characters aswell
|
||||
* @return the number of targets found
|
||||
*/
|
||||
public static int getPlayersCountInRadius(int range, L2Object npc, boolean playable, boolean invisible)
|
||||
{
|
||||
int count = 0;
|
||||
final Collection<L2Object> objs = npc.getKnownList().getKnownObjects().values();
|
||||
for (L2Object obj : objs)
|
||||
{
|
||||
if ((obj != null) && playable && (obj.isPlayable() || obj.isPet()))
|
||||
{
|
||||
if (!invisible && obj.isInvisible())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2Character cha = (L2Character) obj;
|
||||
if (((cha.getZ() < (npc.getZ() - 100)) && (cha.getZ() > (npc.getZ() + 100))) || !GeoEngine.getInstance().canSeeTarget(cha, npc))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Util.checkIfInRange(range, npc, obj, true) && !cha.isDead())
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static String formatTime(int time)
|
||||
{
|
||||
if (time == 0)
|
||||
@@ -702,8 +709,8 @@ public final class Util
|
||||
|
||||
public static boolean isInsideRangeOfObjectId(L2Object obj, int targetObjId, int radius)
|
||||
{
|
||||
final L2Object target = obj.getKnownList().getKnownObjects().get(targetObjId);
|
||||
return (target != null) && (obj.calculateDistance(target, false, false) <= radius);
|
||||
final L2Object target = L2World.getInstance().findObject(targetObjId);
|
||||
return (target != null) && (obj.calculateDistance(target, true, false) <= radius);
|
||||
}
|
||||
|
||||
public static int min(int value1, int value2, int... values)
|
||||
|
Reference in New Issue
Block a user