Fill trade_pricing with craftable items

This commit is contained in:
juliancoffee 2021-07-03 02:37:22 +03:00
parent 3ee123b745
commit f213ba138a
9 changed files with 200 additions and 72 deletions

View File

@ -12,18 +12,21 @@ loot_tables: [
(0.025, false, "common.loot_tables.weapons.cultist"),
(0.025, false, "common.loot_tables.weapons.cave"),
(0.02, false, "common.loot_tables.weapons.legendary"),
// Armor
// Non-craftable Armor
(20.0, true, "common.loot_tables.armor.cloth"),
(1.0, true, "common.loot_tables.armor.twigs"),
(1.0, true, "common.loot_tables.armor.twigsflowers"),
(1.0, true, "common.loot_tables.armor.twigsleaves"),
// Materials
(7.5, true, "common.loot_tables.materials.common"),
(8.0, true, "common.loot_tables.materials.underground"),
// Food
(0.3, true, "common.loot_tables.food.farm_ingredients"),
(0.4, true, "common.loot_tables.food.wild_ingredients"),
(0.2, true, "common.loot_tables.food.prepared"),
(0.01, false, "common.loot_tables.trading.jewellery"),
// Ingredients
(1.0, true, "common.loot_tables.trading.sellable_materials"),
(1.0, false, "common.loot_tables.trading.unsellable_materials"),
// Food Ingredients
(1.0, true, "common.loot_tables.trading.food"),
// Potions
//
// crafted from food, no need to duplicate it here.
@ -35,16 +38,17 @@ loot_tables: [
//
// Misc
(0.1, true, "common.loot_tables.consumable.throwable"),
(0.7, true, "common.loot_tables.consumable.misc"),
(1.0, false, "common.loot_tables.trading"),
// Collections
(0.00001, false, "common.loot_tables.trading.collection"),
],
// this is the amount of that good the most common item represents
// so basically this table balances the goods against each other (higher=less valuable)
good_scaling: [
(Potions, 0.0075), // common.items.consumable.potion_minor
(Food, 0.1), // common.items.food.mushroom
(Potions, 0.005), // common.items.consumable.potion_minor
(Food, 0.5), // common.items.food.mushroom
(Coin, 1.0), // common.items.utility.coins
(Armor, 1.0), // common.items.armor.misc.pants.worker_blue
(Tools, 0.25), // common.items.weapons.staff.starter_staff
(Ingredients, 0.25), // common.items.crafting_ing.leather_scraps
(Armor, 0.5), // common.items.armor.misc.pants.worker_blue
(Tools, 0.5), // common.items.weapons.staff.starter_staff
(Ingredients, 0.5), // common.items.crafting_ing.leather_scraps
])

View File

@ -1,37 +0,0 @@
// Loot table that exists purely for price rationalisation
// Please keep it sorting by rarity so it's easier to reason about things
[
// Ores
(0.03, Item("common.items.mineral.ore.gold")),
(0.045, Item("common.items.mineral.ore.silver")),
(0.1, Item("common.items.mineral.ore.bloodstone")),
(0.2, Item("common.items.mineral.ore.cobalt")),
(0.25, Item("common.items.mineral.ore.coal")),
(0.3, Item("common.items.mineral.ore.iron")),
(0.5, Item("common.items.mineral.ore.velorite")),
(0.6, Item("common.items.mineral.ore.veloritefrag")),
(1.5, Item("common.items.mineral.ore.copper")),
(1.5, Item("common.items.mineral.ore.tin")),
// Animal Hide
(0.05, Item("common.items.crafting_ing.hide.dragon_scale")),
(0.05, Item("common.items.crafting_ing.hide.plate")),
(0.1, Item("common.items.crafting_ing.leather.rigid_leather")),
(0.1, Item("common.items.crafting_ing.hide.carapace")),
(0.2, Item("common.items.crafting_ing.hide.scales")),
(0.7, Item("common.items.crafting_ing.hide.tough_hide")),
(1.0, Item("common.items.crafting_ing.hide.animal_hide")),
(1.5, Item("common.items.crafting_ing.leather.leather_strips")),
// Mob Drops
(0.01, Item("common.items.crafting_ing.animal_misc.phoenix_feather")),
(0.08, Item("common.items.crafting_ing.animal_misc.large_horn")),
(0.1, Item("common.items.crafting_ing.animal_misc.icy_fang")),
(0.15, Item("common.items.crafting_ing.animal_misc.grim_eyeball")),
(0.15, Item("common.items.crafting_ing.animal_misc.lively_vine")),
(1.2, Item("common.items.crafting_ing.animal_misc.fur")),
// Meats
(0.6, Item("common.items.food.meat.beast_large_raw")),
(0.8, Item("common.items.food.meat.tough_raw")),
(1.0, Item("common.items.food.meat.beast_small_raw")),
(1.2, Item("common.items.food.meat.fish_raw")),
(1.3, Item("common.items.food.meat.bird_raw")),
]

View File

@ -0,0 +1,10 @@
// Loot table that exists purely for price rationalisation
// Put here anything that doesn't fit in anything else.
//
// This loot table should be marked as un-sellable.
// If you want to add something that merchants can buy and sell,
// add another loot table
//
// Please keep it sorted by rarity so it's easier to reason about things
[
]

View File

@ -0,0 +1,22 @@
// Loot table that exists purely for price rationalisation
// Put here anything that doesn't fit in anything else.
//
// This loot table should be marked as un-sellable.
// If you want to add something that merchants can buy and sell,
// add another loot table
//
// Please keep it sorted by rarity so it's easier to reason about things
[
/// Non-craftable gliders
// Butterfly gliders
(5, Item("common.items.glider.glider_morpho")),
(5, Item("common.items.glider.glider_monarch")),
(5, Item("common.items.glider.glider_moth")),
// Skullgrin
(2, Item("common.items.glider.glider_purp")),
/// Lanterns
(5, Item("common.items.lantern.geode_purp")),
(2, Item("common.items.lantern.blue_0")),
(2, Item("common.items.boss_drops.lantern")),
]

View File

@ -0,0 +1,24 @@
// Loot table that exists purely for price rationalisation
//
// This loot table should be marked as sellable.
// If you want to add something that merchants can buy but not sell,
// add another loot table
//
// Please keep it sorted by rarity so it's easier to reason about things
[
// Meats
(0.0125, Item("common.items.food.meat.bird_large_raw")),
(0.5, Item("common.items.food.meat.beast_large_raw")),
(2.0, Item("common.items.food.meat.bird_raw")),
(2.0, Item("common.items.food.meat.fish_raw")),
(2.0, Item("common.items.food.meat.tough_raw")),
(4.0, Item("common.items.food.meat.beast_small_raw")),
// Gatherables
(0.025, Item("common.items.food.coconut")),
(0.25, Item("common.items.food.cheese")),
(0.25, Item("common.items.food.apple")),
(2.0, Item("common.items.food.carrot")),
(2.0, Item("common.items.food.lettuce")),
(2.0, Item("common.items.food.tomato")),
(2.0, Item("common.items.food.mushroom")),
]

View File

@ -0,0 +1,11 @@
// Loot table that exists purely for price rationalisation
//
// This loot table should be marked as un-sellable.
// If you want to add something that merchants can buy and sell,
// add another loot table
//
// Please keep it sorted by rarity so it's easier to reason about things
[
(1, Item("common.items.armor.misc.back.dungeon_purple")),
(1, Item("common.items.armor.misc.ring.skull")),
]

View File

@ -0,0 +1,58 @@
// Loot table that exists purely for price rationalisation
//
// This loot table should be marked as sellable.
// If you want to add something that merchants can buy but not sell,
// add another loot table
//
// Please keep it sorted by rarity so it's easier to reason about things
[
// Stones
(0.02, Item("common.items.mineral.gem.diamond")),
(0.08, Item("common.items.mineral.gem.ruby")),
(0.1, Item("common.items.mineral.gem.emerald")),
(0.2, Item("common.items.mineral.gem.sapphire")),
(0.25, Item("common.items.mineral.ore.velorite")),
(0.5, Item("common.items.mineral.ore.veloritefrag")),
(0.75, Item("common.items.mineral.gem.topaz")),
(1.0, Item("common.items.mineral.gem.amethyst")),
(4.0, Item("common.items.crafting_ing.stones")),
// Ores
(0.5, Item("common.items.mineral.ore.velorite")),
(0.6, Item("common.items.mineral.ore.veloritefrag")),
(2.5, Item("common.items.mineral.ore.copper")),
(2.5, Item("common.items.mineral.ore.iron")),
(2.5, Item("common.items.mineral.ore.tin")),
// Animal Hide
(2.5, Item("common.items.crafting_ing.hide.tough_hide")),
(4.0, Item("common.items.crafting_ing.hide.animal_hide")),
// Mob Drops
(0.15, Item("common.items.crafting_ing.animal_misc.grim_eyeball")),
(0.15, Item("common.items.crafting_ing.animal_misc.lively_vine")),
(0.5, Item("common.items.crafting_ing.animal_misc.raptor_feather")),
(1.0, Item("common.items.crafting_ing.animal_misc.icy_fang")),
(1.2, Item("common.items.crafting_ing.animal_misc.claw")),
(2.5, Item("common.items.crafting_ing.animal_misc.fur")),
(2.5, Item("common.items.crafting_ing.animal_misc.sharp_fang")),
(2.5, Item("common.items.crafting_ing.animal_misc.venom_sac")),
(2.5, Item("common.items.crafting_ing.animal_misc.viscous_ooze")),
(4.0, Item("common.items.crafting_ing.cloth.wool")),
// Junk
(4.0, Item("common.items.crafting_ing.bowl")),
(4.0, Item("common.items.crafting_ing.empty_vial")),
// Gatherables
(0.1, Item("common.items.crafting_ing.seashells")),
(0.2, Item("common.items.crafting_ing.honey")),
(0.2, Item("common.items.flowers.moonbell")),
(1.0, Item("common.items.crafting_ing.cactus")),
(1.0, Item("common.items.crafting_ing.cotton_boll")),
(1.0, Item("common.items.flowers.pyrebloom")),
(3.0, Item("common.items.crafting_ing.twigs")),
(4.0, Item("common.items.flowers.red")),
(4.0, Item("common.items.flowers.wild_flax")),
(9.0, Item("common.items.flowers.sunflower")),
]

View File

@ -0,0 +1,32 @@
// Loot table that exists purely for price rationalisation
//
// This loot table should be marked as un-sellable.
// If you want to add something that merchants can buy and sell,
// add another loot table
//
// Please keep it sorted by rarity so it's easier to reason about things
[
// High tier Ores
(0.025, Item("common.items.mineral.ore.gold")),
(0.03, Item("common.items.mineral.ore.silver")),
(0.1, Item("common.items.mineral.ore.bloodstone")),
(0.2, Item("common.items.mineral.ore.cobalt")),
(0.25, Item("common.items.mineral.ore.coal")),
// High tier Animal Hide
(0.025, Item("common.items.crafting_ing.hide.dragon_scale")),
(0.05, Item("common.items.crafting_ing.hide.plate")),
(0.05, Item("common.items.crafting_ing.hide.leather_troll")),
(0.05, Item("common.items.crafting_ing.hide.rugged_hide")),
(0.2, Item("common.items.crafting_ing.hide.carapace")),
(0.2, Item("common.items.crafting_ing.hide.scales")),
// High tier Mob drops
(0.005, Item("common.items.crafting_ing.animal_misc.phoenix_feather")),
(0.08, Item("common.items.crafting_ing.animal_misc.large_horn")),
(0.08, Item("common.items.crafting_ing.animal_misc.lively_vine")),
(0.225, Item("common.items.crafting_ing.sticky_thread")),
// Ultra Rare drops
(0.0005, Item("common.items.crafting_ing.mindflayer_bag_damaged")),
]

View File

@ -223,8 +223,6 @@ impl TradePricing {
fn get_list_by_path(&self, name: &str) -> &[Entry] {
match name {
// Armor
// TODO: balance mindflayer bag price so this isn't needed
"common.items.crafting_ing.mindflayer_bag_damaged" => &self.armor.entries,
_ if name.starts_with("common.items.armor.") => &self.armor.entries,
// Tools
_ if name.starts_with("common.items.weapons.") => &self.tools.entries,
@ -253,8 +251,6 @@ impl TradePricing {
fn get_list_by_path_mut(&mut self, name: &str) -> &mut Entries {
match name {
// Armor
// TODO: balance mindflayer bag price so this isn't needed
"common.items.crafting_ing.mindflayer_bag_damaged" => &mut self.armor,
_ if name.starts_with("common.items.armor.") => &mut self.armor,
// Tools
_ if name.starts_with("common.items.weapons.") => &mut self.tools,
@ -350,22 +346,30 @@ impl TradePricing {
let mut ordered_recipes: Vec<RememberedRecipe> = Vec::new();
for (_, recipe) in book.iter() {
let (ref asset_path, amount) = recipe.output;
ordered_recipes.push(RememberedRecipe {
output: asset_path.id().into(),
amount,
material_cost: Self::UNAVAILABLE_PRICE,
input: recipe
.inputs
.iter()
.filter_map(|&(ref recipe_input, count)| {
if let RecipeInput::Item(it) = recipe_input {
Some((it.id().into(), count))
} else {
None
}
})
.collect(),
});
// Trading don't know how to work with recycling yet
if !recipe.is_recycling {
ordered_recipes.push(RememberedRecipe {
output: asset_path.id().into(),
amount,
material_cost: Self::UNAVAILABLE_PRICE,
input: recipe
.inputs
.iter()
.filter_map(|&(ref recipe_input, count)| {
if let RecipeInput::Item(it) = recipe_input {
// If item is not consumed in craft, ignore it
if count == 0 {
None
} else {
Some((it.id().into(), count))
}
} else {
None
}
})
.collect(),
});
}
}
// re-evaluate prices based on crafting tables