mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add Energy regen buff
* Fix broken i18n keys for health and energy increases * Better handle buff descriptions Calculate infobox lines for item stats to set correct infobox frame dimensions
This commit is contained in:
parent
54c48c7112
commit
34c5e95d8a
@ -1,39 +1,67 @@
|
||||
buff-remove = Click to remove
|
||||
buff-title-missing = Missing Title
|
||||
buff-desc-missing = Missing Description
|
||||
## Regeneration
|
||||
buff-title-heal = Heal
|
||||
buff-desc-heal = Gain health over time.
|
||||
buff-stat-health = Restores { $str_total } Health
|
||||
## Potion
|
||||
buff-title-potion = Potion
|
||||
buff-desc-potion = Drinking...
|
||||
## Saturation
|
||||
buff-title-saturation = Saturation
|
||||
buff-desc-saturation = Gain health over time from consumables.
|
||||
## Campfire
|
||||
buff-title-campfire_heal = Campfire Heal
|
||||
buff-desc-campfire_heal = Resting at a campfire heals { $rate }% per second.
|
||||
## Energy Regen
|
||||
buff-title-energy_regen = Energy Regeneration
|
||||
buff-desc-energy_regen = Faster energy regeneration
|
||||
buff-stat-energy_regen = Restores { $str_total } Energy
|
||||
## Health Increase
|
||||
buff-title-increase_max_health = Increase Max Health
|
||||
buff-desc-increase_max_health = Raise your max health cap
|
||||
buff-stat-increase_max_health =
|
||||
Raises maximum health
|
||||
by { $strength }
|
||||
## Energy Increase
|
||||
buff-title-increase_max_energy = Increase Max Energy
|
||||
buff-desc-increase_max_energy = Raise your max energy cap
|
||||
buff-stat-increase_max_energy =
|
||||
Raises maximum energy
|
||||
by { $strength }
|
||||
## Invulnerability
|
||||
buff-title-invulnerability = Invulnerability
|
||||
buff-desc-invulnerability = You cannot be damaged by any attack.
|
||||
buff-stat-invulnerability = Grants invulnerability
|
||||
## Protection Ward
|
||||
buff-title-protectingward = Protecting Ward
|
||||
buff-desc-protectingward = You are protected, somewhat, from attacks.
|
||||
## Frenzied
|
||||
buff-title-frenzied = Frenzied
|
||||
buff-desc-frenzied = You are imbued with unnatural speed and can ignore minor injuries.
|
||||
## Haste
|
||||
buff-title-hastened = Hastened
|
||||
buff-desc-hastened = Your movements and attacks are faster.
|
||||
## Bleeding
|
||||
buff-title-bleed = Bleeding
|
||||
buff-desc-bleed = Inflicts regular damage.
|
||||
## Curse
|
||||
buff-title-cursed = Cursed
|
||||
buff-desc-cursed = You are cursed.
|
||||
## Burning
|
||||
buff-title-burn = On Fire
|
||||
buff-desc-burn = You are burning alive
|
||||
## Crippled
|
||||
buff-title-crippled = Crippled
|
||||
buff-desc-crippled = Your movement is crippled as your legs are heavily injured.
|
||||
## Freeze
|
||||
buff-title-frozen = Frozen
|
||||
buff-desc-frozen = Your movements and attacks are slowed.
|
||||
## Wet
|
||||
buff-title-wet = Wet
|
||||
buff-desc-wet = The ground rejects your feet, making it hard to stop.
|
||||
## Ensnared
|
||||
buff-title-ensnared = Ensnared
|
||||
buff-desc-ensnared = Vines grasp at your legs, impeding your movement.
|
||||
buff-stat-health = Restores { $str_total } Health
|
||||
buff-stat-increase_max_energy = Raises Maximum Energy by { $strength }
|
||||
buff-stat-increase_max_health = Raises Maximum Health by { $strength }
|
||||
buff-stat-invulnerability = Grants invulnerability
|
||||
## Util
|
||||
buff-text-over_seconds = over { $dur_secs } seconds
|
||||
buff-text-for_seconds = for { $dur_secs } seconds
|
||||
buff-text-for_seconds = for { $dur_secs } seconds
|
||||
buff-remove = Click to remove
|
||||
|
@ -1,37 +1,64 @@
|
||||
buff-remove = Клікніть, щоб видалити
|
||||
buff-title-missing = Назва відсутня
|
||||
buff-desc-missing = Опис відсутній
|
||||
## Regeneration
|
||||
buff-title-heal = Зцілення
|
||||
buff-desc-heal = Поступово відновлює Здоров'я.
|
||||
buff-stat-health = Відновлює { $str_total } ОЗ
|
||||
## Potion
|
||||
buff-title-potion = Зілля
|
||||
buff-desc-potion = Пиття...
|
||||
## Saturation
|
||||
buff-title-saturation = Насичення
|
||||
buff-desc-saturation = Поступово відновлює Здоров'я з їжі.
|
||||
## Campfire
|
||||
buff-title-campfire_heal = Відновлення біля ватри
|
||||
buff-desc-campfire_heal = Відпочинок біля ватри лікує на { $rate }% за секунду.
|
||||
## Energy Regen
|
||||
buff-title-energy_regen = Відновлення Енергії
|
||||
buff-desc-energy_regen = Поступово відновляє Eнергію
|
||||
buff-stat-energy-regen = Відновлює { $str_total } енергії
|
||||
## Health Increase
|
||||
buff-title-increase_max_health = Підвищення Максимального Здоров'я
|
||||
buff-desc-increase_max_health = Піднімає ліміт вашого здоров'я
|
||||
buff-stat-increase_max_health =
|
||||
Підвищує максимальне здоров'я
|
||||
на { $strength }
|
||||
## Energy Increase
|
||||
buff-title-increase_max_energy = Підвищення Максимальної Енергії
|
||||
buff-desc-increase_max_energy = Піднімає ліміт вашої енергії
|
||||
buff-stat-increase_max_energy =
|
||||
Підвищує максимальну енергію
|
||||
на { $strength }
|
||||
## Invulnerability
|
||||
buff-title-invulnerability = Невразливість
|
||||
buff-desc-invulnerability = Ви невразливий, тільки тримайтесь подалі від омели.
|
||||
buff-stat-invulnerability = Дає невразливість
|
||||
## Protection Ward
|
||||
buff-title-protectingward = Захисна Аура
|
||||
buff-desc-protectingward = Ви захищені від атак, у якомусь сенсі.
|
||||
## Frenized
|
||||
buff-title-frenzied = Манія
|
||||
buff-desc-frenzied = Кров тече швидше, прискоруючи ваш рух та помалу зцілюючи вас.
|
||||
## Cursed
|
||||
buff-title-cursed = Проклін
|
||||
buff-desc-cursed = Вас прокляли.
|
||||
## Bleeding
|
||||
buff-title-bleed = Кровотеча
|
||||
buff-desc-bleed = Завдає регулярних пошкодженнь.
|
||||
## Burning
|
||||
buff-title-burn = У Вогні
|
||||
buff-desc-burn = Ви згораєте заживо.
|
||||
## Crippled
|
||||
buff-title-crippled = Калічення
|
||||
buff-desc-crippled = Ваші рухи дуже скуті через отримані травми.
|
||||
## Freeze
|
||||
buff-title-frozen = Обмороження
|
||||
buff-desc-frozen = Швидкість пересування та атак знижена.
|
||||
## Wet
|
||||
buff-title-wet = Волога
|
||||
buff-desc-wet = Земля плутає ваші ноги ускладнючи пересування.
|
||||
## Ensnared
|
||||
buff-title-ensnared = Пастка
|
||||
buff-desc-ensnared = Ліани опутують ваші ноги, перешкоджаючи ходьбі.
|
||||
buff-stat-health = Відновлює { $str_total } ОЗ
|
||||
buff-stat-increase_max_health = Підвищує Максимальне Здоров'я на { $strength }
|
||||
buff-stat-increase_max_energy = Підвищує Максимальну Енергію на { $strength }
|
||||
buff-stat-invulnerability = Дає невразливість
|
||||
## Util
|
||||
buff-text-for_seconds = протягом { $dur_secs } сек.
|
||||
buff-text-over_seconds = впродовж { $dur_secs } сек.
|
||||
buff-text-over_seconds = впродовж { $dur_secs } сек.
|
||||
buff-remove = Клікніть, щоб видалити
|
||||
|
@ -141,6 +141,7 @@ lazy_static! {
|
||||
BuffKind::Cursed => "cursed",
|
||||
BuffKind::Potion => "potion",
|
||||
BuffKind::CampfireHeal => "campfire_heal",
|
||||
BuffKind::EnergyRegen => "energy_regen",
|
||||
BuffKind::IncreaseMaxEnergy => "increase_max_energy",
|
||||
BuffKind::IncreaseMaxHealth => "increase_max_health",
|
||||
BuffKind::Invulnerability => "invulnerability",
|
||||
@ -154,7 +155,9 @@ lazy_static! {
|
||||
BuffKind::Hastened => "hastened",
|
||||
};
|
||||
let mut buff_parser = HashMap::new();
|
||||
BuffKind::iter().for_each(|kind| {buff_parser.insert(string_from_buff(kind).to_string(), kind);});
|
||||
for kind in BuffKind::iter() {
|
||||
buff_parser.insert(string_from_buff(kind).to_string(), kind);
|
||||
}
|
||||
buff_parser
|
||||
};
|
||||
|
||||
|
@ -27,6 +27,9 @@ pub enum BuffKind {
|
||||
/// Applied when sitting at a campfire
|
||||
/// Strength is fraction of health restored per second
|
||||
CampfireHeal,
|
||||
/// Restores energy/time for some period
|
||||
/// Strength should be the healing per second
|
||||
EnergyRegen,
|
||||
/// Raises maximum energy
|
||||
/// Strength should be 10x the effect to max energy
|
||||
IncreaseMaxEnergy,
|
||||
@ -91,6 +94,7 @@ impl BuffKind {
|
||||
| BuffKind::Potion
|
||||
| BuffKind::CampfireHeal
|
||||
| BuffKind::Frenzied
|
||||
| BuffKind::EnergyRegen
|
||||
| BuffKind::IncreaseMaxEnergy
|
||||
| BuffKind::IncreaseMaxHealth
|
||||
| BuffKind::Invulnerability
|
||||
@ -279,6 +283,14 @@ impl Buff {
|
||||
],
|
||||
data.duration,
|
||||
),
|
||||
BuffKind::EnergyRegen => (
|
||||
vec![BuffEffect::EnergyChangeOverTime {
|
||||
rate: data.strength,
|
||||
accumulated: 0.0,
|
||||
kind: ModifierKind::Additive,
|
||||
}],
|
||||
data.duration,
|
||||
),
|
||||
BuffKind::IncreaseMaxEnergy => (
|
||||
vec![BuffEffect::MaxEnergyModifier {
|
||||
value: data.strength,
|
||||
@ -296,9 +308,9 @@ impl Buff {
|
||||
BuffKind::Invulnerability => (vec![BuffEffect::DamageReduction(1.0)], data.duration),
|
||||
BuffKind::ProtectingWard => (
|
||||
vec![BuffEffect::DamageReduction(
|
||||
// Causes non-linearity in effect strength, but necessary to allow for tool
|
||||
// power and other things to affect the strength. 0.5 also still provides 50%
|
||||
// damage reduction.
|
||||
// Causes non-linearity in effect strength, but necessary
|
||||
// to allow for tool power and other things to affect the
|
||||
// strength. 0.5 also still provides 50% damage reduction.
|
||||
nn_scaling(data.strength),
|
||||
)],
|
||||
data.duration,
|
||||
|
@ -788,6 +788,7 @@ fn insert_killing_buff(buff: BuffKind, localized_strings: &Localization, templat
|
||||
| BuffKind::Saturation
|
||||
| BuffKind::Potion
|
||||
| BuffKind::CampfireHeal
|
||||
| BuffKind::EnergyRegen
|
||||
| BuffKind::IncreaseMaxEnergy
|
||||
| BuffKind::IncreaseMaxHealth
|
||||
| BuffKind::Invulnerability
|
||||
|
@ -4564,6 +4564,7 @@ pub fn get_buff_image(buff: BuffKind, imgs: &Imgs) -> conrod_core::image::Id {
|
||||
BuffKind::Saturation { .. } => imgs.buff_saturation_0,
|
||||
BuffKind::Potion { .. } => imgs.buff_potion_0,
|
||||
BuffKind::CampfireHeal { .. } => imgs.buff_campfire_heal_0,
|
||||
BuffKind::EnergyRegen { .. } => imgs.buff_energyplus_0,
|
||||
BuffKind::IncreaseMaxEnergy { .. } => imgs.buff_energyplus_0,
|
||||
BuffKind::IncreaseMaxHealth { .. } => imgs.buff_healthplus_0,
|
||||
BuffKind::Invulnerability => imgs.buff_invincibility_0,
|
||||
@ -4589,10 +4590,13 @@ pub fn get_buff_title(buff: BuffKind, localized_strings: &Localization) -> Cow<s
|
||||
BuffKind::Saturation { .. } => localized_strings.get_msg("buff-title-saturation"),
|
||||
BuffKind::Potion { .. } => localized_strings.get_msg("buff-title-potion"),
|
||||
BuffKind::CampfireHeal { .. } => localized_strings.get_msg("buff-title-campfire_heal"),
|
||||
BuffKind::EnergyRegen { .. } => localized_strings.get_msg("buff-title-energy_regen"),
|
||||
BuffKind::IncreaseMaxHealth { .. } => {
|
||||
localized_strings.get_msg("buff-title-IncreaseMaxHealth")
|
||||
localized_strings.get_msg("buff-title-increase_max_health")
|
||||
},
|
||||
BuffKind::IncreaseMaxEnergy { .. } => {
|
||||
localized_strings.get_msg("buff-title-increase_max_energy")
|
||||
},
|
||||
BuffKind::IncreaseMaxEnergy { .. } => localized_strings.get_msg("buff-title-energyup"),
|
||||
BuffKind::Invulnerability => localized_strings.get_msg("buff-title-invulnerability"),
|
||||
BuffKind::ProtectingWard => localized_strings.get_msg("buff-title-protectingward"),
|
||||
BuffKind::Frenzied => localized_strings.get_msg("buff-title-frenzied"),
|
||||
@ -4620,11 +4624,12 @@ pub fn get_buff_desc(buff: BuffKind, data: BuffData, localized_strings: &Localiz
|
||||
"rate" => data.strength * 100.0
|
||||
})
|
||||
},
|
||||
BuffKind::EnergyRegen { .. } => localized_strings.get_msg("buff-desc-energy_regen"),
|
||||
BuffKind::IncreaseMaxHealth { .. } => {
|
||||
localized_strings.get_msg("buff-desc-IncreaseMaxHealth")
|
||||
localized_strings.get_msg("buff-desc-increase_max_health")
|
||||
},
|
||||
BuffKind::IncreaseMaxEnergy { .. } => {
|
||||
localized_strings.get_msg("buff-desc-IncreaseMaxEnergy")
|
||||
localized_strings.get_msg("buff-desc-increase_max_energy")
|
||||
},
|
||||
BuffKind::Invulnerability => localized_strings.get_msg("buff-desc-invulnerability"),
|
||||
BuffKind::ProtectingWard => localized_strings.get_msg("buff-desc-protectingward"),
|
||||
|
@ -21,51 +21,43 @@ pub fn price_desc<'a>(
|
||||
item_definition_id: ItemDefinitionId<'_>,
|
||||
i18n: &'a Localization,
|
||||
) -> Option<(Cow<'a, str>, Cow<'a, str>, f32)> {
|
||||
if let Some(prices) = prices {
|
||||
if let Some(materials) = TradePricing::get_materials(&item_definition_id) {
|
||||
let coinprice = prices.values.get(&Good::Coin).cloned().unwrap_or(1.0);
|
||||
let buyprice: f32 = materials
|
||||
.iter()
|
||||
.map(|e| prices.values.get(&e.1).cloned().unwrap_or_default() * e.0)
|
||||
.sum();
|
||||
let sellprice: f32 = materials
|
||||
.iter()
|
||||
.map(|e| {
|
||||
prices.values.get(&e.1).cloned().unwrap_or_default() * e.0 * e.1.trade_margin()
|
||||
})
|
||||
.sum();
|
||||
let prices = prices.as_ref()?;
|
||||
let materials = TradePricing::get_materials(&item_definition_id)?;
|
||||
let coinprice = prices.values.get(&Good::Coin).cloned().unwrap_or(1.0);
|
||||
let buyprice: f32 = materials
|
||||
.iter()
|
||||
.map(|e| prices.values.get(&e.1).cloned().unwrap_or_default() * e.0)
|
||||
.sum();
|
||||
let sellprice: f32 = materials
|
||||
.iter()
|
||||
.map(|e| prices.values.get(&e.1).cloned().unwrap_or_default() * e.0 * e.1.trade_margin())
|
||||
.sum();
|
||||
|
||||
let deal_goodness: f32 = materials
|
||||
.iter()
|
||||
.map(|e| prices.values.get(&e.1).cloned().unwrap_or(0.0))
|
||||
.sum::<f32>()
|
||||
/ prices.values.get(&Good::Coin).cloned().unwrap_or(1.0)
|
||||
/ (materials.len() as f32);
|
||||
let deal_goodness = deal_goodness.log(2.0);
|
||||
let deal_goodness: f32 = materials
|
||||
.iter()
|
||||
.map(|e| prices.values.get(&e.1).cloned().unwrap_or(0.0))
|
||||
.sum::<f32>()
|
||||
/ prices.values.get(&Good::Coin).cloned().unwrap_or(1.0)
|
||||
/ (materials.len() as f32);
|
||||
let deal_goodness = deal_goodness.log(2.0);
|
||||
|
||||
let buy_string = i18n.get_msg_ctx("hud-trade-buy", &fluent_args! {
|
||||
"coin_num" => buyprice / coinprice,
|
||||
"coin_formatted" => format!("{:0.1}", buyprice / coinprice),
|
||||
});
|
||||
let sell_string = i18n.get_msg_ctx("hud-trade-sell", &fluent_args! {
|
||||
"coin_num" => sellprice / coinprice,
|
||||
"coin_formatted" => format!("{:0.1}", sellprice / coinprice),
|
||||
});
|
||||
let buy_string = i18n.get_msg_ctx("hud-trade-buy", &fluent_args! {
|
||||
"coin_num" => buyprice / coinprice,
|
||||
"coin_formatted" => format!("{:0.1}", buyprice / coinprice),
|
||||
});
|
||||
let sell_string = i18n.get_msg_ctx("hud-trade-sell", &fluent_args! {
|
||||
"coin_num" => sellprice / coinprice,
|
||||
"coin_formatted" => format!("{:0.1}", sellprice / coinprice),
|
||||
});
|
||||
|
||||
let deal_goodness = match deal_goodness {
|
||||
x if x < -2.5 => 0.0,
|
||||
x if x < -1.05 => 0.25,
|
||||
x if x < -0.95 => 0.5,
|
||||
x if x < 0.0 => 0.75,
|
||||
_ => 1.0,
|
||||
};
|
||||
Some((buy_string, sell_string, deal_goodness))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
let deal_goodness = match deal_goodness {
|
||||
x if x < -2.5 => 0.0,
|
||||
x if x < -1.05 => 0.25,
|
||||
x if x < -0.95 => 0.5,
|
||||
x if x < 0.0 => 0.75,
|
||||
_ => 1.0,
|
||||
};
|
||||
Some((buy_string, sell_string, deal_goodness))
|
||||
}
|
||||
|
||||
pub fn kind_text<'a>(kind: &ItemKind, i18n: &'a Localization) -> Cow<'a, str> {
|
||||
@ -126,6 +118,21 @@ pub fn stats_count(item: &dyn ItemDesc, msm: &MaterialStatManifest) -> usize {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn line_count(item: &dyn ItemDesc, msm: &MaterialStatManifest, i18n: &Localization) -> usize {
|
||||
match &*item.kind() {
|
||||
ItemKind::Consumable { effects, .. } => {
|
||||
let descs = consumable_desc(effects, i18n);
|
||||
let mut lines = 0;
|
||||
for desc in descs {
|
||||
lines += desc.matches('\n').count() + 1;
|
||||
}
|
||||
|
||||
lines
|
||||
},
|
||||
_ => stats_count(item, msm),
|
||||
}
|
||||
}
|
||||
|
||||
/// Takes N `effects` and returns N effect descriptions
|
||||
/// If effect isn't intended to have description, returns empty string
|
||||
///
|
||||
@ -149,6 +156,11 @@ pub fn consumable_desc(effects: &[Effect], i18n: &Localization) -> Vec<String> {
|
||||
.get_msg_ctx("buff-stat-health", &i18n::fluent_args! {
|
||||
"str_total" => format_float(str_total),
|
||||
}),
|
||||
BuffKind::EnergyRegen => {
|
||||
i18n.get_msg_ctx("buff-stat-energy_regen", &i18n::fluent_args! {
|
||||
"str_total" => format_float(str_total),
|
||||
})
|
||||
},
|
||||
BuffKind::IncreaseMaxEnergy => {
|
||||
i18n.get_msg_ctx("buff-stat-increase_max_energy", &i18n::fluent_args! {
|
||||
"strength" => format_float(strength),
|
||||
@ -178,11 +190,10 @@ pub fn consumable_desc(effects: &[Effect], i18n: &Localization) -> Vec<String> {
|
||||
|
||||
let dur_desc = if let Some(dur_secs) = dur_secs {
|
||||
match buff.kind {
|
||||
BuffKind::Saturation | BuffKind::Regeneration => {
|
||||
i18n.get_msg_ctx("buff-text-over_seconds", &i18n::fluent_args! {
|
||||
BuffKind::Saturation | BuffKind::Regeneration | BuffKind::EnergyRegen => i18n
|
||||
.get_msg_ctx("buff-text-over_seconds", &i18n::fluent_args! {
|
||||
"dur_secs" => dur_secs
|
||||
})
|
||||
},
|
||||
}),
|
||||
BuffKind::IncreaseMaxEnergy
|
||||
| BuffKind::IncreaseMaxHealth
|
||||
| BuffKind::Invulnerability => {
|
||||
@ -204,7 +215,9 @@ pub fn consumable_desc(effects: &[Effect], i18n: &Localization) -> Vec<String> {
|
||||
| BuffKind::Poisoned
|
||||
| BuffKind::Hastened => Cow::Borrowed(""),
|
||||
}
|
||||
} else if let BuffKind::Saturation | BuffKind::Regeneration = buff.kind {
|
||||
} else if let BuffKind::Saturation | BuffKind::Regeneration | BuffKind::EnergyRegen =
|
||||
buff.kind
|
||||
{
|
||||
i18n.get_msg("buff-text-every_second")
|
||||
} else {
|
||||
Cow::Borrowed("")
|
||||
|
@ -1248,7 +1248,7 @@ impl<'a> Widget for ItemTooltip<'a> {
|
||||
let frame_h = ICON_SIZE[1] + V_PAD;
|
||||
|
||||
// Stats
|
||||
let stats_count = util::stats_count(self.item, self.msm);
|
||||
let stats_count = util::line_count(self.item, self.msm, self.localized_strings);
|
||||
let stat_h = if stats_count > 0 {
|
||||
widget::Text::new("placeholder")
|
||||
.with_style(self.style.desc)
|
||||
@ -1294,7 +1294,8 @@ impl<'a> Widget for ItemTooltip<'a> {
|
||||
0.0
|
||||
};
|
||||
|
||||
let height = frame_h + stat_h + desc_h + price_h + V_PAD + 5.0; // extra padding to fit frame top padding
|
||||
// extra padding to fit frame top padding
|
||||
let height = frame_h + stat_h + desc_h + price_h + V_PAD + 5.0;
|
||||
Dimension::Absolute(height)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user