mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Re-created item_price_calculation with new loot tables.
This commit is contained in:
parent
a2906168a6
commit
7eb1eefa13
@ -1,24 +1,37 @@
|
||||
(
|
||||
loot_tables: [
|
||||
// balance the loot tables against each other (higher= more common= smaller price)
|
||||
// the fact that loot tables have an own probability not accessible outside of the lottery call doesn't help here
|
||||
(4,"common.loot_tables.wild_animal"),
|
||||
(1,"common.loot_tables.armor.cloth"),
|
||||
(0.1,"common.loot_tables.cave_large"),
|
||||
(0.1,"common.loot_tables.consumables"),
|
||||
// loot_table_crafting is a rare roll on crate/mud sprite looting
|
||||
(0.005,"common.loot_tables.cultists"),
|
||||
(1,"common.loot_tables.fish"),
|
||||
(0.1,"common.loot_tables.humanoids"),
|
||||
(1,"common.loot_tables.maneater"),
|
||||
(0.0001,"common.loot_tables.mindflayer"),
|
||||
(0.001,"common.loot_tables.miniboss"),
|
||||
// loot_table_rocks is dropped by rock monsters, but is also the only source of stones to econsim until cave_scatter information is turned into a loot table
|
||||
(1,"common.loot_tables.fallback"),
|
||||
(0.04,"common.loot_tables.saurok"),
|
||||
(0.05,"common.loot_tables.villager"),
|
||||
// we probably want to include all the scattered scatter information
|
||||
//(0.5,"common.cave_scatter"),
|
||||
// Weapons
|
||||
(16.0, "common.loot_tables.weapons.starter"),
|
||||
(8.0, "common.loot_tables.weapons.tier-0"),
|
||||
(4.0, "common.loot_tables.weapons.tier-1"),
|
||||
(2.0, "common.loot_tables.weapons.tier-2"),
|
||||
(1.0, "common.loot_tables.weapons.tier-3"),
|
||||
(0.5, "common.loot_tables.weapons.tier-4"),
|
||||
(0.25, "common.loot_tables.weapons.tier-5"),
|
||||
(0.125, "common.loot_tables.weapons.cultist"),
|
||||
(0.125, "common.loot_tables.weapons.cave"),
|
||||
(0.0625, "common.loot_tables.weapons.legendary"),
|
||||
// Armor
|
||||
(20.0, "common.loot_tables.armor.cloth"),
|
||||
(6.0, "common.loot_tables.armor.agile"),
|
||||
(3.0, "common.loot_tables.armor.swift"),
|
||||
(6.0, "common.loot_tables.armor.druid"),
|
||||
(2.0, "common.loot_tables.armor.twigs"),
|
||||
(2.0, "common.loot_tables.armor.twigsflowers"),
|
||||
(2.0, "common.loot_tables.armor.twigsleaves"),
|
||||
(0.5, "common.loot_tables.armor.plate"),
|
||||
(0.25, "common.loot_tables.armor.steel"),
|
||||
(0.125, "common.loot_tables.armor.cultist"),
|
||||
// Materials
|
||||
(7.5, "common.loot_tables.materials.common"),
|
||||
(2.0, "common.loot_tables.materials.underground"),
|
||||
// Food
|
||||
(6.0, "common.loot_tables.food.farm_ingredients"),
|
||||
(2.5, "common.loot_tables.food.wild_ingredients"),
|
||||
(0.8, "common.loot_tables.food.prepared"),
|
||||
// TODO: Change consumables when they are split up later
|
||||
(0.5, "common.loot_tables.consumables"),
|
||||
],
|
||||
// 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)
|
||||
|
@ -1,7 +1,7 @@
|
||||
[
|
||||
(1.0, Item("common.items.weapons.bow.rawwood-0")),
|
||||
(1.0, Item("common.items.weapons.bow.rawwood-1")),
|
||||
(1.0, Item("common.items.weapons.bow.rawwood-2")),
|
||||
(1.0, Item("common.items.weapons.bow.rawwood-3")),
|
||||
(1.0, Item("common.items.weapons.bow.rawwood-4")),
|
||||
(1.0, Item("common.items.weapons.bow.metal-0")),
|
||||
(1.0, Item("common.items.weapons.bow.metal-1")),
|
||||
(1.0, Item("common.items.weapons.bow.metal-2")),
|
||||
(1.0, Item("common.items.weapons.bow.metal-3")),
|
||||
(1.0, Item("common.items.weapons.bow.metal-4")),
|
||||
]
|
4
assets/common/loot_tables/weapons/hammer/bronze.ron
Normal file
4
assets/common/loot_tables/weapons/hammer/bronze.ron
Normal file
@ -0,0 +1,4 @@
|
||||
[
|
||||
(1.0, Item("common.items.weapons.hammer.bronze_hammer-0")),
|
||||
(1.0, Item("common.items.weapons.hammer.bronze_hammer-1")),
|
||||
]
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
assets::{self, AssetExt},
|
||||
lottery::LootSpec,
|
||||
lottery::{LootSpec, Lottery},
|
||||
recipe::{default_recipe_book, RecipeInput},
|
||||
trade::Good,
|
||||
};
|
||||
@ -8,7 +8,7 @@ use assets_manager::AssetGuard;
|
||||
use hashbrown::HashMap;
|
||||
use lazy_static::lazy_static;
|
||||
use serde::Deserialize;
|
||||
use tracing::info;
|
||||
use tracing::{info, warn};
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Entry {
|
||||
@ -38,6 +38,7 @@ lazy_static! {
|
||||
static ref TRADE_PRICING: TradePricing = TradePricing::read();
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct ProbabilityFile {
|
||||
pub content: Vec<(f32, String)>,
|
||||
}
|
||||
@ -53,10 +54,21 @@ impl From<Vec<(f32, LootSpec)>> for ProbabilityFile {
|
||||
Self {
|
||||
content: content
|
||||
.into_iter()
|
||||
.filter_map(|(a, b)| match b {
|
||||
LootSpec::Item(c) => Some((a, c)),
|
||||
LootSpec::ItemQuantity(c, d, e) => Some((a * (d + e) as f32 / 2.0, c)),
|
||||
_ => None,
|
||||
.flat_map(|(a, b)| match b {
|
||||
LootSpec::Item(c) => vec![(a, c)].into_iter(),
|
||||
LootSpec::ItemQuantity(c, d, e) => {
|
||||
vec![(a * (d + e) as f32 / 2.0, c)].into_iter()
|
||||
},
|
||||
LootSpec::LootTable(c) => {
|
||||
let total = Lottery::<LootSpec>::load_expect(&c).read().total();
|
||||
ProbabilityFile::load_expect_cloned(&c)
|
||||
.content
|
||||
.into_iter()
|
||||
.map(|(d, e)| (a * d / total, e))
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
},
|
||||
LootSpec::CreatureMaterial => vec![].into_iter(),
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
@ -306,6 +318,10 @@ impl TradePricing {
|
||||
Some(TradePricing::COIN_ITEM.into())
|
||||
} else {
|
||||
let table = self.get_list(good);
|
||||
if table.is_empty() {
|
||||
warn!("Good: {:?}, was unreachable.", good);
|
||||
return None;
|
||||
}
|
||||
let upper = table.len();
|
||||
let lower = table
|
||||
.iter()
|
||||
|
Loading…
Reference in New Issue
Block a user