From 8bd0cee2e52468d42e731bffa56f2120e764855d Mon Sep 17 00:00:00 2001 From: Snowram Date: Sun, 22 Nov 2020 19:18:39 +0100 Subject: [PATCH] Add basic guards to towns --- common/src/loadout_builder.rs | 120 +++++++++++-------------------- tools/src/main.rs | 4 +- world/src/site/settlement/mod.rs | 16 +++-- 3 files changed, 57 insertions(+), 83 deletions(-) diff --git a/common/src/loadout_builder.rs b/common/src/loadout_builder.rs index 43a685571e..302232df16 100644 --- a/common/src/loadout_builder.rs +++ b/common/src/loadout_builder.rs @@ -116,7 +116,7 @@ impl LoadoutBuilder { active_item, second_item: None, shoulder: Some(Item::new_from_asset_expect( - "common.items.armor.shoulder.chain", + "common.items.armor.shoulder.steel_0", )), chest: Some(Item::new_from_asset_expect( "common.items.armor.chest.steel_0", @@ -376,83 +376,47 @@ impl LoadoutBuilder { head: None, tabard: None, }, - Villager => { - if is_giant { - Loadout { - active_item, - second_item: None, - shoulder: Some(Item::new_from_asset_expect( - "common.items.armor.shoulder.plate_0", - )), - chest: Some(Item::new_from_asset_expect(match alignment { - Alignment::Enemy => "common.items.npc_armor.chest.plate_red_0", - _ => "common.items.npc_armor.chest.plate_green_0", - })), - belt: Some(Item::new_from_asset_expect( - "common.items.armor.belt.plate_0", - )), - hand: Some(Item::new_from_asset_expect( - "common.items.armor.hand.plate_0", - )), - pants: Some(Item::new_from_asset_expect(match alignment { - Alignment::Enemy => "common.items.npc_armor.pants.plate_red_0", - _ => "common.items.npc_armor.pants.plate_green_0", - })), - foot: Some(Item::new_from_asset_expect( - "common.items.armor.foot.plate_0", - )), - back: None, - ring: None, - neck: None, - lantern: None, - glider: None, - head: None, - tabard: None, - } - } else { - Loadout { - active_item, - second_item: None, - shoulder: None, - chest: Some(Item::new_from_asset_expect( - match rand::thread_rng().gen_range(0, 10) { - 0 => "common.items.armor.chest.worker_green_0", - 1 => "common.items.armor.chest.worker_green_1", - 2 => "common.items.armor.chest.worker_red_0", - 3 => "common.items.armor.chest.worker_red_1", - 4 => "common.items.armor.chest.worker_purple_0", - 5 => "common.items.armor.chest.worker_purple_1", - 6 => "common.items.armor.chest.worker_yellow_0", - 7 => "common.items.armor.chest.worker_yellow_1", - 8 => "common.items.armor.chest.worker_orange_0", - _ => "common.items.armor.chest.worker_orange_1", - }, - )), - belt: Some(Item::new_from_asset_expect( - "common.items.armor.belt.leather_0", - )), - hand: None, - pants: Some(Item::new_from_asset_expect( - "common.items.armor.pants.worker_blue_0", - )), - foot: Some(Item::new_from_asset_expect( - match rand::thread_rng().gen_range(0, 2) { - 0 => "common.items.armor.foot.leather_0", - _ => "common.items.armor.starter.sandals_0", - }, - )), - back: None, - ring: None, - neck: None, - lantern: Some(Item::new_from_asset_expect( - "common.items.lantern.black_0", - )), - glider: None, - head: None, - tabard: None, - } - } - }, + Villager => Loadout { + active_item, + second_item: None, + shoulder: None, + chest: Some(Item::new_from_asset_expect( + match rand::thread_rng().gen_range(0, 10) { + 0 => "common.items.armor.chest.worker_green_0", + 1 => "common.items.armor.chest.worker_green_1", + 2 => "common.items.armor.chest.worker_red_0", + 3 => "common.items.armor.chest.worker_red_1", + 4 => "common.items.armor.chest.worker_purple_0", + 5 => "common.items.armor.chest.worker_purple_1", + 6 => "common.items.armor.chest.worker_yellow_0", + 7 => "common.items.armor.chest.worker_yellow_1", + 8 => "common.items.armor.chest.worker_orange_0", + _ => "common.items.armor.chest.worker_orange_1", + }, + )), + belt: Some(Item::new_from_asset_expect( + "common.items.armor.belt.leather_0", + )), + hand: None, + pants: Some(Item::new_from_asset_expect( + "common.items.armor.pants.worker_blue_0", + )), + foot: Some(Item::new_from_asset_expect( + match rand::thread_rng().gen_range(0, 2) { + 0 => "common.items.armor.foot.leather_0", + _ => "common.items.armor.starter.sandals_0", + }, + )), + back: None, + ring: None, + neck: None, + lantern: Some(Item::new_from_asset_expect( + "common.items.lantern.black_0", + )), + glider: None, + head: None, + tabard: None, + } } } else { match body { diff --git a/tools/src/main.rs b/tools/src/main.rs index 62995f9e24..4252a16206 100644 --- a/tools/src/main.rs +++ b/tools/src/main.rs @@ -43,7 +43,7 @@ fn armor_stats() -> Result<(), Box> { fn weapon_stats() -> Result<(), Box> { let mut wtr = csv::Writer::from_path("weaponstats.csv")?; - wtr.write_record(&["Path", "Kind", "Name", "Power", "Equip Time (ms)"])?; + wtr.write_record(&["Path", "Kind", "Name", "Power", "Speed", "Equip Time (ms)"])?; for item in comp::item::Item::new_from_asset_glob("common.items.weapons.*") .expect("Failed to iterate over item folders!") @@ -51,6 +51,7 @@ fn weapon_stats() -> Result<(), Box> { match item.kind() { comp::item::ItemKind::Tool(tool) => { let power = tool.base_power().to_string(); + let speed = tool.base_speed().to_string(); let equip_time = tool.equip_time().subsec_millis().to_string(); let kind = get_tool_kind(&tool.kind); @@ -59,6 +60,7 @@ fn weapon_stats() -> Result<(), Box> { &kind, item.name(), &power, + &speed, &equip_time, ])?; }, diff --git a/world/src/site/settlement/mod.rs b/world/src/site/settlement/mod.rs index 7656af2ffc..188e63cd6f 100644 --- a/world/src/site/settlement/mod.rs +++ b/world/src/site/settlement/mod.rs @@ -917,8 +917,17 @@ impl Settlement { } else { comp::Alignment::Tame }) + .do_if(!is_dummy, |e| e.with_automatic_name()) + .do_if(is_dummy, |e| e.with_name("Training Dummy")) .do_if(is_human && dynamic_rng.gen(), |entity| { - entity.with_main_tool(Item::new_from_asset_expect( + match dynamic_rng.gen_range(0, 5) { + 0 => entity.with_main_tool(Item::new_from_asset_expect( + "common.items.weapons.sword.greatsword_2h_simple-0", + )) + .with_name("Guard") + .with_level(dynamic_rng.gen_range(10, 15)) + .with_config(common::loadout_builder::LoadoutConfig::Guard), + _ => entity.with_main_tool(Item::new_from_asset_expect( match dynamic_rng.gen_range(0, 7) { 0 => "common.items.npc_weapons.tool.broom", 1 => "common.items.npc_weapons.tool.hoe", @@ -931,9 +940,8 @@ impl Settlement { }, )) .with_config(common::loadout_builder::LoadoutConfig::Villager) - }) - .do_if(is_dummy, |e| e.with_name("Training Dummy")) - .do_if(!is_dummy, |e| e.with_automatic_name()); + } + }); supplement.add_entity(entity); }