Browse Source

Merge remote-tracking branch 'origin/bugfix-armorpiercing' into post-wipe-merge

master
MagicBot 2 years ago
parent
commit
a0b805698e
  1. 18
      src/engine/net/client/ClientMessagePump.java
  2. 1
      src/engine/objects/Item.java
  3. 7
      src/engine/objects/Resists.java
  4. 10
      src/engine/powers/effectmodifiers/ArmorPiercingEffectModifier.java
  5. 19
      src/engine/powers/effectmodifiers/DurabilityEffectModifier.java

18
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.chat.AbstractChatMsg;
import engine.net.client.msg.commands.ClientAdminCommandMsg; import engine.net.client.msg.commands.ClientAdminCommandMsg;
import engine.objects.*; import engine.objects.*;
import engine.powers.effectmodifiers.AbstractEffectModifier;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import engine.server.world.WorldServer; import engine.server.world.WorldServer;
import engine.session.Session; import engine.session.Session;
@ -36,6 +37,7 @@ import org.pmw.tinylog.Logger;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@ -2022,10 +2024,17 @@ boolean updateCity = false;
//make sure item is damaged and not destroyed //make sure item is damaged and not destroyed
short dur = toRepair.getDurabilityCurrent(); short dur = toRepair.getDurabilityCurrent();
short max = toRepair.getDurabilityMax(); short max = toRepair.getDurabilityMax();
//account for durability modifications
if (dur >= max || dur < 1) 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; return;
}
//TODO get cost to repair //TODO get cost to repair
int cost = (int) ((max - dur) * 80.1); int cost = (int) ((max - dur) * 80.1);
Building b = (!npc.isStatic()) ? npc.getBuilding() : null; Building b = (!npc.isStatic()) ? npc.getBuilding() : null;
@ -2056,14 +2065,11 @@ boolean updateCity = false;
ugm.configure(); ugm.configure();
dispatch = Dispatch.borrow(player, ugm); dispatch = Dispatch.borrow(player, ugm);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
//update durability to database //update durability to database
if (!DbManager.ItemQueries.SET_DURABILITY(toRepair, max)) if (!DbManager.ItemQueries.SET_DURABILITY(toRepair, max))
return; return;
//repair the item //repair the item
toRepair.setDurabilityCurrent(max); toRepair.setDurabilityCurrent(max);
//send repair msg //send repair msg
msg.setupRepairAck(max - dur); msg.setupRepairAck(max - dur);
dispatch = Dispatch.borrow(player, msg); dispatch = Dispatch.borrow(player, msg);

1
src/engine/objects/Item.java

@ -489,7 +489,6 @@ public class Item extends AbstractWorldObject {
} }
return max; return max;
} }
public void setDurabilityCurrent(short value) { public void setDurabilityCurrent(short value) {
this.durabilityCurrent = value; this.durabilityCurrent = value;
} }

7
src/engine/objects/Resists.java

@ -16,11 +16,13 @@ import engine.Enum.SourceType;
import engine.gameManager.ChatManager; import engine.gameManager.ChatManager;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.powers.EffectsBase; import engine.powers.EffectsBase;
import engine.powers.effectmodifiers.ArmorPiercingEffectModifier;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -305,9 +307,10 @@ public class Resists {
public float getResistedDamage(AbstractCharacter source, AbstractCharacter target, DamageType type, float damage, int trains) { public float getResistedDamage(AbstractCharacter source, AbstractCharacter target, DamageType type, float damage, int trains) {
//handle fortitudes //handle fortitudes
damage = handleFortitude(target, type, damage); 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 //check to see if any damage absorbers should cancel
float damageAfterResists = damage * (1 - (this.getResist(type, trains) / 100));
if (target != null) { if (target != null) {
//debug damage shields if any found //debug damage shields if any found
if (source.getDebug(2) && source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { if (source.getDebug(2) && source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {

10
src/engine/powers/effectmodifiers/ArmorPiercingEffectModifier.java

@ -10,10 +10,7 @@
package engine.powers.effectmodifiers; package engine.powers.effectmodifiers;
import engine.jobs.AbstractEffectJob; import engine.jobs.AbstractEffectJob;
import engine.objects.AbstractCharacter; import engine.objects.*;
import engine.objects.AbstractWorldObject;
import engine.objects.Building;
import engine.objects.Item;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -32,7 +29,10 @@ public class ArmorPiercingEffectModifier extends AbstractEffectModifier {
@Override @Override
public void applyBonus(AbstractCharacter ac, int trains) { public void applyBonus(AbstractCharacter ac, int trains) {
Float amount = 0f;
PlayerBonuses bonus = ac.getBonuses();
amount = this.percentMod;
bonus.addFloat(this, amount * 0.01f);
} }
@Override @Override

19
src/engine/powers/effectmodifiers/DurabilityEffectModifier.java

@ -9,14 +9,13 @@
package engine.powers.effectmodifiers; package engine.powers.effectmodifiers;
import engine.Enum;
import engine.jobs.AbstractEffectJob; import engine.jobs.AbstractEffectJob;
import engine.objects.AbstractCharacter; import engine.objects.*;
import engine.objects.AbstractWorldObject;
import engine.objects.Building;
import engine.objects.Item;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.concurrent.ConcurrentHashMap;
public class DurabilityEffectModifier extends AbstractEffectModifier { public class DurabilityEffectModifier extends AbstractEffectModifier {
@ -35,7 +34,17 @@ public class DurabilityEffectModifier extends AbstractEffectModifier {
} }
@Override @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 @Override
public void applyBonus(Building building, int trains) {} public void applyBonus(Building building, int trains) {}
} }

Loading…
Cancel
Save