Fixed offset of decayed health

This commit is contained in:
Sam 2021-03-27 20:05:05 -04:00
parent 0e3b0a9ee7
commit 0c19679406
3 changed files with 17 additions and 14 deletions

View File

@ -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))

View File

@ -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);

View File

@ -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))