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

@@ -480,7 +480,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())
@@ -514,7 +514,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
@@ -532,7 +532,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
@@ -679,7 +679,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
*/
@@ -694,7 +694,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

@@ -526,7 +526,7 @@ public class AttackableAI extends CreatureAI
y1 = (leader.getY() - y1) + minRadius;
}
// 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, leader.getZ());
}
else if (Rnd.get(RANDOM_WALK_RATE) == 0)
@@ -574,7 +574,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.getInstanceWorld());
moveTo(moveLoc.getX(), moveLoc.getY(), moveLoc.getZ());
}

View File

@@ -350,7 +350,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
@@ -379,7 +379,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

@@ -219,7 +219,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
@@ -248,7 +248,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

@@ -3142,6 +3142,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));
@@ -3282,7 +3292,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>
@@ -3630,7 +3640,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

@@ -51,7 +51,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())
{