v3.3.0: tele grab is now instant if the collected items are also instant

This commit is contained in:
Evan Debenham
2025-11-19 12:12:40 -05:00
parent b975708a84
commit 47ddb75f44
2 changed files with 28 additions and 5 deletions
@@ -56,6 +56,10 @@ public abstract class TargetedSpell extends Spell {
callback); callback);
Sample.INSTANCE.play( Assets.Sounds.ZAP ); Sample.INSTANCE.play( Assets.Sounds.ZAP );
} }
protected float timeToCast(){
return Actor.TICK;
}
private static CellSelector.Listener targeter = new CellSelector.Listener(){ private static CellSelector.Listener targeter = new CellSelector.Listener(){
@@ -92,7 +96,7 @@ public abstract class TargetedSpell extends Spell {
curSpell.detach( curUser.belongings.backpack ); curSpell.detach( curUser.belongings.backpack );
Invisibility.dispel(); Invisibility.dispel();
curSpell.updateQuickslot(); curSpell.updateQuickslot();
curUser.spendAndNext( 1f ); curUser.spendAndNext( curSpell.timeToCast() );
Catalog.countUse(curSpell.getClass()); Catalog.countUse(curSpell.getClass());
if (Random.Float() < curSpell.talentChance){ if (Random.Float() < curSpell.talentChance){
Talent.onScrollUsed(curUser, curUser.pos, curSpell.talentFactor, curSpell.getClass()); Talent.onScrollUsed(curUser, curUser.pos, curSpell.talentFactor, curSpell.getClass());
@@ -57,6 +57,11 @@ public class TelekineticGrab extends TargetedSpell {
Sample.INSTANCE.play( Assets.Sounds.ZAP ); Sample.INSTANCE.play( Assets.Sounds.ZAP );
} }
@Override
protected float timeToCast() {
return 0;
}
@Override @Override
protected void affectTarget(Ballistica bolt, Hero hero) { protected void affectTarget(Ballistica bolt, Hero hero) {
Char ch = Actor.findChar(bolt.collisionPos); Char ch = Actor.findChar(bolt.collisionPos);
@@ -69,29 +74,37 @@ public class TelekineticGrab extends TargetedSpell {
} }
} }
float totalpickupTime = 0;
if (ch != null && ch.buff(PinCushion.class) != null){ if (ch != null && ch.buff(PinCushion.class) != null){
while (ch.buff(PinCushion.class) != null) { while (ch.buff(PinCushion.class) != null) {
Item item = ch.buff(PinCushion.class).grabOne(); Item item = ch.buff(PinCushion.class).grabOne();
if (item.doPickUp(hero, ch.pos)) { if (item.doPickUp(hero, ch.pos)) {
hero.spend(-item.pickupDelay()); //casting the spell already takes a turn totalpickupTime += item.pickupDelay();
GLog.i( Messages.capitalize(Messages.get(hero, "you_now_have", item.name())) ); GLog.i( Messages.capitalize(Messages.get(hero, "you_now_have", item.name())) );
} else { } else {
GLog.w(Messages.get(this, "cant_grab")); GLog.w(Messages.get(this, "cant_grab"));
Dungeon.level.drop(item, ch.pos).sprite.drop(); Dungeon.level.drop(item, ch.pos).sprite.drop();
return; break;
} }
} }
//casting the spell takes at most 1 turn
if (totalpickupTime > 1){
hero.spend(-(totalpickupTime-1));
}
} else if (Dungeon.level.heaps.get(bolt.collisionPos) != null){ } else if (Dungeon.level.heaps.get(bolt.collisionPos) != null){
Heap h = Dungeon.level.heaps.get(bolt.collisionPos); Heap h = Dungeon.level.heaps.get(bolt.collisionPos);
if (h.type != Heap.Type.HEAP){ if (h.type != Heap.Type.HEAP){
GLog.w(Messages.get(this, "cant_grab")); GLog.w(Messages.get(this, "cant_grab"));
hero.spend(Actor.TICK);
h.sprite.drop(); h.sprite.drop();
return; return;
} }
@@ -100,18 +113,24 @@ public class TelekineticGrab extends TargetedSpell {
Item item = h.peek(); Item item = h.peek();
if (item.doPickUp(hero, h.pos)) { if (item.doPickUp(hero, h.pos)) {
h.pickUp(); h.pickUp();
hero.spend(-item.pickupDelay()); //casting the spell already takes a turn totalpickupTime += item.pickupDelay();
GLog.i( Messages.capitalize(Messages.get(hero, "you_now_have", item.name())) ); GLog.i( Messages.capitalize(Messages.get(hero, "you_now_have", item.name())) );
} else { } else {
GLog.w(Messages.get(this, "cant_grab")); GLog.w(Messages.get(this, "cant_grab"));
h.sprite.drop(); h.sprite.drop();
return; break;
} }
} }
//casting the spell takes at most 1 turn
if (totalpickupTime > 1){
hero.spend(-(totalpickupTime-1));
}
} else { } else {
GLog.w(Messages.get(this, "no_target")); GLog.w(Messages.get(this, "no_target"));
hero.spend(Actor.TICK);
} }
} }