// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . // ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· // ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ // ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ // ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ // Magicbane Emulator Project © 2013 - 2022 // www.magicbane.com package engine.net.client.handlers; import engine.Enum; import engine.exception.MsgSendException; import engine.gameManager.BuildingManager; import engine.gameManager.MovementManager; import engine.net.client.ClientConnection; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.MoveToPointMsg; import engine.objects.*; public class MoveToPointHandler extends AbstractClientMsgHandler { public MoveToPointHandler() { super(MoveToPointMsg.class); } @Override protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { MoveToPointMsg msg = (MoveToPointMsg) baseMsg; PlayerCharacter pc = (origin != null) ? (origin.getPlayerCharacter()) : null; if (pc == null) return false; AbstractWorldObject target = null; Enum.GameObjectType targetType; targetType = Enum.GameObjectType.values()[msg.getTargetType()]; switch(targetType){ case Building: target = BuildingManager.getBuilding(msg.getTargetID()); break; case NPC: target = NPC.getNPC(msg.getTargetID()); break; } if(target != null) { switch (target.getObjectType()) { case Building: target = BuildingManager.getBuilding(msg.getTargetID()); if (target == null) { pc.teleport(pc.loc); msg.setEndCoord(pc.loc); origin.sendMsg(msg); return true;// early exit for no building pulled } Building targetBuilding = (Building) target; if (!targetBuilding.isVulnerable() || targetBuilding.getRank() < 0) { pc.teleport(pc.loc); msg.setEndCoord(pc.loc); origin.sendMsg(msg); return true;// cannot attack destroyed building or protected building } break; case NPC: pc.teleport(pc.loc); msg.setEndCoord(pc.loc); origin.sendMsg(msg); return true;//cannot attack anything other than the 3 above } } MovementManager.movement(msg, pc); return true; } }