From 3d31248ced23c80d13b3f79cddffb2f0acddbad4 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 14 Sep 2021 10:55:14 -0400 Subject: [PATCH] Fixed health ui in few places and xp scaling from health. --- common/src/combat.rs | 4 ++-- common/systems/src/buff.rs | 7 ++----- voxygen/src/hud/bag.rs | 2 +- voxygen/src/hud/group.rs | 2 +- voxygen/src/hud/overhead.rs | 4 ++-- voxygen/src/hud/util.rs | 2 +- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/common/src/combat.rs b/common/src/combat.rs index 42132ec053..8b87860671 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -905,13 +905,13 @@ pub fn combat_rating( msm: &MaterialStatManifest, ) -> f32 { const WEAPON_WEIGHT: f32 = 1.0; - const HEALTH_WEIGHT: f32 = 0.5; + const HEALTH_WEIGHT: f32 = 5.0; const ENERGY_WEIGHT: f32 = 0.5; const SKILLS_WEIGHT: f32 = 1.0; const POISE_WEIGHT: f32 = 0.5; const CRIT_WEIGHT: f32 = 0.6; // Assumes a "standard" max health of 100 - let health_rating = health.base_max() as f32 + let health_rating = health.base_max() / 100.0 / (1.0 - Damage::compute_damage_reduction(Some(inventory), None, None)).max(0.00001); diff --git a/common/systems/src/buff.rs b/common/systems/src/buff.rs index b6d7239fab..42bf1280d1 100644 --- a/common/systems/src/buff.rs +++ b/common/systems/src/buff.rs @@ -209,9 +209,7 @@ impl<'a> System<'a> for Sys { }; let amount = match *kind { ModifierKind::Additive => *accumulated, - ModifierKind::Fractional => { - health.maximum() as f32 * *accumulated - }, + ModifierKind::Fractional => health.maximum() * *accumulated, }; server_emitter.emit(ServerEvent::HealthChange { entity, @@ -248,8 +246,7 @@ impl<'a> System<'a> for Sys { // Current fraction uses information from last tick, which is // necessary as buffs from this tick are not guaranteed to have // finished applying - let current_fraction = - health.maximum() as f32 / health.base_max() as f32; + let current_fraction = health.maximum() / health.base_max(); // If achieved_fraction not initialized, initialize it to health // fraction diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 34eacf20c4..f2f8126ae4 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -896,7 +896,7 @@ impl<'a> Widget for Bag<'a> { * Damage::compute_damage_reduction(Some(inventory), Some(self.stats), None,)) as i32 ); - let health_txt = format!("{}", (self.health.maximum() as f32 / 10.0) as usize); + let health_txt = format!("{}", self.health.maximum().round() as usize); let energy_txt = format!("{}", (self.energy.maximum() as f32 / 10.0) as usize); let combat_rating_txt = format!("{}", (combat_rating * 10.0) as usize); let stun_res_txt = format!( diff --git a/voxygen/src/hud/group.rs b/voxygen/src/hud/group.rs index 1d3d8d5696..d519bc6fb0 100644 --- a/voxygen/src/hud/group.rs +++ b/voxygen/src/hud/group.rs @@ -415,7 +415,7 @@ impl<'a> Widget for Group<'a> { .top_left_with_margins_on(state.ids.member_panels_bg[i], 2.0, 2.0) .set(state.ids.member_health[i], ui); // Health Decay - let decayed_health = 1.0 - health.maximum() as f64 / health.base_max() as f64; + let decayed_health = f64::from(1.0 - health.maximum() / health.base_max()); if decayed_health > 0.0 { let decay_bar_len = 148.0 * decayed_health; Image::new(self.imgs.bar_content) diff --git a/voxygen/src/hud/overhead.rs b/voxygen/src/hud/overhead.rs index 8bc591254f..be6aa772c2 100644 --- a/voxygen/src/hud/overhead.rs +++ b/voxygen/src/hud/overhead.rs @@ -190,7 +190,7 @@ impl<'a> Widget for Overhead<'a> { { // Used to set healthbar colours based on hp_percentage let hp_percentage = health.map_or(100.0, |h| { - h.current() as f64 / h.base_max().max(h.maximum()) as f64 * 100.0 + f64::from(h.current() / h.base_max().max(h.maximum()) * 100.0) }); // Compare levels to decide if a skull is shown let health_current = health.map_or(1.0, |h| f64::from(h.current())); @@ -318,7 +318,7 @@ impl<'a> Widget for Overhead<'a> { // Show HP Bar let hp_ani = (self.pulse * 4.0/* speed factor */).cos() * 0.5 + 1.0; //Animation timer let crit_hp_color: Color = Color::Rgba(0.93, 0.59, 0.03, hp_ani); - let decayed_health = 1.0 - health.maximum() as f64 / health.base_max() as f64; + let decayed_health = f64::from(1.0 - health.maximum() / health.base_max()); // Background Image::new(if self.in_group {self.imgs.health_bar_group_bg} else {self.imgs.enemy_health_bg}) .w_h(84.0 * BARSIZE, 10.0 * BARSIZE) diff --git a/voxygen/src/hud/util.rs b/voxygen/src/hud/util.rs index 3e368eacab..600b08fc9f 100644 --- a/voxygen/src/hud/util.rs +++ b/voxygen/src/hud/util.rs @@ -139,7 +139,7 @@ pub fn consumable_desc(effects: &[Effect], i18n: &Localization) -> Vec { for effect in effects { let mut description = String::new(); if let Effect::Buff(buff) = effect { - let strength = buff.data.strength * 0.1; + let strength = buff.data.strength; let dur_secs = buff.data.duration.map(|d| d.as_secs_f32()); let str_total = dur_secs.map_or(strength, |secs| strength * secs);