Fixed characters reaching targets with less speed.
Contributed by Sahar.
This commit is contained in:
@@ -476,7 +476,7 @@ abstract class AbstractAI implements Ctrl
|
||||
}
|
||||
|
||||
// Calculate movement data for a move to location action and add the actor to movingObjects of GameTimeController
|
||||
_accessor.moveTo(pawn.getX(), pawn.getY(), pawn.getZ(), offset);
|
||||
_accessor.moveTo(pawn, pawn.getX(), pawn.getY(), pawn.getZ(), offset);
|
||||
|
||||
// Mobius: Solves moving to wrong Z when not using geodata,
|
||||
// but probably is not accurate and you should use geodata.
|
||||
|
@@ -977,7 +977,7 @@ public class CreatureAI extends AbstractAI
|
||||
return true;
|
||||
}
|
||||
// allow larger hit range when the target is moving (check is run only once per second)
|
||||
if (!_actor.isInsideRadius(target, offsetWithCollision + 30, false, false))
|
||||
if (!_actor.isInsideRadius(target, offsetWithCollision + 100, false, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -1018,7 +1018,7 @@ public class CreatureAI extends AbstractAI
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getFollowTarget() != null)
|
||||
if (isFollowing())
|
||||
{
|
||||
stopFollow();
|
||||
}
|
||||
|
@@ -4248,14 +4248,15 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
|
||||
/**
|
||||
* Accessor to Creature moveToLocation() method with an interaction area.
|
||||
* @param target The target to follow, if any.
|
||||
* @param x the x
|
||||
* @param y the y
|
||||
* @param z the z
|
||||
* @param offset the offset
|
||||
*/
|
||||
public void moveTo(int x, int y, int z, int offset)
|
||||
public void moveTo(WorldObject target, int x, int y, int z, int offset)
|
||||
{
|
||||
moveToLocation(x, y, z, offset);
|
||||
moveToLocation(target, x, y, z, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4333,6 +4334,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
|
||||
public int _moveStartTime;
|
||||
public int _moveTimestamp;
|
||||
public WorldObject _target;
|
||||
public int _xDestination;
|
||||
public int _yDestination;
|
||||
public int _zDestination;
|
||||
@@ -4855,6 +4857,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
final MoveData m = _move;
|
||||
if (m != null)
|
||||
{
|
||||
final WorldObject target = m._target;
|
||||
if (target != null)
|
||||
{
|
||||
return target.getX();
|
||||
}
|
||||
|
||||
return m._xDestination;
|
||||
}
|
||||
return getX();
|
||||
@@ -4869,6 +4877,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
final MoveData m = _move;
|
||||
if (m != null)
|
||||
{
|
||||
final WorldObject target = m._target;
|
||||
if (target != null)
|
||||
{
|
||||
return target.getY();
|
||||
}
|
||||
|
||||
return m._yDestination;
|
||||
}
|
||||
return getY();
|
||||
@@ -4883,6 +4897,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
final MoveData m = _move;
|
||||
if (m != null)
|
||||
{
|
||||
final WorldObject target = m._target;
|
||||
if (target != null)
|
||||
{
|
||||
return target.getZ();
|
||||
}
|
||||
|
||||
return m._zDestination;
|
||||
}
|
||||
return getZ();
|
||||
@@ -5088,6 +5108,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
return false;
|
||||
}
|
||||
|
||||
final WorldObject target = m._target;
|
||||
final int xPrev = getX();
|
||||
final int yPrev = getY();
|
||||
final int zPrev = getZ(); // the z coordinate may be modified by coordinate synchronizations
|
||||
@@ -5098,13 +5119,29 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
// the only method that can modify x,y while moving (otherwise _move would/should be set null)
|
||||
if (Config.COORD_SYNCHRONIZE == 1)
|
||||
{
|
||||
dx = m._xDestination - xPrev;
|
||||
dy = m._yDestination - yPrev;
|
||||
if (target != null)
|
||||
{
|
||||
dx = target.getX() - xPrev;
|
||||
dy = target.getY() - yPrev;
|
||||
}
|
||||
else
|
||||
{
|
||||
dx = m._xDestination - xPrev;
|
||||
dy = m._yDestination - yPrev;
|
||||
}
|
||||
}
|
||||
else // otherwise we need saved temporary values to avoid rounding errors
|
||||
{
|
||||
dx = m._xDestination - m._xAccurate;
|
||||
dy = m._yDestination - m._yAccurate;
|
||||
if (target != null)
|
||||
{
|
||||
dx = target.getX() - m._xAccurate;
|
||||
dy = target.getY() - m._yAccurate;
|
||||
}
|
||||
else
|
||||
{
|
||||
dx = m._xDestination - m._xAccurate;
|
||||
dy = m._yDestination - m._yAccurate;
|
||||
}
|
||||
}
|
||||
|
||||
// Z coordinate will follow client values
|
||||
@@ -5162,8 +5199,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
if (distFraction > 1)
|
||||
{
|
||||
// Set the position of the Creature to the destination
|
||||
super.setXYZ(m._xDestination, m._yDestination, m._zDestination);
|
||||
if (this instanceof BoatInstance)
|
||||
if (target != null)
|
||||
{
|
||||
super.setXYZ(target.getX(), target.getY(), target.getZ());
|
||||
}
|
||||
else
|
||||
{
|
||||
super.setXYZ(m._xDestination, m._yDestination, m._zDestination);
|
||||
}
|
||||
|
||||
if (isBoat())
|
||||
{
|
||||
((BoatInstance) this).updatePeopleInTheBoat(m._xDestination, m._yDestination, m._zDestination);
|
||||
}
|
||||
@@ -5344,6 +5389,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
return _target;
|
||||
}
|
||||
|
||||
public void moveToLocation(int xValue, int yValue, int zValue, int offsetValue)
|
||||
{
|
||||
moveToLocation(null, xValue, yValue, zValue, offsetValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate movement data for a move to location action and add the Creature to movingObjects of GameTimeController (only called by AI Accessor).<br>
|
||||
* <br>
|
||||
@@ -5364,12 +5414,13 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
* <b><u>Example of use</u>:</b><br>
|
||||
* <li>AI : onIntentionMoveTo(Location), onIntentionPickUp(WorldObject), onIntentionInteract(WorldObject)</li>
|
||||
* <li>FollowTask</li><br>
|
||||
* @param target The target to follow, if any.
|
||||
* @param xValue The X position of the destination
|
||||
* @param yValue The Y position of the destination
|
||||
* @param zValue The Y position of the destination
|
||||
* @param offsetValue The size of the interaction area of the Creature targeted
|
||||
*/
|
||||
protected void moveToLocation(int xValue, int yValue, int zValue, int offsetValue)
|
||||
protected void moveToLocation(WorldObject target, int xValue, int yValue, int zValue, int offsetValue)
|
||||
{
|
||||
// Block movement during Event start
|
||||
if (isPlayer())
|
||||
@@ -5645,6 +5696,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
// Calculate the number of ticks between the current position and the destination
|
||||
// One tick added for rounding reasons
|
||||
final int ticksToMove = 1 + (int) ((GameTimeController.TICKS_PER_SECOND * distance) / speed);
|
||||
m._target = target;
|
||||
m._xDestination = x;
|
||||
m._yDestination = y;
|
||||
m._zDestination = z; // this is what was requested from client
|
||||
|
@@ -92,7 +92,7 @@ public class DoorInstance extends Creature
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveTo(int x, int y, int z, int offset)
|
||||
public void moveTo(WorldObject target, int x, int y, int z, int offset)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.ai.CreatureAI;
|
||||
import org.l2jmobius.gameserver.ai.CtrlEvent;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Summon;
|
||||
@@ -95,7 +96,8 @@ public class CreatureFollowTaskManager
|
||||
}
|
||||
|
||||
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
|
||||
if (!creature.isInsideRadius(followTarget, followRange, true, false))
|
||||
final int followRangeWithCollision = followRange + creature.getTemplate().getCollisionRadius() + ((Creature) followTarget).getTemplate().getCollisionRadius();
|
||||
if (!creature.isInsideRadius(followTarget, followRangeWithCollision, true, false))
|
||||
{
|
||||
if (!creature.isInsideRadius(followTarget, 3000, true, false))
|
||||
{
|
||||
@@ -109,6 +111,10 @@ public class CreatureFollowTaskManager
|
||||
}
|
||||
ai.moveToPawn(followTarget, followRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
ThreadPool.execute(() -> ai.notifyEvent(CtrlEvent.EVT_ARRIVED));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user