From 96b354c178027d1c3e91045f07dcb05da3e61f91 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 30 Mar 2021 11:10:17 -0400 Subject: [PATCH] Consolidated loot tables by switching to CreatureMaterial where possible --- assets/common/item_price_calculation.ron | 16 +++---- assets/common/loot_tables/animal_parts.ron | 3 -- .../loot_tables/{ => armor}/armor_cloth.ron | 0 .../loot_tables/{ => armor}/armor_heavy.ron | 0 .../loot_tables/{ => armor}/armor_light.ron | 0 .../loot_tables/{ => armor}/armor_misc.ron | 0 .../loot_tables/{ => armor}/armor_nature.ron | 0 assets/common/loot_tables/raptor.ron | 4 -- assets/common/loot_tables/troll.ron | 4 -- assets/common/loot_tables/wendigo.ron | 3 -- .../{animal_ice.ron => wild_animal.ron} | 6 +-- common/src/bin/csv_import/main.rs | 4 +- common/src/comp/body.rs | 20 +++++++- common/src/comp/inventory/item/mod.rs | 16 +++---- common/src/lottery.rs | 2 +- server/src/events/entity_manipulation.rs | 48 ++++++------------- world/src/site/dungeon/mod.rs | 28 ++++++----- 17 files changed, 70 insertions(+), 84 deletions(-) delete mode 100644 assets/common/loot_tables/animal_parts.ron rename assets/common/loot_tables/{ => armor}/armor_cloth.ron (100%) rename assets/common/loot_tables/{ => armor}/armor_heavy.ron (100%) rename assets/common/loot_tables/{ => armor}/armor_light.ron (100%) rename assets/common/loot_tables/{ => armor}/armor_misc.ron (100%) rename assets/common/loot_tables/{ => armor}/armor_nature.ron (100%) delete mode 100644 assets/common/loot_tables/raptor.ron delete mode 100644 assets/common/loot_tables/troll.ron delete mode 100644 assets/common/loot_tables/wendigo.ron rename assets/common/loot_tables/{animal_ice.ron => wild_animal.ron} (51%) diff --git a/assets/common/item_price_calculation.ron b/assets/common/item_price_calculation.ron index 0cb4c3be87..6f071e774d 100644 --- a/assets/common/item_price_calculation.ron +++ b/assets/common/item_price_calculation.ron @@ -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"), ], diff --git a/assets/common/loot_tables/animal_parts.ron b/assets/common/loot_tables/animal_parts.ron deleted file mode 100644 index 38b242b969..0000000000 --- a/assets/common/loot_tables/animal_parts.ron +++ /dev/null @@ -1,3 +0,0 @@ -[ - (2.0, Item("common.items.crafting_ing.leather_scraps")), -] diff --git a/assets/common/loot_tables/armor_cloth.ron b/assets/common/loot_tables/armor/armor_cloth.ron similarity index 100% rename from assets/common/loot_tables/armor_cloth.ron rename to assets/common/loot_tables/armor/armor_cloth.ron diff --git a/assets/common/loot_tables/armor_heavy.ron b/assets/common/loot_tables/armor/armor_heavy.ron similarity index 100% rename from assets/common/loot_tables/armor_heavy.ron rename to assets/common/loot_tables/armor/armor_heavy.ron diff --git a/assets/common/loot_tables/armor_light.ron b/assets/common/loot_tables/armor/armor_light.ron similarity index 100% rename from assets/common/loot_tables/armor_light.ron rename to assets/common/loot_tables/armor/armor_light.ron diff --git a/assets/common/loot_tables/armor_misc.ron b/assets/common/loot_tables/armor/armor_misc.ron similarity index 100% rename from assets/common/loot_tables/armor_misc.ron rename to assets/common/loot_tables/armor/armor_misc.ron diff --git a/assets/common/loot_tables/armor_nature.ron b/assets/common/loot_tables/armor/armor_nature.ron similarity index 100% rename from assets/common/loot_tables/armor_nature.ron rename to assets/common/loot_tables/armor/armor_nature.ron diff --git a/assets/common/loot_tables/raptor.ron b/assets/common/loot_tables/raptor.ron deleted file mode 100644 index 5cb6de2720..0000000000 --- a/assets/common/loot_tables/raptor.ron +++ /dev/null @@ -1,4 +0,0 @@ -[ - (2.0, Item("common.items.crafting_ing.raptor_feather")), - (1.0, Item("common.items.crafting_ing.leather_scraps")), -] \ No newline at end of file diff --git a/assets/common/loot_tables/troll.ron b/assets/common/loot_tables/troll.ron deleted file mode 100644 index 6e758cd219..0000000000 --- a/assets/common/loot_tables/troll.ron +++ /dev/null @@ -1,4 +0,0 @@ -[ - (1.0, Item("common.items.crafting_ing.leather_troll")), - (0.25, Item("common.items.crafting_ing.leather_scraps")), -] \ No newline at end of file diff --git a/assets/common/loot_tables/wendigo.ron b/assets/common/loot_tables/wendigo.ron deleted file mode 100644 index 6a47d4575b..0000000000 --- a/assets/common/loot_tables/wendigo.ron +++ /dev/null @@ -1,3 +0,0 @@ -[ - (1.0, Item("common.items.crafting_ing.icy_fang")), -] \ No newline at end of file diff --git a/assets/common/loot_tables/animal_ice.ron b/assets/common/loot_tables/wild_animal.ron similarity index 51% rename from assets/common/loot_tables/animal_ice.ron rename to assets/common/loot_tables/wild_animal.ron index e9ac2d3b94..97b29abb2c 100644 --- a/assets/common/loot_tables/animal_ice.ron +++ b/assets/common/loot_tables/wild_animal.ron @@ -1,4 +1,4 @@ -[ - (2.0, Item("common.items.crafting_ing.icy_fang")), +[ (1.0, Item("common.items.crafting_ing.leather_scraps")), -] \ No newline at end of file + (1.0, CreatureMaterial), +] diff --git a/common/src/bin/csv_import/main.rs b/common/src/bin/csv_import/main.rs index 8efd36c5d8..d66e59cdb8 100644 --- a/common/src/bin/csv_import/main.rs +++ b/common/src/bin/csv_import/main.rs @@ -422,7 +422,9 @@ fn loot_table(loot_table: &str) -> Result<(), Box> { 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?!"); diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index 9a4c6a00b5..5abf28e23d 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -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", }) } diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index da355662a5..44ba29a281 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -604,10 +604,10 @@ impl Item { chosen = Lottery::::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::::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::::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(); diff --git a/common/src/lottery.rs b/common/src/lottery.rs index 83c9028c6f..ef82002bb4 100644 --- a/common/src/lottery.rs +++ b/common/src/lottery.rs @@ -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(), ), } } diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index f3a0c9a33e..697a6db940 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -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::::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", }, } diff --git a/world/src/site/dungeon/mod.rs b/world/src/site/dungeon/mod.rs index 1da4d165bc..6561f6e6d2 100644 --- a/world/src/site/dungeon/mod.rs +++ b/world/src/site/dungeon/mod.rs @@ -555,28 +555,28 @@ impl Floor { 0 => Lottery::::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::::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::::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::::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::::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::::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::::load_expect("common.loot_tables.armor_misc"), + _ => Lottery::::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::::load_expect( - "common.loot_tables.armor_heavy", + "common.loot_tables.armor.armor_heavy", ), 3 => Lottery::::load_expect( "common.loot_tables.weapon_rare", @@ -859,7 +861,7 @@ impl Floor { }, ), _ => Lottery::::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::::load_expect( - "common.loot_tables.animal_parts", + "common.loot_tables.wild_animal", ), 1 => Lottery::::load_expect( - "common.loot_tables.animal_parts", + "common.loot_tables.wild_animal", ), 2 => Lottery::::load_expect( - "common.loot_tables.animal_parts", + "common.loot_tables.wild_animal", ), 3 => Lottery::::load_expect( "common.loot_tables.weapon_rare", @@ -1013,7 +1015,7 @@ impl Floor { ), 5 => Lottery::::load_expect("common.loot_tables.husk"), _ => Lottery::::load_expect( - "common.loot_tables.armor_misc", + "common.loot_tables.armor.armor_misc", ), }; let chosen = chosen.read();