mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Defensive abilities
This commit is contained in:
parent
ec03bd7032
commit
d99eddb483
@ -1,25 +1,12 @@
|
||||
// TODO: Make actual ability, just for testing right now
|
||||
BasicMelee(
|
||||
energy_cost: 50,
|
||||
buildup_duration: 0.3,
|
||||
swing_duration: 0.1,
|
||||
recover_duration: 0.2,
|
||||
melee_constructor: (
|
||||
kind: Stab(
|
||||
damage: 10,
|
||||
poise: 0,
|
||||
knockback: 0,
|
||||
energy_regen: 0,
|
||||
),
|
||||
range: 5.0,
|
||||
angle: 10.0,
|
||||
),
|
||||
ori_modifier: 1.0,
|
||||
SelfBuff(
|
||||
buildup_duration: 0.15,
|
||||
cast_duration: 0.4,
|
||||
recover_duration: 0.25,
|
||||
buff_kind: ProtectingWard,
|
||||
buff_strength: 0.5,
|
||||
buff_duration: Some(30.0),
|
||||
energy_cost: 40,
|
||||
meta: (
|
||||
kind: Some(Sword(Balanced)),
|
||||
capabilities: (
|
||||
// Block
|
||||
bits: 0b00000010,
|
||||
),
|
||||
kind: Some(Sword(Defensive)),
|
||||
),
|
||||
)
|
||||
)
|
@ -1,25 +1,47 @@
|
||||
// TODO: Make actual ability, just for testing right now
|
||||
BasicMelee(
|
||||
energy_cost: 50,
|
||||
buildup_duration: 0.3,
|
||||
swing_duration: 0.1,
|
||||
recover_duration: 0.2,
|
||||
melee_constructor: (
|
||||
kind: Stab(
|
||||
damage: 10,
|
||||
poise: 0,
|
||||
knockback: 0,
|
||||
energy_regen: 0,
|
||||
ComboMelee2(
|
||||
strikes: [
|
||||
(
|
||||
melee_constructor: (
|
||||
kind: Slash(
|
||||
damage: 7,
|
||||
poise: 0,
|
||||
knockback: 0,
|
||||
energy_regen: 5,
|
||||
),
|
||||
range: 3.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,
|
||||
),
|
||||
ori_modifier: 1.0,
|
||||
(
|
||||
melee_constructor: (
|
||||
kind: Slash(
|
||||
damage: 10,
|
||||
poise: 0,
|
||||
knockback: 0,
|
||||
energy_regen: 10,
|
||||
),
|
||||
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,
|
||||
),
|
||||
],
|
||||
is_stance: true,
|
||||
energy_cost_per_strike: 5,
|
||||
meta: (
|
||||
kind: Some(Sword(Balanced)),
|
||||
kind: Some(Sword(Defensive)),
|
||||
capabilities: (
|
||||
// Block
|
||||
// Blocking can interrupt attack
|
||||
bits: 0b00000010,
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
@ -1,25 +1,31 @@
|
||||
// TODO: Make actual ability, just for testing right now
|
||||
BasicMelee(
|
||||
energy_cost: 50,
|
||||
buildup_duration: 0.3,
|
||||
swing_duration: 0.1,
|
||||
recover_duration: 0.2,
|
||||
melee_constructor: (
|
||||
kind: Stab(
|
||||
damage: 10,
|
||||
poise: 0,
|
||||
knockback: 0,
|
||||
energy_regen: 0,
|
||||
ComboMelee2(
|
||||
strikes: [
|
||||
(
|
||||
melee_constructor: (
|
||||
kind: Slash(
|
||||
damage: 10,
|
||||
poise: 0,
|
||||
knockback: 0,
|
||||
energy_regen: 10,
|
||||
),
|
||||
range: 6.0,
|
||||
angle: 5.0,
|
||||
),
|
||||
buildup_duration: 0.2,
|
||||
swing_duration: 0.1,
|
||||
hit_timing: 0.6,
|
||||
recover_duration: 0.4,
|
||||
movement: (
|
||||
buildup: None,
|
||||
swing: None,
|
||||
recover: Some(Reverse(1.5)),
|
||||
),
|
||||
ori_modifier: 0.6,
|
||||
),
|
||||
range: 5.0,
|
||||
angle: 10.0,
|
||||
),
|
||||
ori_modifier: 1.0,
|
||||
],
|
||||
is_stance: false,
|
||||
energy_cost_per_strike: 10,
|
||||
meta: (
|
||||
kind: Some(Sword(Balanced)),
|
||||
capabilities: (
|
||||
// Block
|
||||
bits: 0b00000010,
|
||||
),
|
||||
kind: Some(Sword(Defensive)),
|
||||
),
|
||||
)
|
||||
)
|
@ -15,7 +15,11 @@ ComboMelee2(
|
||||
swing_duration: 0.1,
|
||||
hit_timing: 0.6,
|
||||
recover_duration: 0.4,
|
||||
movement: Some(Forward(2.5)),
|
||||
movement: (
|
||||
buildup: Some(Forward(2.5)),
|
||||
swing: Some(Forward(1.0)),
|
||||
recover: None,
|
||||
),
|
||||
ori_modifier: 0.6,
|
||||
),
|
||||
],
|
||||
|
@ -2477,7 +2477,7 @@ pub enum SwordStance {
|
||||
bitflags::bitflags! {
|
||||
#[derive(Default, Serialize, Deserialize)]
|
||||
pub struct Capability: u8 {
|
||||
const ROLL = 0b00000001;
|
||||
const BLOCK = 0b00000010;
|
||||
const ROLL_INTERRUPT = 0b00000001;
|
||||
const BLOCK_INTERRUPT = 0b00000010;
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Strike<T> {
|
||||
/// Used to construct the Melee attack
|
||||
pub melee_constructor: MeleeConstructor,
|
||||
@ -26,7 +27,8 @@ pub struct Strike<T> {
|
||||
/// Initial recover duration of stage (how long until character exits state)
|
||||
pub recover_duration: T,
|
||||
/// How much forward movement there is in the swing portion of the stage
|
||||
pub movement: Option<ForcedMovement>,
|
||||
#[serde(default)]
|
||||
pub movement: StrikeMovement,
|
||||
/// Adjusts turning rate during the attack
|
||||
pub ori_modifier: f32,
|
||||
}
|
||||
@ -58,6 +60,14 @@ impl Strike<f32> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Default)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct StrikeMovement {
|
||||
pub buildup: Option<ForcedMovement>,
|
||||
pub swing: Option<ForcedMovement>,
|
||||
pub recover: Option<ForcedMovement>,
|
||||
}
|
||||
|
||||
// TODO: Completely rewrite this with skill tree rework. Don't bother converting
|
||||
// to melee constructor.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
@ -117,7 +127,7 @@ impl CharacterBehavior for Data {
|
||||
|
||||
match self.stage_section {
|
||||
Some(StageSection::Buildup) => {
|
||||
if let Some(movement) = strike_data.movement {
|
||||
if let Some(movement) = strike_data.movement.buildup {
|
||||
handle_forced_movement(data, &mut update, movement);
|
||||
}
|
||||
if self.timer < strike_data.buildup_duration {
|
||||
@ -134,7 +144,7 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
},
|
||||
Some(StageSection::Action) => {
|
||||
if let Some(movement) = strike_data.movement {
|
||||
if let Some(movement) = strike_data.movement.swing {
|
||||
handle_forced_movement(data, &mut update, movement);
|
||||
}
|
||||
if input_is_pressed(data, ability_input) {
|
||||
@ -178,6 +188,9 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
},
|
||||
Some(StageSection::Recover) => {
|
||||
if let Some(movement) = strike_data.movement.recover {
|
||||
handle_forced_movement(data, &mut update, movement);
|
||||
}
|
||||
if self.timer < strike_data.recover_duration {
|
||||
// Recovery
|
||||
if let CharacterState::ComboMelee2(c) = &mut update.character {
|
||||
|
@ -420,6 +420,16 @@ pub fn handle_forced_movement(
|
||||
* strength;
|
||||
}
|
||||
},
|
||||
ForcedMovement::Reverse(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
|
||||
}) {
|
||||
update.vel.0 +=
|
||||
Vec2::broadcast(data.dt.0) * accel * -Vec2::from(update.ori) * strength;
|
||||
}
|
||||
},
|
||||
ForcedMovement::Leap {
|
||||
vertical,
|
||||
forward,
|
||||
@ -1063,12 +1073,16 @@ pub fn handle_interrupts(
|
||||
matches!(stage_section, StageSection::Buildup)
|
||||
});
|
||||
let interruptible = data.character.ability_info().map_or(false, |info| {
|
||||
info.ability_meta.capabilities.contains(Capability::ROLL)
|
||||
info.ability_meta
|
||||
.capabilities
|
||||
.contains(Capability::ROLL_INTERRUPT)
|
||||
});
|
||||
in_buildup || interruptible
|
||||
};
|
||||
let can_block = data.character.ability_info().map_or(false, |info| {
|
||||
info.ability_meta.capabilities.contains(Capability::BLOCK)
|
||||
info.ability_meta
|
||||
.capabilities
|
||||
.contains(Capability::BLOCK_INTERRUPT)
|
||||
});
|
||||
if can_dodge {
|
||||
handle_dodge_input(data, update);
|
||||
@ -1203,6 +1217,7 @@ pub enum StageSection {
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub enum ForcedMovement {
|
||||
Forward(f32),
|
||||
Reverse(f32),
|
||||
Leap {
|
||||
vertical: f32,
|
||||
forward: f32,
|
||||
|
Loading…
Reference in New Issue
Block a user