Use try for CreatureFollowTaskManager as original method did.

This commit is contained in:
MobiusDevelopment
2020-04-09 10:16:43 +00:00
parent e04b0efc83
commit 1b0e1d7214
18 changed files with 504 additions and 378 deletions

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getFollowTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getFollowTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius(followTarget, followRange, true, false))
{
if (!creature.isInsideRadius(followTarget, 3000, true, false))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius(followTarget, followRange, true, false))
{
if (!creature.isInsideRadius(followTarget, 3000, true, false))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getFollowTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getFollowTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getFollowTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getFollowTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }

View File

@@ -76,28 +76,16 @@ public class CreatureFollowTaskManager
private void follow(Creature creature, int range) private void follow(Creature creature, int range)
{ {
if (creature.hasAI()) try
{ {
final CreatureAI ai = creature.getAI(); if (creature.hasAI())
if (ai != null)
{ {
final WorldObject followTarget = ai.getTarget(); final CreatureAI ai = creature.getAI();
if (followTarget == null) if (ai != null)
{ {
if (creature.isSummon()) final WorldObject followTarget = ai.getTarget();
if (followTarget == null)
{ {
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon()) if (creature.isSummon())
{ {
((Summon) creature).setFollowStatus(false); ((Summon) creature).setFollowStatus(false);
@@ -105,7 +93,26 @@ public class CreatureFollowTaskManager
ai.setIntention(AI_INTENTION_IDLE); ai.setIntention(AI_INTENTION_IDLE);
return; return;
} }
ai.moveToPawn(followTarget, followRange);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
if (!creature.isInsideRadius3D(followTarget, followRange))
{
if (!creature.isInsideRadius3D(followTarget, 3000))
{
// If the target is too far (maybe also teleported).
if (creature.isSummon())
{
((Summon) creature).setFollowStatus(false);
}
ai.setIntention(AI_INTENTION_IDLE);
return;
}
ai.moveToPawn(followTarget, followRange);
}
}
else
{
remove(creature);
} }
} }
else else
@@ -113,9 +120,9 @@ public class CreatureFollowTaskManager
remove(creature); remove(creature);
} }
} }
else catch (Exception e)
{ {
remove(creature); // Ignore.
} }
} }