diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java new file mode 100644 index 000000000..852ae44ce --- /dev/null +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java @@ -0,0 +1,75 @@ +package com.shatteredpixel.shatteredpixeldungeon.items.wands; + +import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile; +import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; +import com.watabou.noosa.audio.Sample; +import com.watabou.utils.Callback; +import com.watabou.utils.Random; + +//helper class to contain all the cursed wand zapping logic, so the main wand class doesn't get huge. +//TODO: fill this in +public class CursedWand { + + private static float COMMON_CHANCE = 0.6f; + private static float UNCOMMON_CHANCE = 0.3f; + private static float RARE_CHANCE = 0.09f; + private static float VERY_RARE_CHANCE = 0.01f; + + public static void cursedZap(final Hero user, final Ballistica bolt){ + switch (Random.chances(new float[]{COMMON_CHANCE, UNCOMMON_CHANCE, RARE_CHANCE, VERY_RARE_CHANCE})){ + case 0: + default: + commonEffect(user, bolt); + break; + case 1: + uncommonEffect(user, bolt); + break; + case 2: + rareEffect(user, bolt); + break; + case 3: + veryRareEffect(user, bolt); + break; + } + } + + private static void commonEffect(final Hero user, final Ballistica bolt){ + //Random Fire! + if (Random.Int(2) == 0){ + Buff.affect(user, Burning.class).reignite(user); + } else { + cursedFX(user, bolt, new Callback() { + public void call() { + Char target = Actor.findChar(bolt.collisionPos); + if (target != null) + Buff.affect(target, Burning.class).reignite(target); + + } + }); + } + } + + private static void uncommonEffect(final Hero user, final Ballistica bolt){ + + } + + private static void rareEffect(final Hero user, final Ballistica bolt){ + + } + + private static void veryRareEffect(final Hero user, final Ballistica bolt){ + + } + + private static void cursedFX(final Hero user, final Ballistica bolt, final Callback callback){ + MagicMissile.shadow(user.sprite.parent, bolt.sourcePos, bolt.collisionPos, callback); + Sample.INSTANCE.play( Assets.SND_ZAP ); + } + +} diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java index 58fd56ee5..7e48bb2c8 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java @@ -23,16 +23,13 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.watabou.noosa.audio.Sample; import com.shatteredpixel.shatteredpixeldungeon.Assets; -import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; -import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile; import com.shatteredpixel.shatteredpixeldungeon.items.Item; -import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfMagic.Magic; import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; @@ -233,8 +230,8 @@ public abstract class Wand extends Item { } protected void wandUsed() { - usagesToKnow -= chargesPerCast(); - curCharges -= chargesPerCast(); + usagesToKnow -= cursed ? 1 : chargesPerCast(); + curCharges -= cursed ? 1 : chargesPerCast(); if (!isIdentified() && usagesToKnow <= 0) { identify(); GLog.w( TXT_IDENTIFY, name() ); @@ -256,8 +253,13 @@ public abstract class Wand extends Item { } } - upgrade( n ); - + if (Random.Float() < 0.3f){ + upgrade( Random.Int(n) ); + cursed = true; + cursedKnown = false; + } else + upgrade(n); + return this; } @@ -333,16 +335,25 @@ public abstract class Wand extends Item { else QuickSlotButton.target(Actor.findChar(cell)); - if (curWand.curCharges >= curWand.chargesPerCast()) { + if (curWand.curCharges >= (curWand.cursed ? 1 : curWand.chargesPerCast())) { curUser.busy(); - curWand.fx( shot, new Callback() { - public void call() { - curWand.onZap( shot ); - curWand.wandUsed(); + if (curWand.cursed){ + CursedWand.cursedZap(curUser, new Ballistica( curUser.pos, target, Ballistica.MAGIC_BOLT)); + if (!curWand.cursedKnown){ + curWand.cursedKnown = true; + GLog.n("This " + curItem.name() + " is cursed!"); } - } ); + curWand.wandUsed(); + } else { + curWand.fx(shot, new Callback() { + public void call() { + curWand.onZap(shot); + curWand.wandUsed(); + } + }); + } Invisibility.dispel();