From 1f3bd0e1d29430d3c4dd6f1e514a8c95408fa02e Mon Sep 17 00:00:00 2001 From: jiminycrick Date: Mon, 5 Oct 2020 22:21:22 -0700 Subject: [PATCH] Responded to testing feedback --- common/src/comp/ability.rs | 6 +++++- common/src/comp/inventory/item/tool.rs | 23 ++++++++++++----------- common/src/states/charged_melee.rs | 23 ++++++++++++++++++++--- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 10b4e4a25b..251570e3b2 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -158,6 +158,7 @@ pub enum CharacterAbility { charge_duration: Duration, swing_duration: Duration, recover_duration: Duration, + is_interruptible: bool, }, ChargedRanged { energy_cost: u32, @@ -526,7 +527,7 @@ impl From<&CharacterAbility> for CharacterState { exhausted: false, }), CharacterAbility::ChargedMelee { - energy_cost: _, + energy_cost, energy_drain, initial_damage, max_damage, @@ -537,8 +538,10 @@ impl From<&CharacterAbility> for CharacterState { recover_duration, range, max_angle, + is_interruptible, } => CharacterState::ChargedMelee(charged_melee::Data { static_data: charged_melee::StaticData { + energy_cost: *energy_cost, energy_drain: *energy_drain, initial_damage: *initial_damage, max_damage: *max_damage, @@ -549,6 +552,7 @@ impl From<&CharacterAbility> for CharacterState { charge_duration: *charge_duration, swing_duration: *swing_duration, recover_duration: *recover_duration, + is_interruptible: *is_interruptible, }, stage_section: StageSection::Charge, timer: Duration::default(), diff --git a/common/src/comp/inventory/item/tool.rs b/common/src/comp/inventory/item/tool.rs index 5c49693408..9eb029f563 100644 --- a/common/src/comp/inventory/item/tool.rs +++ b/common/src/comp/inventory/item/tool.rs @@ -228,15 +228,15 @@ impl Tool { }, LeapMelee { energy_cost: 450, - buildup_duration: Duration::from_millis(100), - movement_duration: Duration::from_millis(900), + buildup_duration: Duration::from_millis(200), + movement_duration: Duration::from_millis(200), swing_duration: Duration::from_millis(200), - recover_duration: Duration::from_millis(100), + recover_duration: Duration::from_millis(200), base_damage: (240.0 * self.base_power()) as u32, knockback: 12.0, range: 4.5, max_angle: 30.0, - forward_leap_strength: 20.0, + forward_leap_strength: 28.0, vertical_leap_strength: 8.0, }, ], @@ -251,24 +251,25 @@ impl Tool { max_angle: 20.0, }, ChargedMelee { - energy_cost: 0, + energy_cost: 1, energy_drain: 300, - initial_damage: (20.0 * self.base_power()) as u32, + initial_damage: (10.0 * self.base_power()) as u32, max_damage: (170.0 * self.base_power()) as u32, - initial_knockback: 12.0, + initial_knockback: 10.0, max_knockback: 60.0, range: 3.5, max_angle: 30.0, charge_duration: Duration::from_millis(1200), swing_duration: Duration::from_millis(400), - recover_duration: Duration::from_millis(600), + recover_duration: Duration::from_millis(100), + is_interruptible: false, }, LeapMelee { energy_cost: 700, - buildup_duration: Duration::from_millis(200), - movement_duration: Duration::from_millis(650), + buildup_duration: Duration::from_millis(100), + movement_duration: Duration::from_millis(800), swing_duration: Duration::from_millis(150), - recover_duration: Duration::from_millis(100), + recover_duration: Duration::from_millis(200), base_damage: (240.0 * self.base_power()) as u32, knockback: 25.0, range: 4.5, diff --git a/common/src/states/charged_melee.rs b/common/src/states/charged_melee.rs index c022659254..e92e5e6b44 100644 --- a/common/src/states/charged_melee.rs +++ b/common/src/states/charged_melee.rs @@ -11,6 +11,8 @@ use std::time::Duration; pub struct StaticData { /// How much energy is drained per second when charging pub energy_drain: u32, + /// Energy cost per attack + pub energy_cost: u32, /// How much damage is dealt with no charge pub initial_damage: u32, /// How much damage is dealt with max charge @@ -29,6 +31,8 @@ pub struct StaticData { pub swing_duration: Duration, /// How long the state has until exiting pub recover_duration: Duration, + /// Whether the state can be interrupted by other abilities + pub is_interruptible: bool, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] @@ -50,14 +54,25 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - handle_move(data, &mut update, 0.3); + handle_move(data, &mut update, 0.7); handle_jump(data, &mut update); + // Allows for other states to interrupt this state + if self.static_data.is_interruptible && !data.inputs.ability3.is_pressed() { + handle_interrupt(data, &mut update); + match update.character { + CharacterState::ChargedMelee(_) => {}, + _ => { + return update; + }, + } + } + match self.stage_section { StageSection::Charge => { if data.inputs.secondary.is_pressed() + && update.energy.current() >= self.static_data.energy_cost && self.timer < self.static_data.charge_duration - && update.energy.current() > 0 { let charge = (self.timer.as_secs_f32() / self.static_data.charge_duration.as_secs_f32()) @@ -80,7 +95,9 @@ impl CharacterBehavior for Data { -(self.static_data.energy_drain as f32 * data.dt.0) as i32, EnergySource::Ability, ); - } else if data.inputs.secondary.is_pressed() { + } else if data.inputs.secondary.is_pressed() + && update.energy.current() >= self.static_data.energy_cost + { // Maintains charge update.character = CharacterState::ChargedMelee(Data { static_data: self.static_data,