Browse Source

Durability repair fix

master
FatBoy-DOTC 2 years ago
parent
commit
8e692ea21e
  1. 18
      src/engine/net/client/ClientMessagePump.java
  2. 1
      src/engine/powers/effectmodifiers/ArmorPiercingEffectModifier.java
  3. 19
      src/engine/powers/effectmodifiers/DurabilityEffectModifier.java

18
src/engine/net/client/ClientMessagePump.java

@ -28,6 +28,7 @@ import engine.net.client.msg.*; @@ -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; @@ -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; @@ -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; @@ -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);

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

@ -31,7 +31,6 @@ public class ArmorPiercingEffectModifier extends AbstractEffectModifier { @@ -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);
}

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

@ -9,14 +9,13 @@ @@ -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 { @@ -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) {}
}

Loading…
Cancel
Save