Glider stamina only costs on deploy

This commit is contained in:
Ludvig Böklin 2021-01-24 10:56:35 +01:00
parent 5eefa86d68
commit 30168e375f
3 changed files with 15 additions and 16 deletions

View File

@ -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

View File

@ -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

View File

@ -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