v1.1.0: fixed various rare quirks with thrown weapon durability

This commit is contained in:
Evan Debenham 2021-10-20 14:48:31 -04:00
parent 33cef58705
commit fbb2c75982
2 changed files with 6 additions and 3 deletions

View File

@ -120,7 +120,9 @@ public class LiquidMetal extends Item {
//we remove a tiny amount here to account for rounding errors
float percentDurabilityLost = 0.999f - (m.durabilityLeft()/100f);
maxToUse = (int)Math.ceil(maxToUse*percentDurabilityLost);
if (maxToUse == 0 || percentDurabilityLost < m.durabilityPerUse()/100f){
float durPerUse = m.durabilityPerUse()/100f;
if (maxToUse == 0 ||
Math.ceil(m.durabilityLeft()/ m.durabilityPerUse()) >= Math.ceil(m.MAX_DURABILITY/ m.durabilityPerUse()) ){
GLog.w(Messages.get(LiquidMetal.class, "already_fixed"));
return;
} else if (maxToUse < quantity()) {

View File

@ -61,7 +61,7 @@ abstract public class MissileWeapon extends Weapon {
protected boolean sticky = true;
protected static final float MAX_DURABILITY = 100;
public static final float MAX_DURABILITY = 100;
protected float durability = MAX_DURABILITY;
protected float baseUses = 10;
@ -265,6 +265,7 @@ abstract public class MissileWeapon extends Weapon {
public void repair( float amount ){
durability += amount;
durability = Math.min(durability, MAX_DURABILITY);
}
public float durabilityPerUse(){
@ -444,7 +445,7 @@ abstract public class MissileWeapon extends Weapon {
bundleRestoring = true;
super.restoreFromBundle(bundle);
bundleRestoring = false;
durability = bundle.getInt(DURABILITY);
durability = bundle.getFloat(DURABILITY);
}
public static class PlaceHolder extends MissileWeapon {