mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Reaching abilities
This commit is contained in:
parent
5d643f430a
commit
7a8653e8f8
@ -1,25 +1,30 @@
|
|||||||
// TODO: Make actual ability, just for testing right now
|
DashMelee(
|
||||||
BasicMelee(
|
energy_cost: 10,
|
||||||
energy_cost: 50,
|
|
||||||
buildup_duration: 0.3,
|
|
||||||
swing_duration: 0.1,
|
|
||||||
recover_duration: 0.2,
|
|
||||||
melee_constructor: (
|
melee_constructor: (
|
||||||
kind: Stab(
|
kind: Slash(
|
||||||
damage: 10,
|
damage: 4,
|
||||||
|
poise: 0,
|
||||||
|
knockback: 0,
|
||||||
|
energy_regen: 5,
|
||||||
|
),
|
||||||
|
scaled: Some(Slash(
|
||||||
|
damage: 12,
|
||||||
poise: 0,
|
poise: 0,
|
||||||
knockback: 0,
|
knockback: 0,
|
||||||
energy_regen: 0,
|
energy_regen: 0,
|
||||||
),
|
)),
|
||||||
range: 5.0,
|
range: 4,
|
||||||
angle: 10.0,
|
angle: 45.0,
|
||||||
),
|
),
|
||||||
ori_modifier: 1.0,
|
energy_drain: 20,
|
||||||
|
forward_speed: 3,
|
||||||
|
buildup_duration: 0.5,
|
||||||
|
charge_duration: 1.0,
|
||||||
|
swing_duration: 0.1,
|
||||||
|
recover_duration: 1.0,
|
||||||
|
ori_modifier: 0.1,
|
||||||
|
charge_through: false,
|
||||||
meta: (
|
meta: (
|
||||||
kind: Some(Sword(Balanced)),
|
kind: Some(Sword(Reaching)),
|
||||||
capabilities: (
|
|
||||||
// Block
|
|
||||||
bits: 0b00000010,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -1,25 +1,77 @@
|
|||||||
// 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: 15,
|
||||||
meta: (
|
meta: (
|
||||||
kind: Some(Sword(Balanced)),
|
kind: Some(Sword(Reaching)),
|
||||||
capabilities: (
|
|
||||||
// Block
|
|
||||||
bits: 0b00000010,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
@ -1,25 +1,20 @@
|
|||||||
// TODO: Make actual ability, just for testing right now
|
RapidMelee(
|
||||||
BasicMelee(
|
|
||||||
energy_cost: 50,
|
|
||||||
buildup_duration: 0.3,
|
buildup_duration: 0.3,
|
||||||
swing_duration: 0.1,
|
swing_duration: 0.2,
|
||||||
recover_duration: 0.2,
|
recover_duration: 0.5,
|
||||||
melee_constructor: (
|
melee_constructor: (
|
||||||
kind: Stab(
|
kind: Slash(
|
||||||
damage: 10,
|
damage: 6,
|
||||||
poise: 0,
|
poise: 0,
|
||||||
knockback: 0,
|
knockback: 0,
|
||||||
energy_regen: 0,
|
energy_regen: 5,
|
||||||
),
|
),
|
||||||
range: 5.0,
|
range: 3.5,
|
||||||
angle: 10.0,
|
angle: 10.0,
|
||||||
),
|
),
|
||||||
ori_modifier: 1.0,
|
energy_cost: 10,
|
||||||
|
max_strikes: 6,
|
||||||
meta: (
|
meta: (
|
||||||
kind: Some(Sword(Balanced)),
|
kind: Some(Sword(Reaching)),
|
||||||
capabilities: (
|
|
||||||
// Block
|
|
||||||
bits: 0b00000010,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -1,25 +1,27 @@
|
|||||||
// 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: 12,
|
||||||
melee_constructor: (
|
poise: 0,
|
||||||
kind: Stab(
|
knockback: 0,
|
||||||
damage: 10,
|
energy_regen: 5,
|
||||||
poise: 0,
|
),
|
||||||
knockback: 0,
|
range: 8.0,
|
||||||
energy_regen: 0,
|
angle: 10.0,
|
||||||
|
multi_target: true,
|
||||||
|
),
|
||||||
|
buildup_duration: 0.3,
|
||||||
|
swing_duration: 0.1,
|
||||||
|
hit_timing: 0.6,
|
||||||
|
recover_duration: 0.3,
|
||||||
|
ori_modifier: 0.6,
|
||||||
),
|
),
|
||||||
range: 5.0,
|
],
|
||||||
angle: 10.0,
|
is_stance: false,
|
||||||
),
|
energy_cost_per_strike: 20,
|
||||||
ori_modifier: 1.0,
|
|
||||||
meta: (
|
meta: (
|
||||||
kind: Some(Sword(Balanced)),
|
kind: Some(Sword(Reaching)),
|
||||||
capabilities: (
|
|
||||||
// Block
|
|
||||||
bits: 0b00000010,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
@ -408,7 +408,8 @@ impl From<&CharacterState> for CharacterAbilityType {
|
|||||||
| CharacterState::ComboMelee2(_)
|
| CharacterState::ComboMelee2(_)
|
||||||
| CharacterState::FinisherMelee(_)
|
| CharacterState::FinisherMelee(_)
|
||||||
| CharacterState::DiveMelee(_)
|
| CharacterState::DiveMelee(_)
|
||||||
| CharacterState::RiposteMelee(_) => Self::Other,
|
| CharacterState::RiposteMelee(_)
|
||||||
|
| CharacterState::RapidMelee(_) => Self::Other,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -697,6 +698,16 @@ pub enum CharacterAbility {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
meta: AbilityMeta,
|
meta: AbilityMeta,
|
||||||
},
|
},
|
||||||
|
RapidMelee {
|
||||||
|
buildup_duration: f32,
|
||||||
|
swing_duration: f32,
|
||||||
|
recover_duration: f32,
|
||||||
|
energy_cost: f32,
|
||||||
|
max_strikes: u32,
|
||||||
|
melee_constructor: MeleeConstructor,
|
||||||
|
#[serde(default)]
|
||||||
|
meta: AbilityMeta,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for CharacterAbility {
|
impl Default for CharacterAbility {
|
||||||
@ -750,7 +761,8 @@ impl CharacterAbility {
|
|||||||
| CharacterAbility::Shockwave { energy_cost, .. }
|
| CharacterAbility::Shockwave { energy_cost, .. }
|
||||||
| CharacterAbility::BasicBlock { energy_cost, .. }
|
| CharacterAbility::BasicBlock { energy_cost, .. }
|
||||||
| CharacterAbility::SelfBuff { energy_cost, .. }
|
| CharacterAbility::SelfBuff { energy_cost, .. }
|
||||||
| CharacterAbility::RiposteMelee { energy_cost, .. } => {
|
| CharacterAbility::RiposteMelee { energy_cost, .. }
|
||||||
|
| CharacterAbility::RapidMelee { energy_cost, .. } => {
|
||||||
update.energy.try_change_by(-*energy_cost).is_ok()
|
update.energy.try_change_by(-*energy_cost).is_ok()
|
||||||
},
|
},
|
||||||
// Consumes energy within state, so value only checked before entering state
|
// Consumes energy within state, so value only checked before entering state
|
||||||
@ -1271,6 +1283,21 @@ impl CharacterAbility {
|
|||||||
*energy_cost /= stats.energy_efficiency;
|
*energy_cost /= stats.energy_efficiency;
|
||||||
*melee_constructor = melee_constructor.adjusted_by_stats(stats);
|
*melee_constructor = melee_constructor.adjusted_by_stats(stats);
|
||||||
},
|
},
|
||||||
|
RapidMelee {
|
||||||
|
ref mut buildup_duration,
|
||||||
|
ref mut swing_duration,
|
||||||
|
ref mut recover_duration,
|
||||||
|
ref mut energy_cost,
|
||||||
|
ref mut melee_constructor,
|
||||||
|
max_strikes: _,
|
||||||
|
meta: _,
|
||||||
|
} => {
|
||||||
|
*buildup_duration /= stats.speed;
|
||||||
|
*swing_duration /= stats.speed;
|
||||||
|
*recover_duration /= stats.speed;
|
||||||
|
*energy_cost /= stats.energy_efficiency;
|
||||||
|
*melee_constructor = melee_constructor.adjusted_by_stats(stats);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@ -1297,7 +1324,8 @@ impl CharacterAbility {
|
|||||||
..
|
..
|
||||||
}
|
}
|
||||||
| DiveMelee { energy_cost, .. }
|
| DiveMelee { energy_cost, .. }
|
||||||
| RiposteMelee { energy_cost, .. } => *energy_cost,
|
| RiposteMelee { energy_cost, .. }
|
||||||
|
| RapidMelee { energy_cost, .. } => *energy_cost,
|
||||||
BasicBeam { energy_drain, .. } => {
|
BasicBeam { energy_drain, .. } => {
|
||||||
if *energy_drain > f32::EPSILON {
|
if *energy_drain > f32::EPSILON {
|
||||||
1.0
|
1.0
|
||||||
@ -1341,7 +1369,8 @@ impl CharacterAbility {
|
|||||||
| FinisherMelee { meta, .. }
|
| FinisherMelee { meta, .. }
|
||||||
| Music { meta, .. }
|
| Music { meta, .. }
|
||||||
| DiveMelee { meta, .. }
|
| DiveMelee { meta, .. }
|
||||||
| RiposteMelee { meta, .. } => *meta,
|
| RiposteMelee { meta, .. }
|
||||||
|
| RapidMelee { meta, .. } => *meta,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1367,7 +1396,8 @@ impl CharacterAbility {
|
|||||||
| BasicBlock { energy_cost, .. }
|
| BasicBlock { energy_cost, .. }
|
||||||
| SelfBuff { energy_cost, .. }
|
| SelfBuff { energy_cost, .. }
|
||||||
| DiveMelee { energy_cost, .. }
|
| DiveMelee { energy_cost, .. }
|
||||||
| RiposteMelee { energy_cost, .. } => {
|
| RiposteMelee { energy_cost, .. }
|
||||||
|
| RapidMelee { energy_cost, .. } => {
|
||||||
*energy_cost *= ENERGY_REDUCTION;
|
*energy_cost *= ENERGY_REDUCTION;
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
@ -2505,6 +2535,29 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
|
|||||||
stage_section: StageSection::Buildup,
|
stage_section: StageSection::Buildup,
|
||||||
exhausted: false,
|
exhausted: false,
|
||||||
}),
|
}),
|
||||||
|
CharacterAbility::RapidMelee {
|
||||||
|
buildup_duration,
|
||||||
|
swing_duration,
|
||||||
|
recover_duration,
|
||||||
|
melee_constructor,
|
||||||
|
energy_cost,
|
||||||
|
max_strikes,
|
||||||
|
meta: _,
|
||||||
|
} => CharacterState::RapidMelee(rapid_melee::Data {
|
||||||
|
static_data: rapid_melee::StaticData {
|
||||||
|
buildup_duration: Duration::from_secs_f32(*buildup_duration),
|
||||||
|
swing_duration: Duration::from_secs_f32(*swing_duration),
|
||||||
|
recover_duration: Duration::from_secs_f32(*recover_duration),
|
||||||
|
melee_constructor: *melee_constructor,
|
||||||
|
energy_cost: *energy_cost,
|
||||||
|
max_strikes: *max_strikes,
|
||||||
|
ability_info,
|
||||||
|
},
|
||||||
|
timer: Duration::default(),
|
||||||
|
current_strike: 1,
|
||||||
|
stage_section: StageSection::Buildup,
|
||||||
|
exhausted: false,
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,9 @@ pub enum CharacterState {
|
|||||||
DiveMelee(dive_melee::Data),
|
DiveMelee(dive_melee::Data),
|
||||||
/// Attack that attempts to parry, and if it parries moves to an attack
|
/// Attack that attempts to parry, and if it parries moves to an attack
|
||||||
RiposteMelee(riposte_melee::Data),
|
RiposteMelee(riposte_melee::Data),
|
||||||
|
/// A series of consecutive, identical attacks that only go through buildup
|
||||||
|
/// and recover once for the entire state
|
||||||
|
RapidMelee(rapid_melee::Data),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CharacterState {
|
impl CharacterState {
|
||||||
@ -173,6 +176,7 @@ impl CharacterState {
|
|||||||
| CharacterState::FinisherMelee(_)
|
| CharacterState::FinisherMelee(_)
|
||||||
| CharacterState::DiveMelee(_)
|
| CharacterState::DiveMelee(_)
|
||||||
| CharacterState::RiposteMelee(_)
|
| CharacterState::RiposteMelee(_)
|
||||||
|
| CharacterState::RapidMelee(_)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +219,7 @@ impl CharacterState {
|
|||||||
| CharacterState::FinisherMelee(_)
|
| CharacterState::FinisherMelee(_)
|
||||||
| CharacterState::DiveMelee(_)
|
| CharacterState::DiveMelee(_)
|
||||||
| CharacterState::RiposteMelee(_)
|
| CharacterState::RiposteMelee(_)
|
||||||
|
| CharacterState::RapidMelee(_)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,6 +245,7 @@ impl CharacterState {
|
|||||||
| CharacterState::FinisherMelee(_)
|
| CharacterState::FinisherMelee(_)
|
||||||
| CharacterState::DiveMelee(_)
|
| CharacterState::DiveMelee(_)
|
||||||
| CharacterState::RiposteMelee(_)
|
| CharacterState::RiposteMelee(_)
|
||||||
|
| CharacterState::RapidMelee(_)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,6 +352,7 @@ impl CharacterState {
|
|||||||
| CharacterState::SpriteInteract(_)
|
| CharacterState::SpriteInteract(_)
|
||||||
| CharacterState::Music(_)
|
| CharacterState::Music(_)
|
||||||
| CharacterState::RiposteMelee(_)
|
| CharacterState::RiposteMelee(_)
|
||||||
|
| CharacterState::RapidMelee(_)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,6 +419,7 @@ impl CharacterState {
|
|||||||
CharacterState::FinisherMelee(data) => data.behavior(j, output_events),
|
CharacterState::FinisherMelee(data) => data.behavior(j, output_events),
|
||||||
CharacterState::DiveMelee(data) => data.behavior(j, output_events),
|
CharacterState::DiveMelee(data) => data.behavior(j, output_events),
|
||||||
CharacterState::RiposteMelee(data) => data.behavior(j, output_events),
|
CharacterState::RiposteMelee(data) => data.behavior(j, output_events),
|
||||||
|
CharacterState::RapidMelee(data) => data.behavior(j, output_events),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,6 +472,7 @@ impl CharacterState {
|
|||||||
CharacterState::FinisherMelee(data) => data.handle_event(j, output_events, action),
|
CharacterState::FinisherMelee(data) => data.handle_event(j, output_events, action),
|
||||||
CharacterState::DiveMelee(data) => data.handle_event(j, output_events, action),
|
CharacterState::DiveMelee(data) => data.handle_event(j, output_events, action),
|
||||||
CharacterState::RiposteMelee(data) => data.handle_event(j, output_events, action),
|
CharacterState::RiposteMelee(data) => data.handle_event(j, output_events, action),
|
||||||
|
CharacterState::RapidMelee(data) => data.handle_event(j, output_events, action),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,6 +524,7 @@ impl CharacterState {
|
|||||||
CharacterState::Music(data) => Some(data.static_data.ability_info),
|
CharacterState::Music(data) => Some(data.static_data.ability_info),
|
||||||
CharacterState::DiveMelee(data) => Some(data.static_data.ability_info),
|
CharacterState::DiveMelee(data) => Some(data.static_data.ability_info),
|
||||||
CharacterState::RiposteMelee(data) => Some(data.static_data.ability_info),
|
CharacterState::RiposteMelee(data) => Some(data.static_data.ability_info),
|
||||||
|
CharacterState::RapidMelee(data) => Some(data.static_data.ability_info),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,6 +568,7 @@ impl CharacterState {
|
|||||||
CharacterState::Music(data) => Some(data.stage_section),
|
CharacterState::Music(data) => Some(data.stage_section),
|
||||||
CharacterState::DiveMelee(data) => Some(data.stage_section),
|
CharacterState::DiveMelee(data) => Some(data.stage_section),
|
||||||
CharacterState::RiposteMelee(data) => Some(data.stage_section),
|
CharacterState::RiposteMelee(data) => Some(data.stage_section),
|
||||||
|
CharacterState::RapidMelee(data) => Some(data.stage_section),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ pub mod glide_wield;
|
|||||||
pub mod idle;
|
pub mod idle;
|
||||||
pub mod leap_melee;
|
pub mod leap_melee;
|
||||||
pub mod music;
|
pub mod music;
|
||||||
|
pub mod rapid_melee;
|
||||||
pub mod repeater_ranged;
|
pub mod repeater_ranged;
|
||||||
pub mod riposte_melee;
|
pub mod riposte_melee;
|
||||||
pub mod roll;
|
pub mod roll;
|
||||||
|
133
common/src/states/rapid_melee.rs
Normal file
133
common/src/states/rapid_melee.rs
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
use crate::{
|
||||||
|
comp::{character_state::OutputEvents, CharacterState, Melee, MeleeConstructor, StateUpdate},
|
||||||
|
states::{
|
||||||
|
behavior::{CharacterBehavior, JoinData},
|
||||||
|
utils::*,
|
||||||
|
wielding,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
/// Separated out to condense update portions of character state
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
pub struct StaticData {
|
||||||
|
/// How long until the state attacks
|
||||||
|
pub buildup_duration: Duration,
|
||||||
|
/// How long the state is in the swing duration
|
||||||
|
pub swing_duration: Duration,
|
||||||
|
/// How long until state ends
|
||||||
|
pub recover_duration: Duration,
|
||||||
|
/// Used to construct the Melee attack
|
||||||
|
pub melee_constructor: MeleeConstructor,
|
||||||
|
/// Energy cost per attack
|
||||||
|
pub energy_cost: f32,
|
||||||
|
/// Maximum number of consecutive strikes
|
||||||
|
pub max_strikes: u32,
|
||||||
|
/// What key is used to press ability
|
||||||
|
pub ability_info: AbilityInfo,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
pub struct Data {
|
||||||
|
/// Struct containing data that does not change over the course of the
|
||||||
|
/// character state
|
||||||
|
pub static_data: StaticData,
|
||||||
|
/// Timer for each stage
|
||||||
|
pub timer: Duration,
|
||||||
|
/// How many spins it has done
|
||||||
|
pub current_strike: u32,
|
||||||
|
/// What section the character stage is in
|
||||||
|
pub stage_section: StageSection,
|
||||||
|
/// Whether the state can deal damage
|
||||||
|
pub exhausted: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CharacterBehavior for Data {
|
||||||
|
fn behavior(&self, data: &JoinData, _: &mut OutputEvents) -> StateUpdate {
|
||||||
|
let mut update = StateUpdate::from(data);
|
||||||
|
|
||||||
|
handle_orientation(data, &mut update, 1.0, None);
|
||||||
|
handle_move(data, &mut update, 0.7);
|
||||||
|
handle_interrupts(data, &mut update, None);
|
||||||
|
|
||||||
|
match self.stage_section {
|
||||||
|
StageSection::Buildup => {
|
||||||
|
if self.timer < self.static_data.buildup_duration {
|
||||||
|
// Build up
|
||||||
|
if let CharacterState::RapidMelee(c) = &mut update.character {
|
||||||
|
c.timer = tick_attack_or_default(data, self.timer, None);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Transitions to swing section of stage
|
||||||
|
if let CharacterState::RapidMelee(c) = &mut update.character {
|
||||||
|
c.timer = Duration::default();
|
||||||
|
c.stage_section = StageSection::Action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
StageSection::Action => {
|
||||||
|
if !self.exhausted {
|
||||||
|
if let CharacterState::RapidMelee(c) = &mut update.character {
|
||||||
|
c.timer = Duration::default();
|
||||||
|
c.exhausted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
let crit_data = get_crit_data(data, self.static_data.ability_info);
|
||||||
|
let buff_strength = get_buff_strength(data, self.static_data.ability_info);
|
||||||
|
|
||||||
|
data.updater.insert(
|
||||||
|
data.entity,
|
||||||
|
self.static_data
|
||||||
|
.melee_constructor
|
||||||
|
.create_melee(crit_data, buff_strength),
|
||||||
|
);
|
||||||
|
} else if self.timer < self.static_data.swing_duration {
|
||||||
|
// Swings
|
||||||
|
if let CharacterState::RapidMelee(c) = &mut update.character {
|
||||||
|
c.timer = tick_attack_or_default(data, self.timer, None);
|
||||||
|
}
|
||||||
|
} else if self.current_strike < self.static_data.max_strikes
|
||||||
|
&& update
|
||||||
|
.energy
|
||||||
|
.try_change_by(-self.static_data.energy_cost)
|
||||||
|
.is_ok()
|
||||||
|
{
|
||||||
|
if let CharacterState::RapidMelee(c) = &mut update.character {
|
||||||
|
c.timer = Duration::default();
|
||||||
|
c.current_strike += 1;
|
||||||
|
c.exhausted = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Transitions to recover section of stage
|
||||||
|
if let CharacterState::RapidMelee(c) = &mut update.character {
|
||||||
|
c.timer = Duration::default();
|
||||||
|
c.stage_section = StageSection::Recover;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
StageSection::Recover => {
|
||||||
|
if self.timer < self.static_data.recover_duration {
|
||||||
|
// Recover
|
||||||
|
if let CharacterState::RapidMelee(c) = &mut update.character {
|
||||||
|
c.timer = tick_attack_or_default(data, self.timer, None);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Done
|
||||||
|
update.character =
|
||||||
|
CharacterState::Wielding(wielding::Data { is_sneaking: false });
|
||||||
|
// Make sure attack component is removed
|
||||||
|
data.updater.remove::<Melee>(data.entity);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
// If it somehow ends up in an incorrect stage section
|
||||||
|
update.character = CharacterState::Wielding(wielding::Data { is_sneaking: false });
|
||||||
|
// Make sure attack component is removed
|
||||||
|
data.updater.remove::<Melee>(data.entity);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
update
|
||||||
|
}
|
||||||
|
}
|
@ -448,8 +448,7 @@ pub fn handle_forced_movement(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
update.vel.0 +=
|
update.vel.0 += Vec2::broadcast(data.dt.0) * accel * direction * strength;
|
||||||
Vec2::broadcast(data.dt.0) * accel * direction * strength;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ForcedMovement::Leap {
|
ForcedMovement::Leap {
|
||||||
|
@ -199,7 +199,8 @@ impl<'a> System<'a> for Sys {
|
|||||||
| CharacterState::SpriteSummon(_)
|
| CharacterState::SpriteSummon(_)
|
||||||
| CharacterState::FinisherMelee(_)
|
| CharacterState::FinisherMelee(_)
|
||||||
| CharacterState::DiveMelee(_)
|
| CharacterState::DiveMelee(_)
|
||||||
| CharacterState::RiposteMelee(_) => {
|
| CharacterState::RiposteMelee(_)
|
||||||
|
| CharacterState::RapidMelee(_) => {
|
||||||
if energy.regen_rate != 0.0 {
|
if energy.regen_rate != 0.0 {
|
||||||
energy.regen_rate = 0.0
|
energy.regen_rate = 0.0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user