Dash now ticks damage based off distance rather than duration. Fix for golem no longer being able to melee.

This commit is contained in:
Sam 2021-01-22 18:10:47 -05:00
parent 4b4504a3a3
commit d6be67e0a0
3 changed files with 8 additions and 10 deletions

View File

@ -1162,7 +1162,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
}, },
auto_charge: false, auto_charge: false,
timer: Duration::default(), timer: Duration::default(),
refresh_timer: Duration::default(), refresh_distance: 0.0,
stage_section: StageSection::Buildup, stage_section: StageSection::Buildup,
exhausted: false, exhausted: false,
}), }),

View File

@ -54,8 +54,8 @@ pub struct Data {
pub auto_charge: bool, pub auto_charge: bool,
/// Timer for each stage /// Timer for each stage
pub timer: Duration, pub timer: Duration,
/// Timer used to limit how often another attack will be applied /// Distance used to limit how often another attack will be applied
pub refresh_timer: Duration, pub refresh_distance: f32,
/// What section the character stage is in /// What section the character stage is in
pub stage_section: StageSection, pub stage_section: StageSection,
/// Whether the state should attempt attacking again /// Whether the state should attempt attacking again
@ -149,16 +149,14 @@ impl CharacterBehavior for Data {
exhausted: true, exhausted: true,
..*self ..*self
}) })
} else if self.refresh_timer < Duration::from_millis(50) { } else if self.refresh_distance < self.static_data.range * 0.5 {
update.character = CharacterState::DashMelee(Data { update.character = CharacterState::DashMelee(Data {
timer: self 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_timer: self refresh_distance: self.refresh_distance
.refresh_timer + data.dt.0 * data.vel.0.magnitude(),
.checked_add(Duration::from_secs_f32(data.dt.0))
.unwrap_or_default(),
..*self ..*self
}) })
} else { } else {
@ -167,7 +165,7 @@ impl CharacterBehavior for Data {
.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_timer: Duration::default(), refresh_distance: 0.0,
exhausted: false, exhausted: false,
..*self ..*self
}) })

View File

@ -890,7 +890,7 @@ impl<'a> System<'a> for Sys {
} }
}, },
Tactic::StoneGolemBoss => { Tactic::StoneGolemBoss => {
if dist_sqrd < (MIN_ATTACK_DIST * scale).powi(2) { if dist_sqrd < (MIN_ATTACK_DIST * scale * 2.0).powi(2) { // 2.0 is temporary correction factor to allow them to melee with their large hitbox
inputs.move_dir = Vec2::zero(); inputs.move_dir = Vec2::zero();
inputs.primary.set_state(true); inputs.primary.set_state(true);
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) } else if dist_sqrd < MAX_CHASE_DIST.powi(2)