v2.0.0: implemented a weapon ability for the whip

This commit is contained in:
Evan Debenham
2022-12-06 13:19:10 -05:00
parent e5bd7ab0ba
commit 8684b972c9
2 changed files with 46 additions and 0 deletions

View File

@@ -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

View File

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