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;
@ -480,17 +481,21 @@ public abstract class AbstractAI implements Ctrl
{
if (_actor.isOnGeodataPath())
{
_actor.broadcastPacket(new MoveToLocation(_actor));
_actor.broadcastMoveToLocation();
_clientMovingToPawnOffset = 0;
}
else
{
_actor.broadcastPacket(new MoveToPawn(_actor, pawn, offset));
final WorldRegion region = _actor.getWorldRegion();
if ((region != null) && region.isActive())
{
_actor.broadcastPacket(new MoveToPawn(_actor, pawn, offset));
}
}
}
else
{
_actor.broadcastPacket(new MoveToLocation(_actor));
_actor.broadcastMoveToLocation();
}
}
else
@ -524,7 +529,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

@ -29,7 +29,6 @@ import org.l2jmobius.gameserver.model.actor.instance.DoppelgangerInstance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillCaster;
import org.l2jmobius.gameserver.network.serverpackets.MoveToLocation;
public class DoppelgangerAI extends CreatureAI
{
@ -261,7 +260,7 @@ public class DoppelgangerAI extends CreatureAI
// Doppelgangers always send MoveToLocation packet.
if (sendPacket)
{
_actor.broadcastPacket(new MoveToLocation(_actor));
_actor.broadcastMoveToLocation();
}
}
else

View File

@ -652,6 +652,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
*/
@ -3126,7 +3144,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));
@ -3623,7 +3641,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;
}
@ -4850,11 +4868,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

@ -101,7 +101,6 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcInfo;
import org.l2jmobius.gameserver.network.serverpackets.NpcInfoAbnormalVisualEffect;
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;
@ -208,7 +207,7 @@ public class Npc extends Creature
if ((now - _lastSocialBroadcast) > MINIMUM_SOCIAL_INTERVAL)
{
_lastSocialBroadcast = now;
broadcastPacket(new SocialAction(getObjectId(), animationId));
broadcastSocialAction(animationId);
}
}