From 610d47f78743f862b23e49714e25f6b2a87d72f5 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 13 Feb 2023 21:43:52 -0500 Subject: [PATCH] Effect power now affects more than just poise --- assets/voxygen/i18n/en/common.ftl | 2 +- common/src/combat.rs | 61 +++++++++++++++++++++++--- common/src/comp/ability.rs | 20 +-------- common/src/comp/character_state.rs | 10 ++--- common/src/comp/melee.rs | 31 +++++++------ common/src/comp/projectile.rs | 49 +++++++++++++-------- common/src/states/basic_melee.rs | 4 +- common/src/states/basic_ranged.rs | 4 +- common/src/states/charged_melee.rs | 8 ++-- common/src/states/charged_ranged.rs | 4 +- common/src/states/combo_melee.rs | 15 ++----- common/src/states/combo_melee2.rs | 4 +- common/src/states/dash_melee.rs | 12 ++--- common/src/states/dive_melee.rs | 4 +- common/src/states/finisher_melee.rs | 4 +- common/src/states/leap_melee.rs | 4 +- common/src/states/rapid_melee.rs | 4 +- common/src/states/repeater_ranged.rs | 4 +- common/src/states/riposte_melee.rs | 4 +- common/src/states/spin_melee.rs | 4 +- common/src/states/utils.rs | 13 +++--- server/src/wiring.rs | 10 ++++- voxygen/src/ui/widgets/item_tooltip.rs | 8 ++-- 23 files changed, 166 insertions(+), 117 deletions(-) diff --git a/assets/voxygen/i18n/en/common.ftl b/assets/voxygen/i18n/en/common.ftl index 8329e77540..4aba5f2d76 100644 --- a/assets/voxygen/i18n/en/common.ftl +++ b/assets/voxygen/i18n/en/common.ftl @@ -90,7 +90,7 @@ common-rand_name = Random name common-stats-combat_rating = CR common-stats-power = Power common-stats-speed = Speed -common-stats-poise = Poise +common-stats-effect-power = Effect Power common-stats-range = Range common-stats-energy_efficiency = Energy Efficiency common-stats-buff_strength = Buff/Debuff Strength diff --git a/common/src/combat.rs b/common/src/combat.rs index d6537289ce..08f022aeb6 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -4,7 +4,11 @@ use crate::{ comp::{ ability::Capability, inventory::{ - item::{armor::Protection, tool::ToolKind, ItemDesc, ItemKind, MaterialStatManifest}, + item::{ + armor::Protection, + tool::{self, ToolKind}, + ItemDesc, ItemKind, MaterialStatManifest, + }, slot::EquipSlot, }, skillset::SkillGroupKind, @@ -28,7 +32,7 @@ use crate::{comp::Group, resources::Time}; #[cfg(not(target_arch = "wasm32"))] use specs::{saveload::MarkerAllocator, Entity as EcsEntity, ReadStorage}; #[cfg(not(target_arch = "wasm32"))] -use std::ops::MulAssign; +use std::ops::{Mul, MulAssign}; #[cfg(not(target_arch = "wasm32"))] use vek::*; #[cfg(not(target_arch = "wasm32"))] @@ -832,6 +836,46 @@ pub enum CombatEffect { StunnedVulnerable(f32), } +impl CombatEffect { + pub fn adjusted_by_stats(self, stats: tool::Stats) -> Self { + match self { + CombatEffect::Heal(h) => CombatEffect::Heal(h * stats.effect_power), + CombatEffect::Buff(CombatBuff { + kind, + dur_secs, + strength, + chance, + }) => CombatEffect::Buff(CombatBuff { + kind, + dur_secs, + strength: strength * stats.buff_strength, + chance, + }), + CombatEffect::Knockback(Knockback { + direction, + strength, + }) => CombatEffect::Knockback(Knockback { + direction, + strength: strength * stats.buff_strength, + }), + CombatEffect::EnergyReward(e) => CombatEffect::EnergyReward(e), + CombatEffect::Lifesteal(l) => CombatEffect::Lifesteal(l * stats.effect_power), + CombatEffect::Poise(p) => CombatEffect::Poise(p * stats.effect_power), + CombatEffect::Combo(c) => CombatEffect::Combo(c), + CombatEffect::StageVulnerable(v, s) => { + CombatEffect::StageVulnerable(v * stats.effect_power, s) + }, + CombatEffect::RefreshBuff(c, b) => CombatEffect::RefreshBuff(c, b), + CombatEffect::BuffsVulnerable(v, b) => { + CombatEffect::BuffsVulnerable(v * stats.effect_power, b) + }, + CombatEffect::StunnedVulnerable(v) => { + CombatEffect::StunnedVulnerable(v * stats.effect_power) + }, + } + } +} + #[cfg(not(target_arch = "wasm32"))] #[derive(Clone, Debug, Serialize, Deserialize)] pub enum CombatRequirement { @@ -1106,11 +1150,16 @@ impl CombatBuffStrength { } impl MulAssign for CombatBuffStrength { - fn mul_assign(&mut self, mul: f32) { + fn mul_assign(&mut self, mul: f32) { *self = *self * mul; } +} + +impl Mul for CombatBuffStrength { + type Output = Self; + + fn mul(self, mult: f32) -> Self { match self { - Self::DamageFraction(ref mut val) | Self::Value(ref mut val) => { - *val *= mul; - }, + Self::DamageFraction(val) => Self::DamageFraction(val * mult), + Self::Value(val) => Self::Value(val * mult), } } } diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 4a086fb5d7..65d95df780 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -1305,15 +1305,7 @@ impl CharacterAbility { *poise_damage *= stats.effect_power; *shockwave_duration *= stats.range; *energy_cost /= stats.energy_efficiency; - if let Some(CombatEffect::Buff(combat::CombatBuff { - kind: _, - dur_secs: _, - strength, - chance: _, - })) = damage_effect - { - *strength *= stats.buff_strength; - } + *damage_effect = damage_effect.map(|de| de.adjusted_by_stats(stats)); }, BasicBeam { ref mut buildup_duration, @@ -1338,15 +1330,7 @@ impl CharacterAbility { // Duration modified to keep velocity constant *beam_duration *= stats.range; *energy_drain /= stats.energy_efficiency; - if let Some(CombatEffect::Buff(combat::CombatBuff { - kind: _, - dur_secs: _, - strength, - chance: _, - })) = damage_effect - { - *strength *= stats.buff_strength; - } + *damage_effect = damage_effect.map(|de| de.adjusted_by_stats(stats)); }, BasicAura { ref mut buildup_duration, diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 10c26f3194..9e2ea21973 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -913,6 +913,11 @@ impl CharacterState { } else { AttackSource::AirShockwave }), + CharacterState::LeapShockwave(data) => Some(if data.static_data.requires_ground { + AttackSource::GroundShockwave + } else { + AttackSource::AirShockwave + }), CharacterState::BasicBeam(_) => Some(AttackSource::Beam), CharacterState::BasicAura(_) => None, CharacterState::Blink(_) => None, @@ -926,11 +931,6 @@ impl CharacterState { CharacterState::DiveMelee(_) => Some(AttackSource::Melee), CharacterState::RiposteMelee(_) => Some(AttackSource::Melee), CharacterState::RapidMelee(_) => Some(AttackSource::Melee), - CharacterState::LeapShockwave(data) => Some(if data.static_data.requires_ground { - AttackSource::GroundShockwave - } else { - AttackSource::AirShockwave - }), } } } diff --git a/common/src/comp/melee.rs b/common/src/comp/melee.rs index 211a5034b5..4ad05321ec 100644 --- a/common/src/comp/melee.rs +++ b/common/src/comp/melee.rs @@ -62,7 +62,7 @@ pub struct MeleeConstructor { } impl MeleeConstructor { - pub fn create_melee(self, (crit_chance, crit_mult): (f32, f32), buff_strength: f32) -> Melee { + pub fn create_melee(self, (crit_chance, crit_mult): (f32, f32), tool_stats: Stats) -> Melee { use MeleeConstructorKind::*; if self.scaled.is_some() { dev_panic!( @@ -83,9 +83,10 @@ impl MeleeConstructor { let buff = CombatEffect::Buff(CombatBuff { kind: BuffKind::Bleeding, dur_secs: 10.0, - strength: CombatBuffStrength::DamageFraction(0.1 * buff_strength), + strength: CombatBuffStrength::DamageFraction(0.1), chance: 0.1, - }); + }) + .adjusted_by_stats(tool_stats); let mut damage = AttackDamage::new( Damage { source: DamageSource::Melee, @@ -109,7 +110,8 @@ impl MeleeConstructor { CombatEffect::Knockback(Knockback { strength: knockback, direction: KnockbackDir::Away, - }), + }) + .adjusted_by_stats(tool_stats), ) .with_requirement(CombatRequirement::AnyDamage); @@ -132,9 +134,10 @@ impl MeleeConstructor { let buff = CombatEffect::Buff(CombatBuff { kind: BuffKind::Bleeding, dur_secs: 5.0, - strength: CombatBuffStrength::DamageFraction(0.05 * buff_strength), + strength: CombatBuffStrength::DamageFraction(0.05), chance: 0.1, - }); + }) + .adjusted_by_stats(tool_stats); let mut damage = AttackDamage::new( Damage { source: DamageSource::Melee, @@ -158,7 +161,8 @@ impl MeleeConstructor { CombatEffect::Knockback(Knockback { strength: knockback, direction: KnockbackDir::Away, - }), + }) + .adjusted_by_stats(tool_stats), ) .with_requirement(CombatRequirement::AnyDamage); @@ -200,7 +204,8 @@ impl MeleeConstructor { CombatEffect::Knockback(Knockback { strength: knockback, direction: KnockbackDir::Away, - }), + }) + .adjusted_by_stats(tool_stats), ) .with_requirement(CombatRequirement::AnyDamage); @@ -239,7 +244,8 @@ impl MeleeConstructor { CombatEffect::Knockback(Knockback { strength: pull, direction: KnockbackDir::Towards, - }), + }) + .adjusted_by_stats(tool_stats), ) .with_requirement(CombatRequirement::AnyDamage); @@ -276,7 +282,8 @@ impl MeleeConstructor { CombatEffect::Knockback(Knockback { strength: knockback, direction: KnockbackDir::Away, - }), + }) + .adjusted_by_stats(tool_stats), ) .with_requirement(CombatRequirement::AnyDamage); @@ -419,9 +426,7 @@ impl MeleeConstructor { if let Some(ref mut scaled) = &mut self.scaled { *scaled = scaled.adjusted_by_stats(stats); } - if let Some(CombatEffect::Buff(CombatBuff { strength, .. })) = &mut self.damage_effect { - *strength *= stats.buff_strength; - } + self.damage_effect = self.damage_effect.map(|de| de.adjusted_by_stats(stats)); self } } diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index ce57b7c3a3..27d8c1aba9 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -3,7 +3,10 @@ use crate::{ Attack, AttackDamage, AttackEffect, CombatBuff, CombatBuffStrength, CombatEffect, CombatRequirement, Damage, DamageKind, DamageSource, GroupTarget, Knockback, KnockbackDir, }, - comp::{buff::BuffKind, item::Reagent}, + comp::{ + buff::BuffKind, + item::{tool, Reagent}, + }, uid::Uid, Explosion, RadiusEffect, }; @@ -119,7 +122,7 @@ impl ProjectileConstructor { owner: Option, crit_chance: f32, crit_mult: f32, - buff_strength: f32, + tool_stats: tool::Stats, damage_effect: Option, ) -> Projectile { let instance = rand::random(); @@ -135,7 +138,8 @@ impl ProjectileConstructor { CombatEffect::Knockback(Knockback { strength: knockback, direction: KnockbackDir::Away, - }), + }) + .adjusted_by_stats(tool_stats), ) .with_requirement(CombatRequirement::AnyDamage); let energy = AttackEffect::new(None, CombatEffect::EnergyReward(energy_regen)) @@ -143,9 +147,10 @@ impl ProjectileConstructor { let buff = CombatEffect::Buff(CombatBuff { kind: BuffKind::Bleeding, dur_secs: 10.0, - strength: CombatBuffStrength::DamageFraction(0.1 * buff_strength), + strength: CombatBuffStrength::DamageFraction(0.1), chance: 0.1, - }); + }) + .adjusted_by_stats(tool_stats); let mut damage = AttackDamage::new( Damage { source: DamageSource::Projectile, @@ -187,9 +192,10 @@ impl ProjectileConstructor { let buff = CombatEffect::Buff(CombatBuff { kind: BuffKind::Burning, dur_secs: 5.0, - strength: CombatBuffStrength::DamageFraction(0.1 * buff_strength), + strength: CombatBuffStrength::DamageFraction(0.1), chance: 0.1, - }); + }) + .adjusted_by_stats(tool_stats); let damage = AttackDamage::new( Damage { source: DamageSource::Explosion, @@ -268,9 +274,10 @@ impl ProjectileConstructor { CombatEffect::Buff(CombatBuff { kind: BuffKind::Poisoned, dur_secs: 5.0, - strength: CombatBuffStrength::DamageFraction(0.8 * buff_strength), + strength: CombatBuffStrength::DamageFraction(0.8), chance: 1.0, - }), + }) + .adjusted_by_stats(tool_stats), ) .with_requirement(CombatRequirement::AnyDamage); let damage = AttackDamage::new( @@ -359,7 +366,8 @@ impl ProjectileConstructor { CombatEffect::Knockback(Knockback { strength: knockback, direction: KnockbackDir::Away, - }), + }) + .adjusted_by_stats(tool_stats), ) .with_requirement(CombatRequirement::AnyDamage); let damage = AttackDamage::new( @@ -506,7 +514,8 @@ impl ProjectileConstructor { CombatEffect::Knockback(Knockback { strength: knockback, direction: KnockbackDir::Away, - }), + }) + .adjusted_by_stats(tool_stats), ) .with_requirement(CombatRequirement::AnyDamage); let buff = AttackEffect::new( @@ -514,9 +523,10 @@ impl ProjectileConstructor { CombatEffect::Buff(CombatBuff { kind: BuffKind::Burning, dur_secs: 5.0, - strength: CombatBuffStrength::DamageFraction(0.2 * buff_strength), + strength: CombatBuffStrength::DamageFraction(0.2), chance: 1.0, - }), + }) + .adjusted_by_stats(tool_stats), ) .with_requirement(CombatRequirement::AnyDamage); let damage = AttackDamage::new( @@ -563,7 +573,8 @@ impl ProjectileConstructor { CombatEffect::Knockback(Knockback { strength: knockback, direction: KnockbackDir::Away, - }), + }) + .adjusted_by_stats(tool_stats), ) .with_requirement(CombatRequirement::AnyDamage); let buff = AttackEffect::new( @@ -571,9 +582,10 @@ impl ProjectileConstructor { CombatEffect::Buff(CombatBuff { kind: BuffKind::Burning, dur_secs: 5.0, - strength: CombatBuffStrength::DamageFraction(0.2 * buff_strength), + strength: CombatBuffStrength::DamageFraction(0.2), chance: 1.0, - }), + }) + .adjusted_by_stats(tool_stats), ) .with_requirement(CombatRequirement::AnyDamage); let damage = AttackDamage::new( @@ -628,9 +640,10 @@ impl ProjectileConstructor { CombatEffect::Buff(CombatBuff { kind: BuffKind::Frozen, dur_secs: 5.0, - strength: CombatBuffStrength::DamageFraction(0.05 * buff_strength), + strength: CombatBuffStrength::DamageFraction(0.05), chance: 1.0, - }), + }) + .adjusted_by_stats(tool_stats), ) .with_requirement(CombatRequirement::AnyDamage); let damage = AttackDamage::new( diff --git a/common/src/states/basic_melee.rs b/common/src/states/basic_melee.rs index 4274ec1fb2..cd91f40a28 100644 --- a/common/src/states/basic_melee.rs +++ b/common/src/states/basic_melee.rs @@ -75,13 +75,13 @@ impl CharacterBehavior for Data { }); let crit_data = get_crit_data(data, self.static_data.ability_info); - let buff_strength = get_buff_strength(data, self.static_data.ability_info); + let tool_stats = get_tool_stats(data, self.static_data.ability_info); data.updater.insert( data.entity, self.static_data .melee_constructor - .create_melee(crit_data, buff_strength) + .create_melee(crit_data, tool_stats) .with_block_breaking( data.inputs .break_block_pos diff --git a/common/src/states/basic_ranged.rs b/common/src/states/basic_ranged.rs index ad20914e2a..84fbd82165 100644 --- a/common/src/states/basic_ranged.rs +++ b/common/src/states/basic_ranged.rs @@ -80,12 +80,12 @@ impl CharacterBehavior for Data { // Fire let (crit_chance, crit_mult) = get_crit_data(data, self.static_data.ability_info); - let buff_strength = get_buff_strength(data, self.static_data.ability_info); + let tool_stats = get_tool_stats(data, self.static_data.ability_info); let projectile = self.static_data.projectile.create_projectile( Some(*data.uid), crit_chance, crit_mult, - buff_strength, + tool_stats, self.static_data.damage_effect, ); // Shoots all projectiles simultaneously diff --git a/common/src/states/charged_melee.rs b/common/src/states/charged_melee.rs index 2e29ce7fa1..74a8c61e5a 100644 --- a/common/src/states/charged_melee.rs +++ b/common/src/states/charged_melee.rs @@ -71,9 +71,9 @@ impl CharacterBehavior for Data { } } else { let crit_data = get_crit_data(data, self.static_data.ability_info); - let buff_strength = get_buff_strength(data, self.static_data.ability_info); + let tool_stats = get_tool_stats(data, self.static_data.ability_info); data.updater - .insert(data.entity, strike.create_melee(crit_data, buff_strength)); + .insert(data.entity, strike.create_melee(crit_data, tool_stats)); if let CharacterState::ChargedMelee(c) = &mut update.character { c.stage_section = StageSection::Charge; @@ -141,14 +141,14 @@ impl CharacterBehavior for Data { }); let crit_data = get_crit_data(data, self.static_data.ability_info); - let buff_strength = get_buff_strength(data, self.static_data.ability_info); + let tool_stats = get_tool_stats(data, self.static_data.ability_info); data.updater.insert( data.entity, self.static_data .melee_constructor .handle_scaling(self.charge_amount) - .create_melee(crit_data, buff_strength), + .create_melee(crit_data, tool_stats), ); if let Some(FrontendSpecifier::GroundCleave) = self.static_data.specifier { diff --git a/common/src/states/charged_ranged.rs b/common/src/states/charged_ranged.rs index 785aedb947..0277c42312 100644 --- a/common/src/states/charged_ranged.rs +++ b/common/src/states/charged_ranged.rs @@ -112,7 +112,7 @@ impl CharacterBehavior for Data { // Fire let (crit_chance, crit_mult) = get_crit_data(data, self.static_data.ability_info); - let buff_strength = get_buff_strength(data, self.static_data.ability_info); + let tool_stats = get_tool_stats(data, self.static_data.ability_info); // Gets offsets let body_offsets = data.body.projectile_offsets(update.ori.look_vec()); let pos = Pos(data.pos.0 + body_offsets); @@ -120,7 +120,7 @@ impl CharacterBehavior for Data { Some(*data.uid), crit_chance, crit_mult, - buff_strength, + tool_stats, self.static_data.damage_effect, ); output_events.emit_server(ServerEvent::Shoot { diff --git a/common/src/states/combo_melee.rs b/common/src/states/combo_melee.rs index 84701649ac..653b69294d 100644 --- a/common/src/states/combo_melee.rs +++ b/common/src/states/combo_melee.rs @@ -1,5 +1,5 @@ use crate::{ - combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement}, + combat::{Attack, AttackDamage, AttackEffect, CombatEffect, CombatRequirement}, comp::{ character_state::OutputEvents, melee::MultiTarget, @@ -72,16 +72,7 @@ impl Stage { } #[must_use] - pub fn adjusted_by_stats(mut self, stats: Stats) -> Self { - if let Some(CombatEffect::Buff(CombatBuff { - kind: _, - dur_secs: _, - ref mut strength, - chance: _, - })) = self.damage_effect - { - *strength *= stats.buff_strength; - } + pub fn adjusted_by_stats(self, stats: Stats) -> Self { Self { stage: self.stage, base_damage: self.base_damage * stats.power, @@ -97,7 +88,7 @@ impl Stage { base_recover_duration: self.base_recover_duration / stats.speed, forward_movement: self.forward_movement, damage_kind: self.damage_kind, - damage_effect: self.damage_effect, + damage_effect: self.damage_effect.map(|de| de.adjusted_by_stats(stats)), } } diff --git a/common/src/states/combo_melee2.rs b/common/src/states/combo_melee2.rs index cfff041001..19b32e38e8 100644 --- a/common/src/states/combo_melee2.rs +++ b/common/src/states/combo_melee2.rs @@ -154,13 +154,13 @@ impl CharacterBehavior for Data { } let crit_data = get_crit_data(data, self.static_data.ability_info); - let buff_strength = get_buff_strength(data, self.static_data.ability_info); + let tool_stats = get_tool_stats(data, self.static_data.ability_info); data.updater.insert( data.entity, strike_data .melee_constructor - .create_melee(crit_data, buff_strength), + .create_melee(crit_data, tool_stats), ); } else if self.timer < strike_data.swing_duration { // Swings diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index b97586eccb..4547b0e28c 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -1,6 +1,6 @@ use crate::{ comp::{ - character_state::OutputEvents, CharacterState, Melee, MeleeConstructor, + character_state::OutputEvents, item::tool, CharacterState, Melee, MeleeConstructor, MeleeConstructorKind, StateUpdate, }, states::{ @@ -62,11 +62,11 @@ impl CharacterBehavior for Data { let create_melee = |charge_frac: f32| { let crit_data = get_crit_data(data, self.static_data.ability_info); - let buff_strength = get_buff_strength(data, self.static_data.ability_info); + let tool_stats = get_tool_stats(data, self.static_data.ability_info); self.static_data .melee_constructor .handle_scaling(charge_frac) - .create_melee(crit_data, buff_strength) + .create_melee(crit_data, tool_stats) }; match self.stage_section { @@ -208,14 +208,14 @@ impl CharacterBehavior for Data { .min(1.0); let crit_data = get_crit_data(data, self.static_data.ability_info); - let buff_strength = get_buff_strength(data, self.static_data.ability_info); + let tool_stats = get_tool_stats(data, self.static_data.ability_info); data.updater.insert( data.entity, self.static_data .melee_constructor .handle_scaling(charge_frac) - .create_melee(crit_data, buff_strength), + .create_melee(crit_data, tool_stats), ); update.character = CharacterState::DashMelee(Data { @@ -277,5 +277,5 @@ fn create_test_melee(static_data: StaticData) -> Melee { multi_target: None, damage_effect: None, }; - melee.create_melee((0.0, 0.0), 0.0) + melee.create_melee((0.0, 0.0), tool::Stats::one()) } diff --git a/common/src/states/dive_melee.rs b/common/src/states/dive_melee.rs index 43c951bd42..a67c921250 100644 --- a/common/src/states/dive_melee.rs +++ b/common/src/states/dive_melee.rs @@ -95,7 +95,7 @@ impl CharacterBehavior for Data { if !self.exhausted { // Attack let crit_data = get_crit_data(data, self.static_data.ability_info); - let buff_strength = get_buff_strength(data, self.static_data.ability_info); + let tool_stats = get_tool_stats(data, self.static_data.ability_info); let scaling = self.max_vertical_speed / self.static_data.vertical_speed; let scaling = scaling.min(self.static_data.max_scaling); @@ -104,7 +104,7 @@ impl CharacterBehavior for Data { self.static_data .melee_constructor .handle_scaling(scaling) - .create_melee(crit_data, buff_strength), + .create_melee(crit_data, tool_stats), ); if let CharacterState::DiveMelee(c) = &mut update.character { diff --git a/common/src/states/finisher_melee.rs b/common/src/states/finisher_melee.rs index 64c09256fb..2dfdafc708 100644 --- a/common/src/states/finisher_melee.rs +++ b/common/src/states/finisher_melee.rs @@ -107,11 +107,11 @@ impl CharacterBehavior for Data { } let crit_data = get_crit_data(data, self.static_data.ability_info); - let buff_strength = get_buff_strength(data, self.static_data.ability_info); + let tool_stats = get_tool_stats(data, self.static_data.ability_info); data.updater.insert( data.entity, - melee_constructor.create_melee(crit_data, buff_strength), + melee_constructor.create_melee(crit_data, tool_stats), ); } else if self.timer < self.static_data.swing_duration { // Swings diff --git a/common/src/states/leap_melee.rs b/common/src/states/leap_melee.rs index 7fadef7997..07cf8ca7c5 100644 --- a/common/src/states/leap_melee.rs +++ b/common/src/states/leap_melee.rs @@ -120,13 +120,13 @@ impl CharacterBehavior for Data { StageSection::Recover => { if !self.exhausted { let crit_data = get_crit_data(data, self.static_data.ability_info); - let buff_strength = get_buff_strength(data, self.static_data.ability_info); + let tool_stats = get_tool_stats(data, self.static_data.ability_info); data.updater.insert( data.entity, self.static_data .melee_constructor - .create_melee(crit_data, buff_strength), + .create_melee(crit_data, tool_stats), ); update.character = CharacterState::LeapMelee(Data { diff --git a/common/src/states/rapid_melee.rs b/common/src/states/rapid_melee.rs index e7b015a84c..4ab4f80d6f 100644 --- a/common/src/states/rapid_melee.rs +++ b/common/src/states/rapid_melee.rs @@ -85,13 +85,13 @@ impl CharacterBehavior for Data { } let crit_data = get_crit_data(data, self.static_data.ability_info); - let buff_strength = get_buff_strength(data, self.static_data.ability_info); + let tool_stats = get_tool_stats(data, self.static_data.ability_info); data.updater.insert( data.entity, self.static_data .melee_constructor - .create_melee(crit_data, buff_strength), + .create_melee(crit_data, tool_stats), ); } else if self.timer < self.static_data.swing_duration { // Swings diff --git a/common/src/states/repeater_ranged.rs b/common/src/states/repeater_ranged.rs index 040592a8ed..639c47f57b 100644 --- a/common/src/states/repeater_ranged.rs +++ b/common/src/states/repeater_ranged.rs @@ -93,7 +93,7 @@ impl CharacterBehavior for Data { // Fire if input is pressed still let (crit_chance, crit_mult) = get_crit_data(data, self.static_data.ability_info); - let buff_strength = get_buff_strength(data, self.static_data.ability_info); + let tool_stats = get_tool_stats(data, self.static_data.ability_info); // Gets offsets let body_offsets = data.body.projectile_offsets(update.ori.look_vec()); let pos = Pos(data.pos.0 + body_offsets); @@ -101,7 +101,7 @@ impl CharacterBehavior for Data { Some(*data.uid), crit_chance, crit_mult, - buff_strength, + tool_stats, self.static_data.damage_effect, ); output_events.emit_server(ServerEvent::Shoot { diff --git a/common/src/states/riposte_melee.rs b/common/src/states/riposte_melee.rs index c8cd298ed2..aac88b5f8e 100644 --- a/common/src/states/riposte_melee.rs +++ b/common/src/states/riposte_melee.rs @@ -65,13 +65,13 @@ impl CharacterBehavior for Data { } let crit_data = get_crit_data(data, self.static_data.ability_info); - let buff_strength = get_buff_strength(data, self.static_data.ability_info); + let tool_stats = get_tool_stats(data, self.static_data.ability_info); data.updater.insert( data.entity, self.static_data .melee_constructor - .create_melee(crit_data, buff_strength), + .create_melee(crit_data, tool_stats), ); } else if self.timer < self.static_data.swing_duration { // Swings diff --git a/common/src/states/spin_melee.rs b/common/src/states/spin_melee.rs index 93efbc3a0a..f1ceac6c19 100644 --- a/common/src/states/spin_melee.rs +++ b/common/src/states/spin_melee.rs @@ -93,13 +93,13 @@ impl CharacterBehavior for Data { }); let crit_data = get_crit_data(data, self.static_data.ability_info); - let buff_strength = get_buff_strength(data, self.static_data.ability_info); + let tool_stats = get_tool_stats(data, self.static_data.ability_info); data.updater.insert( data.entity, self.static_data .melee_constructor - .create_melee(crit_data, buff_strength), + .create_melee(crit_data, tool_stats), ); } else if self.timer < self.static_data.swing_duration { if matches!( diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 52acb1fff7..441df70c35 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -7,7 +7,11 @@ use crate::{ character_state::OutputEvents, controller::InventoryManip, inventory::slot::{ArmorSlot, EquipSlot, Slot}, - item::{armor::Friction, tool::AbilityContext, Hands, ItemKind, ToolKind}, + item::{ + armor::Friction, + tool::{self, AbilityContext}, + Hands, ItemKind, ToolKind, + }, quadruped_low, quadruped_medium, quadruped_small, skills::{Skill, SwimSkill, SKILL_MODIFIERS}, theropod, Body, CharacterAbility, CharacterState, Density, InputAttr, InputKind, @@ -1269,8 +1273,7 @@ pub fn get_crit_data(data: &JoinData<'_>, ai: AbilityInfo) -> (f32, f32) { (crit_chance, crit_mult) } -/// Returns buff strength from the weapon used in the ability -pub fn get_buff_strength(data: &JoinData<'_>, ai: AbilityInfo) -> f32 { +pub fn get_tool_stats(data: &JoinData<'_>, ai: AbilityInfo) -> tool::Stats { ai.hand .map(|hand| match hand { HandInfo::TwoHanded | HandInfo::MainHand => EquipSlot::ActiveMainhand, @@ -1279,12 +1282,12 @@ pub fn get_buff_strength(data: &JoinData<'_>, ai: AbilityInfo) -> f32 { .and_then(|slot| data.inventory.and_then(|inv| inv.equipped(slot))) .and_then(|item| { if let ItemKind::Tool(tool) = &*item.kind() { - Some(tool.base_buff_strength()) + Some(tool.stats) } else { None } }) - .unwrap_or(1.0) + .unwrap_or(tool::Stats::one()) } pub fn input_is_pressed(data: &JoinData<'_>, input: InputKind) -> bool { diff --git a/server/src/wiring.rs b/server/src/wiring.rs index 9fc259f4ef..384be7b52e 100644 --- a/server/src/wiring.rs +++ b/server/src/wiring.rs @@ -1,5 +1,5 @@ use common::{ - comp::{object, Body, LightEmitter, PhysicsState, Pos, ProjectileConstructor}, + comp::{item::tool, object, Body, LightEmitter, PhysicsState, Pos, ProjectileConstructor}, event::{Emitter, ServerEvent}, terrain::{Block, TerrainChunkSize}, util::Dir, @@ -188,7 +188,13 @@ impl WiringAction { pos, dir: Dir::forward(), body: Body::Object(object::Body::Arrow), - projectile: constr.create_projectile(None, 0.0, 1.0, 1.0, None), + projectile: constr.create_projectile( + None, + 0.0, + 1.0, + tool::Stats::one(), + None, + ), light: None, speed: 5.0, object: None, diff --git a/voxygen/src/ui/widgets/item_tooltip.rs b/voxygen/src/ui/widgets/item_tooltip.rs index 50b39a0f21..7333c32ad8 100644 --- a/voxygen/src/ui/widgets/item_tooltip.rs +++ b/voxygen/src/ui/widgets/item_tooltip.rs @@ -620,12 +620,10 @@ impl<'a> Widget for ItemTooltip<'a> { ); // Effect Power - // TODO: Allow effect power to have different terminology based on what it is - // affecting. stat_text( format!( "{} : {:+.0}%", - i18n.get_msg("common-stats-poise"), + i18n.get_msg("common-stats-effect-power"), (stats.effect_power - 1.0) * 100.0 ), 2, @@ -1053,13 +1051,13 @@ impl<'a> Widget for ItemTooltip<'a> { let effect_power_text = if is_primary { format!( "{} : {:+.0}%", - i18n.get_msg("common-stats-poise"), + i18n.get_msg("common-stats-effect-power"), (stats.effect_power - 1.0) * 100.0 ) } else { format!( "{} : x{:.2}", - i18n.get_msg("common-stats-poise"), + i18n.get_msg("common-stats-effect-power"), stats.effect_power ) };