From 0c19679406d1b16ed467c67f53be5766b6ac7b5b Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 27 Mar 2021 20:05:05 -0400 Subject: [PATCH] Fixed offset of decayed health --- voxygen/src/hud/group.rs | 5 +++-- voxygen/src/hud/overhead.rs | 24 +++++++++++++----------- voxygen/src/hud/skillbar.rs | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/voxygen/src/hud/group.rs b/voxygen/src/hud/group.rs index f731600eb6..35609660d2 100644 --- a/voxygen/src/hud/group.rs +++ b/voxygen/src/hud/group.rs @@ -373,7 +373,8 @@ impl<'a> Widget for Group<'a> { let combat_rating = combat::combat_rating(inventory, health, stats, *body, &self.msm); let char_name = stats.name.to_string(); - let health_perc = health.current() as f64 / health.maximum() as f64; + let health_perc = + health.current() as f64 / health.base_max().max(health.maximum()) as f64; // change panel positions when debug info is shown let x = if debug_on { i / 8 } else { i / 12 }; let y = if debug_on { i % 8 } else { i % 12 }; @@ -407,7 +408,7 @@ impl<'a> Widget for Group<'a> { // Health Decay let decayed_health = 1.0 - health.maximum() as f64 / health.base_max() as f64; if decayed_health > 0.0 { - let decay_bar_len = 148.0 * decayed_health * 0.5; + let decay_bar_len = 148.0 * decayed_health; Image::new(self.imgs.bar_content) .w_h(decay_bar_len, 22.0) .color(Some(QUALITY_EPIC)) diff --git a/voxygen/src/hud/overhead.rs b/voxygen/src/hud/overhead.rs index 4c2a2bd5e6..fed7ccacd9 100644 --- a/voxygen/src/hud/overhead.rs +++ b/voxygen/src/hud/overhead.rs @@ -16,7 +16,7 @@ use conrod_core::{ widget::{self, Image, Rectangle, Text}, widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon, }; -use inline_tweak::*; + const MAX_BUBBLE_WIDTH: f64 = 250.0; widget_ids! { struct Ids { @@ -188,8 +188,9 @@ impl<'a> Widget for Overhead<'a> { }) = self.info { // Used to set healthbar colours based on hp_percentage - let hp_percentage = - health.map_or(100.0, |h| h.current() as f64 / h.maximum() as f64 * 100.0); + let hp_percentage = health.map_or(100.0, |h| { + h.current() as f64 / h.base_max().max(h.maximum()) as f64 * 100.0 + }); // Compare levels to decide if a skull is shown let health_current = health.map_or(1.0, |h| (h.current() / 10) as f64); let health_max = health.map_or(1.0, |h| (h.maximum() / 10) as f64); @@ -356,19 +357,20 @@ impl<'a> Widget for Overhead<'a> { if decayed_health > 0.0 { let x_decayed = if self.in_group { - (tweak!(0.0) + (decayed_health / 100.0 * tweak!(41.0) - tweak!(41.0))) - * BARSIZE + (0.0 - (decayed_health * 41.0 - 41.0)) * BARSIZE } else { - (tweak!(-4.5) - + (decayed_health / 100.0 * tweak!(36.45) - tweak!(36.45))) - * BARSIZE + (4.5 - (decayed_health * 36.45 - 36.45)) * BARSIZE }; - let decay_bar_len = - decayed_health * 0.5 * if self.in_group { 82.0 } else { 73.0 }; + let decay_bar_len = decayed_health + * if self.in_group { + 82.0 * BARSIZE + } else { + 73.0 * BARSIZE + }; Image::new(self.imgs.enemy_bar) .w_h(decay_bar_len, h) - .x_y(x_decayed * tweak!(-1.0), MANA_BAR_Y + 8.0) + .x_y(x_decayed, MANA_BAR_Y + 8.0) .color(Some(QUALITY_EPIC)) .parent(id) .set(state.ids.decay_bar, ui); diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index 8fe9ce9620..7b6ff3c53c 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -313,7 +313,7 @@ impl<'a> Widget for Skillbar<'a> { .set(state.ids.hp_filling, ui); if decayed_health > 0.0 { - let decay_bar_len = 480.0 * decayed_health * 0.5; + let decay_bar_len = 480.0 * decayed_health; Image::new(self.imgs.bar_content) .w_h(decay_bar_len, 18.0) .color(Some(QUALITY_EPIC))