Adjustments for auto attacking players.

This commit is contained in:
MobiusDevelopment 2022-11-15 22:26:09 +00:00
parent 4956142361
commit a12f034e68
6 changed files with 27 additions and 9 deletions

View File

@ -169,7 +169,7 @@ public class AutoPlayTaskManager
// Find target.
Creature creature = null;
double closestDistance = Double.MAX_VALUE;
TARGET: for (Creature nearby : World.getInstance().getVisibleObjectsInRange(player, Creature.class, player.getAutoPlaySettings().isShortRange() ? 600 : 1400))
TARGET: for (Creature nearby : World.getInstance().getVisibleObjectsInRange(player, Creature.class, player.getAutoPlaySettings().isShortRange() && (targetMode != 2 /* Characters */) && (targetMode != 4 /* Counterattack */) ? 600 : 1400))
{
// Skip unavailable creatures.
if ((nearby == null) || nearby.isAlikeDead())

View File

@ -357,7 +357,13 @@ public class AutoUseTaskManager
}
// Check bad skill target.
if ((target == null) || !target.isAttackable() || ((Creature) target).isDead())
if ((target == null) || ((Creature) target).isDead())
{
break SKILLS;
}
// Peace zone and auto attackable checks.
if (target.isInsideZone(ZoneId.PEACE) || !target.isAutoAttackable(player))
{
break SKILLS;
}
@ -366,7 +372,7 @@ public class AutoUseTaskManager
if (target instanceof Guard)
{
final int targetMode = player.getAutoPlaySettings().getNextTargetMode();
if (((targetMode != 3 /* NPC */) && (targetMode != 0 /* Any Target */)) || target.isInsideZone(ZoneId.PEACE) || !target.isAutoAttackable(player))
if ((targetMode != 3 /* NPC */) && (targetMode != 0 /* Any Target */))
{
break SKILLS;
}

View File

@ -169,7 +169,7 @@ public class AutoPlayTaskManager
// Find target.
Creature creature = null;
double closestDistance = Double.MAX_VALUE;
TARGET: for (Creature nearby : World.getInstance().getVisibleObjectsInRange(player, Creature.class, player.getAutoPlaySettings().isShortRange() ? 600 : 1400))
TARGET: for (Creature nearby : World.getInstance().getVisibleObjectsInRange(player, Creature.class, player.getAutoPlaySettings().isShortRange() && (targetMode != 2 /* Characters */) && (targetMode != 4 /* Counterattack */) ? 600 : 1400))
{
// Skip unavailable creatures.
if ((nearby == null) || nearby.isAlikeDead())

View File

@ -357,7 +357,13 @@ public class AutoUseTaskManager
}
// Check bad skill target.
if ((target == null) || !target.isAttackable() || ((Creature) target).isDead())
if ((target == null) || ((Creature) target).isDead())
{
break SKILLS;
}
// Peace zone and auto attackable checks.
if (target.isInsideZone(ZoneId.PEACE) || !target.isAutoAttackable(player))
{
break SKILLS;
}
@ -366,7 +372,7 @@ public class AutoUseTaskManager
if (target instanceof Guard)
{
final int targetMode = player.getAutoPlaySettings().getNextTargetMode();
if (((targetMode != 3 /* NPC */) && (targetMode != 0 /* Any Target */)) || target.isInsideZone(ZoneId.PEACE) || !target.isAutoAttackable(player))
if ((targetMode != 3 /* NPC */) && (targetMode != 0 /* Any Target */))
{
break SKILLS;
}

View File

@ -169,7 +169,7 @@ public class AutoPlayTaskManager
// Find target.
Creature creature = null;
double closestDistance = Double.MAX_VALUE;
TARGET: for (Creature nearby : World.getInstance().getVisibleObjectsInRange(player, Creature.class, player.getAutoPlaySettings().isShortRange() ? 600 : 1400))
TARGET: for (Creature nearby : World.getInstance().getVisibleObjectsInRange(player, Creature.class, player.getAutoPlaySettings().isShortRange() && (targetMode != 2 /* Characters */) && (targetMode != 4 /* Counterattack */) ? 600 : 1400))
{
// Skip unavailable creatures.
if ((nearby == null) || nearby.isAlikeDead())

View File

@ -357,7 +357,13 @@ public class AutoUseTaskManager
}
// Check bad skill target.
if ((target == null) || !target.isAttackable() || ((Creature) target).isDead())
if ((target == null) || ((Creature) target).isDead())
{
break SKILLS;
}
// Peace zone and auto attackable checks.
if (target.isInsideZone(ZoneId.PEACE) || !target.isAutoAttackable(player))
{
break SKILLS;
}
@ -366,7 +372,7 @@ public class AutoUseTaskManager
if (target instanceof Guard)
{
final int targetMode = player.getAutoPlaySettings().getNextTargetMode();
if (((targetMode != 3 /* NPC */) && (targetMode != 0 /* Any Target */)) || target.isInsideZone(ZoneId.PEACE) || !target.isAutoAttackable(player))
if ((targetMode != 3 /* NPC */) && (targetMode != 0 /* Any Target */))
{
break SKILLS;
}