Merge branch 'sam/fix-dash' into 'master'

Fixed dash

See merge request veloren/veloren!1933
This commit is contained in:
Marcel 2021-03-18 03:09:46 +00:00
commit a6cae66a54

View File

@ -174,16 +174,47 @@ impl CharacterBehavior for Data {
exhausted: true, exhausted: true,
..*self ..*self
}) })
} else if self.refresh_distance < self.static_data.range * 0.5 { } else if let Some(melee) = data.melee_attack {
update.character = CharacterState::DashMelee(Data { // Creates timer ahead of time so xmac can look at line count
timer: self let timer = self
.timer .timer
.checked_add(Duration::from_secs_f32(data.dt.0)) .checked_add(Duration::from_secs_f32(data.dt.0))
.unwrap_or_default(), .unwrap_or_default();
refresh_distance: self.refresh_distance // If melee attack has not applied yet, tick both duration and dsitance
+ data.dt.0 * data.vel.0.magnitude(), if !melee.applied {
..*self update.character = CharacterState::DashMelee(Data {
}) timer,
refresh_distance: self.refresh_distance
+ data.dt.0 * data.vel.0.magnitude(),
..*self
})
// If melee attack has applied, but hit nothing, remove
// exhausted so it can attack again
} else if melee.hit_count == 0 {
update.character = CharacterState::DashMelee(Data {
timer,
refresh_distance: 0.0,
exhausted: false,
..*self
})
// Else, melee attack applied and hit something, enter
// cooldown
} else if self.refresh_distance < self.static_data.range {
update.character = CharacterState::DashMelee(Data {
timer,
refresh_distance: self.refresh_distance
+ data.dt.0 * data.vel.0.magnitude(),
..*self
})
// Else cooldown has finished, remove exhausted
} else {
update.character = CharacterState::DashMelee(Data {
timer,
refresh_distance: 0.0,
exhausted: false,
..*self
})
}
} else { } else {
update.character = CharacterState::DashMelee(Data { update.character = CharacterState::DashMelee(Data {
timer: self timer: self