Skip to content

Commit

Permalink
Wand of Voltage added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Smujb committed Dec 6, 2020
1 parent 5e318f9 commit cb196a6
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 17 deletions.
8 changes: 8 additions & 0 deletions core/src/main/assets/messages/items/items.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,14 @@ items.wands.wand.prompt=Choose a location to zap
items.wands.wand.miscast=Your %s miscasts!
items.wands.wand.backfire=Your %s backfires!


items.wands.wandofvoltage.name=wand of voltage
items.wands.wandofvoltage.staff_name=staff of voltage
items.wands.wandofvoltage.desc=[tba]
items.wands.wandofvoltage.stats_desc=This wand will shoot a bolt of lightning that deals _%1$d-%2$d damage_, inflicting "charge" on the target. Lightning will zap between all charged targets when the wand is used dealing _%3$s%%_ of base damage.
items.wands.wandofvoltage$charged.name=Charged
items.wands.wandofvoltage$charged.desc=The target is charged with electrical energy\n\nTurns remaining: %s

items.wands.wandofdarkness.name=wand of darkness
items.wands.wandofdarkness.staff_name=staff of darkness
items.wands.wandofdarkness.desc=This wand is made of an ancient mossy stone that looks like it has seen better days. This does not prevent it's bolts from causing havoc however.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import com.shatteredpixel.yasd.general.items.scrolls.ScrollOfUpgrade;
import com.shatteredpixel.yasd.general.items.shield.RoundShield;
import com.shatteredpixel.yasd.general.items.wands.WandOfMagicMissile;
import com.shatteredpixel.yasd.general.items.wands.WandOfVoltage;
import com.shatteredpixel.yasd.general.items.weapon.SpiritBow;
import com.shatteredpixel.yasd.general.items.weapon.melee.Dagger;
import com.shatteredpixel.yasd.general.items.weapon.melee.Glove;
Expand Down Expand Up @@ -187,6 +188,7 @@ public static void initTest(Hero hero) {
new TomeOfMastery().collect();
new MegaStick().identify().collect();
new DeveloperItem().collect();
new WandOfVoltage().identify().collect();

for (Class<?> itemClass : Generator.Category.WEAPON.classes) {
Item item = (Item) Reflection.newInstance(itemClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
import com.shatteredpixel.yasd.general.items.wands.WandOfRegrowth;
import com.shatteredpixel.yasd.general.items.wands.WandOfThornvines;
import com.shatteredpixel.yasd.general.items.wands.WandOfTransfusion;
import com.shatteredpixel.yasd.general.items.wands.WandOfVoltage;
import com.shatteredpixel.yasd.general.items.wands.WandOfWarding;
import com.shatteredpixel.yasd.general.items.weapon.melee.Axe;
import com.shatteredpixel.yasd.general.items.weapon.melee.ButchersKnife;
Expand Down Expand Up @@ -533,8 +534,10 @@ public static int order( Item item ) {
WandOfThornvines.class,
WandOfPlasmaBolt.class,
WandOfFlow.class,
WandOfDarkness.class};
WAND.probs = new float[]{ 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 4, 3, 3 };
WandOfDarkness.class,
WandOfVoltage.class
};
WAND.probs = new float[]{ 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 4, 3, 2, 3 };

//see generator.randomWeapon
WEAPON.classes = new Class<?>[]{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.shatteredpixel.yasd.general.items.wands;

import com.shatteredpixel.yasd.general.Dungeon;
import com.shatteredpixel.yasd.general.Element;
import com.shatteredpixel.yasd.general.actors.Actor;
import com.shatteredpixel.yasd.general.actors.Char;
import com.shatteredpixel.yasd.general.actors.buffs.Buff;
import com.shatteredpixel.yasd.general.actors.buffs.FlavourBuff;
import com.shatteredpixel.yasd.general.actors.mobs.Mob;
import com.shatteredpixel.yasd.general.items.weapon.melee.MagesStaff;
import com.shatteredpixel.yasd.general.mechanics.Ballistica;
import com.shatteredpixel.yasd.general.messages.Messages;
import com.shatteredpixel.yasd.general.sprites.CharSprite;
import com.shatteredpixel.yasd.general.sprites.ItemSpriteSheet;
import com.shatteredpixel.yasd.general.ui.BuffIndicator;
import com.watabou.noosa.Image;
import com.watabou.utils.Callback;

public class WandOfVoltage extends DamageWand {

{
image = ItemSpriteSheet.Wands.VOLTAGE;

damageMultiplier = 0.75f;

element = Element.SHOCK;
}

private static final float SHOCK_DAMAGE_FACTOR = 0.2f;

@Override
public void onZap(Ballistica attack) {
int pos = attack.collisionPos;
Char target = Actor.findChar(pos);
if (target != null) {
hit(target);
Buff.affect(target, Charged.class, Charged.DURATION);
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
if (mob.buff(Charged.class) != null && mob != target) {
fx(new Ballistica(target.pos, mob.pos, Ballistica.WONT_STOP), new Callback() {
@Override
public void call() {
Char.DamageSrc src = new Char.DamageSrc(Element.SHOCK, WandOfVoltage.this);
mob.damage((int) (damageRoll()*SHOCK_DAMAGE_FACTOR), src);
target.damage((int) (damageRoll()*SHOCK_DAMAGE_FACTOR), src);
}
});
}
}
}
}

@Override
public void onHit(MagesStaff staff, Char attacker, Char defender, int damage) {
Buff.affect(defender, Charged.class, Charged.DURATION*2f);
}

@Override
public String statsDesc() {
if (levelKnown) return Messages.get(this, "stats_desc", min(), max(), (int) (SHOCK_DAMAGE_FACTOR*100));
else return Messages.get(this, "stats_desc", defaultMin(), defaultMax(), (int) (SHOCK_DAMAGE_FACTOR*100));
}

public static class Charged extends FlavourBuff {

{
announced = true;
}

public static final float DURATION = 10f;

@Override
public int icon() {
return BuffIndicator.VERTIGO;
}

@Override
public void tintIcon(Image icon) {
icon.hardlight(0.2f, 0.6f, 1f);
}

@Override
public void fx(boolean on) {
if (on) target.sprite.add( CharSprite.State.CHARGED );
else if (target.invisible == 0) target.sprite.remove( CharSprite.State.CHARGED );
}

@Override
public String toString() {
return Messages.get(this, "name");
}

@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}

@Override
public float iconFadePercent() {
return Math.max(0, (DURATION - visualcooldown()) / DURATION);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import com.shatteredpixel.yasd.general.effects.particles.ShadowParticle;
import com.shatteredpixel.yasd.general.effects.particles.SmokeParticle;
import com.shatteredpixel.yasd.general.effects.particles.SnowParticle;
import com.shatteredpixel.yasd.general.effects.particles.SparkParticle;
import com.shatteredpixel.yasd.general.items.weapon.ranged.MarksmansBow;
import com.shatteredpixel.yasd.general.levels.chapters.sewers.SewerLevel;
import com.shatteredpixel.yasd.general.messages.Messages;
Expand Down Expand Up @@ -97,7 +98,7 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
protected float shadowOffset = 0.25f;

public enum State {
BURNING, LEVITATING, INVISIBLE, PARALYSED, FROZEN, ILLUMINATED, CHILLED, DARKENED, MARKED, HEALING, SHIELDED, POISONED, BLEEDING, WEAKENED, BLESSED, OOZE, VERTIGO, WET, BERSERK, PURITY, ADRENALINE, AMOK
BURNING, LEVITATING, INVISIBLE, PARALYSED, FROZEN, ILLUMINATED, CHILLED, DARKENED, MARKED, HEALING, SHIELDED, POISONED, BLEEDING, WEAKENED, BLESSED, OOZE, VERTIGO, WET, BERSERK, PURITY, ADRENALINE, AMOK, CHARGED
}

protected Animation idle;
Expand Down Expand Up @@ -126,6 +127,7 @@ public enum State {
protected Emitter wet;
protected Emitter amok;
protected Emitter burningSmoke;
protected Emitter charged;

protected IceBlock iceBlock;
protected DarkBlock darkBlock;
Expand Down Expand Up @@ -394,43 +396,43 @@ public synchronized void add( State state ) {
switch (state) {
case BURNING:
burning = emitter();
burning.pour( FlameParticle.FACTORY, 0.06f );
burning.pour(FlameParticle.FACTORY, 0.06f);
if (visible) {
Sample.INSTANCE.play( Assets.Sounds.BURNING );
Sample.INSTANCE.play(Assets.Sounds.BURNING);
}
burningSmoke = emitter();
burningSmoke.pour( SmokeParticle.FACTORY, 0.2f );
burningSmoke.pour(SmokeParticle.FACTORY, 0.2f);
break;
case LEVITATING:
levitation = emitter();
levitation.pour( Speck.factory( Speck.JET ), 0.02f );
levitation.pour(Speck.factory(Speck.JET), 0.02f);
break;
case INVISIBLE:
if (invisible != null) {
invisible.killAndErase();
}
invisible = new AlphaTweener( this, 0.4f, 0.4f );
if (parent != null){
invisible = new AlphaTweener(this, 0.4f, 0.4f);
if (parent != null) {
parent.add(invisible);
} else
alpha( 0.4f );
alpha(0.4f);
break;
case PARALYSED:
paused = true;
break;
case FROZEN:
iceBlock = IceBlock.freeze( this );
iceBlock = IceBlock.freeze(this);
paused = true;
break;
case ILLUMINATED:
GameScene.effect( light = new TorchHalo( this ) );
GameScene.effect(light = new TorchHalo(this));
break;
case CHILLED:
chilled = emitter();
chilled.pour(SnowParticle.FACTORY, 0.1f);
break;
case DARKENED:
darkBlock = DarkBlock.darken( this );
darkBlock = DarkBlock.darken(this);
break;
case MARKED:
marked = emitter();
Expand All @@ -441,19 +443,19 @@ public synchronized void add( State state ) {
healing.pour(Speck.factory(Speck.HEALING), 0.5f);
break;
case SHIELDED:
GameScene.effect( shield = new ShieldHalo( this ));
GameScene.effect(shield = new ShieldHalo(this));
break;
case POISONED:
poisoned = emitter();
poisoned.pour(Speck.factory(Speck.BUBBLE_PURPLE), 0.5f);
break;
case WEAKENED:
weakened = emitter();
weakened.pour(GooSprite.GooParticle.FACTORY, 0.1f );
weakened.pour(GooSprite.GooParticle.FACTORY, 0.1f);
break;
case BLEEDING:
bleeding = emitter();
bleeding.pour( BloodParticle.FACTORY, 0.1f );
bleeding.pour(BloodParticle.FACTORY, 0.1f);
break;
case WET:
wet = emitter();
Expand All @@ -475,7 +477,7 @@ public synchronized void add( State state ) {
redBlock = RedBlock.darken(this);
break;
case PURITY:
GameScene.effect( redShield = new RedShieldHalo( this ));
GameScene.effect(redShield = new RedShieldHalo(this));
break;
case ADRENALINE:
yellowBlock = YellowBlock.darken(this);
Expand All @@ -484,6 +486,10 @@ public synchronized void add( State state ) {
amok = emitter();
amok.pour(Speck.factory(Speck.ANGRY), 0.5f);
break;
case CHARGED:
charged = emitter();
charged.pour(SparkParticle.FACTORY, 0.1f);
break;
}
}

Expand Down Expand Up @@ -622,6 +628,12 @@ public synchronized void remove( State state ) {
amok = null;
}
break;
case CHARGED:
if (charged != null) {
charged.on = false;
charged = null;
}
break;
}
}

Expand Down

0 comments on commit cb196a6

Please sign in to comment.