|
|
@ -12,7 +12,6 @@ import engine.job.JobContainer; |
|
|
|
import engine.job.JobScheduler; |
|
|
|
import engine.job.JobScheduler; |
|
|
|
import engine.jobs.AttackJob; |
|
|
|
import engine.jobs.AttackJob; |
|
|
|
import engine.jobs.DeferredPowerJob; |
|
|
|
import engine.jobs.DeferredPowerJob; |
|
|
|
import engine.math.Vector3f; |
|
|
|
|
|
|
|
import engine.mbEnums; |
|
|
|
import engine.mbEnums; |
|
|
|
import engine.net.client.ClientConnection; |
|
|
|
import engine.net.client.ClientConnection; |
|
|
|
import engine.net.client.msg.TargetedActionMsg; |
|
|
|
import engine.net.client.msg.TargetedActionMsg; |
|
|
@ -125,18 +124,12 @@ public enum CombatManager { |
|
|
|
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { |
|
|
|
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { |
|
|
|
if (!attacker.isCombat()) |
|
|
|
if (!attacker.isCombat()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
//check if this slot is on attack timer, if timer has passed clear it, else early exit
|
|
|
|
|
|
|
|
if(attacker.getTimers() != null && attacker.getTimers().containsKey("Attack"+slot.name())) |
|
|
|
|
|
|
|
if(attacker.getTimers().get("Attack"+slot.name()).timeToExecutionLeft() <= 0) |
|
|
|
|
|
|
|
attacker.getTimers().remove("Attack"+slot.name()); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
target.combatLock.writeLock().lock(); |
|
|
|
|
|
|
|
|
|
|
|
// check if character is in range to attack target
|
|
|
|
// check if character is in range to attack target
|
|
|
|
|
|
|
|
try { |
|
|
|
PlayerBonuses bonus = attacker.getBonuses(); |
|
|
|
PlayerBonuses bonus = attacker.getBonuses(); |
|
|
|
|
|
|
|
|
|
|
|
float rangeMod = 1.0f; |
|
|
|
float rangeMod = 1.0f; |
|
|
@ -473,7 +466,12 @@ public enum CombatManager { |
|
|
|
|
|
|
|
|
|
|
|
//set auto attack job
|
|
|
|
//set auto attack job
|
|
|
|
setAutoAttackJob(attacker, slot, delay); |
|
|
|
setAutoAttackJob(attacker, slot, delay); |
|
|
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
|
|
cancelAutoAttackJob(attacker,slot); |
|
|
|
|
|
|
|
//Logger.error("COMBAT CAUGHT ERROR: " + ex.getMessage());
|
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
target.combatLock.writeLock().unlock(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void toggleCombat(boolean toggle, ClientConnection origin) { |
|
|
|
public static void toggleCombat(boolean toggle, ClientConnection origin) { |
|
|
@ -624,7 +622,20 @@ public enum CombatManager { |
|
|
|
Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); |
|
|
|
Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
public static int calculatePetDamage(AbstractCharacter agent) { |
|
|
|
public static void cancelAutoAttackJob(AbstractCharacter attacker, mbEnums.EquipSlotType slot) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//handle auto attack job creation
|
|
|
|
|
|
|
|
ConcurrentHashMap<String, JobContainer> timers = attacker.getTimers(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (timers != null) { |
|
|
|
|
|
|
|
timers.get("Attack" + slot.name()).cancelJob(); |
|
|
|
|
|
|
|
} else |
|
|
|
|
|
|
|
Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static void calculatePetDamage(AbstractCharacter agent) { |
|
|
|
//damage calc for pet
|
|
|
|
//damage calc for pet
|
|
|
|
float range; |
|
|
|
float range; |
|
|
|
float damage; |
|
|
|
float damage; |
|
|
@ -636,7 +647,6 @@ public enum CombatManager { |
|
|
|
dmgMultiplier += agent.getLevel() * 0.1f; |
|
|
|
dmgMultiplier += agent.getLevel() * 0.1f; |
|
|
|
range = (float) (maxDmg - minDmg); |
|
|
|
range = (float) (maxDmg - minDmg); |
|
|
|
damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2; |
|
|
|
damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2; |
|
|
|
return (int) (damage * dmgMultiplier); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
public static double getMinDmg(double min, AbstractCharacter agent) { |
|
|
|
public static double getMinDmg(double min, AbstractCharacter agent) { |
|
|
|
int primary = agent.getStatStrCurrent(); |
|
|
|
int primary = agent.getStatStrCurrent(); |
|
|
|