From a2906168a6bc08d2418bfc019e239d49e9650439 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 1 Apr 2021 15:35:40 -0400 Subject: [PATCH] Moved materials into their own loot tables. --- assets/common/item_price_calculation.ron | 2 - assets/common/loot_tables/cave_large.ron | 3 +- assets/common/loot_tables/crafting.ron | 9 ---- assets/common/loot_tables/husk.ron | 3 -- assets/common/loot_tables/materials/gems.ron | 8 ++++ .../loot_tables/materials/underground.ron | 6 +++ assets/common/loot_tables/rocks.ron | 6 --- common/src/comp/inventory/item/mod.rs | 8 ++-- server/src/events/entity_manipulation.rs | 5 +-- world/src/site/dungeon/mod.rs | 45 +++++++++++-------- 10 files changed, 49 insertions(+), 46 deletions(-) delete mode 100644 assets/common/loot_tables/crafting.ron delete mode 100644 assets/common/loot_tables/husk.ron create mode 100644 assets/common/loot_tables/materials/gems.ron create mode 100644 assets/common/loot_tables/materials/underground.ron delete mode 100644 assets/common/loot_tables/rocks.ron diff --git a/assets/common/item_price_calculation.ron b/assets/common/item_price_calculation.ron index 3a2deb1508..634bab8563 100644 --- a/assets/common/item_price_calculation.ron +++ b/assets/common/item_price_calculation.ron @@ -7,7 +7,6 @@ loot_tables: [ (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 - (0.05,"common.loot_tables.crafting"), (0.005,"common.loot_tables.cultists"), (1,"common.loot_tables.fish"), (0.1,"common.loot_tables.humanoids"), @@ -15,7 +14,6 @@ loot_tables: [ (0.0001,"common.loot_tables.mindflayer"), (0.001,"common.loot_tables.miniboss"), // 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.05,"common.loot_tables.villager"), diff --git a/assets/common/loot_tables/cave_large.ron b/assets/common/loot_tables/cave_large.ron index 7121ba23c1..848f8a04ae 100644 --- a/assets/common/loot_tables/cave_large.ron +++ b/assets/common/loot_tables/cave_large.ron @@ -1,7 +1,8 @@ [ // Misc (0.25, Item("common.items.armor.misc.neck.plain_1")), - (3.0, LootTable("common.loot_tables.materials.common")), + (1.5, LootTable("common.loot_tables.materials.common")), + (3.5, LootTable("common.loot_tables.materials.underground")), (0.1, Item("common.items.glider.glider_blue")), (0.05, Item("common.items.glider.glider_morpho")), (0.05, Item("common.items.glider.glider_monarch")), diff --git a/assets/common/loot_tables/crafting.ron b/assets/common/loot_tables/crafting.ron deleted file mode 100644 index 9824e55f52..0000000000 --- a/assets/common/loot_tables/crafting.ron +++ /dev/null @@ -1,9 +0,0 @@ -[ - // crafting ingredients - (0.5, Item("common.items.crafting_ing.amethyst")), - (0.5, Item("common.items.crafting_ing.topaz")), - (0.4, Item("common.items.crafting_ing.sapphire")), - (0.35, Item("common.items.crafting_ing.emerald")), - (0.25, Item("common.items.crafting_ing.ruby")), - (0.1, Item("common.items.crafting_ing.diamond")), -] \ No newline at end of file diff --git a/assets/common/loot_tables/husk.ron b/assets/common/loot_tables/husk.ron deleted file mode 100644 index be0a0aeef5..0000000000 --- a/assets/common/loot_tables/husk.ron +++ /dev/null @@ -1,3 +0,0 @@ -[ - (1.0, Item("common.items.crafting_ing.stones")), -] diff --git a/assets/common/loot_tables/materials/gems.ron b/assets/common/loot_tables/materials/gems.ron new file mode 100644 index 0000000000..ed6df318db --- /dev/null +++ b/assets/common/loot_tables/materials/gems.ron @@ -0,0 +1,8 @@ +[ + (3.0, Item("common.items.crafting_ing.topaz")), + (3.0, Item("common.items.crafting_ing.amethyst")), + (1.6, Item("common.items.crafting_ing.sapphire")), + (1.2, Item("common.items.crafting_ing.emerald")), + (0.8, Item("common.items.crafting_ing.ruby")), + (0.4, Item("common.items.crafting_ing.diamond")), +] \ No newline at end of file diff --git a/assets/common/loot_tables/materials/underground.ron b/assets/common/loot_tables/materials/underground.ron new file mode 100644 index 0000000000..2ff78e7df9 --- /dev/null +++ b/assets/common/loot_tables/materials/underground.ron @@ -0,0 +1,6 @@ +[ + (2.0, Item("common.items.crafting_ing.stones")), + (0.5, Item("common.items.ore.veloritefrag")), + (0.25, Item("common.items.ore.velorite")), + (0.25, LootTable("common.loot_tables.materials.gems")), +] \ No newline at end of file diff --git a/assets/common/loot_tables/rocks.ron b/assets/common/loot_tables/rocks.ron deleted file mode 100644 index 61321fafd1..0000000000 --- a/assets/common/loot_tables/rocks.ron +++ /dev/null @@ -1,6 +0,0 @@ -[ - (1.0, Item("common.items.crafting_ing.stones")), - (0.05, Item("common.items.crafting_ing.diamond")), - (0.1, Item("common.items.ore.velorite")), - (0.2, Item("common.items.ore.veloritefrag")), -] \ No newline at end of file diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index b936426ba1..d844ab0a20 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -624,17 +624,17 @@ impl Item { }, SpriteKind::Mud => { chosen = Lottery::::load_expect(match rng.gen_range(0..5) { - 0 => "common.loot_tables.crafting", + 0 => "common.loot_tables.materials.common", 1 => "common.loot_tables.weapons.tier-0", - 2 => "common.loot_tables.fallback", - _ => "common.loot_tables.rocks", + 2 => "common.loot_tables.materials.underground", + _ => "common.loot_tables.fallback", }) .read(); return Some(chosen.choose().to_item(None)); }, SpriteKind::Crate => { chosen = Lottery::::load_expect(match rng.gen_range(0..4) { - 0 => "common.loot_tables.crafting", + 0 => "common.loot_tables.materials.common", _ => "common.loot_tables.food.prepared", }) .read(); diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index a96a240b9a..6de97c9afd 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -351,9 +351,8 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc }, Some(common::comp::Body::QuadrupedSmall(quadruped_small)) => { match quadruped_small.species { - quadruped_small::Species::Dodarock => match rng.gen_range(0..6) { - 1 => "common.loot_tables.rocks", - _ => "common.loot_tables.rocks", + quadruped_small::Species::Dodarock => { + "common.loot_tables.materials.underground" }, _ => match rng.gen_range(0..4) { 0 => "common.loot_tables.food.wild_ingredients", diff --git a/world/src/site/dungeon/mod.rs b/world/src/site/dungeon/mod.rs index 198d9b901a..180e777c33 100644 --- a/world/src/site/dungeon/mod.rs +++ b/world/src/site/dungeon/mod.rs @@ -1011,13 +1011,11 @@ impl Floor { 4 => Lottery::::load_expect( "common.loot_tables.weapons.tier-4", ), - 5 => Lottery::::load_expect("common.loot_tables.husk"), + 5 => Lottery::::load_expect("common.loot_tables.cultist"), _ => { Lottery::::load_expect("common.loot_tables.fallback") }, }; - let chosen = chosen.read(); - let chosen = chosen.choose(); let entity = match room.difficulty { 0 => { let body = comp::Body::QuadrupedMedium( @@ -1030,7 +1028,9 @@ impl Floor { EntityInfo::at(tile_wcenter.map(|e| e as f32)) .with_body(body) .with_name("Bonerattler".to_string()) - .with_loot_drop(chosen.to_item(Some(body))), + .with_loot_drop( + chosen.read().choose().to_item(Some(body)), + ), ] }, 1 => { @@ -1044,7 +1044,9 @@ impl Floor { EntityInfo::at(tile_wcenter.map(|e| e as f32)) .with_body(body) .with_name("Bonerattler".to_string()) - .with_loot_drop(chosen.to_item(Some(body))); + .with_loot_drop( + chosen.read().choose().to_item(Some(body)) + ); 3 ] }, @@ -1060,7 +1062,9 @@ impl Floor { 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))) + .with_loot_drop( + chosen.read().choose().to_item(Some(body)), + ) }); entities }, @@ -1071,7 +1075,7 @@ impl Floor { EntityInfo::at(tile_wcenter.map(|e| e as f32)) .with_body(body) .with_name("Animal Trainer".to_string()) - .with_loot_drop(chosen.to_item(Some(body))) + .with_loot_drop(chosen.read().choose().to_item(Some(body))) .with_loadout_config(loadout_builder::LoadoutConfig::CultistAcolyte) .with_skillset_config( common::skillset_builder::SkillSetConfig::CultistAcolyte @@ -1098,7 +1102,9 @@ impl Floor { EntityInfo::at(tile_wcenter.map(|e| e as f32)) .with_body(body) .with_name("Tamed Darkhound".to_string()) - .with_loot_drop(chosen.to_item(Some(body))) + .with_loot_drop( + chosen.read().choose().to_item(Some(body)), + ) }); entities }, @@ -1113,23 +1119,26 @@ impl Floor { EntityInfo::at(tile_wcenter.map(|e| e as f32)) .with_body(body) .with_name("Dullahan Guard".to_string()) - .with_loot_drop(chosen.to_item(Some(body))), + .with_loot_drop( + chosen.read().choose().to_item(Some(body)), + ), ] }, 5 => { + let body = comp::Body::BipedSmall( + comp::biped_small::Body::random_with( + dynamic_rng, + &comp::biped_small::Species::Husk, + ), + ); 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_body(body) .with_name("Cultist Husk".to_string()) - .with_loot_drop(comp::Item::new_from_asset_expect( - "common.items.crafting_ing.stones", - )) + .with_loot_drop( + chosen.read().choose().to_item(Some(body)), + ) .with_loadout_config( loadout_builder::LoadoutConfig::Husk, )