v2.0.0: the rapier can now lunge out of the hero's FOV
This commit is contained in:
+14
-4
@@ -72,22 +72,25 @@ public class Rapier extends MeleeWeapon {
|
||||
}
|
||||
|
||||
Char enemy = Actor.findChar(target);
|
||||
if (enemy == null || enemy == hero || hero.isCharmedBy(enemy) || !Dungeon.level.heroFOV[target]){
|
||||
//duelist can lunge out of her FOV, but this wastes the ability instead of cancelling if there is no target
|
||||
if (Dungeon.level.heroFOV[target]) {
|
||||
if (enemy == null || enemy == hero || hero.isCharmedBy(enemy)) {
|
||||
GLog.w(Messages.get(this, "ability_no_target"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Dungeon.level.distance(hero.pos, enemy.pos) != 2){
|
||||
if (Dungeon.level.distance(hero.pos, target) != 2){
|
||||
GLog.w(Messages.get(this, "ability_bad_position"));
|
||||
return;
|
||||
}
|
||||
|
||||
int lungeCell = -1;
|
||||
for (int i : PathFinder.NEIGHBOURS8){
|
||||
if (Dungeon.level.adjacent(hero.pos + i, enemy.pos)
|
||||
if (Dungeon.level.adjacent(hero.pos + i, target)
|
||||
&& 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)){
|
||||
if (lungeCell == -1 || Dungeon.level.trueDistance(hero.pos + i, target) < Dungeon.level.trueDistance(lungeCell, target)){
|
||||
lungeCell = hero.pos + i;
|
||||
}
|
||||
}
|
||||
@@ -110,6 +113,7 @@ public class Rapier extends MeleeWeapon {
|
||||
hero.pos = dest;
|
||||
Dungeon.level.occupyCell(hero);
|
||||
|
||||
if (enemy != null) {
|
||||
hero.sprite.attack(enemy.pos, new Callback() {
|
||||
@Override
|
||||
public void call() {
|
||||
@@ -127,6 +131,12 @@ public class Rapier extends MeleeWeapon {
|
||||
afterAbilityUsed(hero);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
beforeAbilityUsed(hero);
|
||||
GLog.w(Messages.get(Rapier.class, "ability_no_target"));
|
||||
hero.spendAndNext(hero.speed());
|
||||
afterAbilityUsed(hero);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user