mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed health ui in few places and xp scaling from health.
This commit is contained in:
parent
338e82c36c
commit
3d31248ced
@ -905,13 +905,13 @@ pub fn combat_rating(
|
|||||||
msm: &MaterialStatManifest,
|
msm: &MaterialStatManifest,
|
||||||
) -> f32 {
|
) -> f32 {
|
||||||
const WEAPON_WEIGHT: f32 = 1.0;
|
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 ENERGY_WEIGHT: f32 = 0.5;
|
||||||
const SKILLS_WEIGHT: f32 = 1.0;
|
const SKILLS_WEIGHT: f32 = 1.0;
|
||||||
const POISE_WEIGHT: f32 = 0.5;
|
const POISE_WEIGHT: f32 = 0.5;
|
||||||
const CRIT_WEIGHT: f32 = 0.6;
|
const CRIT_WEIGHT: f32 = 0.6;
|
||||||
// Assumes a "standard" max health of 100
|
// Assumes a "standard" max health of 100
|
||||||
let health_rating = health.base_max() as f32
|
let health_rating = health.base_max()
|
||||||
/ 100.0
|
/ 100.0
|
||||||
/ (1.0 - Damage::compute_damage_reduction(Some(inventory), None, None)).max(0.00001);
|
/ (1.0 - Damage::compute_damage_reduction(Some(inventory), None, None)).max(0.00001);
|
||||||
|
|
||||||
|
@ -209,9 +209,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
};
|
};
|
||||||
let amount = match *kind {
|
let amount = match *kind {
|
||||||
ModifierKind::Additive => *accumulated,
|
ModifierKind::Additive => *accumulated,
|
||||||
ModifierKind::Fractional => {
|
ModifierKind::Fractional => health.maximum() * *accumulated,
|
||||||
health.maximum() as f32 * *accumulated
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
server_emitter.emit(ServerEvent::HealthChange {
|
server_emitter.emit(ServerEvent::HealthChange {
|
||||||
entity,
|
entity,
|
||||||
@ -248,8 +246,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
// Current fraction uses information from last tick, which is
|
// Current fraction uses information from last tick, which is
|
||||||
// necessary as buffs from this tick are not guaranteed to have
|
// necessary as buffs from this tick are not guaranteed to have
|
||||||
// finished applying
|
// finished applying
|
||||||
let current_fraction =
|
let current_fraction = health.maximum() / health.base_max();
|
||||||
health.maximum() as f32 / health.base_max() as f32;
|
|
||||||
|
|
||||||
// If achieved_fraction not initialized, initialize it to health
|
// If achieved_fraction not initialized, initialize it to health
|
||||||
// fraction
|
// fraction
|
||||||
|
@ -896,7 +896,7 @@ impl<'a> Widget for Bag<'a> {
|
|||||||
* Damage::compute_damage_reduction(Some(inventory), Some(self.stats), None,))
|
* Damage::compute_damage_reduction(Some(inventory), Some(self.stats), None,))
|
||||||
as i32
|
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 energy_txt = format!("{}", (self.energy.maximum() as f32 / 10.0) as usize);
|
||||||
let combat_rating_txt = format!("{}", (combat_rating * 10.0) as usize);
|
let combat_rating_txt = format!("{}", (combat_rating * 10.0) as usize);
|
||||||
let stun_res_txt = format!(
|
let stun_res_txt = format!(
|
||||||
|
@ -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)
|
.top_left_with_margins_on(state.ids.member_panels_bg[i], 2.0, 2.0)
|
||||||
.set(state.ids.member_health[i], ui);
|
.set(state.ids.member_health[i], ui);
|
||||||
// Health Decay
|
// 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 {
|
if decayed_health > 0.0 {
|
||||||
let decay_bar_len = 148.0 * decayed_health;
|
let decay_bar_len = 148.0 * decayed_health;
|
||||||
Image::new(self.imgs.bar_content)
|
Image::new(self.imgs.bar_content)
|
||||||
|
@ -190,7 +190,7 @@ impl<'a> Widget for Overhead<'a> {
|
|||||||
{
|
{
|
||||||
// Used to set healthbar colours based on hp_percentage
|
// Used to set healthbar colours based on hp_percentage
|
||||||
let hp_percentage = health.map_or(100.0, |h| {
|
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
|
// Compare levels to decide if a skull is shown
|
||||||
let health_current = health.map_or(1.0, |h| f64::from(h.current()));
|
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
|
// Show HP Bar
|
||||||
let hp_ani = (self.pulse * 4.0/* speed factor */).cos() * 0.5 + 1.0; //Animation timer
|
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 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
|
// Background
|
||||||
Image::new(if self.in_group {self.imgs.health_bar_group_bg} else {self.imgs.enemy_health_bg})
|
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)
|
.w_h(84.0 * BARSIZE, 10.0 * BARSIZE)
|
||||||
|
@ -139,7 +139,7 @@ pub fn consumable_desc(effects: &[Effect], i18n: &Localization) -> Vec<String> {
|
|||||||
for effect in effects {
|
for effect in effects {
|
||||||
let mut description = String::new();
|
let mut description = String::new();
|
||||||
if let Effect::Buff(buff) = effect {
|
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 dur_secs = buff.data.duration.map(|d| d.as_secs_f32());
|
||||||
let str_total = dur_secs.map_or(strength, |secs| strength * secs);
|
let str_total = dur_secs.map_or(strength, |secs| strength * secs);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user