From d6c10725f07ee3e0ea79931c742944516ae998e6 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 22 Nov 2022 17:35:42 -0500 Subject: [PATCH] v2.0.0: added a duelist ability for the spear --- .../assets/messages/items/items.properties | 2 + .../items/weapon/melee/Rapier.java | 2 - .../items/weapon/melee/Spear.java | 56 +++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/core/src/main/assets/messages/items/items.properties b/core/src/main/assets/messages/items/items.properties index 92d1b5156..6959026c8 100644 --- a/core/src/main/assets/messages/items/items.properties +++ b/core/src/main/assets/messages/items/items.properties @@ -1604,6 +1604,8 @@ items.weapon.melee.scimitar.desc=A thick curved blade. Its shape allows for fast items.weapon.melee.spear.name=spear items.weapon.melee.spear.stats_desc=This is a rather slow weapon.\nThis weapon has extra reach. +items.weapon.melee.spear.ability_name=spike +items.weapon.melee.spear.ability_desc=The duelist can use the tip of a spear to _spike_ an enemy that is in range but not adjacent. This deals -25% damage, but knocks the enemy back and is guaranteed to hit. items.weapon.melee.spear.desc=A slender wooden rod tipped with sharpened iron. items.weapon.melee.sword.name=sword diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Rapier.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Rapier.java index ea15b9336..5433b0075 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Rapier.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Rapier.java @@ -117,7 +117,5 @@ public class Rapier extends MeleeWeapon { }); } }); - - super.duelistAbility(hero, target); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Spear.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Spear.java index e672cf0dc..43fe930b8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Spear.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Spear.java @@ -22,7 +22,20 @@ 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.Vertigo; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent; +import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave; +import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; +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; public class Spear extends MeleeWeapon { @@ -42,4 +55,47 @@ public class Spear extends MeleeWeapon { lvl*Math.round(1.33f*(tier+1)); //+4 per level, up from +3 } + @Override + public String targetingPrompt() { + return Messages.get(this, "prompt"); + } + + @Override + protected void duelistAbility(Hero hero, Integer target) { + if (target == null) { + return; + } + + Char enemy = Actor.findChar(target); + if (enemy == null || enemy == hero || hero.isCharmedBy(enemy) || !Dungeon.level.heroFOV[target]) { + GLog.w(Messages.get(this, "ability_no_target")); + return; + } + + if (!hero.canAttack(enemy) || Dungeon.level.adjacent(hero.pos, enemy.pos)){ + GLog.w(Messages.get(this, "ability_bad_position")); + return; + } + + hero.sprite.attack(enemy.pos, new Callback() { + @Override + public void call() { + hero.attack(enemy, 0.75f, 0, Char.INFINITE_ACCURACY); + onAbilityUsed(hero); + Sample.INSTANCE.play(Assets.Sounds.HIT_STRONG); + + if (enemy.isAlive()){ + //trace a ballistica to our target (which will also extend past them + Ballistica trajectory = new Ballistica(hero.pos, enemy.pos, Ballistica.STOP_TARGET); + //trim it to just be the part that goes past them + trajectory = new Ballistica(trajectory.collisionPos, trajectory.path.get(trajectory.path.size() - 1), Ballistica.PROJECTILE); + //knock them back along that ballistica + WandOfBlastWave.throwChar(enemy, trajectory, 1, true, false, hero.getClass()); + } + hero.spendAndNext(hero.attackDelay()); + } + }); + + } + }