From 6c2de7d70e85da69642971d925aaeebfee7bd96e Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 26 Mar 2021 16:11:25 -0400 Subject: [PATCH] Fixed boost having ridiculous velocity. --- assets/common/abilities/debug/forwardboost.ron | 2 ++ assets/common/abilities/debug/upboost.ron | 2 ++ common/src/comp/ability.rs | 8 ++++++++ common/src/states/boost.rs | 12 ++++++++++-- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/assets/common/abilities/debug/forwardboost.ron b/assets/common/abilities/debug/forwardboost.ron index 7c7c31703b..dc198e3d62 100644 --- a/assets/common/abilities/debug/forwardboost.ron +++ b/assets/common/abilities/debug/forwardboost.ron @@ -1,4 +1,6 @@ Boost( movement_duration: 0.05, only_up: false, + speed: 400.0, + max_exit_velocity: 100.0, ) \ No newline at end of file diff --git a/assets/common/abilities/debug/upboost.ron b/assets/common/abilities/debug/upboost.ron index f6600130c8..643ee1f97f 100644 --- a/assets/common/abilities/debug/upboost.ron +++ b/assets/common/abilities/debug/upboost.ron @@ -1,4 +1,6 @@ Boost( movement_duration: 0.05, only_up: true, + speed: 250.0, + max_exit_velocity: 70.0, ) \ No newline at end of file diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 4ca98f1591..038da4ac05 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -95,6 +95,8 @@ pub enum CharacterAbility { Boost { movement_duration: f32, only_up: bool, + speed: f32, + max_exit_velocity: f32, }, DashMelee { energy_cost: f32, @@ -371,9 +373,11 @@ impl CharacterAbility { }, Boost { ref mut movement_duration, + speed: ref mut boost_speed, .. } => { *movement_duration /= speed; + *boost_speed *= power; }, DashMelee { ref mut base_damage, @@ -1150,10 +1154,14 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState { CharacterAbility::Boost { movement_duration, only_up, + speed, + max_exit_velocity, } => CharacterState::Boost(boost::Data { static_data: boost::StaticData { movement_duration: Duration::from_secs_f32(*movement_duration), only_up: *only_up, + speed: *speed, + max_exit_velocity: *max_exit_velocity, ability_info, }, timer: Duration::default(), diff --git a/common/src/states/boost.rs b/common/src/states/boost.rs index 415e4c9d6b..24f3cb6257 100644 --- a/common/src/states/boost.rs +++ b/common/src/states/boost.rs @@ -13,6 +13,8 @@ use std::time::Duration; pub struct StaticData { pub movement_duration: Duration, pub only_up: bool, + pub speed: f32, + pub max_exit_velocity: f32, pub ability_info: AbilityInfo, } @@ -34,9 +36,9 @@ impl CharacterBehavior for Data { if self.timer < self.static_data.movement_duration { // Movement if self.static_data.only_up { - update.vel.0.z += 500.0 * data.dt.0; + update.vel.0.z += self.static_data.speed * data.dt.0; } else { - update.vel.0 += *data.inputs.look_dir * 500.0 * data.dt.0; + update.vel.0 += *data.inputs.look_dir * self.static_data.speed * data.dt.0; } update.character = CharacterState::Boost(Data { timer: self @@ -50,6 +52,12 @@ impl CharacterBehavior for Data { if input_is_pressed(data, self.static_data.ability_info.input) { reset_state(self, data, &mut update); } else { + update.vel.0 = update.vel.0.normalized() + * update + .vel + .0 + .magnitude() + .min(self.static_data.max_exit_velocity); update.character = CharacterState::Wielding; } }