From 8bcafa6f190e9d74cc003543c92e67eae4d92398 Mon Sep 17 00:00:00 2001 From: scott-c Date: Sat, 13 Jun 2020 00:07:38 +0800 Subject: [PATCH 1/4] automatically wield on secondary or ability3 --- common/src/states/dance.rs | 2 +- common/src/states/idle.rs | 2 +- common/src/states/sit.rs | 2 +- common/src/states/utils.rs | 11 +++++++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/common/src/states/dance.rs b/common/src/states/dance.rs index 2cefa225fe..67070edf9c 100644 --- a/common/src/states/dance.rs +++ b/common/src/states/dance.rs @@ -11,7 +11,7 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - handle_primary_wield(data, &mut update); + handle_wield(data, &mut update); // Try to Fall/Stand up/Move if !data.physics.on_ground || data.inputs.move_dir.magnitude_squared() > 0.0 { diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index f55707df3a..4e7797bb51 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -12,7 +12,7 @@ impl CharacterBehavior for Data { handle_move(data, &mut update, 1.0); handle_jump(data, &mut update); - handle_primary_wield(data, &mut update); + handle_wield(data, &mut update); handle_climb(data, &mut update); handle_glide(data, &mut update); handle_dodge_input(data, &mut update); diff --git a/common/src/states/sit.rs b/common/src/states/sit.rs index 54f5658d19..8d372c6ccf 100644 --- a/common/src/states/sit.rs +++ b/common/src/states/sit.rs @@ -11,7 +11,7 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - handle_primary_wield(data, &mut update); + handle_wield(data, &mut update); // Try to Fall/Stand up/Move if !data.physics.on_ground || data.inputs.move_dir.magnitude_squared() > 0.0 { diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 740c59c0ad..952d648468 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -96,10 +96,13 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { } } -/// First checks whether `primary` input is pressed, then -/// attempts to go into Equipping state, otherwise Idle -pub fn handle_primary_wield(data: &JoinData, update: &mut StateUpdate) { - if data.inputs.primary.is_pressed() { +/// First checks whether `primary`, `secondary` or `ability3` input is pressed, +/// then attempts to go into Equipping state, otherwise Idle +pub fn handle_wield(data: &JoinData, update: &mut StateUpdate) { + if data.inputs.primary.is_pressed() + || data.inputs.secondary.is_pressed() + || data.inputs.ability3.is_pressed() + { attempt_wield(data, update); } } From f2f79a1b3c1c86c33646fd0ed46707d800f277c3 Mon Sep 17 00:00:00 2001 From: scott-c Date: Sat, 13 Jun 2020 11:45:03 +0800 Subject: [PATCH 2/4] reset energy regen on ability use instead of wield --- common/src/sys/stats.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/common/src/sys/stats.rs b/common/src/sys/stats.rs index 266bda8158..58fbfa4696 100644 --- a/common/src/sys/stats.rs +++ b/common/src/sys/stats.rs @@ -77,7 +77,13 @@ impl<'a> System<'a> for Sys { // Accelerate recharging energy if not wielding. match character_state { - CharacterState::Idle { .. } | CharacterState::Sit { .. } => { + CharacterState::Idle { .. } + | CharacterState::Sit { .. } + | CharacterState::Dance { .. } + | CharacterState::Glide { .. } + | CharacterState::Wielding { .. } + | CharacterState::Equipping { .. } + | CharacterState::Boost { .. } => { let res = { let energy = energy.get_unchecked(); energy.current() < energy.maximum() @@ -95,13 +101,18 @@ impl<'a> System<'a> for Sys { (energy.regen_rate + ENERGY_REGEN_ACCEL * dt.0).min(100.0); } }, - // Wield does not regen and sets the rate back to zero. - CharacterState::Wielding { .. } => { + // Ability use does not regen and sets the rate back to zero. + CharacterState::Roll { .. } + | CharacterState::BasicBlock { .. } + | CharacterState::Climb { .. } + | CharacterState::BasicMelee { .. } + | CharacterState::DashMelee { .. } + | CharacterState::TripleStrike { .. } + | CharacterState::BasicRanged { .. } => { if energy.get_unchecked().regen_rate != 0.0 { energy.get_mut_unchecked().regen_rate = 0.0 } }, - _ => {}, } } } From 0b9cae84de91b16697a3435ab728cf05235b7d39 Mon Sep 17 00:00:00 2001 From: scott-c Date: Sat, 13 Jun 2020 12:00:41 +0800 Subject: [PATCH 3/4] Add changes to change log --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b624a58167..e3e97a72e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed a crash caused by certain audio devices on OSX - Bow animations now show held arrows - Fixed a bug where walk/run sfx played while a character rolled/dodged +- Energy regen resets on last ability use instead of on wield +- Fixed unable to use ability; Secondary and ability3 (fire rod) will now automatically wield ### Removed From b2cbf3ee8f6b2abda8ab72a1bac151fc1678126b Mon Sep 17 00:00:00 2001 From: scott-c Date: Sat, 13 Jun 2020 19:35:31 +0800 Subject: [PATCH 4/4] Adjust character state's energy regen --- common/src/sys/stats.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/common/src/sys/stats.rs b/common/src/sys/stats.rs index 58fbfa4696..e594ef2667 100644 --- a/common/src/sys/stats.rs +++ b/common/src/sys/stats.rs @@ -75,8 +75,8 @@ impl<'a> System<'a> for Sys { .set_to(stat.health.maximum(), HealthSource::LevelUp); } - // Accelerate recharging energy if not wielding. match character_state { + // Accelerate recharging energy. CharacterState::Idle { .. } | CharacterState::Sit { .. } | CharacterState::Dance { .. } @@ -102,17 +102,18 @@ impl<'a> System<'a> for Sys { } }, // Ability use does not regen and sets the rate back to zero. - CharacterState::Roll { .. } - | CharacterState::BasicBlock { .. } - | CharacterState::Climb { .. } - | CharacterState::BasicMelee { .. } + CharacterState::BasicMelee { .. } | CharacterState::DashMelee { .. } | CharacterState::TripleStrike { .. } - | CharacterState::BasicRanged { .. } => { + | CharacterState::BasicRanged { .. } + | CharacterState::BasicBlock { .. } => { if energy.get_unchecked().regen_rate != 0.0 { energy.get_mut_unchecked().regen_rate = 0.0 } }, + // Non-combat abilities that consume energy; + // temporarily stall energy gain, but preserve regen_rate. + CharacterState::Roll { .. } | CharacterState::Climb { .. } => {}, } } }