From 1d98252ebffd4c3d2b3a54f3596ff1b9167f8100 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 27 Jul 2019 18:06:30 -0400 Subject: [PATCH] v0.7.4a: Adjustments to wand of warding: - Wand can now reach through walls, but only to visible locations - Wand now fizzles if it is at ward capacity --- .../items/wands/Wand.java | 4 +- .../items/wands/WandOfWarding.java | 63 ++++++++++++------- .../messages/actors/actors.properties | 2 +- .../messages/items/items.properties | 4 +- 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java index 7b75e399d..a738c0edc 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java @@ -111,7 +111,7 @@ public abstract class Wand extends Item { public abstract void onHit( MagesStaff staff, Char attacker, Char defender, int damage); - public boolean tryToZap( Hero owner ){ + public boolean tryToZap( Hero owner, int target ){ if (owner.buff(MagicImmune.class) != null){ GLog.w( Messages.get(this, "no_magic") ); @@ -440,7 +440,7 @@ public abstract class Wand extends Item { else QuickSlotButton.target(Actor.findChar(cell)); - if (curWand.tryToZap(curUser)) { + if (curWand.tryToZap(curUser, target)) { curUser.busy(); Invisibility.dispel(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfWarding.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfWarding.java index 211398d7d..766a45ff1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfWarding.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfWarding.java @@ -15,7 +15,6 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.sprites.WardSprite; -import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; import com.watabou.noosa.audio.Sample; @@ -28,14 +27,16 @@ import com.watabou.utils.Random; public class WandOfWarding extends Wand { { - collisionProperties = Ballistica.STOP_TARGET | Ballistica.STOP_TERRAIN; + collisionProperties = Ballistica.STOP_TARGET; image = ItemSpriteSheet.WAND_WARDING; } - + + private boolean wardAvailable = true; + @Override - protected void onZap(Ballistica bolt) { - + public boolean tryToZap(Hero owner, int target) { + int currentWardEnergy = 0; for (Char ch : Actor.chars()){ if (ch instanceof Ward){ @@ -51,34 +52,50 @@ public class WandOfWarding extends Wand { } } } - + + wardAvailable = (currentWardEnergy < maxWardEnergy); + + Char ch = Actor.findChar(target); + if (ch instanceof Ward){ + if (!wardAvailable && ((Ward) ch).tier <= 3){ + GLog.w( Messages.get(this, "no_more_wards")); + return false; + } + } else { + if ((currentWardEnergy + 2) > maxWardEnergy){ + GLog.w( Messages.get(this, "no_more_wards")); + return false; + } + } + + return super.tryToZap(owner, target); + } + + @Override + protected void onZap(Ballistica bolt) { + Char ch = Actor.findChar(bolt.collisionPos); - if (ch != null){ + if (!curUser.fieldOfView[bolt.collisionPos]){ + GLog.w( Messages.get(this, "bad_location")); + + } else if (ch != null){ if (ch instanceof Ward){ - if (currentWardEnergy < maxWardEnergy) { + if (wardAvailable) { ((Ward) ch).upgrade(level()); } else { - if (((Ward) ch).tier <= 3){ - GLog.w( Messages.get(this, "no_more_wards")); - } else { - ((Ward) ch).wandHeal( level() ); - } + ((Ward) ch).wandHeal( level() ); } ch.sprite.emitter().burst(MagicMissile.WardParticle.UP, ((Ward) ch).tier); } else { GLog.w( Messages.get(this, "bad_location")); } } else if (canPlaceWard(bolt.collisionPos)){ - if ((currentWardEnergy + 2) <= maxWardEnergy) { - Ward ward = new Ward(); - ward.pos = bolt.collisionPos; - ward.wandLevel = level(); - GameScene.add(ward, 1f); - Dungeon.level.press(ward.pos, ward); - ward.sprite.emitter().burst(MagicMissile.WardParticle.UP, ward.tier); - } else { - GLog.w( Messages.get(this, "no_more_wards")); - } + Ward ward = new Ward(); + ward.pos = bolt.collisionPos; + ward.wandLevel = level(); + GameScene.add(ward, 1f); + Dungeon.level.press(ward.pos, ward); + ward.sprite.emitter().burst(MagicMissile.WardParticle.UP, ward.tier); } else { GLog.w( Messages.get(this, "bad_location")); } diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties index 50019826b..bfa085573 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties @@ -98,7 +98,7 @@ actors.buffs.burning.desc=Few things are more distressing than being engulfed in actors.buffs.charm.name=Charmed actors.buffs.charm.heromsg=You are charmed! -actors.buffs.charm.desc=A charm is manipulative magic that can make enemies temporarily adore eachother.\n\nCharacters affected by charm are unable to directly attack the enemy they are charmed by. Attacking other targets is still possible however. The shock of pain will lessen the duration of charm.\n\nTurns of charm remaining: %s. +actors.buffs.charm.desc=A charm is manipulative magic that can make enemies temporarily adore each other.\n\nCharacters affected by charm are unable to directly attack the enemy they are charmed by. Attacking other targets is still possible however. The shock of pain will lessen the duration of charm.\n\nTurns of charm remaining: %s. actors.buffs.chill.name=Chilled actors.buffs.chill.freezes=%s freezes! diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties index 6d39c2209..1c465cea6 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties @@ -1218,9 +1218,9 @@ items.wands.wandoftransfusion.stats_desc=When used on allies, this wand saps som items.wands.wandofwarding.name=wand of warding items.wands.wandofwarding.staff_name=staff of warding items.wands.wandofwarding.no_more_wards=Your wand can't sustain any more wards. -items.wands.wandofwarding.bad_location=There isn't enough space to place a ward there. +items.wands.wandofwarding.bad_location=You can't place a ward there. items.wands.wandofwarding.desc=This short metal wand has a bright purple gem floating above its tip. -items.wands.wandofwarding.stats_desc=Rather than directly damaging an enemy, this wand will summon stationary wards and sentries. Note that wards cannot be placed next to each other, and this wand can only sustain _%d energy_ worth of wards at a time. +items.wands.wandofwarding.stats_desc=Rather than directly damaging an enemy, this wand will summon stationary wards and sentries. Wards can be summoned anywhere you have vision, even through walls, but cannot be placed next to each other. This wand can sustain _%d energy_ worth of wards at a time. items.wands.wandofwarding$ward.name_1=lesser ward items.wands.wandofwarding$ward.desc_1=This basic ward will automatically zap any enemy which comes into its range of vision, dealing _%1$d-%2$d damage._\n\nZapping this ward with your wand of warding will upgrade it.\n\nThis ward will only zap a single time before dissipating.\n\nYour wand of warding is using _2 energy_ to sustain this ward. items.wands.wandofwarding$ward.name_2=ward