Stances now require a small amount of time to enter them

This commit is contained in:
Sam 2022-10-20 13:49:54 -04:00
parent eb67cc2cf7
commit 2e8ad96121
3 changed files with 28 additions and 9 deletions

View File

@ -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)
},

View File

@ -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::<Melee>(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);
}

View File

@ -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,