From 61bdda7886be0bce8355d44648296726a227d164 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 28 Jan 2023 17:57:40 -0600 Subject: [PATCH 1/4] combat to include armor piercing calculation --- src/engine/objects/Item.java | 54 +++++++++++++++++++++++++++++++++ src/engine/objects/Resists.java | 8 +++-- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index 64f139e3..fb7504fc 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -319,6 +319,60 @@ public class Item extends AbstractWorldObject { public short getDurabilityMax() { return durabilityMax; } + public float getArmorPiercing(){ + float val = 1; + for(String eff : this.effectNames){ + switch(eff) + { + case"PRE-001": + val += -0.20f; + break; + case"PRE-002": + val += -0.10f; + break; + case"PRE-003": + val += 0.020f; + break; + case"PRE-004": + val += 0.040f; + break; + case"PRE-005": + val += 0.060f; + break; + case"PRE-006": + val += 0.080f; + break; + case"PRE-007": + val += 0.10f; + break; + case"PRE-008": + val += 0.12f; + break; + case"PRE-009": + val += 0.14f; + break; + case"PRE-010": + val += 0.15f; + break; + case"PRE-311": + val += 0.20f; + break; + case"SUF-008": + val += 0.05f; + break; + case"SUF-009": + val += 0.10f; + break; + case"SUF-010": + val += 0.15f; + break; + case"SUF-301": + val += 0.20f; + break; + } + } + return val; + } public void setDurabilityCurrent(short value) { this.durabilityCurrent = value; diff --git a/src/engine/objects/Resists.java b/src/engine/objects/Resists.java index 4342ae3b..f9f7ddc9 100644 --- a/src/engine/objects/Resists.java +++ b/src/engine/objects/Resists.java @@ -305,9 +305,13 @@ public class Resists { public float getResistedDamage(AbstractCharacter source, AbstractCharacter target, DamageType type, float damage, int trains) { //handle fortitudes damage = handleFortitude(target, type, damage); - //check to see if any damage absorbers should cancel - float damageAfterResists = damage * (1 - (this.getResist(type, trains) / 100)); + float apMod = 0; + + if(source.getCharItemManager().getEquipped(2) != null) { + apMod = source.getCharItemManager().getEquipped(2).getArmorPiercing(); // need to get the item in players off-hand and check for armor piercing enchants + } + float damageAfterResists = damage * (1 - (this.getResist(type, trains) / 100) + apMod); if (target != null) { //debug damage shields if any found if (source.getDebug(2) && source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { From c0e3fcffd1283adafd9538e81a7c7c8dc126e1e8 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 28 Jan 2023 18:06:51 -0600 Subject: [PATCH 2/4] finalized cleanup --- src/engine/objects/Item.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index fb7504fc..d3cc5a46 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -320,7 +320,7 @@ public class Item extends AbstractWorldObject { return durabilityMax; } public float getArmorPiercing(){ - float val = 1; + float val = 0; for(String eff : this.effectNames){ switch(eff) { From 727309a706fe7dbcbdc20a8aa194463174279973 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 29 Jan 2023 15:10:37 -0600 Subject: [PATCH 3/4] finalized cleanup --- src/engine/objects/Item.java | 55 ------------------- src/engine/objects/Resists.java | 11 ++-- .../ArmorPiercingEffectModifier.java | 11 ++-- 3 files changed, 11 insertions(+), 66 deletions(-) diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index d3cc5a46..52d206bc 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -319,61 +319,6 @@ public class Item extends AbstractWorldObject { public short getDurabilityMax() { return durabilityMax; } - public float getArmorPiercing(){ - float val = 0; - for(String eff : this.effectNames){ - switch(eff) - { - case"PRE-001": - val += -0.20f; - break; - case"PRE-002": - val += -0.10f; - break; - case"PRE-003": - val += 0.020f; - break; - case"PRE-004": - val += 0.040f; - break; - case"PRE-005": - val += 0.060f; - break; - case"PRE-006": - val += 0.080f; - break; - case"PRE-007": - val += 0.10f; - break; - case"PRE-008": - val += 0.12f; - break; - case"PRE-009": - val += 0.14f; - break; - case"PRE-010": - val += 0.15f; - break; - case"PRE-311": - val += 0.20f; - break; - case"SUF-008": - val += 0.05f; - break; - case"SUF-009": - val += 0.10f; - break; - case"SUF-010": - val += 0.15f; - break; - case"SUF-301": - val += 0.20f; - break; - } - } - return val; - } - public void setDurabilityCurrent(short value) { this.durabilityCurrent = value; } diff --git a/src/engine/objects/Resists.java b/src/engine/objects/Resists.java index f9f7ddc9..c084f5c6 100644 --- a/src/engine/objects/Resists.java +++ b/src/engine/objects/Resists.java @@ -16,11 +16,13 @@ import engine.Enum.SourceType; import engine.gameManager.ChatManager; import engine.gameManager.DbManager; import engine.powers.EffectsBase; +import engine.powers.effectmodifiers.ArmorPiercingEffectModifier; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; @@ -305,13 +307,10 @@ public class Resists { public float getResistedDamage(AbstractCharacter source, AbstractCharacter target, DamageType 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 - float apMod = 0; - - if(source.getCharItemManager().getEquipped(2) != null) { - apMod = source.getCharItemManager().getEquipped(2).getArmorPiercing(); // need to get the item in players off-hand and check for armor piercing enchants - } - float damageAfterResists = damage * (1 - (this.getResist(type, trains) / 100) + apMod); if (target != null) { //debug damage shields if any found if (source.getDebug(2) && source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { diff --git a/src/engine/powers/effectmodifiers/ArmorPiercingEffectModifier.java b/src/engine/powers/effectmodifiers/ArmorPiercingEffectModifier.java index 29ee21fe..19feb4fd 100644 --- a/src/engine/powers/effectmodifiers/ArmorPiercingEffectModifier.java +++ b/src/engine/powers/effectmodifiers/ArmorPiercingEffectModifier.java @@ -10,10 +10,7 @@ package engine.powers.effectmodifiers; import engine.jobs.AbstractEffectJob; -import engine.objects.AbstractCharacter; -import engine.objects.AbstractWorldObject; -import engine.objects.Building; -import engine.objects.Item; +import engine.objects.*; import java.sql.ResultSet; import java.sql.SQLException; @@ -32,7 +29,11 @@ public class ArmorPiercingEffectModifier extends AbstractEffectModifier { @Override public void applyBonus(AbstractCharacter ac, int trains) { - + Float amount = 0f; + PlayerBonuses bonus = ac.getBonuses(); + //for to testing: + amount = this.percentMod; + bonus.addFloat(this, amount * 0.01f); } @Override From 8e692ea21eab2e053aa874aba7a34b2aac456ef3 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 29 Jan 2023 19:06:54 -0600 Subject: [PATCH 4/4] Durability repair fix --- src/engine/net/client/ClientMessagePump.java | 18 ++++++++++++------ .../ArmorPiercingEffectModifier.java | 1 - .../DurabilityEffectModifier.java | 19 ++++++++++++++----- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 0d89f91d..70177a74 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -28,6 +28,7 @@ import engine.net.client.msg.*; import engine.net.client.msg.chat.AbstractChatMsg; import engine.net.client.msg.commands.ClientAdminCommandMsg; import engine.objects.*; +import engine.powers.effectmodifiers.AbstractEffectModifier; import engine.server.MBServerStatics; import engine.server.world.WorldServer; import engine.session.Session; @@ -36,6 +37,7 @@ import org.pmw.tinylog.Logger; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; @@ -2022,10 +2024,17 @@ boolean updateCity = false; //make sure item is damaged and not destroyed short dur = toRepair.getDurabilityCurrent(); short max = toRepair.getDurabilityMax(); - - if (dur >= max || dur < 1) + //account for durability modifications + float durMod = toRepair.getBonusPercent(ModType.Durability,SourceType.None); + max *= (1 + (durMod * 0.01f)); + if (dur >= max || dur < 1) { + //redundancy message to clear item from window in client + toRepair.setDurabilityCurrent(max); + msg.setupRepairAck(max - dur); + dispatch = Dispatch.borrow(player, msg); + DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); return; - + } //TODO get cost to repair int cost = (int) ((max - dur) * 80.1); Building b = (!npc.isStatic()) ? npc.getBuilding() : null; @@ -2056,14 +2065,11 @@ boolean updateCity = false; ugm.configure(); dispatch = Dispatch.borrow(player, ugm); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); - //update durability to database if (!DbManager.ItemQueries.SET_DURABILITY(toRepair, max)) return; - //repair the item toRepair.setDurabilityCurrent(max); - //send repair msg msg.setupRepairAck(max - dur); dispatch = Dispatch.borrow(player, msg); diff --git a/src/engine/powers/effectmodifiers/ArmorPiercingEffectModifier.java b/src/engine/powers/effectmodifiers/ArmorPiercingEffectModifier.java index 19feb4fd..39ec058e 100644 --- a/src/engine/powers/effectmodifiers/ArmorPiercingEffectModifier.java +++ b/src/engine/powers/effectmodifiers/ArmorPiercingEffectModifier.java @@ -31,7 +31,6 @@ public class ArmorPiercingEffectModifier extends AbstractEffectModifier { public void applyBonus(AbstractCharacter ac, int trains) { Float amount = 0f; PlayerBonuses bonus = ac.getBonuses(); - //for to testing: amount = this.percentMod; bonus.addFloat(this, amount * 0.01f); } diff --git a/src/engine/powers/effectmodifiers/DurabilityEffectModifier.java b/src/engine/powers/effectmodifiers/DurabilityEffectModifier.java index 2af78999..cc50dc66 100644 --- a/src/engine/powers/effectmodifiers/DurabilityEffectModifier.java +++ b/src/engine/powers/effectmodifiers/DurabilityEffectModifier.java @@ -9,14 +9,13 @@ package engine.powers.effectmodifiers; +import engine.Enum; import engine.jobs.AbstractEffectJob; -import engine.objects.AbstractCharacter; -import engine.objects.AbstractWorldObject; -import engine.objects.Building; -import engine.objects.Item; +import engine.objects.*; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.concurrent.ConcurrentHashMap; public class DurabilityEffectModifier extends AbstractEffectModifier { @@ -35,7 +34,17 @@ public class DurabilityEffectModifier extends AbstractEffectModifier { } @Override - public void applyBonus(Item item, int trains) {} + public void applyBonus(Item item, int trains) + { + if(item == null){ + return; + } + float amount = 0; + amount = this.percentMod; + item.addBonus(this,amount); + + + } @Override public void applyBonus(Building building, int trains) {} }