v1.1.0: fixed various rare quirks with thrown weapon durability
This commit is contained in:
parent
33cef58705
commit
fbb2c75982
|
@ -120,7 +120,9 @@ public class LiquidMetal extends Item {
|
||||||
//we remove a tiny amount here to account for rounding errors
|
//we remove a tiny amount here to account for rounding errors
|
||||||
float percentDurabilityLost = 0.999f - (m.durabilityLeft()/100f);
|
float percentDurabilityLost = 0.999f - (m.durabilityLeft()/100f);
|
||||||
maxToUse = (int)Math.ceil(maxToUse*percentDurabilityLost);
|
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"));
|
GLog.w(Messages.get(LiquidMetal.class, "already_fixed"));
|
||||||
return;
|
return;
|
||||||
} else if (maxToUse < quantity()) {
|
} else if (maxToUse < quantity()) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ abstract public class MissileWeapon extends Weapon {
|
||||||
|
|
||||||
protected boolean sticky = true;
|
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 durability = MAX_DURABILITY;
|
||||||
protected float baseUses = 10;
|
protected float baseUses = 10;
|
||||||
|
|
||||||
|
@ -265,6 +265,7 @@ abstract public class MissileWeapon extends Weapon {
|
||||||
|
|
||||||
public void repair( float amount ){
|
public void repair( float amount ){
|
||||||
durability += amount;
|
durability += amount;
|
||||||
|
durability = Math.min(durability, MAX_DURABILITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float durabilityPerUse(){
|
public float durabilityPerUse(){
|
||||||
|
@ -444,7 +445,7 @@ abstract public class MissileWeapon extends Weapon {
|
||||||
bundleRestoring = true;
|
bundleRestoring = true;
|
||||||
super.restoreFromBundle(bundle);
|
super.restoreFromBundle(bundle);
|
||||||
bundleRestoring = false;
|
bundleRestoring = false;
|
||||||
durability = bundle.getInt(DURABILITY);
|
durability = bundle.getFloat(DURABILITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PlaceHolder extends MissileWeapon {
|
public static class PlaceHolder extends MissileWeapon {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user