From 38493b615b84bd24757c5f2dea5ed13cdd0d53d8 Mon Sep 17 00:00:00 2001 From: juliancoffee Date: Thu, 2 Sep 2021 23:22:53 +0300 Subject: [PATCH 1/2] Rebalance chest density in dungeons - Make it depend on relative floor and not absolute floor to keep it the same through different dungeons. - Make it start around the middle of dungeon to avoid chest only runs. --- world/src/site2/plot/dungeon.rs | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/world/src/site2/plot/dungeon.rs b/world/src/site2/plot/dungeon.rs index d6eb8143c3..5cb39e65d6 100644 --- a/world/src/site2/plot/dungeon.rs +++ b/world/src/site2/plot/dungeon.rs @@ -63,6 +63,8 @@ lazy_static! { .clone(); } +fn floor_amount(difficulty: u32) -> u32 { 3 + difficulty / 2 } + impl Dungeon { pub fn generate(wpos: Vec2, land: &Land, rng: &mut impl Rng) -> Self { let mut ctx = GenCtx { land, rng }; @@ -75,7 +77,7 @@ impl Dungeon { err ) }); - let floors = 3 + difficulty / 2; + let floors = floor_amount(difficulty); Self { name: { @@ -383,7 +385,7 @@ impl Floor { difficulty: u32, ) -> (Self, Vec2) { const MAX_WIDTH: u32 = 4; - let floors = 3 + difficulty / 2; + let floors = floor_amount(difficulty); let final_level = level == floors as i32 - 1; let width = (2 + difficulty / 2).min(MAX_WIDTH); let height = (15 + difficulty * 3).min(30); @@ -516,11 +518,20 @@ impl Floor { None => return, }; + let loot_density = |difficulty, level| { + let max_floor = floor_amount(difficulty); + // We count floors from 0, don't divide by zero + let current_floor = level + 1; + let ratio = f64::from(current_floor) / f64::from(max_floor); + // filter starting floors + let ratio = 0.0_f64.max(ratio - 0.55); + 0.00175 * ratio as f32 + }; match ctx.rng.gen_range(0..5) { // Miniboss room 0 => self.create_room(Room { seed: ctx.rng.gen(), - loot_density: 0.000025 + level as f32 * 0.00015, + loot_density: loot_density(self.difficulty, level), kind: RoomKind::Miniboss, area, height: ctx.rng.gen_range(15..20), @@ -530,7 +541,7 @@ impl Floor { // Fight room with enemies in it _ => self.create_room(Room { seed: ctx.rng.gen(), - loot_density: 0.000025 + level as f32 * 0.00015, + loot_density: loot_density(self.difficulty, level), kind: RoomKind::Fight, area, height: ctx.rng.gen_range(10..15), @@ -1219,8 +1230,9 @@ impl Floor { let seed = room.seed; let loot_density = room.loot_density; let difficulty = room.difficulty; - // Place chests with a random distribution based on the room's loot density in - // valid sprite locations, filled based on the room's difficulty + // Place chests with a random distribution based on the + // room's loot density in valid sprite locations, + // filled based on the room's difficulty let chest_sprite = prim(Primitive::Sampling( sprite_layer, Box::new(move |pos| RandomField::new(seed).chance(pos, loot_density * 0.5)), @@ -1236,9 +1248,10 @@ impl Floor { })); chests = Some((chest_sprite, chest_sprite_fill)); - // If a room has pillars, the current tile aligns with the pillar spacing, and - // we're not too close to a wall (i.e. the adjacent tiles are rooms and not - // hallways/solid), place a pillar + // If a room has pillars, the current tile aligns with + // the pillar spacing, and we're not too close to a wall + // (i.e. the adjacent tiles are rooms and not hallways/solid), + // place a pillar if room .pillars .map(|pillar_space| { From f88373f7d88bf11c486d1f5d67ce4679f1c6c920 Mon Sep 17 00:00:00 2001 From: juliancoffee Date: Fri, 3 Sep 2021 01:03:45 +0300 Subject: [PATCH 2/2] Nerf coin drop from enemies --- assets/common/loot_tables/dungeon/tier-0/enemy.ron | 4 ++-- assets/common/loot_tables/dungeon/tier-1/enemy.ron | 4 ++-- assets/common/loot_tables/dungeon/tier-2/enemy.ron | 4 ++-- assets/common/loot_tables/dungeon/tier-3/enemy.ron | 4 ++-- assets/common/loot_tables/dungeon/tier-4/enemy.ron | 4 ++-- assets/common/loot_tables/dungeon/tier-5/enemy.ron | 2 +- assets/common/loot_tables/dungeon/tier-5/minion.ron | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/assets/common/loot_tables/dungeon/tier-0/enemy.ron b/assets/common/loot_tables/dungeon/tier-0/enemy.ron index a28a7b1aed..9ca703569d 100644 --- a/assets/common/loot_tables/dungeon/tier-0/enemy.ron +++ b/assets/common/loot_tables/dungeon/tier-0/enemy.ron @@ -1,8 +1,8 @@ [ // Currency - (1.0, ItemQuantity("common.items.utility.coins", 5, 10)), + (1.0, ItemQuantity("common.items.utility.coins", 2, 4)), // Food (1.0, LootTable("common.loot_tables.food.wild_ingredients")), // Nothing (2.0, None), -] \ No newline at end of file +] diff --git a/assets/common/loot_tables/dungeon/tier-1/enemy.ron b/assets/common/loot_tables/dungeon/tier-1/enemy.ron index 1f74d7c77a..ec12216fd1 100644 --- a/assets/common/loot_tables/dungeon/tier-1/enemy.ron +++ b/assets/common/loot_tables/dungeon/tier-1/enemy.ron @@ -1,10 +1,10 @@ [ // Currency - (1.0, ItemQuantity("common.items.utility.coins", 10, 25)), + (1.0, ItemQuantity("common.items.utility.coins", 4, 10)), // Food (1.0, LootTable("common.loot_tables.food.wild_ingredients")), // Nothing (2.0, None), // Placeholder Drop Location (1.0, Item("common.items.crafting_ing.sticky_thread")), -] \ No newline at end of file +] diff --git a/assets/common/loot_tables/dungeon/tier-2/enemy.ron b/assets/common/loot_tables/dungeon/tier-2/enemy.ron index ce4da6e403..c1368adc5d 100644 --- a/assets/common/loot_tables/dungeon/tier-2/enemy.ron +++ b/assets/common/loot_tables/dungeon/tier-2/enemy.ron @@ -1,8 +1,8 @@ [ // Currency - (1.0, ItemQuantity("common.items.utility.coins", 25, 50)), + (1.0, ItemQuantity("common.items.utility.coins", 10, 20)), // Food (1.0, LootTable("common.loot_tables.food.wild_ingredients")), // Nothing (2.0, None), -] \ No newline at end of file +] diff --git a/assets/common/loot_tables/dungeon/tier-3/enemy.ron b/assets/common/loot_tables/dungeon/tier-3/enemy.ron index abe65e857b..6ef2e26870 100644 --- a/assets/common/loot_tables/dungeon/tier-3/enemy.ron +++ b/assets/common/loot_tables/dungeon/tier-3/enemy.ron @@ -1,8 +1,8 @@ [ // Currency - (1.0, ItemQuantity("common.items.utility.coins", 50, 100)), + (1.0, ItemQuantity("common.items.utility.coins", 20, 40)), // Food (1.0, LootTable("common.loot_tables.food.prepared")), // Nothing (2.0, None), -] \ No newline at end of file +] diff --git a/assets/common/loot_tables/dungeon/tier-4/enemy.ron b/assets/common/loot_tables/dungeon/tier-4/enemy.ron index c94d909763..c0b5dff2df 100644 --- a/assets/common/loot_tables/dungeon/tier-4/enemy.ron +++ b/assets/common/loot_tables/dungeon/tier-4/enemy.ron @@ -1,8 +1,8 @@ [ // Currency - (1.0, ItemQuantity("common.items.utility.coins", 100, 250)), + (1.0, ItemQuantity("common.items.utility.coins", 40, 100)), // Food (1.0, LootTable("common.loot_tables.food.prepared")), // Nothing (2.0, None), -] \ No newline at end of file +] diff --git a/assets/common/loot_tables/dungeon/tier-5/enemy.ron b/assets/common/loot_tables/dungeon/tier-5/enemy.ron index e37f3568f2..106ef0b2ad 100644 --- a/assets/common/loot_tables/dungeon/tier-5/enemy.ron +++ b/assets/common/loot_tables/dungeon/tier-5/enemy.ron @@ -1,6 +1,6 @@ [ // Currency - (1.0, ItemQuantity("common.items.utility.coins", 200, 500)), + (1.0, ItemQuantity("common.items.utility.coins", 100, 200)), // Food (1.0, LootTable("common.loot_tables.food.prepared")), // Cheese diff --git a/assets/common/loot_tables/dungeon/tier-5/minion.ron b/assets/common/loot_tables/dungeon/tier-5/minion.ron index b35a11ef9c..5f4de1106a 100644 --- a/assets/common/loot_tables/dungeon/tier-5/minion.ron +++ b/assets/common/loot_tables/dungeon/tier-5/minion.ron @@ -1,6 +1,6 @@ [ // Currency - (50.0, ItemQuantity("common.items.utility.coins", 100, 300)), + (50.0, ItemQuantity("common.items.utility.coins", 50, 100)), // Nothing (50.0, None), // Special