From 055841cadfeb481b3c910af878b62b8dd70f1910 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 29 Aug 2022 23:30:35 -0400 Subject: [PATCH] v1.4.0: telekinetic grab now grabs all possible items when cast --- .../assets/messages/items/items.properties | 2 +- .../items/spells/TelekineticGrab.java | 38 +++++++++++-------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/core/src/main/assets/messages/items/items.properties b/core/src/main/assets/messages/items/items.properties index 931e094d1..4ba8ebc5c 100644 --- a/core/src/main/assets/messages/items/items.properties +++ b/core/src/main/assets/messages/items/items.properties @@ -1147,7 +1147,7 @@ items.spells.targetedspell.inv_title=Infuse an item items.spells.telekineticgrab.name=telekinetic grab items.spells.telekineticgrab.cant_grab=You can't grab that. items.spells.telekineticgrab.no_target=There's nothing to grab there. -items.spells.telekineticgrab.desc=This spell allows the caster to remotely grab any item from the ground, or any thrown weapon that's stuck to an enemy!\n\nIt can't be used to grab items that someone else owns, or to grab containers like chests. +items.spells.telekineticgrab.desc=This spell allows the caster to remotely grab all items at a location, or all thrown weapons stuck to an enemy!\n\nIt can't be used to grab items that someone else owns, or to grab containers like chests. items.spells.wildenergy.name=wild energy items.spells.wildenergy.desc=This spell contains some of the cursed energy which powered DM-300. When cast, it will recharge your wands and worn artifacts, while also triggering a random cursed wand effect. You are able to choose a direction for this cursed magic to shoot in, however. diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/TelekineticGrab.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/TelekineticGrab.java index 2ec22cda7..afdb359e5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/TelekineticGrab.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/TelekineticGrab.java @@ -69,15 +69,19 @@ public class TelekineticGrab extends TargetedSpell { if (ch != null && ch.buff(PinCushion.class) != null){ - Item item = ch.buff(PinCushion.class).grabOne(); + while (ch.buff(PinCushion.class) != null) { + Item item = ch.buff(PinCushion.class).grabOne(); - if (item.doPickUp(hero, ch.pos)){ - hero.spend(-Item.TIME_TO_PICK_UP); //casting the spell already takes a turn + if (item.doPickUp(hero, ch.pos)) { + hero.spend(-Item.TIME_TO_PICK_UP); //casting the spell already takes a turn + 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; + } - } else { - GLog.w(Messages.get(this, "cant_grab")); - Dungeon.level.drop(item, ch.pos).sprite.drop(); - return; } } else if (Dungeon.level.heaps.get(bolt.collisionPos) != null){ @@ -90,16 +94,18 @@ public class TelekineticGrab extends TargetedSpell { return; } - Item item = h.peek(); + while (!h.isEmpty()) { + Item item = h.peek(); + if (item.doPickUp(hero, h.pos)) { + h.pickUp(); + hero.spend(-Item.TIME_TO_PICK_UP); //casting the spell already takes a turn + GLog.i( Messages.capitalize(Messages.get(hero, "you_now_have", item.name())) ); - if (item.doPickUp(hero, h.pos)){ - h.pickUp(); - hero.spend(-Item.TIME_TO_PICK_UP); //casting the spell already takes a turn - - } else { - GLog.w(Messages.get(this, "cant_grab")); - h.sprite.drop(); - return; + } else { + GLog.w(Messages.get(this, "cant_grab")); + h.sprite.drop(); + return; + } } } else {