v0.3.0: reworked scroll of recharging & battlemage charging mechanics

This commit is contained in:
Evan Debenham 2015-03-30 02:08:57 -04:00
parent ff804668a4
commit 348f16c19b
6 changed files with 52 additions and 26 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -86,6 +86,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
@ -102,7 +103,6 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage; import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndResurrect; import com.shatteredpixel.shatteredpixeldungeon.windows.WndResurrect;
@ -872,19 +872,11 @@ public class Hero extends Char {
} }
break; break;
case BATTLEMAGE: case BATTLEMAGE:
if (wep instanceof Wand) { if (wep instanceof Wand || wep instanceof MagesStaff) {
Wand wand = (Wand)wep; //gives wands 50% charge
if (wand.curCharges < wand.maxCharges && damage > 0) { Buff.affect( this, ScrollOfRecharging.Recharging.class, 2f);
wand.curCharges++;
if (Dungeon.quickslot.contains(wand)) {
QuickSlotButton.refresh();
}
ScrollOfRecharging.charge( this ); ScrollOfRecharging.charge( this );
} }
damage += wand.curCharges;
}
break; break;
case SNIPER: case SNIPER:
if (rangedWeapon != null) { if (rangedWeapon != null) {

View File

@ -17,6 +17,9 @@
*/ */
package com.shatteredpixel.shatteredpixeldungeon.items.scrolls; package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
@ -27,6 +30,8 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class ScrollOfRecharging extends Scroll { public class ScrollOfRecharging extends Scroll {
public static final float BUFF_DURATION = 30f;
{ {
name = "Scroll of Recharging"; name = "Scroll of Recharging";
initials = "Re"; initials = "Re";
@ -35,18 +40,14 @@ public class ScrollOfRecharging extends Scroll {
@Override @Override
protected void doRead() { protected void doRead() {
int count = curUser.belongings.charge( true ); Buff.affect(curUser, Recharging.class, BUFF_DURATION);
charge(curUser); charge(curUser);
Sample.INSTANCE.play( Assets.SND_READ ); Sample.INSTANCE.play( Assets.SND_READ );
Invisibility.dispel(); Invisibility.dispel();
if (count > 0) { GLog.i( "a surge of energy courses through your body, invigorating your wands.");
GLog.i( "a surge of energy courses through your pack, recharging your wand" + (count > 1 ? "s" : "") );
SpellSprite.show( curUser, SpellSprite.CHARGE ); SpellSprite.show( curUser, SpellSprite.CHARGE );
} else {
GLog.i( "a surge of energy courses through your pack, but nothing happens" );
}
setKnown(); setKnown();
curUser.spendAndNext( TIME_TO_READ ); curUser.spendAndNext( TIME_TO_READ );
@ -56,7 +57,7 @@ public class ScrollOfRecharging extends Scroll {
public String desc() { public String desc() {
return return
"The raw magical power bound up in this parchment will, when released, " + "The raw magical power bound up in this parchment will, when released, " +
"recharge all of the reader's wands to full power."; "charge up all the users wands over time.";
} }
public static void charge( Hero hero ) { public static void charge( Hero hero ) {
@ -67,4 +68,28 @@ public class ScrollOfRecharging extends Scroll {
public int price() { public int price() {
return isKnown() ? 40 * quantity : super.price(); return isKnown() ? 40 * quantity : super.price();
} }
public static class Recharging extends FlavourBuff {
@Override
public int icon() {
return BuffIndicator.CHARGE;
}
@Override
public String toString() {
return "Recharging";
}
//want to process partial turns for this buff, and not count it when it's expiring.
//firstly, if this buff has half a turn left, should give out half the benefit.
//secondly, recall that buffs execute in random order, so this can cause a problem where we can't simply check
//if this buff is still attached, must instead directly check its remaining time, and act accordingly.
//otherwise this causes inconsistent behaviour where this may detach before, or after, a wand charger acts.
public float remainder() {
return Math.min( 1f, this.cooldown());
}
}
} }

View File

@ -19,6 +19,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.wands;
import java.util.ArrayList; import java.util.ArrayList;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
@ -61,7 +62,7 @@ public abstract class Wand extends KindOfWeapon {
public int maxCharges = initialCharges(); public int maxCharges = initialCharges();
public int curCharges = maxCharges; public int curCharges = maxCharges;
private float partialCharge = 0f; protected float partialCharge = 0f;
protected Charger charger; protected Charger charger;
@ -395,6 +396,8 @@ public abstract class Wand extends KindOfWeapon {
private static final float SCALING_CHARGE_ADDITION = 40f; private static final float SCALING_CHARGE_ADDITION = 40f;
private static final float NORMAL_SCALE_FACTOR = 0.85f; private static final float NORMAL_SCALE_FACTOR = 0.85f;
private static final float CHARGE_BUFF_BONUS = 0.25f;
float scalingFactor = NORMAL_SCALE_FACTOR; float scalingFactor = NORMAL_SCALE_FACTOR;
@Override @Override
@ -427,6 +430,11 @@ public abstract class Wand extends KindOfWeapon {
+ (SCALING_CHARGE_ADDITION * Math.pow(scalingFactor, missingCharges))); + (SCALING_CHARGE_ADDITION * Math.pow(scalingFactor, missingCharges)));
partialCharge += 1f/turnsToCharge; partialCharge += 1f/turnsToCharge;
ScrollOfRecharging.Recharging bonus = target.buff(ScrollOfRecharging.Recharging.class);
if (bonus != null && bonus.remainder() > 0f){
partialCharge += CHARGE_BUFF_BONUS * bonus.remainder();
}
} }
private void setScaleFactor(float value){ private void setScaleFactor(float value){

View File

@ -67,6 +67,7 @@ public class BuffIndicator extends Component {
public static final int THORNS = 31; public static final int THORNS = 31;
public static final int FORESIGHT = 32; public static final int FORESIGHT = 32;
public static final int VERTIGO = 33; public static final int VERTIGO = 33;
public static final int CHARGE = 34;
public static final int SIZE = 7; public static final int SIZE = 7;