From d6be67e0a08ce0a69363038eed3a83d0faf3bc6b Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 22 Jan 2021 18:10:47 -0500 Subject: [PATCH] Dash now ticks damage based off distance rather than duration. Fix for golem no longer being able to melee. --- common/src/comp/ability.rs | 2 +- common/src/states/dash_melee.rs | 14 ++++++-------- common/sys/src/agent.rs | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 7fdbaf2c1e..99b411ebd8 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -1162,7 +1162,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState { }, auto_charge: false, timer: Duration::default(), - refresh_timer: Duration::default(), + refresh_distance: 0.0, stage_section: StageSection::Buildup, exhausted: false, }), diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index 57b7437419..597bd33f7b 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -54,8 +54,8 @@ pub struct Data { pub auto_charge: bool, /// Timer for each stage pub timer: Duration, - /// Timer used to limit how often another attack will be applied - pub refresh_timer: Duration, + /// Distance used to limit how often another attack will be applied + pub refresh_distance: f32, /// What section the character stage is in pub stage_section: StageSection, /// Whether the state should attempt attacking again @@ -149,16 +149,14 @@ impl CharacterBehavior for Data { exhausted: true, ..*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 { timer: self .timer .checked_add(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), - refresh_timer: self - .refresh_timer - .checked_add(Duration::from_secs_f32(data.dt.0)) - .unwrap_or_default(), + refresh_distance: self.refresh_distance + + data.dt.0 * data.vel.0.magnitude(), ..*self }) } else { @@ -167,7 +165,7 @@ impl CharacterBehavior for Data { .timer .checked_add(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), - refresh_timer: Duration::default(), + refresh_distance: 0.0, exhausted: false, ..*self }) diff --git a/common/sys/src/agent.rs b/common/sys/src/agent.rs index c695a17dfb..5cf9b0b19c 100644 --- a/common/sys/src/agent.rs +++ b/common/sys/src/agent.rs @@ -890,7 +890,7 @@ impl<'a> System<'a> for Sys { } }, 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.primary.set_state(true); } else if dist_sqrd < MAX_CHASE_DIST.powi(2)