Merge branch 'holychowders/add_stealth_stat_to_bag_ui' into 'master'

Add stealth stat to Bag UI.

See merge request veloren/veloren!3369
This commit is contained in:
Samuel Keiffer
2022-05-14 15:24:26 +00:00
6 changed files with 19 additions and 4 deletions

View File

@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added Belarusian translation - Added Belarusian translation
- Add FOV check for agents scanning for targets they are hostile to - Add FOV check for agents scanning for targets they are hostile to
- Implemented an LoD system for objects, making trees visible far beyond the view distance - Implemented an LoD system for objects, making trees visible far beyond the view distance
- Add stealth stat on Bag UI
### Changed ### Changed

BIN
assets/voxygen/element/ui/bag/icons/stealth_rating.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -34,6 +34,7 @@
"hud.bag.combat_rating": "Combat Rating", "hud.bag.combat_rating": "Combat Rating",
"hud.bag.protection": "Protection", "hud.bag.protection": "Protection",
"hud.bag.stun_res": "Stun Resilience", "hud.bag.stun_res": "Stun Resilience",
"hud.bag.stealth": "Stealth",
"hud.bag.combat_rating_desc": "Calculated from your\nequipment and health.", "hud.bag.combat_rating_desc": "Calculated from your\nequipment and health.",
"hud.bag.protection_desc": "Damage reduction through armor", "hud.bag.protection_desc": "Damage reduction through armor",
"hud.bag.stun_res_desc": "Resilience against being stunned by consecutive hits.\nRegenerates like Energy.", "hud.bag.stun_res_desc": "Resilience against being stunned by consecutive hits.\nRegenerates like Energy.",

View File

@ -18,7 +18,7 @@ use crate::{
use client::Client; use client::Client;
use common::{ use common::{
assets::AssetExt, assets::AssetExt,
combat::{combat_rating, Damage}, combat::{combat_rating, perception_dist_multiplier_from_stealth, Damage},
comp::{ comp::{
inventory::InventorySortOrder, inventory::InventorySortOrder,
item::{ItemDef, ItemDesc, MaterialStatManifest, Quality}, item::{ItemDef, ItemDesc, MaterialStatManifest, Quality},
@ -629,12 +629,13 @@ impl<'a> Bag<'a> {
} }
} }
} }
const STATS: [&str; 5] = [ const STATS: [&str; 6] = [
"Health", "Health",
"Energy", "Energy",
"Protection", "Protection",
"Combat Rating", "Combat Rating",
"Stun Resilience", "Stun Resilience",
"Stealth",
]; ];
pub struct BagState { pub struct BagState {
@ -924,6 +925,7 @@ impl<'a> Widget for Bag<'a> {
"Combat Rating" => self.imgs.combat_rating_ico, "Combat Rating" => self.imgs.combat_rating_ico,
"Protection" => self.imgs.protection_ico, "Protection" => self.imgs.protection_ico,
"Stun Resilience" => self.imgs.stun_res_ico, "Stun Resilience" => self.imgs.stun_res_ico,
"Stealth" => self.imgs.stealth_rating_ico,
_ => self.imgs.nothing, _ => self.imgs.nothing,
}) })
.w_h(20.0, 20.0) .w_h(20.0, 20.0)
@ -945,6 +947,11 @@ impl<'a> Widget for Bag<'a> {
"{}", "{}",
(100.0 * Poise::compute_poise_damage_reduction(inventory)) as i32 (100.0 * Poise::compute_poise_damage_reduction(inventory)) as i32
); );
let stealth_txt = format!(
"{:.1}%",
((1.0 - perception_dist_multiplier_from_stealth(Some(inventory), None))
* 100.0)
);
let btn = if i.0 == 0 { let btn = if i.0 == 0 {
btn.top_left_with_margins_on(state.bg_ids.bg_frame, 55.0, 10.0) btn.top_left_with_margins_on(state.bg_ids.bg_frame, 55.0, 10.0)
} else { } else {
@ -956,6 +963,7 @@ impl<'a> Widget for Bag<'a> {
"Combat Rating" => i18n.get("hud.bag.combat_rating"), "Combat Rating" => i18n.get("hud.bag.combat_rating"),
"Protection" => i18n.get("hud.bag.protection"), "Protection" => i18n.get("hud.bag.protection"),
"Stun Resilience" => i18n.get("hud.bag.stun_res"), "Stun Resilience" => i18n.get("hud.bag.stun_res"),
"Stealth" => i18n.get("hud.bag.stealth"),
_ => "", _ => "",
}; };
let tooltip_txt = match i.1 { let tooltip_txt = match i.1 {
@ -978,6 +986,7 @@ impl<'a> Widget for Bag<'a> {
"Combat Rating" => &combat_rating_txt, "Combat Rating" => &combat_rating_txt,
"Protection" => &protection_txt, "Protection" => &protection_txt,
"Stun Resilience" => &stun_res_txt, "Stun Resilience" => &stun_res_txt,
"Stealth" => &stealth_txt,
_ => "", _ => "",
}) })
.right_from(state.ids.stat_icons[i.0], 10.0) .right_from(state.ids.stat_icons[i.0], 10.0)

View File

@ -1112,7 +1112,7 @@ impl<'a> Widget for Diary<'a> {
"Stun-Resistance", "Stun-Resistance",
"Crit-Power", "Crit-Power",
"Energy Reward", "Energy Reward",
"Stealth (Items)", "Stealth",
"Weapon Power", "Weapon Power",
"Weapon Speed", "Weapon Speed",
"Weapon Poise", "Weapon Poise",
@ -1206,7 +1206,7 @@ impl<'a> Widget for Diary<'a> {
combat::compute_energy_reward_mod(Some(self.inventory)); combat::compute_energy_reward_mod(Some(self.inventory));
format!("{:+.0}%", (energy_rew - 1.0) * 100.0) format!("{:+.0}%", (energy_rew - 1.0) * 100.0)
}, },
"Stealth (Items)" => { "Stealth" => {
let stealth_perception_multiplier = let stealth_perception_multiplier =
combat::perception_dist_multiplier_from_stealth( combat::perception_dist_multiplier_from_stealth(
Some(self.inventory), Some(self.inventory),

View File

@ -521,6 +521,7 @@ image_ids! {
stun_res_ico: "voxygen.element.ui.bag.icons.stun_res", stun_res_ico: "voxygen.element.ui.bag.icons.stun_res",
combat_rating_ico: "voxygen.element.ui.bag.icons.combat_rating", combat_rating_ico: "voxygen.element.ui.bag.icons.combat_rating",
combat_rating_ico_shadow: "voxygen.element.ui.bag.icons.combat_rating_shadow", combat_rating_ico_shadow: "voxygen.element.ui.bag.icons.combat_rating_shadow",
stealth_rating_ico: "voxygen.element.ui.bag.icons.stealth_rating",
not_found: "voxygen.element.not_found", not_found: "voxygen.element.not_found",