feat: fitness stat effects movement speed

This commit is contained in:
timokoesters 2020-01-21 19:24:09 +01:00
parent 4f90e6325e
commit 28fe73825d
2 changed files with 31 additions and 22 deletions

View File

@ -178,12 +178,12 @@ impl Stats {
};
let (endurance, fitness, willpower) = match race {
Some(Race::Danari) => (0, 1, 2),
Some(Race::Dwarf) => (1, 2, 0),
Some(Race::Elf) => (2, 1, 0),
Some(Race::Human) => (1, 0, 2),
Some(Race::Orc) => (0, 2, 1),
Some(Race::Undead) => (2, 0, 1),
Some(Race::Danari) => (0, 2, 3), // Small, flexible, intelligent, physically weak
Some(Race::Dwarf) => (2, 2, 1), // phyiscally strong, intelligent, slow reflexes
Some(Race::Elf) => (1, 2, 2), // Intelligent, quick, physically weak
Some(Race::Human) => (2, 1, 2), // Perfectly balanced
Some(Race::Orc) => (3, 2, 0), // Physically strong, non intelligent, medium reflexes
Some(Race::Undead) => (1, 3, 1), // Very good reflexes, equally intelligent and strong
None => (0, 0, 0),
};

View File

@ -15,13 +15,13 @@ use vek::*;
pub const ROLL_DURATION: Duration = Duration::from_millis(600);
const HUMANOID_ACCEL: f32 = 100.0;
const HUMANOID_SPEED: f32 = 120.0;
const HUMANOID_AIR_ACCEL: f32 = 15.0;
const HUMANOID_AIR_SPEED: f32 = 100.0;
const HUMANOID_WATER_ACCEL: f32 = 70.0;
const HUMANOID_WATER_SPEED: f32 = 120.0;
const HUMANOID_CLIMB_ACCEL: f32 = 10.0;
const BASE_HUMANOID_ACCEL: f32 = 100.0;
const BASE_HUMANOID_SPEED: f32 = 120.0;
const BASE_HUMANOID_AIR_ACCEL: f32 = 15.0;
const BASE_HUMANOID_AIR_SPEED: f32 = 100.0;
const BASE_HUMANOID_WATER_ACCEL: f32 = 70.0;
const BASE_HUMANOID_WATER_SPEED: f32 = 120.0;
const BASE_HUMANOID_CLIMB_ACCEL: f32 = 10.0;
const ROLL_SPEED: f32 = 17.0;
const CHARGE_SPEED: f32 = 20.0;
const GLIDE_ACCEL: f32 = 15.0;
@ -142,24 +142,33 @@ impl<'a> System<'a> for Sys {
vel.0 += Vec2::broadcast(dt.0)
* inputs.move_dir
* match (physics.on_ground, &character.movement) {
(true, Run) if vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) => {
HUMANOID_ACCEL
(true, Run)
if vel.0.magnitude_squared()
< (BASE_HUMANOID_SPEED + stats.fitness as f32 * 50.0).powf(2.0) =>
{
BASE_HUMANOID_ACCEL
}
(false, Climb) if vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) => {
HUMANOID_CLIMB_ACCEL
(false, Climb)
if vel.0.magnitude_squared() < BASE_HUMANOID_SPEED.powf(2.0) =>
{
BASE_HUMANOID_CLIMB_ACCEL
}
(false, Glide) if vel.0.magnitude_squared() < GLIDE_SPEED.powf(2.0) => {
GLIDE_ACCEL
}
(false, Fall) | (false, Jump)
if vel.0.magnitude_squared() < HUMANOID_AIR_SPEED.powf(2.0) =>
if vel.0.magnitude_squared()
< (BASE_HUMANOID_AIR_SPEED + stats.fitness as f32 * 10.0)
.powf(2.0) =>
{
HUMANOID_AIR_ACCEL
BASE_HUMANOID_AIR_ACCEL
}
(false, Swim)
if vel.0.magnitude_squared() < HUMANOID_WATER_SPEED.powf(2.0) =>
if vel.0.magnitude_squared()
< (BASE_HUMANOID_WATER_SPEED + stats.fitness as f32 * 30.0)
.powf(2.0) =>
{
HUMANOID_WATER_ACCEL
BASE_HUMANOID_WATER_ACCEL + stats.fitness as f32 * 10.0
}
_ => 0.0,
};
@ -228,7 +237,7 @@ impl<'a> System<'a> for Sys {
}
if character.movement == Swim && inputs.jump.is_pressed() {
vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(HUMANOID_WATER_SPEED);
vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(BASE_HUMANOID_WATER_SPEED);
}
}
}