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

@@ -24,6 +24,7 @@ import org.l2jmobius.gameserver.GameTimeController;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.Skill;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.WorldRegion;
import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Playable;
@@ -493,17 +494,21 @@ abstract class AbstractAI implements Ctrl
{
if (_actor.isOnGeodataPath())
{
_actor.broadcastPacket(new CharMoveToLocation(_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 CharMoveToLocation(_actor));
_actor.broadcastMoveToLocation();
}
}
else
@@ -532,7 +537,7 @@ abstract class AbstractAI implements Ctrl
_accessor.moveTo(x, y, z);
// Send a Server->Client packet CharMoveToLocation to the actor and all PlayerInstance in its _knownPlayers
_actor.broadcastPacket(new CharMoveToLocation(_actor));
_actor.broadcastMoveToLocation();
}
else
{

View File

@@ -128,6 +128,7 @@ import org.l2jmobius.gameserver.network.serverpackets.PartySpelled;
import org.l2jmobius.gameserver.network.serverpackets.PetInfo;
import org.l2jmobius.gameserver.network.serverpackets.Revive;
import org.l2jmobius.gameserver.network.serverpackets.SetupGauge;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
import org.l2jmobius.gameserver.network.serverpackets.StopMove;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
@@ -390,6 +391,24 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
}
}
public void broadcastMoveToLocation()
{
final WorldRegion region = getWorldRegion();
if ((region != null) && region.isActive())
{
broadcastPacket(new CharMoveToLocation(this));
}
}
public void broadcastSocialAction(int id)
{
final WorldRegion region = getWorldRegion();
if ((region != null) && region.isActive())
{
broadcastPacket(new SocialAction(getObjectId(), id));
}
}
/**
* Need hp update.
* @param barPixels the bar pixels
@@ -5797,7 +5816,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
// the CtrlEvent.EVT_ARRIVED will be sent when the character will actually arrive to destination by GameTimeController
// Send a Server->Client packet CharMoveToLocation to the actor and all PlayerInstance in its _knownPlayers
broadcastPacket(new CharMoveToLocation(this));
broadcastMoveToLocation();
return true;
}

View File

@@ -92,7 +92,6 @@ import org.l2jmobius.gameserver.network.serverpackets.MyTargetSelected;
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import org.l2jmobius.gameserver.network.serverpackets.NpcInfo;
import org.l2jmobius.gameserver.network.serverpackets.RadarControl;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
@@ -149,7 +148,7 @@ public class NpcInstance extends Creature
if ((now - _lastSocialBroadcast) > MINIMUM_SOCIAL_INTERVAL)
{
_lastSocialBroadcast = now;
broadcastPacket(new SocialAction(getObjectId(), animationId));
broadcastSocialAction(animationId);
}
}
@@ -704,7 +703,7 @@ public class NpcInstance extends Creature
}
// Send a Server->Client packet SocialAction to the all PlayerInstance on the _knownPlayer of the NpcInstance to display a social action of the NpcInstance on their client
broadcastPacket(new SocialAction(getObjectId(), Rnd.get(8)));
broadcastSocialAction(Rnd.get(8));
// Open a chat window on client with the text of the NpcInstance
if (isEventMob)
{
@@ -993,7 +992,7 @@ public class NpcInstance extends Creature
}
// Send a Server->Client packet SocialAction to the all PlayerInstance on the _knownPlayer of the NpcInstance to display a social action of the NpcInstance on their client
broadcastPacket(new SocialAction(getObjectId(), Rnd.get(8)));
broadcastSocialAction(Rnd.get(8));
// Open a chat window on client with the text of the NpcInstance
if (isEventMob)
{

View File

@@ -23,7 +23,6 @@ import org.l2jmobius.gameserver.model.actor.instance.CabaleBufferInstance;
import org.l2jmobius.gameserver.model.actor.instance.FestivalGuideInstance;
import org.l2jmobius.gameserver.model.actor.instance.FolkInstance;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.network.serverpackets.CharMoveToLocation;
public class NpcKnownList extends CreatureKnownList
{
@@ -44,7 +43,7 @@ public class NpcKnownList extends CreatureKnownList
// Broadcast correct walking NPC position.
if (getActiveObject().isNpc() && (object instanceof Creature) && object.isPlayer() && getActiveChar().isMoving() && !getActiveChar().isInCombat())
{
((Creature) object).broadcastPacket(new CharMoveToLocation(getActiveChar()));
((Creature) object).broadcastMoveToLocation();
}
return true;
}