From e08f7d4fa935e0288d541736ece0b93a2789b699 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 14 Aug 2022 16:18:47 +0100 Subject: [PATCH] Added blacksmith --- common/src/rtsim.rs | 3 +++ rtsim/src/gen/mod.rs | 5 +++-- server/src/rtsim2/tick.rs | 8 +++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/common/src/rtsim.rs b/common/src/rtsim.rs index bd5684a6d5..de97dc66bc 100644 --- a/common/src/rtsim.rs +++ b/common/src/rtsim.rs @@ -106,6 +106,8 @@ pub enum Profession { Guard, #[serde(rename = "4")] Adventurer(u32), + #[serde(rename = "5")] + Blacksmith, } impl Profession { @@ -116,6 +118,7 @@ impl Profession { Self::Merchant => "Merchant".to_string(), Self::Guard => "Guard".to_string(), Self::Adventurer(_) => "Adventurer".to_string(), + Self::Blacksmith => "Blacksmith".to_string(), } } } diff --git a/rtsim/src/gen/mod.rs b/rtsim/src/gen/mod.rs index 97fe5b730e..3e14d02963 100644 --- a/rtsim/src/gen/mod.rs +++ b/rtsim/src/gen/mod.rs @@ -46,11 +46,12 @@ impl Data { wpos2d.map(|e| e as f32 + 0.5) .with_z(world.sim().get_alt_approx(wpos2d).unwrap_or(0.0)) }; - for _ in 0..10 { + for _ in 0..20 { this.npcs.create(Npc::new(rng.gen(), rand_wpos(&mut rng)).with_home(site_id).with_profession(match rng.gen_range(0..10) { 0 => Profession::Hunter, - 1..=4 => Profession::Farmer, + 1 => Profession::Blacksmith, + 2..=4 => Profession::Farmer, _ => Profession::Guard, })); } diff --git a/server/src/rtsim2/tick.rs b/server/src/rtsim2/tick.rs index 1249db34be..88bef6b91b 100644 --- a/server/src/rtsim2/tick.rs +++ b/server/src/rtsim2/tick.rs @@ -105,6 +105,12 @@ impl<'a> System<'a> for Sys { economy.as_ref(), |good| matches!(good, Good::Food), ), + Profession::Blacksmith => trader_loadout( + loadout_builder + .with_asset_expect("common.loadout.village.blacksmith", &mut rng), + economy.as_ref(), + |good| matches!(good, Good::Tools | Good::Armor), + ), Profession::Hunter => loadout_builder .with_asset_expect("common.loadout.village.villager", &mut rng), @@ -114,7 +120,7 @@ impl<'a> System<'a> for Sys { let can_speak = npc.profession.is_some(); // TODO: not this - let trade_for_site = if let Some(Profession::Merchant | Profession::Farmer) = npc.profession { + let trade_for_site = if let Some(Profession::Merchant | Profession::Farmer | Profession::Blacksmith) = npc.profession { npc.home.and_then(|home| Some(data.sites.get(home)?.world_site?.id())) } else { None