v2.1.4: improved aiming logic for elemental blast

This commit is contained in:
Evan Debenham
2023-07-01 16:39:58 -04:00
committed by Evan Debenham
parent b0c29ec809
commit 8257991f2b
@@ -128,12 +128,23 @@ public class ElementalBlast extends ArmorAbility {
@Override @Override
protected void activate(ClassArmor armor, Hero hero, Integer target) { protected void activate(ClassArmor armor, Hero hero, Integer target) {
Ballistica aim; Ballistica aim;
//Basically the direction of the aim only matters if it goes outside the map //The direction of the aim only matters if it goes outside the map
//So we just ensure it won't do that. //So we try to aim in the cardinal direction that has the most space
if (hero.pos % Dungeon.level.width() > 10){ int x = hero.pos % Dungeon.level.width();
aim = new Ballistica(hero.pos, hero.pos - 1, Ballistica.WONT_STOP); int y = hero.pos / Dungeon.level.width();
if (Math.max(x, Dungeon.level.width()-x) >= Math.max(y, Dungeon.level.height()-y)){
if (x > Dungeon.level.width()/2){
aim = new Ballistica(hero.pos, hero.pos - 1, Ballistica.WONT_STOP);
} else {
aim = new Ballistica(hero.pos, hero.pos + 1, Ballistica.WONT_STOP);
}
} else { } else {
aim = new Ballistica(hero.pos, hero.pos + 1, Ballistica.WONT_STOP); if (y > Dungeon.level.height()/2){
aim = new Ballistica(hero.pos, hero.pos - Dungeon.level.width(), Ballistica.WONT_STOP);
} else {
aim = new Ballistica(hero.pos, hero.pos + Dungeon.level.width(), Ballistica.WONT_STOP);
}
} }
Class<? extends Wand> wandCls = null; Class<? extends Wand> wandCls = null;
@@ -183,7 +194,7 @@ public class ElementalBlast extends ArmorAbility {
((MagicMissile)hero.sprite.parent.recycle( MagicMissile.class )).reset( ((MagicMissile)hero.sprite.parent.recycle( MagicMissile.class )).reset(
effectTypes.get(wandCls), effectTypes.get(wandCls),
hero.sprite, hero.sprite,
aim.path.get(aoeSize / 2), aim.path.get(Math.min(aoeSize / 2, aim.path.size()-1)),
new Callback() { new Callback() {
@Override @Override
public void call() { public void call() {