From 8bdf70c0e19ed2f6ed36a839c3c9c93aa4cd7ed8 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Tue, 16 Jun 2020 16:08:26 +0000 Subject: [PATCH] Fixed stackoverflow errors from movement. Contributed by Sahar. --- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 2 +- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 2 +- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 2 +- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 2 +- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 2 +- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 2 +- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 2 +- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 2 +- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 10 +++++++--- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 10 +++++++--- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 7 ++++++- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 7 ++++++- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 2 +- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 2 +- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 2 +- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 2 +- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 2 +- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 2 +- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- .../java/org/l2jmobius/gameserver/ai/AbstractAI.java | 2 +- .../taskmanager/CreatureFollowTaskManager.java | 9 +++++++-- 38 files changed, 174 insertions(+), 61 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 1480e8207f..2c2c86348b 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -692,7 +692,7 @@ public abstract class AbstractAI implements Ctrl public boolean isFollowing() { - return (_target != null) && _target.isCreature() && (_intention == AI_INTENTION_FOLLOW); + return (_target != null) && _target.isCreature() && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); } /** diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 5ff7099dae..09899bab14 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 1480e8207f..2c2c86348b 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -692,7 +692,7 @@ public abstract class AbstractAI implements Ctrl public boolean isFollowing() { - return (_target != null) && _target.isCreature() && (_intention == AI_INTENTION_FOLLOW); + return (_target != null) && _target.isCreature() && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); } /** diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 5ff7099dae..09899bab14 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 1480e8207f..2c2c86348b 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -692,7 +692,7 @@ public abstract class AbstractAI implements Ctrl public boolean isFollowing() { - return (_target != null) && _target.isCreature() && (_intention == AI_INTENTION_FOLLOW); + return (_target != null) && _target.isCreature() && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); } /** diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 5ff7099dae..09899bab14 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 1480e8207f..2c2c86348b 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -692,7 +692,7 @@ public abstract class AbstractAI implements Ctrl public boolean isFollowing() { - return (_target != null) && _target.isCreature() && (_intention == AI_INTENTION_FOLLOW); + return (_target != null) && _target.isCreature() && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); } /** diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 5ff7099dae..09899bab14 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 1480e8207f..2c2c86348b 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -692,7 +692,7 @@ public abstract class AbstractAI implements Ctrl public boolean isFollowing() { - return (_target != null) && _target.isCreature() && (_intention == AI_INTENTION_FOLLOW); + return (_target != null) && _target.isCreature() && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); } /** diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 5ff7099dae..09899bab14 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 1480e8207f..2c2c86348b 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -692,7 +692,7 @@ public abstract class AbstractAI implements Ctrl public boolean isFollowing() { - return (_target != null) && _target.isCreature() && (_intention == AI_INTENTION_FOLLOW); + return (_target != null) && _target.isCreature() && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); } /** diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 5ff7099dae..09899bab14 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 1480e8207f..2c2c86348b 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -692,7 +692,7 @@ public abstract class AbstractAI implements Ctrl public boolean isFollowing() { - return (_target != null) && _target.isCreature() && (_intention == AI_INTENTION_FOLLOW); + return (_target != null) && _target.isCreature() && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); } /** diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 5ff7099dae..09899bab14 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 1480e8207f..2c2c86348b 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -692,7 +692,7 @@ public abstract class AbstractAI implements Ctrl public boolean isFollowing() { - return (_target != null) && _target.isCreature() && (_intention == AI_INTENTION_FOLLOW); + return (_target != null) && _target.isCreature() && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); } /** diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 5ff7099dae..09899bab14 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/ai/AbstractAI.java index c5bf9a754b..79b9c95981 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -694,11 +694,10 @@ abstract class AbstractAI implements Ctrl { if (_clientMoving) { - final Creature follow = getFollowTarget(); - if ((_clientMovingToPawnOffset != 0) && (follow != null)) + if ((_clientMovingToPawnOffset != 0) && isFollowing()) { // Send a Server->Client packet MoveToPawn to the actor and all PlayerInstance in its _knownPlayers - player.sendPacket(new MoveToPawn(_actor, follow, _clientMovingToPawnOffset)); + player.sendPacket(new MoveToPawn(_actor, _followTarget, _clientMovingToPawnOffset)); } else { @@ -708,6 +707,11 @@ abstract class AbstractAI implements Ctrl } } + public boolean isFollowing() + { + return (_followTarget != null) && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); + } + /** * Create and Launch an AI Follow Task to execute every 1s. * @param target The Creature to follow diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 113a052c60..a33d64a9d9 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/ai/AbstractAI.java index c5bf9a754b..79b9c95981 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -694,11 +694,10 @@ abstract class AbstractAI implements Ctrl { if (_clientMoving) { - final Creature follow = getFollowTarget(); - if ((_clientMovingToPawnOffset != 0) && (follow != null)) + if ((_clientMovingToPawnOffset != 0) && isFollowing()) { // Send a Server->Client packet MoveToPawn to the actor and all PlayerInstance in its _knownPlayers - player.sendPacket(new MoveToPawn(_actor, follow, _clientMovingToPawnOffset)); + player.sendPacket(new MoveToPawn(_actor, _followTarget, _clientMovingToPawnOffset)); } else { @@ -708,6 +707,11 @@ abstract class AbstractAI implements Ctrl } } + public boolean isFollowing() + { + return (_followTarget != null) && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); + } + /** * Create and Launch an AI Follow Task to execute every 1s. * @param target The Creature to follow diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 113a052c60..a33d64a9d9 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 82f2442e2c..76f4f75056 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -744,7 +744,7 @@ public abstract class AbstractAI implements Ctrl { if (_actor.isVisibleFor(player) && _clientMoving) { - if ((_clientMovingToPawnOffset != 0) && (_followTarget != null)) + if ((_clientMovingToPawnOffset != 0) && isFollowing()) { // Send a Server->Client packet MoveToPawn to the actor and all PlayerInstance in its _knownPlayers player.sendPacket(new MoveToPawn(_actor, _followTarget, _clientMovingToPawnOffset)); @@ -757,6 +757,11 @@ public abstract class AbstractAI implements Ctrl } } + public boolean isFollowing() + { + return (_followTarget != null) && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); + } + /** * Create and Launch an AI Follow Task to execute every 1s. * @param target The Creature to follow diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index b9232d3c1a..046565b087 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 82f2442e2c..76f4f75056 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -744,7 +744,7 @@ public abstract class AbstractAI implements Ctrl { if (_actor.isVisibleFor(player) && _clientMoving) { - if ((_clientMovingToPawnOffset != 0) && (_followTarget != null)) + if ((_clientMovingToPawnOffset != 0) && isFollowing()) { // Send a Server->Client packet MoveToPawn to the actor and all PlayerInstance in its _knownPlayers player.sendPacket(new MoveToPawn(_actor, _followTarget, _clientMovingToPawnOffset)); @@ -757,6 +757,11 @@ public abstract class AbstractAI implements Ctrl } } + public boolean isFollowing() + { + return (_followTarget != null) && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); + } + /** * Create and Launch an AI Follow Task to execute every 1s. * @param target The Creature to follow diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index b9232d3c1a..046565b087 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 1480e8207f..2c2c86348b 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -692,7 +692,7 @@ public abstract class AbstractAI implements Ctrl public boolean isFollowing() { - return (_target != null) && _target.isCreature() && (_intention == AI_INTENTION_FOLLOW); + return (_target != null) && _target.isCreature() && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); } /** diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 5ff7099dae..09899bab14 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 1480e8207f..2c2c86348b 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -692,7 +692,7 @@ public abstract class AbstractAI implements Ctrl public boolean isFollowing() { - return (_target != null) && _target.isCreature() && (_intention == AI_INTENTION_FOLLOW); + return (_target != null) && _target.isCreature() && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); } /** diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 5ff7099dae..09899bab14 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 1480e8207f..2c2c86348b 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -692,7 +692,7 @@ public abstract class AbstractAI implements Ctrl public boolean isFollowing() { - return (_target != null) && _target.isCreature() && (_intention == AI_INTENTION_FOLLOW); + return (_target != null) && _target.isCreature() && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); } /** diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 5ff7099dae..09899bab14 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 1480e8207f..2c2c86348b 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -692,7 +692,7 @@ public abstract class AbstractAI implements Ctrl public boolean isFollowing() { - return (_target != null) && _target.isCreature() && (_intention == AI_INTENTION_FOLLOW); + return (_target != null) && _target.isCreature() && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); } /** diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 5ff7099dae..09899bab14 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 1480e8207f..2c2c86348b 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -692,7 +692,7 @@ public abstract class AbstractAI implements Ctrl public boolean isFollowing() { - return (_target != null) && _target.isCreature() && (_intention == AI_INTENTION_FOLLOW); + return (_target != null) && _target.isCreature() && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); } /** diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 5ff7099dae..09899bab14 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 1480e8207f..2c2c86348b 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -692,7 +692,7 @@ public abstract class AbstractAI implements Ctrl public boolean isFollowing() { - return (_target != null) && _target.isCreature() && (_intention == AI_INTENTION_FOLLOW); + return (_target != null) && _target.isCreature() && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); } /** diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 5ff7099dae..09899bab14 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature) diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ai/AbstractAI.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ai/AbstractAI.java index 1480e8207f..2c2c86348b 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ai/AbstractAI.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ai/AbstractAI.java @@ -692,7 +692,7 @@ public abstract class AbstractAI implements Ctrl public boolean isFollowing() { - return (_target != null) && _target.isCreature() && (_intention == AI_INTENTION_FOLLOW); + return (_target != null) && _target.isCreature() && ((_intention == AI_INTENTION_FOLLOW) || CreatureFollowTaskManager.getInstance().isFollowing(_actor)); } /** diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java index 5ff7099dae..09899bab14 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/taskmanager/CreatureFollowTaskManager.java @@ -126,16 +126,21 @@ public class CreatureFollowTaskManager } } + public boolean isFollowing(Creature creature) + { + return NORMAL_FOLLOW_CREATURES.containsKey(creature) || ATTACK_FOLLOW_CREATURES.containsKey(creature); + } + public void addNormalFollow(Creature creature, int range) { - follow(creature, range); NORMAL_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void addAttackFollow(Creature creature, int range) { - follow(creature, range); ATTACK_FOLLOW_CREATURES.putIfAbsent(creature, range); + follow(creature, range); } public void remove(Creature creature)