diff --git a/src/engine/gameManager/MovementManager.java b/src/engine/gameManager/MovementManager.java index 977d424c..644569b7 100644 --- a/src/engine/gameManager/MovementManager.java +++ b/src/engine/gameManager/MovementManager.java @@ -316,17 +316,6 @@ public enum MovementManager { else Logger.debug("Movement sync is good - desyncDist = " + desyncDist); - if (ac.getDebug(1) && ac.getObjectType().equals(GameObjectType.PlayerCharacter)) - if (desyncDist > MBServerStatics.MOVEMENT_DESYNC_TOLERANCE * MBServerStatics.MOVEMENT_DESYNC_TOLERANCE) { - PlayerCharacter pc = (PlayerCharacter) ac; - ChatManager.chatSystemInfo(pc, - "Movement out of sync for " + ac.getFirstName() - + ", Server Loc: " + serverLoc.getX() + ' ' + serverLoc.getZ() - + " , Client loc: " + clientLoc.getX() + ' ' + clientLoc.getZ() - + " desync distance " + desyncDist - + " moving=" + ac.isMoving()); - } - // return indicator that the two are in sync or not return (desyncDist < 100f * 100f); @@ -351,9 +340,6 @@ public enum MovementManager { + " moving=" + ac.isMoving() + " and current location is " + curLoc.getX() + ' ' + curLoc.getZ()); - if (ac.getDebug(1) && ac.getObjectType().equals(GameObjectType.PlayerCharacter)) - ChatManager.chatSystemInfo((PlayerCharacter) ac, "Finished Alt change, setting the end location to " + ac.getEndLoc().getX() + ' ' + ac.getEndLoc().getZ() + " moving=" + ac.isMoving() + " and current location is " + curLoc.getX() + ' ' + curLoc.getZ()); - //Send run/walk/sit/stand to tell the client we are flying / landing etc ac.update(); ac.stopMovement(ac.getLoc()); diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index baf4c252..0942cf6c 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -2261,12 +2261,8 @@ public enum PowersManager { defense = tar.getDefenseRating(); } else defense = 0f; - // Get hit chance - if (pc.getDebug(16)) { - String smsg = "ATR: " + atr + ", Defense: " + defense; - ChatManager.chatSystemInfo(pc, smsg); - } + // Get hit chance int chance; diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index b36b1f88..aaef3730 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -672,28 +672,28 @@ public abstract class AbstractCharacter extends AbstractWorldObject { // make sure weapon exists boolean noWeapon = false; - ItemTemplate wb = null; + ItemTemplate weaponTemplate = null; + if (weapon == null) noWeapon = true; else { - ItemTemplate ib = weapon.template; - if (ib == null) + ItemTemplate itemTemplate = weapon.template; + + if (itemTemplate == null) noWeapon = true; else if (!weapon.template.item_type.equals(ItemType.WEAPON)) { defaultAtrAndDamage(abstractCharacter, mainHand); return; } else - wb = ib; + weaponTemplate = itemTemplate; } + float skillPercentage, masteryPercentage; float mastDam; int min, max; float speed = 20f; boolean strBased = false; - ItemTemplate wbMain = (weapon != null) ? weapon.template : null; - ItemTemplate wbOff = (otherHand != null) ? otherHand.template : null; - // get skill percentages and min and max damage for weapons if (noWeapon) { if (mainHand) { @@ -711,6 +711,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { skillPercentage = getModifiedAmount(abstractCharacter.skills.get("Unarmed Combat")); masteryPercentage = getModifiedAmount(abstractCharacter.skills.get("Unarmed Combat Mastery")); + if (masteryPercentage == 0f) mastDam = CharacterSkill.getQuickMastery(abstractCharacter, "Unarmed Combat Mastery"); else @@ -733,17 +734,21 @@ public abstract class AbstractCharacter extends AbstractWorldObject { abstractCharacter.rangeHandTwo *= range_bonus; } + skillPercentage = getModifiedAmount(abstractCharacter.skills.get(weapon.template.item_skill_used)); - masteryPercentage = getModifiedAmount(abstractCharacter.skills.get(wb.item_skill_mastery_used)); + masteryPercentage = getModifiedAmount(abstractCharacter.skills.get(weaponTemplate.item_skill_mastery_used)); + if (masteryPercentage == 0f) mastDam = 0f; // mastDam = CharacterSkill.getQuickMastery(this, wb.getMastery()); else mastDam = masteryPercentage; - int[] damages = (int[]) wb.item_weapon_damage.values().toArray()[0]; + int[] damages = (int[]) weaponTemplate.item_weapon_damage.values().toArray()[0]; + min = damages[0]; max = damages[1]; - strBased = wb.item_primary_attr.equals(AttributeType.Strength); + + strBased = weaponTemplate.item_primary_attr.equals(AttributeType.Strength); // // Add parry bonus for weapon and allow parry if needed @@ -803,13 +808,15 @@ public abstract class AbstractCharacter extends AbstractWorldObject { } //calculate speed - if (wb != null) - speed = wb.item_weapon_wepspeed; + if (weaponTemplate != null) + speed = weaponTemplate.item_weapon_wepspeed; else speed = 20f; //unarmed attack speed if (weapon != null) speed *= (1 + abstractCharacter.bonuses.getFloatPercentAll(ModType.WeaponSpeed, SourceType.NONE)); + speed *= (1 + abstractCharacter.bonuses.getFloatPercentAll(ModType.AttackDelay, SourceType.NONE)); + if (speed < 10) speed = 10; @@ -822,6 +829,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { min += weapon.getBonus(ModType.MeleeDamageModifier, SourceType.NONE); max += weapon.getBonus(ModType.MeleeDamageModifier, SourceType.NONE); + // Finally use any multipliers. DO THIS LAST! float percentMinDamage = 1; @@ -839,8 +847,10 @@ public abstract class AbstractCharacter extends AbstractWorldObject { } //if duel wielding, cut damage by 30% + if (otherHand != null) { ItemTemplate ibo = otherHand.template; + if (ibo != null && otherHand.template.equals(ItemType.WEAPON)) { min *= 0.7f; max *= 0.7f; @@ -910,9 +920,9 @@ public abstract class AbstractCharacter extends AbstractWorldObject { if (ItemTemplate.isShield(shield) == false) return 0; - ItemTemplate ab = shield.template; + ItemTemplate template = shield.template; - if (ab == null) + if (template == null) return 0; CharacterSkill blockSkill = abstractCharacter.skills.get("Block"); @@ -924,9 +934,10 @@ public abstract class AbstractCharacter extends AbstractWorldObject { } else skillMod = blockSkill.getModifiedAmount(); - float def = ab.item_defense_rating; + float def = template.item_defense_rating; //apply item defense bonuses + if (shield != null) { def += shield.getBonus(ModType.DR, SourceType.NONE); def *= (1 + shield.getBonusPercent(ModType.DR, SourceType.NONE)); @@ -983,39 +994,45 @@ public abstract class AbstractCharacter extends AbstractWorldObject { * @ Calculates Defense for weapon */ private static float getWeaponDefense(AbstractCharacter abstractCharacter, ConcurrentHashMap equipped) { + Item weapon = equipped.get(EquipSlotType.RHELD); - ItemTemplate wb = null; + ItemTemplate weaponTemplate = null; CharacterSkill skill, mastery; float val = 0; boolean unarmed = false; + if (weapon == null) { weapon = equipped.get(EquipSlotType.LHELD); if (weapon == null || ItemTemplate.isShield(weapon)) unarmed = true; else - wb = weapon.template; + weaponTemplate = weapon.template; } else - wb = weapon.template; - if (wb == null) + weaponTemplate = weapon.template; + + if (weaponTemplate == null) unarmed = true; + if (unarmed) { skill = abstractCharacter.skills.get("Unarmed Combat"); mastery = abstractCharacter.skills.get("Unarmed Combat Mastery"); } else { skill = abstractCharacter.skills.get(weapon.template.item_skill_used); - mastery = abstractCharacter.skills.get(wb.item_skill_mastery_used); + mastery = abstractCharacter.skills.get(weaponTemplate.item_skill_mastery_used); } + if (skill != null) val += (int) skill.getModifiedAmount() / 2f; + if (mastery != null) val += (int) mastery.getModifiedAmount() / 2f; + return val; } //Don't call this function directly. linked from pc.calculateSkills() //through SkillCalcJob. Designed to only run from one worker thread public static void runSkillCalc(AbstractCharacter abstractCharacter) { - try { //see if any new skills or powers granted CharacterSkill.calculateSkills(abstractCharacter); @@ -1024,18 +1041,20 @@ public abstract class AbstractCharacter extends AbstractWorldObject { //see if any new powers unlocked from previous check CharacterPower.calculatePowers(abstractCharacter); - } catch (Exception e) { - } - } //calculate item bonuses here public static void calculateItemBonuses(AbstractCharacter abstractCharacter) { + if (abstractCharacter.charItemManager == null || abstractCharacter.bonuses == null) return; + ConcurrentHashMap equipped = abstractCharacter.charItemManager.getEquipped(); + for (Item item : equipped.values()) { + ItemTemplate ib = item.template; + if (ib == null) continue; //TODO add effect bonuses in here for equipped items @@ -1046,6 +1065,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { * @ Defaults ATR, Defense and Damage for player */ private static void defaultAtrAndDamage(AbstractCharacter abstractCharacter, boolean mainHand) { + if (mainHand) { abstractCharacter.atrHandOne = 0; abstractCharacter.minDamageHandOne = 0; @@ -1136,22 +1156,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { public final short getUnusedStatPoints() { return this.unusedStatPoints; } - - public final void setDebug( - final int value, - final boolean toggle - ) { - if (toggle) { - this.debug |= value; //turn on debug - } else { - this.debug &= ~value; //turn off debug - } - } - - public final boolean getDebug(final int value) { - return ((this.debug & value) != 0); - } - @Override public String getName() { if (this.firstName.length() == 0 && this.lastName.length() == 0) { diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 8218d390..db630df8 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -2760,8 +2760,6 @@ public class PlayerCharacter extends AbstractCharacter { } public int getSeeInvis() { - if (this.getDebug(8)) //<-added for see invis debug devcmd - return 10000; return this.seeInvis; } @@ -4389,21 +4387,14 @@ public class PlayerCharacter extends AbstractCharacter { this.stopMovement(newLoc); return; } + if (newLoc.equals(this.getEndLoc())) { this.stopMovement(newLoc); - if (this.getDebug(1)) - ChatManager.chatSystemInfo(this, - "Arrived at End location. " + this.getEndLoc()); return; - //Next upda } setLoc(newLoc); - if (this.getDebug(1)) - ChatManager.chatSystemInfo(this, - "Distance to target " + this.getEndLoc().distance2D(this.getLoc()) + " speed " + this.getSpeed()); - if (this.getStamina() < 10) MovementManager.sendOOS(this); diff --git a/src/engine/objects/Resists.java b/src/engine/objects/Resists.java index c65fb237..ce1428e4 100644 --- a/src/engine/objects/Resists.java +++ b/src/engine/objects/Resists.java @@ -14,7 +14,6 @@ import engine.Enum.ModType; import engine.Enum.SourceType; import engine.gameManager.ChatManager; import engine.gameManager.DbManager; -import engine.powers.EffectsBase; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; @@ -326,28 +325,15 @@ public class Resists { public float getResistedDamage(AbstractCharacter source, AbstractCharacter target, SourceType type, float damage, int trains) { //handle fortitudes damage = handleFortitude(target, type, damage); + //calculate armor piercing float ap = source.getBonuses().getFloatPercentAll(ModType.ArmorPiercing, SourceType.NONE); float damageAfterResists = damage * (1 - (this.getResist(type, trains) * 0.01f) + ap); + //check to see if any damage absorbers should cancel - if (target != null) { - //debug damage shields if any found - if (source.getDebug(2) && source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { - Effect da = target.getDamageAbsorber(); - if (da != null && da.getEffectsBase() != null) { - EffectsBase eb = da.getEffectsBase(); - String text = "Damage: " + damage + '\n'; - text += "Damage after resists: " + damageAfterResists + '\n'; - text += "Attack damage type: " + type.name() + '\n'; - text += "Fortitude damage types; " + eb.getDamageTypes() + '\n'; - text += "Fortitude damage before attack: " + da.getDamageAmount() + '\n'; - text += "Fortitude total health: " + eb.getDamageAmount(da.getTrains()) + '\n'; - text += "Fortitude trains: " + da.getTrains(); - ChatManager.chatSystemInfo((PlayerCharacter) source, text); - } - } + if (target != null) target.cancelOnTakeDamage(type, (damageAfterResists)); - } + return damageAfterResists; } diff --git a/src/engine/powers/effectmodifiers/HealthEffectModifier.java b/src/engine/powers/effectmodifiers/HealthEffectModifier.java index ba979109..7542ce68 100644 --- a/src/engine/powers/effectmodifiers/HealthEffectModifier.java +++ b/src/engine/powers/effectmodifiers/HealthEffectModifier.java @@ -12,7 +12,6 @@ package engine.powers.effectmodifiers; import engine.Enum.GameObjectType; import engine.Enum.ModType; import engine.Enum.SourceType; -import engine.gameManager.ChatManager; import engine.jobs.AbstractEffectJob; import engine.jobs.DamageOverTimeJob; import engine.net.AbstractNetMsg; @@ -83,12 +82,6 @@ public class HealthEffectModifier extends AbstractEffectModifier { modAmount *= 2.5f; } - //debug for spell damage and atr - if (source.getDebug(16) && source.getObjectType().equals(GameObjectType.PlayerCharacter)) { - PlayerCharacter pc = (PlayerCharacter) source; - String smsg = "Percent Damage: " + mod * 100 + '%'; - ChatManager.chatSystemInfo(pc, smsg); - } } // Modify health by min/max amount @@ -124,11 +117,6 @@ public class HealthEffectModifier extends AbstractEffectModifier { min = HealthEffectModifier.getMinDamage(min, intt, spi, focus); max = HealthEffectModifier.getMaxDamage(max, intt, spi, focus); - //debug for spell damage and atr - if (pc.getDebug(16)) { - String smsg = "Damage: " + (int) Math.abs(min) + " - " + (int) Math.abs(max); - ChatManager.chatSystemInfo(pc, smsg); - } } else if (source.getObjectType() == GameObjectType.Mob) { Mob pc = (Mob) source; diff --git a/src/engine/powers/effectmodifiers/ManaEffectModifier.java b/src/engine/powers/effectmodifiers/ManaEffectModifier.java index aa2ab6d3..35fbe03b 100644 --- a/src/engine/powers/effectmodifiers/ManaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/ManaEffectModifier.java @@ -12,7 +12,6 @@ package engine.powers.effectmodifiers; import engine.Enum; import engine.Enum.ModType; import engine.Enum.SourceType; -import engine.gameManager.ChatManager; import engine.jobs.AbstractEffectJob; import engine.jobs.DamageOverTimeJob; import engine.net.DispatchMessage; @@ -74,15 +73,6 @@ public class ManaEffectModifier extends AbstractEffectModifier { if (awoac.isSit()) modAmount *= 2.5f; - - //debug for spell damage and atr - if (source.getDebug(16) && source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { - - PlayerCharacter pc = (PlayerCharacter) source; - String smsg = "Percent Damage: " + mod * 100 + '%'; - - ChatManager.chatSystemInfo(pc, smsg); - } } // Modify health by min/max amount @@ -117,13 +107,8 @@ public class ManaEffectModifier extends AbstractEffectModifier { // max *= (intt * 0.0117 + 0.13 * (float)Math.sqrt(intt - 0.5) + spi * 0.0024 + (float)Math.sqrt(spi - 0.5) * 0.021 + 0.015 * (int)focus); min = HealthEffectModifier.getMinDamage(min, intt, spi, focus); max = HealthEffectModifier.getMaxDamage(max, intt, spi, focus); - - //debug for spell damage and atr - if (pc.getDebug(16)) { - String smsg = "Damage: " + (int) Math.abs(min) + " - " + (int) Math.abs(max); - ChatManager.chatSystemInfo(pc, smsg); - } } + modAmount = calculateDamage(source, awoac, min, max, awo, trains); PlayerBonuses bonus = source.getBonuses(); diff --git a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java index 551f3ea1..be134489 100644 --- a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java @@ -12,7 +12,6 @@ package engine.powers.effectmodifiers; import engine.Enum; import engine.Enum.ModType; import engine.Enum.SourceType; -import engine.gameManager.ChatManager; import engine.jobs.AbstractEffectJob; import engine.jobs.DamageOverTimeJob; import engine.net.DispatchMessage; @@ -72,13 +71,6 @@ public class StaminaEffectModifier extends AbstractEffectModifier { modAmount = mod * awoac.getStaminaMax(); if (awoac.isSit()) modAmount *= 2.5f; - - //debug for spell damage and atr - if (source.getDebug(16) && source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { - PlayerCharacter pc = (PlayerCharacter) source; - String smsg = "Percent Damage: " + mod * 100 + '%'; - ChatManager.chatSystemInfo(pc, smsg); - } } // Modify Stamina by min/max amount @@ -113,13 +105,8 @@ public class StaminaEffectModifier extends AbstractEffectModifier { // max *= (intt * 0.0117 + 0.13 * (float)Math.sqrt(intt - 0.5) + spi * 0.0024 + (float)Math.sqrt(spi - 0.5) * 0.021 + 0.015 * (int)focus); min = HealthEffectModifier.getMinDamage(min, intt, spi, focus); max = HealthEffectModifier.getMaxDamage(max, intt, spi, focus); - - //debug for spell damage and atr - if (pc.getDebug(16)) { - String smsg = "Damage: " + (int) Math.abs(min) + " - " + (int) Math.abs(max); - ChatManager.chatSystemInfo(pc, smsg); - } } + modAmount = calculateDamage(source, awoac, min, max, awo, trains); PlayerBonuses bonus = source.getBonuses(); diff --git a/src/engine/powers/poweractions/TransferStatPowerAction.java b/src/engine/powers/poweractions/TransferStatPowerAction.java index bd8015d1..ab718ae4 100644 --- a/src/engine/powers/poweractions/TransferStatPowerAction.java +++ b/src/engine/powers/poweractions/TransferStatPowerAction.java @@ -12,7 +12,6 @@ package engine.powers.poweractions; import engine.Enum; import engine.Enum.ModType; import engine.Enum.SourceType; -import engine.gameManager.ChatManager; import engine.math.Vector3fImmutable; import engine.net.AbstractNetMsg; import engine.net.DispatchMessage; @@ -200,12 +199,6 @@ public class TransferStatPowerAction extends AbstractPowerAction { // get range between min and max float range = max - min; - //debug for spell damage and atr - if (pc.getDebug(16)) { - String smsg = "Damage: " + (int) Math.abs(min) + " - " + (int) Math.abs(max); - ChatManager.chatSystemInfo(pc, smsg); - } - // Damage is calculated twice to average a more central point damage = ThreadLocalRandom.current().nextFloat() * range; damage = (damage + (ThreadLocalRandom.current().nextFloat() * range)) / 2;