From 165603aa65c50be113ce8041378ea361773cf166 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 13 Apr 2021 01:46:42 -0400 Subject: [PATCH] Parrying --- assets/common/abilities/shield/block.ron | 1 + common/src/combat.rs | 10 +++++++--- common/src/comp/ability.rs | 15 ++++++++------- common/src/states/basic_block.rs | 8 ++++++-- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/assets/common/abilities/shield/block.ron b/assets/common/abilities/shield/block.ron index ca387d1ae6..f586128082 100644 --- a/assets/common/abilities/shield/block.ron +++ b/assets/common/abilities/shield/block.ron @@ -3,4 +3,5 @@ BasicBlock( recover_duration: 0.1, max_angle: 90.0, block_strength: 0.8, + energy_cost: 0.0, ) \ No newline at end of file diff --git a/common/src/combat.rs b/common/src/combat.rs index 0cbd466021..52ed671846 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -12,8 +12,8 @@ use crate::{ }, poise::PoiseChange, skills::SkillGroupKind, - Body, CharacterState, Combo, Energy, EnergyChange, EnergySource, Health, HealthChange, HealthSource, - Inventory, Ori, SkillSet, Stats, + Body, CharacterState, Combo, Energy, EnergyChange, EnergySource, Health, HealthChange, + HealthSource, Inventory, Ori, SkillSet, Stats, }, event::ServerEvent, outcome::Outcome, @@ -125,7 +125,11 @@ impl Attack { { if ori.look_vec().angle_between(-*dir) < data.static_data.max_angle.to_radians() { - data.static_data.block_strength + if data.parry { + 1.0 + } else { + data.static_data.block_strength + } } else { 0.0 } diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 143e66d891..804e4d7563 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -119,6 +119,7 @@ pub enum CharacterAbility { recover_duration: f32, max_angle: f32, block_strength: f32, + energy_cost: f32, }, Roll { energy_cost: f32, @@ -310,7 +311,8 @@ impl CharacterAbility { | CharacterAbility::ChargedRanged { energy_cost, .. } | CharacterAbility::ChargedMelee { energy_cost, .. } | CharacterAbility::Shockwave { energy_cost, .. } - | CharacterAbility::BasicAura { energy_cost, .. } => update + | CharacterAbility::BasicAura { energy_cost, .. } + | CharacterAbility::BasicBlock { energy_cost, .. } => update .energy .try_change_by(-(*energy_cost as i32), EnergySource::Ability) .is_ok(), @@ -352,6 +354,7 @@ impl CharacterAbility { recover_duration: 0.1, max_angle: 60.0, block_strength: 0.5, + energy_cost: 50.0, } } @@ -600,7 +603,8 @@ impl CharacterAbility { | ChargedRanged { energy_cost, .. } | Shockwave { energy_cost, .. } | HealingBeam { energy_cost, .. } - | BasicAura { energy_cost, .. } => *energy_cost as u32, + | BasicAura { energy_cost, .. } + | BasicBlock { energy_cost, .. } => *energy_cost as u32, BasicBeam { energy_drain, .. } => { if *energy_drain > f32::EPSILON { 1 @@ -608,11 +612,7 @@ impl CharacterAbility { 0 } }, - BasicBlock { .. } - | Boost { .. } - | ComboMelee { .. } - | Blink { .. } - | BasicSummon { .. } => 0, + Boost { .. } | ComboMelee { .. } | Blink { .. } | BasicSummon { .. } => 0, } } @@ -1266,6 +1266,7 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState { recover_duration, max_angle, block_strength, + energy_cost: _, } => CharacterState::BasicBlock(basic_block::Data { static_data: basic_block::StaticData { buildup_duration: Duration::from_secs_f32(*buildup_duration), diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index bdd5dae164..4ecb58802b 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -49,14 +49,18 @@ impl CharacterBehavior for Data { .timer .checked_add(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), - parry: !input_is_pressed(data, InputKind::Block), + parry: self.parry || !input_is_pressed(data, InputKind::Block), ..*self }); } else { // Transitions to swing section of stage update.character = CharacterState::BasicBlock(Data { timer: Duration::default(), - stage_section: StageSection::Swing, + stage_section: if self.parry { + StageSection::Recover + } else { + StageSection::Swing + }, ..*self }); }