v2.2.0: quests now use the deck system for their equipment loot
This commit is contained in:
+56
@@ -26,9 +26,12 @@ import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.AscensionChallenge;
|
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.Generator;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.quest.DarkGold;
|
import com.shatteredpixel.shatteredpixeldungeon.items.quest.DarkGold;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.quest.Pickaxe;
|
import com.shatteredpixel.shatteredpixeldungeon.items.quest.Pickaxe;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest.BlacksmithRoom;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest.BlacksmithRoom;
|
||||||
@@ -44,6 +47,7 @@ import com.watabou.utils.Callback;
|
|||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
public class Blacksmith extends NPC {
|
public class Blacksmith extends NPC {
|
||||||
|
|
||||||
@@ -269,6 +273,9 @@ public class Blacksmith extends NPC {
|
|||||||
public static int hardens;
|
public static int hardens;
|
||||||
public static int upgrades;
|
public static int upgrades;
|
||||||
public static int smiths;
|
public static int smiths;
|
||||||
|
|
||||||
|
//pre-generate these so they are consistent between seeds
|
||||||
|
public static ArrayList<Item> smithRewards;
|
||||||
|
|
||||||
public static void reset() {
|
public static void reset() {
|
||||||
type = 0;
|
type = 0;
|
||||||
@@ -286,6 +293,8 @@ public class Blacksmith extends NPC {
|
|||||||
hardens = 0;
|
hardens = 0;
|
||||||
upgrades = 0;
|
upgrades = 0;
|
||||||
smiths = 0;
|
smiths = 0;
|
||||||
|
|
||||||
|
smithRewards = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String NODE = "blacksmith";
|
private static final String NODE = "blacksmith";
|
||||||
@@ -305,6 +314,7 @@ public class Blacksmith extends NPC {
|
|||||||
private static final String HARDENS = "hardens";
|
private static final String HARDENS = "hardens";
|
||||||
private static final String UPGRADES = "upgrades";
|
private static final String UPGRADES = "upgrades";
|
||||||
private static final String SMITHS = "smiths";
|
private static final String SMITHS = "smiths";
|
||||||
|
private static final String SMITH_REWARDS = "smith_rewards";
|
||||||
|
|
||||||
public static void storeInBundle( Bundle bundle ) {
|
public static void storeInBundle( Bundle bundle ) {
|
||||||
|
|
||||||
@@ -327,6 +337,8 @@ public class Blacksmith extends NPC {
|
|||||||
node.put( HARDENS, hardens );
|
node.put( HARDENS, hardens );
|
||||||
node.put( UPGRADES, upgrades );
|
node.put( UPGRADES, upgrades );
|
||||||
node.put( SMITHS, smiths );
|
node.put( SMITHS, smiths );
|
||||||
|
|
||||||
|
if (smithRewards != null) node.put( SMITH_REWARDS, smithRewards );
|
||||||
}
|
}
|
||||||
|
|
||||||
bundle.put( NODE, node );
|
bundle.put( NODE, node );
|
||||||
@@ -361,6 +373,10 @@ public class Blacksmith extends NPC {
|
|||||||
upgrades = node.getInt( UPGRADES );
|
upgrades = node.getInt( UPGRADES );
|
||||||
smiths = node.getInt( SMITHS );
|
smiths = node.getInt( SMITHS );
|
||||||
|
|
||||||
|
if (node.contains( SMITH_REWARDS )){
|
||||||
|
smithRewards = new ArrayList<>((Collection<Item>) ((Collection<?>) node.getCollection( SMITH_REWARDS )));
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
@@ -378,11 +394,51 @@ public class Blacksmith extends NPC {
|
|||||||
alternative = false;
|
alternative = false;
|
||||||
|
|
||||||
given = false;
|
given = false;
|
||||||
|
generateRewards( true );
|
||||||
|
|
||||||
}
|
}
|
||||||
return rooms;
|
return rooms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void generateRewards( boolean useDecks ){
|
||||||
|
smithRewards = new ArrayList<>();
|
||||||
|
smithRewards.add(Generator.randomWeapon(3, useDecks));
|
||||||
|
smithRewards.add(Generator.randomWeapon(3, useDecks));
|
||||||
|
ArrayList<Item> toUndo = new ArrayList<>();
|
||||||
|
while (smithRewards.get(0).getClass() == smithRewards.get(1).getClass()) {
|
||||||
|
if (useDecks) toUndo.add(smithRewards.get(1));
|
||||||
|
smithRewards.remove(1);
|
||||||
|
smithRewards.add(Generator.randomWeapon(3, useDecks));
|
||||||
|
}
|
||||||
|
for (Item i : toUndo){
|
||||||
|
Generator.undoDrop(i);
|
||||||
|
}
|
||||||
|
smithRewards.add(Generator.randomArmor(3));
|
||||||
|
|
||||||
|
//15%:+0, 55%:+1, 20%:+2, 5%:+3
|
||||||
|
int rewardLevel;
|
||||||
|
float itemLevelRoll = Random.Float();
|
||||||
|
if (itemLevelRoll < 0.2f){
|
||||||
|
rewardLevel = 0;
|
||||||
|
} else if (itemLevelRoll < 0.75f){
|
||||||
|
rewardLevel = 1;
|
||||||
|
} else if (itemLevelRoll < 0.95f){
|
||||||
|
rewardLevel = 2;
|
||||||
|
} else {
|
||||||
|
rewardLevel = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Item i : smithRewards){
|
||||||
|
i.level(rewardLevel);
|
||||||
|
if (i instanceof Weapon) {
|
||||||
|
((Weapon) i).enchant(null);
|
||||||
|
} else if (i instanceof Armor){
|
||||||
|
((Armor) i).inscribe(null);
|
||||||
|
}
|
||||||
|
i.cursed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int Type(){
|
public static int Type(){
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -325,7 +325,7 @@ public class Ghost extends NPC {
|
|||||||
}
|
}
|
||||||
//50%:tier2, 30%:tier3, 15%:tier4, 5%:tier5
|
//50%:tier2, 30%:tier3, 15%:tier4, 5%:tier5
|
||||||
int wepTier = Random.chances(new float[]{0, 0, 10, 6, 3, 1});
|
int wepTier = Random.chances(new float[]{0, 0, 10, 6, 3, 1});
|
||||||
weapon = (Weapon) Generator.randomUsingDefaults(Generator.wepTiers[wepTier - 1]);
|
weapon = (Weapon) Generator.random(Generator.wepTiers[wepTier - 1]);
|
||||||
|
|
||||||
//clear weapon's starting properties
|
//clear weapon's starting properties
|
||||||
weapon.level(0);
|
weapon.level(0);
|
||||||
|
|||||||
+1
-1
@@ -236,7 +236,7 @@ public class Imp extends NPC {
|
|||||||
given = false;
|
given = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
reward = (Ring)Generator.randomUsingDefaults( Generator.Category.RING );
|
reward = (Ring)Generator.random( Generator.Category.RING );
|
||||||
} while (reward.cursed);
|
} while (reward.cursed);
|
||||||
reward.upgrade( 2 );
|
reward.upgrade( 2 );
|
||||||
reward.cursed = true;
|
reward.cursed = true;
|
||||||
|
|||||||
+10
-4
@@ -317,13 +317,19 @@ public class Wandmaker extends NPC {
|
|||||||
spawned = true;
|
spawned = true;
|
||||||
|
|
||||||
given = false;
|
given = false;
|
||||||
wand1 = (Wand) Generator.randomUsingDefaults(Generator.Category.WAND);
|
wand1 = (Wand) Generator.random(Generator.Category.WAND);
|
||||||
wand1.cursed = false;
|
wand1.cursed = false;
|
||||||
wand1.upgrade();
|
wand1.upgrade();
|
||||||
|
|
||||||
do {
|
wand2 = (Wand) Generator.random(Generator.Category.WAND);
|
||||||
wand2 = (Wand) Generator.randomUsingDefaults(Generator.Category.WAND);
|
ArrayList<Item> toUndo = new ArrayList<>();
|
||||||
} while (wand2.getClass().equals(wand1.getClass()));
|
while (wand2.getClass() == wand1.getClass()) {
|
||||||
|
toUndo.add(wand2);
|
||||||
|
wand2 = (Wand) Generator.random(Generator.Category.WAND);
|
||||||
|
}
|
||||||
|
for (Item i :toUndo){
|
||||||
|
Generator.undoDrop(i);
|
||||||
|
}
|
||||||
wand2.cursed = false;
|
wand2.cursed = false;
|
||||||
wand2.upgrade();
|
wand2.upgrade();
|
||||||
|
|
||||||
|
|||||||
@@ -537,6 +537,7 @@ public class Generator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//reverts changes to drop chances generates by this item
|
//reverts changes to drop chances generates by this item
|
||||||
|
//equivalent of shuffling the card back into the deck, does not preserve order!
|
||||||
public static void undoDrop(Item item){
|
public static void undoDrop(Item item){
|
||||||
for (Category cat : Category.values()){
|
for (Category cat : Category.values()){
|
||||||
if (item.getClass().isAssignableFrom(cat.superClass)){
|
if (item.getClass().isAssignableFrom(cat.superClass)){
|
||||||
|
|||||||
+4
-31
@@ -30,7 +30,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
|
||||||
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.Generator;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
|
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;
|
||||||
@@ -47,7 +46,6 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
import com.watabou.noosa.audio.Sample;
|
import com.watabou.noosa.audio.Sample;
|
||||||
import com.watabou.utils.Random;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -438,10 +436,6 @@ public class WndBlacksmith extends Window {
|
|||||||
private static final int BTN_GAP = 5;
|
private static final int BTN_GAP = 5;
|
||||||
private static final int GAP = 2;
|
private static final int GAP = 2;
|
||||||
|
|
||||||
Item[] rewards = new Item[3];
|
|
||||||
|
|
||||||
int rewardLevel;
|
|
||||||
|
|
||||||
public WndSmith( Blacksmith troll, Hero hero ){
|
public WndSmith( Blacksmith troll, Hero hero ){
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@@ -458,35 +452,13 @@ public class WndBlacksmith extends Window {
|
|||||||
message.setPos(0, titlebar.bottom() + GAP);
|
message.setPos(0, titlebar.bottom() + GAP);
|
||||||
add( message );
|
add( message );
|
||||||
|
|
||||||
rewards[0] = Generator.randomWeapon(3, true);
|
if (Blacksmith.Quest.smithRewards == null || Blacksmith.Quest.smithRewards.isEmpty()){
|
||||||
do {
|
Blacksmith.Quest.generateRewards(false);
|
||||||
rewards[1] = Generator.randomWeapon(3, true);
|
|
||||||
} while (rewards[0].getClass() == rewards[1].getClass());
|
|
||||||
rewards[2] = Generator.randomArmor(3);
|
|
||||||
|
|
||||||
//15%:+0, 55%:+1, 20%:+2, 5%:+3
|
|
||||||
float itemLevelRoll = Random.Float();
|
|
||||||
if (itemLevelRoll < 0.2f){
|
|
||||||
rewardLevel = 0;
|
|
||||||
} else if (itemLevelRoll < 0.75f){
|
|
||||||
rewardLevel = 1;
|
|
||||||
} else if (itemLevelRoll < 0.95f){
|
|
||||||
rewardLevel = 2;
|
|
||||||
} else {
|
|
||||||
rewardLevel = 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Item i : rewards){
|
for (Item i : Blacksmith.Quest.smithRewards){
|
||||||
count++;
|
count++;
|
||||||
i.level(rewardLevel);
|
|
||||||
if (i instanceof Weapon) {
|
|
||||||
((Weapon) i).enchant(null);
|
|
||||||
} else if (i instanceof Armor){
|
|
||||||
((Armor) i).inscribe(null);
|
|
||||||
}
|
|
||||||
i.cursed = false;
|
|
||||||
|
|
||||||
ItemButton btnReward = new ItemButton(){
|
ItemButton btnReward = new ItemButton(){
|
||||||
@Override
|
@Override
|
||||||
protected void onClick() {
|
protected void onClick() {
|
||||||
@@ -526,6 +498,7 @@ public class WndBlacksmith extends Window {
|
|||||||
Dungeon.level.drop( item, Dungeon.hero.pos ).sprite.drop();
|
Dungeon.level.drop( item, Dungeon.hero.pos ).sprite.drop();
|
||||||
}
|
}
|
||||||
WndSmith.this.hide();
|
WndSmith.this.hide();
|
||||||
|
Blacksmith.Quest.smithRewards = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
btnConfirm.setRect(0, height+2, width/2-1, 16);
|
btnConfirm.setRect(0, height+2, width/2-1, 16);
|
||||||
|
|||||||
Reference in New Issue
Block a user