v0.6.3: improved visibility and logic for missile weapon degradation

This commit is contained in:
Evan Debenham 2018-01-01 03:47:06 -05:00
parent ec724bea02
commit 4d91ba2a24
7 changed files with 61 additions and 65 deletions

View File

@ -42,8 +42,6 @@ public class Boomerang extends MissileWeapon {
unique = true; unique = true;
bones = false; bones = false;
//does not use durability
durability = -1;
} }
@Override @Override
@ -91,6 +89,11 @@ public class Boomerang extends MissileWeapon {
return this; return this;
} }
@Override
protected float durabilityPerUse() {
return 0;
}
@Override @Override
public void rangedHit( Char enemy ) { public void rangedHit( Char enemy ) {
circleBack(enemy.pos, curUser); circleBack(enemy.pos, curUser);

View File

@ -36,8 +36,6 @@ public class Dart extends MissileWeapon {
bones = false; //Finding them in bones would be semi-frequent and disappointing. bones = false; //Finding them in bones would be semi-frequent and disappointing.
//does not use durability
durability = -1;
} }
@Override @Override
@ -55,6 +53,11 @@ public class Dart extends MissileWeapon {
return 10; return 10;
} }
@Override
protected float durabilityPerUse() {
return 0;
}
@Override @Override
protected void rangedHit(Char enemy) { protected void rangedHit(Char enemy) {
if (enemy.isAlive()) if (enemy.isAlive())

View File

@ -64,11 +64,6 @@ public class Javelin extends MissileWeapon {
return super.proc( attacker, defender, damage ); return super.proc( attacker, defender, damage );
} }
@Override
protected void reduceDurability() {
durability -= 10;
}
@Override @Override
public Item random() { public Item random() {
quantity = Random.Int( 5, 15 ); quantity = Random.Int( 5, 15 );

View File

@ -30,12 +30,10 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.SnipersMark;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Projecting; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Projecting;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.utils.Bundle; import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
import java.util.ArrayList; import java.util.ArrayList;
@ -49,8 +47,11 @@ abstract public class MissileWeapon extends Weapon {
usesTargeting = true; usesTargeting = true;
} }
//weapons which don't use durability should set it to -1 protected static final float MAX_DURABILITY = 100;
protected float durability = 100; protected float durability = MAX_DURABILITY;
//used to reduce durability from the source weapon stack, rather than the one being thrown.
protected MissileWeapon parent;
@Override @Override
public ArrayList<String> actions( Hero hero ) { public ArrayList<String> actions( Hero hero ) {
@ -73,6 +74,7 @@ abstract public class MissileWeapon extends Weapon {
protected void onThrow( int cell ) { protected void onThrow( int cell ) {
Char enemy = Actor.findChar( cell ); Char enemy = Actor.findChar( cell );
if (enemy == null || enemy == curUser) { if (enemy == null || enemy == curUser) {
parent = null;
super.onThrow( cell ); super.onThrow( cell );
} else { } else {
if (!curUser.shoot( enemy, this )) { if (!curUser.shoot( enemy, this )) {
@ -109,48 +111,49 @@ abstract public class MissileWeapon extends Weapon {
} }
protected void rangedHit( Char enemy ){ protected void rangedHit( Char enemy ){
reduceDurability(); //if this weapon was thrown from a source stack, degrade that stack.
//unless a weapon is about to break, then break the one being thrown
if (parent != null){
if (parent.durability <= parent.durabilityPerUse()){
durability = 0;
parent.durability = MAX_DURABILITY;
} else {
parent.durability -= parent.durabilityPerUse();
}
parent = null;
} else {
durability -= durabilityPerUse();
}
if (durability > 0){ if (durability > 0){
if (enemy.isAlive()) if (enemy.isAlive()) Buff.affect(enemy, PinCushion.class).stick(this);
Buff.affect(enemy, PinCushion.class).stick(this); else Dungeon.level.drop( this, enemy.pos).sprite.drop();
else
Dungeon.level.drop( this, enemy.pos).sprite.drop();
} }
} }
protected void reduceDurability(){
//do nothing by default
}
protected void rangedMiss( int cell ) { protected void rangedMiss( int cell ) {
int bonus = RingOfSharpshooting.getBonus(curUser, RingOfSharpshooting.Aim.class); parent = null;
//degraded ring of sharpshooting will even make missed shots break.
if (Random.Float() < Math.pow(0.6, -bonus))
super.onThrow(cell); super.onThrow(cell);
} }
@Override protected float durabilityPerUse(){
public Item random() { return MAX_DURABILITY/10f;
if (durability != -1) durability = Random.NormalIntRange(70, 100);
return this;
} }
@Override @Override
public void reset() { public void reset() {
super.reset(); super.reset();
durability = 100; durability = MAX_DURABILITY;
} }
@Override @Override
public Item merge(Item other) { public Item merge(Item other) {
super.merge(other); super.merge(other);
if (isSimilar(other) && durability != -1) { if (isSimilar(other)) {
durability += ((MissileWeapon)other).durability; durability += ((MissileWeapon)other).durability;
durability -= 100; durability -= MAX_DURABILITY;
while (durability <= 0){ while (durability <= 0){
quantity -= 1; quantity -= 1;
durability += 100; durability += MAX_DURABILITY;
} }
} }
return this; return this;
@ -160,14 +163,23 @@ abstract public class MissileWeapon extends Weapon {
public Item split(int amount) { public Item split(int amount) {
Item split = super.split(amount); Item split = super.split(amount);
//the split item will retain lost durability //unless the thrown weapon will break, split off a max durability item and
if (split != null && durability != -1){ //have it reduce the durability of the main stack. Cleaner to the player this way
durability = 100; if (split != null){
MissileWeapon m = (MissileWeapon)split;
m.durability = MAX_DURABILITY;
m.parent = this;
} }
return split; return split;
} }
@Override
public boolean doPickUp(Hero hero) {
parent = null;
return super.doPickUp(hero);
}
@Override @Override
public boolean isUpgradable() { public boolean isUpgradable() {
return false; return false;
@ -206,13 +218,11 @@ abstract public class MissileWeapon extends Weapon {
info += "\n\n" + Messages.get(this, "durability"); info += "\n\n" + Messages.get(this, "durability");
//weapons which don't use durability should set it to -1, and have their own text if (durabilityPerUse() > 0){
if (durability >= 100) info += "\n\n" + Messages.get(this, "dur_100"); info += " " + Messages.get(this, "uses_left",
else if (durability >= 80) info += "\n\n" + Messages.get(this, "dur_80"); (int)Math.ceil(durability/durabilityPerUse()),
else if (durability >= 60) info += "\n\n" + Messages.get(this, "dur_60"); (int)Math.ceil(MAX_DURABILITY/durabilityPerUse()));
else if (durability >= 40) info += "\n\n" + Messages.get(this, "dur_40"); }
else if (durability >= 20) info += "\n\n" + Messages.get(this, "dur_20");
else if (durability >= 0) info += "\n\n" + Messages.get(this, "dur_0");
return info; return info;

View File

@ -57,11 +57,6 @@ public class Shuriken extends MissileWeapon {
quantity = number; quantity = number;
} }
@Override
protected void reduceDurability() {
durability -= 10;
}
@Override @Override
public Item random() { public Item random() {
quantity = Random.Int( 5, 15 ); quantity = Random.Int( 5, 15 );

View File

@ -65,11 +65,6 @@ public class Tamahawk extends MissileWeapon {
return super.proc( attacker, defender, damage ); return super.proc( attacker, defender, damage );
} }
@Override
protected void reduceDurability() {
durability -= 10;
}
@Override @Override
public Item random() { public Item random() {
quantity = Random.Int( 5, 12 ); quantity = Random.Int( 5, 12 );

View File

@ -945,13 +945,8 @@ items.weapon.missiles.javelin.desc=This length of metal is weighted to keep the
items.weapon.missiles.missileweapon.stats=This missile weapon deals _%1$d-%2$d damage_ and requires _%3$d strength_ to use properly. items.weapon.missiles.missileweapon.stats=This missile weapon deals _%1$d-%2$d damage_ and requires _%3$d strength_ to use properly.
items.weapon.missiles.missileweapon.distance=This weapon is designed to be used at a distance, it is much less accurate at melee range. items.weapon.missiles.missileweapon.distance=This weapon is designed to be used at a distance, it is much less accurate at melee range.
items.weapon.missiles.missileweapon.durability=Missile weapons will wear out and break as they are used. You will automatically combine parts so that only the first weapon in a stack is worn. items.weapon.missiles.missileweapon.durability=Missile weapons will wear out and break as they are used.
items.weapon.missiles.missileweapon.dur_100=The first weapon is in _perfect condition._ items.weapon.missiles.missileweapon.uses_left=This stack of weapons has _%d/%d_ uses left before one breaks.
items.weapon.missiles.missileweapon.dur_80=The first weapon is in _excellent condition._
items.weapon.missiles.missileweapon.dur_60=The first weapon is in _good condition._
items.weapon.missiles.missileweapon.dur_40=The first weapon is in _fair condition._
items.weapon.missiles.missileweapon.dur_20=The first weapon is in _poor condition._
items.weapon.missiles.missileweapon.dur_0=The first weapon is in _terrible condition._
items.weapon.missiles.shuriken.name=shuriken items.weapon.missiles.shuriken.name=shuriken
items.weapon.missiles.shuriken.desc=Star-shaped pieces of metal with razor-sharp blades do significant damage when they hit a target. They can be thrown at very high rate. items.weapon.missiles.shuriken.desc=Star-shaped pieces of metal with razor-sharp blades do significant damage when they hit a target. They can be thrown at very high rate.