v0.6.3: improved visibility and logic for missile weapon degradation
This commit is contained in:
parent
ec724bea02
commit
4d91ba2a24
|
@ -42,8 +42,6 @@ public class Boomerang extends MissileWeapon {
|
|||
unique = true;
|
||||
bones = false;
|
||||
|
||||
//does not use durability
|
||||
durability = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -91,6 +89,11 @@ public class Boomerang extends MissileWeapon {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float durabilityPerUse() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rangedHit( Char enemy ) {
|
||||
circleBack(enemy.pos, curUser);
|
||||
|
|
|
@ -36,8 +36,6 @@ public class Dart extends MissileWeapon {
|
|||
|
||||
bones = false; //Finding them in bones would be semi-frequent and disappointing.
|
||||
|
||||
//does not use durability
|
||||
durability = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,6 +53,11 @@ public class Dart extends MissileWeapon {
|
|||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float durabilityPerUse() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rangedHit(Char enemy) {
|
||||
if (enemy.isAlive())
|
||||
|
|
|
@ -64,11 +64,6 @@ public class Javelin extends MissileWeapon {
|
|||
return super.proc( attacker, defender, damage );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reduceDurability() {
|
||||
durability -= 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item random() {
|
||||
quantity = Random.Int( 5, 15 );
|
||||
|
|
|
@ -30,12 +30,10 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.SnipersMark;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
|
||||
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.enchantments.Projecting;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.watabou.utils.Bundle;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -49,8 +47,11 @@ abstract public class MissileWeapon extends Weapon {
|
|||
usesTargeting = true;
|
||||
}
|
||||
|
||||
//weapons which don't use durability should set it to -1
|
||||
protected float durability = 100;
|
||||
protected static final float MAX_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
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
|
@ -73,6 +74,7 @@ abstract public class MissileWeapon extends Weapon {
|
|||
protected void onThrow( int cell ) {
|
||||
Char enemy = Actor.findChar( cell );
|
||||
if (enemy == null || enemy == curUser) {
|
||||
parent = null;
|
||||
super.onThrow( cell );
|
||||
} else {
|
||||
if (!curUser.shoot( enemy, this )) {
|
||||
|
@ -109,48 +111,49 @@ abstract public class MissileWeapon extends Weapon {
|
|||
}
|
||||
|
||||
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 (enemy.isAlive())
|
||||
Buff.affect(enemy, PinCushion.class).stick(this);
|
||||
else
|
||||
Dungeon.level.drop( this, enemy.pos).sprite.drop();
|
||||
if (enemy.isAlive()) Buff.affect(enemy, PinCushion.class).stick(this);
|
||||
else Dungeon.level.drop( this, enemy.pos).sprite.drop();
|
||||
}
|
||||
}
|
||||
|
||||
protected void reduceDurability(){
|
||||
//do nothing by default
|
||||
}
|
||||
|
||||
protected void rangedMiss( int cell ) {
|
||||
int bonus = RingOfSharpshooting.getBonus(curUser, RingOfSharpshooting.Aim.class);
|
||||
|
||||
//degraded ring of sharpshooting will even make missed shots break.
|
||||
if (Random.Float() < Math.pow(0.6, -bonus))
|
||||
parent = null;
|
||||
super.onThrow(cell);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item random() {
|
||||
if (durability != -1) durability = Random.NormalIntRange(70, 100);
|
||||
return this;
|
||||
protected float durabilityPerUse(){
|
||||
return MAX_DURABILITY/10f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
durability = 100;
|
||||
durability = MAX_DURABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item merge(Item other) {
|
||||
super.merge(other);
|
||||
if (isSimilar(other) && durability != -1) {
|
||||
if (isSimilar(other)) {
|
||||
durability += ((MissileWeapon)other).durability;
|
||||
durability -= 100;
|
||||
durability -= MAX_DURABILITY;
|
||||
while (durability <= 0){
|
||||
quantity -= 1;
|
||||
durability += 100;
|
||||
durability += MAX_DURABILITY;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
|
@ -160,14 +163,23 @@ abstract public class MissileWeapon extends Weapon {
|
|||
public Item split(int amount) {
|
||||
Item split = super.split(amount);
|
||||
|
||||
//the split item will retain lost durability
|
||||
if (split != null && durability != -1){
|
||||
durability = 100;
|
||||
//unless the thrown weapon will break, split off a max durability item and
|
||||
//have it reduce the durability of the main stack. Cleaner to the player this way
|
||||
if (split != null){
|
||||
MissileWeapon m = (MissileWeapon)split;
|
||||
m.durability = MAX_DURABILITY;
|
||||
m.parent = this;
|
||||
}
|
||||
|
||||
return split;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doPickUp(Hero hero) {
|
||||
parent = null;
|
||||
return super.doPickUp(hero);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgradable() {
|
||||
return false;
|
||||
|
@ -206,13 +218,11 @@ abstract public class MissileWeapon extends Weapon {
|
|||
|
||||
info += "\n\n" + Messages.get(this, "durability");
|
||||
|
||||
//weapons which don't use durability should set it to -1, and have their own text
|
||||
if (durability >= 100) info += "\n\n" + Messages.get(this, "dur_100");
|
||||
else if (durability >= 80) info += "\n\n" + Messages.get(this, "dur_80");
|
||||
else if (durability >= 60) info += "\n\n" + Messages.get(this, "dur_60");
|
||||
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");
|
||||
if (durabilityPerUse() > 0){
|
||||
info += " " + Messages.get(this, "uses_left",
|
||||
(int)Math.ceil(durability/durabilityPerUse()),
|
||||
(int)Math.ceil(MAX_DURABILITY/durabilityPerUse()));
|
||||
}
|
||||
|
||||
|
||||
return info;
|
||||
|
|
|
@ -57,11 +57,6 @@ public class Shuriken extends MissileWeapon {
|
|||
quantity = number;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reduceDurability() {
|
||||
durability -= 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item random() {
|
||||
quantity = Random.Int( 5, 15 );
|
||||
|
|
|
@ -65,11 +65,6 @@ public class Tamahawk extends MissileWeapon {
|
|||
return super.proc( attacker, defender, damage );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reduceDurability() {
|
||||
durability -= 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item random() {
|
||||
quantity = Random.Int( 5, 12 );
|
||||
|
|
|
@ -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.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.dur_100=The first weapon is in _perfect condition._
|
||||
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.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.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.
|
||||
|
|
Loading…
Reference in New Issue
Block a user