Add hit_timing to BasicMelee

This commit is contained in:
maxicarlos08 2023-11-23 16:41:50 +01:00 committed by Maxicarlos08
parent 256afc1960
commit c7ee737fef
No known key found for this signature in database
33 changed files with 47 additions and 5 deletions

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.4, buildup_duration: 0.4,
swing_duration: 0.2, swing_duration: 0.2,
hit_timing: 0.8,
recover_duration: 0.4, recover_duration: 0.4,
melee_constructor: ( melee_constructor: (
kind: Stab( kind: Stab(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.4, buildup_duration: 0.4,
swing_duration: 0.25, swing_duration: 0.25,
hit_timing: 0.6,
recover_duration: 0.45, recover_duration: 0.45,
melee_constructor: ( melee_constructor: (
kind: Stab( kind: Stab(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.5, buildup_duration: 0.5,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.5, recover_duration: 0.5,
melee_constructor: ( melee_constructor: (
kind: Slash( kind: Slash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 1.2, buildup_duration: 1.2,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.4,
recover_duration: 1.0, recover_duration: 1.0,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.9, buildup_duration: 0.9,
swing_duration: 0.3, swing_duration: 0.3,
hit_timing: 0.6,
recover_duration: 0.6, recover_duration: 0.6,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 1.6, buildup_duration: 1.6,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.6,
recover_duration: 1.0, recover_duration: 1.0,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.8, buildup_duration: 0.8,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.7, recover_duration: 0.7,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.7, buildup_duration: 0.7,
swing_duration: 0.15, swing_duration: 0.15,
hit_timing: 0.7,
recover_duration: 0.6, recover_duration: 0.6,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.5, buildup_duration: 0.5,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.7, recover_duration: 0.7,
melee_constructor: ( melee_constructor: (
kind: Slash( kind: Slash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.4, buildup_duration: 0.4,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.8, recover_duration: 0.8,
melee_constructor: ( melee_constructor: (
kind: Slash( kind: Slash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.9, buildup_duration: 0.9,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 1.2, recover_duration: 1.2,
melee_constructor: ( melee_constructor: (
kind: Slash( kind: Slash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.4, buildup_duration: 0.4,
swing_duration: 0.05, swing_duration: 0.05,
hit_timing: 0.8,
recover_duration: 0.6, recover_duration: 0.6,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -1,7 +1,8 @@
BasicMelee( BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.25, buildup_duration: 0.5,
swing_duration: 0.3, swing_duration: 0.3,
hit_timing: 0.5,
recover_duration: 1.0, recover_duration: 1.0,
melee_constructor: ( melee_constructor: (
kind: SonicWave( kind: SonicWave(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.45, buildup_duration: 0.45,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.7,
recover_duration: 1.2, recover_duration: 1.2,
melee_constructor: ( melee_constructor: (
kind: Slash( kind: Slash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 1.15, buildup_duration: 1.15,
swing_duration: 0.3, swing_duration: 0.3,
hit_timing: 0.4,
recover_duration: 0.85, recover_duration: 0.85,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.2, buildup_duration: 0.2,
swing_duration: 0.3, swing_duration: 0.3,
hit_timing: 0.5,
recover_duration: 0.1, recover_duration: 0.1,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.45, buildup_duration: 0.45,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.3,
recover_duration: 1.2, recover_duration: 1.2,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.5, buildup_duration: 0.5,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.4,
recover_duration: 0.5, recover_duration: 0.5,
melee_constructor: ( melee_constructor: (
kind: Slash( kind: Slash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.9, buildup_duration: 0.9,
swing_duration: 0.3, swing_duration: 0.3,
hit_timing: 0.6,
recover_duration: 0.6, recover_duration: 0.6,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 1.6, buildup_duration: 1.6,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.6,
recover_duration: 1.0, recover_duration: 1.0,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 1.2, buildup_duration: 1.2,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.8,
recover_duration: 2.0, recover_duration: 2.0,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.1, buildup_duration: 0.1,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.3, recover_duration: 0.3,
melee_constructor: ( melee_constructor: (
kind: Stab( kind: Stab(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.0, buildup_duration: 0.0,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.0,
recover_duration: 0.9, recover_duration: 0.9,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.6, buildup_duration: 0.6,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.15, recover_duration: 0.15,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.3, buildup_duration: 0.3,
swing_duration: 0.05, swing_duration: 0.05,
hit_timing: 0.8,
recover_duration: 0.45, recover_duration: 0.45,
melee_constructor: ( melee_constructor: (
kind: Slash( kind: Slash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.6, buildup_duration: 0.6,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.45, recover_duration: 0.45,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.15, buildup_duration: 0.15,
swing_duration: 0.05, swing_duration: 0.05,
hit_timing: 0.4,
recover_duration: 0.375, recover_duration: 0.375,
melee_constructor: ( melee_constructor: (
kind: Stab( kind: Stab(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.25, buildup_duration: 0.25,
swing_duration: 0.05, swing_duration: 0.05,
hit_timing: 0.5,
recover_duration: 0.075, recover_duration: 0.075,
melee_constructor: ( melee_constructor: (
kind: Stab( kind: Stab(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.1, buildup_duration: 0.1,
swing_duration: 0.1, swing_duration: 0.1,
hit_timing: 0.0,
recover_duration: 0.3, recover_duration: 0.3,
melee_constructor: ( melee_constructor: (
kind: Bash( kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0, energy_cost: 0,
buildup_duration: 0.25, buildup_duration: 0.25,
swing_duration: 0.05, swing_duration: 0.05,
hit_timing: 0.5,
recover_duration: 0.075, recover_duration: 0.075,
melee_constructor: ( melee_constructor: (
kind: Stab( kind: Stab(

View File

@ -687,6 +687,7 @@ pub enum CharacterAbility {
energy_cost: f32, energy_cost: f32,
buildup_duration: f32, buildup_duration: f32,
swing_duration: f32, swing_duration: f32,
hit_timing: f32,
recover_duration: f32, recover_duration: f32,
melee_constructor: MeleeConstructor, melee_constructor: MeleeConstructor,
ori_modifier: f32, ori_modifier: f32,
@ -1026,6 +1027,7 @@ impl Default for CharacterAbility {
energy_cost: 0.0, energy_cost: 0.0,
buildup_duration: 0.25, buildup_duration: 0.25,
swing_duration: 0.25, swing_duration: 0.25,
hit_timing: 0.0,
recover_duration: 0.5, recover_duration: 0.5,
melee_constructor: MeleeConstructor { melee_constructor: MeleeConstructor {
kind: MeleeConstructorKind::Slash { kind: MeleeConstructorKind::Slash {
@ -1185,6 +1187,7 @@ impl CharacterAbility {
ref mut recover_duration, ref mut recover_duration,
ref mut melee_constructor, ref mut melee_constructor,
ori_modifier: _, ori_modifier: _,
hit_timing: _,
meta: _, meta: _,
} => { } => {
*buildup_duration /= stats.speed; *buildup_duration /= stats.speed;
@ -2230,6 +2233,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
CharacterAbility::BasicMelee { CharacterAbility::BasicMelee {
buildup_duration, buildup_duration,
swing_duration, swing_duration,
hit_timing,
recover_duration, recover_duration,
melee_constructor, melee_constructor,
ori_modifier, ori_modifier,
@ -2239,6 +2243,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
static_data: basic_melee::StaticData { static_data: basic_melee::StaticData {
buildup_duration: Duration::from_secs_f32(*buildup_duration), buildup_duration: Duration::from_secs_f32(*buildup_duration),
swing_duration: Duration::from_secs_f32(*swing_duration), swing_duration: Duration::from_secs_f32(*swing_duration),
hit_timing: hit_timing.min(1.0),
recover_duration: Duration::from_secs_f32(*recover_duration), recover_duration: Duration::from_secs_f32(*recover_duration),
melee_constructor: *melee_constructor, melee_constructor: *melee_constructor,
ori_modifier: *ori_modifier, ori_modifier: *ori_modifier,

View File

@ -23,6 +23,8 @@ pub struct StaticData {
pub swing_duration: Duration, pub swing_duration: Duration,
/// How long the state has until exiting /// How long the state has until exiting
pub recover_duration: Duration, pub recover_duration: Duration,
/// At what fraction of swing_duration to make the hit
pub hit_timing: f32,
/// Used to construct the Melee attack /// Used to construct the Melee attack
pub melee_constructor: MeleeConstructor, pub melee_constructor: MeleeConstructor,
/// Adjusts turning rate during the attack /// Adjusts turning rate during the attack
@ -70,9 +72,13 @@ impl CharacterBehavior for Data {
} }
}, },
StageSection::Action => { StageSection::Action => {
if !self.exhausted { if !self.exhausted
&& self.timer.as_secs_f32()
>= self.static_data.swing_duration.as_secs_f32()
* self.static_data.hit_timing
{
update.character = CharacterState::BasicMelee(Data { update.character = CharacterState::BasicMelee(Data {
timer: Duration::default(), timer: tick_attack_or_default(data, self.timer, None),
exhausted: true, exhausted: true,
..*self ..*self
}); });

View File

@ -74,6 +74,7 @@ fn maps_basic_melee() {
static_data: states::basic_melee::StaticData { static_data: states::basic_melee::StaticData {
buildup_duration: Duration::default(), buildup_duration: Duration::default(),
swing_duration: Duration::default(), swing_duration: Duration::default(),
hit_timing: 0.0,
recover_duration: Duration::default(), recover_duration: Duration::default(),
melee_constructor: melee::MeleeConstructor { melee_constructor: melee::MeleeConstructor {
kind: melee::MeleeConstructorKind::Slash { kind: melee::MeleeConstructorKind::Slash {