Fixed lag coming from siege guards during siege.
Contributed by Sahar.
This commit is contained in:
@@ -20,6 +20,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -697,16 +698,37 @@ public class AttackableAI extends CreatureAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Creature finalTarget = target;
|
final Creature finalTarget = target;
|
||||||
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (final WeakReference<Creature> reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference.get() == finalTarget)
|
||||||
{
|
{
|
||||||
return;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o.get() == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != CtrlIntention.AI_INTENTION_IDLE) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalTarget.isPlayable())
|
if (finalTarget.isPlayable())
|
||||||
{
|
{
|
||||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
@@ -719,8 +741,8 @@ public class AttackableAI extends CreatureAI
|
|||||||
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
|
@@ -20,6 +20,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -697,16 +698,37 @@ public class AttackableAI extends CreatureAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Creature finalTarget = target;
|
final Creature finalTarget = target;
|
||||||
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (final WeakReference<Creature> reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference.get() == finalTarget)
|
||||||
{
|
{
|
||||||
return;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o.get() == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != CtrlIntention.AI_INTENTION_IDLE) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalTarget.isPlayable())
|
if (finalTarget.isPlayable())
|
||||||
{
|
{
|
||||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
@@ -719,8 +741,8 @@ public class AttackableAI extends CreatureAI
|
|||||||
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
|
@@ -20,6 +20,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -697,16 +698,37 @@ public class AttackableAI extends CreatureAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Creature finalTarget = target;
|
final Creature finalTarget = target;
|
||||||
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (final WeakReference<Creature> reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference.get() == finalTarget)
|
||||||
{
|
{
|
||||||
return;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o.get() == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != CtrlIntention.AI_INTENTION_IDLE) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalTarget.isPlayable())
|
if (finalTarget.isPlayable())
|
||||||
{
|
{
|
||||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
@@ -719,8 +741,8 @@ public class AttackableAI extends CreatureAI
|
|||||||
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
|
@@ -20,6 +20,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -697,16 +698,37 @@ public class AttackableAI extends CreatureAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Creature finalTarget = target;
|
final Creature finalTarget = target;
|
||||||
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (final WeakReference<Creature> reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference.get() == finalTarget)
|
||||||
{
|
{
|
||||||
return;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o.get() == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != CtrlIntention.AI_INTENTION_IDLE) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalTarget.isPlayable())
|
if (finalTarget.isPlayable())
|
||||||
{
|
{
|
||||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
@@ -719,8 +741,8 @@ public class AttackableAI extends CreatureAI
|
|||||||
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
|
@@ -20,6 +20,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -697,16 +698,37 @@ public class AttackableAI extends CreatureAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Creature finalTarget = target;
|
final Creature finalTarget = target;
|
||||||
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (final WeakReference<Creature> reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference.get() == finalTarget)
|
||||||
{
|
{
|
||||||
return;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o.get() == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != CtrlIntention.AI_INTENTION_IDLE) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalTarget.isPlayable())
|
if (finalTarget.isPlayable())
|
||||||
{
|
{
|
||||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
@@ -719,8 +741,8 @@ public class AttackableAI extends CreatureAI
|
|||||||
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
|
@@ -20,6 +20,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -697,16 +698,37 @@ public class AttackableAI extends CreatureAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Creature finalTarget = target;
|
final Creature finalTarget = target;
|
||||||
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (final WeakReference<Creature> reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference.get() == finalTarget)
|
||||||
{
|
{
|
||||||
return;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o.get() == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != CtrlIntention.AI_INTENTION_IDLE) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalTarget.isPlayable())
|
if (finalTarget.isPlayable())
|
||||||
{
|
{
|
||||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
@@ -719,8 +741,8 @@ public class AttackableAI extends CreatureAI
|
|||||||
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
|
@@ -20,6 +20,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -697,16 +698,37 @@ public class AttackableAI extends CreatureAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Creature finalTarget = target;
|
final Creature finalTarget = target;
|
||||||
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (final WeakReference<Creature> reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference.get() == finalTarget)
|
||||||
{
|
{
|
||||||
return;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o.get() == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != CtrlIntention.AI_INTENTION_IDLE) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalTarget.isPlayable())
|
if (finalTarget.isPlayable())
|
||||||
{
|
{
|
||||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
@@ -719,8 +741,8 @@ public class AttackableAI extends CreatureAI
|
|||||||
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
|
@@ -20,6 +20,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -697,16 +698,37 @@ public class AttackableAI extends CreatureAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Creature finalTarget = target;
|
final Creature finalTarget = target;
|
||||||
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (final WeakReference<Creature> reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference.get() == finalTarget)
|
||||||
{
|
{
|
||||||
return;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o.get() == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != CtrlIntention.AI_INTENTION_IDLE) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalTarget.isPlayable())
|
if (finalTarget.isPlayable())
|
||||||
{
|
{
|
||||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
@@ -719,8 +741,8 @@ public class AttackableAI extends CreatureAI
|
|||||||
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
|
@@ -846,39 +846,61 @@ public class AttackableAI extends CreatureAI
|
|||||||
// Go through all WorldObject that belong to its faction
|
// Go through all WorldObject that belong to its faction
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (Npc called : World.getInstance().getVisibleObjectsInRange(npc, Npc.class, factionRange))
|
final Creature finalTarget = originalAttackTarget;
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (Creature reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference == finalTarget)
|
||||||
{
|
{
|
||||||
continue;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(originalAttackTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().contains(originalAttackTarget) && ((called.getAI()._intention == AI_INTENTION_IDLE) || (called.getAI()._intention == AI_INTENTION_ACTIVE)) && (called.getInstanceId() == npc.getInstanceId()))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
if (originalAttackTarget.isPlayable())
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
{
|
{
|
||||||
if (originalAttackTarget.isInParty() && originalAttackTarget.getParty().isInDimensionalRift())
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != AI_INTENTION_IDLE) && (called.getAI()._intention != AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finalTarget.isPlayable())
|
||||||
|
{
|
||||||
|
// Dimensional Rift check.
|
||||||
|
if (finalTarget.isInParty() && finalTarget.getParty().isInDimensionalRift())
|
||||||
{
|
{
|
||||||
final byte riftType = originalAttackTarget.getParty().getDimensionalRift().getType();
|
final byte riftType = finalTarget.getParty().getDimensionalRift().getType();
|
||||||
final byte riftRoom = originalAttackTarget.getParty().getDimensionalRift().getCurrentRoom();
|
final byte riftRoom = finalTarget.getParty().getDimensionalRift().getCurrentRoom();
|
||||||
if ((npc instanceof RiftInvaderInstance) && !DimensionalRiftManager.getInstance().getRoom(riftType, riftRoom).checkIfInZone(npc.getX(), npc.getY(), npc.getZ()))
|
if ((npc instanceof RiftInvaderInstance) && !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.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
// Notify the AI with EVT_AGGRESSION
|
// Notify the AI with EVT_AGGRESSION
|
||||||
called.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, originalAttackTarget, 1);
|
called.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, finalTarget, 1);
|
||||||
EventDispatcher.getInstance().notifyEventAsync(new OnAttackableFactionCall(called, getActiveChar(), originalAttackTarget.getActingPlayer(), originalAttackTarget.isSummon()), called);
|
EventDispatcher.getInstance().notifyEventAsync(new OnAttackableFactionCall(called, getActiveChar(), finalTarget.getActingPlayer(), finalTarget.isSummon()), called);
|
||||||
}
|
}
|
||||||
else if (called.isAttackable() && (getAttackTarget() != null) && (called.getAI()._intention != AI_INTENTION_ATTACK))
|
else if (called.isAttackable() && (called.getAI()._intention != AI_INTENTION_ATTACK))
|
||||||
{
|
{
|
||||||
((Attackable) called).addDamageHate(getAttackTarget(), 0, npc.getHating(getAttackTarget()));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(AI_INTENTION_ATTACK, getAttackTarget());
|
called.getAI().setIntention(AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
|
@@ -846,39 +846,61 @@ public class AttackableAI extends CreatureAI
|
|||||||
// Go through all WorldObject that belong to its faction
|
// Go through all WorldObject that belong to its faction
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (Npc called : World.getInstance().getVisibleObjectsInRange(npc, Npc.class, factionRange))
|
final Creature finalTarget = originalAttackTarget;
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (Creature reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference == finalTarget)
|
||||||
{
|
{
|
||||||
continue;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(originalAttackTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().contains(originalAttackTarget) && ((called.getAI()._intention == AI_INTENTION_IDLE) || (called.getAI()._intention == AI_INTENTION_ACTIVE)) && (called.getInstanceId() == npc.getInstanceId()))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
if (originalAttackTarget.isPlayable())
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
{
|
{
|
||||||
if (originalAttackTarget.isInParty() && originalAttackTarget.getParty().isInDimensionalRift())
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != AI_INTENTION_IDLE) && (called.getAI()._intention != AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finalTarget.isPlayable())
|
||||||
|
{
|
||||||
|
// Dimensional Rift check.
|
||||||
|
if (finalTarget.isInParty() && finalTarget.getParty().isInDimensionalRift())
|
||||||
{
|
{
|
||||||
final byte riftType = originalAttackTarget.getParty().getDimensionalRift().getType();
|
final byte riftType = finalTarget.getParty().getDimensionalRift().getType();
|
||||||
final byte riftRoom = originalAttackTarget.getParty().getDimensionalRift().getCurrentRoom();
|
final byte riftRoom = finalTarget.getParty().getDimensionalRift().getCurrentRoom();
|
||||||
if ((npc instanceof RiftInvaderInstance) && !DimensionalRiftManager.getInstance().getRoom(riftType, riftRoom).checkIfInZone(npc.getX(), npc.getY(), npc.getZ()))
|
if ((npc instanceof RiftInvaderInstance) && !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.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
// Notify the AI with EVT_AGGRESSION
|
// Notify the AI with EVT_AGGRESSION
|
||||||
called.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, originalAttackTarget, 1);
|
called.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, finalTarget, 1);
|
||||||
EventDispatcher.getInstance().notifyEventAsync(new OnAttackableFactionCall(called, getActiveChar(), originalAttackTarget.getActingPlayer(), originalAttackTarget.isSummon()), called);
|
EventDispatcher.getInstance().notifyEventAsync(new OnAttackableFactionCall(called, getActiveChar(), finalTarget.getActingPlayer(), finalTarget.isSummon()), called);
|
||||||
}
|
}
|
||||||
else if (called.isAttackable() && (getAttackTarget() != null) && (called.getAI()._intention != AI_INTENTION_ATTACK))
|
else if (called.isAttackable() && (called.getAI()._intention != AI_INTENTION_ATTACK))
|
||||||
{
|
{
|
||||||
((Attackable) called).addDamageHate(getAttackTarget(), 0, npc.getHating(getAttackTarget()));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(AI_INTENTION_ATTACK, getAttackTarget());
|
called.getAI().setIntention(AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
|
@@ -20,6 +20,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -697,16 +698,37 @@ public class AttackableAI extends CreatureAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Creature finalTarget = target;
|
final Creature finalTarget = target;
|
||||||
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (final WeakReference<Creature> reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference.get() == finalTarget)
|
||||||
{
|
{
|
||||||
return;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o.get() == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != CtrlIntention.AI_INTENTION_IDLE) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalTarget.isPlayable())
|
if (finalTarget.isPlayable())
|
||||||
{
|
{
|
||||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
@@ -719,8 +741,8 @@ public class AttackableAI extends CreatureAI
|
|||||||
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
|
@@ -20,6 +20,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -697,16 +698,37 @@ public class AttackableAI extends CreatureAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Creature finalTarget = target;
|
final Creature finalTarget = target;
|
||||||
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (final WeakReference<Creature> reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference.get() == finalTarget)
|
||||||
{
|
{
|
||||||
return;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o.get() == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != CtrlIntention.AI_INTENTION_IDLE) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalTarget.isPlayable())
|
if (finalTarget.isPlayable())
|
||||||
{
|
{
|
||||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
@@ -719,8 +741,8 @@ public class AttackableAI extends CreatureAI
|
|||||||
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
|
@@ -20,6 +20,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -697,16 +698,37 @@ public class AttackableAI extends CreatureAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Creature finalTarget = target;
|
final Creature finalTarget = target;
|
||||||
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (final WeakReference<Creature> reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference.get() == finalTarget)
|
||||||
{
|
{
|
||||||
return;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o.get() == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != CtrlIntention.AI_INTENTION_IDLE) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalTarget.isPlayable())
|
if (finalTarget.isPlayable())
|
||||||
{
|
{
|
||||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
@@ -719,8 +741,8 @@ public class AttackableAI extends CreatureAI
|
|||||||
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
|
@@ -20,6 +20,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -697,16 +698,37 @@ public class AttackableAI extends CreatureAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Creature finalTarget = target;
|
final Creature finalTarget = target;
|
||||||
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (final WeakReference<Creature> reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference.get() == finalTarget)
|
||||||
{
|
{
|
||||||
return;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o.get() == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != CtrlIntention.AI_INTENTION_IDLE) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalTarget.isPlayable())
|
if (finalTarget.isPlayable())
|
||||||
{
|
{
|
||||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
@@ -719,8 +741,8 @@ public class AttackableAI extends CreatureAI
|
|||||||
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
|
@@ -20,6 +20,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -697,16 +698,37 @@ public class AttackableAI extends CreatureAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Creature finalTarget = target;
|
final Creature finalTarget = target;
|
||||||
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (final WeakReference<Creature> reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference.get() == finalTarget)
|
||||||
{
|
{
|
||||||
return;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o.get() == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != CtrlIntention.AI_INTENTION_IDLE) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalTarget.isPlayable())
|
if (finalTarget.isPlayable())
|
||||||
{
|
{
|
||||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
@@ -719,8 +741,8 @@ public class AttackableAI extends CreatureAI
|
|||||||
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
|
@@ -20,6 +20,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -697,16 +698,37 @@ public class AttackableAI extends CreatureAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Creature finalTarget = target;
|
final Creature finalTarget = target;
|
||||||
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (final WeakReference<Creature> reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference.get() == finalTarget)
|
||||||
{
|
{
|
||||||
return;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o.get() == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != CtrlIntention.AI_INTENTION_IDLE) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalTarget.isPlayable())
|
if (finalTarget.isPlayable())
|
||||||
{
|
{
|
||||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
@@ -719,8 +741,8 @@ public class AttackableAI extends CreatureAI
|
|||||||
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
|
@@ -20,6 +20,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -697,16 +698,37 @@ public class AttackableAI extends CreatureAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Creature finalTarget = target;
|
final Creature finalTarget = target;
|
||||||
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
|
||||||
|
// Call friendly npcs for help only if this NPC was attacked by the target creature.
|
||||||
|
boolean targetExistsInAttackByList = false;
|
||||||
|
for (final WeakReference<Creature> reference : npc.getAttackByList())
|
||||||
{
|
{
|
||||||
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
if (reference.get() == finalTarget)
|
||||||
{
|
{
|
||||||
return;
|
targetExistsInAttackByList = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if the WorldObject is inside the Faction Range of the actor
|
if (targetExistsInAttackByList)
|
||||||
if (called.hasAI() && (Math.abs(finalTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().stream().anyMatch(o -> o.get() == finalTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)))
|
{
|
||||||
|
World.getInstance().forEachVisibleObjectInRange(npc, Npc.class, factionRange, called ->
|
||||||
{
|
{
|
||||||
|
// Don't call dead npcs, npcs without ai or npcs which are too far away.
|
||||||
|
if (called.isDead() || !called.hasAI() || (Math.abs(finalTarget.getZ() - called.getZ()) > 600))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who are already doing some action (e.g. attacking, casting).
|
||||||
|
if ((called.getAI()._intention != CtrlIntention.AI_INTENTION_IDLE) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't call npcs who aren't in the same clan.
|
||||||
|
if (!getActiveChar().getTemplate().isClan(called.getTemplate().getClans()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finalTarget.isPlayable())
|
if (finalTarget.isPlayable())
|
||||||
{
|
{
|
||||||
// By default, when a faction member calls for help, attack the caller's attacker.
|
// By default, when a faction member calls for help, attack the caller's attacker.
|
||||||
@@ -719,8 +741,8 @@ public class AttackableAI extends CreatureAI
|
|||||||
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
((Attackable) called).addDamageHate(finalTarget, 0, npc.getHating(finalTarget));
|
||||||
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
called.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, finalTarget);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user