From e6921efacb652828379a16d5a15428d2c1673610 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sun, 11 Sep 2022 21:02:40 +0000 Subject: [PATCH] Improved auto play attack and move logic. --- .../taskmanager/AutoPlayTaskManager.java | 22 +++++++++++++++---- .../taskmanager/AutoPlayTaskManager.java | 22 +++++++++++++++---- .../taskmanager/AutoPlayTaskManager.java | 22 +++++++++++++++---- .../taskmanager/AutoPlayTaskManager.java | 22 +++++++++++++++---- .../taskmanager/AutoPlayTaskManager.java | 22 +++++++++++++++---- .../taskmanager/AutoPlayTaskManager.java | 22 +++++++++++++++---- .../taskmanager/AutoPlayTaskManager.java | 22 +++++++++++++++---- .../taskmanager/AutoPlayTaskManager.java | 22 +++++++++++++++---- 8 files changed, 144 insertions(+), 32 deletions(-) diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java index 5862509e8f..dce93cdcc3 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java @@ -26,6 +26,7 @@ import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; +import org.l2jmobius.gameserver.model.actor.Attackable; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.instance.Monster; @@ -76,7 +77,7 @@ public class AutoPlayTaskManager implements Runnable { player.setTarget(null); } - else if (monster.getTarget() == player) + else if ((monster.getTarget() == player) || (monster.getTarget() == null)) { // We take granted that mage classes do not auto hit. if (isMageCaster(player)) @@ -84,10 +85,23 @@ public class AutoPlayTaskManager implements Runnable continue PLAY; } - // Check if actually attacking. - if (player.hasAI() && player.getAI().isAutoAttacking() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving()) + // Attack and add aggro to the monster. + if (player.hasAI() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving() && !player.isDisabled()) { - player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + if (player.getAI().getIntention() != CtrlIntention.AI_INTENTION_ATTACK) + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + } + else + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, monster); + } + + // Make sure monster is engaged. + if (monster.hasAI() && !monster.getAI().isAutoAttacking()) + { + ((Attackable) monster).addDamageHate(player, 0, 100); + } } continue PLAY; } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java index 5862509e8f..dce93cdcc3 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java @@ -26,6 +26,7 @@ import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; +import org.l2jmobius.gameserver.model.actor.Attackable; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.instance.Monster; @@ -76,7 +77,7 @@ public class AutoPlayTaskManager implements Runnable { player.setTarget(null); } - else if (monster.getTarget() == player) + else if ((monster.getTarget() == player) || (monster.getTarget() == null)) { // We take granted that mage classes do not auto hit. if (isMageCaster(player)) @@ -84,10 +85,23 @@ public class AutoPlayTaskManager implements Runnable continue PLAY; } - // Check if actually attacking. - if (player.hasAI() && player.getAI().isAutoAttacking() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving()) + // Attack and add aggro to the monster. + if (player.hasAI() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving() && !player.isDisabled()) { - player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + if (player.getAI().getIntention() != CtrlIntention.AI_INTENTION_ATTACK) + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + } + else + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, monster); + } + + // Make sure monster is engaged. + if (monster.hasAI() && !monster.getAI().isAutoAttacking()) + { + ((Attackable) monster).addDamageHate(player, 0, 100); + } } continue PLAY; } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java index 5862509e8f..dce93cdcc3 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java @@ -26,6 +26,7 @@ import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; +import org.l2jmobius.gameserver.model.actor.Attackable; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.instance.Monster; @@ -76,7 +77,7 @@ public class AutoPlayTaskManager implements Runnable { player.setTarget(null); } - else if (monster.getTarget() == player) + else if ((monster.getTarget() == player) || (monster.getTarget() == null)) { // We take granted that mage classes do not auto hit. if (isMageCaster(player)) @@ -84,10 +85,23 @@ public class AutoPlayTaskManager implements Runnable continue PLAY; } - // Check if actually attacking. - if (player.hasAI() && player.getAI().isAutoAttacking() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving()) + // Attack and add aggro to the monster. + if (player.hasAI() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving() && !player.isDisabled()) { - player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + if (player.getAI().getIntention() != CtrlIntention.AI_INTENTION_ATTACK) + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + } + else + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, monster); + } + + // Make sure monster is engaged. + if (monster.hasAI() && !monster.getAI().isAutoAttacking()) + { + ((Attackable) monster).addDamageHate(player, 0, 100); + } } continue PLAY; } diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java index 5862509e8f..dce93cdcc3 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java @@ -26,6 +26,7 @@ import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; +import org.l2jmobius.gameserver.model.actor.Attackable; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.instance.Monster; @@ -76,7 +77,7 @@ public class AutoPlayTaskManager implements Runnable { player.setTarget(null); } - else if (monster.getTarget() == player) + else if ((monster.getTarget() == player) || (monster.getTarget() == null)) { // We take granted that mage classes do not auto hit. if (isMageCaster(player)) @@ -84,10 +85,23 @@ public class AutoPlayTaskManager implements Runnable continue PLAY; } - // Check if actually attacking. - if (player.hasAI() && player.getAI().isAutoAttacking() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving()) + // Attack and add aggro to the monster. + if (player.hasAI() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving() && !player.isDisabled()) { - player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + if (player.getAI().getIntention() != CtrlIntention.AI_INTENTION_ATTACK) + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + } + else + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, monster); + } + + // Make sure monster is engaged. + if (monster.hasAI() && !monster.getAI().isAutoAttacking()) + { + ((Attackable) monster).addDamageHate(player, 0, 100); + } } continue PLAY; } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java index ee9c80000b..b1b9332e16 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java @@ -26,6 +26,7 @@ import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; +import org.l2jmobius.gameserver.model.actor.Attackable; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.instance.Monster; @@ -76,7 +77,7 @@ public class AutoPlayTaskManager implements Runnable { player.setTarget(null); } - else if (monster.getTarget() == player) + else if ((monster.getTarget() == player) || (monster.getTarget() == null)) { // We take granted that mage classes do not auto hit. if (isMageCaster(player)) @@ -84,10 +85,23 @@ public class AutoPlayTaskManager implements Runnable continue PLAY; } - // Check if actually attacking. - if (player.hasAI() && player.getAI().isAutoAttacking() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving()) + // Attack and add aggro to the monster. + if (player.hasAI() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving() && !player.isDisabled()) { - player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + if (player.getAI().getIntention() != CtrlIntention.AI_INTENTION_ATTACK) + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + } + else + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, monster); + } + + // Make sure monster is engaged. + if (monster.hasAI() && !monster.getAI().isAutoAttacking()) + { + ((Attackable) monster).addDamageHate(player, 0, 100); + } } continue PLAY; } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java index 21f0e8f7ab..ac4c2d0b16 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java @@ -26,6 +26,7 @@ import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; +import org.l2jmobius.gameserver.model.actor.Attackable; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.instance.Monster; @@ -77,7 +78,7 @@ public class AutoPlayTaskManager implements Runnable { player.setTarget(null); } - else if (monster.getTarget() == player) + else if ((monster.getTarget() == player) || (monster.getTarget() == null)) { // We take granted that mage classes do not auto hit. if (isMageCaster(player)) @@ -85,10 +86,23 @@ public class AutoPlayTaskManager implements Runnable continue PLAY; } - // Check if actually attacking. - if (player.hasAI() && player.getAI().isAutoAttacking() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving()) + // Attack and add aggro to the monster. + if (player.hasAI() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving() && !player.isDisabled()) { - player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + if (player.getAI().getIntention() != CtrlIntention.AI_INTENTION_ATTACK) + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + } + else + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, monster); + } + + // Make sure monster is engaged. + if (monster.hasAI() && !monster.getAI().isAutoAttacking()) + { + ((Attackable) monster).addDamageHate(player, 0, 100); + } } continue PLAY; } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java index 21f0e8f7ab..ac4c2d0b16 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java @@ -26,6 +26,7 @@ import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; +import org.l2jmobius.gameserver.model.actor.Attackable; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.instance.Monster; @@ -77,7 +78,7 @@ public class AutoPlayTaskManager implements Runnable { player.setTarget(null); } - else if (monster.getTarget() == player) + else if ((monster.getTarget() == player) || (monster.getTarget() == null)) { // We take granted that mage classes do not auto hit. if (isMageCaster(player)) @@ -85,10 +86,23 @@ public class AutoPlayTaskManager implements Runnable continue PLAY; } - // Check if actually attacking. - if (player.hasAI() && player.getAI().isAutoAttacking() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving()) + // Attack and add aggro to the monster. + if (player.hasAI() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving() && !player.isDisabled()) { - player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + if (player.getAI().getIntention() != CtrlIntention.AI_INTENTION_ATTACK) + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + } + else + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, monster); + } + + // Make sure monster is engaged. + if (monster.hasAI() && !monster.getAI().isAutoAttacking()) + { + ((Attackable) monster).addDamageHate(player, 0, 100); + } } continue PLAY; } diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java index 21f0e8f7ab..ac4c2d0b16 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/taskmanager/AutoPlayTaskManager.java @@ -26,6 +26,7 @@ import org.l2jmobius.gameserver.enums.Race; import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; +import org.l2jmobius.gameserver.model.actor.Attackable; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.instance.Monster; @@ -77,7 +78,7 @@ public class AutoPlayTaskManager implements Runnable { player.setTarget(null); } - else if (monster.getTarget() == player) + else if ((monster.getTarget() == player) || (monster.getTarget() == null)) { // We take granted that mage classes do not auto hit. if (isMageCaster(player)) @@ -85,10 +86,23 @@ public class AutoPlayTaskManager implements Runnable continue PLAY; } - // Check if actually attacking. - if (player.hasAI() && player.getAI().isAutoAttacking() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving()) + // Attack and add aggro to the monster. + if (player.hasAI() && !player.isAttackingNow() && !player.isCastingNow() && !player.isMoving() && !player.isDisabled()) { - player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + if (player.getAI().getIntention() != CtrlIntention.AI_INTENTION_ATTACK) + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster); + } + else + { + player.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, monster); + } + + // Make sure monster is engaged. + if (monster.hasAI() && !monster.getAI().isAutoAttacking()) + { + ((Attackable) monster).addDamageHate(player, 0, 100); + } } continue PLAY; }