Files
lakebane/src/engine/net/client/handlers/MoveToPointHandler.java
T

63 lines
2.6 KiB
Java
Raw Normal View History

2022-04-30 09:41:17 -04:00
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.net.client.handlers;
2023-09-10 14:08:54 -05:00
import engine.Enum;
2022-04-30 09:41:17 -04:00
import engine.exception.MsgSendException;
2023-09-10 14:08:54 -05:00
import engine.gameManager.BuildingManager;
2022-04-30 09:41:17 -04:00
import engine.gameManager.MovementManager;
import engine.net.client.ClientConnection;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.MoveToPointMsg;
2023-09-10 14:08:54 -05:00
import engine.objects.*;
2022-04-30 09:41:17 -04:00
public class MoveToPointHandler extends AbstractClientMsgHandler {
public MoveToPointHandler() {
super(MoveToPointMsg.class);
}
@Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
2023-07-15 09:23:48 -04:00
ClientConnection origin) throws MsgSendException {
2022-04-30 09:41:17 -04:00
MoveToPointMsg msg = (MoveToPointMsg) baseMsg;
PlayerCharacter pc = (origin != null) ? (origin.getPlayerCharacter()) : null;
if (pc == null)
return false;
if (msg.getInitiatedFromAttack() == 1) {
//move message was initiated by an attack message
2023-09-10 16:45:17 -05:00
Enum.GameObjectType combatTargetType = pc.combatTarget.getObjectType();
if (combatTargetType.equals(Enum.GameObjectType.NPC)) {
2023-09-10 16:45:17 -05:00
msg.clearTarget();
pc.setCombatTarget(null);
origin.sendMsg(msg);
} else if (combatTargetType.equals(Enum.GameObjectType.Building)) {
2023-09-10 16:45:17 -05:00
Building targetBuilding = BuildingManager.getBuilding(pc.combatTarget.getObjectUUID());
if (targetBuilding != null) {
if (!targetBuilding.isVulnerable() || targetBuilding.getRank() < 0) {
2023-09-10 16:45:17 -05:00
msg.clearTarget();
pc.setCombatTarget(null);
origin.sendMsg(msg);
}
}
}
msg.setEndCoord(pc.loc);
origin.sendMsg(msg);
return true;
2023-09-10 14:58:56 -05:00
}
MovementManager.movement(msg, pc);
2022-04-30 09:41:17 -04:00
return true;
}
}