v3.3.0: rewrote the fix for unstable spell not always triggering talents

Now more robust, fixes errors with siren's song and unstable spellbook
This commit is contained in:
Evan Debenham
2025-10-18 18:01:14 -04:00
parent 684b73bd0d
commit 6e1ea49540
3 changed files with 11 additions and 18 deletions

View File

@@ -25,7 +25,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Blindness; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Blindness;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MagicImmune; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MagicImmune;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Regeneration; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Regeneration;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
@@ -153,6 +152,7 @@ public class UnstableSpellbook extends Artifact {
|| (scroll instanceof ScrollOfTransmutation)); || (scroll instanceof ScrollOfTransmutation));
scroll.anonymize(); scroll.anonymize();
scroll.talentChance = 0; //spellbook does not trigger on-scroll talents
curItem = scroll; curItem = scroll;
curUser = hero; curUser = hero;
@@ -176,14 +176,13 @@ public class UnstableSpellbook extends Artifact {
curItem = scroll; curItem = scroll;
charge--; charge--;
scroll.anonymize(); scroll.anonymize();
scroll.talentChance = 0;
checkForArtifactProc(curUser, scroll); checkForArtifactProc(curUser, scroll);
scroll.doRead(); scroll.doRead();
Invisibility.dispel();
Talent.onArtifactUsed(Dungeon.hero); Talent.onArtifactUsed(Dungeon.hero);
} else { } else {
checkForArtifactProc(curUser, fScroll); checkForArtifactProc(curUser, fScroll);
fScroll.doRead(); fScroll.doRead();
Invisibility.dispel();
Talent.onArtifactUsed(Dungeon.hero); Talent.onArtifactUsed(Dungeon.hero);
} }
updateQuickslot(); updateQuickslot();
@@ -197,7 +196,6 @@ public class UnstableSpellbook extends Artifact {
} else { } else {
checkForArtifactProc(curUser, scroll); checkForArtifactProc(curUser, scroll);
scroll.doRead(); scroll.doRead();
Invisibility.dispel();
Talent.onArtifactUsed(Dungeon.hero); Talent.onArtifactUsed(Dungeon.hero);
} }
@@ -232,11 +230,11 @@ public class UnstableSpellbook extends Artifact {
curUser = Dungeon.hero; curUser = Dungeon.hero;
curItem = scroll; curItem = scroll;
scroll.anonymize(); scroll.anonymize();
scroll.talentChance = 0;
Game.runOnRenderThread(new Callback() { Game.runOnRenderThread(new Callback() {
@Override @Override
public void call() { public void call() {
scroll.doRead(); scroll.doRead();
Invisibility.dispel();
Item.updateQuickslot(); Item.updateQuickslot();
} }
}); });

View File

@@ -92,9 +92,9 @@ public abstract class Scroll extends Item {
protected String rune; protected String rune;
//affects how strongly on-scroll talents trigger from this scroll //affects how strongly on-scroll talents trigger from this scroll
protected float talentFactor = 1; public float talentFactor = 1;
//the chance (0-1) of whether on-scroll talents trigger from this potion //the chance (0-1) of whether on-scroll talents trigger from this potion
protected float talentChance = 1; public float talentChance = 1;
{ {
stackable = true; stackable = true;
@@ -194,17 +194,16 @@ public abstract class Scroll extends Item {
public abstract void doRead(); public abstract void doRead();
public void readAnimation() { public void readAnimation() {
//if scroll is being created for its effect, depend on creating item to dispel Invisibility.dispel();
if (!anonymous) Invisibility.dispel();
curUser.spend( TIME_TO_READ ); curUser.spend( TIME_TO_READ );
curUser.busy(); curUser.busy();
((HeroSprite)curUser.sprite).read(); ((HeroSprite)curUser.sprite).read();
if (!anonymous) { if (!anonymous) {
Catalog.countUse(getClass()); Catalog.countUse(getClass());
if (Random.Float() < talentChance) { }
Talent.onScrollUsed(curUser, curUser.pos, talentFactor, getClass()); if (Random.Float() < talentChance) {
} Talent.onScrollUsed(curUser, curUser.pos, talentFactor, getClass());
} }
} }

View File

@@ -21,9 +21,7 @@
package com.shatteredpixel.shatteredpixeldungeon.items.spells; package com.shatteredpixel.shatteredpixeldungeon.items.spells;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify;
@@ -111,14 +109,12 @@ public class UnstableSpell extends Spell {
} }
s.anonymize(); s.anonymize();
s.talentChance = s.talentFactor = 1;
curItem = s; curItem = s;
s.doRead(); s.doRead();
Invisibility.dispel();
Catalog.countUse(getClass()); Catalog.countUse(getClass());
if (Random.Float() < talentChance){ //don't trigger talents, as they'll be triggered by the scroll
Talent.onScrollUsed(curUser, curUser.pos, talentFactor, getClass());
}
} }
//lower values, as it's cheaper to make //lower values, as it's cheaper to make