diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 07f9c5e1b..4236742f7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -64,6 +64,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; import com.shatteredpixel.shatteredpixeldungeon.items.Amulet; import com.shatteredpixel.shatteredpixeldungeon.items.Ankh; import com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop; +import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem; import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Heap.Type; import com.shatteredpixel.shatteredpixeldungeon.items.Item; @@ -74,11 +75,13 @@ import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Brimstone; import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Viscosity; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.AlchemistsToolkit; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CapeOfThorns; +import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.EtherealChains; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TalismanOfForesight; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass; +import com.shatteredpixel.shatteredpixeldungeon.items.bags.MagicalHolster; import com.shatteredpixel.shatteredpixeldungeon.items.journal.Guidebook; import com.shatteredpixel.shatteredpixeldungeon.items.keys.CrystalKey; import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey; @@ -98,10 +101,12 @@ import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfMight; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfTenacity; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping; +import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfLivingEarth; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.SpiritBow; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Flail; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon; import com.shatteredpixel.shatteredpixeldungeon.journal.Document; import com.shatteredpixel.shatteredpixeldungeon.journal.Notes; @@ -1986,16 +1991,30 @@ public class Hero extends Char { HP = HT; live(); + MagicalHolster holster = belongings.getItem(MagicalHolster.class); + 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); + //FIXME this is very messy, maybe it would be better to just have one buff that + // handled all items that recharge over time? + 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)){ + ((CloakOfShadows) i).activate(this); + } else if (i instanceof Wand && i.keptThoughLostInvent){ + if (holster.contains(i)){ + ((Wand) i).charge(this, MagicalHolster.HOLSTER_SCALE_FACTOR); + } else { + ((Wand) i).charge(this); + } + } else if (i instanceof MagesStaff && i.keptThoughLostInvent){ + ((MagesStaff) i).applyWandChargeBuff(this); + } + } } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java index 7f16d7bcd..d0c2605b3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java @@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.CounterBuff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.EnhancedRings; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Haste; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LostInventory; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Recharging; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.RevealedArea; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Roots; @@ -259,7 +260,9 @@ public enum Talent { if (talent == LIGHT_CLOAK && hero.pointsInTalent(LIGHT_CLOAK) == 1){ for (Item item : Dungeon.hero.belongings.backpack){ if (item instanceof CloakOfShadows){ - ((CloakOfShadows) item).activate(Dungeon.hero); + if (hero.buff(LostInventory.class) == null || item.keptThoughLostInvent) { + ((CloakOfShadows) item).activate(Dungeon.hero); + } } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/LostBackpack.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/LostBackpack.java index c09c2d909..c1071adf9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/LostBackpack.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/LostBackpack.java @@ -5,6 +5,11 @@ 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; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent; +import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows; +import com.shatteredpixel.shatteredpixeldungeon.items.bags.MagicalHolster; +import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.watabou.noosa.audio.Sample; @@ -23,12 +28,23 @@ public class LostBackpack extends Item { hero.buff(LostInventory.class).detach(); } + MagicalHolster holster = hero.belongings.getItem(MagicalHolster.class); for (Item i : hero.belongings){ if (i.keptThoughLostInvent){ - i.keptThoughLostInvent = false; + i.keptThoughLostInvent = false; //don't reactivate, was previously activated } else { if (i instanceof EquipableItem && i.isEquipped(hero)){ ((EquipableItem) i).activate(hero); + } else if ( i instanceof CloakOfShadows && hero.hasTalent(Talent.LIGHT_CLOAK)){ + ((CloakOfShadows) i).activate(hero); + } else if (i instanceof Wand){ + if (holster.contains(i)){ + ((Wand) i).charge(hero, MagicalHolster.HOLSTER_SCALE_FACTOR); + } else { + ((Wand) i).charge(hero); + } + } else if (i instanceof MagesStaff){ + ((MagesStaff) i).applyWandChargeBuff(hero); } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java index 105730e70..a68f1e0e7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java @@ -113,7 +113,7 @@ public class MagesStaff extends MeleeWeapon { @Override public void activate( Char ch ) { - if(wand != null) wand.charge( ch, STAFF_SCALE_FACTOR ); + applyWandChargeBuff(ch); } @Override @@ -189,8 +189,8 @@ public class MagesStaff extends MeleeWeapon { @Override public boolean collect( Bag container ) { if (super.collect(container)) { - if (container.owner != null && wand != null) { - wand.charge(container.owner, STAFF_SCALE_FACTOR); + if (container.owner != null) { + applyWandChargeBuff(container.owner); } return true; } else { @@ -264,6 +264,12 @@ public class MagesStaff extends MeleeWeapon { } } + public void applyWandChargeBuff(Char owner){ + if (wand != null){ + wand.charge(owner, STAFF_SCALE_FACTOR); + } + } + public Class wandClass(){ return wand != null ? wand.getClass() : null; }