v0.9.4: lost invent debuff now has functionality to work selectively

This commit is contained in:
Evan Debenham 2021-07-27 18:07:41 -04:00
parent 8328962579
commit 1ae3e4fcbd
27 changed files with 215 additions and 113 deletions

View File

@ -315,7 +315,7 @@ public abstract class Char extends Actor {
if (this instanceof Hero){
Hero h = (Hero)this;
if (h.belongings.weapon instanceof MissileWeapon
if (h.belongings.weapon() instanceof MissileWeapon
&& h.subClass == HeroSubClass.SNIPER
&& !Dungeon.level.adjacent(h.pos, enemy.pos)){
dr = 0;

View File

@ -168,8 +168,8 @@ public class Combo extends Buff implements ActionIndicator.Action {
@Override
public Image getIcon() {
Image icon;
if (((Hero)target).belongings.weapon != null){
icon = new ItemSprite(((Hero)target).belongings.weapon.image, null);
if (((Hero)target).belongings.weapon() != null){
icon = new ItemSprite(((Hero)target).belongings.weapon().image, null);
} else {
icon = new ItemSprite(new Item(){ {image = ItemSpriteSheet.WEAPON_HOLDER; }});
}

View File

@ -45,18 +45,6 @@ public class Belongings implements Iterable<Item> {
private Hero owner;
public Bag backpack;
//FIXME these need accessor methods so they can work in conjunction with the lost inventory debuff =I
public KindOfWeapon weapon = null;
public Armor armor = null;
public Artifact artifact = null;
public KindofMisc misc = null;
public Ring ring = null;
//used when thrown weapons temporary occupy the weapon slot
public KindOfWeapon stashedWeapon = null;
public static class Backpack extends Bag {
public int capacity(){
int cap = super.capacity();
@ -69,6 +57,8 @@ public class Belongings implements Iterable<Item> {
}
}
public Backpack backpack;
public Belongings( Hero owner ) {
this.owner = owner;
@ -76,6 +66,69 @@ public class Belongings implements Iterable<Item> {
backpack.owner = owner;
}
public KindOfWeapon weapon = null;
public Armor armor = null;
public Artifact artifact = null;
public KindofMisc misc = null;
public Ring ring = null;
//used when thrown weapons temporary become the current weapon
public KindOfWeapon thrownWeapon = null;
//*** these accessor methods are so that worn items can be affected by various effects/debuffs
// we still want to access the raw equipped items in cases where effects should be ignored though,
// such as when equipping something, showing an interface, or dealing with items from a dead hero
public KindOfWeapon weapon(){
//no point in lost invent check, if it's assigned it must be usable
if (thrownWeapon != null) return thrownWeapon;
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
if (!lostInvent || (weapon != null && weapon.keptThoughLostInvent)){
return weapon;
} else {
return null;
}
}
public Armor armor(){
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
if (!lostInvent || (armor != null && armor.keptThoughLostInvent)){
return armor;
} else {
return null;
}
}
public Artifact artifact(){
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
if (!lostInvent || (artifact != null && artifact.keptThoughLostInvent)){
return artifact;
} else {
return null;
}
}
public KindofMisc misc(){
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
if (!lostInvent || (misc != null && misc.keptThoughLostInvent)){
return misc;
} else {
return null;
}
}
public Ring ring(){
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
if (!lostInvent || (ring != null && ring.keptThoughLostInvent)){
return ring;
} else {
return null;
}
}
// ***
private static final String WEAPON = "weapon";
private static final String ARMOR = "armor";
private static final String ARTIFACT = "artifact";
@ -172,13 +225,15 @@ public class Belongings implements Iterable<Item> {
@SuppressWarnings("unchecked")
public<T extends Item> T getItem( Class<T> itemClass ) {
if (owner != null && owner.buff(LostInventory.class) != null) return null;
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
for (Item item : this) {
if (itemClass.isInstance( item )) {
if (!lostInvent || item.keptThoughLostInvent) {
return (T) item;
}
}
}
return null;
}
@ -186,39 +241,45 @@ public class Belongings implements Iterable<Item> {
public<T extends Item> ArrayList<T> getAllItems( Class<T> itemClass ) {
ArrayList<T> result = new ArrayList<>();
if (owner != null && owner.buff(LostInventory.class) != null) return result;
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
for (Item item : this) {
if (itemClass.isInstance( item )) {
if (!lostInvent || item.keptThoughLostInvent) {
result.add((T) item);
}
}
}
return result;
}
public boolean contains( Item contains ){
if (owner != null && owner.buff(LostInventory.class) != null) return false;
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
for (Item item : this) {
if (contains == item) {
if (!lostInvent || item.keptThoughLostInvent) {
return true;
}
}
}
return false;
}
public Item getSimilar( Item similar ){
if (owner != null && owner.buff(LostInventory.class) != null) return null;
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
for (Item item : this) {
if (similar != item && similar.isSimilar(item)) {
if (!lostInvent || item.keptThoughLostInvent) {
return item;
}
}
}
return null;
}
@ -226,13 +287,15 @@ public class Belongings implements Iterable<Item> {
public ArrayList<Item> getAllSimilar( Item similar ){
ArrayList<Item> result = new ArrayList<>();
if (owner != null && owner.buff(LostInventory.class) != null) return result;
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
for (Item item : this) {
if (item != similar && similar.isSimilar(item)) {
if (!lostInvent || item.keptThoughLostInvent) {
result.add(item);
}
}
}
return result;
}

View File

@ -359,8 +359,8 @@ public class Hero extends Char {
@Override
public void hitSound(float pitch) {
if ( belongings.weapon != null ){
belongings.weapon.hitSound(pitch);
if ( belongings.weapon() != null ){
belongings.weapon().hitSound(pitch);
} else if (RingOfForce.getBuffedBonus(this, RingOfForce.Force.class) > 0) {
//pitch deepens by 2.5% (additive) per point of strength, down to 75%
super.hitSound( pitch * GameMath.gate( 0.75f, 1.25f - 0.025f*STR(), 1f) );
@ -371,7 +371,7 @@ public class Hero extends Char {
@Override
public boolean blockSound(float pitch) {
if ( belongings.weapon != null && belongings.weapon.defenseFactor(this) >= 4 ){
if ( belongings.weapon() != null && belongings.weapon().defenseFactor(this) >= 4 ){
Sample.INSTANCE.play( Assets.Sounds.HIT_PARRY, 1, pitch);
return true;
}
@ -387,10 +387,10 @@ public class Hero extends Char {
}
public int tier() {
if (belongings.armor instanceof ClassArmor){
if (belongings.armor() instanceof ClassArmor){
return 6;
} else if (belongings.armor != null){
return belongings.armor.tier;
} else if (belongings.armor() != null){
return belongings.armor().tier;
} else {
return 0;
}
@ -401,12 +401,11 @@ public class Hero extends Char {
this.enemy = enemy;
//temporarily set the hero's weapon to the missile weapon being used
belongings.stashedWeapon = belongings.weapon;
belongings.weapon = wep;
//TODO improve this!
belongings.thrownWeapon = wep;
boolean hit = attack( enemy );
Invisibility.dispel();
belongings.weapon = belongings.stashedWeapon;
belongings.stashedWeapon = null;
belongings.thrownWeapon = null;
if (hit && subClass == HeroSubClass.GLADIATOR){
Buff.affect( this, Combo.class ).hit( enemy );
@ -417,7 +416,7 @@ public class Hero extends Char {
@Override
public int attackSkill( Char target ) {
KindOfWeapon wep = belongings.weapon;
KindOfWeapon wep = belongings.weapon();
float accuracy = 1;
accuracy *= RingOfAccuracy.accuracyMultiplier( this );
@ -455,8 +454,8 @@ public class Hero extends Char {
evasion /= 2;
}
if (belongings.armor != null) {
evasion = belongings.armor.evasionFactor(this, evasion);
if (belongings.armor() != null) {
evasion = belongings.armor().evasionFactor(this, evasion);
}
return Math.round(evasion);
@ -480,17 +479,17 @@ public class Hero extends Char {
public int drRoll() {
int dr = 0;
if (belongings.armor != null) {
int armDr = Random.NormalIntRange( belongings.armor.DRMin(), belongings.armor.DRMax());
if (STR() < belongings.armor.STRReq()){
armDr -= 2*(belongings.armor.STRReq() - STR());
if (belongings.armor() != null) {
int armDr = Random.NormalIntRange( belongings.armor().DRMin(), belongings.armor().DRMax());
if (STR() < belongings.armor().STRReq()){
armDr -= 2*(belongings.armor().STRReq() - STR());
}
if (armDr > 0) dr += armDr;
}
if (belongings.weapon != null) {
int wepDr = Random.NormalIntRange( 0 , belongings.weapon.defenseFactor( this ) );
if (STR() < ((Weapon)belongings.weapon).STRReq()){
wepDr -= 2*(((Weapon)belongings.weapon).STRReq() - STR());
if (belongings.weapon() != null) {
int wepDr = Random.NormalIntRange( 0 , belongings.weapon().defenseFactor( this ) );
if (STR() < ((Weapon)belongings.weapon()).STRReq()){
wepDr -= 2*(((Weapon)belongings.weapon()).STRReq() - STR());
}
if (wepDr > 0) dr += wepDr;
}
@ -504,7 +503,7 @@ public class Hero extends Char {
@Override
public int damageRoll() {
KindOfWeapon wep = belongings.weapon;
KindOfWeapon wep = belongings.weapon();
int dmg;
if (wep != null) {
@ -525,8 +524,8 @@ public class Hero extends Char {
speed *= RingOfHaste.speedMultiplier(this);
if (belongings.armor != null) {
speed = belongings.armor.speedFactor(this, speed);
if (belongings.armor() != null) {
speed = belongings.armor().speedFactor(this, speed);
}
Momentum momentum = buff(Momentum.class);
@ -547,9 +546,9 @@ public class Hero extends Char {
}
public boolean canSurpriseAttack(){
if (belongings.weapon == null || !(belongings.weapon instanceof Weapon)) return true;
if (STR() < ((Weapon)belongings.weapon).STRReq()) return false;
if (belongings.weapon instanceof Flail) return false;
if (belongings.weapon() == null || !(belongings.weapon() instanceof Weapon)) return true;
if (STR() < ((Weapon)belongings.weapon()).STRReq()) return false;
if (belongings.weapon() instanceof Flail) return false;
return true;
}
@ -564,7 +563,7 @@ public class Hero extends Char {
return true;
}
KindOfWeapon wep = Dungeon.hero.belongings.weapon;
KindOfWeapon wep = Dungeon.hero.belongings.weapon();
if (wep != null){
return wep.canReach(this, enemy.pos);
@ -579,9 +578,9 @@ public class Hero extends Char {
return 0;
}
if (belongings.weapon != null) {
if (belongings.weapon() != null) {
return belongings.weapon.delayFactor( this );
return belongings.weapon().delayFactor( this );
} else {
//Normally putting furor speed on unarmed attacks would be unnecessary
@ -1110,7 +1109,7 @@ public class Hero extends Char {
public int attackProc( final Char enemy, int damage ) {
damage = super.attackProc( enemy, damage );
KindOfWeapon wep = belongings.weapon;
KindOfWeapon wep = belongings.weapon();
if (wep != null) damage = wep.proc( this, enemy, damage );
@ -1158,8 +1157,8 @@ public class Hero extends Char {
berserk.damage(damage);
}
if (belongings.armor != null) {
damage = belongings.armor.proc( enemy, this, damage );
if (belongings.armor() != null) {
damage = belongings.armor().proc( enemy, this, damage );
}
Earthroot.Armor armor = buff( Earthroot.Armor.class );
@ -1198,9 +1197,9 @@ public class Hero extends Char {
dmg = (int)Math.ceil(dmg * RingOfTenacity.damageMultiplier( this ));
//TODO improve this when I have proper damage source logic
if (belongings.armor != null && belongings.armor.hasGlyph(AntiMagic.class, this)
if (belongings.armor() != null && belongings.armor().hasGlyph(AntiMagic.class, this)
&& AntiMagic.RESISTS.contains(src.getClass())){
dmg -= AntiMagic.drRoll(belongings.armor.buffedLvl());
dmg -= AntiMagic.drRoll(belongings.armor().buffedLvl());
}
if (buff(Talent.WarriorFoodImmunity.class) != null){
@ -1586,8 +1585,8 @@ public class Hero extends Char {
public float stealth() {
float stealth = super.stealth();
if (belongings.armor != null){
stealth = belongings.armor.stealthFactor(this, stealth);
if (belongings.armor() != null){
stealth = belongings.armor().stealthFactor(this, stealth);
}
return stealth;
@ -1834,8 +1833,8 @@ public class Hero extends Char {
@Override
public boolean isImmune(Class effect) {
if (effect == Burning.class
&& belongings.armor != null
&& belongings.armor.hasGlyph(Brimstone.class, this)){
&& belongings.armor() != null
&& belongings.armor().hasGlyph(Brimstone.class, this)){
return true;
}
return super.isImmune(effect);
@ -1982,6 +1981,13 @@ public class Hero extends Char {
Buff.affect(this, LostInventory.class);
Buff.affect(this, Invisibility.class, 3f);
//lost inventory is dropped in interlevelscene
//activate items that persist after lost inventory
if (belongings.weapon() != null) belongings.weapon().activate(this);
if (belongings.armor() != null) belongings.armor().activate(this);
if (belongings.artifact() != null) belongings.artifact().activate(this);
if (belongings.misc() != null) belongings.misc().activate(this);
if (belongings.ring() != null) belongings.ring().activate(this);
}
@Override

View File

@ -239,8 +239,8 @@ public enum Talent {
}
if (talent == ARMSMASTERS_INTUITION && hero.pointsInTalent(ARMSMASTERS_INTUITION) == 2){
if (hero.belongings.weapon != null) hero.belongings.weapon.identify();
if (hero.belongings.armor != null) hero.belongings.armor.identify();
if (hero.belongings.weapon() != null) hero.belongings.weapon().identify();
if (hero.belongings.armor() != null) hero.belongings.armor.identify();
}
if (talent == THIEFS_INTUITION && hero.pointsInTalent(THIEFS_INTUITION) == 2){
if (hero.belongings.ring instanceof Ring) hero.belongings.ring.identify();
@ -446,7 +446,7 @@ public enum Talent {
}
if (hero.hasTalent(Talent.FOLLOWUP_STRIKE)) {
if (hero.belongings.weapon instanceof MissileWeapon) {
if (hero.belongings.weapon() instanceof MissileWeapon) {
Buff.affect(enemy, FollowupStrikeTracker.class);
} else if (enemy.buff(FollowupStrikeTracker.class) != null){
dmg += 1 + hero.pointsInTalent(FOLLOWUP_STRIKE);

View File

@ -203,8 +203,8 @@ public class ShadowClone extends ArmorAbility {
public int attackProc( Char enemy, int damage ) {
damage = super.attackProc( enemy, damage );
if (Random.Int(4) < Dungeon.hero.pointsInTalent(Talent.SHADOW_BLADE)
&& Dungeon.hero.belongings.weapon != null){
return Dungeon.hero.belongings.weapon.proc( this, enemy, damage );
&& Dungeon.hero.belongings.weapon() != null){
return Dungeon.hero.belongings.weapon().proc( this, enemy, damage );
} else {
return damage;
}
@ -225,8 +225,8 @@ public class ShadowClone extends ArmorAbility {
public int defenseProc(Char enemy, int damage) {
damage = super.defenseProc(enemy, damage);
if (Random.Int(4) < Dungeon.hero.pointsInTalent(Talent.CLONED_ARMOR)
&& Dungeon.hero.belongings.armor != null){
return Dungeon.hero.belongings.armor.proc( enemy, this, damage );
&& Dungeon.hero.belongings.armor() != null){
return Dungeon.hero.belongings.armor().proc( enemy, this, damage );
} else {
return damage;
}

View File

@ -568,7 +568,7 @@ public abstract class Mob extends Char {
public int defenseProc( Char enemy, int damage ) {
if (enemy instanceof Hero
&& ((Hero) enemy).belongings.weapon instanceof MissileWeapon
&& ((Hero) enemy).belongings.weapon() instanceof MissileWeapon
&& !hitWithRanged){
hitWithRanged = true;
Statistics.thrownAssists++;
@ -580,8 +580,8 @@ public abstract class Mob extends Char {
Badges.validateRogueUnlock();
//TODO this is somewhat messy, it would be nicer to not have to manually handle delays here
// playing the strong hit sound might work best as another property of weapon?
if (Dungeon.hero.belongings.weapon instanceof SpiritBow.SpiritArrow
|| Dungeon.hero.belongings.weapon instanceof Dart){
if (Dungeon.hero.belongings.weapon() instanceof SpiritBow.SpiritArrow
|| Dungeon.hero.belongings.weapon() instanceof Dart){
Sample.INSTANCE.playDelayed(Assets.Sounds.HIT_STRONG, 0.125f);
} else {
Sample.INSTANCE.play(Assets.Sounds.HIT_STRONG);

View File

@ -102,8 +102,8 @@ public class MirrorImage extends NPC {
@Override
public int damageRoll() {
int damage;
if (hero.belongings.weapon != null){
damage = hero.belongings.weapon.damageRoll(this);
if (hero.belongings.weapon() != null){
damage = hero.belongings.weapon().damageRoll(this);
} else {
damage = hero.damageRoll(); //handles ring of force
}
@ -135,13 +135,13 @@ public class MirrorImage extends NPC {
@Override
protected boolean canAttack(Char enemy) {
return super.canAttack(enemy) || (hero.belongings.weapon != null && hero.belongings.weapon.canReach(this, enemy.pos));
return super.canAttack(enemy) || (hero.belongings.weapon() != null && hero.belongings.weapon().canReach(this, enemy.pos));
}
@Override
public int drRoll() {
if (hero != null && hero.belongings.weapon != null){
return Random.NormalIntRange(0, hero.belongings.weapon.defenseFactor(this)/2);
if (hero != null && hero.belongings.weapon() != null){
return Random.NormalIntRange(0, hero.belongings.weapon().defenseFactor(this)/2);
} else {
return 0;
}
@ -159,8 +159,8 @@ public class MirrorImage extends NPC {
if (enemy instanceof Mob) {
((Mob)enemy).aggro( this );
}
if (hero.belongings.weapon != null){
damage = hero.belongings.weapon.proc( this, enemy, damage );
if (hero.belongings.weapon() != null){
damage = hero.belongings.weapon().proc( this, enemy, damage );
if (!enemy.isAlive() && enemy == Dungeon.hero){
Dungeon.fail(getClass());
GLog.n( Messages.capitalize(Messages.get(Char.class, "kill", name())) );

View File

@ -185,8 +185,8 @@ public class PrismaticImage extends NPC {
@Override
public int defenseProc(Char enemy, int damage) {
damage = super.defenseProc(enemy, damage);
if (hero != null && hero.belongings.armor != null){
return hero.belongings.armor.proc( enemy, this, damage );
if (hero != null && hero.belongings.armor() != null){
return hero.belongings.armor().proc( enemy, this, damage );
} else {
return damage;
}
@ -196,9 +196,9 @@ public class PrismaticImage extends NPC {
public void damage(int dmg, Object src) {
//TODO improve this when I have proper damage source logic
if (hero != null && hero.belongings.armor != null && hero.belongings.armor.hasGlyph(AntiMagic.class, this)
if (hero != null && hero.belongings.armor() != null && hero.belongings.armor().hasGlyph(AntiMagic.class, this)
&& AntiMagic.RESISTS.contains(src.getClass())){
dmg -= AntiMagic.drRoll(hero.belongings.armor.buffedLvl());
dmg -= AntiMagic.drRoll(hero.belongings.armor().buffedLvl());
}
super.damage(dmg, src);
@ -206,8 +206,8 @@ public class PrismaticImage extends NPC {
@Override
public float speed() {
if (hero != null && hero.belongings.armor != null){
return hero.belongings.armor.speedFactor(this, super.speed());
if (hero != null && hero.belongings.armor() != null){
return hero.belongings.armor().speedFactor(this, super.speed());
}
return super.speed();
}
@ -238,8 +238,8 @@ public class PrismaticImage extends NPC {
public boolean isImmune(Class effect) {
if (effect == Burning.class
&& hero != null
&& hero.belongings.armor != null
&& hero.belongings.armor.hasGlyph(Brimstone.class, this)){
&& hero.belongings.armor() != null
&& hero.belongings.armor().hasGlyph(Brimstone.class, this)){
return true;
}
return super.isImmune(effect);

View File

@ -117,7 +117,7 @@ public class RatKing extends NPC {
yell( Messages.get(this, "not_sleeping") );
state = WANDERING;
} else if (crown != null){
if (Dungeon.hero.belongings.armor == null){
if (Dungeon.hero.belongings.armor() == null){
yell( Messages.get(RatKing.class, "crown_clothes") );
} else {
Badges.validateRatmogrify();
@ -135,7 +135,7 @@ public class RatKing extends NPC {
@Override
protected void onSelect(int index) {
if (index == 0){
crown.upgradeArmor(Dungeon.hero, Dungeon.hero.belongings.armor, new Ratmogrify());
crown.upgradeArmor(Dungeon.hero, Dungeon.hero.belongings.armor(), new Ratmogrify());
((RatKingSprite)sprite).resetAnims();
yell(Messages.get(RatKing.class, "crown_thankyou"));
} else if (index == 1) {

View File

@ -29,6 +29,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Blindness;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Degrade;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LostInventory;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
@ -87,6 +88,9 @@ public class Item implements Bundlable {
// Unique items persist through revival
public boolean unique = false;
// These items are preserved even if the hero's inventory is lost via unblessed ankh
public boolean keptThoughLostInvent = false;
// whether an item can be included in heroes remains
public boolean bones = false;
@ -484,6 +488,7 @@ public class Item implements Bundlable {
private static final String CURSED = "cursed";
private static final String CURSED_KNOWN = "cursedKnown";
private static final String QUICKSLOT = "quickslotpos";
private static final String KEPT_LOST = "kept_lost";
@Override
public void storeInBundle( Bundle bundle ) {
@ -495,6 +500,7 @@ public class Item implements Bundlable {
if (Dungeon.quickslot.contains(this)) {
bundle.put( QUICKSLOT, Dungeon.quickslot.getSlot(this) );
}
bundle.put( KEPT_LOST, keptThoughLostInvent );
}
@Override
@ -518,6 +524,8 @@ public class Item implements Bundlable {
Dungeon.quickslot.setSlot(bundle.getInt(QUICKSLOT), this);
}
}
keptThoughLostInvent = bundle.getBoolean( KEPT_LOST );
}
public int targetingPos( Hero user, int dst ){

View File

@ -44,7 +44,7 @@ abstract public class KindOfWeapon extends EquipableItem {
@Override
public boolean isEquipped( Hero hero ) {
return hero.belongings.weapon == this || hero.belongings.stashedWeapon == this;
return hero.belongings.weapon() == this;
}
@Override

View File

@ -174,9 +174,9 @@ public abstract class KindofMisc extends EquipableItem {
@Override
public boolean isEquipped( Hero hero ) {
return hero.belongings.artifact == this
|| hero.belongings.misc == this
|| hero.belongings.ring == this;
return hero.belongings.artifact() == this
|| hero.belongings.misc() == this
|| hero.belongings.ring() == this;
}
}

View File

@ -67,8 +67,8 @@ public class KingsCrown extends Item {
if (action.equals(AC_WEAR)) {
curUser = hero;
if (hero.belongings.armor != null){
GameScene.show( new WndChooseAbility(this, hero.belongings.armor, hero));
if (hero.belongings.armor() != null){
GameScene.show( new WndChooseAbility(this, hero.belongings.armor(), hero));
} else {
GLog.w( Messages.get(this, "naked"));
}

View File

@ -1,6 +1,7 @@
package com.shatteredpixel.shatteredpixeldungeon.items;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LostInventory;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
@ -20,6 +21,17 @@ public class LostBackpack extends Item {
if (hero.buff(LostInventory.class) != null){
hero.buff(LostInventory.class).detach();
}
for (Item i : hero.belongings){
if (i.keptThoughLostInvent){
i.keptThoughLostInvent = false;
} else {
if (i instanceof EquipableItem && i.isEquipped(hero)){
((EquipableItem) i).activate(hero);
}
}
}
Item.updateQuickslot();
Sample.INSTANCE.play( Assets.Sounds.DEWDROP );
hero.spendAndNext(TIME_TO_PICK_UP);

View File

@ -276,7 +276,7 @@ public class Armor extends EquipableItem {
@Override
public boolean isEquipped( Hero hero ) {
return hero.belongings.armor == this;
return hero.belongings.armor() == this;
}
public final int DRMax(){

View File

@ -57,7 +57,7 @@ public class Viscosity extends Glyph {
//account for huntress armor piercing
if (attacker instanceof Hero
&& ((Hero) attacker).belongings.weapon instanceof MissileWeapon
&& ((Hero) attacker).belongings.weapon() instanceof MissileWeapon
&& ((Hero) attacker).subClass == HeroSubClass.SNIPER
&& !Dungeon.level.adjacent(attacker.pos, defender.pos)){
realDamage = damage;

View File

@ -167,7 +167,8 @@ public class Bag extends Item implements Iterable<Item> {
}
public boolean canHold( Item item ){
if (!loading && owner != null && owner.buff(LostInventory.class) != null){
if (!loading && owner != null && owner.buff(LostInventory.class) != null
&& !item.keptThoughLostInvent){
return false;
}

View File

@ -98,8 +98,8 @@ public class Dart extends MissileWeapon {
private static Crossbow bow;
private void updateCrossbow(){
if (Dungeon.hero.belongings.weapon instanceof Crossbow){
bow = (Crossbow) Dungeon.hero.belongings.weapon;
if (Dungeon.hero.belongings.weapon() instanceof Crossbow){
bow = (Crossbow) Dungeon.hero.belongings.weapon();
} else {
bow = null;
}

View File

@ -126,7 +126,7 @@ public class HighGrass {
//Camouflage
//FIXME doesn't work with sad ghost
if (hero.belongings.armor != null && hero.belongings.armor.hasGlyph(Camouflage.class, hero)) {
if (hero.belongings.armor() != null && hero.belongings.armor().hasGlyph(Camouflage.class, hero)) {
Buff.prolong(hero, Invisibility.class, 3 + hero.belongings.armor.buffedLvl()/2);
Sample.INSTANCE.play( Assets.Sounds.MELD );
}

View File

@ -74,7 +74,7 @@ public class CursingTrap extends Trap {
//items the trap can curse if nothing else is available.
ArrayList<Item> canCurse = new ArrayList<>();
KindOfWeapon weapon = hero.belongings.weapon;
KindOfWeapon weapon = hero.belongings.weapon();
if (weapon instanceof Weapon && !(weapon instanceof MagesStaff)){
if (((Weapon) weapon).enchantment == null)
priorityCurse.add(weapon);
@ -82,7 +82,7 @@ public class CursingTrap extends Trap {
canCurse.add(weapon);
}
Armor armor = hero.belongings.armor;
Armor armor = hero.belongings.armor();
if (armor != null){
if (armor.glyph == null)
priorityCurse.add(armor);

View File

@ -149,7 +149,7 @@ public class MissileSprite extends ItemSprite implements Tweener.Listener {
}
float speed = SPEED;
if (item instanceof Dart && Dungeon.hero.belongings.weapon instanceof Crossbow){
if (item instanceof Dart && Dungeon.hero.belongings.weapon() instanceof Crossbow){
speed *= 3f;
} else if (item instanceof SpiritBow.SpiritArrow

View File

@ -216,7 +216,9 @@ public class QuickSlotButton extends Button {
}
private void enableSlot() {
slot.enable(Dungeon.quickslot.isNonePlaceholder( slotNum ) && Dungeon.hero.buff(LostInventory.class) == null);
//TODO check if item persists!
slot.enable(Dungeon.quickslot.isNonePlaceholder( slotNum )
&& (Dungeon.hero.buff(LostInventory.class) == null || Dungeon.quickslot.getItem(slotNum).keptThoughLostInvent));
}
public static void useTargeting(int idx){

View File

@ -388,7 +388,8 @@ public class WndBag extends WndTabbed {
enable( false );
} else if (selector != null && !selector.itemSelectable(item)) {
enable(false);
} else if (Dungeon.hero.buff(LostInventory.class) != null){
} else if (Dungeon.hero.buff(LostInventory.class) != null
&& !item.keptThoughLostInvent){
enable(false);
}
} else {

View File

@ -55,8 +55,8 @@ public class WndCombo extends Window {
pos = title.bottom() + 3*MARGIN;
Image icon;
if (Dungeon.hero.belongings.weapon != null){
icon = new ItemSprite(Dungeon.hero.belongings.weapon.image, null);
if (Dungeon.hero.belongings.weapon() != null){
icon = new ItemSprite(Dungeon.hero.belongings.weapon().image, null);
} else {
icon = new ItemSprite(new Item(){ {image = ItemSpriteSheet.WEAPON_HOLDER; }});
}

View File

@ -198,8 +198,9 @@ public class WndQuickBag extends Window {
}
}
if (Dungeon.hero.buff(LostInventory.class) != null){
enable(false); //TODO enable when hero has selected this item to keep
if (Dungeon.hero.buff(LostInventory.class) != null
&& !item.keptThoughLostInvent){
enable(false);
}
} else {

View File

@ -70,6 +70,14 @@ public class WndResurrect extends Window {
Statistics.ankhsUsed++;
//TODO let the player choose their items, instead of rigid weapon or armor
if (Dungeon.hero.belongings.weapon() != null){
Dungeon.hero.belongings.weapon().keptThoughLostInvent = true;
}
if (Dungeon.hero.belongings.armor() != null){
Dungeon.hero.belongings.armor().keptThoughLostInvent = true;
}
InterlevelScene.mode = InterlevelScene.Mode.RESURRECT;
Game.switchScene( InterlevelScene.class );
}