From a3fdba4fe59d6f646599fa01df2d7bd16741b258 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 14 Jan 2022 10:47:43 -0500 Subject: [PATCH] Add 4th level type, completing section 5.17 --- raws/spawns.json | 108 +++++++++++++++++- src/map/themes.rs | 4 +- src/map_builders.rs | 3 +- src/map_builders/limestone_cavern.rs | 20 ++++ src/map_builders/prefab_builder.rs | 9 ++ .../prefab_builder/prefab_sections.rs | 25 ++++ src/raws/prop_structs.rs | 5 +- src/raws/rawmaster.rs | 12 ++ 8 files changed, 176 insertions(+), 10 deletions(-) diff --git a/raws/spawns.json b/raws/spawns.json index 118fae1..9d939fc 100644 --- a/raws/spawns.json +++ b/raws/spawns.json @@ -4,14 +4,13 @@ "name": "Goblin", "weight": 10, "min_depth": 3, - "max_depth": 100 + "max_depth": 4 }, { "name": "Orc", "weight": 1, - "min_depth": 3, - "max_depth": 100, - "add_map_depth_to_weight": true + "min_depth": 4, + "max_depth": 100 }, { "name": "Health Potion", @@ -63,6 +62,30 @@ "min_depth": 3, "max_depth": 100 }, + { + "name": "Leather Armor", + "weight": 1, + "min_depth": 2, + "max_depth": 100 + }, + { + "name": "Leather Boots", + "weight": 1, + "min_depth": 2, + "max_depth": 100 + }, + { + "name": "Chainmail Armor", + "weight": 1, + "min_depth": 4, + "max_depth": 100 + }, + { + "name": "Chain Coif", + "weight": 1, + "min_depth": 4, + "max_depth": 100 + }, { "name": "Rations", "weight": 10, @@ -91,7 +114,7 @@ "name": "Kobold", "weight": 15, "min_depth": 3, - "max_depth": 5 + "max_depth": 3 }, { "name": "Rat", @@ -641,6 +664,40 @@ "initiative_penalty": 0.5, "vendor_category": "clothes" }, + { + "name": "Chainmail Armor", + "renderable": { + "glyph": "[", + "fg": "#00FF00", + "bg": "#000000", + "order": 2 + }, + "wearable": { + "slot": "Torso", + "armor_class": 2.0 + }, + "weight_lbs": 20.0, + "base_value": 50.0, + "initiative_penalty": 1.0, + "vendor_category": "armor" + }, + { + "name": "Chain Coif", + "renderable": { + "glyph": "[", + "fg": "#00FF00", + "bg": "#000000", + "order": 2 + }, + "wearable": { + "slot": "Head", + "armor_class": 1.0 + }, + "weight_lbs": 5.0, + "base_value": 20.0, + "initiative_penalty": 0.5, + "vendor_category": "armor" + }, { "name": "Leather Boots", "renderable": { @@ -1185,6 +1242,28 @@ "faction": "Cave Goblins", "gold": "1d8" }, + { + "name": "Orc Leader", + "renderable": { + "glyph": "O", + "fg": "#FF0000", + "bg": "#000000", + "order": 1 + }, + "blocks_tile": true, + "vision_range": 8, + "movement": "static", + "attributes": {}, + "faction": "Cave Goblins", + "gold": "3d8", + "equipped": [ + "Battleaxe", + "Tower Shield", + "Leather Armor", + "Leather Boots" + ], + "level": 2 + }, { "name": "Goblin", "renderable": { @@ -1469,6 +1548,25 @@ "order": 2 }, "hidden": false + }, + { + "name": "Watch Fire", + "renderable": { + "glyph": "☼", + "fg": "#FFFF55", + "bg": "#000000", + "order": 2 + }, + "hidden": false, + "light": { + "range": 6, + "color": "#FFFF55" + }, + "entry_trigger": { + "effects": { + "damage": "6" + } + } } ] } \ No newline at end of file diff --git a/src/map/themes.rs b/src/map/themes.rs index 220e1d5..afc8ce1 100644 --- a/src/map/themes.rs +++ b/src/map/themes.rs @@ -4,7 +4,7 @@ use super::{Map, TileType}; pub fn tile_glyph(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) { let (glyph, mut fg, mut bg) = match map.depth { - 3 => get_limestone_cavern_glyph(idx, map), + 3 | 4 => get_limestone_cavern_glyph(idx, map), 2 => get_forest_glyph(idx, map), _ => get_tile_glyph_default(idx, map), }; @@ -33,7 +33,7 @@ fn get_limestone_cavern_glyph(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) TileType::Road => (to_cp437('≡'), RGB::named(rltk::YELLOW)), TileType::Grass => (to_cp437('"'), RGB::named(rltk::GREEN)), TileType::ShallowWater => (to_cp437('░'), RGB::named(rltk::CYAN)), - TileType::DeepWater => (to_cp437('▓'), RGB::named(rltk::BLUE)), + TileType::DeepWater => (to_cp437('▓'), RGB::from_f32(0.2, 0.2, 1.0)), TileType::Gravel => (to_cp437(';'), RGB::from_f32(0.5, 0.5, 0.5)), TileType::DownStairs => (to_cp437('>'), RGB::from_f32(0., 1.0, 1.0)), TileType::UpStairs => (to_cp437('<'), RGB::from_f32(0., 1.0, 1.0)), diff --git a/src/map_builders.rs b/src/map_builders.rs index c307a5d..be4bd98 100644 --- a/src/map_builders.rs +++ b/src/map_builders.rs @@ -42,7 +42,7 @@ use dla::DLABuilder; use door_placement::DoorPlacement; use drunkard::DrunkardsWalkBuilder; use forest::forest_builder; -use limestone_cavern::limestone_cavern_builder; +use limestone_cavern::{limestone_cavern_builder, limestone_deep_cavern_builder}; use maze::MazeBuilder; use prefab_builder::PrefabBuilder; use room_based_spawner::RoomBasedSpawner; @@ -348,6 +348,7 @@ pub fn level_builder( 1 => town_builder(new_depth, rng, width, height), 2 => forest_builder(new_depth, rng, width, height), 3 => limestone_cavern_builder(new_depth, rng, width, height), + 4 => limestone_deep_cavern_builder(new_depth, rng, width, height), _ => random_builder(new_depth, rng, width, height), } } diff --git a/src/map_builders/limestone_cavern.rs b/src/map_builders/limestone_cavern.rs index ff69d2f..435b836 100644 --- a/src/map_builders/limestone_cavern.rs +++ b/src/map_builders/limestone_cavern.rs @@ -5,6 +5,8 @@ use super::{ DrunkardsWalkBuilder, MetaMapBuilder, VoronoiSpawning, XStart, YStart, }; use crate::map::TileType; +use crate::map_builders::dla::DLABuilder; +use crate::map_builders::prefab_builder::{prefab_sections, PrefabBuilder}; pub fn limestone_cavern_builder( new_depth: i32, @@ -25,6 +27,24 @@ pub fn limestone_cavern_builder( chain } +pub fn limestone_deep_cavern_builder( + new_depth: i32, + _rng: &mut RandomNumberGenerator, + width: i32, + height: i32, +) -> BuilderChain { + let mut chain = BuilderChain::new(new_depth, width, height, "Deep Limestone Caverns"); + chain + .start_with(DLABuilder::central_attractor()) + .with(AreaStartingPosition::new(XStart::Left, YStart::Top)) + .with(VoronoiSpawning::new()) + .with(DistantExit::new()) + .with(CaveDecorator::new()) + .with(PrefabBuilder::sectional(prefab_sections::ORC_CAMP)); + + chain +} + pub struct CaveDecorator {} impl MetaMapBuilder for CaveDecorator { diff --git a/src/map_builders/prefab_builder.rs b/src/map_builders/prefab_builder.rs index f12f16b..a6a3dfe 100644 --- a/src/map_builders/prefab_builder.rs +++ b/src/map_builders/prefab_builder.rs @@ -123,6 +123,15 @@ impl PrefabBuilder { .spawn_list .push((idx, "Health Potion".to_string())); } + '≈' => build_data.map.tiles[idx] = TileType::DeepWater, + 'O' => { + build_data.map.tiles[idx] = TileType::Floor; + build_data.spawn_list.push((idx, "Orc Leader".to_string())); + } + '☼' => { + build_data.map.tiles[idx] = TileType::Floor; + build_data.spawn_list.push((idx, "Watch Fire".to_string())); + } _ => { rltk::console::log(format!("Unknown glyph loading map: {}", (ch as u8) as char)); } diff --git a/src/map_builders/prefab_builder/prefab_sections.rs b/src/map_builders/prefab_builder/prefab_sections.rs index 2466787..f4a4c9d 100644 --- a/src/map_builders/prefab_builder/prefab_sections.rs +++ b/src/map_builders/prefab_builder/prefab_sections.rs @@ -78,3 +78,28 @@ const RIGHT_FORT: &str = " ####### # "; + +#[allow(dead_code)] +pub const ORC_CAMP: PrefabSection = PrefabSection { + template: ORC_CAMP_TXT, + width: 12, + height: 12, + placement: (HorizontalPlacement::Center, VerticalPlacement::Center), +}; + +#[allow(dead_code)] +const ORC_CAMP_TXT: &str = " + + ≈≈≈≈o≈≈≈≈≈ + ≈☼ ☼≈ + ≈ g ≈ + ≈ ≈ + ≈ g ≈ + o O o + ≈ ≈ + ≈ g ≈ + ≈ g ≈ + ≈☼ ☼≈ + ≈≈≈≈o≈≈≈≈≈ + +"; diff --git a/src/raws/prop_structs.rs b/src/raws/prop_structs.rs index da8ba30..e50c629 100644 --- a/src/raws/prop_structs.rs +++ b/src/raws/prop_structs.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; -use ::serde::Deserialize; - +use super::mob_structs::MobLight; use super::Renderable; +use ::serde::Deserialize; #[derive(Deserialize, Debug)] pub struct Prop { @@ -13,6 +13,7 @@ pub struct Prop { pub blocks_visibility: Option, pub door_open: Option, pub entry_trigger: Option, + pub light: Option, } #[derive(Deserialize, Debug)] diff --git a/src/raws/rawmaster.rs b/src/raws/rawmaster.rs index 24404d1..7eaf082 100644 --- a/src/raws/rawmaster.rs +++ b/src/raws/rawmaster.rs @@ -570,6 +570,18 @@ pub fn spawn_named_prop( } } } + if let Some(light) = &prop_template.light { + eb = eb + .with(LightSource { + range: light.range, + color: RGB::from_hex(&light.color).expect("Invalid color"), + }) + .with(Viewshed { + range: light.range, + dirty: true, + visible_tiles: Vec::new(), + }); + } return Some(eb.build()); }