diff --git a/assets/items.png b/assets/items.png index 471ea791b..a24f95aeb 100644 Binary files a/assets/items.png and b/assets/items.png differ diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Bones.java b/src/com/shatteredpixel/shatteredpixeldungeon/Bones.java index fe7654735..8d30d10f4 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Bones.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Bones.java @@ -181,7 +181,7 @@ public class Bones { } } - item.sync(); + item.reset(); return item; } else { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java index c3c7a1008..849013b0a 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java @@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Challenges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSigil; import com.shatteredpixel.shatteredpixeldungeon.items.armor.ClothArmor; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows; import com.shatteredpixel.shatteredpixeldungeon.items.food.Food; @@ -108,7 +109,7 @@ public enum HeroClass { Dart darts = new Dart( 8 ); darts.identify().collect(); - hero.belongings.armor.activate(hero); + new BrokenSigil().collect(); Dungeon.quickslot.setSlot(0, darts); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSigil.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSigil.java index bc473c726..2bdcd1d24 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSigil.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSigil.java @@ -1,11 +1,72 @@ 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.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; +import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; +import com.watabou.noosa.audio.Sample; -//TODO: add actual item properties here -public class BrokenSigil { +import java.util.ArrayList; + +public class BrokenSigil extends Item { + + public static final String AC_AFFIX = "AFFIX"; + + { + image = ItemSpriteSheet.SIGIL; + + cursedKnown = levelKnown = true; + unique = true; + bones = false; + } + + @Override + public ArrayList actions(Hero hero) { + ArrayList actions = super.actions(hero); + actions.add(AC_AFFIX); + return actions; + } + + @Override + public void execute(Hero hero, String action) { + if (action.equals(AC_AFFIX)){ + curItem = this; + GameScene.selectItem(armorSelector, WndBag.Mode.ARMOR, Messages.get(this, "prompt")); + } else { + super.execute(hero, action); + } + } + + @Override + public boolean isUpgradable() { + return false; + } + + protected static WndBag.Listener armorSelector = new WndBag.Listener() { + @Override + public void onSelect( Item item ) { + if (item != null && item instanceof Armor) { + Armor armor = (Armor)item; + if (!armor.levelKnown){ + GLog.w(Messages.get(BrokenSigil.class, "unknown_armor")); + } else if (armor.cursed || armor.level() < 0){ + GLog.w(Messages.get(BrokenSigil.class, "degraded_armor")); + } else { + GLog.p(Messages.get(BrokenSigil.class, "affix")); + Dungeon.hero.sprite.operate(Dungeon.hero.pos); + Sample.INSTANCE.play(Assets.SND_UNLOCK); + armor.affixSigil((BrokenSigil)curItem); + curItem.detach(Dungeon.hero.belongings.backpack); + } + } + } + }; public static class SigilShield extends Buff { @@ -16,10 +77,9 @@ public class BrokenSigil { public boolean act() { if (armor == null) detach(); else if (armor.isEquipped((Hero)target)) { - //1 + half of your DR, rounded up. - int maxShield = (int)(armor.DR()/2f + 1.5f); + int maxShield = 1 + armor.tier + armor.level(); if (target.SHLD < maxShield){ - partialShield += (maxShield - target.SHLD)/50f; + partialShield += 1/(30*Math.pow(0.9f, (maxShield - target.SHLD))); } } while (partialShield >= 1){ diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/Item.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/Item.java index 20bc575c3..7fc2d18fe 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/Item.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/Item.java @@ -117,8 +117,8 @@ public class Item implements Bundlable { Dungeon.level.drop( detachAll( hero.belongings.backpack ), hero.pos ).sprite.drop( hero.pos ); } - //'syncs' an item to be consistent between two separate game instances. - public void sync(){ + //resets an item's properties, to ensure consistency between runs + public void reset(){ //resets the name incase the language has changed. name = Messages.get(this, "name"); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java index 8a7a21b5f..d67451422 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java @@ -25,7 +25,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; -import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSigil; import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem; @@ -49,11 +48,14 @@ import com.watabou.utils.Bundlable; import com.watabou.utils.Bundle; import com.watabou.utils.Random; +import java.util.ArrayList; + public class Armor extends EquipableItem { private static final int HITS_TO_KNOW = 10; private static final String TXT_TO_STRING = "%s :%d"; + private static final String AC_DETACH = "DETACH"; public int tier; @@ -73,11 +75,14 @@ public class Armor extends EquipableItem { private static final String UNFAMILIRIARITY = "unfamiliarity"; private static final String GLYPH = "glyph"; + private static final String SIGIL = "sigil"; + @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); bundle.put( UNFAMILIRIARITY, hitsToKnow ); bundle.put( GLYPH, glyph ); + bundle.put( SIGIL, sigil ); } @Override @@ -87,6 +92,44 @@ public class Armor extends EquipableItem { hitsToKnow = HITS_TO_KNOW; } inscribe((Glyph) bundle.get(GLYPH)); + sigil = bundle.getBoolean(SIGIL); + if (sigil) unique = true; + } + + @Override + public void reset() { + super.reset(); + //armor can be kept in bones between runs, the sigil cannot. + sigil = false; + } + + @Override + public ArrayList actions(Hero hero) { + ArrayList actions = super.actions(hero); + if (sigil) actions.add(AC_DETACH); + return actions; + } + + @Override + public void execute(Hero hero, String action) { + if (action.equals(AC_DETACH) && sigil){ + sigil = false; + BrokenSigil.SigilShield sigilBuff = hero.buff(BrokenSigil.SigilShield.class); + if (sigilBuff != null) sigilBuff.setArmor(null); + + BrokenSigil sigil = new BrokenSigil(); + if (level() > 0){ + sigil.upgrade(); + degrade(); + } + GLog.i( Messages.get(Armor.class, "detach_sigil") ); + hero.sprite.operate(hero.pos); + if (!sigil.collect()){ + Dungeon.level.drop(sigil, hero.pos); + } + } else { + super.execute(hero, action); + } } @Override @@ -120,8 +163,18 @@ public class Armor extends EquipableItem { @Override public void activate(Char ch) { - if (Dungeon.hero.heroClass == HeroClass.WARRIOR) - Buff.affect(ch, BrokenSigil.SigilShield.class).setArmor(this); + if (sigil) Buff.affect(ch, BrokenSigil.SigilShield.class).setArmor(this); + } + + public void affixSigil(BrokenSigil sigil){ + this.sigil = true; + if (sigil.level() > 0){ + //doesn't override existing glyphs, but doesn't create one either + upgrade(glyph != null); + } + if (isEquipped(Dungeon.hero)){ + Buff.affect(Dungeon.hero, BrokenSigil.SigilShield.class).setArmor(this); + } } @Override @@ -136,8 +189,8 @@ public class Armor extends EquipableItem { hero.belongings.armor = null; ((HeroSprite)hero.sprite).updateArmor(); - BrokenSigil.SigilShield sigil = hero.buff(BrokenSigil.SigilShield.class); - if (sigil != null) sigil.setArmor(null); + BrokenSigil.SigilShield sigilBuff = hero.buff(BrokenSigil.SigilShield.class); + if (sigilBuff != null) sigilBuff.setArmor(null); return true; @@ -247,8 +300,7 @@ public class Armor extends EquipableItem { @Override public Emitter emitter() { - //if (!sigil) return super.emitter(); - if (Dungeon.hero.heroClass != HeroClass.WARRIOR) return super.emitter(); + if (!sigil) return super.emitter(); Emitter emitter = new Emitter(); emitter.pos(10f, 6f); emitter.fillTarget = false; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java index 307d5ceee..c69f8a0b0 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java @@ -268,10 +268,6 @@ public class LloydsBeacon extends Artifact { } return desc; } - - public void reset() { - returnDepth = -1; - } private static final Glowing WHITE = new Glowing( 0xFFFFFF ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java index ce69de13d..eaaddce9d 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java @@ -20,32 +20,32 @@ */ package com.shatteredpixel.shatteredpixeldungeon.items.potions; -import java.util.ArrayList; -import java.util.HashSet; - +import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.Badges; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning; -import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; -import com.watabou.noosa.audio.Sample; -import com.shatteredpixel.shatteredpixeldungeon.Assets; -import com.shatteredpixel.shatteredpixeldungeon.Badges; -import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.effects.Splash; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +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.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; +import com.watabou.noosa.audio.Sample; import com.watabou.utils.Bundle; +import java.util.ArrayList; +import java.util.HashSet; + public class Potion extends Item { public static final String AC_DRINK = "DRINK"; @@ -112,12 +112,12 @@ public class Potion extends Item { public Potion() { super(); - sync(); + reset(); } @Override - public void sync(){ - super.sync(); + public void reset(){ + super.reset(); image = handler.image( this ); color = handler.label( this ); }; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java index c0d30e05b..7d652df0e 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java @@ -92,11 +92,11 @@ public class Ring extends KindofMisc { public Ring() { super(); - sync(); + reset(); } - public void sync() { - super.sync(); + public void reset() { + super.reset(); image = handler.image( this ); gem = handler.label( this ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java index dc415b221..f8dd258f9 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java @@ -100,12 +100,12 @@ public abstract class Scroll extends Item { public Scroll() { super(); - sync(); + reset(); } @Override - public void sync(){ - super.sync(); + public void reset(){ + super.reset(); image = handler.image( this ); rune = handler.label( this ); }; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties b/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties index 92b6445e2..ccea6984a 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties +++ b/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties @@ -29,6 +29,8 @@ items.armor.glyphs.viscosity$defereddamage.desc=While your armor's glyph has pro ###armor +items.armor.armor.ac_detach=DETACH +items.armor.armor.detach_sigil=You detach the sigil from your armor. items.armor.armor.equip_cursed=your %s constricts around you painfully items.armor.armor.identify=you are now familiar enough with your %s to identify it. It is %s. items.armor.armor.incompatible=Interaction of different types of magic has erased the glyph on this armor! @@ -801,6 +803,14 @@ items.bomb.desc_burning=A fairly hefty black powder bomb. An explosion from this items.bomb$doublebomb.name=two bombs items.bomb$doublebomb.desc=A stack of two hefty black powder bombs, looks like you get one free! +items.brokensigil.name=Broken Sigil +items.brokensigil.ac_affix=AFFIX +items.brokensigil.prompt=Select an armor +items.brokensigil.unknown_armor=You must identify that armor first. +items.brokensigil.degraded_armor=That armor is in too poor a condition. +items.brokensigil.affix=You affix the sigil to your armor! +items.brokensigil.desc=A broken sigil from the warrior's past.\n\nMORE STUFF NEEDED HERE. + items.dewdrop.name=dewdrop items.dewdrop.value=%+dHP items.dewdrop.already_full=You already have full health. diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java b/src/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java index ad3201d37..92f7ae4eb 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java @@ -46,39 +46,40 @@ public class ItemSpriteSheet { public static final int DEWDROP = ROW1+1; public static final int PETAL = ROW1+2; public static final int SANDBAG = ROW1+3; + public static final int DBL_BOMB = ROW1+4; // Heaps (containers) - public static final int BONES = ROW1+4; - public static final int REMAINS = ROW1+5; - public static final int TOMB = ROW1+6; - public static final int GRAVE = ROW1+7; - public static final int CHEST = ROW1+8; - public static final int LOCKED_CHEST = ROW1+9; - public static final int CRYSTAL_CHEST = ROW1+10; + public static final int BONES = ROW1+5; + public static final int REMAINS = ROW1+6; + public static final int TOMB = ROW1+7; + public static final int GRAVE = ROW1+8; + public static final int CHEST = ROW1+9; + public static final int LOCKED_CHEST = ROW1+10; + public static final int CRYSTAL_CHEST = ROW1+11; // Placeholders - public static final int WEAPON = ROW1+11; - public static final int ARMOR = ROW1+12; - public static final int RING = ROW1+13; - public static final int SMTH = ROW1+14; + public static final int WEAPON = ROW1+12; + public static final int ARMOR = ROW1+13; + public static final int RING = ROW1+14; + public static final int SMTH = ROW1+15; //Row Two: Miscellaneous single use items public static final int GOLD = ROW2+0; public static final int TORCH = ROW2+1; public static final int STYLUS = ROW2+2; public static final int ANKH = ROW2+3; + public static final int WEIGHT = ROW2+4; + public static final int BOMB = ROW2+5; + public static final int HONEYPOT = ROW2+6; + public static final int SHATTPOT = ROW2+7; + public static final int SIGIL = ROW2+8; // Keys - public static final int IRON_KEY = ROW2+4; - public static final int GOLDEN_KEY = ROW2+5; - public static final int SKELETON_KEY = ROW2+6; + public static final int IRON_KEY = ROW2+9; + public static final int GOLDEN_KEY = ROW2+10; + public static final int SKELETON_KEY = ROW2+11; //Boss Rewards - public static final int BEACON = ROW2+7; - public static final int MASTERY = ROW2+8; - public static final int KIT = ROW2+9; - public static final int AMULET = ROW2+10; - public static final int WEIGHT = ROW2+11; - public static final int BOMB = ROW2+12; - public static final int DBL_BOMB= ROW2+13; - public static final int HONEYPOT= ROW2+14; - public static final int SHATTPOT= ROW2+15; + public static final int BEACON = ROW2+12; + public static final int MASTERY = ROW2+13; + public static final int KIT = ROW2+14; + public static final int AMULET = ROW2+15; //Row Three: Melee weapons public static final int KNUCKLEDUSTER = ROW3+0;