diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 11a47a796d..074b8c2b1f 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -437,6 +437,7 @@ impl From<&CharacterAbility> for CharacterState { timer: Duration::default(), spins_remaining: *num_spins - 1, stage_section: StageSection::Buildup, + exhausted: false, }), CharacterAbility::ChargedRanged { energy_cost: _, diff --git a/common/src/comp/inventory/item/tool.rs b/common/src/comp/inventory/item/tool.rs index 0f2e0c7daf..dc29ff8abb 100644 --- a/common/src/comp/inventory/item/tool.rs +++ b/common/src/comp/inventory/item/tool.rs @@ -185,7 +185,7 @@ impl Tool { }, SpinMelee { buildup_duration: Duration::from_millis(150), - swing_duration: Duration::from_millis(100), + swing_duration: Duration::from_millis(500), recover_duration: Duration::from_millis(150), base_damage: (100.0 * self.base_power()) as u32, knockback: 0.0, @@ -209,7 +209,7 @@ impl Tool { }, SpinMelee { buildup_duration: Duration::from_millis(100), - swing_duration: Duration::from_millis(50), + swing_duration: Duration::from_millis(250), recover_duration: Duration::from_millis(100), base_damage: (60.0 * self.base_power()) as u32, knockback: 0.0, diff --git a/common/src/states/spin_melee.rs b/common/src/states/spin_melee.rs index f0a425bf5e..c8d5e70c84 100644 --- a/common/src/states/spin_melee.rs +++ b/common/src/states/spin_melee.rs @@ -45,6 +45,8 @@ pub struct Data { pub spins_remaining: u32, /// What section the character stage is in pub stage_section: StageSection, + /// Whether the state can deal damage + pub exhausted: bool, } impl CharacterBehavior for Data { @@ -70,6 +72,7 @@ impl CharacterBehavior for Data { .unwrap_or_default(), spins_remaining: self.spins_remaining, stage_section: self.stage_section, + exhausted: self.exhausted }); } else if self.stage_section == StageSection::Buildup { // Transitions to swing section of stage @@ -78,6 +81,15 @@ impl CharacterBehavior for Data { timer: Duration::default(), spins_remaining: self.spins_remaining, stage_section: StageSection::Swing, + exhausted: self.exhausted + }); + } else if !self.exhausted { + update.character = CharacterState::SpinMelee(Data { + static_data: self.static_data, + timer: Duration::default(), + spins_remaining: self.spins_remaining, + stage_section: self.stage_section, + exhausted: true, }); // Hit attempt data.updater.insert(data.entity, Attacking { @@ -100,14 +112,37 @@ impl CharacterBehavior for Data { .unwrap_or_default(), spins_remaining: self.spins_remaining, stage_section: self.stage_section, + exhausted: self.exhausted }); - } else if self.stage_section == StageSection::Swing { + } else if update.energy.current() >= self.static_data.energy_cost + && (self.spins_remaining != 0 + || (self.static_data.is_infinite && data.inputs.secondary.is_pressed())) + { + let new_spins_remaining = if self.static_data.is_infinite { + self.spins_remaining + } else { + self.spins_remaining - 1 + }; + update.character = CharacterState::SpinMelee(Data { + static_data: self.static_data, + timer: Duration::default(), + spins_remaining: new_spins_remaining, + stage_section: self.stage_section, + exhausted: false, + }); + // Consumes energy if there's enough left and RMB is held down + update.energy.change_by( + -(self.static_data.energy_cost as i32), + EnergySource::Ability, + ); + } else if self.stage_section == StageSection::Swing { // Transitions to recover section of stage update.character = CharacterState::SpinMelee(Data { static_data: self.static_data, timer: Duration::default(), spins_remaining: self.spins_remaining, stage_section: StageSection::Recover, + exhausted: self.exhausted }) } else if self.stage_section == StageSection::Recover && self.timer < self.static_data.recover_duration @@ -121,27 +156,8 @@ impl CharacterBehavior for Data { .unwrap_or_default(), spins_remaining: self.spins_remaining, stage_section: self.stage_section, + exhausted: self.exhausted }) - } else if update.energy.current() >= self.static_data.energy_cost - && (self.spins_remaining != 0 - || (self.static_data.is_infinite && data.inputs.secondary.is_pressed())) - { - let new_spins_remaining = if self.static_data.is_infinite { - self.spins_remaining - } else { - self.spins_remaining - 1 - }; - update.character = CharacterState::SpinMelee(Data { - static_data: self.static_data, - timer: Duration::default(), - spins_remaining: new_spins_remaining, - stage_section: StageSection::Buildup, - }); - // Consumes energy if there's enough left and RMB is held down - update.energy.change_by( - -(self.static_data.energy_cost as i32), - EnergySource::Ability, - ); } else { // Done update.character = CharacterState::Wielding;