Fixed trading

This commit is contained in:
Sam 2021-03-29 00:12:11 -04:00
parent bdbe6134f2
commit ab2fca21cf
9 changed files with 220 additions and 178 deletions

View File

@ -17,7 +17,7 @@ use veloren_common::{
ItemKind, ItemKind,
}, },
}, },
lottery::{Lottery, LootSpec}, lottery::{LootSpec, Lottery},
}; };
#[derive(StructOpt)] #[derive(StructOpt)]
@ -219,7 +219,13 @@ fn all_items() -> Result<(), Box<dyn Error>> {
fn loot_table(loot_table: &str) -> Result<(), Box<dyn Error>> { fn loot_table(loot_table: &str) -> Result<(), Box<dyn Error>> {
let mut wtr = csv::Writer::from_path("loot_table.csv")?; 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; let loot_table = "common.loot_tables.".to_owned() + loot_table;
@ -238,9 +244,19 @@ fn loot_table(loot_table: &str) -> Result<(), Box<dyn Error>> {
match item { match item {
LootSpec::Item(item) => wtr.write_record(&[&chance, "Item", 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::ItemQuantity(item, lower, upper) => wtr.write_record(&[
LootSpec::LootTable(table) => wtr.write_record(&[&chance, "LootTable", table, "", ""])?, &chance,
LootSpec::CreatureMaterial => wtr.write_record(&[&chance, "CreatureMaterial", "", "", ""])?, "Item",
item,
&lower.to_string(),
&upper.to_string(),
])?,
LootSpec::LootTable(table) => {
wtr.write_record(&[&chance, "LootTable", table, "", ""])?
},
LootSpec::CreatureMaterial => {
wtr.write_record(&[&chance, "CreatureMaterial", "", "", ""])?
},
} }
} }

View File

@ -383,12 +383,26 @@ fn loot_table(loot_table: &str) -> Result<(), Box<dyn Error>> {
for record in rdr.records() { for record in rdr.records() {
if let Ok(ref record) = record { if let Ok(ref record) = record {
let item = match record.get(headers["Kind"]).expect("No loot specifier") { 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())) { "Item" => {
LootSpec::ItemQuantity(record.get(headers["Item"]).expect("No item").to_string(), lower, upper) if let (Some(Ok(lower)), Some(Ok(upper))) = (
} else { record.get(headers["Lower Amount"]).map(|a| a.parse()),
LootSpec::Item(record.get(headers["Item"]).expect("No item").to_string()) 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, "CreatureMaterial" => LootSpec::CreatureMaterial,
_ => panic!("Loot specifier kind must be either \"Item\" or \"LootTable\""), _ => panic!("Loot specifier kind must be either \"Item\" or \"LootTable\""),
}; };

View File

@ -586,7 +586,7 @@ impl Body {
pub fn get_loot(&self) -> Item { pub fn get_loot(&self) -> Item {
Item::new_from_asset_expect(match self { Item::new_from_asset_expect(match self {
_ => "common.items.food.cheese" _ => "common.items.food.cheese",
}) })
} }
} }

View File

@ -13,7 +13,7 @@ use crate::{
CharacterAbility, CharacterAbility,
}, },
effect::Effect, effect::Effect,
lottery::{Lottery, LootSpec}, lottery::{LootSpec, Lottery},
recipe::RecipeInput, recipe::RecipeInput,
terrain::{Block, SpriteKind}, terrain::{Block, SpriteKind},
}; };
@ -610,7 +610,7 @@ impl Item {
_ => "common.loot_tables.armor_misc", _ => "common.loot_tables.armor_misc",
}) })
.read(); .read();
return Some(chosen.choose().to_item(None)) return Some(chosen.choose().to_item(None));
}, },
SpriteKind::ChestBurried => { SpriteKind::ChestBurried => {
chosen = Lottery::<LootSpec>::load_expect(match rng.gen_range(0..7) { chosen = Lottery::<LootSpec>::load_expect(match rng.gen_range(0..7) {
@ -620,7 +620,7 @@ impl Item {
_ => "common.loot_tables.armor_misc", _ => "common.loot_tables.armor_misc",
}) })
.read(); .read();
return Some(chosen.choose().to_item(None)) return Some(chosen.choose().to_item(None));
}, },
SpriteKind::Mud => { SpriteKind::Mud => {
chosen = Lottery::<LootSpec>::load_expect(match rng.gen_range(0..5) { chosen = Lottery::<LootSpec>::load_expect(match rng.gen_range(0..5) {
@ -630,7 +630,7 @@ impl Item {
_ => "common.loot_tables.rocks", _ => "common.loot_tables.rocks",
}) })
.read(); .read();
return Some(chosen.choose().to_item(None)) return Some(chosen.choose().to_item(None));
}, },
SpriteKind::Crate => { SpriteKind::Crate => {
chosen = Lottery::<LootSpec>::load_expect(match rng.gen_range(0..4) { chosen = Lottery::<LootSpec>::load_expect(match rng.gen_range(0..4) {
@ -638,7 +638,7 @@ impl Item {
_ => "common.loot_tables.food", _ => "common.loot_tables.food",
}) })
.read(); .read();
return Some(chosen.choose().to_item(None)) return Some(chosen.choose().to_item(None));
}, },
SpriteKind::Beehive => "common.items.crafting_ing.honey", SpriteKind::Beehive => "common.items.crafting_ing.honey",

View File

@ -568,19 +568,18 @@ impl LoadoutBuilder {
.unwrap_or_default() .unwrap_or_default()
/ 10.0; / 10.0;
for s in backpack.slots_mut() { for s in backpack.slots_mut() {
// TODO: Re-implement later if coins > 0 {
// if coins > 0 { let mut coin_item =
// let mut coin_item = Item::new_from_asset_expect("common.items.utility.coins");
// Item::new_from_asset_expect("common.items.utility.coins"); coin_item
// coin_item .set_amount(coins)
// .set_amount(coins) .expect("coins should be stackable");
// .expect("coins should be stackable"); *s = Some(coin_item);
// *s = Some(coin_item); coins = 0;
// coins = 0; } else if let Some(item_id) = TradePricing::random_item(Good::Armor, armor)
// } else if let Some(item_id) = TradePricing::random_item(Good::Armor, armor) {
// { *s = Some(Item::new_from_asset_expect(&item_id));
// *s = Some(Item::new_from_asset_expect(&item_id)); }
// }
} }
let mut bag1 = Item::new_from_asset_expect( let mut bag1 = Item::new_from_asset_expect(
"common.items.armor.misc.bag.reliable_backpack", "common.items.armor.misc.bag.reliable_backpack",
@ -592,9 +591,9 @@ impl LoadoutBuilder {
.unwrap_or_default() .unwrap_or_default()
/ 10.0; / 10.0;
for i in bag1.slots_mut() { for i in bag1.slots_mut() {
// if let Some(item_id) = TradePricing::random_item(Good::Tools, weapon) { if let Some(item_id) = TradePricing::random_item(Good::Tools, weapon) {
// *i = Some(Item::new_from_asset_expect(&item_id)); *i = Some(Item::new_from_asset_expect(&item_id));
// } }
} }
let mut bag2 = Item::new_from_asset_expect( let mut bag2 = Item::new_from_asset_expect(
"common.items.armor.misc.bag.reliable_backpack", "common.items.armor.misc.bag.reliable_backpack",
@ -606,11 +605,11 @@ impl LoadoutBuilder {
.unwrap_or_default() .unwrap_or_default()
/ 10.0; / 10.0;
for i in bag2.slots_mut() { for i in bag2.slots_mut() {
// if let Some(item_id) = if let Some(item_id) =
// TradePricing::random_item(Good::Ingredients, ingredients) TradePricing::random_item(Good::Ingredients, ingredients)
// { {
// *i = Some(Item::new_from_asset_expect(&item_id)); *i = Some(Item::new_from_asset_expect(&item_id));
// } }
} }
let mut bag3 = Item::new_from_asset_expect( let mut bag3 = Item::new_from_asset_expect(
"common.items.armor.misc.bag.reliable_backpack", "common.items.armor.misc.bag.reliable_backpack",
@ -622,9 +621,9 @@ impl LoadoutBuilder {
.unwrap_or_default() .unwrap_or_default()
/ 10.0; / 10.0;
for i in bag3.slots_mut() { for i in bag3.slots_mut() {
// if let Some(item_id) = TradePricing::random_item(Good::Food, food) { if let Some(item_id) = TradePricing::random_item(Good::Food, food) {
// *i = Some(Item::new_from_asset_expect(&item_id)); *i = Some(Item::new_from_asset_expect(&item_id));
// } }
} }
let mut bag4 = Item::new_from_asset_expect( let mut bag4 = Item::new_from_asset_expect(
"common.items.armor.misc.bag.reliable_backpack", "common.items.armor.misc.bag.reliable_backpack",
@ -636,9 +635,9 @@ impl LoadoutBuilder {
.unwrap_or_default() .unwrap_or_default()
/ 10.0; / 10.0;
for i in bag4.slots_mut() { for i in bag4.slots_mut() {
// if let Some(item_id) = TradePricing::random_item(Good::Potions, potions) { if let Some(item_id) = TradePricing::random_item(Good::Potions, potions) {
// *i = Some(Item::new_from_asset_expect(&item_id)); *i = Some(Item::new_from_asset_expect(&item_id));
// } }
} }
LoadoutBuilder::new() LoadoutBuilder::new()
.active_item(active_item) .active_item(active_item)

View File

@ -1,5 +1,6 @@
use crate::{ use crate::{
assets::{self, AssetExt}, assets::{self, AssetExt},
lottery::LootSpec,
recipe::{default_recipe_book, RecipeInput}, recipe::{default_recipe_book, RecipeInput},
trade::Good, trade::Good,
}; };
@ -42,13 +43,24 @@ struct ProbabilityFile {
} }
impl assets::Asset for ProbabilityFile { impl assets::Asset for ProbabilityFile {
type Loader = assets::LoadFrom<Vec<(f32, String)>, assets::RonLoader>; type Loader = assets::LoadFrom<Vec<(f32, LootSpec)>, assets::RonLoader>;
const EXTENSION: &'static str = "ron"; const EXTENSION: &'static str = "ron";
} }
impl From<Vec<(f32, String)>> for ProbabilityFile { impl From<Vec<(f32, LootSpec)>> for ProbabilityFile {
fn from(content: Vec<(f32, String)>) -> ProbabilityFile { Self { content } } 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)] #[derive(Debug, Deserialize)]
@ -184,16 +196,15 @@ impl TradePricing {
let mut result = TradePricing::default(); let mut result = TradePricing::default();
let files = TradingPriceFile::load_expect("common.item_price_calculation"); let files = TradingPriceFile::load_expect("common.item_price_calculation");
let contents = files.read(); let contents = files.read();
// TODO: Re-enable this for i in contents.loot_tables.iter() {
// for i in contents.loot_tables.iter() { if PRICING_DEBUG {
// if PRICING_DEBUG { info!(?i);
// info!(?i); }
// } let loot = ProbabilityFile::load_expect(&i.1);
// let loot = ProbabilityFile::load_expect(&i.1); for j in loot.read().content.iter() {
// for j in loot.read().content.iter() { add(&mut result.get_list_by_path_mut(&j.1), &j.1, i.0 * j.0);
// add(&mut result.get_list_by_path_mut(&j.1), &j.1, i.0 * j.0); }
// } }
// }
// Apply recipe book // Apply recipe book
let book = default_recipe_book().read(); let book = default_recipe_book().read();
@ -290,28 +301,27 @@ impl TradePricing {
result result
} }
// TODO: Re-enable later fn random_item_impl(&self, good: Good, amount: f32) -> Option<String> {
// fn random_item_impl(&self, good: Good, amount: f32) -> Option<String> { if good == Good::Coin {
// if good == Good::Coin { Some(TradePricing::COIN_ITEM.into())
// Some(TradePricing::COIN_ITEM.into()) } else {
// } else { let table = self.get_list(good);
// let table = self.get_list(good); let upper = table.len();
// let upper = table.len(); let lower = table
// let lower = table .iter()
// .iter() .enumerate()
// .enumerate() .find(|i| i.1.1 * amount >= 1.0)
// .find(|i| i.1.1 * amount >= 1.0) .map(|i| i.0)
// .map(|i| i.0) .unwrap_or(upper - 1);
// .unwrap_or(upper - 1); let index = (rand::random::<f32>() * ((upper - lower) as f32)).floor() as usize + lower;
// let index = (rand::random::<f32>() * ((upper - lower) as f32)).floor() as usize + lower; //.gen_range(lower..upper);
// //.gen_range(lower..upper); table.get(index).map(|i| i.0.clone())
// table.get(index).map(|i| i.0.clone()) }
// } }
// }
// pub fn random_item(good: Good, amount: f32) -> Option<String> { pub fn random_item(good: Good, amount: f32) -> Option<String> {
// TRADE_PRICING.random_item_impl(good, amount) TRADE_PRICING.random_item_impl(good, amount)
// } }
pub fn get_material(item: &str) -> (Good, f32) { pub fn get_material(item: &str) -> (Good, f32) {
if item == TradePricing::COIN_ITEM { if item == TradePricing::COIN_ITEM {

View File

@ -26,7 +26,10 @@
// Cheese drop rate = 3/X = 29.6% // Cheese drop rate = 3/X = 29.6%
// Coconut drop rate = 1/X = 9.85% // 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 rand::prelude::*;
use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde::{de::DeserializeOwned, Deserialize, Serialize};
@ -85,6 +88,7 @@ pub enum LootSpec {
} }
impl LootSpec { impl LootSpec {
#[allow(unused_must_use)]
pub fn to_item(&self, body: Option<Body>) -> Item { pub fn to_item(&self, body: Option<Body>) -> Item {
match self { match self {
Self::Item(item) => Item::new_from_asset_expect(&item), Self::Item(item) => Item::new_from_asset_expect(&item),
@ -95,10 +99,14 @@ impl LootSpec {
item.set_amount(quantity); item.set_amount(quantity);
item item
}, },
Self::LootTable(table) => { Self::LootTable(table) => Lottery::<LootSpec>::load_expect(&table)
Lottery::<LootSpec>::load_expect(&table).read().choose().to_item(body) .read()
}, .choose()
Self::CreatureMaterial => body.map_or(Item::new_from_asset_expect("common.items.food.cheese"), |b| b.get_loot()), .to_item(body),
Self::CreatureMaterial => body.map_or(
Item::new_from_asset_expect("common.items.food.cheese"),
|b| b.get_loot(),
),
} }
} }
} }

View File

@ -18,7 +18,7 @@ use common::{
HealthSource, Inventory, Player, Poise, PoiseChange, PoiseSource, Pos, Stats, HealthSource, Inventory, Player, Poise, PoiseChange, PoiseSource, Pos, Stats,
}, },
event::{EventBus, ServerEvent}, event::{EventBus, ServerEvent},
lottery::{Lottery, LootSpec}, lottery::{LootSpec, Lottery},
outcome::Outcome, outcome::Outcome,
resources::Time, resources::Time,
rtsim::RtSimEntity, rtsim::RtSimEntity,
@ -368,9 +368,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
Some(common::comp::Body::QuadrupedMedium(quadruped_medium)) => { Some(common::comp::Body::QuadrupedMedium(quadruped_medium)) => {
match quadruped_medium.species { match quadruped_medium.species {
quadruped_medium::Species::Frostfang quadruped_medium::Species::Frostfang
| quadruped_medium::Species::Roshwalr => { | quadruped_medium::Species::Roshwalr => "common.loot_tables.animal_ice",
"common.loot_tables.animal_ice"
},
_ => match rng.gen_range(0..4) { _ => match rng.gen_range(0..4) {
0 => "common.loot_tables.food", 0 => "common.loot_tables.food",
2 => "common.loot_tables.animal_parts", 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::Dragon(_)) => "common.loot_tables.weapon_rare",
Some(common::comp::Body::QuadrupedLow(quadruped_low)) => { Some(common::comp::Body::QuadrupedLow(quadruped_low)) => {
match quadruped_low.species { match quadruped_low.species {
quadruped_low::Species::Maneater => { quadruped_low::Species::Maneater => "common.loot_tables.maneater",
"common.loot_tables.maneater"
},
_ => match rng.gen_range(0..3) { _ => match rng.gen_range(0..3) {
0 => "common.loot_tables.food", 0 => "common.loot_tables.food",
1 => "common.loot_tables.animal_parts", 1 => "common.loot_tables.animal_parts",

View File

@ -552,54 +552,52 @@ impl Floor {
{ {
// Bad // Bad
let chosen = match room.difficulty { let chosen = match room.difficulty {
0 => { 0 => Lottery::<LootSpec>::load_expect(
Lottery::<LootSpec>::load_expect(match dynamic_rng.gen_range(0..4) { match dynamic_rng.gen_range(0..4) {
0 => "common.loot_tables.humanoids", 0 => "common.loot_tables.humanoids",
1 => "common.loot_tables.armor_cloth", 1 => "common.loot_tables.armor_cloth",
_ => "common.loot_tables.weapon_common", _ => "common.loot_tables.weapon_common",
}) },
}, ),
1 => { 1 => Lottery::<LootSpec>::load_expect(
Lottery::<LootSpec>::load_expect(match dynamic_rng.gen_range(0..4) { match dynamic_rng.gen_range(0..4) {
0 => "common.loot_tables.humanoids", 0 => "common.loot_tables.humanoids",
1 => "common.loot_tables.armor_light", 1 => "common.loot_tables.armor_light",
_ => "common.loot_tables.weapon_uncommon", _ => "common.loot_tables.weapon_uncommon",
}) },
}, ),
2 => { 2 => Lottery::<LootSpec>::load_expect(
Lottery::<LootSpec>::load_expect(match dynamic_rng.gen_range(0..4) { match dynamic_rng.gen_range(0..4) {
0 => "common.loot_tables.humanoids", 0 => "common.loot_tables.humanoids",
1 => "common.loot_tables.armor_heavy", 1 => "common.loot_tables.armor_heavy",
_ => "common.loot_tables.weapon_rare", _ => "common.loot_tables.weapon_rare",
}) },
}, ),
3 => { 3 => Lottery::<LootSpec>::load_expect(
Lottery::<LootSpec>::load_expect(match dynamic_rng.gen_range(0..10) { match dynamic_rng.gen_range(0..10) {
0 => "common.loot_tables.humanoids", 0 => "common.loot_tables.humanoids",
1 => "common.loot_tables.armor_heavy", 1 => "common.loot_tables.armor_heavy",
2 => "common.loot_tables.weapon_rare", 2 => "common.loot_tables.weapon_rare",
_ => "common.loot_tables.cultists", _ => "common.loot_tables.cultists",
}) },
},
4 => {
Lottery::<LootSpec>::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::<LootSpec>::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::<LootSpec>::load_expect(
"common.loot_tables.armor_misc",
), ),
4 => Lottery::<LootSpec>::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::<LootSpec>::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::<LootSpec>::load_expect("common.loot_tables.armor_misc"),
}; };
let chosen = chosen.read(); let chosen = chosen.read();
let chosen = chosen.choose(); 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); .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 { let entity = match room.difficulty {
0 => { 0 => {
let body = comp::Body::BipedSmall( let body =
comp::biped_small::Body::random_with( comp::Body::BipedSmall(comp::biped_small::Body::random_with(
dynamic_rng, dynamic_rng,
&comp::biped_small::Species::Gnarling, &comp::biped_small::Species::Gnarling,
), ));
);
entity entity
.with_body(body) .with_body(body)
.with_name("Gnarling") .with_name("Gnarling")
@ -653,12 +650,11 @@ impl Floor {
)) ))
}, },
1 => { 1 => {
let body = comp::Body::BipedSmall( let body =
comp::biped_small::Body::random_with( comp::Body::BipedSmall(comp::biped_small::Body::random_with(
dynamic_rng, dynamic_rng,
&comp::biped_small::Species::Adlet, &comp::biped_small::Species::Adlet,
), ));
);
entity entity
.with_body(body) .with_body(body)
.with_name("Adlet") .with_name("Adlet")
@ -669,9 +665,13 @@ impl Floor {
.with_loot_drop(chosen.to_item(Some(body))) .with_loot_drop(chosen.to_item(Some(body)))
.with_main_tool(comp::Item::new_from_asset_expect( .with_main_tool(comp::Item::new_from_asset_expect(
match dynamic_rng.gen_range(0..5) { 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 => { 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.\ "common.items.npc_weapons.biped_small.adlet.\
@ -681,12 +681,11 @@ impl Floor {
)) ))
}, },
2 => { 2 => {
let body = comp::Body::BipedSmall( let body =
comp::biped_small::Body::random_with( comp::Body::BipedSmall(comp::biped_small::Body::random_with(
dynamic_rng, dynamic_rng,
&comp::biped_small::Species::Sahagin, &comp::biped_small::Species::Sahagin,
), ));
);
entity entity
.with_body(body) .with_body(body)
.with_name("Sahagin") .with_name("Sahagin")
@ -698,7 +697,8 @@ impl Floor {
.with_main_tool(comp::Item::new_from_asset_expect( .with_main_tool(comp::Item::new_from_asset_expect(
match dynamic_rng.gen_range(0..5) { match dynamic_rng.gen_range(0..5) {
0 => { 0 => {
"common.items.npc_weapons.biped_small.sahagin.adlet_bow" "common.items.npc_weapons.biped_small.sahagin.\
adlet_bow"
}, },
1 => { 1 => {
"common.items.npc_weapons.biped_small.sahagin.\ "common.items.npc_weapons.biped_small.sahagin.\
@ -712,12 +712,11 @@ impl Floor {
)) ))
}, },
3 => { 3 => {
let body = comp::Body::BipedSmall( let body =
comp::biped_small::Body::random_with( comp::Body::BipedSmall(comp::biped_small::Body::random_with(
dynamic_rng, dynamic_rng,
&comp::biped_small::Species::Haniwa, &comp::biped_small::Species::Haniwa,
), ));
);
entity entity
.with_body(body) .with_body(body)
.with_name("Haniwa") .with_name("Haniwa")
@ -729,7 +728,8 @@ impl Floor {
.with_main_tool(comp::Item::new_from_asset_expect( .with_main_tool(comp::Item::new_from_asset_expect(
match dynamic_rng.gen_range(0..5) { match dynamic_rng.gen_range(0..5) {
0 => { 0 => {
"common.items.npc_weapons.biped_small.haniwa.adlet_bow" "common.items.npc_weapons.biped_small.haniwa.\
adlet_bow"
}, },
1 => { 1 => {
"common.items.npc_weapons.biped_small.haniwa.\ "common.items.npc_weapons.biped_small.haniwa.\
@ -743,12 +743,11 @@ impl Floor {
)) ))
}, },
4 => { 4 => {
let body = comp::Body::BipedSmall( let body =
comp::biped_small::Body::random_with( comp::Body::BipedSmall(comp::biped_small::Body::random_with(
dynamic_rng, dynamic_rng,
&comp::biped_small::Species::Myrmidon, &comp::biped_small::Species::Myrmidon,
), ));
);
entity entity
.with_body(body) .with_body(body)
.with_name("Myrmidon") .with_name("Myrmidon")
@ -780,7 +779,9 @@ impl Floor {
entity entity
.with_body(body) .with_body(body)
.with_name("Cultist Warlock") .with_name("Cultist Warlock")
.with_loadout_config(loadout_builder::LoadoutConfig::Warlock) .with_loadout_config(
loadout_builder::LoadoutConfig::Warlock,
)
.with_skillset_config( .with_skillset_config(
common::skillset_builder::SkillSetConfig::Warlock, common::skillset_builder::SkillSetConfig::Warlock,
) )
@ -848,9 +849,9 @@ impl Floor {
3 => Lottery::<LootSpec>::load_expect( 3 => Lottery::<LootSpec>::load_expect(
"common.loot_tables.weapon_rare", "common.loot_tables.weapon_rare",
), ),
4 => Lottery::<LootSpec>::load_expect( 4 => {
"common.loot_tables.miniboss", Lottery::<LootSpec>::load_expect("common.loot_tables.miniboss")
), },
5 => Lottery::<LootSpec>::load_expect( 5 => Lottery::<LootSpec>::load_expect(
match dynamic_rng.gen_range(0..3) { match dynamic_rng.gen_range(0..3) {
0 => "common.loot_tables.mindflayer", 0 => "common.loot_tables.mindflayer",
@ -907,12 +908,10 @@ impl Floor {
] ]
}, },
3 => { 3 => {
let body = comp::Body::Golem( let body = comp::Body::Golem(comp::golem::Body::random_with(
comp::golem::Body::random_with( dynamic_rng,
dynamic_rng, &comp::golem::Species::ClayGolem,
&comp::golem::Species::ClayGolem, ));
),
);
vec![ vec![
EntityInfo::at(tile_wcenter.map(|e| e as f32)) EntityInfo::at(tile_wcenter.map(|e| e as f32))
.with_body(body) .with_body(body)
@ -1012,9 +1011,7 @@ impl Floor {
4 => Lottery::<LootSpec>::load_expect( 4 => Lottery::<LootSpec>::load_expect(
"common.loot_tables.weapon_rare", "common.loot_tables.weapon_rare",
), ),
5 => Lottery::<LootSpec>::load_expect( 5 => Lottery::<LootSpec>::load_expect("common.loot_tables.husk"),
"common.loot_tables.husk",
),
_ => Lottery::<LootSpec>::load_expect( _ => Lottery::<LootSpec>::load_expect(
"common.loot_tables.armor_misc", "common.loot_tables.armor_misc",
), ),
@ -1041,7 +1038,7 @@ impl Floor {
comp::quadruped_medium::Body::random_with( comp::quadruped_medium::Body::random_with(
dynamic_rng, dynamic_rng,
&comp::quadruped_medium::Species::Bonerattler, &comp::quadruped_medium::Species::Bonerattler,
) ),
); );
vec![ vec![
EntityInfo::at(tile_wcenter.map(|e| e as f32)) EntityInfo::at(tile_wcenter.map(|e| e as f32))
@ -1060,18 +1057,16 @@ impl Floor {
), ),
); );
entities.resize_with(6, || { entities.resize_with(6, || {
EntityInfo::at(tile_wcenter.map(|e| e as f32)) EntityInfo::at(tile_wcenter.map(|e| e as f32))
.with_body(body) .with_body(body)
.with_name("Hakulaq".to_string()) .with_name("Hakulaq".to_string())
.with_loot_drop(chosen.to_item(Some(body))) .with_loot_drop(chosen.to_item(Some(body)))
}); });
entities entities
}, },
3 => { 3 => {
let mut entities = Vec::new(); let mut entities = Vec::new();
let body = comp::Body::Humanoid( let body = comp::Body::Humanoid(comp::humanoid::Body::random());
comp::humanoid::Body::random(),
);
entities.push( entities.push(
EntityInfo::at(tile_wcenter.map(|e| e as f32)) EntityInfo::at(tile_wcenter.map(|e| e as f32))
.with_body(body) .with_body(body)
@ -1124,16 +1119,20 @@ impl Floor {
5 => { 5 => {
let mut entities = Vec::new(); let mut entities = Vec::new();
entities.resize_with(10, || { entities.resize_with(10, || {
EntityInfo::at(tile_wcenter.map(|e| e as f32)) EntityInfo::at(tile_wcenter.map(|e| e as f32))
.with_body(comp::Body::BipedSmall( .with_body(comp::Body::BipedSmall(
comp::biped_small::Body::random_with( comp::biped_small::Body::random_with(
dynamic_rng, dynamic_rng,
&comp::biped_small::Species::Husk, &comp::biped_small::Species::Husk,
), ),
)) ))
.with_name("Cultist Husk".to_string()) .with_name("Cultist Husk".to_string())
.with_loot_drop(comp::Item::new_from_asset_expect("common.items.crafting_ing.stones")) .with_loot_drop(comp::Item::new_from_asset_expect(
.with_loadout_config(loadout_builder::LoadoutConfig::Husk) "common.items.crafting_ing.stones",
))
.with_loadout_config(
loadout_builder::LoadoutConfig::Husk,
)
}); });
entities entities
}, },