|
|
@ -9,6 +9,7 @@ import engine.net.client.msg.AttackCmdMsg; |
|
|
|
import engine.net.client.msg.ClientNetMsg; |
|
|
|
import engine.net.client.msg.ClientNetMsg; |
|
|
|
import engine.net.client.msg.TargetedActionMsg; |
|
|
|
import engine.net.client.msg.TargetedActionMsg; |
|
|
|
import engine.objects.AbstractWorldObject; |
|
|
|
import engine.objects.AbstractWorldObject; |
|
|
|
|
|
|
|
import engine.objects.Building; |
|
|
|
import engine.objects.Mob; |
|
|
|
import engine.objects.Mob; |
|
|
|
import engine.objects.PlayerCharacter; |
|
|
|
import engine.objects.PlayerCharacter; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
@ -39,7 +40,6 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler { |
|
|
|
msg = (AttackCmdMsg) baseMsg; |
|
|
|
msg = (AttackCmdMsg) baseMsg; |
|
|
|
|
|
|
|
|
|
|
|
int targetType; |
|
|
|
int targetType; |
|
|
|
AbstractWorldObject target; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (TargetedActionMsg.un2cnt == 60 || TargetedActionMsg.un2cnt == 70) |
|
|
|
if (TargetedActionMsg.un2cnt == 60 || TargetedActionMsg.un2cnt == 70) |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -54,26 +54,21 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
targetType = msg.getTargetType(); |
|
|
|
AbstractWorldObject target = playerCharacter.combatTarget; |
|
|
|
|
|
|
|
if(target == null) |
|
|
|
if (targetType == Enum.GameObjectType.PlayerCharacter.ordinal()) { |
|
|
|
return true; // cannot attack a null target
|
|
|
|
target = PlayerCharacter.getFromCache(msg.getTargetID()); |
|
|
|
|
|
|
|
} else if (targetType == Enum.GameObjectType.Building.ordinal()) { |
|
|
|
switch(target.getObjectType()){ |
|
|
|
target = BuildingManager.getBuildingFromCache(msg.getTargetID()); |
|
|
|
case NPC: |
|
|
|
} else if (targetType == Enum.GameObjectType.Mob.ordinal()) { |
|
|
|
playerCharacter.setCombatTarget(null); |
|
|
|
target = Mob.getFromCache(msg.getTargetID()); |
|
|
|
return true; //cannot attack NPCs
|
|
|
|
} else { |
|
|
|
case Building: |
|
|
|
playerCharacter.setCombatTarget(null); |
|
|
|
Building targetBuilding = (Building) target; |
|
|
|
return true; //not valid type to attack
|
|
|
|
if(!targetBuilding.isVulnerable() || targetBuilding.getRank() < 0) |
|
|
|
|
|
|
|
playerCharacter.setCombatTarget(null); |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// quit of the combat target is already the current combat target
|
|
|
|
|
|
|
|
// or there is no combat target
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (target == null) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//set sources target
|
|
|
|
//set sources target
|
|
|
|
|
|
|
|
|
|
|
|
playerCharacter.setCombatTarget(target); |
|
|
|
playerCharacter.setCombatTarget(target); |
|
|
|