diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 91410abd..45751ace 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -12,7 +12,6 @@ import engine.job.JobContainer; import engine.job.JobScheduler; import engine.jobs.AttackJob; import engine.jobs.DeferredPowerJob; -import engine.math.Vector3f; import engine.mbEnums; import engine.net.client.ClientConnection; import engine.net.client.msg.TargetedActionMsg; @@ -124,9 +123,9 @@ public enum CombatManager { 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()); + 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; } @@ -156,12 +155,12 @@ public enum CombatManager { boolean inRange = false; if (AbstractCharacter.IsAbstractCharacter(target)) { - attackRange += ((AbstractCharacter)target).calcHitBox(); + attackRange += ((AbstractCharacter) target).calcHitBox(); } else { } - if(attackRange > 15 && attacker.isMoving()){ + if (attackRange > 15 && attacker.isMoving()) { //cannot shoot bow while moving; return; } @@ -178,14 +177,14 @@ public enum CombatManager { inRange = true; break; case Building: - if(attackRange > 15){ + if (attackRange > 15) { float rangeSquared = (attackRange + target.getBounds().getHalfExtents().x) * (attackRange + target.getBounds().getHalfExtents().x); //float distanceSquared = attacker.loc.distanceSquared(target.loc); - if(distanceSquared < rangeSquared) { + if (distanceSquared < rangeSquared) { inRange = true; break; } - }else { + } else { float locX = target.loc.x - target.getBounds().getHalfExtents().x; float locZ = target.loc.z - target.getBounds().getHalfExtents().y; float sizeX = (target.getBounds().getHalfExtents().x + attackRange) * 2; @@ -309,7 +308,7 @@ public enum CombatManager { DispatchManager.sendToAllInRange(attacker, msg); //we need to send the animation even if the attacker misses - TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template,null,slot)); + TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot)); DispatchManager.sendToAllInRange(target, cmm); //set auto attack job @@ -349,7 +348,7 @@ public enum CombatManager { DispatchManager.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); //we need to send the animation even if the attacker misses - TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template,null,slot)); + TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot)); DispatchManager.sendToAllInRange(target, cmm); //set auto attack job setAutoAttackJob(attacker, slot, delay); @@ -364,7 +363,7 @@ public enum CombatManager { setAutoAttackJob(attacker, slot, delay); return; } - if(attacker.getObjectType().equals(mbEnums.GameObjectType.Mob) && ((Mob)attacker).isPet()) + if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob) && ((Mob) attacker).isPet()) calculatePetDamage(attacker); //get the damage type @@ -434,7 +433,7 @@ public enum CombatManager { if (resists.immuneTo(damageType)) { //set auto attack job //we need to send the animation even if the attacker misses - TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template,null,slot)); + TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot)); DispatchManager.sendToAllInRange(target, cmm); setAutoAttackJob(attacker, slot, delay); return; @@ -545,7 +544,7 @@ public enum CombatManager { } //Item has no equipment slots and should not try to return an animation, return default instead - if(wb.item_eq_slots_or == null || wb.item_eq_slots_or.isEmpty()){ + if (wb.item_eq_slots_or == null || wb.item_eq_slots_or.isEmpty()) { return 75; } @@ -554,15 +553,15 @@ public enum CombatManager { int random; //Item can only be equipped in one slot, return animation for that slot - if(wb.item_eq_slots_or.size() == 1){ + if (wb.item_eq_slots_or.size() == 1) { if (wb.item_eq_slots_or.iterator().next().equals(mbEnums.EquipSlotType.RHELD)) { anim = wb.weapon_attack_anim_right.get(0)[0]; if (dpj != null) { random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size()); anim = wb.weapon_attack_anim_right.get(random)[0]; } - }else { - anim = wb.weapon_attack_anim_left.get(0)[0]; + } else { + anim = wb.weapon_attack_anim_left.get(0)[0]; if (dpj != null) { random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size()); anim = wb.weapon_attack_anim_left.get(random)[0]; @@ -578,7 +577,7 @@ public enum CombatManager { random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size()); anim = wb.weapon_attack_anim_right.get(random)[0]; } - }else { + } else { anim = wb.weapon_attack_anim_left.get(0)[0]; if (dpj != null) { random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size()); @@ -588,8 +587,8 @@ public enum CombatManager { return anim; } - public static int getPassiveAnimation(mbEnums.PassiveType passiveType){ - switch(passiveType){ + public static int getPassiveAnimation(mbEnums.PassiveType passiveType) { + switch (passiveType) { case Block: return COMBAT_BLOCK_ANIMATION; case Parry: @@ -604,7 +603,7 @@ public enum CombatManager { public static void setAutoAttackJob(AbstractCharacter attacker, mbEnums.EquipSlotType slot, long delay) { //calculate next allowed attack and update the timestamp - if(attacker.getTimestamps().containsKey("Attack" + slot.name()) && attacker.getTimestamps().get("Attack" + slot.name()) > System.currentTimeMillis()) + if (attacker.getTimestamps().containsKey("Attack" + slot.name()) && attacker.getTimestamps().get("Attack" + slot.name()) > System.currentTimeMillis()) return; attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); @@ -621,6 +620,7 @@ public enum CombatManager { Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); } + public static int calculatePetDamage(AbstractCharacter agent) { //damage calc for pet float range; @@ -635,6 +635,7 @@ public enum CombatManager { damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2; return (int) (damage * dmgMultiplier); } + public static double getMinDmg(double min, AbstractCharacter agent) { int primary = agent.getStatStrCurrent(); int secondary = agent.getStatDexCurrent(); @@ -642,6 +643,7 @@ public enum CombatManager { int masteryLevel = 0; return min * (pow(0.0048 * primary + .049 * (primary - 0.75), 0.5) + pow(0.0066 * secondary + 0.064 * (secondary - 0.75), 0.5) + +0.01 * (focusLevel + masteryLevel)); } + public static double getMaxDmg(double max, AbstractCharacter agent) { int primary = agent.getStatStrCurrent(); int secondary = agent.getStatDexCurrent(); diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index b4cc9fd4..18afad56 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -100,7 +100,7 @@ public class MobAI { public static void attackPlayer(Mob mob, PlayerCharacter target) { try { - if(target == null || !target.isAlive() || !target.isActive() ) { + if (target == null || !target.isAlive() || !target.isActive()) { mob.setCombatTarget(null); return; } @@ -175,7 +175,7 @@ public class MobAI { public static void attackMob(Mob mob, Mob target) { try { - if(mob == null || target == null) + if (mob == null || target == null) return; if (mob.getRange() >= 30 && mob.isMoving()) @@ -975,36 +975,36 @@ public class MobAI { } private static void hamletGuardAggro(Mob mob) { - Realm realm = RealmMap.getRealmAtLocation(mob.loc); - if(realm.getRealmName().equals("Uthgaard")){ - HashSet loadedMobs = WorldGrid.getObjectsInRangePartial(mob.loc, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_MOB); - for (AbstractWorldObject awo : loadedMobs) { - Mob targetMob = (Mob) awo; - if (targetMob.equals(mob)) - continue; - if (!targetMob.isAlive() || targetMob.despawned) - continue; - if (targetMob.isPet()) - continue; - mob.combatTarget = targetMob; - return; - } - return; - } - HashSet loadedPlayers = WorldGrid.getObjectsInRangePartial(mob.loc, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_PLAYER); - for (AbstractWorldObject awo : loadedPlayers) { - PlayerCharacter pc = (PlayerCharacter) awo; - if (!pc.isAlive() || !pc.isActive()) + Realm realm = RealmMap.getRealmAtLocation(mob.loc); + if (realm.getRealmName().equals("Uthgaard")) { + HashSet loadedMobs = WorldGrid.getObjectsInRangePartial(mob.loc, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_MOB); + for (AbstractWorldObject awo : loadedMobs) { + Mob targetMob = (Mob) awo; + if (targetMob.equals(mob)) continue; - if (pc.guild.equals(Guild.getErrantGuild())) { - mob.combatTarget = pc; - return; - } - if (pc.guild.charter.equals(mob.guild.charter)) + if (!targetMob.isAlive() || targetMob.despawned) continue; + if (targetMob.isPet()) + continue; + mob.combatTarget = targetMob; + return; + } + return; + } + HashSet loadedPlayers = WorldGrid.getObjectsInRangePartial(mob.loc, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_PLAYER); + for (AbstractWorldObject awo : loadedPlayers) { + PlayerCharacter pc = (PlayerCharacter) awo; + if (!pc.isAlive() || !pc.isActive()) + continue; + if (pc.guild.equals(Guild.getErrantGuild())) { mob.combatTarget = pc; return; } + if (pc.guild.charter.equals(mob.guild.charter)) + continue; + mob.combatTarget = pc; + return; + } } private static void defaultLogic(Mob mob) { diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 7c48a3cd..e4f71827 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -806,7 +806,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { speed *= (1 + abstractCharacter.bonuses.getFloatPercentAll(ModType.WeaponSpeed, SourceType.None)); PlayerBonuses bonuses = abstractCharacter.bonuses; - if(bonuses != null){ + if (bonuses != null) { ModType modType = ModType.AttackDelay; for (AbstractEffectModifier mod : bonuses.bonusFloats.keySet()) { @@ -1829,7 +1829,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { Mob target = (Mob) this; if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter)) { - if(target.playerAgroMap.containsKey(attacker.getObjectUUID())) + if (target.playerAgroMap.containsKey(attacker.getObjectUUID())) target.playerAgroMap.put(attacker.getObjectUUID(), target.playerAgroMap.get(attacker.getObjectUUID()) + value); else target.playerAgroMap.put(attacker.getObjectUUID(), value); diff --git a/src/engine/objects/Bane.java b/src/engine/objects/Bane.java index a60be6d2..16c2c051 100644 --- a/src/engine/objects/Bane.java +++ b/src/engine/objects/Bane.java @@ -641,18 +641,18 @@ public final class Bane { return cityUUID; } - public void startBane(){ + public void startBane() { City city = this.getCity(); - if(city == null) + if (city == null) return; this.isStarted = true; //flag the bane as started - for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(city.loc,mbEnums.CityBoundsType.ZONE.halfExtents + 64,MBServerStatics.MASK_BUILDING)){ - Building building = (Building)awo; - if(building == null) + for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(city.loc, mbEnums.CityBoundsType.ZONE.halfExtents + 64, MBServerStatics.MASK_BUILDING)) { + Building building = (Building) awo; + if (building == null) continue; - if(building.protectionState.equals(ProtectionState.UNDERSIEGE) == false) + if (building.protectionState.equals(ProtectionState.UNDERSIEGE) == false) building.protectionState = ProtectionState.UNDERSIEGE; } diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index 42f3cb4d..5b52985b 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -300,7 +300,7 @@ public class City extends AbstractWorldObject { //handle compiling of cities able to be teleported to for lore rule-set for (AbstractGameObject ago : worldCities.values()) { City city = (City) ago; - if(city.cityName.equals("Perdition") || city.cityName.equals("Bastion")) + if (city.cityName.equals("Perdition") || city.cityName.equals("Bastion")) continue; // cannot teleport to perdition or bastion if (city.isNpc == 1 && city.getGuild().charter.equals(pc.guild.charter)) { cities.add(city); // anyone of the same charter can teleport to a safehold of that charter @@ -407,7 +407,7 @@ public class City extends AbstractWorldObject { //handle compiling of cities able to be repledged to for lore rule-set for (AbstractGameObject ago : worldCities.values()) { City city = (City) ago; - if(city.cityName.equals("Perdition") || city.cityName.equals("Bastion")) + if (city.cityName.equals("Perdition") || city.cityName.equals("Bastion")) continue; // cannot repledge to perdition or bastion if (city.isNpc == 1 && city.getGuild().charter.canJoin(playerCharacter)) { cities.add(city); // anyone of the same charter can teleport to a safehold of that charter diff --git a/src/engine/powers/poweractions/OpenGatePowerAction.java b/src/engine/powers/poweractions/OpenGatePowerAction.java index 8b946ec7..2812049b 100644 --- a/src/engine/powers/poweractions/OpenGatePowerAction.java +++ b/src/engine/powers/poweractions/OpenGatePowerAction.java @@ -11,7 +11,6 @@ package engine.powers.poweractions; import engine.math.Vector3fImmutable; import engine.mbEnums; -import engine.mbEnums.BuildingGroup; import engine.mbEnums.GameObjectType; import engine.mbEnums.PortalType; import engine.objects.AbstractCharacter; @@ -54,15 +53,17 @@ public class OpenGatePowerAction extends AbstractPowerAction { return; // Make sure target building is a runegate - if(targetBuilding.meshUUID != 24500) // runegate + + if (targetBuilding.meshUUID != 24500) // runegate return; // Which runegate was clicked on? + Runegate runeGate = Runegate._runegates.get(targetBuilding.getObjectUUID()); - if(runeGate == null){ + if (runeGate == null) return; // mob camp prop runegate cannot be opened - } + // Which portal was opened? token = pb.getToken(); @@ -72,41 +73,31 @@ public class OpenGatePowerAction extends AbstractPowerAction { case 428937084: //Death Gate portalType = PortalType.OBLIV; break; - case 429756284: //Chaos Gate portalType = PortalType.CHAOS; break; - case 429723516: //Khar Gate portalType = PortalType.MERCHANT; break; - case 429559676: //Spirit Gate portalType = PortalType.SPIRIT; break; - case 429592444: //Water Gate portalType = PortalType.WATER; break; - case 429428604: //Fire Gate portalType = PortalType.FIRE; break; - case 429526908: //Air Gate portalType = PortalType.AIR; break; - case 429625212: //Earth Gate portalType = PortalType.EARTH; break; - default: } - runeGate.activatePortal(portalType); - } @Override diff --git a/src/engine/workthreads/HourlyJobThread.java b/src/engine/workthreads/HourlyJobThread.java index 43c68b40..ae05915c 100644 --- a/src/engine/workthreads/HourlyJobThread.java +++ b/src/engine/workthreads/HourlyJobThread.java @@ -289,10 +289,10 @@ public class HourlyJobThread implements Runnable { Logger.info(PurgeOprhans.recordsDeleted.toString() + "orphaned items deleted"); } - public static void processBanes(){ + public static void processBanes() { //handle banes - for(Bane bane : Bane.banes.values()){ - if(bane.getLiveDate() != null && DateTime.now().isAfter(bane.getLiveDate().minusMinutes(1)) && bane.isStarted == false) + for (Bane bane : Bane.banes.values()) { + if (bane.getLiveDate() != null && DateTime.now().isAfter(bane.getLiveDate().minusMinutes(1)) && bane.isStarted == false) bane.startBane(); } }