Handled health change over time buff effect better.

This commit is contained in:
Sam 2020-10-18 20:52:07 -05:00
parent 5a5d35fade
commit fdf8decb18
3 changed files with 8 additions and 3 deletions

View File

@ -61,8 +61,12 @@ impl<'a> System<'a> for Sys {
// Only add an effect here if it is continuous or it is not immediate
BuffEffect::HealthChangeOverTime { rate, accumulated } => {
*accumulated += *rate * buff_delta;
// Apply only 0.5 or higher damage
if accumulated.abs() > 50.0 {
// Apply damage only once a second (with a minimum of 1 damage), or when a buff is removed
if accumulated.abs() > rate.abs().max(10.0)
|| active_buff_indices_for_removal
.iter()
.any(|index| *index == i)
{
let cause = if *accumulated > 0.0 {
HealthSource::Healing { by: buff_owner }
} else {

View File

@ -167,7 +167,7 @@ impl<'a> System<'a> for Sys {
uid: *uid_b,
buff_change: buff::BuffChange::Add(buff::Buff::new(
buff::BuffId::Regeneration {
strength: 100.0,
strength: 1.0,
duration: Some(Duration::from_secs(60)),
},
vec![buff::BuffCategoryId::Physical, buff::BuffCategoryId::Buff],

View File

@ -76,6 +76,7 @@ impl<'a> System<'a> for Sys {
| HealthSource::Projectile { owner: Some(by) }
| HealthSource::Energy { owner: Some(by) }
| HealthSource::Explosion { owner: Some(by) }
| HealthSource::Buff { owner: Some(by) }
| HealthSource::Healing { by: Some(by) } => {
let by_me = my_uid.map_or(false, |&uid| by == uid);
// If the attack was by me also reset this timer