Mobility abilities

This commit is contained in:
Sam 2022-03-05 18:18:55 -05:00
parent 500e0ae3d0
commit 5d643f430a
4 changed files with 139 additions and 65 deletions

View File

@ -1,25 +1,12 @@
// TODO: Make actual ability, just for testing right now SelfBuff(
BasicMelee( buildup_duration: 0.15,
energy_cost: 50, cast_duration: 0.4,
buildup_duration: 0.3, recover_duration: 0.25,
swing_duration: 0.1, buff_kind: Hastened,
recover_duration: 0.2, buff_strength: 0.5,
melee_constructor: ( buff_duration: Some(20.0),
kind: Stab( energy_cost: 40,
damage: 10,
poise: 0,
knockback: 0,
energy_regen: 0,
),
range: 5.0,
angle: 10.0,
),
ori_modifier: 1.0,
meta: ( meta: (
kind: Some(Sword(Balanced)), kind: Some(Sword(Mobility)),
capabilities: (
// Block
bits: 0b00000010,
),
), ),
) )

View File

@ -1,25 +1,81 @@
// TODO: Make actual ability, just for testing right now ComboMelee2(
BasicMelee( strikes: [
energy_cost: 50, (
buildup_duration: 0.3, melee_constructor: (
swing_duration: 0.1, kind: Slash(
recover_duration: 0.2, damage: 10,
melee_constructor: ( poise: 0,
kind: Stab( knockback: 0,
damage: 10, energy_regen: 5,
poise: 0, ),
knockback: 0, range: 3.0,
energy_regen: 0, angle: 45.0,
),
buildup_duration: 0.3,
swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.5,
ori_modifier: 0.6,
), ),
range: 5.0, (
angle: 10.0, melee_constructor: (
), kind: Slash(
ori_modifier: 1.0, damage: 14,
poise: 0,
knockback: 0,
energy_regen: 8,
),
range: 3.0,
angle: 45.0,
),
buildup_duration: 0.3,
swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.3,
ori_modifier: 0.6,
),
(
melee_constructor: (
kind: Slash(
damage: 9,
poise: 0,
knockback: 0,
energy_regen: 10,
),
range: 3.0,
angle: 45.0,
),
buildup_duration: 0.2,
swing_duration: 0.05,
hit_timing: 0.5,
recover_duration: 0.1,
ori_modifier: 0.6,
),
(
melee_constructor: (
kind: Slash(
damage: 12,
poise: 0,
knockback: 0,
energy_regen: 10,
),
range: 3.0,
angle: 45.0,
),
buildup_duration: 0.2,
swing_duration: 0.05,
hit_timing: 0.5,
recover_duration: 0.4,
ori_modifier: 0.6,
),
],
is_stance: true,
energy_cost_per_strike: 10,
meta: ( meta: (
kind: Some(Sword(Balanced)), kind: Some(Sword(Mobility)),
capabilities: ( capabilities: (
// Block // Rolling can interrupt attack
bits: 0b00000010, bits: 0b00000001,
), ),
), ),
) )

View File

@ -1,25 +1,31 @@
// TODO: Make actual ability, just for testing right now ComboMelee2(
BasicMelee( strikes: [
energy_cost: 50, (
buildup_duration: 0.3, melee_constructor: (
swing_duration: 0.1, kind: Slash(
recover_duration: 0.2, damage: 15,
melee_constructor: ( poise: 0,
kind: Stab( knockback: 0,
damage: 10, energy_regen: 10,
poise: 0, ),
knockback: 0, range: 6.0,
energy_regen: 0, angle: 5.0,
),
buildup_duration: 0.2,
swing_duration: 0.1,
hit_timing: 0.6,
recover_duration: 0.4,
movement: (
buildup: Some(Sideways(2.0)),
swing: None,
recover: None,
),
ori_modifier: 0.6,
), ),
range: 5.0, ],
angle: 10.0, is_stance: false,
), energy_cost_per_strike: 15,
ori_modifier: 1.0,
meta: ( meta: (
kind: Some(Sword(Balanced)), kind: Some(Sword(Mobility)),
capabilities: (
// Block
bits: 0b00000010,
),
), ),
) )

View File

@ -23,6 +23,7 @@ use core::hash::BuildHasherDefault;
use fxhash::FxHasher64; use fxhash::FxHasher64;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{ use std::{
f32::consts::PI,
ops::{Add, Div}, ops::{Add, Div},
time::Duration, time::Duration,
}; };
@ -428,6 +429,29 @@ pub fn handle_forced_movement(
Vec2::broadcast(data.dt.0) * accel * -Vec2::from(update.ori) * strength; Vec2::broadcast(data.dt.0) * accel * -Vec2::from(update.ori) * strength;
} }
}, },
ForcedMovement::Sideways(strength) => {
let strength = strength * data.stats.move_speed_modifier * data.stats.friction_modifier;
if let Some(accel) = data.physics.on_ground.map(|block| {
// FRIC_GROUND temporarily used to normalize things around expected values
data.body.base_accel() * block.get_traction() * block.get_friction() / FRIC_GROUND
}) {
let direction = {
// Left if positive, else right
let side = Vec2::from(update.ori)
.rotated_z(PI / 2.)
.dot(data.inputs.move_dir)
.signum();
if side > 0.0 {
Vec2::from(update.ori).rotated_z(PI / 2.)
} else {
-Vec2::from(update.ori).rotated_z(PI / 2.)
}
};
update.vel.0 +=
Vec2::broadcast(data.dt.0) * accel * direction * strength;
}
},
ForcedMovement::Leap { ForcedMovement::Leap {
vertical, vertical,
forward, forward,
@ -1216,6 +1240,7 @@ pub enum StageSection {
pub enum ForcedMovement { pub enum ForcedMovement {
Forward(f32), Forward(f32),
Reverse(f32), Reverse(f32),
Sideways(f32),
Leap { Leap {
vertical: f32, vertical: f32,
forward: f32, forward: f32,