v3.2.5: added functionality for item variable pickup delay

This commit is contained in:
Evan Debenham
2025-09-18 12:59:40 -04:00
parent 7d2098426b
commit efb58becba
16 changed files with 34 additions and 37 deletions

View File

@@ -74,7 +74,7 @@ public class Dewdrop extends Item {
}
Sample.INSTANCE.play( Assets.Sounds.DEWDROP );
hero.spendAndNext( TIME_TO_PICK_UP );
hero.spendAndNext( pickupDelay() );
return true;
}

View File

@@ -64,7 +64,7 @@ public class EnergyCrystal extends Item {
GameScene.pickUp( this, pos );
hero.sprite.showStatusWithIcon( 0x44CCFF, Integer.toString(quantity), FloatingText.ENERGY );
hero.spendAndNext( TIME_TO_PICK_UP );
hero.spendAndNext( pickupDelay() );
Sample.INSTANCE.play( Assets.Sounds.ITEM );

View File

@@ -68,7 +68,7 @@ public class Gold extends Item {
GameScene.pickUp( this, pos );
hero.sprite.showStatusWithIcon( CharSprite.NEUTRAL, Integer.toString(quantity), FloatingText.GOLD );
hero.spendAndNext( TIME_TO_PICK_UP );
hero.spendAndNext( pickupDelay() );
Sample.INSTANCE.play( Assets.Sounds.GOLD, 1, 1, Random.Float( 0.9f, 1.1f ) );
updateQuickslot();

View File

@@ -126,7 +126,7 @@ public class Item implements Bundlable {
GameScene.pickUp( this, pos );
Sample.INSTANCE.play( Assets.Sounds.ITEM );
hero.spendAndNext( TIME_TO_PICK_UP );
hero.spendAndNext( pickupDelay() );
return true;
} else {
@@ -697,6 +697,10 @@ public class Item implements Bundlable {
public float castDelay( Char user, int cell ){
return TIME_TO_THROW;
}
public float pickupDelay(){
return TIME_TO_PICK_UP;
}
protected static Hero curUser = null;
protected static Item curItem = null;

View File

@@ -77,7 +77,7 @@ public class LostBackpack extends Item {
Item.updateQuickslot();
Sample.INSTANCE.play( Assets.Sounds.DEWDROP );
hero.spendAndNext(TIME_TO_PICK_UP);
hero.spendAndNext(pickupDelay());
GameScene.pickUp( this, pos );
((HeroSprite)hero.sprite).updateArmor();

View File

@@ -503,7 +503,7 @@ public class DriedRose extends Artifact {
return false;
} if ( rose.level() >= rose.levelCap ){
GLog.i( Messages.get(this, "no_room") );
hero.spendAndNext(TIME_TO_PICK_UP);
hero.spendAndNext(pickupDelay());
return true;
} else {
@@ -516,7 +516,7 @@ public class DriedRose extends Artifact {
Sample.INSTANCE.play( Assets.Sounds.DEWDROP );
GameScene.pickUp(this, pos);
hero.spendAndNext(TIME_TO_PICK_UP);
hero.spendAndNext(pickupDelay());
return true;
}

View File

@@ -165,7 +165,7 @@ public class MasterThievesArmband extends Artifact {
} else {
if (loot.doPickUp(curUser)) {
//item collection happens instantly
curUser.spend(-TIME_TO_PICK_UP);
curUser.spend(-loot.pickupDelay());
} else {
Dungeon.level.drop(loot, curUser.pos).sprite.drop();
}

View File

@@ -518,7 +518,7 @@ public class TimekeepersHourglass extends Artifact {
else
GLog.i( Messages.get(this, "levelup") );
GameScene.pickUp(this, pos);
hero.spendAndNext(TIME_TO_PICK_UP);
hero.spendAndNext(pickupDelay());
return true;
} else {
GLog.w( Messages.get(this, "no_hourglass") );

View File

@@ -64,7 +64,7 @@ public abstract class DocumentPage extends Item {
}
document().findPage(page);
Sample.INSTANCE.play( Assets.Sounds.ITEM );
hero.spendAndNext( TIME_TO_PICK_UP );
hero.spendAndNext( pickupDelay() );
return true;
}

View File

@@ -63,7 +63,7 @@ public class Guidebook extends Item {
}
GameScene.flashForDocument(Document.ADVENTURERS_GUIDE, Document.GUIDE_INTRO);
Sample.INSTANCE.play( Assets.Sounds.ITEM );
hero.spendAndNext( TIME_TO_PICK_UP );
hero.spendAndNext( pickupDelay() );
return true;
}

View File

@@ -57,7 +57,7 @@ public abstract class Key extends Item {
WndJournal.last_index = 0;
Notes.add(this);
Sample.INSTANCE.play( Assets.Sounds.ITEM );
hero.spendAndNext( TIME_TO_PICK_UP );
hero.spendAndNext( pickupDelay() );
GameScene.updateKeyDisplay();
return true;
}

View File

@@ -75,7 +75,7 @@ public class TelekineticGrab extends TargetedSpell {
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
hero.spend(-item.pickupDelay()); //casting the spell already takes a turn
GLog.i( Messages.capitalize(Messages.get(hero, "you_now_have", item.name())) );
} else {
@@ -100,7 +100,7 @@ public class TelekineticGrab extends TargetedSpell {
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
hero.spend(-item.pickupDelay()); //casting the spell already takes a turn
GLog.i( Messages.capitalize(Messages.get(hero, "you_now_have", item.name())) );
} else {

View File

@@ -51,16 +51,22 @@ public class HeavyBoomerang extends MissileWeapon {
(tier-1) * lvl; //3 scaling, down from 4
}
boolean circleBackhit = false;
boolean circlingBack = false;
@Override
protected float adjacentAccFactor(Char owner, Char target) {
if (circleBackhit){
if (circlingBack){
return 1.5f;
}
return super.adjacentAccFactor(owner, target);
}
@Override
public float pickupDelay() {
//pickup is instant when circling back
return circlingBack ? 0f : super.pickupDelay();
}
@Override
protected void rangedHit(Char enemy, int cell) {
decrementDurability();
@@ -126,22 +132,18 @@ public class HeavyBoomerang extends MissileWeapon {
@Override
public void call() {
detach();
boomerang.circlingBack = true;
if (returnTarget == target){
if (!boomerang.spawnedForEffect) {
if (target instanceof Hero && boomerang.doPickUp((Hero) target)) {
//grabbing the boomerang takes no time
((Hero) target).spend(-TIME_TO_PICK_UP);
} else {
if (!(target instanceof Hero) || !boomerang.doPickUp((Hero) target)) {
Dungeon.level.drop(boomerang, returnPos).sprite.drop();
}
}
} else if (returnTarget != null){
boomerang.circleBackhit = true;
if (((Hero)target).shoot( returnTarget, boomerang )) {
boomerang.decrementDurability();
}
boomerang.circleBackhit = false;
if (!boomerang.spawnedForEffect && boomerang.durability > 0) {
Dungeon.level.drop(boomerang, returnPos).sprite.drop();
}
@@ -149,6 +151,7 @@ public class HeavyBoomerang extends MissileWeapon {
} else if (!boomerang.spawnedForEffect) {
Dungeon.level.drop(boomerang, returnPos).sprite.drop();
}
boomerang.circlingBack = false;
CircleBack.this.next();
}
});

View File

@@ -598,7 +598,7 @@ abstract public class MissileWeapon extends Weapon {
parent = null;
if (!UpgradedSetTracker.pickupValid(hero, this)){
Sample.INSTANCE.play( Assets.Sounds.ITEM );
hero.spendAndNext( TIME_TO_PICK_UP );
hero.spendAndNext( pickupDelay() );
GLog.w(Messages.get(this, "dust"));
quantity(0);
return true;

View File

@@ -22,7 +22,6 @@
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class ThrowingClub extends MissileWeapon {
@@ -38,12 +37,8 @@ public class ThrowingClub extends MissileWeapon {
}
@Override
public boolean doPickUp(Hero hero, int pos) {
if (super.doPickUp(hero, pos)){
hero.spendAndNext( -hero.cooldown() );
return true;
}
return false;
public float pickupDelay() {
return 0; //picked up instantly
}
@Override

View File

@@ -22,7 +22,6 @@
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class ThrowingHammer extends MissileWeapon {
@@ -38,12 +37,8 @@ public class ThrowingHammer extends MissileWeapon {
}
@Override
public boolean doPickUp(Hero hero, int pos) {
if (super.doPickUp(hero, pos)){
hero.spendAndNext( -hero.cooldown() );
return true;
}
return false;
public float pickupDelay() {
return 0; //picked up instantly
}
@Override