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
commit ff16fc52c9
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
- 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
- Add stealth stat on Bag UI
### 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.protection": "Protection",
"hud.bag.stun_res": "Stun Resilience",
"hud.bag.stealth": "Stealth",
"hud.bag.combat_rating_desc": "Calculated from your\nequipment and health.",
"hud.bag.protection_desc": "Damage reduction through armor",
"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 common::{
assets::AssetExt,
combat::{combat_rating, Damage},
combat::{combat_rating, perception_dist_multiplier_from_stealth, Damage},
comp::{
inventory::InventorySortOrder,
item::{ItemDef, ItemDesc, MaterialStatManifest, Quality},
@ -629,12 +629,13 @@ impl<'a> Bag<'a> {
}
}
}
const STATS: [&str; 5] = [
const STATS: [&str; 6] = [
"Health",
"Energy",
"Protection",
"Combat Rating",
"Stun Resilience",
"Stealth",
];
pub struct BagState {
@ -924,6 +925,7 @@ impl<'a> Widget for Bag<'a> {
"Combat Rating" => self.imgs.combat_rating_ico,
"Protection" => self.imgs.protection_ico,
"Stun Resilience" => self.imgs.stun_res_ico,
"Stealth" => self.imgs.stealth_rating_ico,
_ => self.imgs.nothing,
})
.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
);
let stealth_txt = format!(
"{:.1}%",
((1.0 - perception_dist_multiplier_from_stealth(Some(inventory), None))
* 100.0)
);
let btn = if i.0 == 0 {
btn.top_left_with_margins_on(state.bg_ids.bg_frame, 55.0, 10.0)
} else {
@ -956,6 +963,7 @@ impl<'a> Widget for Bag<'a> {
"Combat Rating" => i18n.get("hud.bag.combat_rating"),
"Protection" => i18n.get("hud.bag.protection"),
"Stun Resilience" => i18n.get("hud.bag.stun_res"),
"Stealth" => i18n.get("hud.bag.stealth"),
_ => "",
};
let tooltip_txt = match i.1 {
@ -978,6 +986,7 @@ impl<'a> Widget for Bag<'a> {
"Combat Rating" => &combat_rating_txt,
"Protection" => &protection_txt,
"Stun Resilience" => &stun_res_txt,
"Stealth" => &stealth_txt,
_ => "",
})
.right_from(state.ids.stat_icons[i.0], 10.0)

View File

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

View File

@ -521,6 +521,7 @@ image_ids! {
stun_res_ico: "voxygen.element.ui.bag.icons.stun_res",
combat_rating_ico: "voxygen.element.ui.bag.icons.combat_rating",
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",