diff --git a/src/fighter/attack/directional_influence.rs b/src/fighter/attack/directional_influence.rs index 13978e9..cd62c50 100644 --- a/src/fighter/attack/directional_influence.rs +++ b/src/fighter/attack/directional_influence.rs @@ -26,13 +26,17 @@ pub fn apply_directional_influence( let normal = FGVec2::new(-base_launch_direction.y, base_launch_direction.x); let di_amount = receiver_stick.dot(normal); let angle_change = di_amount * di_max_angle.to_fixed::(); + let angle_change = angle_change.clamp( + -di_max_angle.to_fixed::(), + di_max_angle.to_fixed::(), + ); let (sin, cos) = (attack_angle + angle_change.to_fixed::()).sin_cos(); FGVec2::new(cos, sin).normalize_or_zero() } #[cfg(test)] mod test { -use crate::{ + use crate::{ fighter::attack::directional_influence::apply_directional_influence, math::{int::FGi32, vec::FGVec2}, }; @@ -47,10 +51,18 @@ use crate::{ #[test] fn di_applies_on_the_correct_side() { - let di = apply_directional_influence(FGVec2::lit("0.0", "1.0"), FGi32::lit("0.0"), FGi32::lit("18.0")); + let di = apply_directional_influence( + FGVec2::lit("0.0", "1.0"), + FGi32::lit("0.0"), + FGi32::lit("18.0"), + ); assert!(di.x > FGi32::ZERO); assert!(di.y > FGi32::ZERO); - let di = apply_directional_influence(FGVec2::lit("0.0", "-1.0"), FGi32::lit("0.0"), FGi32::lit("18.0")); + let di = apply_directional_influence( + FGVec2::lit("0.0", "-1.0"), + FGi32::lit("0.0"), + FGi32::lit("18.0"), + ); assert!(di.x > FGi32::ZERO); assert!(di.y < FGi32::ZERO); } diff --git a/src/fighter/state/hitstun.rs b/src/fighter/state/hitstun.rs index 558cba8..a10e795 100644 --- a/src/fighter/state/hitstun.rs +++ b/src/fighter/state/hitstun.rs @@ -24,6 +24,16 @@ pub struct HitstunState { knockback_applied: bool } +impl HitstunState { + pub fn new(hit_reaction: FighterHitReaction, hitstop_kind: HitstopStateKind) -> Self { + Self { + hit_reaction, + hitstop_kind, + knockback_applied: false + } + } +} + impl FighterStateImpl for HitstunState { const NAME: &'static str = "Hitstun"; diff --git a/src/fighter/state/mod.rs b/src/fighter/state/mod.rs index 2a8a36a..e2c585a 100644 --- a/src/fighter/state/mod.rs +++ b/src/fighter/state/mod.rs @@ -451,10 +451,10 @@ pub fn state_interrupt_system( } info!("Entering hitstop kind: {:?}", hitstop_kind); - Some(FighterState::Hitstun(HitstunState { - hit_reaction: reaction, + Some(FighterState::Hitstun(HitstunState::new( + reaction, hitstop_kind, - })) + ))) } else if hitstop.remaining_frames > 0 { None } else {