From f88fd5f349508b77eeb198fc25f2859545582787 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 29 Mar 2021 00:12:11 -0400 Subject: [PATCH] Fixed trading --- common/src/bin/csv_export/main.rs | 26 ++- common/src/bin/csv_import/main.rs | 24 ++- common/src/comp/body.rs | 2 +- common/src/comp/inventory/item/mod.rs | 10 +- common/src/comp/inventory/loadout_builder.rs | 53 +++--- common/src/comp/inventory/trade_pricing.rs | 78 ++++---- common/src/lottery.rs | 18 +- server/src/events/entity_manipulation.rs | 10 +- world/src/site/dungeon/mod.rs | 177 +++++++++---------- 9 files changed, 220 insertions(+), 178 deletions(-) diff --git a/common/src/bin/csv_export/main.rs b/common/src/bin/csv_export/main.rs index 6878a5a776..60437b6716 100644 --- a/common/src/bin/csv_export/main.rs +++ b/common/src/bin/csv_export/main.rs @@ -17,7 +17,7 @@ use veloren_common::{ ItemKind, }, }, - lottery::{Lottery, LootSpec}, + lottery::{LootSpec, Lottery}, }; #[derive(StructOpt)] @@ -219,7 +219,13 @@ fn all_items() -> Result<(), Box> { fn loot_table(loot_table: &str) -> Result<(), Box> { let mut wtr = csv::Writer::from_path("loot_table.csv")?; - wtr.write_record(&["Relative Chance", "Kind", "Item", "Lower Amount", "Upper Amount"])?; + wtr.write_record(&[ + "Relative Chance", + "Kind", + "Item", + "Lower Amount", + "Upper Amount", + ])?; let loot_table = "common.loot_tables.".to_owned() + loot_table; @@ -238,9 +244,19 @@ fn loot_table(loot_table: &str) -> Result<(), Box> { match item { LootSpec::Item(item) => wtr.write_record(&[&chance, "Item", item, "", ""])?, - LootSpec::ItemQuantity(item, lower, upper) => wtr.write_record(&[&chance, "Item", item, &lower.to_string(), &upper.to_string()])?, - LootSpec::LootTable(table) => wtr.write_record(&[&chance, "LootTable", table, "", ""])?, - LootSpec::CreatureMaterial => wtr.write_record(&[&chance, "CreatureMaterial", "", "", ""])?, + LootSpec::ItemQuantity(item, lower, upper) => wtr.write_record(&[ + &chance, + "Item", + item, + &lower.to_string(), + &upper.to_string(), + ])?, + LootSpec::LootTable(table) => { + wtr.write_record(&[&chance, "LootTable", table, "", ""])? + }, + LootSpec::CreatureMaterial => { + wtr.write_record(&[&chance, "CreatureMaterial", "", "", ""])? + }, } } diff --git a/common/src/bin/csv_import/main.rs b/common/src/bin/csv_import/main.rs index 255c9498ba..8efd36c5d8 100644 --- a/common/src/bin/csv_import/main.rs +++ b/common/src/bin/csv_import/main.rs @@ -383,12 +383,26 @@ fn loot_table(loot_table: &str) -> Result<(), Box> { for record in rdr.records() { if let Ok(ref record) = record { let item = match record.get(headers["Kind"]).expect("No loot specifier") { - "Item" => if let (Some(Ok(lower)), Some(Ok(upper))) = (record.get(headers["Lower Amount"]).map(|a| a.parse()), record.get(headers["Upper Amount"]).map(|a| a.parse())) { - LootSpec::ItemQuantity(record.get(headers["Item"]).expect("No item").to_string(), lower, upper) - } else { - LootSpec::Item(record.get(headers["Item"]).expect("No item").to_string()) + "Item" => { + if let (Some(Ok(lower)), Some(Ok(upper))) = ( + record.get(headers["Lower Amount"]).map(|a| a.parse()), + record.get(headers["Upper Amount"]).map(|a| a.parse()), + ) { + LootSpec::ItemQuantity( + record.get(headers["Item"]).expect("No item").to_string(), + lower, + upper, + ) + } else { + LootSpec::Item(record.get(headers["Item"]).expect("No item").to_string()) + } }, - "LootTable" => LootSpec::LootTable(record.get(headers["Item"]).expect("No loot table").to_string()), + "LootTable" => LootSpec::LootTable( + record + .get(headers["Item"]) + .expect("No loot table") + .to_string(), + ), "CreatureMaterial" => LootSpec::CreatureMaterial, _ => panic!("Loot specifier kind must be either \"Item\" or \"LootTable\""), }; diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index f0ac684bef..9a4c6a00b5 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -586,7 +586,7 @@ impl Body { pub fn get_loot(&self) -> Item { Item::new_from_asset_expect(match self { - _ => "common.items.food.cheese" + _ => "common.items.food.cheese", }) } } diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index 6dacdcd593..da355662a5 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -13,7 +13,7 @@ use crate::{ CharacterAbility, }, effect::Effect, - lottery::{Lottery, LootSpec}, + lottery::{LootSpec, Lottery}, recipe::RecipeInput, terrain::{Block, SpriteKind}, }; @@ -610,7 +610,7 @@ impl Item { _ => "common.loot_tables.armor_misc", }) .read(); - return Some(chosen.choose().to_item(None)) + return Some(chosen.choose().to_item(None)); }, SpriteKind::ChestBurried => { chosen = Lottery::::load_expect(match rng.gen_range(0..7) { @@ -620,7 +620,7 @@ impl Item { _ => "common.loot_tables.armor_misc", }) .read(); - return Some(chosen.choose().to_item(None)) + return Some(chosen.choose().to_item(None)); }, SpriteKind::Mud => { chosen = Lottery::::load_expect(match rng.gen_range(0..5) { @@ -630,7 +630,7 @@ impl Item { _ => "common.loot_tables.rocks", }) .read(); - return Some(chosen.choose().to_item(None)) + return Some(chosen.choose().to_item(None)); }, SpriteKind::Crate => { chosen = Lottery::::load_expect(match rng.gen_range(0..4) { @@ -638,7 +638,7 @@ impl Item { _ => "common.loot_tables.food", }) .read(); - return Some(chosen.choose().to_item(None)) + return Some(chosen.choose().to_item(None)); }, SpriteKind::Beehive => "common.items.crafting_ing.honey", diff --git a/common/src/comp/inventory/loadout_builder.rs b/common/src/comp/inventory/loadout_builder.rs index a928859bc2..8986cf0aee 100644 --- a/common/src/comp/inventory/loadout_builder.rs +++ b/common/src/comp/inventory/loadout_builder.rs @@ -568,19 +568,18 @@ impl LoadoutBuilder { .unwrap_or_default() / 10.0; for s in backpack.slots_mut() { - // TODO: Re-implement later - // if coins > 0 { - // let mut coin_item = - // Item::new_from_asset_expect("common.items.utility.coins"); - // coin_item - // .set_amount(coins) - // .expect("coins should be stackable"); - // *s = Some(coin_item); - // coins = 0; - // } else if let Some(item_id) = TradePricing::random_item(Good::Armor, armor) - // { - // *s = Some(Item::new_from_asset_expect(&item_id)); - // } + if coins > 0 { + let mut coin_item = + Item::new_from_asset_expect("common.items.utility.coins"); + coin_item + .set_amount(coins) + .expect("coins should be stackable"); + *s = Some(coin_item); + coins = 0; + } else if let Some(item_id) = TradePricing::random_item(Good::Armor, armor) + { + *s = Some(Item::new_from_asset_expect(&item_id)); + } } let mut bag1 = Item::new_from_asset_expect( "common.items.armor.misc.bag.reliable_backpack", @@ -592,9 +591,9 @@ impl LoadoutBuilder { .unwrap_or_default() / 10.0; for i in bag1.slots_mut() { - // if let Some(item_id) = TradePricing::random_item(Good::Tools, weapon) { - // *i = Some(Item::new_from_asset_expect(&item_id)); - // } + if let Some(item_id) = TradePricing::random_item(Good::Tools, weapon) { + *i = Some(Item::new_from_asset_expect(&item_id)); + } } let mut bag2 = Item::new_from_asset_expect( "common.items.armor.misc.bag.reliable_backpack", @@ -606,11 +605,11 @@ impl LoadoutBuilder { .unwrap_or_default() / 10.0; for i in bag2.slots_mut() { - // if let Some(item_id) = - // TradePricing::random_item(Good::Ingredients, ingredients) - // { - // *i = Some(Item::new_from_asset_expect(&item_id)); - // } + if let Some(item_id) = + TradePricing::random_item(Good::Ingredients, ingredients) + { + *i = Some(Item::new_from_asset_expect(&item_id)); + } } let mut bag3 = Item::new_from_asset_expect( "common.items.armor.misc.bag.reliable_backpack", @@ -622,9 +621,9 @@ impl LoadoutBuilder { .unwrap_or_default() / 10.0; for i in bag3.slots_mut() { - // if let Some(item_id) = TradePricing::random_item(Good::Food, food) { - // *i = Some(Item::new_from_asset_expect(&item_id)); - // } + if let Some(item_id) = TradePricing::random_item(Good::Food, food) { + *i = Some(Item::new_from_asset_expect(&item_id)); + } } let mut bag4 = Item::new_from_asset_expect( "common.items.armor.misc.bag.reliable_backpack", @@ -636,9 +635,9 @@ impl LoadoutBuilder { .unwrap_or_default() / 10.0; for i in bag4.slots_mut() { - // if let Some(item_id) = TradePricing::random_item(Good::Potions, potions) { - // *i = Some(Item::new_from_asset_expect(&item_id)); - // } + if let Some(item_id) = TradePricing::random_item(Good::Potions, potions) { + *i = Some(Item::new_from_asset_expect(&item_id)); + } } LoadoutBuilder::new() .active_item(active_item) diff --git a/common/src/comp/inventory/trade_pricing.rs b/common/src/comp/inventory/trade_pricing.rs index 4797009630..4bb85b026c 100644 --- a/common/src/comp/inventory/trade_pricing.rs +++ b/common/src/comp/inventory/trade_pricing.rs @@ -1,5 +1,6 @@ use crate::{ assets::{self, AssetExt}, + lottery::LootSpec, recipe::{default_recipe_book, RecipeInput}, trade::Good, }; @@ -42,13 +43,24 @@ struct ProbabilityFile { } impl assets::Asset for ProbabilityFile { - type Loader = assets::LoadFrom, assets::RonLoader>; + type Loader = assets::LoadFrom, assets::RonLoader>; const EXTENSION: &'static str = "ron"; } -impl From> for ProbabilityFile { - fn from(content: Vec<(f32, String)>) -> ProbabilityFile { Self { content } } +impl From> for ProbabilityFile { + fn from(content: Vec<(f32, LootSpec)>) -> 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, + }) + .collect(), + } + } } #[derive(Debug, Deserialize)] @@ -184,16 +196,15 @@ impl TradePricing { let mut result = TradePricing::default(); let files = TradingPriceFile::load_expect("common.item_price_calculation"); let contents = files.read(); - // TODO: Re-enable this - // for i in contents.loot_tables.iter() { - // if PRICING_DEBUG { - // info!(?i); - // } - // let loot = ProbabilityFile::load_expect(&i.1); - // for j in loot.read().content.iter() { - // add(&mut result.get_list_by_path_mut(&j.1), &j.1, i.0 * j.0); - // } - // } + for i in contents.loot_tables.iter() { + if PRICING_DEBUG { + info!(?i); + } + let loot = ProbabilityFile::load_expect(&i.1); + for j in loot.read().content.iter() { + add(&mut result.get_list_by_path_mut(&j.1), &j.1, i.0 * j.0); + } + } // Apply recipe book let book = default_recipe_book().read(); @@ -290,28 +301,27 @@ impl TradePricing { result } - // TODO: Re-enable later - // fn random_item_impl(&self, good: Good, amount: f32) -> Option { - // if good == Good::Coin { - // Some(TradePricing::COIN_ITEM.into()) - // } else { - // let table = self.get_list(good); - // let upper = table.len(); - // let lower = table - // .iter() - // .enumerate() - // .find(|i| i.1.1 * amount >= 1.0) - // .map(|i| i.0) - // .unwrap_or(upper - 1); - // let index = (rand::random::() * ((upper - lower) as f32)).floor() as usize + lower; - // //.gen_range(lower..upper); - // table.get(index).map(|i| i.0.clone()) - // } - // } + fn random_item_impl(&self, good: Good, amount: f32) -> Option { + if good == Good::Coin { + Some(TradePricing::COIN_ITEM.into()) + } else { + let table = self.get_list(good); + let upper = table.len(); + let lower = table + .iter() + .enumerate() + .find(|i| i.1.1 * amount >= 1.0) + .map(|i| i.0) + .unwrap_or(upper - 1); + let index = (rand::random::() * ((upper - lower) as f32)).floor() as usize + lower; + //.gen_range(lower..upper); + table.get(index).map(|i| i.0.clone()) + } + } - // pub fn random_item(good: Good, amount: f32) -> Option { - // TRADE_PRICING.random_item_impl(good, amount) - // } + pub fn random_item(good: Good, amount: f32) -> Option { + TRADE_PRICING.random_item_impl(good, amount) + } pub fn get_material(item: &str) -> (Good, f32) { if item == TradePricing::COIN_ITEM { diff --git a/common/src/lottery.rs b/common/src/lottery.rs index 1e4851ae8e..83c9028c6f 100644 --- a/common/src/lottery.rs +++ b/common/src/lottery.rs @@ -26,7 +26,10 @@ // Cheese drop rate = 3/X = 29.6% // Coconut drop rate = 1/X = 9.85% -use crate::{assets::{self, AssetExt}, comp::{Body, Item}}; +use crate::{ + assets::{self, AssetExt}, + comp::{Body, Item}, +}; use rand::prelude::*; use serde::{de::DeserializeOwned, Deserialize, Serialize}; @@ -85,6 +88,7 @@ pub enum LootSpec { } impl LootSpec { + #[allow(unused_must_use)] pub fn to_item(&self, body: Option) -> Item { match self { Self::Item(item) => Item::new_from_asset_expect(&item), @@ -95,10 +99,14 @@ impl LootSpec { item.set_amount(quantity); item }, - Self::LootTable(table) => { - Lottery::::load_expect(&table).read().choose().to_item(body) - }, - Self::CreatureMaterial => body.map_or(Item::new_from_asset_expect("common.items.food.cheese"), |b| b.get_loot()), + Self::LootTable(table) => Lottery::::load_expect(&table) + .read() + .choose() + .to_item(body), + Self::CreatureMaterial => body.map_or( + Item::new_from_asset_expect("common.items.food.cheese"), + |b| b.get_loot(), + ), } } } diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 7b2fcf8bf5..f3a0c9a33e 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -18,7 +18,7 @@ use common::{ HealthSource, Inventory, Player, Poise, PoiseChange, PoiseSource, Pos, Stats, }, event::{EventBus, ServerEvent}, - lottery::{Lottery, LootSpec}, + lottery::{LootSpec, Lottery}, outcome::Outcome, resources::Time, rtsim::RtSimEntity, @@ -368,9 +368,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc Some(common::comp::Body::QuadrupedMedium(quadruped_medium)) => { match quadruped_medium.species { quadruped_medium::Species::Frostfang - | quadruped_medium::Species::Roshwalr => { - "common.loot_tables.animal_ice" - }, + | quadruped_medium::Species::Roshwalr => "common.loot_tables.animal_ice", _ => match rng.gen_range(0..4) { 0 => "common.loot_tables.food", 2 => "common.loot_tables.animal_parts", @@ -427,9 +425,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc Some(common::comp::Body::Dragon(_)) => "common.loot_tables.weapon_rare", Some(common::comp::Body::QuadrupedLow(quadruped_low)) => { match quadruped_low.species { - quadruped_low::Species::Maneater => { - "common.loot_tables.maneater" - }, + quadruped_low::Species::Maneater => "common.loot_tables.maneater", _ => match rng.gen_range(0..3) { 0 => "common.loot_tables.food", 1 => "common.loot_tables.animal_parts", diff --git a/world/src/site/dungeon/mod.rs b/world/src/site/dungeon/mod.rs index 9e7e85539c..1da4d165bc 100644 --- a/world/src/site/dungeon/mod.rs +++ b/world/src/site/dungeon/mod.rs @@ -552,54 +552,52 @@ impl Floor { { // Bad let chosen = match room.difficulty { - 0 => { - Lottery::::load_expect(match dynamic_rng.gen_range(0..4) { + 0 => Lottery::::load_expect( + match dynamic_rng.gen_range(0..4) { 0 => "common.loot_tables.humanoids", 1 => "common.loot_tables.armor_cloth", _ => "common.loot_tables.weapon_common", - }) - }, - 1 => { - Lottery::::load_expect(match dynamic_rng.gen_range(0..4) { + }, + ), + 1 => Lottery::::load_expect( + match dynamic_rng.gen_range(0..4) { 0 => "common.loot_tables.humanoids", 1 => "common.loot_tables.armor_light", _ => "common.loot_tables.weapon_uncommon", - }) - }, - 2 => { - Lottery::::load_expect(match dynamic_rng.gen_range(0..4) { + }, + ), + 2 => Lottery::::load_expect( + match dynamic_rng.gen_range(0..4) { 0 => "common.loot_tables.humanoids", 1 => "common.loot_tables.armor_heavy", _ => "common.loot_tables.weapon_rare", - }) - }, - 3 => { - Lottery::::load_expect(match dynamic_rng.gen_range(0..10) { + }, + ), + 3 => Lottery::::load_expect( + match dynamic_rng.gen_range(0..10) { 0 => "common.loot_tables.humanoids", 1 => "common.loot_tables.armor_heavy", 2 => "common.loot_tables.weapon_rare", _ => "common.loot_tables.cultists", - }) - }, - 4 => { - Lottery::::load_expect(match dynamic_rng.gen_range(0..6) { - 0 => "common.loot_tables.humanoids", - 1 => "common.loot_tables.armor_misc", - 2 => "common.loot_tables.weapon_rare", - _ => "common.loot_tables.cultists", - }) - }, - 5 => { - Lottery::::load_expect(match dynamic_rng.gen_range(0..5) { - 0 => "common.loot_tables.humanoids", - 1 => "common.loot_tables.armor_misc", - 2 => "common.loot_tables.weapon_rare", - _ => "common.loot_tables.cultists", - }) - }, - _ => Lottery::::load_expect( - "common.loot_tables.armor_misc", + }, ), + 4 => Lottery::::load_expect( + match dynamic_rng.gen_range(0..6) { + 0 => "common.loot_tables.humanoids", + 1 => "common.loot_tables.armor_misc", + 2 => "common.loot_tables.weapon_rare", + _ => "common.loot_tables.cultists", + }, + ), + 5 => Lottery::::load_expect( + match dynamic_rng.gen_range(0..5) { + 0 => "common.loot_tables.humanoids", + 1 => "common.loot_tables.armor_misc", + 2 => "common.loot_tables.weapon_rare", + _ => "common.loot_tables.cultists", + }, + ), + _ => Lottery::::load_expect("common.loot_tables.armor_misc"), }; let chosen = chosen.read(); let chosen = chosen.choose(); @@ -621,12 +619,11 @@ impl Floor { .with_level(dynamic_rng.gen_range((room.difficulty as f32).powf(1.25) + 3.0..(room.difficulty as f32).powf(1.5) + 4.0).round() as u16); let entity = match room.difficulty { 0 => { - let body = comp::Body::BipedSmall( - comp::biped_small::Body::random_with( + let body = + comp::Body::BipedSmall(comp::biped_small::Body::random_with( dynamic_rng, &comp::biped_small::Species::Gnarling, - ), - ); + )); entity .with_body(body) .with_name("Gnarling") @@ -653,12 +650,11 @@ impl Floor { )) }, 1 => { - let body = comp::Body::BipedSmall( - comp::biped_small::Body::random_with( + let body = + comp::Body::BipedSmall(comp::biped_small::Body::random_with( dynamic_rng, &comp::biped_small::Species::Adlet, - ), - ); + )); entity .with_body(body) .with_name("Adlet") @@ -669,9 +665,13 @@ impl Floor { .with_loot_drop(chosen.to_item(Some(body))) .with_main_tool(comp::Item::new_from_asset_expect( match dynamic_rng.gen_range(0..5) { - 0 => "common.items.npc_weapons.biped_small.adlet.adlet_bow", + 0 => { + "common.items.npc_weapons.biped_small.adlet.\ + adlet_bow" + }, 1 => { - "common.items.npc_weapons.biped_small.adlet.gnoll_staff" + "common.items.npc_weapons.biped_small.adlet.\ + gnoll_staff" }, _ => { "common.items.npc_weapons.biped_small.adlet.\ @@ -681,12 +681,11 @@ impl Floor { )) }, 2 => { - let body = comp::Body::BipedSmall( - comp::biped_small::Body::random_with( + let body = + comp::Body::BipedSmall(comp::biped_small::Body::random_with( dynamic_rng, &comp::biped_small::Species::Sahagin, - ), - ); + )); entity .with_body(body) .with_name("Sahagin") @@ -698,7 +697,8 @@ impl Floor { .with_main_tool(comp::Item::new_from_asset_expect( match dynamic_rng.gen_range(0..5) { 0 => { - "common.items.npc_weapons.biped_small.sahagin.adlet_bow" + "common.items.npc_weapons.biped_small.sahagin.\ + adlet_bow" }, 1 => { "common.items.npc_weapons.biped_small.sahagin.\ @@ -712,12 +712,11 @@ impl Floor { )) }, 3 => { - let body = comp::Body::BipedSmall( - comp::biped_small::Body::random_with( + let body = + comp::Body::BipedSmall(comp::biped_small::Body::random_with( dynamic_rng, &comp::biped_small::Species::Haniwa, - ), - ); + )); entity .with_body(body) .with_name("Haniwa") @@ -729,7 +728,8 @@ impl Floor { .with_main_tool(comp::Item::new_from_asset_expect( match dynamic_rng.gen_range(0..5) { 0 => { - "common.items.npc_weapons.biped_small.haniwa.adlet_bow" + "common.items.npc_weapons.biped_small.haniwa.\ + adlet_bow" }, 1 => { "common.items.npc_weapons.biped_small.haniwa.\ @@ -743,12 +743,11 @@ impl Floor { )) }, 4 => { - let body = comp::Body::BipedSmall( - comp::biped_small::Body::random_with( + let body = + comp::Body::BipedSmall(comp::biped_small::Body::random_with( dynamic_rng, &comp::biped_small::Species::Myrmidon, - ), - ); + )); entity .with_body(body) .with_name("Myrmidon") @@ -780,7 +779,9 @@ impl Floor { entity .with_body(body) .with_name("Cultist Warlock") - .with_loadout_config(loadout_builder::LoadoutConfig::Warlock) + .with_loadout_config( + loadout_builder::LoadoutConfig::Warlock, + ) .with_skillset_config( common::skillset_builder::SkillSetConfig::Warlock, ) @@ -848,9 +849,9 @@ impl Floor { 3 => Lottery::::load_expect( "common.loot_tables.weapon_rare", ), - 4 => Lottery::::load_expect( - "common.loot_tables.miniboss", - ), + 4 => { + Lottery::::load_expect("common.loot_tables.miniboss") + }, 5 => Lottery::::load_expect( match dynamic_rng.gen_range(0..3) { 0 => "common.loot_tables.mindflayer", @@ -907,12 +908,10 @@ impl Floor { ] }, 3 => { - let body = comp::Body::Golem( - comp::golem::Body::random_with( - dynamic_rng, - &comp::golem::Species::ClayGolem, - ), - ); + let body = comp::Body::Golem(comp::golem::Body::random_with( + dynamic_rng, + &comp::golem::Species::ClayGolem, + )); vec![ EntityInfo::at(tile_wcenter.map(|e| e as f32)) .with_body(body) @@ -1012,9 +1011,7 @@ impl Floor { 4 => Lottery::::load_expect( "common.loot_tables.weapon_rare", ), - 5 => Lottery::::load_expect( - "common.loot_tables.husk", - ), + 5 => Lottery::::load_expect("common.loot_tables.husk"), _ => Lottery::::load_expect( "common.loot_tables.armor_misc", ), @@ -1041,7 +1038,7 @@ impl Floor { comp::quadruped_medium::Body::random_with( dynamic_rng, &comp::quadruped_medium::Species::Bonerattler, - ) + ), ); vec![ EntityInfo::at(tile_wcenter.map(|e| e as f32)) @@ -1060,18 +1057,16 @@ impl Floor { ), ); entities.resize_with(6, || { - EntityInfo::at(tile_wcenter.map(|e| e as f32)) - .with_body(body) - .with_name("Hakulaq".to_string()) - .with_loot_drop(chosen.to_item(Some(body))) + EntityInfo::at(tile_wcenter.map(|e| e as f32)) + .with_body(body) + .with_name("Hakulaq".to_string()) + .with_loot_drop(chosen.to_item(Some(body))) }); entities }, 3 => { let mut entities = Vec::new(); - let body = comp::Body::Humanoid( - comp::humanoid::Body::random(), - ); + let body = comp::Body::Humanoid(comp::humanoid::Body::random()); entities.push( EntityInfo::at(tile_wcenter.map(|e| e as f32)) .with_body(body) @@ -1124,16 +1119,20 @@ impl Floor { 5 => { let mut entities = Vec::new(); entities.resize_with(10, || { - EntityInfo::at(tile_wcenter.map(|e| e as f32)) - .with_body(comp::Body::BipedSmall( - comp::biped_small::Body::random_with( - dynamic_rng, - &comp::biped_small::Species::Husk, - ), - )) - .with_name("Cultist Husk".to_string()) - .with_loot_drop(comp::Item::new_from_asset_expect("common.items.crafting_ing.stones")) - .with_loadout_config(loadout_builder::LoadoutConfig::Husk) + EntityInfo::at(tile_wcenter.map(|e| e as f32)) + .with_body(comp::Body::BipedSmall( + comp::biped_small::Body::random_with( + dynamic_rng, + &comp::biped_small::Species::Husk, + ), + )) + .with_name("Cultist Husk".to_string()) + .with_loot_drop(comp::Item::new_from_asset_expect( + "common.items.crafting_ing.stones", + )) + .with_loadout_config( + loadout_builder::LoadoutConfig::Husk, + ) }); entities },