diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/BlessSpell.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/BlessSpell.java index 72400a4ab..1bb35e55e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/BlessSpell.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/BlessSpell.java @@ -49,8 +49,8 @@ public class BlessSpell extends TargetedClericSpell { } @Override - public boolean usesTargeting() { - return false; //targeting behaviour is often wrong + public int targetingFlags(){ + return -1; //auto-targeting behaviour is often wrong, so we don't use it } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/ClericSpell.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/ClericSpell.java index 2f8edf325..ec1ffdb89 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/ClericSpell.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/ClericSpell.java @@ -63,6 +63,10 @@ public abstract class ClericSpell { return false; } + public int targetingFlags(){ + return -1; //-1 for no targeting + } + public int icon(){ return HeroIcon.NONE; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/Flash.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/Flash.java index c5a7930b9..2a0cb2a18 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/Flash.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/Flash.java @@ -54,6 +54,11 @@ public class Flash extends TargetedClericSpell { return super.canCast(hero) && hero.buff(AscendedForm.AscendBuff.class) != null; } + @Override + public int targetingFlags() { + return -1; //targets an empty cell, not an enemy + } + @Override protected void onTargetSelected(HolyTome tome, Hero hero, Integer target) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/GuidingLight.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/GuidingLight.java index 283354f89..bab80e999 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/GuidingLight.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/GuidingLight.java @@ -58,7 +58,7 @@ public class GuidingLight extends TargetedClericSpell { return; } - Ballistica aim = new Ballistica(hero.pos, target, Ballistica.MAGIC_BOLT); + Ballistica aim = new Ballistica(hero.pos, target, targetingFlags()); if (Actor.findChar( aim.collisionPos ) == hero){ GLog.i( Messages.get(Wand.class, "self_target") ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/HallowedGround.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/HallowedGround.java index 4395f0219..1e3baca62 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/HallowedGround.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/HallowedGround.java @@ -43,6 +43,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShaftParticle; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HolyTome; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; @@ -67,6 +68,11 @@ public class HallowedGround extends TargetedClericSpell { return 2; } + @Override + public int targetingFlags() { + return Ballistica.STOP_TARGET; + } + @Override protected void onTargetSelected(HolyTome tome, Hero hero, Integer target) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/HolyLance.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/HolyLance.java index 1cc5ff915..102de7684 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/HolyLance.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/HolyLance.java @@ -73,13 +73,18 @@ public class HolyLance extends TargetedClericSpell { return 4; } + @Override + public int targetingFlags() { + return Ballistica.PROJECTILE; + } + @Override protected void onTargetSelected(HolyTome tome, Hero hero, Integer target) { if (target == null){ return; } - Ballistica aim = new Ballistica(hero.pos, target, Ballistica.PROJECTILE); + Ballistica aim = new Ballistica(hero.pos, target, targetingFlags()); if (Actor.findChar( aim.collisionPos ) == hero){ GLog.i( Messages.get(Wand.class, "self_target") ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/MnemonicPrayer.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/MnemonicPrayer.java index 304d6b1aa..c731215a1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/MnemonicPrayer.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/MnemonicPrayer.java @@ -52,6 +52,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HolyTome; import com.shatteredpixel.shatteredpixeldungeon.items.potions.elixirs.ElixirOfAquaticRejuvenation; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ScrollOfChallenge; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Kinetic; +import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.plants.Sungrass; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; @@ -68,6 +69,11 @@ public class MnemonicPrayer extends TargetedClericSpell { return HeroIcon.MNEMONIC_PRAYER; } + @Override + public int targetingFlags() { + return Ballistica.STOP_TARGET; + } + @Override @SuppressWarnings("unchecked") protected void onTargetSelected(HolyTome tome, Hero hero, Integer target) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/ShieldOfLight.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/ShieldOfLight.java index 064a44054..52925ebe6 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/ShieldOfLight.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/ShieldOfLight.java @@ -31,6 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HolyTome; +import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.HeroIcon; @@ -47,6 +48,11 @@ public class ShieldOfLight extends TargetedClericSpell { return HeroIcon.SHIELD_OF_LIGHT; } + @Override + public int targetingFlags() { + return Ballistica.STOP_TARGET; + } + @Override protected void onTargetSelected(HolyTome tome, Hero hero, Integer target) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/Sunray.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/Sunray.java index fbcb5e0c9..f6d3da04f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/Sunray.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/Sunray.java @@ -65,7 +65,7 @@ public class Sunray extends TargetedClericSpell { return; } - Ballistica aim = new Ballistica(hero.pos, target, Ballistica.MAGIC_BOLT); + Ballistica aim = new Ballistica(hero.pos, target, targetingFlags()); if (Actor.findChar( aim.collisionPos ) == hero){ GLog.i( Messages.get(Wand.class, "self_target") ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/TargetedClericSpell.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/TargetedClericSpell.java index 7f8ebcef9..f92691db5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/TargetedClericSpell.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/TargetedClericSpell.java @@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.hero.spells; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HolyTome; +import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; @@ -45,8 +46,8 @@ public abstract class TargetedClericSpell extends ClericSpell { } @Override - public boolean usesTargeting() { - return true; + public int targetingFlags(){ + return Ballistica.MAGIC_BOLT; } protected String targetingPrompt(){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HolyTome.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HolyTome.java index dc04e3bf5..f4c37715f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HolyTome.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HolyTome.java @@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfEnergy; import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog; +import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; @@ -95,6 +96,18 @@ public class HolyTome extends Artifact { } } + //used to ensure tome has variable targeting logic for whatever spell is being case + public ClericSpell targetingSpell = null; + + @Override + public int targetingPos(Hero user, int dst) { + if (targetingSpell == null || targetingSpell.targetingFlags() == -1) { + return super.targetingPos(user, dst); + } else { + return new Ballistica( user.pos, dst, targetingSpell.targetingFlags() ).collisionPos; + } + } + @Override public boolean doUnequip(Hero hero, boolean collect, boolean single) { if (super.doUnequip(hero, collect, single)){ @@ -328,9 +341,9 @@ public class HolyTome extends Artifact { return; } - //TODO this is all pretty akward, might be better to just add autotarget functionality to the indicator if (QuickSlotButton.targetingSlot != -1 && Dungeon.quickslot.getItem(QuickSlotButton.targetingSlot) == HolyTome.this) { + targetingSpell = quickSpell; int cell = QuickSlotButton.autoAim(QuickSlotButton.lastTarget, HolyTome.this); if (cell != -1){ @@ -342,7 +355,8 @@ public class HolyTome extends Artifact { } else { quickSpell.onCast(HolyTome.this, Dungeon.hero); - if (quickSpell.usesTargeting() && Dungeon.quickslot.contains(HolyTome.this)){ + if (quickSpell.targetingFlags() != -1 && Dungeon.quickslot.contains(HolyTome.this)){ + targetingSpell = quickSpell; QuickSlotButton.useTargeting(Dungeon.quickslot.getSlot(HolyTome.this)); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndClericSpells.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndClericSpells.java index b37e28398..903d421d8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndClericSpells.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndClericSpells.java @@ -178,8 +178,8 @@ public class WndClericSpells extends Window { } else { spell.onCast(tome, Dungeon.hero); - //TODO, probably need targeting logic here - if (spell.usesTargeting() && Dungeon.quickslot.contains(tome)){ + if (spell.targetingFlags() != -1 && Dungeon.quickslot.contains(tome)){ + tome.targetingSpell = spell; QuickSlotButton.useTargeting(Dungeon.quickslot.getSlot(tome)); } } @@ -215,8 +215,8 @@ public class WndClericSpells extends Window { } else { spell.onCast(tome, Dungeon.hero); - //TODO, probably need targeting logic here - if (spell.usesTargeting() && Dungeon.quickslot.contains(tome)){ + if (spell.targetingFlags() != -1 && Dungeon.quickslot.contains(tome)){ + tome.targetingSpell = spell; QuickSlotButton.useTargeting(Dungeon.quickslot.getSlot(tome)); } }