Rename EntityInfo level field to health_scaling

This commit is contained in:
juliancoffee 2021-09-17 19:41:13 +03:00
parent 9cc70e6d22
commit f810af4eec
5 changed files with 37 additions and 58 deletions

View File

@ -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,

View File

@ -172,7 +172,7 @@ pub struct EntityInfo {
pub second_tool: Option<Item>,
pub scale: f32,
// TODO: Properly give NPCs skills
pub level: Option<u16>,
pub health_scaling: Option<u16>,
pub loot_drop: Option<Item>,
pub loadout_asset: Option<String>,
pub make_loadout: Option<fn(LoadoutBuilder, Option<&trade::SiteInformation>) -> 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
}

View File

@ -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 {

View File

@ -1008,13 +1008,13 @@ fn humanoid(pos: Vec3<f32>, 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)

View File

@ -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<i32>,
wpos2d: Vec2<i32>,
tile_pos: Vec2<i32>,
@ -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<i32>) -> Vec<EntityInf
let number = dynamic_rng.gen_range(2..=4);
let mut entities = Vec::new();
entities.resize_with(number, || {
let entity = EntityInfo::at(tile_wcenter.map(|e| e as f32));
// TODO: give enemies health skills?
let entity = EntityInfo::at(tile_wcenter.map(|e| e as f32))
.with_health_scaling(dynamic_rng.gen_range(3..4));
match dynamic_rng.gen_range(0..=4) {
0 => 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<i32>) -> Vec<EntityInf
let number = dynamic_rng.gen_range(2..=4);
let mut entities = Vec::new();
entities.resize_with(number, || {
let entity = EntityInfo::at(tile_wcenter.map(|e| e as f32));
// TODO: give enemies health skills?
let entity = EntityInfo::at(tile_wcenter.map(|e| e as f32))
.with_health_scaling(dynamic_rng.gen_range(4..5));
match dynamic_rng.gen_range(0..=4) {
0 => 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<i32>) -> Vec<EntityInf
let number = dynamic_rng.gen_range(2..=4);
let mut entities = Vec::new();
entities.resize_with(number, || {
let entity = EntityInfo::at(tile_wcenter.map(|e| e as f32));
// TODO: give enemies health skills?
let entity = EntityInfo::at(tile_wcenter.map(|e| e as f32))
.with_health_scaling(dynamic_rng.gen_range(5..7));
match dynamic_rng.gen_range(0..=4) {
0 => 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<i32>) -> Vec<EntityInf
let number = dynamic_rng.gen_range(2..=4);
let mut entities = Vec::new();
entities.resize_with(number, || {
let entity = EntityInfo::at(tile_wcenter.map(|e| e as f32));
// TODO: give enemies health skills?
let entity = EntityInfo::at(tile_wcenter.map(|e| e as f32))
.with_health_scaling(dynamic_rng.gen_range(7..9));
match dynamic_rng.gen_range(0..=4) {
0 => 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<i32>) -> Vec<EntityInf
let number = dynamic_rng.gen_range(2..=4);
let mut entities = Vec::new();
entities.resize_with(number, || {
let entity = EntityInfo::at(tile_wcenter.map(|e| e as f32));
// TODO: give enemies health skills?
let entity = EntityInfo::at(tile_wcenter.map(|e| e as f32))
.with_health_scaling(dynamic_rng.gen_range(9..12));
match dynamic_rng.gen_range(0..=4) {
0 => 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<i32>) -> Vec<EntityInf
let number = dynamic_rng.gen_range(1..=3);
let mut entities = Vec::new();
entities.resize_with(number, || {
let entity = EntityInfo::at(tile_wcenter.map(|e| e as f32));
// TODO: give enemies health skills?
let entity = EntityInfo::at(tile_wcenter.map(|e| e as f32))
.with_health_scaling(dynamic_rng.gen_range(10..15));
match dynamic_rng.gen_range(0..=4) {
0 => 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<i32>) -> Vec<Entit
0 => {
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))