Broadcast MoveToLocation when Playable tries to reach a Playable target.

Thanks to Trance.
This commit is contained in:
MobiusDevelopment
2021-11-15 03:09:33 +00:00
parent 2e213a1133
commit 9c6f431961
155 changed files with 632 additions and 380 deletions

View File

@@ -527,7 +527,7 @@ public abstract class AbstractAI implements Ctrl
// return;
// }
// Send a Server->Client packet MoveToPawn/CharMoveToLocation to the actor and all PlayerInstance in its _knownPlayers
// Send a Server->Client packet MoveToPawn/MoveToLocation to the actor and all PlayerInstance in its _knownPlayers
if (pawn.isCreature())
{
if (_actor.isOnGeodataPath())
@@ -561,7 +561,7 @@ public abstract class AbstractAI implements Ctrl
}
/**
* Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet CharMoveToLocation <i>(broadcast)</i>.<br>
* Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation <i>(broadcast)</i>.<br>
* <font color=#FF0000><b><u>Caution</u>: Low level function, used by AI subclasses</b></font>
* @param x
* @param y
@@ -579,7 +579,7 @@ public abstract class AbstractAI implements Ctrl
// Calculate movement data for a move to location action and add the actor to movingObjects of GameTimeTaskManager
_actor.moveToLocation(x, y, z, 0);
// Send a Server->Client packet CharMoveToLocation to the actor and all PlayerInstance in its _knownPlayers
// Send a Server->Client packet MoveToLocation to the actor and all PlayerInstance in its _knownPlayers
_actor.broadcastMoveToLocation();
}
else
@@ -729,7 +729,7 @@ public abstract class AbstractAI implements Ctrl
}
/**
* Update the state of this actor client side by sending Server->Client packet MoveToPawn/CharMoveToLocation and AutoAttackStart to the PlayerInstance player.<br>
* Update the state of this actor client side by sending Server->Client packet MoveToPawn/MoveToLocation and AutoAttackStart to the PlayerInstance player.<br>
* <font color=#FF0000><b><u>Caution</u>: Low level function, used by AI subclasses</b></font>
* @param player The PlayerIstance to notify with state of this Creature
*/
@@ -744,7 +744,7 @@ public abstract class AbstractAI implements Ctrl
}
else
{
// Send a Server->Client packet CharMoveToLocation to the actor and all PlayerInstance in its _knownPlayers
// Send a Server->Client packet MoveToLocation to the actor and all PlayerInstance in its _knownPlayers
player.sendPacket(new MoveToLocation(_actor));
}
}

View File

@@ -663,7 +663,7 @@ public class AttackableAI extends CreatureAI
x1 = x1 > (offset + minRadius) ? (leader.getX() + x1) - offset : (leader.getX() - x1) + minRadius;
y1 = y1 > (offset + minRadius) ? (leader.getY() + y1) - offset : (leader.getY() - y1) + minRadius;
z1 = leader.getZ();
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet CharMoveToLocation (broadcast)
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
moveTo(x1, y1, z1);
return;
}
@@ -708,7 +708,7 @@ public class AttackableAI extends CreatureAI
z1 = npc.getZ();
}
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet CharMoveToLocation (broadcast)
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
final Location moveLoc = _actor.isFlying() ? new Location(x1, y1, z1) : GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), x1, y1, z1, npc.getInstanceId());
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
}

View File

@@ -340,7 +340,7 @@ public class CreatureAI extends AbstractAI
* <ul>
* <li>Stop the actor auto-attack server side AND client side by sending Server->Client packet AutoAttackStop (broadcast)</li>
* <li>Set the Intention of this AI to AI_INTENTION_MOVE_TO</li>
* <li>Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet CharMoveToLocation (broadcast)</li>
* <li>Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)</li>
* </ul>
*/
@Override
@@ -362,7 +362,7 @@ public class CreatureAI extends AbstractAI
// Abort the attack of the Creature and send Server->Client ActionFailed packet
_actor.abortAttack();
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet CharMoveToLocation (broadcast)
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
moveTo(loc.getX(), loc.getY(), loc.getZ());
}

View File

@@ -193,7 +193,7 @@ public class PlayerAI extends PlayableAI
* <ul>
* <li>Stop the actor auto-attack server side AND client side by sending Server->Client packet AutoAttackStop (broadcast)</li>
* <li>Set the Intention of this AI to AI_INTENTION_MOVE_TO</li>
* <li>Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet CharMoveToLocation (broadcast)</li>
* <li>Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)</li>
* </ul>
*/
@Override
@@ -227,7 +227,7 @@ public class PlayerAI extends PlayableAI
// Abort the attack of the Creature and send Server->Client ActionFailed packet
_actor.abortAttack();
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet CharMoveToLocation (broadcast)
// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet MoveToLocation (broadcast)
moveTo(loc.getX(), loc.getY(), loc.getZ());
}

View File

@@ -4100,6 +4100,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Set the timer of last position update to now
m._moveTimestamp = gameTicks;
// Broadcast MoveToLocation when Playable tries to reach a Playable target (once per second).
if (isPlayable())
{
final WorldObject target = _target;
if ((target != null) && target.isPlayable() && ((gameTicks % 10) == 0) && (calculateDistance3D(target) > 150))
{
broadcastPacket(new MoveToLocation(this));
}
}
if (distFraction > 1)
{
ThreadPool.execute(() -> getAI().notifyEvent(CtrlEvent.EVT_ARRIVED));
@@ -4238,7 +4248,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* <li>Add the Creature to movingObjects of the GameTimeTaskManager</li>
* <li>Create a task to notify the AI that Creature arrives at a check point of the movement</li>
* </ul>
* <font color=#FF0000><b><u>Caution</u>: This method DOESN'T send Server->Client packet MoveToPawn/CharMoveToLocation.</b></font><br>
* <font color=#FF0000><b><u>Caution</u>: This method DOESN'T send Server->Client packet MoveToPawn/MoveToLocation.</b></font><br>
* <br>
* <b><u>Example of use</u>:</b>
* <ul>
@@ -4586,7 +4596,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// the CtrlEvent.EVT_ARRIVED will be sent when the character will actually arrive
// to destination by GameTimeTaskManager
// Send a Server->Client packet CharMoveToLocation to the actor and all PlayerInstance in its _knownPlayers
// Send a Server->Client packet MoveToLocation to the actor and all PlayerInstance in its _knownPlayers
broadcastMoveToLocation();
return true;
}

View File

@@ -53,7 +53,7 @@ public class RequestRecordInfo implements IClientIncomingPacket
if (object.isCreature())
{
// Update the state of the Creature object client side by sending Server->Client packet
// MoveToPawn/CharMoveToLocation and AutoAttackStart to the PlayerInstance
// MoveToPawn/MoveToLocation and AutoAttackStart to the PlayerInstance
final Creature creature = (Creature) object;
if (creature.hasAI())
{