v0.3.0: added in baseline functionality for cursed wands, need to fill it in still

This commit is contained in:
Evan Debenham 2015-05-21 08:07:55 -04:00
parent 05d20a4525
commit 20437994e2
2 changed files with 99 additions and 13 deletions

View File

@ -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 );
}
}

View File

@ -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();