diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java index fbe572839..c98482a0d 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java @@ -30,6 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.EarthImbue; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FireImbue; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MagicalSleep; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Slow; @@ -257,13 +258,14 @@ public abstract class Char extends Actor { } } - if (SHLD >= dmg){ + //FIXME: when I add proper damage properties, should add an IGNORES_SHIELDS property to use here. + if (src instanceof Hunger || SHLD == 0){ + HP -= dmg; + } else if (SHLD >= dmg){ SHLD -= dmg; } else if (SHLD > 0) { HP -= (dmg - SHLD); SHLD = 0; - } else { - HP -= dmg; } if (dmg > 0 || src instanceof Char) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java index 9243e03fa..c3c7a1008 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java @@ -25,24 +25,20 @@ 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.bags.PotionBandolier; -import com.shatteredpixel.shatteredpixeldungeon.items.bags.ScrollHolder; -import com.shatteredpixel.shatteredpixeldungeon.items.bags.SeedPouch; -import com.shatteredpixel.shatteredpixeldungeon.items.bags.WandHolster; -import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.items.armor.ClothArmor; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows; import com.shatteredpixel.shatteredpixeldungeon.items.food.Food; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMindVision; -import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade; -import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfMagicMissile; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Dagger; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.ShortSword; -import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Dart; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Dart; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.watabou.utils.Bundle; public enum HeroClass { @@ -108,15 +104,15 @@ public enum HeroClass { } private static void initWarrior( Hero hero ) { - hero.STR = hero.STR + 1; - (hero.belongings.weapon = new ShortSword()).identify(); Dart darts = new Dart( 8 ); darts.identify().collect(); + hero.belongings.armor.activate(hero); + Dungeon.quickslot.setSlot(0, darts); - new PotionOfStrength().setKnown(); + new PotionOfHealing().setKnown(); } private static void initMage( Hero hero ) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSigil.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSigil.java new file mode 100644 index 000000000..bc473c726 --- /dev/null +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSigil.java @@ -0,0 +1,37 @@ +package com.shatteredpixel.shatteredpixeldungeon.items; + +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; + +//TODO: add actual item properties here +public class BrokenSigil { + + public static class SigilShield extends Buff { + + private Armor armor; + private float partialShield; + + @Override + 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); + if (target.SHLD < maxShield){ + partialShield += (maxShield - target.SHLD)/50f; + } + } + while (partialShield >= 1){ + target.SHLD++; + partialShield--; + } + spend(TICK); + return true; + } + + public void setArmor(Armor arm){ + armor = arm; + } + } +} diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java index f55dfd512..8a7a21b5f 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java @@ -23,7 +23,11 @@ package com.shatteredpixel.shatteredpixeldungeon.items.armor; import com.shatteredpixel.shatteredpixeldungeon.Badges; 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; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Affection; @@ -40,6 +44,7 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; +import com.watabou.noosa.particles.Emitter; import com.watabou.utils.Bundlable; import com.watabou.utils.Bundle; import com.watabou.utils.Random; @@ -57,6 +62,7 @@ public class Armor extends EquipableItem { private int hitsToKnow = HITS_TO_KNOW; public Glyph glyph; + private boolean sigil; public Armor( int tier ) { @@ -99,6 +105,7 @@ public class Armor extends EquipableItem { } ((HeroSprite)hero.sprite).updateArmor(); + activate(hero); hero.spendAndNext( 2 * time2equip( hero ) ); return true; @@ -111,6 +118,12 @@ 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); + } + @Override protected float time2equip( Hero hero ) { return hero.speed(); @@ -123,6 +136,9 @@ 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); + return true; } else { @@ -228,7 +244,18 @@ public class Armor extends EquipableItem { return info; } - + + @Override + public Emitter emitter() { + //if (!sigil) return super.emitter(); + if (Dungeon.hero.heroClass != HeroClass.WARRIOR) return super.emitter(); + Emitter emitter = new Emitter(); + emitter.pos(10f, 6f); + emitter.fillTarget = false; + emitter.pour(Speck.factory( Speck.LIGHT ), 1f); + return emitter; + } + @Override public Item random() { if (Random.Float() < 0.4) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java index 956663be6..f4ad24859 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java @@ -113,14 +113,8 @@ abstract public class Weapon extends KindOfWeapon { float ACU = this.ACU; if (this instanceof MissileWeapon) { - switch (hero.heroClass) { - case WARRIOR: - encumbrance += 3; - break; - case HUNTRESS: + if (hero.heroClass == HeroClass.HUNTRESS) { encumbrance -= 2; - break; - default: } int bonus = 0; for (Buff buff : hero.buffs(RingOfSharpshooting.Aim.class)) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/ShortSword.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/ShortSword.java index 4a6f2ec30..df08991e7 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/ShortSword.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/ShortSword.java @@ -20,113 +20,16 @@ */ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee; -import com.shatteredpixel.shatteredpixeldungeon.Assets; -import com.shatteredpixel.shatteredpixeldungeon.Badges; -import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; -import com.shatteredpixel.shatteredpixeldungeon.items.Item; -import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade; -import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang; -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; - -import java.util.ArrayList; public class ShortSword extends MeleeWeapon { - public static final String AC_REFORGE = "REFORGE"; - - private static final String TXT_SELECT_WEAPON = "Select a weapon to upgrade"; - - private static final String TXT_REFORGED = - "you reforged the short sword to upgrade your %s"; - private static final String TXT_NOT_BOOMERANG = - "you can't upgrade a boomerang this way"; - - private static final float TIME_TO_REFORGE = 2f; - - private boolean equipped; - { image = ItemSpriteSheet.SHORT_SWORD; - - unique = true; - bones = false; } public ShortSword() { super( 1, 1f, 1f ); - - STR = 11; } - @Override - protected int maxBase() { - return 12; - } - - @Override - public ArrayList actions( Hero hero ) { - ArrayList actions = super.actions( hero ); - if (level() > 0) { - actions.add( AC_REFORGE ); - } - return actions; - } - - @Override - public void execute( Hero hero, String action ) { - if (action == AC_REFORGE) { - - if (hero.belongings.weapon == this) { - equipped = true; - hero.belongings.weapon = null; - } else { - equipped = false; - detach( hero.belongings.backpack ); - } - - curUser = hero; - - GameScene.selectItem( itemSelector, WndBag.Mode.WEAPON, TXT_SELECT_WEAPON ); - - } else { - - super.execute( hero, action ); - - } - } - - private final WndBag.Listener itemSelector = new WndBag.Listener() { - @Override - public void onSelect( Item item ) { - if (item != null && !(item instanceof Boomerang)) { - - Sample.INSTANCE.play( Assets.SND_EVOKE ); - ScrollOfUpgrade.upgrade( curUser ); - evoke( curUser ); - - GLog.w( TXT_REFORGED, item.name() ); - - ((MeleeWeapon)item).safeUpgrade(); - curUser.spendAndNext( TIME_TO_REFORGE ); - - Badges.validateItemLevelAquired( item ); - - } else { - - if (item instanceof Boomerang) { - GLog.w( TXT_NOT_BOOMERANG ); - } - - if (equipped) { - curUser.belongings.weapon = ShortSword.this; - } else { - collect( curUser.belongings.backpack ); - } - } - } - }; } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties b/src/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties index e32a77fa9..866457c7d 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties +++ b/src/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties @@ -200,11 +200,11 @@ actors.hero.hero.pain_resist=The pain helps you resist the urge to sleep. actors.hero.hero.revive=The ankh explodes with life-giving energy! actors.hero.heroclass.warrior=warrior -actors.hero.heroclass.warrior_perk1=The Warrior starts with 11 points of Strength. -actors.hero.heroclass.warrior_perk2=The Warrior starts with a unique short sword. This sword can later be "reforged" to upgrade another melee weapon. -actors.hero.heroclass.warrior_perk3=The Warrior is less proficient with missile weapons. +actors.hero.heroclass.warrior_perk1=The Warrior starts with a broken sigil which he can affix to armor. +actors.hero.heroclass.warrior_perk2=The Warrior will slowly generate a shield while he is wearing armor with the sigil affixed. +actors.hero.heroclass.warrior_perk3=The sigil can be moved between armor, carrying a single upgrade with it. actors.hero.heroclass.warrior_perk4=Any piece of food restores some health when eaten. -actors.hero.heroclass.warrior_perk5=Potions of Strength are identified from the beginning. +actors.hero.heroclass.warrior_perk5=Potions of Healing are identified from the beginning. actors.hero.heroclass.mage=mage actors.hero.heroclass.mage_perk1=The Mage starts with a unique Staff, which can be imbued with the properties of a wand.