chance to log dungeon features per clock turn
This commit is contained in:
parent
050973eae4
commit
a038a3f586
6 changed files with 59 additions and 8 deletions
|
|
@ -43,3 +43,9 @@ pub const PLAYER_DIED_ADDENDUM_LAST: &str = ", and ";
|
|||
pub const STATUS_CONFUSED_STRING: &str = "confused";
|
||||
pub const STATUS_BLIND_STRING: &str = "blinded";
|
||||
// Results in something like: "You died! You were killed by a kobold captain, whilst confused."
|
||||
|
||||
// Dungeon features
|
||||
pub const FEATURE_TREANTS: &str = "You feel an unusual freshness in the air.";
|
||||
pub const FEATURE_BARRACKS_GOBLIN: &str = "You hear an order being barked, and ignored.";
|
||||
pub const FEATURE_BARRACKS_KOBOLD: &str = "You hear someone being reprimanded for disobedience.";
|
||||
pub const FEATURE_BARRACKS_ORC: &str = "You hear someone barking orders.";
|
||||
|
|
|
|||
|
|
@ -273,6 +273,7 @@ impl GameState for State {
|
|||
self.run_systems();
|
||||
self.ecs.maintain();
|
||||
try_spawn_interval(&mut self.ecs);
|
||||
maybe_map_message(&mut self.ecs);
|
||||
match *self.ecs.fetch::<RunState>() {
|
||||
RunState::AwaitingInput => {
|
||||
new_runstate = RunState::AwaitingInput;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,33 @@ use specs::prelude::*;
|
|||
use crate::data::events::*;
|
||||
|
||||
const TRY_SPAWN_CHANCE: i32 = 70;
|
||||
const FEATURE_MESSAGE_CHANCE: i32 = 110;
|
||||
|
||||
pub fn maybe_map_message(ecs: &mut World) {
|
||||
let mut maybe_message = false;
|
||||
let map = ecs.fetch::<Map>();
|
||||
if map.messages.is_empty() {
|
||||
return;
|
||||
}
|
||||
// Scope for borrow checker (ECS)
|
||||
{
|
||||
let clock = ecs.read_storage::<Clock>();
|
||||
let turns = ecs.read_storage::<TakingTurn>();
|
||||
let mut rng = ecs.write_resource::<rltk::RandomNumberGenerator>();
|
||||
for (_c, _t) in (&clock, &turns).join() {
|
||||
if rng.roll_dice(1, FEATURE_MESSAGE_CHANCE) == 1 {
|
||||
maybe_message = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if maybe_message {
|
||||
let mut logger = gamelog::Logger::new();
|
||||
for message in map.messages.clone() {
|
||||
logger = logger.append(message);
|
||||
}
|
||||
logger.log();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_spawn_interval(ecs: &mut World) {
|
||||
let mut try_spawn = false;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use std::collections::{ HashSet, HashMap };
|
|||
mod tiletype;
|
||||
pub use tiletype::{ tile_cost, tile_opaque, tile_walkable, TileType, get_dest, Destination };
|
||||
mod interval_spawning_system;
|
||||
pub use interval_spawning_system::try_spawn_interval;
|
||||
pub use interval_spawning_system::{ maybe_map_message, try_spawn_interval };
|
||||
pub mod dungeon;
|
||||
pub use dungeon::{ level_transition, MasterDungeonMap };
|
||||
pub mod themes;
|
||||
|
|
@ -30,6 +30,7 @@ pub struct Map {
|
|||
pub name: String,
|
||||
pub short_name: String,
|
||||
pub depth: i32,
|
||||
pub messages: HashSet<String>,
|
||||
pub difficulty: i32,
|
||||
pub bloodstains: HashMap<usize, RGB>,
|
||||
pub view_blocked: HashSet<usize>,
|
||||
|
|
@ -70,6 +71,7 @@ impl Map {
|
|||
id: new_id,
|
||||
name: name.to_string(),
|
||||
short_name: short_name.to_string(),
|
||||
messages: HashSet::new(),
|
||||
depth: depth,
|
||||
difficulty: difficulty,
|
||||
bloodstains: HashMap::new(),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use super::{ BuilderMap, MetaMapBuilder, Rect, TileType };
|
||||
use crate::tile_walkable;
|
||||
use crate::data::messages::{ FEATURE_TREANTS, FEATURE_BARRACKS_GOBLIN, FEATURE_BARRACKS_KOBOLD, FEATURE_BARRACKS_ORC };
|
||||
use crate::raws;
|
||||
use rltk::RandomNumberGenerator;
|
||||
|
||||
|
|
@ -59,6 +60,7 @@ impl ThemeRooms {
|
|||
}
|
||||
}
|
||||
}
|
||||
build_data.map.messages.insert(FEATURE_TREANTS.to_string());
|
||||
}
|
||||
|
||||
fn place_barracks(&mut self, rng: &mut RandomNumberGenerator, build_data: &mut BuilderMap, room: &Rect) {
|
||||
|
|
@ -75,9 +77,18 @@ impl ThemeRooms {
|
|||
|
||||
let mut needs_captain = if rng.roll_dice(1, 3) == 1 { false } else { true };
|
||||
let (captain, squad) = match rng.roll_dice(1, 4) {
|
||||
1 => ("goblin_chieftain", "squad_goblin"),
|
||||
2 => ("kobold_captain", "squad_kobold"),
|
||||
_ => ("orc_captain", "squad_orc"),
|
||||
1 => {
|
||||
build_data.map.messages.insert(FEATURE_BARRACKS_GOBLIN.to_string());
|
||||
("goblin_chieftain", "squad_goblin")
|
||||
}
|
||||
2 => {
|
||||
build_data.map.messages.insert(FEATURE_BARRACKS_KOBOLD.to_string());
|
||||
("kobold_captain", "squad_kobold")
|
||||
}
|
||||
_ => {
|
||||
build_data.map.messages.insert(FEATURE_BARRACKS_ORC.to_string());
|
||||
("orc_captain", "squad_orc")
|
||||
}
|
||||
};
|
||||
for idx in possible {
|
||||
if idx % 2 == 0 && rng.roll_dice(1, 2) == 1 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue