forked from MagicBane/Server
use target from message in move to point
This commit is contained in:
@@ -33,20 +33,48 @@ public class MoveToPointHandler extends AbstractClientMsgHandler {
|
|||||||
if (pc == null)
|
if (pc == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
AbstractWorldObject target = pc.combatTarget;
|
AbstractWorldObject target;
|
||||||
Enum.GameObjectType targetType;
|
Enum.GameObjectType targetType;
|
||||||
|
|
||||||
|
targetType = Enum.GameObjectType.values()[msg.getTargetType()];
|
||||||
|
|
||||||
|
switch(targetType){
|
||||||
|
case Mob:
|
||||||
|
target = Mob.getMob(msg.getTargetID());
|
||||||
|
break;
|
||||||
|
case PlayerCharacter:
|
||||||
|
target = PlayerCharacter.getPlayerCharacter(msg.getTargetID());
|
||||||
|
break;
|
||||||
|
case Building:
|
||||||
|
target = BuildingManager.getBuilding(msg.getTargetID());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
target = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(target != null) {
|
if(target != null) {
|
||||||
switch (target.getObjectType()) {
|
switch (target.getObjectType()) {
|
||||||
case Building:
|
case Building:
|
||||||
target = BuildingManager.getBuilding(msg.getTargetID());
|
target = BuildingManager.getBuilding(msg.getTargetID());
|
||||||
if (target == null)
|
if (target == null) {
|
||||||
|
pc.teleport(pc.loc);
|
||||||
|
msg.setEndCoord(pc.loc);
|
||||||
|
origin.sendMsg(msg);
|
||||||
return true;// early exit for no building pulled
|
return true;// early exit for no building pulled
|
||||||
|
}
|
||||||
Building targetBuilding = (Building) target;
|
Building targetBuilding = (Building) target;
|
||||||
if (!targetBuilding.isVulnerable() || targetBuilding.getRank() < 0)
|
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
|
return true;// cannot attack destroyed building or protected building
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NPC:
|
case NPC:
|
||||||
|
pc.teleport(pc.loc);
|
||||||
|
msg.setEndCoord(pc.loc);
|
||||||
|
origin.sendMsg(msg);
|
||||||
return true;//cannot attack anything other than the 3 above
|
return true;//cannot attack anything other than the 3 above
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user