v2.0.0: implemented the rapier's duelist ability
This commit is contained in:
@@ -1580,7 +1580,10 @@ items.weapon.melee.quarterstaff.desc=A staff of hardwood, its ends are shod with
|
||||
items.weapon.melee.rapier.name=rapier
|
||||
items.weapon.melee.rapier.stats_desc=This weapon blocks 0-1 damage.
|
||||
items.weapon.melee.rapier.ability_name=lunge
|
||||
items.weapon.melee.rapier.ability_desc=The duelist can _lunge_ with a rapier at an enemy 1 tile away. This moves into the enemy, deals +33% damage, and is guaranteed to hit.
|
||||
items.weapon.melee.rapier.ability_desc=The duelist can _lunge_ with a rapier at an enemy 1 tile away. This moves toward the enemy, deals +67% damage, and is guaranteed to hit.
|
||||
items.weapon.melee.rapier.no_target=There is no target at that location.
|
||||
items.weapon.melee.rapier.bad_distance=The target must be 1 tile away.
|
||||
items.weapon.melee.rapier.cant_reach=You cannot reach that target.
|
||||
items.weapon.melee.rapier.desc=A slim straight sword that offers some protection in exchange for less slashing power.
|
||||
|
||||
items.weapon.melee.roundshield.name=round shield
|
||||
|
||||
@@ -86,10 +86,10 @@ public class MeleeWeapon extends Weapon {
|
||||
GLog.w(Messages.get(this, "ability_equip"));
|
||||
} else if (Buff.affect(hero, Charger.class).charges < abilityChargeUse()) {
|
||||
GLog.w(Messages.get(this, "ability_charge"));
|
||||
usesTargeting = false;
|
||||
} else {
|
||||
|
||||
if (targetingPrompt() == null){
|
||||
Buff.affect(hero, Charger.class).charges -= abilityChargeUse();
|
||||
duelistAbility(hero, hero.pos);
|
||||
updateQuickslot();
|
||||
} else {
|
||||
@@ -98,7 +98,6 @@ public class MeleeWeapon extends Weapon {
|
||||
@Override
|
||||
public void onSelect(Integer cell) {
|
||||
if (cell != null) {
|
||||
Buff.affect(hero, Charger.class).charges -= abilityChargeUse();
|
||||
duelistAbility(hero, cell);
|
||||
updateQuickslot();
|
||||
}
|
||||
@@ -126,6 +125,11 @@ public class MeleeWeapon extends Weapon {
|
||||
//TODO make abstract
|
||||
protected void duelistAbility( Hero hero, Integer target ){}
|
||||
|
||||
protected void onAbilityUsed( Hero hero ){
|
||||
Buff.affect(hero, Charger.class).charges -= abilityChargeUse();
|
||||
updateQuickslot();
|
||||
}
|
||||
|
||||
public int abilityChargeUse(){
|
||||
return 1; //TODO
|
||||
}
|
||||
|
||||
@@ -22,9 +22,16 @@
|
||||
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.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 com.watabou.utils.PathFinder;
|
||||
|
||||
public class Rapier extends MeleeWeapon {
|
||||
|
||||
@@ -55,4 +62,62 @@ public class Rapier extends MeleeWeapon {
|
||||
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){
|
||||
GLog.w(Messages.get(this, "no_target"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Dungeon.level.distance(hero.pos, enemy.pos) != 2){
|
||||
GLog.w(Messages.get(this, "bad_distance"));
|
||||
return;
|
||||
}
|
||||
|
||||
int lungeCell = -1;
|
||||
for (int i : PathFinder.NEIGHBOURS8){
|
||||
if (Dungeon.level.adjacent(hero.pos + i, enemy.pos)
|
||||
&& Actor.findChar(hero.pos+i) == null
|
||||
&& Dungeon.level.passable[hero.pos+i]){
|
||||
if (lungeCell == -1 || Dungeon.level.trueDistance(hero.pos + i, enemy.pos) < Dungeon.level.trueDistance(lungeCell, enemy.pos)){
|
||||
lungeCell = hero.pos + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lungeCell == -1){
|
||||
GLog.w(Messages.get(this, "cant_reach"));
|
||||
return;
|
||||
}
|
||||
|
||||
final int dest = lungeCell;
|
||||
hero.busy();
|
||||
Sample.INSTANCE.play(Assets.Sounds.MISS);
|
||||
hero.sprite.jump(hero.pos, dest, 0, 0.1f, new Callback() {
|
||||
@Override
|
||||
public void call() {
|
||||
hero.pos = dest;
|
||||
Dungeon.level.occupyCell(hero);
|
||||
|
||||
hero.sprite.attack(enemy.pos, new Callback() {
|
||||
@Override
|
||||
public void call() {
|
||||
//+3+lvl damage, equivalent to +67% damage, but more consistent
|
||||
hero.attack(enemy, 1f, 3 + level(), Char.INFINITE_ACCURACY);
|
||||
onAbilityUsed(hero);
|
||||
Sample.INSTANCE.play(Assets.Sounds.HIT_STRONG);
|
||||
hero.spendAndNext(hero.attackDelay());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
super.duelistAbility(hero, target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,10 +286,10 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
|
||||
|
||||
public void jump( int from, int to, Callback callback ) {
|
||||
float distance = Math.max( 1f, Dungeon.level.trueDistance( from, to ));
|
||||
jump( from, to, callback, distance * 2, distance * 0.1f );
|
||||
jump( from, to, distance * 2, distance * 0.1f, callback );
|
||||
}
|
||||
|
||||
public void jump( int from, int to, Callback callback, float height, float duration ) {
|
||||
public void jump( int from, int to, float height, float duration, Callback callback ) {
|
||||
jumpCallback = callback;
|
||||
|
||||
jumpTweener = new JumpTweener( this, worldToCamera( to ), height, duration );
|
||||
|
||||
@@ -115,7 +115,7 @@ public abstract class FistSprite extends MobSprite {
|
||||
public void attack( int cell ) {
|
||||
super.attack( cell );
|
||||
|
||||
jump(ch.pos, ch.pos, null, 9, SLAM_TIME );
|
||||
jump(ch.pos, ch.pos, 9, SLAM_TIME, null );
|
||||
}
|
||||
|
||||
//different bolt, so overrides zap
|
||||
|
||||
@@ -119,8 +119,8 @@ public class HeroSprite extends CharSprite {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jump( int from, int to, Callback callback ) {
|
||||
super.jump( from, to, callback );
|
||||
public void jump( int from, int to, float height, float duration, Callback callback ) {
|
||||
super.jump( from, to, height, duration, callback );
|
||||
play( fly );
|
||||
}
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ public class RipperSprite extends MobSprite {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jump(int from, int to, Callback callback) {
|
||||
super.jump(from, to, callback);
|
||||
public void jump( int from, int to, float height, float duration, Callback callback ) {
|
||||
super.jump( from, to, height, duration, callback );
|
||||
play( leap );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user