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

View File

@@ -92,9 +92,9 @@ public abstract class Scroll extends Item {
protected String rune;
//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
protected float talentChance = 1;
public float talentChance = 1;
{
stackable = true;
@@ -194,17 +194,16 @@ public abstract class Scroll extends Item {
public abstract void doRead();
public void readAnimation() {
//if scroll is being created for its effect, depend on creating item to dispel
if (!anonymous) Invisibility.dispel();
Invisibility.dispel();
curUser.spend( TIME_TO_READ );
curUser.busy();
((HeroSprite)curUser.sprite).read();
if (!anonymous) {
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;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
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.scrolls.Scroll;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify;
@@ -111,14 +109,12 @@ public class UnstableSpell extends Spell {
}
s.anonymize();
s.talentChance = s.talentFactor = 1;
curItem = s;
s.doRead();
Invisibility.dispel();
Catalog.countUse(getClass());
if (Random.Float() < talentChance){
Talent.onScrollUsed(curUser, curUser.pos, talentFactor, getClass());
}
//don't trigger talents, as they'll be triggered by the scroll
}
//lower values, as it's cheaper to make