particle lifetime consts, and confusion msg fixes
This commit is contained in:
parent
22d90a46b4
commit
dd91a8cca7
5 changed files with 26 additions and 10 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
use super::{
|
use super::{
|
||||||
gamelog::GameLog, CombatStats, Confusion, Consumable, Destructible, InBackpack, InflictsDamage, Map, Name,
|
gamelog::GameLog, CombatStats, Confusion, Consumable, Destructible, InBackpack, InflictsDamage, Map, Name,
|
||||||
ParticleBuilder, Position, ProvidesHealing, SufferDamage, WantsToDropItem, WantsToPickupItem, WantsToUseItem, AOE,
|
ParticleBuilder, Position, ProvidesHealing, SufferDamage, WantsToDropItem, WantsToPickupItem, WantsToUseItem, AOE,
|
||||||
DEFAULT_PARTICLE_LIFETIME,
|
DEFAULT_PARTICLE_LIFETIME, LONG_PARTICLE_LIFETIME,
|
||||||
};
|
};
|
||||||
use specs::prelude::*;
|
use specs::prelude::*;
|
||||||
|
|
||||||
|
|
@ -113,7 +113,7 @@ impl<'a> System<'a> for ItemUseSystem {
|
||||||
rltk::RGB::named(rltk::ORANGE),
|
rltk::RGB::named(rltk::ORANGE),
|
||||||
rltk::RGB::named(rltk::BLACK),
|
rltk::RGB::named(rltk::BLACK),
|
||||||
rltk::to_cp437('░'),
|
rltk::to_cp437('░'),
|
||||||
200.0,
|
LONG_PARTICLE_LIFETIME,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -208,7 +208,6 @@ impl<'a> System<'a> for ItemUseSystem {
|
||||||
match causes_confusion {
|
match causes_confusion {
|
||||||
None => {}
|
None => {}
|
||||||
Some(confusion) => {
|
Some(confusion) => {
|
||||||
used_item = false;
|
|
||||||
for mob in targets.iter() {
|
for mob in targets.iter() {
|
||||||
add_confusion.push((*mob, confusion.turns));
|
add_confusion.push((*mob, confusion.turns));
|
||||||
// Gamelog entry for this is handled turn-by-turn in AI.
|
// Gamelog entry for this is handled turn-by-turn in AI.
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ use melee_combat_system::MeleeCombatSystem;
|
||||||
mod inventory_system;
|
mod inventory_system;
|
||||||
use inventory_system::*;
|
use inventory_system::*;
|
||||||
mod particle_system;
|
mod particle_system;
|
||||||
use particle_system::{ParticleBuilder, DEFAULT_PARTICLE_LIFETIME};
|
use particle_system::{ParticleBuilder, DEFAULT_PARTICLE_LIFETIME, LONG_PARTICLE_LIFETIME};
|
||||||
mod rex_assets;
|
mod rex_assets;
|
||||||
|
|
||||||
// Embedded resources for use in wasm build
|
// Embedded resources for use in wasm build
|
||||||
|
|
|
||||||
|
|
@ -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 rltk::Point;
|
||||||
use specs::prelude::*;
|
use specs::prelude::*;
|
||||||
|
|
||||||
|
|
@ -19,6 +21,7 @@ impl<'a> System<'a> for MonsterAI {
|
||||||
WriteStorage<'a, WantsToMelee>,
|
WriteStorage<'a, WantsToMelee>,
|
||||||
WriteStorage<'a, Confusion>,
|
WriteStorage<'a, Confusion>,
|
||||||
ReadStorage<'a, Name>,
|
ReadStorage<'a, Name>,
|
||||||
|
WriteExpect<'a, ParticleBuilder>,
|
||||||
);
|
);
|
||||||
|
|
||||||
fn run(&mut self, data: Self::SystemData) {
|
fn run(&mut self, data: Self::SystemData) {
|
||||||
|
|
@ -35,6 +38,7 @@ impl<'a> System<'a> for MonsterAI {
|
||||||
mut wants_to_melee,
|
mut wants_to_melee,
|
||||||
mut confused,
|
mut confused,
|
||||||
name,
|
name,
|
||||||
|
mut particle_builder,
|
||||||
) = data;
|
) = data;
|
||||||
|
|
||||||
if *runstate != RunState::MonsterTurn {
|
if *runstate != RunState::MonsterTurn {
|
||||||
|
|
@ -48,11 +52,18 @@ impl<'a> System<'a> for MonsterAI {
|
||||||
let is_confused = confused.get_mut(entity);
|
let is_confused = confused.get_mut(entity);
|
||||||
if let Some(i_am_confused) = is_confused {
|
if let Some(i_am_confused) = is_confused {
|
||||||
i_am_confused.turns -= 1;
|
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 {
|
if i_am_confused.turns < 1 {
|
||||||
confused.remove(entity);
|
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();
|
particle_builder.request(pos.x, pos.y, fg, rltk::RGB::named(rltk::BLACK), glyph, 200.0);
|
||||||
gamelog.entries.push(format!("{} is confused!", entity_name.name));
|
|
||||||
can_act = false;
|
can_act = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,11 @@ use super::{ParticleLifetime, Position, Renderable, Rltk};
|
||||||
use rltk::RGB;
|
use rltk::RGB;
|
||||||
use specs::prelude::*;
|
use specs::prelude::*;
|
||||||
|
|
||||||
|
// For things which will happen frequently - i.e. attacking.
|
||||||
pub const DEFAULT_PARTICLE_LIFETIME: f32 = 150.0;
|
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.
|
/// Runs each tick, deleting particles who are past their expiry.
|
||||||
// Should make an addition to this to also spawn delayed particles,
|
// Should make an addition to this to also spawn delayed particles,
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,8 @@ fn poison_potion(ecs: &mut World, x: i32, y: i32) {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scrolls
|
||||||
|
// ~10 range should be considered average here.
|
||||||
fn magic_missile_scroll(ecs: &mut World, x: i32, y: i32) {
|
fn magic_missile_scroll(ecs: &mut World, x: i32, y: i32) {
|
||||||
ecs.create_entity()
|
ecs.create_entity()
|
||||||
.with(Position { x, y })
|
.with(Position { x, y })
|
||||||
|
|
@ -193,8 +195,8 @@ fn magic_missile_scroll(ecs: &mut World, x: i32, y: i32) {
|
||||||
.with(Item {})
|
.with(Item {})
|
||||||
.with(Consumable {})
|
.with(Consumable {})
|
||||||
.with(Destructible {})
|
.with(Destructible {})
|
||||||
.with(Ranged { range: 12 })
|
.with(Ranged { range: 12 }) // Long range - as far as default vision range
|
||||||
.with(InflictsDamage { amount: 10 })
|
.with(InflictsDamage { amount: 10 }) // Low~ damage
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -230,7 +232,7 @@ fn confusion_scroll(ecs: &mut World, x: i32, y: i32) {
|
||||||
.with(Item {})
|
.with(Item {})
|
||||||
.with(Consumable {})
|
.with(Consumable {})
|
||||||
.with(Destructible {})
|
.with(Destructible {})
|
||||||
.with(Ranged { range: 6 })
|
.with(Ranged { range: 10 })
|
||||||
.with(Confusion { turns: 4 })
|
.with(Confusion { turns: 4 })
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue