v0.9.4: fixed lots of bugs involving charging items and lost inventory
This commit is contained in:
parent
440694cd47
commit
313ad4751c
|
@ -64,6 +64,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Amulet;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Amulet;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Ankh;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Ankh;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap.Type;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Heap.Type;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
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.armor.glyphs.Viscosity;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.AlchemistsToolkit;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.AlchemistsToolkit;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CapeOfThorns;
|
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.DriedRose;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.EtherealChains;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.EtherealChains;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TalismanOfForesight;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TalismanOfForesight;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
|
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.journal.Guidebook;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.CrystalKey;
|
import com.shatteredpixel.shatteredpixeldungeon.items.keys.CrystalKey;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey;
|
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.rings.RingOfTenacity;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping;
|
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.wands.WandOfLivingEarth;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.SpiritBow;
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.SpiritBow;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Flail;
|
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.items.weapon.missiles.MissileWeapon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
||||||
|
@ -1986,16 +1991,30 @@ public class Hero extends Char {
|
||||||
HP = HT;
|
HP = HT;
|
||||||
live();
|
live();
|
||||||
|
|
||||||
|
MagicalHolster holster = belongings.getItem(MagicalHolster.class);
|
||||||
|
|
||||||
Buff.affect(this, LostInventory.class);
|
Buff.affect(this, LostInventory.class);
|
||||||
Buff.affect(this, Invisibility.class, 3f);
|
Buff.affect(this, Invisibility.class, 3f);
|
||||||
//lost inventory is dropped in interlevelscene
|
//lost inventory is dropped in interlevelscene
|
||||||
|
|
||||||
//activate items that persist after lost inventory
|
//activate items that persist after lost inventory
|
||||||
if (belongings.weapon() != null) belongings.weapon().activate(this);
|
//FIXME this is very messy, maybe it would be better to just have one buff that
|
||||||
if (belongings.armor() != null) belongings.armor().activate(this);
|
// handled all items that recharge over time?
|
||||||
if (belongings.artifact() != null) belongings.artifact().activate(this);
|
for (Item i : belongings){
|
||||||
if (belongings.misc() != null) belongings.misc().activate(this);
|
if (i instanceof EquipableItem && i.isEquipped(this)){
|
||||||
if (belongings.ring() != null) belongings.ring().activate(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
|
@Override
|
||||||
|
|
|
@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.CounterBuff;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.EnhancedRings;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.EnhancedRings;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Haste;
|
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.Recharging;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.RevealedArea;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.RevealedArea;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Roots;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Roots;
|
||||||
|
@ -259,7 +260,9 @@ public enum Talent {
|
||||||
if (talent == LIGHT_CLOAK && hero.pointsInTalent(LIGHT_CLOAK) == 1){
|
if (talent == LIGHT_CLOAK && hero.pointsInTalent(LIGHT_CLOAK) == 1){
|
||||||
for (Item item : Dungeon.hero.belongings.backpack){
|
for (Item item : Dungeon.hero.belongings.backpack){
|
||||||
if (item instanceof CloakOfShadows){
|
if (item instanceof CloakOfShadows){
|
||||||
((CloakOfShadows) item).activate(Dungeon.hero);
|
if (hero.buff(LostInventory.class) == null || item.keptThoughLostInvent) {
|
||||||
|
((CloakOfShadows) item).activate(Dungeon.hero);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,11 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LostInventory;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LostInventory;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
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.HeroSprite;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
import com.watabou.noosa.audio.Sample;
|
import com.watabou.noosa.audio.Sample;
|
||||||
|
@ -23,12 +28,23 @@ public class LostBackpack extends Item {
|
||||||
hero.buff(LostInventory.class).detach();
|
hero.buff(LostInventory.class).detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MagicalHolster holster = hero.belongings.getItem(MagicalHolster.class);
|
||||||
for (Item i : hero.belongings){
|
for (Item i : hero.belongings){
|
||||||
if (i.keptThoughLostInvent){
|
if (i.keptThoughLostInvent){
|
||||||
i.keptThoughLostInvent = false;
|
i.keptThoughLostInvent = false; //don't reactivate, was previously activated
|
||||||
} else {
|
} else {
|
||||||
if (i instanceof EquipableItem && i.isEquipped(hero)){
|
if (i instanceof EquipableItem && i.isEquipped(hero)){
|
||||||
((EquipableItem) i).activate(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class MagesStaff extends MeleeWeapon {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void activate( Char ch ) {
|
public void activate( Char ch ) {
|
||||||
if(wand != null) wand.charge( ch, STAFF_SCALE_FACTOR );
|
applyWandChargeBuff(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -189,8 +189,8 @@ public class MagesStaff extends MeleeWeapon {
|
||||||
@Override
|
@Override
|
||||||
public boolean collect( Bag container ) {
|
public boolean collect( Bag container ) {
|
||||||
if (super.collect(container)) {
|
if (super.collect(container)) {
|
||||||
if (container.owner != null && wand != null) {
|
if (container.owner != null) {
|
||||||
wand.charge(container.owner, STAFF_SCALE_FACTOR);
|
applyWandChargeBuff(container.owner);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} 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<?extends Wand> wandClass(){
|
public Class<?extends Wand> wandClass(){
|
||||||
return wand != null ? wand.getClass() : null;
|
return wand != null ? wand.getClass() : null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user