mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed trading
This commit is contained in:
parent
bdbe6134f2
commit
ab2fca21cf
@ -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<dyn Error>> {
|
||||
|
||||
fn loot_table(loot_table: &str) -> Result<(), Box<dyn Error>> {
|
||||
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<dyn Error>> {
|
||||
|
||||
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", "", "", ""])?
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -383,12 +383,26 @@ fn loot_table(loot_table: &str) -> Result<(), Box<dyn Error>> {
|
||||
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\""),
|
||||
};
|
||||
|
@ -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",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -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::<LootSpec>::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::<LootSpec>::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::<LootSpec>::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",
|
||||
|
@ -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)
|
||||
|
@ -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<Vec<(f32, String)>, assets::RonLoader>;
|
||||
type Loader = assets::LoadFrom<Vec<(f32, LootSpec)>, assets::RonLoader>;
|
||||
|
||||
const EXTENSION: &'static str = "ron";
|
||||
}
|
||||
|
||||
impl From<Vec<(f32, String)>> for ProbabilityFile {
|
||||
fn from(content: Vec<(f32, String)>) -> ProbabilityFile { Self { content } }
|
||||
impl From<Vec<(f32, LootSpec)>> 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<String> {
|
||||
// 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::<f32>() * ((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<String> {
|
||||
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::<f32>() * ((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<String> {
|
||||
// TRADE_PRICING.random_item_impl(good, amount)
|
||||
// }
|
||||
pub fn random_item(good: Good, amount: f32) -> Option<String> {
|
||||
TRADE_PRICING.random_item_impl(good, amount)
|
||||
}
|
||||
|
||||
pub fn get_material(item: &str) -> (Good, f32) {
|
||||
if item == TradePricing::COIN_ITEM {
|
||||
|
@ -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<Body>) -> 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::<LootSpec>::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::<LootSpec>::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(),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -552,54 +552,52 @@ impl Floor {
|
||||
{
|
||||
// Bad
|
||||
let chosen = match room.difficulty {
|
||||
0 => {
|
||||
Lottery::<LootSpec>::load_expect(match dynamic_rng.gen_range(0..4) {
|
||||
0 => Lottery::<LootSpec>::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::<LootSpec>::load_expect(match dynamic_rng.gen_range(0..4) {
|
||||
},
|
||||
),
|
||||
1 => Lottery::<LootSpec>::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::<LootSpec>::load_expect(match dynamic_rng.gen_range(0..4) {
|
||||
},
|
||||
),
|
||||
2 => Lottery::<LootSpec>::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::<LootSpec>::load_expect(match dynamic_rng.gen_range(0..10) {
|
||||
},
|
||||
),
|
||||
3 => Lottery::<LootSpec>::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::<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.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::<LootSpec>::load_expect(
|
||||
"common.loot_tables.weapon_rare",
|
||||
),
|
||||
4 => Lottery::<LootSpec>::load_expect(
|
||||
"common.loot_tables.miniboss",
|
||||
),
|
||||
4 => {
|
||||
Lottery::<LootSpec>::load_expect("common.loot_tables.miniboss")
|
||||
},
|
||||
5 => Lottery::<LootSpec>::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::<LootSpec>::load_expect(
|
||||
"common.loot_tables.weapon_rare",
|
||||
),
|
||||
5 => Lottery::<LootSpec>::load_expect(
|
||||
"common.loot_tables.husk",
|
||||
),
|
||||
5 => Lottery::<LootSpec>::load_expect("common.loot_tables.husk"),
|
||||
_ => Lottery::<LootSpec>::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
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user