From f213ba138a5c7a4af65c24277a4dd3acc26e9722 Mon Sep 17 00:00:00 2001 From: juliancoffee Date: Sat, 3 Jul 2021 02:37:22 +0300 Subject: [PATCH] Fill trade_pricing with craftable items --- assets/common/item_price_calculation.ron | 34 ++++++----- assets/common/loot_tables/trading.ron | 37 ------------ assets/common/loot_tables/trading/buying.ron | 10 ++++ .../common/loot_tables/trading/collection.ron | 22 +++++++ assets/common/loot_tables/trading/food.ron | 24 ++++++++ .../common/loot_tables/trading/jewellery.ron | 11 ++++ .../trading/sellable_materials.ron | 58 +++++++++++++++++++ .../trading/unsellable_materials.ron | 32 ++++++++++ common/src/comp/inventory/trade_pricing.rs | 44 +++++++------- 9 files changed, 200 insertions(+), 72 deletions(-) delete mode 100644 assets/common/loot_tables/trading.ron create mode 100644 assets/common/loot_tables/trading/buying.ron create mode 100644 assets/common/loot_tables/trading/collection.ron create mode 100644 assets/common/loot_tables/trading/food.ron create mode 100644 assets/common/loot_tables/trading/jewellery.ron create mode 100644 assets/common/loot_tables/trading/sellable_materials.ron create mode 100644 assets/common/loot_tables/trading/unsellable_materials.ron diff --git a/assets/common/item_price_calculation.ron b/assets/common/item_price_calculation.ron index 9bbe7bb14f..24fded7293 100644 --- a/assets/common/item_price_calculation.ron +++ b/assets/common/item_price_calculation.ron @@ -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 ]) diff --git a/assets/common/loot_tables/trading.ron b/assets/common/loot_tables/trading.ron deleted file mode 100644 index 3bb520da04..0000000000 --- a/assets/common/loot_tables/trading.ron +++ /dev/null @@ -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")), -] diff --git a/assets/common/loot_tables/trading/buying.ron b/assets/common/loot_tables/trading/buying.ron new file mode 100644 index 0000000000..31bfd830c9 --- /dev/null +++ b/assets/common/loot_tables/trading/buying.ron @@ -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 +[ +] diff --git a/assets/common/loot_tables/trading/collection.ron b/assets/common/loot_tables/trading/collection.ron new file mode 100644 index 0000000000..069a912e22 --- /dev/null +++ b/assets/common/loot_tables/trading/collection.ron @@ -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")), +] diff --git a/assets/common/loot_tables/trading/food.ron b/assets/common/loot_tables/trading/food.ron new file mode 100644 index 0000000000..e98d52abf0 --- /dev/null +++ b/assets/common/loot_tables/trading/food.ron @@ -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")), +] diff --git a/assets/common/loot_tables/trading/jewellery.ron b/assets/common/loot_tables/trading/jewellery.ron new file mode 100644 index 0000000000..cc55273026 --- /dev/null +++ b/assets/common/loot_tables/trading/jewellery.ron @@ -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")), +] diff --git a/assets/common/loot_tables/trading/sellable_materials.ron b/assets/common/loot_tables/trading/sellable_materials.ron new file mode 100644 index 0000000000..c486d78e58 --- /dev/null +++ b/assets/common/loot_tables/trading/sellable_materials.ron @@ -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")), +] diff --git a/assets/common/loot_tables/trading/unsellable_materials.ron b/assets/common/loot_tables/trading/unsellable_materials.ron new file mode 100644 index 0000000000..e08cf09ed7 --- /dev/null +++ b/assets/common/loot_tables/trading/unsellable_materials.ron @@ -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")), +] diff --git a/common/src/comp/inventory/trade_pricing.rs b/common/src/comp/inventory/trade_pricing.rs index b8ea4298ee..aa339f7eab 100644 --- a/common/src/comp/inventory/trade_pricing.rs +++ b/common/src/comp/inventory/trade_pricing.rs @@ -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 = 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