mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed offset of decayed health
This commit is contained in:
@ -373,7 +373,8 @@ impl<'a> Widget for Group<'a> {
|
|||||||
let combat_rating =
|
let combat_rating =
|
||||||
combat::combat_rating(inventory, health, stats, *body, &self.msm);
|
combat::combat_rating(inventory, health, stats, *body, &self.msm);
|
||||||
let char_name = stats.name.to_string();
|
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
|
// change panel positions when debug info is shown
|
||||||
let x = if debug_on { i / 8 } else { i / 12 };
|
let x = if debug_on { i / 8 } else { i / 12 };
|
||||||
let y = 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
|
// Health Decay
|
||||||
let decayed_health = 1.0 - health.maximum() as f64 / health.base_max() as f64;
|
let decayed_health = 1.0 - health.maximum() as f64 / health.base_max() as f64;
|
||||||
if decayed_health > 0.0 {
|
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)
|
Image::new(self.imgs.bar_content)
|
||||||
.w_h(decay_bar_len, 22.0)
|
.w_h(decay_bar_len, 22.0)
|
||||||
.color(Some(QUALITY_EPIC))
|
.color(Some(QUALITY_EPIC))
|
||||||
|
@ -16,7 +16,7 @@ use conrod_core::{
|
|||||||
widget::{self, Image, Rectangle, Text},
|
widget::{self, Image, Rectangle, Text},
|
||||||
widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
|
widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
|
||||||
};
|
};
|
||||||
use inline_tweak::*;
|
|
||||||
const MAX_BUBBLE_WIDTH: f64 = 250.0;
|
const MAX_BUBBLE_WIDTH: f64 = 250.0;
|
||||||
widget_ids! {
|
widget_ids! {
|
||||||
struct Ids {
|
struct Ids {
|
||||||
@ -188,8 +188,9 @@ impl<'a> Widget for Overhead<'a> {
|
|||||||
}) = self.info
|
}) = self.info
|
||||||
{
|
{
|
||||||
// Used to set healthbar colours based on hp_percentage
|
// Used to set healthbar colours based on hp_percentage
|
||||||
let hp_percentage =
|
let hp_percentage = health.map_or(100.0, |h| {
|
||||||
health.map_or(100.0, |h| h.current() as f64 / h.maximum() as f64 * 100.0);
|
h.current() as f64 / h.base_max().max(h.maximum()) as f64 * 100.0
|
||||||
|
});
|
||||||
// Compare levels to decide if a skull is shown
|
// 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_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);
|
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 {
|
if decayed_health > 0.0 {
|
||||||
let x_decayed = if self.in_group {
|
let x_decayed = if self.in_group {
|
||||||
(tweak!(0.0) + (decayed_health / 100.0 * tweak!(41.0) - tweak!(41.0)))
|
(0.0 - (decayed_health * 41.0 - 41.0)) * BARSIZE
|
||||||
* BARSIZE
|
|
||||||
} else {
|
} else {
|
||||||
(tweak!(-4.5)
|
(4.5 - (decayed_health * 36.45 - 36.45)) * BARSIZE
|
||||||
+ (decayed_health / 100.0 * tweak!(36.45) - tweak!(36.45)))
|
|
||||||
* BARSIZE
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let decay_bar_len =
|
let decay_bar_len = decayed_health
|
||||||
decayed_health * 0.5 * if self.in_group { 82.0 } else { 73.0 };
|
* if self.in_group {
|
||||||
|
82.0 * BARSIZE
|
||||||
|
} else {
|
||||||
|
73.0 * BARSIZE
|
||||||
|
};
|
||||||
Image::new(self.imgs.enemy_bar)
|
Image::new(self.imgs.enemy_bar)
|
||||||
.w_h(decay_bar_len, h)
|
.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))
|
.color(Some(QUALITY_EPIC))
|
||||||
.parent(id)
|
.parent(id)
|
||||||
.set(state.ids.decay_bar, ui);
|
.set(state.ids.decay_bar, ui);
|
||||||
|
@ -313,7 +313,7 @@ impl<'a> Widget for Skillbar<'a> {
|
|||||||
.set(state.ids.hp_filling, ui);
|
.set(state.ids.hp_filling, ui);
|
||||||
|
|
||||||
if decayed_health > 0.0 {
|
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)
|
Image::new(self.imgs.bar_content)
|
||||||
.w_h(decay_bar_len, 18.0)
|
.w_h(decay_bar_len, 18.0)
|
||||||
.color(Some(QUALITY_EPIC))
|
.color(Some(QUALITY_EPIC))
|
||||||
|
Reference in New Issue
Block a user