diff --git a/src/inventory_system.rs b/src/inventory_system.rs index 36d7e85..f244800 100644 --- a/src/inventory_system.rs +++ b/src/inventory_system.rs @@ -1,7 +1,7 @@ use super::{ gamelog::GameLog, CombatStats, Confusion, Consumable, Destructible, InBackpack, InflictsDamage, Map, Name, ParticleBuilder, Position, ProvidesHealing, SufferDamage, WantsToDropItem, WantsToPickupItem, WantsToUseItem, AOE, - DEFAULT_PARTICLE_LIFETIME, + DEFAULT_PARTICLE_LIFETIME, LONG_PARTICLE_LIFETIME, }; use specs::prelude::*; @@ -113,7 +113,7 @@ impl<'a> System<'a> for ItemUseSystem { rltk::RGB::named(rltk::ORANGE), rltk::RGB::named(rltk::BLACK), rltk::to_cp437('░'), - 200.0, + LONG_PARTICLE_LIFETIME, ); } } @@ -208,7 +208,6 @@ impl<'a> System<'a> for ItemUseSystem { match causes_confusion { None => {} Some(confusion) => { - used_item = false; for mob in targets.iter() { add_confusion.push((*mob, confusion.turns)); // Gamelog entry for this is handled turn-by-turn in AI. diff --git a/src/main.rs b/src/main.rs index 7550725..0b506fd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,7 +26,7 @@ use melee_combat_system::MeleeCombatSystem; mod inventory_system; use inventory_system::*; mod particle_system; -use particle_system::{ParticleBuilder, DEFAULT_PARTICLE_LIFETIME}; +use particle_system::{ParticleBuilder, DEFAULT_PARTICLE_LIFETIME, LONG_PARTICLE_LIFETIME}; mod rex_assets; // Embedded resources for use in wasm build diff --git a/src/monster_ai_system.rs b/src/monster_ai_system.rs index a0a6803..69dd326 100644 --- a/src/monster_ai_system.rs +++ b/src/monster_ai_system.rs @@ -1,4 +1,6 @@ -use super::{gamelog::GameLog, Confusion, Map, Monster, Name, Position, RunState, Viewshed, WantsToMelee}; +use super::{ + gamelog::GameLog, Confusion, Map, Monster, Name, ParticleBuilder, Position, RunState, Viewshed, WantsToMelee, +}; use rltk::Point; use specs::prelude::*; @@ -19,6 +21,7 @@ impl<'a> System<'a> for MonsterAI { WriteStorage<'a, WantsToMelee>, WriteStorage<'a, Confusion>, ReadStorage<'a, Name>, + WriteExpect<'a, ParticleBuilder>, ); fn run(&mut self, data: Self::SystemData) { @@ -35,6 +38,7 @@ impl<'a> System<'a> for MonsterAI { mut wants_to_melee, mut confused, name, + mut particle_builder, ) = data; if *runstate != RunState::MonsterTurn { @@ -48,11 +52,18 @@ impl<'a> System<'a> for MonsterAI { let is_confused = confused.get_mut(entity); if let Some(i_am_confused) = is_confused { i_am_confused.turns -= 1; + let entity_name = name.get(entity).unwrap(); + let mut fg = rltk::RGB::named(rltk::MAGENTA); + let mut glyph = rltk::to_cp437('?'); if i_am_confused.turns < 1 { confused.remove(entity); + gamelog.entries.push(format!("{} snaps out of its confusion!", entity_name.name)); + fg = rltk::RGB::named(rltk::MEDIUMSLATEBLUE); + glyph = rltk::to_cp437('!'); + } else { + gamelog.entries.push(format!("{} is confused.", entity_name.name)); } - let entity_name = name.get(entity).unwrap(); - gamelog.entries.push(format!("{} is confused!", entity_name.name)); + particle_builder.request(pos.x, pos.y, fg, rltk::RGB::named(rltk::BLACK), glyph, 200.0); can_act = false; } diff --git a/src/particle_system.rs b/src/particle_system.rs index 6928222..343519c 100644 --- a/src/particle_system.rs +++ b/src/particle_system.rs @@ -2,7 +2,11 @@ use super::{ParticleLifetime, Position, Renderable, Rltk}; use rltk::RGB; use specs::prelude::*; +// For things which will happen frequently - i.e. attacking. pub const DEFAULT_PARTICLE_LIFETIME: f32 = 150.0; +// For exceptional things, like large AOEs, to make sure the +// player can actually see what's being impacted - i.e. fireball. +pub const LONG_PARTICLE_LIFETIME: f32 = 300.0; /// Runs each tick, deleting particles who are past their expiry. // Should make an addition to this to also spawn delayed particles, diff --git a/src/spawner.rs b/src/spawner.rs index c55ed9a..bbd6d9d 100644 --- a/src/spawner.rs +++ b/src/spawner.rs @@ -180,6 +180,8 @@ fn poison_potion(ecs: &mut World, x: i32, y: i32) { .build(); } +// Scrolls +// ~10 range should be considered average here. fn magic_missile_scroll(ecs: &mut World, x: i32, y: i32) { ecs.create_entity() .with(Position { x, y }) @@ -193,8 +195,8 @@ fn magic_missile_scroll(ecs: &mut World, x: i32, y: i32) { .with(Item {}) .with(Consumable {}) .with(Destructible {}) - .with(Ranged { range: 12 }) - .with(InflictsDamage { amount: 10 }) + .with(Ranged { range: 12 }) // Long range - as far as default vision range + .with(InflictsDamage { amount: 10 }) // Low~ damage .build(); } @@ -230,7 +232,7 @@ fn confusion_scroll(ecs: &mut World, x: i32, y: i32) { .with(Item {}) .with(Consumable {}) .with(Destructible {}) - .with(Ranged { range: 6 }) + .with(Ranged { range: 10 }) .with(Confusion { turns: 4 }) .build(); }