From 30168e375f01c38c1c846d794fb550ef2ece2857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20B=C3=B6klin?= Date: Sun, 24 Jan 2021 10:56:35 +0100 Subject: [PATCH] Glider stamina only costs on deploy --- CHANGELOG.md | 3 +-- common/src/states/glide.rs | 13 +------------ common/src/states/glide_wield.rs | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f4aefa2ed..ad5d414118 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,8 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Doubled range of ScaleMode slider when set to Custom -- Glider can now be deployed even when not on the ground -- Gliding now has an energy cost for strenuous maneuvers based on lift +- Glider can now be deployed mid-air at the cost of some stamina based on fall speed - Translations are now folders with multiple files instead of a huge single file - Default inventory slots reduced to 18 - existing characters given 3x 6-slot bags as compensation - Protection rating was moved to the top left of the loadout view diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index 97f0b1bae3..9031197d75 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -1,6 +1,6 @@ use super::utils::handle_climb; use crate::{ - comp::{inventory::slot::EquipSlot, CharacterState, EnergySource, StateUpdate}, + comp::{inventory::slot::EquipSlot, CharacterState, StateUpdate}, states::behavior::{CharacterBehavior, JoinData}, util::Dir, }; @@ -59,17 +59,6 @@ impl CharacterBehavior for Data { * (horiz_speed_sq * f32::powf(0.075, 2.0)).clamp(0.2, 1.0); update.vel.0.z += lift * data.dt.0; - - // Expend energy during strenuous maneuvers. - // Cost increases with lift exceeding that of calmly gliding. - let energy_cost = (0.25 * (lift - GLIDE_ANTIGRAV)).max(0.0) as i32; - if update - .energy - .try_change_by(-energy_cost, EnergySource::Glide) - .is_err() - { - update.character = CharacterState::Idle {}; - } } update diff --git a/common/src/states/glide_wield.rs b/common/src/states/glide_wield.rs index 1535239e28..736ee67a0a 100644 --- a/common/src/states/glide_wield.rs +++ b/common/src/states/glide_wield.rs @@ -1,6 +1,6 @@ use super::utils::*; use crate::{ - comp::{slot::EquipSlot, CharacterState, StateUpdate}, + comp::{slot::EquipSlot, CharacterState, EnergySource, StateUpdate}, states::behavior::{CharacterBehavior, JoinData}, }; @@ -17,7 +17,18 @@ impl CharacterBehavior for Data { // If not on the ground while wielding glider enter gliding state if !data.physics.on_ground { - update.character = CharacterState::Glide; + // Expend energy to slow a fall + let energy_cost = (0.5 * data.vel.0.z.min(0.0).powi(2)) as i32; + if update + .energy + .try_change_by(-energy_cost, EnergySource::Glide) + .is_ok() + { + update.character = CharacterState::Glide; + } else { + update.energy.set_to(0, EnergySource::Glide); + update.character = CharacterState::Idle; + } } if data .physics