From 7603fc030ad5212341c7338a6d463e7535fbe3a0 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 15 Nov 2018 19:36:58 -0500 Subject: [PATCH] v0.7.1: fixes and QOL improvements to missile weapons --- .../items/weapon/missiles/MissileWeapon.java | 17 ++++++++++++++--- .../messages/items/items.properties | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java index 9fcef0f03..2825a503a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java @@ -37,6 +37,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Projecting; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.TippedDart; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.utils.Bundle; import com.watabou.utils.Random; @@ -200,10 +201,18 @@ abstract public class MissileWeapon extends Weapon { parent.durability = MAX_DURABILITY; } else { parent.durability -= parent.durabilityPerUse(); + if (parent.durability <= parent.durabilityPerUse()){ + if (level() <= 0)GLog.w(Messages.get(Weapon.class, "about_to_break")); + else GLog.n(Messages.get(Weapon.class, "about_to_break")); + } } parent = null; } else { durability -= durabilityPerUse(); + if (durability <= durabilityPerUse()){ + if (level() <= 0)GLog.w(Messages.get(Weapon.class, "about_to_break")); + else GLog.n(Messages.get(Weapon.class, "about_to_break")); + } } if (durability > 0){ //attempt to stick the missile weapon to the enemy, just drop it if we can't. @@ -231,9 +240,11 @@ abstract public class MissileWeapon extends Weapon { usages *= RingOfSharpshooting.durabilityMultiplier( Dungeon.hero ); - float usage = MAX_DURABILITY/usages; - //after 100 uses, items just last forever. - return usage >= (MAX_DURABILITY/100f) ? usage : 0; + //at 100 uses, items just last forever. + if (usages >= 100f) return 0; + + //add a tiny amount to account for rounding error for calculations like 1/3 + return (MAX_DURABILITY/usages) + 0.001f; } @Override diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties index 96747127f..9c58bb7ba 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties @@ -1366,6 +1366,7 @@ items.weapon.missiles.missileweapon.distance=This weapon is designed to be used items.weapon.missiles.missileweapon.durability=Missile weapons will wear out and break as they are used. items.weapon.missiles.missileweapon.uses_left=This stack of weapons has _%d/%d_ uses left before one breaks. items.weapon.missiles.missileweapon.unlimited_uses=_But these are of such high quality that they will effectively last forever._ +ttems.weapon.missiles.missileweapon.about_to_break=Your thrown weapon is about to break. items.weapon.missiles.shuriken.name=shuriken items.weapon.missiles.shuriken.desc=Star-shaped pieces of metal with razor-sharp blades. They are lightweight and easy to use on the move. A single shuriken can be thrown instantly after moving.