intrinsic speed + regeneration
This commit is contained in:
parent
e8b5f6d997
commit
921fee2ecc
7 changed files with 78 additions and 10 deletions
|
|
@ -10,6 +10,7 @@ use crate::{
|
|||
Map,
|
||||
TakingTurn,
|
||||
Confusion,
|
||||
Intrinsics,
|
||||
};
|
||||
use bracket_lib::prelude::*;
|
||||
use specs::prelude::*;
|
||||
|
|
@ -36,6 +37,7 @@ impl<'a> System<'a> for EnergySystem {
|
|||
ReadStorage<'a, Name>,
|
||||
ReadExpect<'a, Point>,
|
||||
ReadStorage<'a, Confusion>,
|
||||
ReadStorage<'a, Intrinsics>,
|
||||
);
|
||||
|
||||
fn run(&mut self, data: Self::SystemData) {
|
||||
|
|
@ -53,6 +55,7 @@ impl<'a> System<'a> for EnergySystem {
|
|||
names,
|
||||
player_pos,
|
||||
confusion,
|
||||
intrinsics,
|
||||
) = data;
|
||||
// If not ticking, do nothing.
|
||||
if *runstate != RunState::Ticking {
|
||||
|
|
@ -89,10 +92,12 @@ impl<'a> System<'a> for EnergySystem {
|
|||
).join() {
|
||||
let burden_modifier = get_burden_modifier(&burdens, entity);
|
||||
let overmap_mod = get_overmap_modifier(&map);
|
||||
let intrinsic_speed = get_intrinsic_speed(&intrinsics, entity);
|
||||
// Every entity has a POTENTIAL equal to their speed.
|
||||
let mut energy_potential: i32 = ((energy.speed as f32) *
|
||||
burden_modifier *
|
||||
overmap_mod) as i32;
|
||||
overmap_mod *
|
||||
intrinsic_speed) as i32;
|
||||
// Increment current energy by NORMAL_SPEED for every
|
||||
// whole number of NORMAL_SPEEDS in their POTENTIAL.
|
||||
while energy_potential >= NORMAL_SPEED {
|
||||
|
|
@ -162,3 +167,12 @@ fn cull_turn_by_distance(player_pos: &Point, pos: &Position) -> bool {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
fn get_intrinsic_speed(intrinsics: &ReadStorage<Intrinsics>, entity: Entity) -> f32 {
|
||||
if let Some(intrinsics) = intrinsics.get(entity) {
|
||||
if intrinsics.list.contains(&crate::Intrinsic::Speed) {
|
||||
return 4.0 / 3.0;
|
||||
}
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use crate::{
|
|||
Position,
|
||||
RandomNumberGenerator,
|
||||
TakingTurn,
|
||||
Intrinsics,
|
||||
};
|
||||
use specs::prelude::*;
|
||||
use crate::data::events::*;
|
||||
|
|
@ -36,10 +37,24 @@ impl<'a> System<'a> for RegenSystem {
|
|||
ReadStorage<'a, HasClass>,
|
||||
ReadStorage<'a, Attributes>,
|
||||
WriteExpect<'a, RandomNumberGenerator>,
|
||||
ReadStorage<'a, Intrinsics>,
|
||||
ReadExpect<'a, Entity>,
|
||||
);
|
||||
|
||||
fn run(&mut self, data: Self::SystemData) {
|
||||
let (clock, entities, positions, mut pools, turns, player, classes, attributes, mut rng) = data;
|
||||
let (
|
||||
clock,
|
||||
entities,
|
||||
positions,
|
||||
mut pools,
|
||||
turns,
|
||||
player,
|
||||
classes,
|
||||
attributes,
|
||||
mut rng,
|
||||
intrinsics,
|
||||
player_entity,
|
||||
) = data;
|
||||
let mut clock_turn = false;
|
||||
for (_e, _c, _t) in (&entities, &clock, &turns).join() {
|
||||
clock_turn = true;
|
||||
|
|
@ -56,19 +71,29 @@ impl<'a> System<'a> for RegenSystem {
|
|||
}
|
||||
// Player HP regen
|
||||
let level = gamelog::get_event_count(EVENT::COUNT_LEVEL);
|
||||
if current_turn % get_player_hp_regen_turn(level) == 0 {
|
||||
if
|
||||
current_turn % get_player_hp_regen_turn(level) == 0 ||
|
||||
intrinsics.get(*player_entity).unwrap().list.contains(&crate::Intrinsic::Regeneration)
|
||||
{
|
||||
for (_e, _p, pool, _player) in (&entities, &positions, &mut pools, &player).join() {
|
||||
try_hp_regen_tick(pool, get_player_hp_regen_per_tick(level));
|
||||
}
|
||||
}
|
||||
// Both MP regen
|
||||
for (e, _p, pool) in (&entities, &positions, &mut pools).join() {
|
||||
let is_wizard = if let Some(class) = classes.get(e) { class.name == Class::Wizard } else { false };
|
||||
let is_wizard = if let Some(class) = classes.get(e) {
|
||||
class.name == Class::Wizard
|
||||
} else {
|
||||
false
|
||||
};
|
||||
let numerator = if is_wizard { WIZARD_MP_REGEN_MOD } else { NONWIZARD_MP_REGEN_MOD };
|
||||
let multiplier: f32 = (numerator as f32) / (MP_REGEN_DIVISOR as f32);
|
||||
let mp_regen_tick = (((MP_REGEN_BASE - pool.level) as f32) * multiplier) as i32;
|
||||
if current_turn % mp_regen_tick == 0 {
|
||||
try_mana_regen_tick(pool, rng.roll_dice(1, get_mana_regen_per_tick(e, &attributes)));
|
||||
try_mana_regen_tick(
|
||||
pool,
|
||||
rng.roll_dice(1, get_mana_regen_per_tick(e, &attributes))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue