Browse Source

can no longer run to invalid targets

feature-workorder
FatBoy-DOTC 1 year ago
parent
commit
426ef989f8
  1. 5
      src/engine/net/client/handlers/AttackCmdMsgHandler.java
  2. 40
      src/engine/net/client/handlers/MoveToPointHandler.java

5
src/engine/net/client/handlers/AttackCmdMsgHandler.java

@ -56,9 +56,12 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler {
case Building: case Building:
target = BuildingManager.getBuilding(msg.getTargetID()); target = BuildingManager.getBuilding(msg.getTargetID());
break; break;
case NPC:
target = NPC.getNPC(msg.getTargetID());
break;
} }
if(target == null) { if(target == null) {
playerCharacter.setCombatTarget(null);
return true; // cannot attack a null target return true; // cannot attack a null target
} }
//set sources target //set sources target

40
src/engine/net/client/handlers/MoveToPointHandler.java

@ -33,20 +33,38 @@ public class MoveToPointHandler extends AbstractClientMsgHandler {
if (pc == null) if (pc == null)
return false; return false;
AbstractWorldObject target = null; if(pc.combatTarget == null){
Enum.GameObjectType targetType; MovementManager.movement(msg, pc);
return true;
targetType = Enum.GameObjectType.values()[msg.getTargetType()]; } else{
switch(targetType){ Enum.GameObjectType combatTargetType = pc.combatTarget.getObjectType();
case Building: if(combatTargetType.equals(Enum.GameObjectType.NPC)){
int i = 1; msg.clearTarget();
break; pc.setCombatTarget(null);
case NPC: origin.sendMsg(msg);
int j = 1;
break;
} }
if(combatTargetType.equals(Enum.GameObjectType.Mob) || combatTargetType.equals(Enum.GameObjectType.PlayerCharacter)){
MovementManager.movement(msg, pc); MovementManager.movement(msg, pc);
return true; return true;
} else if(combatTargetType.equals(Enum.GameObjectType.Building)) {
Building targetBuilding = BuildingManager.getBuilding(pc.combatTarget.getObjectUUID());
if (targetBuilding != null) {
if (targetBuilding.isVulnerable() && targetBuilding.getRank() > -1) {
MovementManager.movement(msg, pc);
return true;
} else{
msg.clearTarget();
pc.setCombatTarget(null);
origin.sendMsg(msg);
}
}
}
}
pc.teleport(pc.loc);
msg.setEndCoord(pc.loc);
origin.sendMsg(msg);
return true;
} }
} }

Loading…
Cancel
Save