town tweaks

This commit is contained in:
Llywelwyn 2023-07-29 08:43:40 +01:00
parent 3dab5202f8
commit 6d6b84ae6a
8 changed files with 86 additions and 30 deletions

View file

@ -5,7 +5,7 @@
"renderable": { "glyph": "@", "fg": "#EE82EE", "bg": "#000000", "order": 1 }, "renderable": { "glyph": "@", "fg": "#EE82EE", "bg": "#000000", "order": 1 },
"flags": ["BYSTANDER", "BLOCKS_TILE"], "flags": ["BYSTANDER", "BLOCKS_TILE"],
"vision_range": 4, "vision_range": 4,
"quips": ["Drink?"] "quips": ["Drink?", "Something to eat?", "Don't go out on an empty stomach."]
}, },
{ {
"id": "npc_townsperson", "id": "npc_townsperson",
@ -13,7 +13,7 @@
"renderable": { "glyph": "@", "fg": "#9fa86c", "bg": "#000000", "order": 1 }, "renderable": { "glyph": "@", "fg": "#9fa86c", "bg": "#000000", "order": 1 },
"flags": ["BYSTANDER", "BLOCKS_TILE"], "flags": ["BYSTANDER", "BLOCKS_TILE"],
"vision_range": 4, "vision_range": 4,
"quips": ["You won't catch me quipping."] "quips": ["Hello!", "Good morning.", "<a quiet complaint about chores>"]
}, },
{ {
"id": "npc_drunk", "id": "npc_drunk",
@ -21,7 +21,7 @@
"renderable": { "glyph": "@", "fg": "#a0a83c", "bg": "#000000", "order": 1 }, "renderable": { "glyph": "@", "fg": "#a0a83c", "bg": "#000000", "order": 1 },
"flags": ["BYSTANDER", "BLOCKS_TILE"], "flags": ["BYSTANDER", "BLOCKS_TILE"],
"vision_range": 4, "vision_range": 4,
"quips": ["Hic!", "H-Hic'."] "quips": ["Hic!", "H-Hic'.", "Get me 'nother, would you?"]
}, },
{ {
"id": "npc_fisher", "id": "npc_fisher",
@ -29,7 +29,7 @@
"renderable": { "glyph": "@", "fg": "#3ca3a8", "bg": "#000000", "order": 1 }, "renderable": { "glyph": "@", "fg": "#3ca3a8", "bg": "#000000", "order": 1 },
"flags": ["BYSTANDER", "BLOCKS_TILE"], "flags": ["BYSTANDER", "BLOCKS_TILE"],
"vision_range": 4, "vision_range": 4,
"quips": ["Placeholder."] "quips": ["Hey."]
}, },
{ {
"id": "npc_dockworker", "id": "npc_dockworker",
@ -37,13 +37,14 @@
"renderable": { "glyph": "@", "fg": "#68d8de", "bg": "#000000", "order": 1 }, "renderable": { "glyph": "@", "fg": "#68d8de", "bg": "#000000", "order": 1 },
"flags": ["BYSTANDER", "BLOCKS_TILE"], "flags": ["BYSTANDER", "BLOCKS_TILE"],
"vision_range": 4, "vision_range": 4,
"quips": ["Placeholder."] "quips": ["No boat for a few days.", "Not much for us to do."]
}, },
{ {
"id": "npc_priest", "id": "npc_priest",
"name": "priest", "name": "priest",
"renderable": { "glyph": "@", "fg": "#FFFFFF", "bg": "#000000", "order": 1 }, "renderable": { "glyph": "@", "fg": "#FFFFFF", "bg": "#000000", "order": 1 },
"flags": ["BYSTANDER", "BLOCKS_TILE"], "flags": ["BYSTANDER", "BLOCKS_TILE"],
"quips": ["Light's givings.", "<a quiet prayer>", "Bless you."],
"vision_range": 4 "vision_range": 4
}, },
{ {
@ -52,6 +53,7 @@
"renderable": { "glyph": "@", "fg": "#946123", "bg": "#000000", "order": 1 }, "renderable": { "glyph": "@", "fg": "#946123", "bg": "#000000", "order": 1 },
"flags": ["BYSTANDER", "BLOCKS_TILE"], "flags": ["BYSTANDER", "BLOCKS_TILE"],
"vision_range": 4, "vision_range": 4,
"quips": ["You're not borrowing my pick."],
"attacks": [ "attacks": [
{ "name": "hits", "hit_bonus": 0, "damage": "1d8"} { "name": "hits", "hit_bonus": 0, "damage": "1d8"}
] ]
@ -63,7 +65,7 @@
"flags": ["BYSTANDER", "BLOCKS_TILE"], "flags": ["BYSTANDER", "BLOCKS_TILE"],
"level": 2, "level": 2,
"vision_range": 4, "vision_range": 4,
"quips": ["You wont catch me down the mine.", "I'm not paid enough for that."], "quips": ["You wont catch me down the mine.", "Staying out of trouble?"],
"attacks": [ "attacks": [
{ "name": "hits", "hit_bonus": 0, "damage": "1d8"} { "name": "hits", "hit_bonus": 0, "damage": "1d8"}
], ],
@ -77,6 +79,7 @@
"level": 2, "level": 2,
"bac": 6, "bac": 6,
"vision_range": 12, "vision_range": 12,
"quips": ["<woof!>", "<bark!>", "<grrr..>"],
"attacks": [ "attacks": [
{ "name": "bites", "hit_bonus": 0, "damage": "1d6"} { "name": "bites", "hit_bonus": 0, "damage": "1d6"}
] ]
@ -92,6 +95,28 @@
{ "name": "bites", "hit_bonus": 0, "damage": "1d2"} { "name": "bites", "hit_bonus": 0, "damage": "1d2"}
] ]
}, },
{
"id": "chicken",
"name": "chicken",
"renderable": { "glyph": "c", "fg": "#BB6000", "bg": "#000000", "order": 1 },
"flags": ["BYSTANDER", "BLOCKS_TILE"],
"bac": 8,
"vision_range": 4,
"attacks": [
{ "name": "bites", "hit_bonus": 0, "damage": "1d3"}
]
},
{
"id": "chicken_little",
"name": "chick",
"renderable": { "glyph": "c", "fg": "#fae478", "bg": "#000000", "order": 1 },
"flags": ["BYSTANDER", "BLOCKS_TILE"],
"bac": 10,
"vision_range": 4,
"attacks": [
{ "name": "bites", "hit_bonus": 0, "damage": "1d2"}
]
},
{ {
"id": "rat_giant", "id": "rat_giant",
"name": "giant rat", "name": "giant rat",

View file

@ -5,6 +5,12 @@
"renderable": { "glyph": "+", "fg": "#00FFFF", "bg": "#000000", "order": 2 }, "renderable": { "glyph": "+", "fg": "#00FFFF", "bg": "#000000", "order": 2 },
"flags": ["BLOCKS_TILE", "BLOCKS_VISIBILITY", "DOOR", "PROP"] "flags": ["BLOCKS_TILE", "BLOCKS_VISIBILITY", "DOOR", "PROP"]
}, },
{
"id": "prop_altar",
"name": "altar",
"renderable": { "glyph": "_", "fg": "#FFFFFF", "bg": "#000000", "order": 2 },
"flags": ["PROP"]
},
{ {
"id": "prop_keg", "id": "prop_keg",
"name": "keg", "name": "keg",

View file

@ -61,6 +61,7 @@
{ {
"id": "mobs", "id": "mobs",
"table": [ "table": [
{ "id": "chicken", "weight": 1, "difficulty": 1},
{ "id": "rat", "weight": 1, "difficulty": 1}, { "id": "rat", "weight": 1, "difficulty": 1},
{ "id": "goblin", "weight": 3, "difficulty": 1}, { "id": "goblin", "weight": 3, "difficulty": 1},
{ "id": "kobold", "weight": 1, "difficulty": 1}, { "id": "kobold", "weight": 1, "difficulty": 1},

View file

@ -566,7 +566,7 @@ fn main() -> rltk::BError {
raws::load_raws(); raws::load_raws();
gs.ecs.insert(rltk::RandomNumberGenerator::new()); gs.ecs.insert(rltk::RandomNumberGenerator::new());
gs.ecs.insert(Map::new(1, 64, 64, 0)); gs.ecs.insert(Map::new(1, 64, 64, 0, "New Map"));
gs.ecs.insert(Point::new(0, 0)); gs.ecs.insert(Point::new(0, 0));
let player_entity = spawner::player(&mut gs.ecs, 0, 0); let player_entity = spawner::player(&mut gs.ecs, 0, 0);
gs.ecs.insert(player_entity); gs.ecs.insert(player_entity);

View file

@ -24,6 +24,7 @@ pub struct Map {
pub additional_fg_offset: rltk::RGB, pub additional_fg_offset: rltk::RGB,
pub blocked: Vec<bool>, pub blocked: Vec<bool>,
pub id: i32, pub id: i32,
pub name: String,
pub difficulty: i32, pub difficulty: i32,
pub bloodstains: HashSet<usize>, pub bloodstains: HashSet<usize>,
pub view_blocked: HashSet<usize>, pub view_blocked: HashSet<usize>,
@ -38,7 +39,7 @@ impl Map {
(y as usize) * (self.width as usize) + (x as usize) (y as usize) * (self.width as usize) + (x as usize)
} }
pub fn new(new_id: i32, width: i32, height: i32, difficulty: i32) -> Map { pub fn new<S: ToString>(new_id: i32, width: i32, height: i32, difficulty: i32, name: S) -> Map {
let map_tile_count = (width * height) as usize; let map_tile_count = (width * height) as usize;
let mut map = Map { let mut map = Map {
tiles: vec![TileType::Wall; map_tile_count], tiles: vec![TileType::Wall; map_tile_count],
@ -52,6 +53,7 @@ impl Map {
additional_fg_offset: rltk::RGB::from_u8(HALF_OFFSET, HALF_OFFSET, HALF_OFFSET), additional_fg_offset: rltk::RGB::from_u8(HALF_OFFSET, HALF_OFFSET, HALF_OFFSET),
blocked: vec![false; map_tile_count], blocked: vec![false; map_tile_count],
id: new_id, id: new_id,
name: name.to_string(),
difficulty: difficulty, difficulty: difficulty,
bloodstains: HashSet::new(), bloodstains: HashSet::new(),
view_blocked: HashSet::new(), view_blocked: HashSet::new(),

View file

@ -92,13 +92,13 @@ pub struct BuilderChain {
} }
impl BuilderChain { impl BuilderChain {
pub fn new(new_id: i32, width: i32, height: i32, difficulty: i32) -> BuilderChain { pub fn new<S: ToString>(new_id: i32, width: i32, height: i32, difficulty: i32, name: S) -> BuilderChain {
BuilderChain { BuilderChain {
starter: None, starter: None,
builders: Vec::new(), builders: Vec::new(),
build_data: BuilderMap { build_data: BuilderMap {
spawn_list: Vec::new(), spawn_list: Vec::new(),
map: Map::new(new_id, width, height, difficulty), map: Map::new(new_id, width, height, difficulty, name),
starting_position: None, starting_position: None,
rooms: None, rooms: None,
corridors: None, corridors: None,
@ -296,7 +296,7 @@ pub fn random_builder(
difficulty: i32, difficulty: i32,
) -> BuilderChain { ) -> BuilderChain {
rltk::console::log(format!("DEBUGINFO: Building random (ID:{}, DIFF:{})", new_id, difficulty)); rltk::console::log(format!("DEBUGINFO: Building random (ID:{}, DIFF:{})", new_id, difficulty));
let mut builder = BuilderChain::new(new_id, width, height, difficulty); let mut builder = BuilderChain::new(new_id, width, height, difficulty, "<PLACEHOLDER>");
let type_roll = rng.roll_dice(1, 2); let type_roll = rng.roll_dice(1, 2);
let mut want_doors = true; let mut want_doors = true;
match type_roll { match type_roll {

View file

@ -2,9 +2,9 @@ use super::{BuilderChain, BuilderMap, InitialMapBuilder, Position, TileType};
use std::collections::HashSet; use std::collections::HashSet;
pub fn town_builder(new_id: i32, _rng: &mut rltk::RandomNumberGenerator, width: i32, height: i32) -> BuilderChain { pub fn town_builder(new_id: i32, _rng: &mut rltk::RandomNumberGenerator, width: i32, height: i32) -> BuilderChain {
let difficulty = 7; let difficulty = 0;
rltk::console::log(format!("DEBUGINFO: Building town (ID:{}, DIFF:{})", new_id, difficulty)); rltk::console::log(format!("DEBUGINFO: Building town (ID:{}, DIFF:{})", new_id, difficulty));
let mut chain = BuilderChain::new(new_id, width, height, difficulty); let mut chain = BuilderChain::new(new_id, width, height, difficulty, "<PLACEHOLDER>");
chain.start_with(TownBuilder::new()); chain.start_with(TownBuilder::new());
return chain; return chain;
@ -71,7 +71,7 @@ impl TownBuilder {
building_size[1].2 = BuildingTag::Temple; building_size[1].2 = BuildingTag::Temple;
building_size[2].2 = BuildingTag::Mine; building_size[2].2 = BuildingTag::Mine;
building_size[3].2 = BuildingTag::PlayerHouse; building_size[3].2 = BuildingTag::PlayerHouse;
for b in building_size.iter_mut().skip(3) { for b in building_size.iter_mut().skip(4) {
b.2 = BuildingTag::NPCHouse b.2 = BuildingTag::NPCHouse
} }
let last_idx = building_size.len() - 1; let last_idx = building_size.len() - 1;
@ -121,12 +121,21 @@ impl TownBuilder {
) { ) {
for idx in available_building_tiles.iter() { for idx in available_building_tiles.iter() {
if rng.roll_dice(1, 40) == 1 { if rng.roll_dice(1, 40) == 1 {
let roll = rng.roll_dice(1, 3); let roll = rng.roll_dice(1, 6);
match roll { match roll {
1 => build_data.spawn_list.push((*idx, "npc_fisher".to_string())), 1 => build_data.spawn_list.push((*idx, "npc_fisher".to_string())),
2 => build_data.spawn_list.push((*idx, "npc_dockworker".to_string())), 2 => build_data.spawn_list.push((*idx, "npc_dockworker".to_string())),
3 => build_data.spawn_list.push((*idx, "npc_townsperson".to_string())), 3 => build_data.spawn_list.push((*idx, "npc_drunk".to_string())),
_ => build_data.spawn_list.push((*idx, "npc_drunk".to_string())), 4 => build_data.spawn_list.push((*idx, "npc_townsperson".to_string())),
5 => build_data.spawn_list.push((*idx, "npc_guard".to_string())),
_ => {
let animal_roll = rng.roll_dice(1, 3);
match animal_roll {
1 => build_data.spawn_list.push((*idx, "chicken_little".to_string())),
2 => build_data.spawn_list.push((*idx, "chicken".to_string())),
_ => build_data.spawn_list.push((*idx, "dog_little".to_string())),
}
}
} }
} }
} }
@ -171,12 +180,11 @@ impl TownBuilder {
let mut to_place: Vec<&str> = vec![ let mut to_place: Vec<&str> = vec![
"npc_barkeep", "npc_barkeep",
"npc_townsperson", "npc_townsperson",
"npc_townsperson",
"npc_drunk", "npc_drunk",
"npc_drunk", "npc_drunk",
"npc_guard",
"prop_keg", "prop_keg",
"prop_table", "prop_table",
"prop_table",
"prop_chair", "prop_chair",
"prop_chair", "prop_chair",
]; ];
@ -189,8 +197,17 @@ impl TownBuilder {
build_data: &mut BuilderMap, build_data: &mut BuilderMap,
rng: &mut rltk::RandomNumberGenerator, rng: &mut rltk::RandomNumberGenerator,
) { ) {
let mut to_place: Vec<&str> = let mut to_place: Vec<&str> = vec![
vec!["npc_priest", "prop_chair", "prop_chair", "prop_table", "prop_candle", "prop_candle"]; "npc_priest",
"prop_altar",
"prop_chair",
"prop_chair",
"prop_chair",
"prop_table",
"prop_table",
"prop_candle",
"prop_candle",
];
self.random_building_spawn(building, build_data, rng, &mut to_place, 0) self.random_building_spawn(building, build_data, rng, &mut to_place, 0)
} }
@ -203,7 +220,7 @@ impl TownBuilder {
// Place exit // Place exit
let exit_idx = build_data.map.xy_idx(building.0 + (building.2 / 2), building.1 + (building.3 / 2)); let exit_idx = build_data.map.xy_idx(building.0 + (building.2 / 2), building.1 + (building.3 / 2));
build_data.map.tiles[exit_idx] = TileType::DownStair; build_data.map.tiles[exit_idx] = TileType::DownStair;
let mut to_place: Vec<&str> = vec!["npc_miner", "npc_miner", "npc_guard"]; let mut to_place: Vec<&str> = vec!["npc_miner", "npc_miner", "npc_guard", "prop_chair"];
self.random_building_spawn(building, build_data, rng, &mut to_place, exit_idx) self.random_building_spawn(building, build_data, rng, &mut to_place, exit_idx)
} }
@ -213,7 +230,7 @@ impl TownBuilder {
build_data: &mut BuilderMap, build_data: &mut BuilderMap,
rng: &mut rltk::RandomNumberGenerator, rng: &mut rltk::RandomNumberGenerator,
) { ) {
let mut to_place: Vec<&str> = vec!["prop_bed", "prop_table"]; let mut to_place: Vec<&str> = vec!["prop_bed", "prop_table", "dog_little", "prop_chair", "prop_chair"];
self.random_building_spawn(building, build_data, rng, &mut to_place, 0); self.random_building_spawn(building, build_data, rng, &mut to_place, 0);
} }
@ -223,7 +240,7 @@ impl TownBuilder {
build_data: &mut BuilderMap, build_data: &mut BuilderMap,
rng: &mut rltk::RandomNumberGenerator, rng: &mut rltk::RandomNumberGenerator,
) { ) {
let mut to_place: Vec<&str> = vec!["prop_bed", "prop_table"]; let mut to_place: Vec<&str> = vec!["npc_townsperson", "prop_bed", "prop_table", "prop_chair"];
self.random_building_spawn(building, build_data, rng, &mut to_place, 0); self.random_building_spawn(building, build_data, rng, &mut to_place, 0);
} }
@ -233,7 +250,7 @@ impl TownBuilder {
build_data: &mut BuilderMap, build_data: &mut BuilderMap,
rng: &mut rltk::RandomNumberGenerator, rng: &mut rltk::RandomNumberGenerator,
) { ) {
let mut to_place: Vec<&str> = vec!["rat", "rat", "rat"]; let mut to_place: Vec<&str> = vec!["rat", "rat", "rat", "prop_table", "prop_chair"];
self.random_building_spawn(building, build_data, rng, &mut to_place, 0); self.random_building_spawn(building, build_data, rng, &mut to_place, 0);
} }
@ -335,7 +352,7 @@ impl TownBuilder {
const BORDER: i32 = 4; const BORDER: i32 = 4;
const OFFSET_FROM_LEFT: i32 = 25 + BORDER; const OFFSET_FROM_LEFT: i32 = 25 + BORDER;
const PATH_OFFSET_FROM_CENTRE: i32 = 4; const PATH_OFFSET_FROM_CENTRE: i32 = 10;
const HALF_PATH_THICKNESS: i32 = 3; const HALF_PATH_THICKNESS: i32 = 3;
let wall_gap_y = let wall_gap_y =

View file

@ -31,8 +31,13 @@ impl WaveFunctionCollapseBuilder {
let constraints = patterns_to_constraints(patterns, CHUNK_SIZE); let constraints = patterns_to_constraints(patterns, CHUNK_SIZE);
self.render_tile_gallery(&constraints, CHUNK_SIZE, build_data); self.render_tile_gallery(&constraints, CHUNK_SIZE, build_data);
build_data.map = build_data.map = Map::new(
Map::new(build_data.map.id, build_data.map.width, build_data.map.height, build_data.map.difficulty); build_data.map.id,
build_data.map.width,
build_data.map.height,
build_data.map.difficulty,
&build_data.map.name,
);
loop { loop {
let mut solver = Solver::new(constraints.clone(), CHUNK_SIZE, &build_data.map); let mut solver = Solver::new(constraints.clone(), CHUNK_SIZE, &build_data.map);
while !solver.iteration(&mut build_data.map, rng) { while !solver.iteration(&mut build_data.map, rng) {
@ -47,7 +52,7 @@ impl WaveFunctionCollapseBuilder {
} }
fn render_tile_gallery(&mut self, constraints: &[MapChunk], chunk_size: i32, build_data: &mut BuilderMap) { fn render_tile_gallery(&mut self, constraints: &[MapChunk], chunk_size: i32, build_data: &mut BuilderMap) {
build_data.map = Map::new(0, build_data.width, build_data.height, 0); build_data.map = Map::new(0, build_data.width, build_data.height, 0, &build_data.map.name);
let mut counter = 0; let mut counter = 0;
let mut x = 1; let mut x = 1;
let mut y = 1; let mut y = 1;
@ -63,7 +68,7 @@ impl WaveFunctionCollapseBuilder {
if y + chunk_size > build_data.map.height { if y + chunk_size > build_data.map.height {
// Move to the next page // Move to the next page
build_data.take_snapshot(); build_data.take_snapshot();
build_data.map = Map::new(0, build_data.width, build_data.height, 0); build_data.map = Map::new(0, build_data.width, build_data.height, 0, &build_data.map.name);
x = 1; x = 1;
y = 1; y = 1;