Add 4th level type, completing section 5.17

This commit is contained in:
Timothy Warren 2022-01-14 10:47:43 -05:00
parent 022a7921ce
commit a3fdba4fe5
8 changed files with 176 additions and 10 deletions

View File

@ -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"
}
}
}
]
}

View File

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

View File

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

View File

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

View File

@ -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));
}

View File

@ -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
";

View File

@ -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<bool>,
pub door_open: Option<bool>,
pub entry_trigger: Option<EntryTrigger>,
pub light: Option<MobLight>,
}
#[derive(Deserialize, Debug)]

View File

@ -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());
}