v2.2.0: fixed various cases where the pickaxe could be lost, softlocking
This commit is contained in:
@@ -103,7 +103,7 @@ public class Belongings implements Iterable<Item> {
|
||||
|
||||
public KindOfWeapon weapon(){
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
if (!lostInvent || (weapon != null && weapon.keptThoughLostInvent)){
|
||||
if (!lostInvent || (weapon != null && weapon.keptThroughLostInventory())){
|
||||
return weapon;
|
||||
} else {
|
||||
return null;
|
||||
@@ -112,7 +112,7 @@ public class Belongings implements Iterable<Item> {
|
||||
|
||||
public Armor armor(){
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
if (!lostInvent || (armor != null && armor.keptThoughLostInvent)){
|
||||
if (!lostInvent || (armor != null && armor.keptThroughLostInventory())){
|
||||
return armor;
|
||||
} else {
|
||||
return null;
|
||||
@@ -121,7 +121,7 @@ public class Belongings implements Iterable<Item> {
|
||||
|
||||
public Artifact artifact(){
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
if (!lostInvent || (artifact != null && artifact.keptThoughLostInvent)){
|
||||
if (!lostInvent || (artifact != null && artifact.keptThroughLostInventory())){
|
||||
return artifact;
|
||||
} else {
|
||||
return null;
|
||||
@@ -130,7 +130,7 @@ public class Belongings implements Iterable<Item> {
|
||||
|
||||
public KindofMisc misc(){
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
if (!lostInvent || (misc != null && misc.keptThoughLostInvent)){
|
||||
if (!lostInvent || (misc != null && misc.keptThroughLostInventory())){
|
||||
return misc;
|
||||
} else {
|
||||
return null;
|
||||
@@ -139,7 +139,7 @@ public class Belongings implements Iterable<Item> {
|
||||
|
||||
public Ring ring(){
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
if (!lostInvent || (ring != null && ring.keptThoughLostInvent)){
|
||||
if (!lostInvent || (ring != null && ring.keptThroughLostInventory())){
|
||||
return ring;
|
||||
} else {
|
||||
return null;
|
||||
@@ -148,7 +148,7 @@ public class Belongings implements Iterable<Item> {
|
||||
|
||||
public KindOfWeapon secondWep(){
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
if (!lostInvent || (secondWep != null && secondWep.keptThoughLostInvent)){
|
||||
if (!lostInvent || (secondWep != null && secondWep.keptThroughLostInventory())){
|
||||
return secondWep;
|
||||
} else {
|
||||
return null;
|
||||
@@ -236,7 +236,7 @@ public class Belongings implements Iterable<Item> {
|
||||
|
||||
for (Item item : this) {
|
||||
if (itemClass.isInstance( item )) {
|
||||
if (!lostInvent || item.keptThoughLostInvent) {
|
||||
if (!lostInvent || item.keptThroughLostInventory()) {
|
||||
return (T) item;
|
||||
}
|
||||
}
|
||||
@@ -252,7 +252,7 @@ public class Belongings implements Iterable<Item> {
|
||||
|
||||
for (Item item : this) {
|
||||
if (itemClass.isInstance( item )) {
|
||||
if (!lostInvent || item.keptThoughLostInvent) {
|
||||
if (!lostInvent || item.keptThroughLostInventory()) {
|
||||
result.add((T) item);
|
||||
}
|
||||
}
|
||||
@@ -267,7 +267,7 @@ public class Belongings implements Iterable<Item> {
|
||||
|
||||
for (Item item : this) {
|
||||
if (contains == item) {
|
||||
if (!lostInvent || item.keptThoughLostInvent) {
|
||||
if (!lostInvent || item.keptThroughLostInventory()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -282,7 +282,7 @@ public class Belongings implements Iterable<Item> {
|
||||
|
||||
for (Item item : this) {
|
||||
if (similar != item && similar.isSimilar(item)) {
|
||||
if (!lostInvent || item.keptThoughLostInvent) {
|
||||
if (!lostInvent || item.keptThroughLostInventory()) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -298,7 +298,7 @@ public class Belongings implements Iterable<Item> {
|
||||
|
||||
for (Item item : this) {
|
||||
if (item != similar && similar.isSimilar(item)) {
|
||||
if (!lostInvent || item.keptThoughLostInvent) {
|
||||
if (!lostInvent || item.keptThroughLostInventory()) {
|
||||
result.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2351,15 +2351,15 @@ public class Hero extends Char {
|
||||
for (Item i : belongings){
|
||||
if (i instanceof EquipableItem && i.isEquipped(this)){
|
||||
((EquipableItem) i).activate(this);
|
||||
} else if (i instanceof CloakOfShadows && i.keptThoughLostInvent && hasTalent(Talent.LIGHT_CLOAK)){
|
||||
} else if (i instanceof CloakOfShadows && i.keptThroughLostInventory() && hasTalent(Talent.LIGHT_CLOAK)){
|
||||
((CloakOfShadows) i).activate(this);
|
||||
} else if (i instanceof Wand && i.keptThoughLostInvent){
|
||||
} else if (i instanceof Wand && i.keptThroughLostInventory()){
|
||||
if (holster != null && holster.contains(i)){
|
||||
((Wand) i).charge(this, MagicalHolster.HOLSTER_SCALE_FACTOR);
|
||||
} else {
|
||||
((Wand) i).charge(this);
|
||||
}
|
||||
} else if (i instanceof MagesStaff && i.keptThoughLostInvent){
|
||||
} else if (i instanceof MagesStaff && i.keptThroughLostInventory()){
|
||||
((MagesStaff) i).applyWandChargeBuff(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ public enum Talent {
|
||||
if (talent == LIGHT_CLOAK && hero.heroClass == HeroClass.ROGUE){
|
||||
for (Item item : Dungeon.hero.belongings.backpack){
|
||||
if (item instanceof CloakOfShadows){
|
||||
if (hero.buff(LostInventory.class) == null || item.keptThoughLostInvent) {
|
||||
if (hero.buff(LostInventory.class) == null || item.keptThroughLostInventory()) {
|
||||
((CloakOfShadows) item).activate(Dungeon.hero);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public abstract class EquipableItem extends Item {
|
||||
|
||||
if (cursed
|
||||
&& hero.buff(MagicImmune.class) == null
|
||||
&& (hero.buff(LostInventory.class) == null || keptThoughLostInvent)) {
|
||||
&& (hero.buff(LostInventory.class) == null || keptThroughLostInventory())) {
|
||||
GLog.w(Messages.get(EquipableItem.class, "unequip_cursed"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ public class Item implements Bundlable {
|
||||
public boolean unique = false;
|
||||
|
||||
// These items are preserved even if the hero's inventory is lost via unblessed ankh
|
||||
// this is largely set by the resurrection window, items can override this to always be kept
|
||||
public boolean keptThoughLostInvent = false;
|
||||
|
||||
// whether an item can be included in heroes remains
|
||||
@@ -140,6 +141,10 @@ public class Item implements Bundlable {
|
||||
keptThoughLostInvent = false;
|
||||
}
|
||||
|
||||
public boolean keptThroughLostInventory(){
|
||||
return keptThoughLostInvent;
|
||||
}
|
||||
|
||||
public void doThrow( Hero hero ) {
|
||||
GameScene.selectCell(thrower);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class LostBackpack extends Item {
|
||||
|
||||
MagicalHolster holster = hero.belongings.getItem(MagicalHolster.class);
|
||||
for (Item i : hero.belongings){
|
||||
if (i.keptThoughLostInvent){
|
||||
if (i.keptThroughLostInventory()){
|
||||
i.keptThoughLostInvent = false; //don't reactivate, was previously activated
|
||||
} else {
|
||||
if (i instanceof EquipableItem && i.isEquipped(hero)){
|
||||
|
||||
@@ -168,7 +168,7 @@ public class Bag extends Item implements Iterable<Item> {
|
||||
|
||||
public boolean canHold( Item item ){
|
||||
if (!loading && owner != null && owner.buff(LostInventory.class) != null
|
||||
&& !item.keptThoughLostInvent){
|
||||
&& !item.keptThroughLostInventory()){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.MiningLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
@@ -88,6 +89,10 @@ public class Pickaxe extends MeleeWeapon {
|
||||
if (Blacksmith.Quest.oldMiningQuest()) {
|
||||
actions.add(AC_MINE);
|
||||
}
|
||||
if (Dungeon.level instanceof MiningLevel){
|
||||
actions.remove(AC_DROP);
|
||||
actions.remove(AC_THROW);
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
@@ -166,6 +171,12 @@ public class Pickaxe extends MeleeWeapon {
|
||||
return super.proc( attacker, defender, damage );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keptThroughLostInventory() {
|
||||
//pickaxe is always kept when it's needed for the mining level
|
||||
return super.keptThroughLostInventory() || Dungeon.level instanceof MiningLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String defaultAction() {
|
||||
if (Dungeon.hero.heroClass == HeroClass.DUELIST && isEquipped(Dungeon.hero)){
|
||||
|
||||
@@ -365,13 +365,13 @@ public class InventoryPane extends Component {
|
||||
b.enable(lastEnabled
|
||||
&& !(b.item() instanceof WndBag.Placeholder)
|
||||
&& (selector == null || selector.itemSelectable(b.item()))
|
||||
&& (!lostInvent || b.item().keptThoughLostInvent));
|
||||
&& (!lostInvent || b.item().keptThroughLostInventory()));
|
||||
}
|
||||
for (InventorySlot b : bagItems){
|
||||
b.enable(lastEnabled
|
||||
&& b.item() != null
|
||||
&& (selector == null || selector.itemSelectable(b.item()))
|
||||
&& (!lostInvent || b.item().keptThoughLostInvent));
|
||||
&& (!lostInvent || b.item().keptThroughLostInventory()));
|
||||
}
|
||||
for (BagButton b : bags){
|
||||
b.enable(lastEnabled);
|
||||
@@ -455,13 +455,13 @@ public class InventoryPane extends Component {
|
||||
b.enable(lastEnabled
|
||||
&& !(b.item() instanceof WndBag.Placeholder)
|
||||
&& (selector == null || selector.itemSelectable(b.item()))
|
||||
&& (!lostInvent || b.item().keptThoughLostInvent));
|
||||
&& (!lostInvent || b.item().keptThroughLostInventory()));
|
||||
}
|
||||
for (InventorySlot b : bagItems){
|
||||
b.enable(lastEnabled
|
||||
&& b.item() != null
|
||||
&& (selector == null || selector.itemSelectable(b.item()))
|
||||
&& (!lostInvent || b.item().keptThoughLostInvent));
|
||||
&& (!lostInvent || b.item().keptThroughLostInventory()));
|
||||
}
|
||||
for (BagButton b : bags){
|
||||
b.enable(lastEnabled);
|
||||
|
||||
@@ -102,7 +102,7 @@ public class InventorySlot extends ItemSlot {
|
||||
if (item.name() == null) {
|
||||
enable( false );
|
||||
} else if (Dungeon.hero.buff(LostInventory.class) != null
|
||||
&& !item.keptThoughLostInvent){
|
||||
&& !item.keptThroughLostInventory()){
|
||||
enable(false);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -302,7 +302,7 @@ public class QuickSlotButton extends Button {
|
||||
|
||||
private void enableSlot() {
|
||||
slot.enable(Dungeon.quickslot.isNonePlaceholder( slotNum )
|
||||
&& (Dungeon.hero.buff(LostInventory.class) == null || Dungeon.quickslot.getItem(slotNum).keptThoughLostInvent));
|
||||
&& (Dungeon.hero.buff(LostInventory.class) == null || Dungeon.quickslot.getItem(slotNum).keptThroughLostInventory()));
|
||||
}
|
||||
|
||||
public void slotMargins( int left, int top, int right, int bottom){
|
||||
|
||||
@@ -128,7 +128,7 @@ public class Toolbar extends Component {
|
||||
Item item = Dungeon.quickslot.getItem(i);
|
||||
|
||||
if (item != null && !Dungeon.quickslot.isPlaceholder(i) &&
|
||||
(Dungeon.hero.buff(LostInventory.class) == null || item.keptThoughLostInvent)){
|
||||
(Dungeon.hero.buff(LostInventory.class) == null || item.keptThroughLostInventory())){
|
||||
slotNames[i] = Messages.titleCase(item.name());
|
||||
slotIcons[i] = new ItemSprite(item);
|
||||
} else {
|
||||
@@ -154,7 +154,7 @@ public class Toolbar extends Component {
|
||||
Item item = Dungeon.quickslot.getItem(idx);
|
||||
|
||||
if (item == null || Dungeon.quickslot.isPlaceholder(idx)
|
||||
|| (Dungeon.hero.buff(LostInventory.class) != null && !item.keptThoughLostInvent)
|
||||
|| (Dungeon.hero.buff(LostInventory.class) != null && !item.keptThroughLostInventory())
|
||||
|| alt){
|
||||
//TODO would be nice to use a radial menu for this too
|
||||
// Also a bunch of code could be moved out of here into subclasses of RadialMenu
|
||||
@@ -420,7 +420,7 @@ public class Toolbar extends Component {
|
||||
|
||||
for(Item i : bag.items){
|
||||
if (i instanceof Bag) items.remove(i);
|
||||
if (Dungeon.hero.buff(LostInventory.class) != null && !i.keptThoughLostInvent) items.remove(i);
|
||||
if (Dungeon.hero.buff(LostInventory.class) != null && !i.keptThroughLostInventory()) items.remove(i);
|
||||
}
|
||||
|
||||
if (idx == 0){
|
||||
|
||||
Reference in New Issue
Block a user