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

View File

@@ -56,6 +56,10 @@ public abstract class TargetedSpell extends Spell {
callback);
Sample.INSTANCE.play( Assets.Sounds.ZAP );
}
protected float timeToCast(){
return Actor.TICK;
}
private static CellSelector.Listener targeter = new CellSelector.Listener(){
@@ -92,7 +96,7 @@ public abstract class TargetedSpell extends Spell {
curSpell.detach( curUser.belongings.backpack );
Invisibility.dispel();
curSpell.updateQuickslot();
curUser.spendAndNext( 1f );
curUser.spendAndNext( curSpell.timeToCast() );
Catalog.countUse(curSpell.getClass());
if (Random.Float() < curSpell.talentChance){
Talent.onScrollUsed(curUser, curUser.pos, curSpell.talentFactor, curSpell.getClass());

View File

@@ -57,6 +57,11 @@ public class TelekineticGrab extends TargetedSpell {
Sample.INSTANCE.play( Assets.Sounds.ZAP );
}
@Override
protected float timeToCast() {
return 0;
}
@Override
protected void affectTarget(Ballistica bolt, Hero hero) {
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){
while (ch.buff(PinCushion.class) != null) {
Item item = ch.buff(PinCushion.class).grabOne();
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())) );
} else {
GLog.w(Messages.get(this, "cant_grab"));
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){
Heap h = Dungeon.level.heaps.get(bolt.collisionPos);
if (h.type != Heap.Type.HEAP){
GLog.w(Messages.get(this, "cant_grab"));
hero.spend(Actor.TICK);
h.sprite.drop();
return;
}
@@ -100,18 +113,24 @@ public class TelekineticGrab extends TargetedSpell {
Item item = h.peek();
if (item.doPickUp(hero, h.pos)) {
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())) );
} else {
GLog.w(Messages.get(this, "cant_grab"));
h.sprite.drop();
return;
break;
}
}
//casting the spell takes at most 1 turn
if (totalpickupTime > 1){
hero.spend(-(totalpickupTime-1));
}
} else {
GLog.w(Messages.get(this, "no_target"));
hero.spend(Actor.TICK);
}
}