v3.0.0: recall glyph now works with runestones

This commit is contained in:
Evan Debenham
2024-11-04 14:36:54 -05:00
parent d5bb26b840
commit 9dbaaa006f
10 changed files with 73 additions and 43 deletions

View File

@@ -60,12 +60,12 @@ import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging;
import com.shatteredpixel.shatteredpixeldungeon.items.stones.Runestone;
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.ShardOfOblivion;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.SpiritBow;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Gloves;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
@@ -707,18 +707,11 @@ public enum Talent {
}
}
public static void onUpgradeScrollUsed( Hero hero ){
if (hero.hasTalent(INSCRIBED_POWER)){
if (hero.heroClass == HeroClass.MAGE) {
MagesStaff staff = hero.belongings.getItem(MagesStaff.class);
if (staff != null) {
staff.gainCharge(2 + 2 * hero.pointsInTalent(INSCRIBED_POWER), true);
ScrollOfRecharging.charge(Dungeon.hero);
SpellSprite.show(hero, SpellSprite.CHARGE);
}
} else {
Buff.affect(hero, Recharging.class, 4 + 8 * hero.pointsInTalent(INSCRIBED_POWER));
}
public static void onRunestoneUsed( Hero hero, int pos, Class<?extends Item> cls ){
if (hero.heroClass == HeroClass.CLERIC
&& hero.hasTalent(RECALL_GLYPH)
&& Runestone.class.isAssignableFrom(cls)){
Buff.affect(hero, RecallGlyph.UsedGlyphTracker.class, hero.pointsInTalent(RECALL_GLYPH) == 2 ? 300 : 10).item = cls;
}
}

View File

@@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTransmutat
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ExoticScroll;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ScrollOfEnchantment;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ScrollOfMetamorphosis;
import com.shatteredpixel.shatteredpixeldungeon.items.stones.InventoryStone;
import com.shatteredpixel.shatteredpixeldungeon.items.stones.Runestone;
import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfAugmentation;
import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfEnchantment;
@@ -66,10 +67,16 @@ public class RecallGlyph extends ClericSpell {
item.setCurrent(hero);
//TODO runestones
if (item instanceof Scroll){
((Scroll) item).anonymize();
((Scroll) item).doRead();
} else if (item instanceof Runestone){
((Runestone) item).anonymize();
if (item instanceof InventoryStone){
((InventoryStone) item).directActivate();
} else {
item.doThrow(hero);
}
}
onSpellCast(tome, hero);

View File

@@ -60,6 +60,10 @@ public abstract class InventoryStone extends Runestone {
protected void activate(int cell) {
GameScene.selectItem( itemSelector );
}
public void directActivate(){
GameScene.selectItem( itemSelector );
}
protected void useAnimation() {
curUser.spend( 1f );

View File

@@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.stones;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
@@ -35,14 +36,25 @@ public abstract class Runestone extends Item {
defaultAction = AC_THROW;
}
//anonymous stones don't count as consumed, do not drop, etc.
//useful for stones which are only spawned for their effects
protected boolean anonymous = false;
public void anonymize(){
image = ItemSpriteSheet.STONE_HOLDER;
anonymous = true;
}
@Override
protected void onThrow(int cell) {
///inventory stones are thrown like normal items, other stones don't trigger when thrown into pits
if (this instanceof InventoryStone ||
(Dungeon.level.pit[cell] && Actor.findChar(cell) == null)){
super.onThrow( cell );
if (!anonymous) super.onThrow( cell );
} else {
Catalog.countUse(getClass());
if (!anonymous) {
Catalog.countUse(getClass());
Talent.onRunestoneUsed(curUser, cell, getClass());
}
activate(cell);
if (Actor.findChar(cell) == null) Dungeon.level.pressCell( cell );
Invisibility.dispel();

View File

@@ -30,7 +30,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.audio.Sample;
@@ -52,15 +51,10 @@ public class StoneOfAggression extends Runestone {
} else {
Buff.prolong(ch, Aggression.class, Aggression.DURATION);
}
CellEmitter.center(cell).start( Speck.factory( Speck.SCREAM ), 0.3f, 3 );
Sample.INSTANCE.play( Assets.Sounds.READ );
} else {
//Item.onThrow
Heap heap = Dungeon.level.drop( this, cell );
if (!heap.isEmpty()) {
heap.sprite.drop( cell );
}
}
CellEmitter.center(cell).start( Speck.factory( Speck.SCREAM ), 0.3f, 3 );
Sample.INSTANCE.play( Assets.Sounds.READ );
}

View File

@@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.items.stones;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
@@ -61,8 +62,11 @@ public class StoneOfAugmentation extends InventoryStone {
weapon.augment = augment;
useAnimation();
ScrollOfUpgrade.upgrade(curUser);
curItem.detach( curUser.belongings.backpack );
Catalog.countUse(getClass());
if (!anonymous) {
curItem.detach(curUser.belongings.backpack);
Catalog.countUse(getClass());
Talent.onRunestoneUsed(curUser, curUser.pos, getClass());
}
}
public void apply( Armor armor, Armor.Augment augment ) {
@@ -70,8 +74,11 @@ public class StoneOfAugmentation extends InventoryStone {
armor.augment = augment;
useAnimation();
ScrollOfUpgrade.upgrade(curUser);
curItem.detach( curUser.belongings.backpack );
Catalog.countUse(getClass());
if (!anonymous) {
curItem.detach(curUser.belongings.backpack);
Catalog.countUse(getClass());
Talent.onRunestoneUsed(curUser, curUser.pos, getClass());
}
}
@Override
@@ -144,7 +151,7 @@ public class StoneOfAugmentation extends InventoryStone {
@Override
protected void onClick() {
hide();
StoneOfAugmentation.this.collect();
if (!anonymous) StoneOfAugmentation.this.collect();
}
};
btnCancel.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT );
@@ -155,7 +162,7 @@ public class StoneOfAugmentation extends InventoryStone {
@Override
public void onBackPressed() {
StoneOfAugmentation.this.collect();
if (!anonymous) StoneOfAugmentation.this.collect();
super.onBackPressed();
}
}

View File

@@ -53,7 +53,7 @@ public class StoneOfBlink extends Runestone {
@Override
protected void activate(int cell) {
if (!ScrollOfTeleportation.teleportToLocation(curUser, cell)){
if (!ScrollOfTeleportation.teleportToLocation(curUser, cell) && !anonymous){
Dungeon.level.drop(this, cell).sprite.drop();
}
}

View File

@@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.items.stones;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
@@ -82,8 +83,11 @@ public class StoneOfDetectMagic extends InventoryStone {
GLog.w(Messages.get(this, "detected_bad"));
}
curItem.detach( curUser.belongings.backpack );
Catalog.countUse(getClass());
if (!anonymous) {
curItem.detach(curUser.belongings.backpack);
Catalog.countUse(getClass());
Talent.onRunestoneUsed(curUser, curUser.pos, getClass());
}
}

View File

@@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.items.stones;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
import com.shatteredpixel.shatteredpixeldungeon.effects.Enchanting;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
@@ -49,8 +50,11 @@ public class StoneOfEnchantment extends InventoryStone {
@Override
protected void onItemSelected(Item item) {
curItem.detach( curUser.belongings.backpack );
Catalog.countUse(getClass());
if (!anonymous) {
curItem.detach(curUser.belongings.backpack);
Catalog.countUse(getClass());
Talent.onRunestoneUsed(curUser, curUser.pos, getClass());
}
if (item instanceof Weapon) {

View File

@@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.stones;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
import com.shatteredpixel.shatteredpixeldungeon.effects.Identification;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
@@ -89,7 +90,8 @@ public class StoneOfIntuition extends InventoryStone {
public static class IntuitionUseTracker extends Buff {{ revivePersists = true; }};
private static Class curGuess = null;
//TODO CLERIC! yikes...
public class WndGuess extends Window {
private static final int WIDTH = 120;
@@ -114,7 +116,6 @@ public class StoneOfIntuition extends InventoryStone {
protected void onClick() {
super.onClick();
useAnimation();
Catalog.countUse(StoneOfIntuition.class);
if (item.getClass() == curGuess){
if (item instanceof Ring){
((Ring) item).setKnown();
@@ -126,11 +127,15 @@ public class StoneOfIntuition extends InventoryStone {
} else {
GLog.w( Messages.get(WndGuess.class, "incorrect") );
}
if (curUser.buff(IntuitionUseTracker.class) == null){
Buff.affect(curUser, IntuitionUseTracker.class);
} else {
curItem.detach( curUser.belongings.backpack );
curUser.buff(IntuitionUseTracker.class).detach();
if (!anonymous) {
Catalog.countUse(StoneOfIntuition.class);
Talent.onRunestoneUsed(curUser, curUser.pos, StoneOfIntuition.class);
if (curUser.buff(IntuitionUseTracker.class) == null) {
Buff.affect(curUser, IntuitionUseTracker.class);
} else {
curItem.detach(curUser.belongings.backpack);
curUser.buff(IntuitionUseTracker.class).detach();
}
}
curGuess = null;
hide();