Fix charged melee swing

This commit is contained in:
jiminycrick 2020-11-15 21:57:13 -08:00 committed by Sam
parent 6b534729be
commit ee03304a3a

View File

@ -130,7 +130,19 @@ impl CharacterBehavior for Data {
}
},
StageSection::Swing => {
if !self.exhausted {
if self.timer.as_millis() as f32
> 0.5 * self.static_data.swing_duration.as_millis() as f32
&& !self.exhausted
{
// Swing
update.character = CharacterState::ChargedMelee(Data {
timer: self
.timer
.checked_add(Duration::from_secs_f32(data.dt.0))
.unwrap_or_default(),
exhausted: true,
..*self
});
let mut damage = Damage {
source: DamageSource::Melee,
value: self.static_data.max_damage as f32,
@ -152,16 +164,6 @@ impl CharacterBehavior for Data {
hit_count: 0,
knockback: Knockback::Away(knockback),
});
// Starts swinging
update.character = CharacterState::ChargedMelee(Data {
timer: self
.timer
.checked_add(Duration::from_secs_f32(data.dt.0))
.unwrap_or_default(),
exhausted: true,
..*self
});
} else if self.timer < self.static_data.swing_duration {
// Swings
update.character = CharacterState::ChargedMelee(Data {