From f810af4eec9cc5b8bd7c0f15341d676901dc0882 Mon Sep 17 00:00:00 2001 From: juliancoffee Date: Fri, 17 Sep 2021 19:41:13 +0300 Subject: [PATCH] Rename EntityInfo level field to health_scaling --- common/src/comp/body.rs | 6 +-- common/src/generation.rs | 8 ++-- server/src/sys/terrain.rs | 4 +- world/src/site/settlement/mod.rs | 4 +- world/src/site2/plot/dungeon.rs | 73 ++++++++++++-------------------- 5 files changed, 37 insertions(+), 58 deletions(-) diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index 946b170df8..fe2243bd0d 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -565,7 +565,7 @@ impl Body { biped_large::Species::Cavetroll => 240, biped_large::Species::Mountaintroll => 240, biped_large::Species::Swamptroll => 240, - biped_large::Species::Dullahan => 300, + biped_large::Species::Dullahan => 700, biped_large::Species::Mindflayer => 1250, biped_large::Species::Tidalwarrior => 1600, biped_large::Species::Yeti => 1200, @@ -613,10 +613,10 @@ impl Body { quadruped_low::Species::Pangolin => 40, quadruped_low::Species::Maneater => 130, quadruped_low::Species::Sandshark => 110, - quadruped_low::Species::Hakulaq => 50, + quadruped_low::Species::Hakulaq => 120, quadruped_low::Species::Lavadrake => 160, quadruped_low::Species::Basilisk => 200, - quadruped_low::Species::Deadwood => 70, + quadruped_low::Species::Deadwood => 120, _ => 70, }, Body::Ship(_) => 1000, diff --git a/common/src/generation.rs b/common/src/generation.rs index 3a3fba904f..837b8a2d83 100644 --- a/common/src/generation.rs +++ b/common/src/generation.rs @@ -172,7 +172,7 @@ pub struct EntityInfo { pub second_tool: Option, pub scale: f32, // TODO: Properly give NPCs skills - pub level: Option, + pub health_scaling: Option, pub loot_drop: Option, pub loadout_asset: Option, pub make_loadout: Option) -> LoadoutBuilder>, @@ -196,7 +196,7 @@ impl EntityInfo { main_tool: None, second_tool: None, scale: 1.0, - level: None, + health_scaling: None, loot_drop: None, loadout_asset: None, make_loadout: None, @@ -373,8 +373,8 @@ impl EntityInfo { self } - pub fn with_level(mut self, level: u16) -> Self { - self.level = Some(level); + pub fn with_health_scaling(mut self, level: u16) -> Self { + self.health_scaling = Some(level); self } diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index d91a7fecc0..850a48001a 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -375,7 +375,7 @@ impl NpcData { name, scale, pos, - level, + health_scaling, loot_drop, // tools and skills skillset_asset, @@ -434,7 +434,7 @@ impl NpcData { loadout_builder.build() }; - let health = Some(comp::Health::new(body, level.unwrap_or(0))); + let health = Some(comp::Health::new(body, health_scaling.unwrap_or(0))); let poise = comp::Poise::new(body); let can_speak = match body { diff --git a/world/src/site/settlement/mod.rs b/world/src/site/settlement/mod.rs index 0e8092e1f1..321afb814b 100644 --- a/world/src/site/settlement/mod.rs +++ b/world/src/site/settlement/mod.rs @@ -1008,13 +1008,13 @@ fn humanoid(pos: Vec3, economy: &SiteInformation, dynamic_rng: &mut impl Rn 0 | 1 => entity .with_agent_mark(agent::Mark::Guard) .with_lazy_loadout(guard_loadout) - .with_level(dynamic_rng.gen_range(10..15)) + .with_health_scaling(dynamic_rng.gen_range(10..15)) .with_asset_expect("common.entity.village.guard"), 2 => entity .with_agent_mark(agent::Mark::Merchant) .with_economy(economy) .with_lazy_loadout(merchant_loadout) - .with_level(dynamic_rng.gen_range(10..15)) + .with_health_scaling(dynamic_rng.gen_range(10..15)) .with_asset_expect("common.entity.village.merchant"), _ => entity .with_lazy_loadout(villager_loadout) diff --git a/world/src/site2/plot/dungeon.rs b/world/src/site2/plot/dungeon.rs index 3f68d2d9b5..98bd8d4202 100644 --- a/world/src/site2/plot/dungeon.rs +++ b/world/src/site2/plot/dungeon.rs @@ -235,16 +235,7 @@ impl Room { }; for entity in entities { - supplement.add_entity( - entity.with_level( - dynamic_rng - .gen_range( - (self.difficulty as f32).powf(1.25) + 3.0 - ..(self.difficulty as f32).powf(1.5) + 4.0, - ) - .round() as u16, - ), - ); + supplement.add_entity(entity); } } else { // Turrets @@ -303,17 +294,7 @@ impl Room { }; for entity in entities { - supplement.add_entity( - entity.with_level( - dynamic_rng - .gen_range( - (self.difficulty as f32).powf(1.25) + 3.0 - ..(self.difficulty as f32).powf(1.5) + 4.0, - ) - .round() as u16 - * 5, - ), - ); + supplement.add_entity(entity); } } } @@ -321,7 +302,6 @@ impl Room { fn fill_boss_cell( &self, supplement: &mut ChunkSupplement, - dynamic_rng: &mut impl Rng, tile_wcenter: Vec3, wpos2d: Vec2, tile_pos: Vec2, @@ -347,17 +327,7 @@ impl Room { }; for entity in entities { - supplement.add_entity( - entity.with_level( - dynamic_rng - .gen_range( - (self.difficulty as f32).powf(1.25) + 3.0 - ..(self.difficulty as f32).powf(1.5) + 4.0, - ) - .round() as u16 - * 5, - ), - ); + supplement.add_entity(entity); } } } @@ -658,13 +628,9 @@ impl Floor { wpos2d, tile_pos, ), - RoomKind::Boss => room.fill_boss_cell( - supplement, - dynamic_rng, - tile_wcenter, - wpos2d, - tile_pos, - ), + RoomKind::Boss => { + room.fill_boss_cell(supplement, tile_wcenter, wpos2d, tile_pos) + }, RoomKind::Peaceful => {}, } } @@ -689,7 +655,9 @@ fn enemy_0(dynamic_rng: &mut impl Rng, tile_wcenter: Vec3) -> Vec entity.with_asset_expect("common.entity.dungeon.tier-0.bow"), 1 => entity.with_asset_expect("common.entity.dungeon.tier-0.staff"), @@ -704,7 +672,9 @@ fn enemy_1(dynamic_rng: &mut impl Rng, tile_wcenter: Vec3) -> Vec entity.with_asset_expect("common.entity.dungeon.tier-1.bow"), 1 => entity.with_asset_expect("common.entity.dungeon.tier-1.staff"), @@ -719,7 +689,9 @@ fn enemy_2(dynamic_rng: &mut impl Rng, tile_wcenter: Vec3) -> Vec entity.with_asset_expect("common.entity.dungeon.tier-2.bow"), 1 => entity.with_asset_expect("common.entity.dungeon.tier-2.staff"), @@ -734,7 +706,9 @@ fn enemy_3(dynamic_rng: &mut impl Rng, tile_wcenter: Vec3) -> Vec entity.with_asset_expect("common.entity.dungeon.tier-3.bow"), 1 => entity.with_asset_expect("common.entity.dungeon.tier-3.staff"), @@ -749,7 +723,9 @@ fn enemy_4(dynamic_rng: &mut impl Rng, tile_wcenter: Vec3) -> Vec entity.with_asset_expect("common.entity.dungeon.tier-4.bow"), 1 => entity.with_asset_expect("common.entity.dungeon.tier-4.staff"), @@ -764,7 +740,9 @@ fn enemy_5(dynamic_rng: &mut impl Rng, tile_wcenter: Vec3) -> Vec entity.with_asset_expect("common.entity.dungeon.tier-5.warlock"), 1 => entity.with_asset_expect("common.entity.dungeon.tier-5.warlord"), @@ -892,7 +870,8 @@ fn mini_boss_5(dynamic_rng: &mut impl Rng, tile_wcenter: Vec3) -> Vec { entities.push( EntityInfo::at(tile_wcenter.map(|e| e as f32)) - .with_asset_expect("common.entity.dungeon.tier-5.beastmaster"), + .with_asset_expect("common.entity.dungeon.tier-5.beastmaster") + .with_health_scaling(dynamic_rng.gen_range(50..75)), ); entities.resize_with(entities.len() + 2, || { EntityInfo::at(tile_wcenter.map(|e| e as f32))