v3.2.0: added a warning window when throwing last of an upgraded set
This commit is contained in:
@@ -2187,6 +2187,9 @@ items.weapon.missiles.missileweapon.curse_discover=This thrown weapon is cursed!
|
|||||||
items.weapon.missiles.missileweapon.about_to_break=Your thrown weapon is about to break.
|
items.weapon.missiles.missileweapon.about_to_break=Your thrown weapon is about to break.
|
||||||
items.weapon.missiles.missileweapon.has_broken=One of your thrown weapons has broken.
|
items.weapon.missiles.missileweapon.has_broken=One of your thrown weapons has broken.
|
||||||
items.weapon.missiles.missileweapon.dust=The thrown weapon crumbles to dust as you touch it.
|
items.weapon.missiles.missileweapon.dust=The thrown weapon crumbles to dust as you touch it.
|
||||||
|
items.weapon.missiles.missileweapon.break_upgraded_warn_desc=If the last thrown weapon in your enhanced thrown weapon set breaks, the set will be permanently lost. Are you sure you want to throw it?
|
||||||
|
items.weapon.missiles.missileweapon.break_upgraded_warn_yes=Yes
|
||||||
|
items.weapon.missiles.missileweapon.break_upgraded_warn_no=No
|
||||||
items.weapon.missiles.missileweapon$placeholder.name=thrown weapon
|
items.weapon.missiles.missileweapon$placeholder.name=thrown weapon
|
||||||
|
|
||||||
items.weapon.missiles.shuriken.name=shuriken
|
items.weapon.missiles.shuriken.name=shuriken
|
||||||
|
|||||||
@@ -45,8 +45,13 @@ import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Explosive;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Projecting;
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Projecting;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart;
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ui.InventoryPane;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
|
||||||
import com.watabou.noosa.audio.Sample;
|
import com.watabou.noosa.audio.Sample;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
@@ -140,7 +145,8 @@ abstract public class MissileWeapon extends Weapon {
|
|||||||
public Item upgrade( boolean enchant ) {
|
public Item upgrade( boolean enchant ) {
|
||||||
if (!bundleRestoring) {
|
if (!bundleRestoring) {
|
||||||
durability = MAX_DURABILITY;
|
durability = MAX_DURABILITY;
|
||||||
quantity = fullSetQuantity = defaultQuantity();
|
extraThrownLeft = false;
|
||||||
|
quantity = defaultQuantity();
|
||||||
Buff.affect(Dungeon.hero, UpgradedSetTracker.class).levelThresholds.put(setID, level()+1);
|
Buff.affect(Dungeon.hero, UpgradedSetTracker.class).levelThresholds.put(setID, level()+1);
|
||||||
}
|
}
|
||||||
return super.upgrade( enchant );
|
return super.upgrade( enchant );
|
||||||
@@ -150,7 +156,8 @@ abstract public class MissileWeapon extends Weapon {
|
|||||||
public Item upgrade() {
|
public Item upgrade() {
|
||||||
if (!bundleRestoring) {
|
if (!bundleRestoring) {
|
||||||
durability = MAX_DURABILITY;
|
durability = MAX_DURABILITY;
|
||||||
quantity = fullSetQuantity = defaultQuantity();
|
extraThrownLeft = false;
|
||||||
|
quantity = defaultQuantity();
|
||||||
Buff.affect(Dungeon.hero, UpgradedSetTracker.class).levelThresholds.put(setID, level()+1);
|
Buff.affect(Dungeon.hero, UpgradedSetTracker.class).levelThresholds.put(setID, level()+1);
|
||||||
}
|
}
|
||||||
return super.upgrade();
|
return super.upgrade();
|
||||||
@@ -217,8 +224,27 @@ abstract public class MissileWeapon extends Weapon {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doThrow(Hero hero) {
|
public void doThrow(Hero hero) {
|
||||||
parent = null; //reset parent before throwing, just incase
|
parent = null; //reset parent before throwing, just in case
|
||||||
super.doThrow(hero);
|
if (((levelKnown && level() >= 0) || hasGoodEnchant() || masteryPotionBonus || enchantHardened)
|
||||||
|
&& !extraThrownLeft && quantity() == 1 && durabilityLeft() <= durabilityPerUse()){
|
||||||
|
GameScene.show(new WndOptions(new ItemSprite(this), name(),
|
||||||
|
Messages.get(MissileWeapon.class, "break_upgraded_warn_desc"),
|
||||||
|
Messages.get(MissileWeapon.class, "break_upgraded_warn_yes"),
|
||||||
|
Messages.get(MissileWeapon.class, "break_upgraded_warn_no")){
|
||||||
|
@Override
|
||||||
|
protected void onSelect(int index) {
|
||||||
|
if (index == 0){
|
||||||
|
MissileWeapon.super.doThrow(hero);
|
||||||
|
} else {
|
||||||
|
QuickSlotButton.cancel();
|
||||||
|
InventoryPane.cancelTargeting();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
super.doThrow(hero);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -307,8 +333,8 @@ abstract public class MissileWeapon extends Weapon {
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
//this is tracked to show warnings when upgrading and some of the set isn't present
|
//mainly used to track warnings relating to throwing the last upgraded one, not super accurate
|
||||||
public int fullSetQuantity = defaultQuantity();
|
public boolean extraThrownLeft = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item random() {
|
public Item random() {
|
||||||
@@ -422,7 +448,7 @@ abstract public class MissileWeapon extends Weapon {
|
|||||||
if (parent.durability <= parent.durabilityPerUse()){
|
if (parent.durability <= parent.durabilityPerUse()){
|
||||||
durability = 0;
|
durability = 0;
|
||||||
parent.durability = MAX_DURABILITY;
|
parent.durability = MAX_DURABILITY;
|
||||||
parent.fullSetQuantity--;
|
parent.extraThrownLeft = false;
|
||||||
if (parent.durabilityPerUse() < 100f) {
|
if (parent.durabilityPerUse() < 100f) {
|
||||||
GLog.n(Messages.get(this, "has_broken"));
|
GLog.n(Messages.get(this, "has_broken"));
|
||||||
}
|
}
|
||||||
@@ -470,6 +496,8 @@ abstract public class MissileWeapon extends Weapon {
|
|||||||
public Item merge(Item other) {
|
public Item merge(Item other) {
|
||||||
super.merge(other);
|
super.merge(other);
|
||||||
if (isSimilar(other)) {
|
if (isSimilar(other)) {
|
||||||
|
extraThrownLeft = false;
|
||||||
|
|
||||||
durability += ((MissileWeapon)other).durability;
|
durability += ((MissileWeapon)other).durability;
|
||||||
durability -= MAX_DURABILITY;
|
durability -= MAX_DURABILITY;
|
||||||
while (durability <= 0){
|
while (durability <= 0){
|
||||||
@@ -520,6 +548,7 @@ abstract public class MissileWeapon extends Weapon {
|
|||||||
MissileWeapon m = (MissileWeapon)split;
|
MissileWeapon m = (MissileWeapon)split;
|
||||||
m.durability = MAX_DURABILITY;
|
m.durability = MAX_DURABILITY;
|
||||||
m.parent = this;
|
m.parent = this;
|
||||||
|
extraThrownLeft = m.extraThrownLeft = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return split;
|
return split;
|
||||||
@@ -535,6 +564,7 @@ abstract public class MissileWeapon extends Weapon {
|
|||||||
quantity(0);
|
quantity(0);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
extraThrownLeft = false;
|
||||||
return super.doPickUp(hero, pos);
|
return super.doPickUp(hero, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -608,7 +638,7 @@ abstract public class MissileWeapon extends Weapon {
|
|||||||
|
|
||||||
private static final String SPAWNED = "spawned";
|
private static final String SPAWNED = "spawned";
|
||||||
private static final String DURABILITY = "durability";
|
private static final String DURABILITY = "durability";
|
||||||
private static final String FULL_QUANTITY = "full_quantity";
|
private static final String EXTRA_LEFT = "extra_left";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeInBundle(Bundle bundle) {
|
public void storeInBundle(Bundle bundle) {
|
||||||
@@ -616,7 +646,7 @@ abstract public class MissileWeapon extends Weapon {
|
|||||||
bundle.put(SET_ID, setID);
|
bundle.put(SET_ID, setID);
|
||||||
bundle.put(SPAWNED, spawnedForEffect);
|
bundle.put(SPAWNED, spawnedForEffect);
|
||||||
bundle.put(DURABILITY, durability);
|
bundle.put(DURABILITY, durability);
|
||||||
bundle.put(FULL_QUANTITY, fullSetQuantity);
|
bundle.put(EXTRA_LEFT, extraThrownLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean bundleRestoring = false;
|
private static boolean bundleRestoring = false;
|
||||||
@@ -636,7 +666,6 @@ abstract public class MissileWeapon extends Weapon {
|
|||||||
if (level() > 0){
|
if (level() > 0){
|
||||||
//set ID will be a random long
|
//set ID will be a random long
|
||||||
quantity = defaultQuantity();
|
quantity = defaultQuantity();
|
||||||
fullSetQuantity = quantity;
|
|
||||||
|
|
||||||
//otherwise treat all currently spawned thrown weapons of the same class as if they are part of the same set
|
//otherwise treat all currently spawned thrown weapons of the same class as if they are part of the same set
|
||||||
//darts already do this though and need no conversion
|
//darts already do this though and need no conversion
|
||||||
@@ -648,7 +677,7 @@ abstract public class MissileWeapon extends Weapon {
|
|||||||
|
|
||||||
spawnedForEffect = bundle.getBoolean(SPAWNED);
|
spawnedForEffect = bundle.getBoolean(SPAWNED);
|
||||||
durability = bundle.getFloat(DURABILITY);
|
durability = bundle.getFloat(DURABILITY);
|
||||||
fullSetQuantity = bundle.getInt(FULL_QUANTITY);
|
extraThrownLeft = bundle.getBoolean(EXTRA_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PlaceHolder extends MissileWeapon {
|
public static class PlaceHolder extends MissileWeapon {
|
||||||
|
|||||||
@@ -405,7 +405,7 @@ public class WndUpgrade extends Window {
|
|||||||
bottom = addMessage(Messages.get(this, "resin"), CharSprite.WARNING, bottom);
|
bottom = addMessage(Messages.get(this, "resin"), CharSprite.WARNING, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toUpgrade instanceof MissileWeapon && toUpgrade.quantity() < ((MissileWeapon) toUpgrade).fullSetQuantity){
|
if (toUpgrade instanceof MissileWeapon && ((MissileWeapon) toUpgrade).extraThrownLeft){
|
||||||
bottom = addMessage("Weapons from this set that aren't in your inventory will crumble to dust.", CharSprite.WARNING, bottom);
|
bottom = addMessage("Weapons from this set that aren't in your inventory will crumble to dust.", CharSprite.WARNING, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user