v2.2.0: implemented a bunch of internal tracking for blacksmith rewards

This commit is contained in:
Evan Debenham
2023-08-18 13:00:29 -04:00
parent 976cb6435b
commit 8e26ab46a1
@@ -30,7 +30,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.AscensionChallenge;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSeal; import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSeal;
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem; import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.quest.DarkGold; import com.shatteredpixel.shatteredpixeldungeon.items.quest.DarkGold;
@@ -126,13 +125,13 @@ public class Blacksmith extends NPC {
Quest.given = true; Quest.given = true;
Quest.completed = false; Quest.completed = false;
Notes.add( Notes.Landmark.TROLL ); Notes.add( Notes.Landmark.TROLL );
Pickaxe pick = new Pickaxe(); Item pick = Quest.pickaxe;
pick.identify();
if (pick.doPickUp( Dungeon.hero )) { if (pick.doPickUp( Dungeon.hero )) {
GLog.i( Messages.capitalize(Messages.get(Dungeon.hero, "you_now_have", pick.name()) )); GLog.i( Messages.capitalize(Messages.get(Dungeon.hero, "you_now_have", pick.name()) ));
} else { } else {
Dungeon.level.drop( pick, Dungeon.hero.pos ).sprite.drop(); Dungeon.level.drop( pick, Dungeon.hero.pos ).sprite.drop();
} }
Quest.pickaxe = null;
if (msg2Final != ""){ if (msg2Final != ""){
GameScene.show(new WndQuest(Blacksmith.this, msg2Final)); GameScene.show(new WndQuest(Blacksmith.this, msg2Final));
@@ -155,14 +154,16 @@ public class Blacksmith extends NPC {
tell(Messages.get(this, "blood_2")); tell(Messages.get(this, "blood_2"));
} else { } else {
if (pick.isEquipped(Dungeon.hero)) { if (pick.isEquipped(Dungeon.hero)) {
boolean wasCursed = pick.cursed;
pick.cursed = false; //so that it can always be removed pick.cursed = false; //so that it can always be removed
pick.doUnequip(Dungeon.hero, false); pick.doUnequip(Dungeon.hero, false);
pick.cursed = wasCursed;
} }
pick.detach(Dungeon.hero.belongings.backpack); pick.detach(Dungeon.hero.belongings.backpack);
Quest.pickaxe = pick;
tell(Messages.get(this, "completed")); tell(Messages.get(this, "completed"));
Quest.completed = true; Quest.completed = true;
Quest.reforged = false;
Statistics.questScores[2] = 3000; Statistics.questScores[2] = 3000;
} }
@@ -176,14 +177,17 @@ public class Blacksmith extends NPC {
tell(Messages.get(this, "gold_2")); tell(Messages.get(this, "gold_2"));
} else { } else {
if (pick.isEquipped(Dungeon.hero)) { if (pick.isEquipped(Dungeon.hero)) {
boolean wasCursed = pick.cursed;
pick.cursed = false; //so that it can always be removed
pick.doUnequip(Dungeon.hero, false); pick.doUnequip(Dungeon.hero, false);
pick.cursed = wasCursed;
} }
pick.detach(Dungeon.hero.belongings.backpack); pick.detach(Dungeon.hero.belongings.backpack);
Quest.pickaxe = pick;
gold.detachAll(Dungeon.hero.belongings.backpack); gold.detachAll(Dungeon.hero.belongings.backpack);
tell(Messages.get(this, "completed")); tell(Messages.get(this, "completed"));
Quest.completed = true; Quest.completed = true;
Quest.reforged = false;
Statistics.questScores[2] = 3000; Statistics.questScores[2] = 3000;
} }
@@ -193,7 +197,7 @@ public class Blacksmith extends NPC {
tell(Messages.get(this, "reminder")); tell(Messages.get(this, "reminder"));
} }
} else if (Quest.type == 0 && !Quest.reforged) { } else if (Quest.type == 0 && Quest.reforges == 0) {
Game.runOnRenderThread(new Callback() { Game.runOnRenderThread(new Callback() {
@Override @Override
@@ -202,11 +206,15 @@ public class Blacksmith extends NPC {
} }
}); });
} else if (Quest.favor > 0) { //only the reforge window at the moment
} else if (Quest.favor >= 500) {
tell("You got " + Quest.favor + " favor. Here's some gold."); Game.runOnRenderThread(new Callback() {
new Gold(Quest.favor).doPickUp(Dungeon.hero, Dungeon.hero.pos); @Override
Quest.favor = 0; public void call() {
GameScene.show( new WndBlacksmith( Blacksmith.this, Dungeon.hero ) );
}
});
} else { } else {
@@ -298,7 +306,10 @@ public class Blacksmith extends NPC {
Badges.validateItemLevelAquired( first ); Badges.validateItemLevelAquired( first );
Item.updateQuickslot(); Item.updateQuickslot();
Quest.reforged = true; Quest.reforges++;
if (Quest.type != 0) {
Quest.favor -= 500;
}
} }
@Override @Override
@@ -328,45 +339,59 @@ public class Blacksmith extends NPC {
// 2 = Fungi // 2 = Fungi
// 3 = Gnoll // 3 = Gnoll
private static int type; private static int type;
//pre-v2.2.0
private static boolean alternative; //false for mining gold, true for bat blood
//quest state information
private static boolean spawned; private static boolean spawned;
private static boolean given; private static boolean given;
private static boolean started; private static boolean started;
private static boolean bossBeaten; private static boolean bossBeaten;
private static boolean completed; private static boolean completed;
//reward tracking. Stores remaining favor, the pickaxe, and how many of each reward has been chosen
private static int favor; private static int favor;
private static Item pickaxe;
//pre-v2.2.0 private static int reforges; //also used by the pre-v2.2.0 version of the quest
private static boolean alternative; //false for mining gold, true for bat blood private static int hardens;
private static boolean reforged; private static int upgrades;
private static int smiths;
public static void reset() { public static void reset() {
type = 0; type = 0;
alternative = false;
spawned = false; spawned = false;
given = false; given = false;
started = false; started = false;
bossBeaten = false; bossBeaten = false;
favor = 0;
completed = false; completed = false;
reforged = false;
favor = 0;
pickaxe = new Pickaxe().identify();
reforges = 0;
hardens = 0;
upgrades = 0;
smiths = 0;
} }
private static final String NODE = "blacksmith"; private static final String NODE = "blacksmith";
private static final String TYPE = "type"; private static final String TYPE = "type";
private static final String ALTERNATIVE = "alternative";
private static final String SPAWNED = "spawned"; private static final String SPAWNED = "spawned";
private static final String GIVEN = "given"; private static final String GIVEN = "given";
private static final String STARTED = "started"; private static final String STARTED = "started";
private static final String BOSS_BEATEN = "boss_beaten"; private static final String BOSS_BEATEN = "boss_beaten";
private static final String COMPLETED = "completed"; private static final String COMPLETED = "completed";
private static final String FAVOR = "favor"; private static final String FAVOR = "favor";
private static final String PICKAXE = "pickaxe";
private static final String ALTERNATIVE = "alternative"; private static final String REFORGES = "reforges";
private static final String REFORGED = "reforged"; private static final String HARDENS = "hardens";
private static final String UPGRADES = "upgrades";
private static final String SMITHS = "smiths";
public static void storeInBundle( Bundle bundle ) { public static void storeInBundle( Bundle bundle ) {
@@ -376,13 +401,19 @@ public class Blacksmith extends NPC {
if (spawned) { if (spawned) {
node.put( TYPE, type ); node.put( TYPE, type );
node.put( ALTERNATIVE, alternative );
node.put( GIVEN, given ); node.put( GIVEN, given );
node.put( STARTED, started ); node.put( STARTED, started );
node.put( BOSS_BEATEN, bossBeaten ); node.put( BOSS_BEATEN, bossBeaten );
node.put( COMPLETED, completed ); node.put( COMPLETED, completed );
node.put( FAVOR, favor ); node.put( FAVOR, favor );
node.put( ALTERNATIVE, alternative ); if (pickaxe != null) node.put( PICKAXE, pickaxe );
node.put( REFORGED, reforged ); node.put( REFORGES, reforges );
node.put( HARDENS, hardens );
node.put( UPGRADES, upgrades );
node.put( SMITHS, smiths );
} }
bundle.put( NODE, node ); bundle.put( NODE, node );
@@ -394,13 +425,29 @@ public class Blacksmith extends NPC {
if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) { if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) {
type = node.getInt(TYPE); type = node.getInt(TYPE);
alternative = node.getBoolean( ALTERNATIVE );
given = node.getBoolean( GIVEN ); given = node.getBoolean( GIVEN );
started = node.getBoolean( STARTED ); started = node.getBoolean( STARTED );
bossBeaten = node.getBoolean( BOSS_BEATEN ); bossBeaten = node.getBoolean( BOSS_BEATEN );
completed = node.getBoolean( COMPLETED ); completed = node.getBoolean( COMPLETED );
favor = node.getInt( FAVOR ); favor = node.getInt( FAVOR );
alternative = node.getBoolean( ALTERNATIVE ); if (node.contains(PICKAXE)) {
reforged = node.getBoolean( REFORGED ); pickaxe = (Item) node.get(PICKAXE);
} else {
pickaxe = null;
}
if (node.contains("reforged")){
//pre-v2.2.0 saves
reforges = node.getBoolean( "reforged" ) ? 1 : 0;
} else {
reforges = node.getInt( REFORGES );
}
hardens = node.getInt( HARDENS );
upgrades = node.getInt( UPGRADES );
smiths = node.getInt( SMITHS );
} else { } else {
reset(); reset();
} }
@@ -446,7 +493,6 @@ public class Blacksmith extends NPC {
public static void complete(){ public static void complete(){
completed = true; completed = true;
reforged = false;
favor = 0; favor = 0;
DarkGold gold = Dungeon.hero.belongings.getItem(DarkGold.class); DarkGold gold = Dungeon.hero.belongings.getItem(DarkGold.class);
@@ -455,12 +501,15 @@ public class Blacksmith extends NPC {
gold.detachAll(Dungeon.hero.belongings.backpack); gold.detachAll(Dungeon.hero.belongings.backpack);
} }
//we may want to store this so that any upgrades are remembered.
Pickaxe pick = Dungeon.hero.belongings.getItem(Pickaxe.class); Pickaxe pick = Dungeon.hero.belongings.getItem(Pickaxe.class);
if (pick.isEquipped(Dungeon.hero)) { if (pick.isEquipped(Dungeon.hero)) {
boolean wasCursed = pick.cursed;
pick.cursed = false; //so that it can always be removed
pick.doUnequip(Dungeon.hero, false); pick.doUnequip(Dungeon.hero, false);
pick.cursed = wasCursed;
} }
pick.detach(Dungeon.hero.belongings.backpack); pick.detach(Dungeon.hero.belongings.backpack);
Quest.pickaxe = pick;
//check for boss enemy, add another 1k points if they are dead //check for boss enemy, add another 1k points if they are dead
//perhaps reduce final quest score if hero is hit by avoidable boss attacks? //perhaps reduce final quest score if hero is hit by avoidable boss attacks?
Statistics.questScores[2] = favor; Statistics.questScores[2] = favor;