Broadcast movement and social action packets when region is active.

This commit is contained in:
MobiusDevelopment
2021-03-16 23:55:59 +00:00
parent 510bb0fc2b
commit 2d987325eb
90 changed files with 715 additions and 333 deletions

View File

@@ -23,6 +23,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
import org.l2jmobius.gameserver.GameTimeController;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.WorldRegion;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@@ -543,17 +544,21 @@ public abstract class AbstractAI implements Ctrl
{
if (_actor.isOnGeodataPath())
{
_actor.broadcastPacket(new MoveToLocation(_actor));
_actor.broadcastMoveToLocation();
_clientMovingToPawnOffset = 0;
}
else if (sendPacket)
{
_actor.broadcastPacket(new MoveToPawn(_actor, (Creature) pawn, offset));
final WorldRegion region = _actor.getWorldRegion();
if ((region != null) && region.isActive())
{
_actor.broadcastPacket(new MoveToPawn(_actor, (Creature) pawn, offset));
}
}
}
else
{
_actor.broadcastPacket(new MoveToLocation(_actor));
_actor.broadcastMoveToLocation();
}
}
else
@@ -587,7 +592,7 @@ public abstract class AbstractAI implements Ctrl
_actor.moveToLocation(x, y, z, 0);
// Send a Server->Client packet CharMoveToLocation to the actor and all PlayerInstance in its _knownPlayers
_actor.broadcastPacket(new MoveToLocation(_actor));
_actor.broadcastMoveToLocation();
}
else
{

View File

@@ -575,6 +575,24 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
});
}
public void broadcastMoveToLocation()
{
final WorldRegion region = getWorldRegion();
if ((region != null) && region.isActive())
{
broadcastPacket(new MoveToLocation(this));
}
}
public void broadcastSocialAction(int id)
{
final WorldRegion region = getWorldRegion();
if ((region != null) && region.isActive())
{
broadcastPacket(new SocialAction(getObjectId(), id));
}
}
/**
* @return true if hp update should be done, false if not
*/
@@ -4063,7 +4081,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
m._moveTimestamp = gameTicks;
// Send a Server->Client packet MoveToLocation to the actor and all known PlayerInstance.
broadcastPacket(new MoveToLocation(this));
broadcastMoveToLocation();
if (distFraction > 1)
{
ThreadPool.execute(() -> getAI().notifyEvent(CtrlEvent.EVT_ARRIVED));
@@ -4558,7 +4576,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// to destination by GameTimeController
// Send a Server->Client packet CharMoveToLocation to the actor and all PlayerInstance in its _knownPlayers
broadcastPacket(new MoveToLocation(this));
broadcastMoveToLocation();
return true;
}
@@ -6282,11 +6300,6 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.isAffected(flag);
}
public void broadcastSocialAction(int id)
{
broadcastPacket(new SocialAction(getObjectId(), id));
}
public Team getTeam()
{
return _team;

View File

@@ -99,7 +99,6 @@ import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import org.l2jmobius.gameserver.network.serverpackets.NpcSay;
import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.taskmanager.DecayTaskManager;
import org.l2jmobius.gameserver.util.Broadcast;
@@ -260,7 +259,7 @@ public class Npc extends Creature
if ((now - _lastSocialBroadcast) > MINIMUM_SOCIAL_INTERVAL)
{
_lastSocialBroadcast = now;
broadcastPacket(new SocialAction(getObjectId(), animationId));
broadcastSocialAction(animationId);
}
}