From 2e8ad9612178dda0dfb229c4b47eb6907fd00f56 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 20 Oct 2022 13:49:54 -0400 Subject: [PATCH] Stances now require a small amount of time to enter them --- common/src/comp/ability.rs | 2 +- common/src/states/combo_melee2.rs | 16 ++++++++++++++-- voxygen/src/scene/figure/mod.rs | 19 +++++++++++++------ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index c338db169d..ea18823025 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -2128,7 +2128,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState { // If ability is a stance, enter the stance without beginning a strike, otherwise // immediately begin the strike stage_section: if *is_stance { - None + Some(StageSection::Charge) } else { Some(StageSection::Buildup) }, diff --git a/common/src/states/combo_melee2.rs b/common/src/states/combo_melee2.rs index a4fc847a3b..e1a7218069 100644 --- a/common/src/states/combo_melee2.rs +++ b/common/src/states/combo_melee2.rs @@ -105,7 +105,8 @@ pub struct Data { pub completed_strikes: usize, } -pub const STANCE_TIME: Duration = Duration::from_secs(3); +pub const STANCE_ENTER_TIME: Duration = Duration::from_millis(250); +pub const STANCE_LEAVE_TIME: Duration = Duration::from_secs(3); impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate { @@ -126,6 +127,17 @@ impl CharacterBehavior for Data { let strike_data = self.strike_data(); match self.stage_section { + Some(StageSection::Charge) => { + // Adds a small duration to entering a stance to discourage spam swapping stances for ability activation benefits of matching stance + if self.timer < STANCE_ENTER_TIME { + if let CharacterState::ComboMelee2(c) = &mut update.character { + c.timer = tick_attack_or_default(data, self.timer, None); + } + } else if let CharacterState::ComboMelee2(c) = &mut update.character { + c.timer = Duration::default(); + c.stage_section = None; + } + }, Some(StageSection::Buildup) => { if let Some(movement) = strike_data.movement.buildup { handle_forced_movement(data, &mut update, movement); @@ -221,7 +233,7 @@ impl CharacterBehavior for Data { data.updater.remove::(data.entity); }, None => { - if self.timer < STANCE_TIME { + if self.timer < STANCE_LEAVE_TIME { if let CharacterState::ComboMelee2(c) = &mut update.character { c.timer = tick_attack_or_default(data, self.timer, None); } diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 81dee8c903..f7d1cd5d08 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -1754,19 +1754,26 @@ impl FigureMgr { } }, CharacterState::ComboMelee2(s) => { - if let Some(stage_section) = s.stage_section { + if matches!( + s.stage_section, + Some( + StageSection::Buildup + | StageSection::Action + | StageSection::Recover + ) + ) { let timer = s.timer.as_secs_f32(); let current_strike = s.completed_strikes % s.static_data.strikes.len(); let strike_data = s.static_data.strikes[current_strike]; - let progress = match stage_section { - StageSection::Buildup => { + let progress = match s.stage_section { + Some(StageSection::Buildup) => { timer / strike_data.buildup_duration.as_secs_f32() }, - StageSection::Action => { + Some(StageSection::Action) => { timer / strike_data.swing_duration.as_secs_f32() }, - StageSection::Recover => { + Some(StageSection::Recover) => { timer / strike_data.recover_duration.as_secs_f32() }, _ => 0.0, @@ -1776,7 +1783,7 @@ impl FigureMgr { &target_base, ( ability_id, - Some(stage_section), + s.stage_section, Some(s.static_data.ability_info), current_strike, move_dir,