Consolidated loot tables by switching to CreatureMaterial where possible

This commit is contained in:
Sam 2021-03-30 11:10:17 -04:00
parent ab2fca21cf
commit 96b354c178
17 changed files with 70 additions and 84 deletions

View File

@ -2,13 +2,12 @@
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
(0.5,"common.loot_tables.animal_ice"),
(4,"common.loot_tables.animal_parts"),
(1,"common.loot_tables.armor_cloth"),
(0.01,"common.loot_tables.armor_heavy"),
(0.1,"common.loot_tables.armor_light"),
(0.1,"common.loot_tables.armor_misc"),
(0.5,"common.loot_tables.armor_nature"),
(4,"common.loot_tables.wild_animal"),
(1,"common.loot_tables.armor.armor_cloth"),
(0.01,"common.loot_tables.armor.armor_heavy"),
(0.1,"common.loot_tables.armor.armor_light"),
(0.1,"common.loot_tables.armor.armor_misc"),
(0.5,"common.loot_tables.armor.armor_nature"),
(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
@ -20,17 +19,14 @@ loot_tables: [
(1,"common.loot_tables.maneater"),
(0.0001,"common.loot_tables.mindflayer"),
(0.001,"common.loot_tables.miniboss"),
(0.05,"common.loot_tables.raptor"),
// 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
(0.2,"common.loot_tables.rocks"),
(1,"common.loot_tables.fallback"),
(0.04,"common.loot_tables.saurok"),
(0.02,"common.loot_tables.troll"),
(0.05,"common.loot_tables.villager"),
(1,"common.loot_tables.weapon_common"),
(0.008,"common.loot_tables.weapon_rare"),
(0.01,"common.loot_tables.weapon_uncommon"),
(0.01,"common.loot_tables.wendigo"),
// we probably want to include all the scattered scatter information
//(0.5,"common.cave_scatter"),
],

View File

@ -1,3 +0,0 @@
[
(2.0, Item("common.items.crafting_ing.leather_scraps")),
]

View File

@ -1,4 +0,0 @@
[
(2.0, Item("common.items.crafting_ing.raptor_feather")),
(1.0, Item("common.items.crafting_ing.leather_scraps")),
]

View File

@ -1,4 +0,0 @@
[
(1.0, Item("common.items.crafting_ing.leather_troll")),
(0.25, Item("common.items.crafting_ing.leather_scraps")),
]

View File

@ -1,3 +0,0 @@
[
(1.0, Item("common.items.crafting_ing.icy_fang")),
]

View File

@ -1,4 +1,4 @@
[
(2.0, Item("common.items.crafting_ing.icy_fang")),
[
(1.0, Item("common.items.crafting_ing.leather_scraps")),
]
(1.0, CreatureMaterial),
]

View File

@ -422,7 +422,9 @@ fn loot_table(loot_table: &str) -> Result<(), Box<dyn Error>> {
let mut path = ASSETS_PATH.clone();
path.push("common");
path.push("loot_tables");
path.push(loot_table);
for part in loot_table.split(".") {
path.push(part);
}
path.set_extension("ron");
let path_str = path.to_str().expect("File path not unicode?!");

View File

@ -584,8 +584,26 @@ impl Body {
}
}
pub fn get_loot(&self) -> Item {
pub fn get_material(&self) -> Item {
Item::new_from_asset_expect(match self {
Body::QuadrupedSmall(_) => "common.items.crafting_ing.leather_scraps",
Body::QuadrupedMedium(b) => match b.species {
quadruped_medium::Species::Frostfang | quadruped_medium::Species::Roshwalr => {
"common.items.crafting_ing.icy_fang"
},
_ => "common.items.crafting_ing.leather_scraps",
},
Body::Theropod(b) => match b.species {
theropod::Species::Sandraptor
| theropod::Species::Snowraptor
| theropod::Species::Woodraptor => "common.items.crafting_ing.raptor_feather",
_ => "common.items.crafting_ing.leather_scraps",
},
Body::BipedLarge(b) => match b.species {
biped_large::Species::Troll => "common.items.crafting_ing.leather_troll",
biped_large::Species::Wendigo => "common.items.crafting_ing.icy_fang",
_ => "common.items.food.cheese",
},
_ => "common.items.food.cheese",
})
}

View File

@ -604,10 +604,10 @@ impl Item {
chosen = Lottery::<LootSpec>::load_expect(match rng.gen_range(0..7) {
0 => "common.loot_tables.weapon_uncommon",
1 => "common.loot_tables.weapon_common",
2 => "common.loot_tables.armor_light",
3 => "common.loot_tables.armor_cloth",
4 => "common.loot_tables.armor_heavy",
_ => "common.loot_tables.armor_misc",
2 => "common.loot_tables.armor.armor_light",
3 => "common.loot_tables.armor.armor_cloth",
4 => "common.loot_tables.armor.armor_heavy",
_ => "common.loot_tables.armor.armor_misc",
})
.read();
return Some(chosen.choose().to_item(None));
@ -615,9 +615,9 @@ impl Item {
SpriteKind::ChestBurried => {
chosen = Lottery::<LootSpec>::load_expect(match rng.gen_range(0..7) {
1 => "common.loot_tables.weapon_common",
2 => "common.loot_tables.armor_light",
3 => "common.loot_tables.armor_cloth",
_ => "common.loot_tables.armor_misc",
2 => "common.loot_tables.armor.armor_light",
3 => "common.loot_tables.armor.armor_cloth",
_ => "common.loot_tables.armor.armor_misc",
})
.read();
return Some(chosen.choose().to_item(None));
@ -626,7 +626,7 @@ impl Item {
chosen = Lottery::<LootSpec>::load_expect(match rng.gen_range(0..5) {
0 => "common.loot_tables.crafting",
1 => "common.loot_tables.weapon_common",
2 => "common.loot_tables.armor_misc",
2 => "common.loot_tables.armor.armor_misc",
_ => "common.loot_tables.rocks",
})
.read();

View File

@ -105,7 +105,7 @@ impl LootSpec {
.to_item(body),
Self::CreatureMaterial => body.map_or(
Item::new_from_asset_expect("common.items.food.cheese"),
|b| b.get_loot(),
|b| b.get_material(),
),
}
}

View File

@ -1,9 +1,6 @@
use crate::{
client::Client,
comp::{
biped_large, quadruped_low, quadruped_medium, quadruped_small, skills::SkillGroupKind,
theropod, PhysicsState,
},
comp::{biped_large, quadruped_low, quadruped_small, skills::SkillGroupKind, PhysicsState},
rtsim::RtSim,
Server, SpawnPoint, StateExt,
};
@ -346,8 +343,8 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
Lottery::<LootSpec>::load_expect(match old_body {
Some(common::comp::Body::Humanoid(_)) => match rng.gen_range(0..4) {
0 => "common.loot_tables.humanoids",
1 => "common.loot_tables.armor_light",
2 => "common.loot_tables.armor_cloth",
1 => "common.loot_tables.armor.armor_light",
2 => "common.loot_tables.armor.armor_cloth",
3 => "common.loot_tables.weapon_common",
4 => "common.loots_tables.loot_table_armor_misc",
_ => "common.loot_tables.humanoids",
@ -360,21 +357,14 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
},
_ => match rng.gen_range(0..4) {
0 => "common.loot_tables.food",
2 => "common.loot_tables.animal_parts",
_ => "common.loot_tables.animal_parts",
2 => "common.loot_tables.wild_animal",
_ => "common.loot_tables.wild_animal",
},
}
},
Some(common::comp::Body::QuadrupedMedium(quadruped_medium)) => {
match quadruped_medium.species {
quadruped_medium::Species::Frostfang
| 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",
_ => "common.loot_tables.animal_parts",
},
}
Some(common::comp::Body::QuadrupedMedium(_)) => match rng.gen_range(0..4) {
0 => "common.loot_tables.food",
_ => "common.loot_tables.wild_animal",
},
Some(common::comp::Body::BirdMedium(_)) => match rng.gen_range(0..3) {
0 => "common.loot_tables.food",
@ -385,7 +375,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
Some(common::comp::Body::BipedLarge(biped_large)) => match biped_large.species {
biped_large::Species::Wendigo => match rng.gen_range(0..7) {
0 => "common.loot_tables.food",
1 => "common.loot_tables.wendigo",
1 => "common.loot_tables.wild_animal",
2 => "common.loot_tables.weapon_uncommon",
_ => "common.loot_tables.cave_large",
},
@ -393,42 +383,34 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
0 => "common.loot_tables.food",
1 => "common.loot_tables.cave_large",
2 => "common.loot_tables.weapon_uncommon",
_ => "common.loot_tables.troll",
_ => "common.loot_tables.wild_animal",
},
biped_large::Species::Occultsaurok
| biped_large::Species::Mightysaurok
| biped_large::Species::Slysaurok => "common.loot_tables.saurok",
_ => match rng.gen_range(0..4) {
0 => "common.loot_tables.food",
1 => "common.loot_tables.armor_nature",
1 => "common.loot_tables.armor.armor_nature",
_ => "common.loot_tables.cave_large",
},
},
Some(common::comp::Body::Golem(_)) => match rng.gen_range(0..9) {
0 => "common.loot_tables.food",
2 => "common.loot_tables.armor_light",
3 => "common.loot_tables.armor_heavy",
2 => "common.loot_tables.armor.armor_light",
3 => "common.loot_tables.armor.armor_heavy",
5 => "common.loot_tables.weapon_common",
6 => "common.loot_tables.weapon_uncommon",
7 => "common.loot_tables.weapon_rare",
_ => "common.loot_tables.fallback",
},
Some(common::comp::Body::Theropod(theropod)) => match theropod.species {
theropod::Species::Sandraptor
| theropod::Species::Snowraptor
| theropod::Species::Woodraptor => match rng.gen_range(0..3) {
0 => "common.loot_tables.raptor",
_ => "common.loot_tables.animal_parts",
},
_ => "common.loot_tables.animal_parts",
},
Some(common::comp::Body::Theropod(_)) => "common.loot_tables.wild_animal",
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",
_ => match rng.gen_range(0..3) {
0 => "common.loot_tables.food",
1 => "common.loot_tables.animal_parts",
1 => "common.loot_tables.wild_animal",
_ => "common.loot_tables.fallback",
},
}

View File

@ -555,28 +555,28 @@ impl Floor {
0 => Lottery::<LootSpec>::load_expect(
match dynamic_rng.gen_range(0..4) {
0 => "common.loot_tables.humanoids",
1 => "common.loot_tables.armor_cloth",
1 => "common.loot_tables.armor.armor_cloth",
_ => "common.loot_tables.weapon_common",
},
),
1 => Lottery::<LootSpec>::load_expect(
match dynamic_rng.gen_range(0..4) {
0 => "common.loot_tables.humanoids",
1 => "common.loot_tables.armor_light",
1 => "common.loot_tables.armor.armor_light",
_ => "common.loot_tables.weapon_uncommon",
},
),
2 => Lottery::<LootSpec>::load_expect(
match dynamic_rng.gen_range(0..4) {
0 => "common.loot_tables.humanoids",
1 => "common.loot_tables.armor_heavy",
1 => "common.loot_tables.armor.armor_heavy",
_ => "common.loot_tables.weapon_rare",
},
),
3 => Lottery::<LootSpec>::load_expect(
match dynamic_rng.gen_range(0..10) {
0 => "common.loot_tables.humanoids",
1 => "common.loot_tables.armor_heavy",
1 => "common.loot_tables.armor.armor_heavy",
2 => "common.loot_tables.weapon_rare",
_ => "common.loot_tables.cultists",
},
@ -584,7 +584,7 @@ impl Floor {
4 => Lottery::<LootSpec>::load_expect(
match dynamic_rng.gen_range(0..6) {
0 => "common.loot_tables.humanoids",
1 => "common.loot_tables.armor_misc",
1 => "common.loot_tables.armor.armor_misc",
2 => "common.loot_tables.weapon_rare",
_ => "common.loot_tables.cultists",
},
@ -592,12 +592,14 @@ impl Floor {
5 => Lottery::<LootSpec>::load_expect(
match dynamic_rng.gen_range(0..5) {
0 => "common.loot_tables.humanoids",
1 => "common.loot_tables.armor_misc",
1 => "common.loot_tables.armor.armor_misc",
2 => "common.loot_tables.weapon_rare",
_ => "common.loot_tables.cultists",
},
),
_ => Lottery::<LootSpec>::load_expect("common.loot_tables.armor_misc"),
_ => Lottery::<LootSpec>::load_expect(
"common.loot_tables.armor.armor_misc",
),
};
let chosen = chosen.read();
let chosen = chosen.choose();
@ -844,7 +846,7 @@ impl Floor {
"common.loot_tables.weapon_uncommon",
),
2 => Lottery::<LootSpec>::load_expect(
"common.loot_tables.armor_heavy",
"common.loot_tables.armor.armor_heavy",
),
3 => Lottery::<LootSpec>::load_expect(
"common.loot_tables.weapon_rare",
@ -859,7 +861,7 @@ impl Floor {
},
),
_ => Lottery::<LootSpec>::load_expect(
"common.loot_tables.armor_misc",
"common.loot_tables.armor.armor_misc",
),
};
let chosen = chosen.read();
@ -997,13 +999,13 @@ impl Floor {
if tile_pos == miniboss_spawn_tile && tile_wcenter.xy() == wpos2d {
let chosen = match room.difficulty {
0 => Lottery::<LootSpec>::load_expect(
"common.loot_tables.animal_parts",
"common.loot_tables.wild_animal",
),
1 => Lottery::<LootSpec>::load_expect(
"common.loot_tables.animal_parts",
"common.loot_tables.wild_animal",
),
2 => Lottery::<LootSpec>::load_expect(
"common.loot_tables.animal_parts",
"common.loot_tables.wild_animal",
),
3 => Lottery::<LootSpec>::load_expect(
"common.loot_tables.weapon_rare",
@ -1013,7 +1015,7 @@ impl Floor {
),
5 => Lottery::<LootSpec>::load_expect("common.loot_tables.husk"),
_ => Lottery::<LootSpec>::load_expect(
"common.loot_tables.armor_misc",
"common.loot_tables.armor.armor_misc",
),
};
let chosen = chosen.read();