|
|
@ -30,8 +30,6 @@ import java.util.HashSet; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.ThreadLocalRandom; |
|
|
|
import java.util.concurrent.ThreadLocalRandom; |
|
|
|
|
|
|
|
|
|
|
|
import static engine.math.FastMath.sqr; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public enum CombatManager { |
|
|
|
public enum CombatManager { |
|
|
|
|
|
|
|
|
|
|
|
COMBATMANAGER; |
|
|
|
COMBATMANAGER; |
|
|
@ -41,63 +39,6 @@ public enum CombatManager { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Message sent by player to attack something. |
|
|
|
* Message sent by player to attack something. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static void setAttackTarget(AttackCmdMsg msg, ClientConnection origin) throws MsgSendException { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PlayerCharacter player; |
|
|
|
|
|
|
|
int targetType; |
|
|
|
|
|
|
|
AbstractWorldObject target; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (TargetedActionMsg.un2cnt == 60 || TargetedActionMsg.un2cnt == 70) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
player = SessionManager.getPlayerCharacter(origin); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (player == null) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//source must match player this account belongs to
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (player.getObjectUUID() != msg.getSourceID() || player.getObjectType().ordinal() != msg.getSourceType()) { |
|
|
|
|
|
|
|
Logger.error("Msg Source ID " + msg.getSourceID() + " Does not Match Player ID " + player.getObjectUUID()); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
targetType = msg.getTargetType(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (targetType == GameObjectType.PlayerCharacter.ordinal()) { |
|
|
|
|
|
|
|
target = PlayerCharacter.getFromCache(msg.getTargetID()); |
|
|
|
|
|
|
|
} else if (targetType == GameObjectType.Building.ordinal()) { |
|
|
|
|
|
|
|
target = BuildingManager.getBuildingFromCache(msg.getTargetID()); |
|
|
|
|
|
|
|
} else if (targetType == GameObjectType.Mob.ordinal()) { |
|
|
|
|
|
|
|
target = Mob.getFromCache(msg.getTargetID()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
player.setCombatTarget(null); |
|
|
|
|
|
|
|
return; //not valid type to attack
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// quit of the combat target is already the current combat target
|
|
|
|
|
|
|
|
// or there is no combat target
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (target == null) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//set sources target
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
player.setCombatTarget(target); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//put in combat if not already
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!player.isCombat()) |
|
|
|
|
|
|
|
toggleCombat(true, origin); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//make character stand if sitting
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (player.isSit()) |
|
|
|
|
|
|
|
toggleSit(false, origin); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AttackTarget(player, target); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void AttackTarget(PlayerCharacter playerCharacter, AbstractWorldObject target) { |
|
|
|
public static void AttackTarget(PlayerCharacter playerCharacter, AbstractWorldObject target) { |
|
|
|
|
|
|
|
|
|
|
@ -1184,7 +1125,7 @@ public enum CombatManager { |
|
|
|
toggleCombat(msg.getToggle(), origin); |
|
|
|
toggleCombat(msg.getToggle(), origin); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void toggleCombat(boolean toggle, ClientConnection origin) { |
|
|
|
public static void toggleCombat(boolean toggle, ClientConnection origin) { |
|
|
|
|
|
|
|
|
|
|
|
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); |
|
|
|
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); |
|
|
|
|
|
|
|
|
|
|
@ -1201,7 +1142,7 @@ public enum CombatManager { |
|
|
|
DispatchMessage.dispatchMsgToInterestArea(pc, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); |
|
|
|
DispatchMessage.dispatchMsgToInterestArea(pc, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void toggleSit(boolean toggle, ClientConnection origin) { |
|
|
|
public static void toggleSit(boolean toggle, ClientConnection origin) { |
|
|
|
|
|
|
|
|
|
|
|
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); |
|
|
|
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); |
|
|
|
|
|
|
|
|
|
|
|