diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java index 3f7c00bfd..8d4f10f11 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java @@ -28,11 +28,11 @@ import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows; import com.shatteredpixel.shatteredpixeldungeon.items.food.Food; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMindVision; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength; -import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify; 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.Knuckles; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.ShortSword; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Dart; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang; @@ -57,11 +57,11 @@ public enum HeroClass { }; public static final String[] MAG_PERKS = { - "Mages start with a unique Wand of Magic Missile. This wand can be later \"disenchanted\" to upgrade another wand.", - "Mages recharge their wands faster.", + "Mages start with a unique Staff, which can be imbued with the properties of a wand.", + "The Mage's staff can be used as a melee weapon or a wand, and charges faster than a wand.", "When eaten, any piece of food restores 1 charge for all wands in the inventory.", "Mages can use wands as a melee weapon.", - "Scrolls of Identify are identified from the beginning." + "Scrolls of Upgrade are identified from the beginning." }; public static final String[] ROG_PERKS = { @@ -149,14 +149,13 @@ public enum HeroClass { } private static void initMage( Hero hero ) { - (hero.belongings.weapon = new Knuckles()).identify(); + MagesStaff staff = new MagesStaff(new WandOfMagicMissile()); + (hero.belongings.weapon = staff).identify(); + hero.belongings.weapon.activate(hero); - WandOfMagicMissile wand = new WandOfMagicMissile(); - wand.identify().collect(); + Dungeon.quickslot.setSlot(0, staff); - Dungeon.quickslot.setSlot(0, wand); - - new ScrollOfIdentify().setKnown(); + new ScrollOfUpgrade().setKnown(); } private static void initRogue( Hero hero ) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java index f721c530b..4b23c71fa 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java @@ -37,6 +37,7 @@ import com.watabou.utils.Random; import java.util.ArrayList; +//TODO: final balancing choices public class WandOfMagicMissile extends Wand { public static final String AC_DISENCHANT = "DISENCHANT"; @@ -73,8 +74,8 @@ public class WandOfMagicMissile extends Wand { if (ch != null) { int level = level(); - - ch.damage( Random.Int( 1, 6 + level * 2 ), this ); + + ch.damage( Random.NormalIntRange( 3+level, 6+level*2 ), this ); ch.sprite.burst( 0xFF99CCFF, level / 2 + 2 ); @@ -109,7 +110,7 @@ public class WandOfMagicMissile extends Wand { } protected int initialCharges() { - return 3; + return 4; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java new file mode 100644 index 000000000..c0f33b16f --- /dev/null +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java @@ -0,0 +1,219 @@ +package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee; + +import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.items.Item; +import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag; +import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade; +import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon; +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 com.watabou.utils.Bundle; + +import java.util.ArrayList; + +/** + * Created by debenhame on 13/03/2015. + */ +//TODO: lots of refinements to make here still. +public class MagesStaff extends MeleeWeapon { + + private Wand wand; + + public static final String AC_IMBUE = "IMBUE"; + public static final String AC_ZAP = "ZAP"; + + private static final String TXT_SELECT_WAND = "Select a wand to consume"; + + //TODO: decide on balancing + private static final float STAFF_SCALE_FACTOR = 0.70f; + + { + name = "Mage's Staff"; + image = ItemSpriteSheet.WAND_MAGIC_MISSILE; + + defaultAction = AC_ZAP; + + bones = false; + } + + public MagesStaff() { + + //tier 1 weapon with really poor base stats. + super(1, 1f, 1f); + MIN = 1; + MAX = 4; + + wand = null; + } + + public MagesStaff(Wand wand){ + this(); + wand.identify(); + wand.cursed = false; + this.wand = wand; + } + + @Override + public ArrayList actions(Hero hero) { + ArrayList actions = super.actions( hero ); + actions.add(AC_IMBUE); + if (wand!= null && wand.curCharges > 0) { + actions.add( AC_ZAP ); + } + return actions; + } + + @Override + public void activate( Hero hero ) { + if(wand != null) wand.charge( hero, STAFF_SCALE_FACTOR ); + } + + @Override + public void execute(Hero hero, String action) { + if (action.equals(AC_IMBUE)) { + + curUser = hero; + GameScene.selectItem(itemSelector, WndBag.Mode.WAND, TXT_SELECT_WAND); + + } else if (action.equals(AC_ZAP)){ + if (wand == null) + return; + + wand.execute(hero, AC_ZAP); + } else + super.execute(hero, action); + } + + @Override + public boolean collect( Bag container ) { + if (super.collect( container )) { + if (container.owner != null && wand != null) { + wand.charge(container.owner, STAFF_SCALE_FACTOR); + } + return true; + } else { + return false; + } + } + + @Override + public void onDetach( ) { + if (wand != null) wand.stopCharging(); + } + + public Item imbueWand(Wand wand, Char owner){ + + this.wand = null; + + GLog.w("TODO"); + enchant( null ); + + //syncs the level of the two items. + //TODO: decide on balancing for this + int targetLevel = Math.round((this.level*2 + wand.level)/3f); + + int staffLevelDiff = targetLevel - this.level; + if (staffLevelDiff > 0) + this.upgrade(staffLevelDiff); + else if (staffLevelDiff < 0) + this.degrade(Math.abs(staffLevelDiff)); + + int wandLevelDiff = targetLevel - wand.level; + if (wandLevelDiff > 0) + wand.upgrade(wandLevelDiff); + else if (wandLevelDiff < 0) + wand.degrade(Math.abs(wandLevelDiff)); + + GLog.p("TODO"); + + this.wand = wand; + wand.identify(); + wand.cursed = false; + wand.charge(owner); + + updateQuickslot(); + + return this; + + } + + @Override + public Item upgrade() { + if (wand != null) wand.upgrade(); + return super.upgrade(); + } + + @Override + public Item degrade() { + if (wand != null) wand.degrade(); + return super.degrade(); + } + + @Override + public String status() { + if (wand == null) return super.status(); + else return wand.status(); + } + + @Override + public String name(){ + if (wand == null) + return super.name(); + else { + String name = wand.name().replace("Wand", "Staff"); + return enchantment == null ? name : enchantment.name( name ); + } + } + + @Override + public String info() { + return super.info(); + } + + private static final String WAND = "wand"; + + @Override + public void storeInBundle(Bundle bundle) { + super.storeInBundle(bundle); + bundle.put(WAND, wand); + } + + @Override + public void restoreFromBundle(Bundle bundle) { + super.restoreFromBundle(bundle); + //TODO: error check here? + wand = (Wand) bundle.get(WAND); + } + + private final WndBag.Listener itemSelector = new WndBag.Listener() { + @Override + public void onSelect( Item item ) { + if (item != null) { + + Sample.INSTANCE.play( Assets.SND_EVOKE ); + ScrollOfUpgrade.upgrade(curUser); + evoke( curUser ); + + GLog.w( "TODO" ); + + Dungeon.quickslot.clearItem(item); + + item.detach( curUser.belongings.backpack ); + + imbueWand((Wand) item, curUser); + + curUser.spendAndNext( 2f ); + + updateQuickslot(); + + } + } + }; +} diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java index faf965fa0..62952bf40 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java @@ -17,8 +17,7 @@ */ package com.shatteredpixel.shatteredpixeldungeon.ui; -import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; -import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang; +import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem; import com.watabou.noosa.Image; import com.watabou.noosa.ui.Button; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; @@ -77,7 +76,7 @@ public class QuickSlotButton extends Button implements WndBag.Listener { GameScene.handleCell( lastTarget.pos ); } else { Item item = select(slotNum); - if (item.stackable || item instanceof Wand || item instanceof Boomerang) + if (item instanceof EquipableItem) useTargeting(); item.execute( Dungeon.hero ); }