From 961edf910dffc1e4b9a1dbc5939a9acb952521fc Mon Sep 17 00:00:00 2001 From: danielkenji83 Date: Mon, 19 Feb 2024 19:22:55 -0300 Subject: [PATCH] Updates from review --- .../common/abilities/ability_set_manifest.ron | 2 +- .../common/abilities/shield/basic_guard.ron | 2 +- .../common/abilities/shield/power_guard.ron | 21 ++++++ .../abilities/sword/defensive_deflect.ron | 2 +- .../abilities/sword/defensive_guard.ron | 2 +- common/src/combat.rs | 64 +++++++++---------- common/src/comp/ability.rs | 36 +---------- common/src/states/basic_block.rs | 3 +- common/src/states/riposte_melee.rs | 3 +- common/src/states/utils.rs | 12 ++-- voxygen/anim/src/character/block.rs | 3 +- .../src/audio/sfx/event_mapper/combat/mod.rs | 6 +- voxygen/src/hud/util.rs | 1 + 13 files changed, 72 insertions(+), 85 deletions(-) create mode 100644 assets/common/abilities/shield/power_guard.ron diff --git a/assets/common/abilities/ability_set_manifest.ron b/assets/common/abilities/ability_set_manifest.ron index 61f9a74939..a142621547 100644 --- a/assets/common/abilities/ability_set_manifest.ron +++ b/assets/common/abilities/ability_set_manifest.ron @@ -353,7 +353,7 @@ Tool(Shield): ( guard: Some(Simple(None, "common.abilities.shield.basic_guard")), primary: Simple(None, "common.abilities.shield.singlestrike"), - secondary: Simple(None, "common.abilities.shield.singlestrike"), + secondary: Simple(None, "common.abilities.shield.power_guard"), abilities: [], ), Custom("Stone Golem"): ( diff --git a/assets/common/abilities/shield/basic_guard.ron b/assets/common/abilities/shield/basic_guard.ron index 5d2ab3f1b5..5d8ac8f34a 100644 --- a/assets/common/abilities/shield/basic_guard.ron +++ b/assets/common/abilities/shield/basic_guard.ron @@ -8,7 +8,7 @@ BasicBlock( recover: false, ), energy_cost: 5.0, - energy_regen: 5.0, + energy_regen: 2.5, can_hold: true, blocked_attacks: ( melee: true, diff --git a/assets/common/abilities/shield/power_guard.ron b/assets/common/abilities/shield/power_guard.ron new file mode 100644 index 0000000000..fbbd23d127 --- /dev/null +++ b/assets/common/abilities/shield/power_guard.ron @@ -0,0 +1,21 @@ +BasicBlock( + buildup_duration: 0.5, + recover_duration: 0.25, + max_angle: 90.0, + block_strength: 15.0, + parry_window: ( + buildup: true, + recover: false, + ), + energy_cost: 15.0, + energy_regen: 2.5, + can_hold: true, + blocked_attacks: ( + melee: true, + projectiles: true, + beams: true, + ground_shockwaves: false, + air_shockwaves: true, + explosions: true, + ), +) \ No newline at end of file diff --git a/assets/common/abilities/sword/defensive_deflect.ron b/assets/common/abilities/sword/defensive_deflect.ron index aa3c71f86a..916f822650 100644 --- a/assets/common/abilities/sword/defensive_deflect.ron +++ b/assets/common/abilities/sword/defensive_deflect.ron @@ -2,7 +2,7 @@ BasicBlock( buildup_duration: 0.4, recover_duration: 0.2, max_angle: 45.0, - block_strength: 5.0, + block_strength: 7.5, parry_window: ( buildup: true, recover: false, diff --git a/assets/common/abilities/sword/defensive_guard.ron b/assets/common/abilities/sword/defensive_guard.ron index b4370f6dcc..1bc159d36b 100644 --- a/assets/common/abilities/sword/defensive_guard.ron +++ b/assets/common/abilities/sword/defensive_guard.ron @@ -2,7 +2,7 @@ BasicBlock( buildup_duration: 0.4, recover_duration: 0.15, max_angle: 60.0, - block_strength: 5.75, + block_strength: 7.5, parry_window: ( buildup: true, recover: false, diff --git a/common/src/combat.rs b/common/src/combat.rs index dadc226c10..9a646df5b5 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -20,7 +20,7 @@ use crate::{ }, outcome::Outcome, resources::{Secs, Time}, - states::utils::{HandInfo, StageSection}, + states::utils::StageSection, uid::{IdMaps, Uid}, util::Dir, }; @@ -1544,41 +1544,35 @@ pub fn precision_mult_from_flank(attack_dir: Vec3, target_ori: Option<&Ori> } pub fn block_strength(inventory: &Inventory, char_state: &CharacterState) -> f32 { - char_state - .ability_info() - .and_then(|a| match a.hand { - Some(HandInfo::TwoHanded | HandInfo::MainHand) => Some(EquipSlot::ActiveMainhand), - Some(HandInfo::OffHand) => Some(EquipSlot::ActiveOffhand), - None => None, - }) - .and_then(|slot| inventory.equipped(slot)) - .map(|item| match &*item.kind() { - ItemKind::Tool(tool) => tool.stats(item.stats_durability_multiplier()).power, - _ => 0.0, - }) - .map_or(0.0, |tool_block_strength| match char_state { - CharacterState::BasicBlock(data) => data.static_data.block_strength, - CharacterState::RiposteMelee(data) => data.static_data.block_strength, - _ => { - char_state - .ability_info() - .map(|ability| ability.ability_meta.capabilities) - .map_or(0.0, |capabilities| { - if capabilities.contains(Capability::PARRIES) - || capabilities.contains(Capability::PARRIES_MELEE) - { - return tool_block_strength; - } - - if capabilities.contains(Capability::BLOCKS) { - return tool_block_strength * 0.5; - } - + match char_state { + CharacterState::BasicBlock(data) => data.static_data.block_strength, + CharacterState::RiposteMelee(data) => data.static_data.block_strength, + _ => char_state + .ability_info() + .map(|ability| (ability.ability_meta.capabilities, ability.hand)) + .map(|(capabilities, hand)| { + ( + if capabilities.contains(Capability::PARRIES) + || capabilities.contains(Capability::PARRIES_MELEE) + || capabilities.contains(Capability::BLOCKS) + { + FALLBACK_BLOCK_STRENGTH + } else { 0.0 - }) - * FALLBACK_BLOCK_STRENGTH - }, - }) + }, + hand.and_then(|hand| inventory.equipped(hand.to_equip_slot())) + .map_or(1.0, |item| match &*item.kind() { + ItemKind::Tool(tool) => { + tool.stats(item.stats_durability_multiplier()).power + }, + _ => 1.0, + }), + ) + }) + .map_or(0.0, |(capability_strength, tool_block_strength)| { + capability_strength * tool_block_strength + }), + } } pub fn get_equip_slot_by_block_priority(inventory: Option<&Inventory>) -> EquipSlot { diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 90a57eec91..46167a7d5c 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -210,21 +210,6 @@ impl ActiveAbilities { spec_ability(i), ) }) - .or_else(|| { - ability_set(EquipSlot::ActiveMainhand) - .and_then(|abilities| { - abilities - .guard(Some(skill_set), context) - .map(|(a, i)| (a.ability.clone(), i)) - }) - .map(|(ability, i)| { - ( - scale_ability(ability, EquipSlot::ActiveMainhand), - false, - spec_ability(i), - ) - }) - }) }, Ability::ToolPrimary => ability_set(EquipSlot::ActiveMainhand) .and_then(|abilities| { @@ -410,19 +395,6 @@ impl Ability { .as_ref() .and_then(|g| contextual_id(Some(g))) }) - }) - .or_else(|| { - ability_set(EquipSlot::ActiveMainhand).and_then(|abilities| { - abilities - .guard(skillset, context) - .map(|a| a.0.id.as_str()) - .or_else(|| { - abilities - .guard - .as_ref() - .and_then(|g| contextual_id(Some(g))) - }) - }) }), Ability::ToolPrimary => ability_set(EquipSlot::ActiveMainhand).and_then(|abilities| { abilities @@ -528,11 +500,7 @@ impl SpecifiedAbility { .map(|abilities| ability_id(self, &abilities.secondary)) }), Ability::ToolGuard => ability_set(combat::get_equip_slot_by_block_priority(inv)) - .and_then(|abilities| abilities.guard.as_ref().map(|a| ability_id(self, a))) - .or_else(|| { - ability_set(EquipSlot::ActiveMainhand) - .and_then(|abilities| abilities.guard.as_ref().map(|a| ability_id(self, a))) - }), + .and_then(|abilities| abilities.guard.as_ref().map(|a| ability_id(self, a))), Ability::SpeciesMovement => None, // TODO: Make not None Ability::MainWeaponAux(index) => ability_set(EquipSlot::ActiveMainhand) .and_then(|abilities| abilities.abilities.get(index).map(|a| ability_id(self, a))), @@ -3015,7 +2983,7 @@ bitflags::bitflags! { const PARRIES = 0b00000001; // Allows blocking to interrupt the ability at any point const BLOCK_INTERRUPT = 0b00000010; - // When the ability is in the buildup section, it counts as a block with 50% DR + // The ability will block melee attacks in the buildup portion const BLOCKS = 0b00000100; // When in the ability, an entity only receives half as much poise damage const POISE_RESISTANT = 0b00001000; diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index 0224e2770a..b21984f42b 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -25,7 +25,8 @@ pub struct StaticData { pub recover_duration: Duration, /// Max angle (45.0 will give you a 90.0 angle window) pub max_angle: f32, - /// What percentage of power is effective + /// Base value that incoming damage is reduced by and converted to poise + /// damage pub block_strength: f32, /// What durations are considered a parry pub parry_window: ParryWindow, diff --git a/common/src/states/riposte_melee.rs b/common/src/states/riposte_melee.rs index c2c55e42c3..c9bb66ea60 100644 --- a/common/src/states/riposte_melee.rs +++ b/common/src/states/riposte_melee.rs @@ -18,7 +18,8 @@ pub struct StaticData { pub swing_duration: Duration, /// How long the state has until exiting pub recover_duration: Duration, - /// What percentage of power is effective + /// Base value that incoming damage is reduced by and converted to poise + /// damage pub block_strength: f32, /// Used to construct the Melee attack pub melee_constructor: MeleeConstructor, diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 8f04403e55..c972201006 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -1402,10 +1402,7 @@ pub fn get_hands(data: &JoinData<'_>) -> (Option, Option) { pub fn get_tool_stats(data: &JoinData<'_>, ai: AbilityInfo) -> tool::Stats { ai.hand - .map(|hand| match hand { - HandInfo::TwoHanded | HandInfo::MainHand => EquipSlot::ActiveMainhand, - HandInfo::OffHand => EquipSlot::ActiveOffhand, - }) + .map(|hand| hand.to_equip_slot()) .and_then(|slot| data.inventory.and_then(|inv| inv.equipped(slot))) .and_then(|item| { if let ItemKind::Tool(tool) = &*item.kind() { @@ -1607,6 +1604,13 @@ impl HandInfo { }, } } + + pub fn to_equip_slot(&self) -> EquipSlot { + match self { + HandInfo::TwoHanded | HandInfo::MainHand => EquipSlot::ActiveMainhand, + HandInfo::OffHand => EquipSlot::ActiveOffhand, + } + } } pub fn leave_stance(data: &JoinData<'_>, output_events: &mut OutputEvents) { diff --git a/voxygen/anim/src/character/block.rs b/voxygen/anim/src/character/block.rs index 0e3c75f484..2fec758d54 100644 --- a/voxygen/anim/src/character/block.rs +++ b/voxygen/anim/src/character/block.rs @@ -56,7 +56,8 @@ impl Animation for BlockAnimation { | Some("common.abilities.axe.basic_guard") | Some("common.abilities.hammer.basic_guard") | Some("common.abilities.sword.defensive_guard") - | Some("common.abilities.shield.basic_guard") => { + | Some("common.abilities.shield.basic_guard") + | Some("common.abilities.shield.power_guard") => { let speed = Vec2::::from(velocity).magnitude(); let (movement1base, move2, movement3) = match stage_section { diff --git a/voxygen/src/audio/sfx/event_mapper/combat/mod.rs b/voxygen/src/audio/sfx/event_mapper/combat/mod.rs index 5cdae03c80..edc86365a8 100644 --- a/voxygen/src/audio/sfx/event_mapper/combat/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/combat/mod.rs @@ -14,7 +14,6 @@ use common::{ inventory::slot::EquipSlot, item::ItemKind, CharacterAbilityType, CharacterState, Inventory, Pos, }, - states::utils::HandInfo, terrain::TerrainChunk, vol::ReadVol, }; @@ -149,10 +148,7 @@ impl CombatEventMapper { let equip_slot = character_state .ability_info() .and_then(|ability| ability.hand) - .map_or(EquipSlot::ActiveMainhand, |hand| match hand { - HandInfo::TwoHanded | HandInfo::MainHand => EquipSlot::ActiveMainhand, - HandInfo::OffHand => EquipSlot::ActiveOffhand, - }); + .map_or(EquipSlot::ActiveMainhand, |hand| hand.to_equip_slot()); if let Some(item) = inventory.equipped(equip_slot) { if let ItemKind::Tool(data) = &*item.kind() { diff --git a/voxygen/src/hud/util.rs b/voxygen/src/hud/util.rs index 761321a50b..805742c70a 100644 --- a/voxygen/src/hud/util.rs +++ b/voxygen/src/hud/util.rs @@ -564,6 +564,7 @@ pub fn ability_image(imgs: &img_ids::Imgs, ability_id: &str) -> image::Id { "common.abilities.sceptre.wardingaura" => imgs.skill_sceptre_aura, // Shield "common.abilities.shield.singlestrike" => imgs.onehshield_m1, + "common.abilities.shield.power_guard" => imgs.onehshield_m1, // Dagger "common.abilities.dagger.tempbasic" => imgs.onehdagger_m1, // Pickaxe