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. 42
      src/engine/net/client/handlers/MoveToPointHandler.java

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

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

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

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

Loading…
Cancel
Save