ai refactor, mob spawns now take into account player level, small fixes
This commit is contained in:
parent
c00418f7c8
commit
6cef899ef6
21 changed files with 301 additions and 148 deletions
|
|
@ -32,6 +32,7 @@ impl<'a> System<'a> for EnergySystem {
|
|||
if energy.current >= TURN_COST {
|
||||
energy.current -= TURN_COST;
|
||||
crate::gamelog::record_event("turns", 1);
|
||||
// Handle spawning mobs each turn
|
||||
if LOG_TICKS {
|
||||
console::log(format!("===== TURN {} =====", crate::gamelog::get_event_count("turns")));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
mod energy_system;
|
||||
pub use energy_system::{EnergySystem, NORMAL_SPEED};
|
||||
mod turn_status;
|
||||
pub use turn_status::TurnStatusSystem;
|
||||
mod turn_status_system;
|
||||
pub use turn_status_system::TurnStatusSystem;
|
||||
mod quip_system;
|
||||
pub use quip_system::QuipSystem;
|
||||
|
|
|
|||
38
src/ai/quip_system.rs
Normal file
38
src/ai/quip_system.rs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
use crate::{gamelog, Name, Quips, TakingTurn, Viewshed};
|
||||
use rltk::prelude::*;
|
||||
use specs::prelude::*;
|
||||
|
||||
pub struct QuipSystem {}
|
||||
|
||||
impl<'a> System<'a> for QuipSystem {
|
||||
#[allow(clippy::type_complexity)]
|
||||
type SystemData = (
|
||||
WriteStorage<'a, Quips>,
|
||||
ReadStorage<'a, Name>,
|
||||
ReadStorage<'a, TakingTurn>,
|
||||
ReadExpect<'a, Point>,
|
||||
ReadStorage<'a, Viewshed>,
|
||||
WriteExpect<'a, RandomNumberGenerator>,
|
||||
);
|
||||
|
||||
fn run(&mut self, data: Self::SystemData) {
|
||||
let (mut quips, names, turns, player_pos, viewsheds, mut rng) = data;
|
||||
for (quip, name, viewshed, _turn) in (&mut quips, &names, &viewsheds, &turns).join() {
|
||||
if !quip.available.is_empty() && viewshed.visible_tiles.contains(&player_pos) && rng.roll_dice(1, 6) == 1 {
|
||||
let quip_index = if quip.available.len() == 1 {
|
||||
0
|
||||
} else {
|
||||
(rng.roll_dice(1, quip.available.len() as i32) - 1) as usize
|
||||
};
|
||||
gamelog::Logger::new()
|
||||
.append("The")
|
||||
.npc_name(&name.name)
|
||||
.append_n("says \"")
|
||||
.append_n(&quip.available[quip_index])
|
||||
.append("\"")
|
||||
.log();
|
||||
quip.available.remove(quip_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue