diff options
Diffstat (limited to 'src/server.rs')
-rw-r--r-- | src/server.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/server.rs b/src/server.rs index 55e7ebc..0f34a12 100644 --- a/src/server.rs +++ b/src/server.rs @@ -506,11 +506,11 @@ const HEALTH_REGEN: f32 = 5.; fn health_regen( health_regen_timer: Res<HealthRegenTimer>, mut connection_manager: ResMut<ServerConnectionManager>, - mut healths: Query<(&PlayerId, &mut Health)>, + mut healths: Query<(&PlayerId, &mut Health, &EffectiveStats)>, ) { if health_regen_timer.0.just_finished() { - for (target_player, mut health) in healths.iter_mut() { - health.0 = (health.0 + HEALTH_REGEN).min(MAX_HEALTH); + for (target_player, mut health, effective_stats) in healths.iter_mut() { + health.0 = (health.0 + HEALTH_REGEN).min(effective_stats.0.max_health); let _ = connection_manager.send_message_to_target::<Channel1, HealthChanged>( HealthChanged(HealthEvent { target_player: *target_player, @@ -522,8 +522,10 @@ fn health_regen( } } -fn effective_stats(mut effective_statses: Query<(&Champion, &mut EffectiveStats, &Buffs)>) { - for (champion, mut effective_stats, buffs) in effective_statses.iter_mut() { +fn effective_stats( + mut effective_statses: Query<(&Champion, &mut EffectiveStats, &Buffs, &mut Health)>, +) { + for (champion, mut effective_stats, buffs, mut health) in effective_statses.iter_mut() { let mut stats = BaseStats::from_champion(*champion).0; if buffs.slow.is_some() { stats.movement_speed *= 0.85; @@ -532,6 +534,7 @@ fn effective_stats(mut effective_statses: Query<(&Champion, &mut EffectiveStats, stats.movement_speed *= 1.25; } effective_stats.0 = stats; + health.0 = health.0.min(effective_stats.0.max_health); } } |