v3.1.0: fixed free pickaxe from smith quest using quest score not favor

This commit is contained in:
Evan Debenham
2025-05-16 17:11:22 -04:00
parent 4cdf8557f2
commit f2287e8620
2 changed files with 20 additions and 3 deletions

View File

@@ -214,6 +214,7 @@ public class Blacksmith extends NPC {
//reward tracking. Stores remaining favor, the pickaxe, and how many of each reward has been chosen //reward tracking. Stores remaining favor, the pickaxe, and how many of each reward has been chosen
public static int favor; public static int favor;
public static Item pickaxe; public static Item pickaxe;
public static boolean freePickaxe;
public static int reforges; public static int reforges;
public static int hardens; public static int hardens;
public static int upgrades; public static int upgrades;
@@ -235,6 +236,7 @@ public class Blacksmith extends NPC {
favor = 0; favor = 0;
pickaxe = new Pickaxe().identify(); pickaxe = new Pickaxe().identify();
freePickaxe = false;
reforges = 0; reforges = 0;
hardens = 0; hardens = 0;
upgrades = 0; upgrades = 0;
@@ -258,6 +260,7 @@ public class Blacksmith extends NPC {
private static final String FAVOR = "favor"; private static final String FAVOR = "favor";
private static final String PICKAXE = "pickaxe"; private static final String PICKAXE = "pickaxe";
private static final String FREE_PICKAXE= "free_pickaxe";
private static final String REFORGES = "reforges"; private static final String REFORGES = "reforges";
private static final String HARDENS = "hardens"; private static final String HARDENS = "hardens";
private static final String UPGRADES = "upgrades"; private static final String UPGRADES = "upgrades";
@@ -282,6 +285,7 @@ public class Blacksmith extends NPC {
node.put( FAVOR, favor ); node.put( FAVOR, favor );
if (pickaxe != null) node.put( PICKAXE, pickaxe ); if (pickaxe != null) node.put( PICKAXE, pickaxe );
node.put( FREE_PICKAXE, freePickaxe );
node.put( REFORGES, reforges ); node.put( REFORGES, reforges );
node.put( HARDENS, hardens ); node.put( HARDENS, hardens );
node.put( UPGRADES, upgrades ); node.put( UPGRADES, upgrades );
@@ -317,6 +321,16 @@ public class Blacksmith extends NPC {
} else { } else {
pickaxe = null; pickaxe = null;
} }
if (node.contains(FREE_PICKAXE)){
freePickaxe = node.getBoolean(FREE_PICKAXE);
} else {
//some for pre-3.1 saves, some from incorrect values from v3.1-BETA-1.0
if (favor >= 2500){
freePickaxe = true;
} else {
freePickaxe = false;
}
}
reforges = node.getInt( REFORGES ); reforges = node.getInt( REFORGES );
hardens = node.getInt( HARDENS ); hardens = node.getInt( HARDENS );
upgrades = node.getInt( UPGRADES ); upgrades = node.getInt( UPGRADES );
@@ -453,12 +467,16 @@ public class Blacksmith extends NPC {
if (bossBeaten) favor += 1000; if (bossBeaten) favor += 1000;
Statistics.questScores[2] += favor; Statistics.questScores[2] += favor;
if (favor >= 2500){
freePickaxe = true;
}
} }
public static boolean rewardsAvailable(){ public static boolean rewardsAvailable(){
return favor > 0 return favor > 0
|| (Quest.smithRewards != null && Quest.smiths > 0) || (Quest.smithRewards != null && Quest.smiths > 0)
|| (pickaxe != null && Statistics.questScores[2] >= 2500); || (pickaxe != null && freePickaxe);
} }
} }

View File

@@ -24,7 +24,6 @@ package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
@@ -76,7 +75,7 @@ public class WndBlacksmith extends Window {
ArrayList<RedButton> buttons = new ArrayList<>(); ArrayList<RedButton> buttons = new ArrayList<>();
int pickaxeCost = Statistics.questScores[2] >= 2500 ? 0 : 250; int pickaxeCost = Blacksmith.Quest.freePickaxe ? 0 : 250;
RedButton pickaxe = new RedButton(Messages.get(this, "pickaxe", pickaxeCost), 6){ RedButton pickaxe = new RedButton(Messages.get(this, "pickaxe", pickaxeCost), 6){
@Override @Override
protected void onClick() { protected void onClick() {