From 8684b972c970d06bd7849ad5ba42724f3825ae3d Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 6 Dec 2022 13:19:10 -0500 Subject: [PATCH] v2.0.0: implemented a weapon ability for the whip --- .../assets/messages/items/items.properties | 2 + .../items/weapon/melee/Whip.java | 44 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/core/src/main/assets/messages/items/items.properties b/core/src/main/assets/messages/items/items.properties index bd8fbf76c..ee6479bd0 100644 --- a/core/src/main/assets/messages/items/items.properties +++ b/core/src/main/assets/messages/items/items.properties @@ -1654,6 +1654,8 @@ items.weapon.melee.warhammer.desc=Few creatures can withstand the crushing blow items.weapon.melee.whip.name=whip items.weapon.melee.whip.stats_desc=This weapon has tremendous reach. +items.weapon.melee.whip.ability_name=lash +items.weapon.melee.whip.ability_desc=The Duelist can _lash_ all enemies around her with a whip. This ability performs a normal attack against all enemies currently within attack range. items.weapon.melee.whip.desc=While the barbed length of rope at the end of this weapon deals poor damage, its reach cannot be matched. items.weapon.melee.wornshortsword.name=worn shortsword diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Whip.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Whip.java index 1eab69593..1d2723c11 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Whip.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Whip.java @@ -22,7 +22,19 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee; 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.Vulnerable; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; +import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; +import com.watabou.noosa.audio.Sample; +import com.watabou.utils.Callback; + +import java.util.ArrayList; public class Whip extends MeleeWeapon { @@ -41,4 +53,36 @@ public class Whip extends MeleeWeapon { lvl*(tier); //+3 per level, down from +4 } + @Override + protected void duelistAbility(Hero hero, Integer target) { + + ArrayList targets = new ArrayList<>(); + + for (Char ch : Actor.chars()){ + if (ch.alignment == Char.Alignment.ENEMY + && !hero.isCharmedBy(ch) + && Dungeon.level.heroFOV[ch.pos] + && hero.canAttack(ch)){ + targets.add(ch); + } + } + + if (targets.isEmpty()) { + GLog.w(Messages.get(this, "ability_no_target")); + return; + } + + throwSound(); + hero.sprite.attack(hero.pos, new Callback() { + @Override + public void call() { + for (Char ch : targets) { + hero.attack(ch); + } + hero.spendAndNext(hero.attackDelay()); + onAbilityUsed(hero); + } + }); + } + }