more setups. chargeswing/dash anims

This commit is contained in:
jshipsey 2021-03-30 00:58:22 -04:00
parent 9a26024acb
commit 529f8eb5a6
15 changed files with 374 additions and 139 deletions

View File

@ -1,5 +1,5 @@
LeapMelee( LeapMelee(
energy_cost: 450, energy_cost: 0,
buildup_duration: 0.2, buildup_duration: 0.2,
movement_duration: 0.2, movement_duration: 0.2,
swing_duration: 0.2, swing_duration: 0.2,

View File

@ -7,7 +7,7 @@ SpinMelee(
knockback: ( strength: 0.0, direction: Away), knockback: ( strength: 0.0, direction: Away),
range: 3.5, range: 3.5,
damage_effect: None, damage_effect: None,
energy_cost: 100, energy_cost: 0,
is_infinite: true, is_infinite: true,
movement_behavior: AxeHover, movement_behavior: AxeHover,
is_interruptible: false, is_interruptible: false,

View File

@ -1,6 +1,6 @@
ChargedMelee( ChargedMelee(
energy_cost: 1, energy_cost: 1,
energy_drain: 300, energy_drain: 0,
initial_damage: 10, initial_damage: 10,
scaled_damage: 160, scaled_damage: 160,
initial_poise_damage: 60, initial_poise_damage: 60,

View File

@ -1,5 +1,5 @@
LeapMelee( LeapMelee(
energy_cost: 700, energy_cost: 0,
buildup_duration: 0.1, buildup_duration: 0.1,
movement_duration: 0.8, movement_duration: 0.8,
swing_duration: 0.15, swing_duration: 0.15,

View File

@ -1,5 +1,5 @@
DashMelee( DashMelee(
energy_cost: 100, energy_cost: 0,
base_damage: 80, base_damage: 80,
scaled_damage: 160, scaled_damage: 160,
base_poise_damage: 60, base_poise_damage: 60,
@ -8,7 +8,7 @@ DashMelee(
scaled_knockback: 7.0, scaled_knockback: 7.0,
range: 5.0, range: 5.0,
angle: 45.0, angle: 45.0,
energy_drain: 600, energy_drain: 0,
forward_speed: 4.0, forward_speed: 4.0,
buildup_duration: 0.25, buildup_duration: 0.25,
charge_duration: 0.6, charge_duration: 0.6,

View File

@ -7,7 +7,7 @@ SpinMelee(
knockback: ( strength: 10.0, direction: Away), knockback: ( strength: 10.0, direction: Away),
range: 3.5, range: 3.5,
damage_effect: None, damage_effect: None,
energy_cost: 150, energy_cost: 0,
is_infinite: false, is_infinite: false,
movement_behavior: ForwardGround, movement_behavior: ForwardGround,
is_interruptible: true, is_interruptible: true,

View File

@ -4,7 +4,7 @@ use super::{
}; };
use common::{ use common::{
comp::item::{Hands, ToolKind}, comp::item::{Hands, ToolKind},
states::utils::StageSection, states::utils::{AbilityInfo, StageSection},
}; };
use std::f32::consts::PI; use std::f32::consts::PI;
@ -18,6 +18,7 @@ impl Animation for AlphaAnimation {
f32, f32,
f32, f32,
Option<StageSection>, Option<StageSection>,
Option<AbilityInfo>,
); );
type Skeleton = CharacterSkeleton; type Skeleton = CharacterSkeleton;
@ -28,7 +29,15 @@ impl Animation for AlphaAnimation {
#[allow(clippy::approx_constant)] // TODO: Pending review in #587 #[allow(clippy::approx_constant)] // TODO: Pending review in #587
fn update_skeleton_inner( fn update_skeleton_inner(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
(active_tool_kind, _second_tool_kind, hands, _velocity, _global_time, stage_section): Self::Dependency, (
active_tool_kind,
_second_tool_kind,
hands,
_velocity,
_global_time,
stage_section,
ability_info,
): Self::Dependency,
anim_time: f32, anim_time: f32,
rate: &mut f32, rate: &mut f32,
s_a: &SkeletonAttr, s_a: &SkeletonAttr,
@ -36,18 +45,20 @@ impl Animation for AlphaAnimation {
*rate = 1.0; *rate = 1.0;
let mut next = (*skeleton).clone(); let mut next = (*skeleton).clone();
let (move1, move2, move3) = match stage_section { let (move1, move2, move3, move2h) = match stage_section {
Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0), Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0, 0.0),
Some(StageSection::Swing) => (1.0, anim_time, 0.0), Some(StageSection::Swing) => (1.0, anim_time.powi(4), 0.0, anim_time.powf(0.25)),
Some(StageSection::Recover) => (1.0, 1.0, anim_time.powi(4)), Some(StageSection::Recover) => (1.0, 1.0, anim_time.powi(4), 1.0), /* hmm maybe don' */
_ => (0.0, 0.0, 0.0), // t complete the
// recovery?
_ => (0.0, 0.0, 0.0, 0.0),
}; };
next.second.position = Vec3::new(0.0, 0.0, 0.0); next.second.position = Vec3::new(0.0, 0.0, 0.0);
next.second.orientation = Quaternion::rotation_z(0.0); next.second.orientation = Quaternion::rotation_z(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * s_a.scaler; next.torso.position = Vec3::new(0.0, 0.0, 0.1) * s_a.scaler;
next.torso.orientation = Quaternion::rotation_z(0.0); next.torso.orientation = Quaternion::rotation_z(0.0);
match active_tool_kind { match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => { Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.main.position = Vec3::new(0.0, 0.0, 0.0); next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0); next.main.orientation = Quaternion::rotation_x(0.0);
@ -60,11 +71,6 @@ impl Animation for AlphaAnimation {
move1 * -0.9 + (move2 * 1.75).sin() * 2.5 + move3 * -0.5, move1 * -0.9 + (move2 * 1.75).sin() * 2.5 + move3 * -0.5,
); );
}, },
Some(ToolKind::Dagger) => {
next.control_l.position = Vec3::new(-10.0, 6.0, 2.0);
next.control_l.orientation =
Quaternion::rotation_x(-1.4) * Quaternion::rotation_z(1.4);
},
Some(ToolKind::Axe) => { Some(ToolKind::Axe) => {
next.main.position = Vec3::new(0.0, 0.0, 0.0); next.main.position = Vec3::new(0.0, 0.0, 0.0);
@ -119,7 +125,7 @@ impl Animation for AlphaAnimation {
} }
match hands { match hands {
(Some(Hands::Two), _) => match active_tool_kind { (Some(Hands::Two), _) => match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => { Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2); next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation = next.hand_l.orientation =
@ -194,7 +200,7 @@ impl Animation for AlphaAnimation {
match hands { match hands {
(Some(Hands::One), Some(Hands::One)) | (Some(Hands::One), None) => { (Some(Hands::One), Some(Hands::One)) | (Some(Hands::One), None) => {
match active_tool_kind { match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => { Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.control_l.position = Vec3::new(-7.0, 8.0, 2.0); next.control_l.position = Vec3::new(-7.0, 8.0, 2.0);
next.control_l.orientation = Quaternion::rotation_x(-0.3 + move2 * 2.0) next.control_l.orientation = Quaternion::rotation_x(-0.3 + move2 * 2.0)
@ -238,7 +244,7 @@ impl Animation for AlphaAnimation {
}; };
match hands { match hands {
(Some(Hands::One), Some(Hands::One)) | (None, Some(Hands::One)) => { (Some(Hands::One), Some(Hands::One)) | (None, Some(Hands::One)) => {
match active_tool_kind { match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => { Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.control_r.position = Vec3::new(7.0 + move2 * 8.0, 8.0, 2.0); next.control_r.position = Vec3::new(7.0 + move2 * 8.0, 8.0, 2.0);
next.control_r.orientation = Quaternion::rotation_x(-0.3 + move2 * 2.0) next.control_r.orientation = Quaternion::rotation_x(-0.3 + move2 * 2.0)
@ -264,11 +270,11 @@ impl Animation for AlphaAnimation {
| Some(ToolKind::Pick) => { | Some(ToolKind::Pick) => {
next.control_r.position = Vec3::new( next.control_r.position = Vec3::new(
7.0, 7.0,
8.0 + move1 * -4.0 + move2 * 4.0, 8.0 + move1 * -4.0 + move2h * 4.0,
2.0 + move1 * 16.0 + move2 * -21.0, 2.0 + move1 * 16.0 + move2h * -21.0,
); );
next.control_r.orientation = next.control_r.orientation =
Quaternion::rotation_x(-0.3 + move1 * 1.3 + move2 * -2.3) Quaternion::rotation_x(-0.3 + move1 * 1.3 + move2h * -2.3)
* Quaternion::rotation_y(0.0) * Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0); * Quaternion::rotation_z(0.0);
next.hand_r.position = Vec3::new(0.0, -0.5, 0.0); next.hand_r.position = Vec3::new(0.0, -0.5, 0.0);

View File

@ -2,7 +2,10 @@ use super::{
super::{vek::*, Animation}, super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr, CharacterSkeleton, SkeletonAttr,
}; };
use common::{comp::item::ToolKind, states::utils::StageSection}; use common::{
comp::item::{Hands, ToolKind},
states::utils::{AbilityInfo, StageSection},
};
pub struct BetaAnimation; pub struct BetaAnimation;
@ -10,9 +13,11 @@ impl Animation for BetaAnimation {
type Dependency = ( type Dependency = (
Option<ToolKind>, Option<ToolKind>,
Option<ToolKind>, Option<ToolKind>,
(Option<Hands>, Option<Hands>),
f32, f32,
f32, f32,
Option<StageSection>, Option<StageSection>,
Option<AbilityInfo>,
); );
type Skeleton = CharacterSkeleton; type Skeleton = CharacterSkeleton;
@ -22,7 +27,15 @@ impl Animation for BetaAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_beta")] #[cfg_attr(feature = "be-dyn-lib", export_name = "character_beta")]
fn update_skeleton_inner( fn update_skeleton_inner(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
(_active_tool_kind, _second_tool_kind, _velocity, _global_time, stage_section): Self::Dependency, (
_active_tool_kind,
_second_tool_kind,
hands,
_velocity,
_global_time,
stage_section,
ability_info,
): Self::Dependency,
anim_time: f32, anim_time: f32,
rate: &mut f32, rate: &mut f32,
s_a: &SkeletonAttr, s_a: &SkeletonAttr,

View File

@ -2,16 +2,21 @@ use super::{
super::{vek::*, Animation}, super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr, CharacterSkeleton, SkeletonAttr,
}; };
use common::{comp::item::ToolKind, states::utils::StageSection}; use common::{
comp::item::{Hands, ToolKind},
states::utils::{AbilityInfo, StageSection},
};
pub struct ChargeswingAnimation; pub struct ChargeswingAnimation;
impl Animation for ChargeswingAnimation { impl Animation for ChargeswingAnimation {
type Dependency = ( type Dependency = (
Option<ToolKind>, Option<ToolKind>,
Option<ToolKind>, Option<ToolKind>,
(Option<Hands>, Option<Hands>),
Vec3<f32>, Vec3<f32>,
f32, f32,
Option<StageSection>, Option<StageSection>,
Option<AbilityInfo>,
); );
type Skeleton = CharacterSkeleton; type Skeleton = CharacterSkeleton;
@ -22,7 +27,15 @@ impl Animation for ChargeswingAnimation {
#[allow(clippy::approx_constant)] // TODO: Pending review in #587 #[allow(clippy::approx_constant)] // TODO: Pending review in #587
fn update_skeleton_inner( fn update_skeleton_inner(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
(active_tool_kind, _second_tool_kind, _velocity, _global_time, stage_section): Self::Dependency, (
active_tool_kind,
_second_tool_kind,
hands,
_velocity,
_global_time,
stage_section,
ability_info,
): Self::Dependency,
anim_time: f32, anim_time: f32,
rate: &mut f32, rate: &mut f32,
s_a: &SkeletonAttr, s_a: &SkeletonAttr,
@ -36,9 +49,9 @@ impl Animation for ChargeswingAnimation {
* ((anim_time * lab * 8.0).sin()); * ((anim_time * lab * 8.0).sin());
// end spin stuff // end spin stuff
let (move1base, move2base, move3, tension, test) = match stage_section { let (move1base, move2base, movement3, tension, test) = match stage_section {
Some(StageSection::Charge) => ( Some(StageSection::Charge) => (
anim_time.min(1.0), (anim_time.powf(0.25)).min(1.0),
0.0, 0.0,
0.0, 0.0,
(anim_time * 18.0 * lab).sin(), (anim_time * 18.0 * lab).sin(),
@ -48,42 +61,128 @@ impl Animation for ChargeswingAnimation {
Some(StageSection::Recover) => (1.0, 1.0, anim_time.powi(4), 0.0, 1.0), Some(StageSection::Recover) => (1.0, 1.0, anim_time.powi(4), 0.0, 1.0),
_ => (0.0, 0.0, 0.0, 0.0, 0.0), _ => (0.0, 0.0, 0.0, 0.0, 0.0),
}; };
let move1 = move1base * (1.0 - move3);
let slowrise = test * (1.0 - move3);
let move2 = move2base * (1.0 - move3); let pullback = (1.0 - movement3);
if let Some(ToolKind::Hammer) = active_tool_kind { let move1 = move1base * pullback;
next.main.position = Vec3::new(0.0, 0.0, 0.0); let move2 = move2base * pullback;
next.main.orientation = Quaternion::rotation_x(0.0); let slowrise = test * pullback;
next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2 + (move2 * -8.0)); next.second.position = Vec3::new(0.0, 0.0, 0.0);
next.hand_l.orientation = next.second.orientation = Quaternion::rotation_z(0.0);
Quaternion::rotation_x(s_a.hhl.3) * Quaternion::rotation_y(s_a.hhl.4);
next.hand_r.position = Vec3::new(s_a.hhr.0, s_a.hhr.1, s_a.hhr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.hhr.3) * Quaternion::rotation_y(s_a.hhr.4);
next.control.position = Vec3::new( if let Some(ToolKind::Hammer) = active_tool_kind {}
s_a.hc.0 + (move1 * -2.0 + move2 * -8.0),
s_a.hc.1 + (move1 * 2.0 + move2 * 6.0), next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
s_a.hc.2 + (move1 * -2.0 + slowrise * 8.0),
); match ability_info.and_then(|a| a.tool) {
next.control.orientation = Quaternion::rotation_x(s_a.hc.3 + (move2 * 0.0)) Some(ToolKind::Hammer) => {
* Quaternion::rotation_y( next.main.position = Vec3::new(0.0, 0.0, 0.0);
s_a.hc.4 + (tension * 0.08 + move1 * 0.7 + move2 * -1.0 + slowrise * 2.0), next.main.orientation = Quaternion::rotation_x(0.0);
)
* Quaternion::rotation_z(s_a.hc.5 + (move1 * 0.2 + move2 * -1.0)); next.chest.orientation =
next.chest.orientation = Quaternion::rotation_z(short * 0.04 + (move1 * 2.0 + move2 * -3.5));
Quaternion::rotation_z(short * 0.04 + (move1 * 2.0 + move2 * -3.5)); next.belt.orientation = Quaternion::rotation_z(short * 0.08 + (move1 * -1.0));
next.belt.orientation = Quaternion::rotation_z(short * 0.08 + (move1 * -1.0)); next.shorts.orientation = Quaternion::rotation_z(short * 0.15 + (move1 * -1.0));
next.shorts.orientation = Quaternion::rotation_z(short * 0.15 + (move1 * -1.0)); next.head.position = Vec3::new(
next.head.position = Vec3::new( 0.0 + (move1 * -1.0 + move2 * 2.0),
0.0 + (move1 * -1.0 + move2 * 2.0), s_a.head.0 + (move1 * 1.0),
s_a.head.0 + (move1 * 1.0), s_a.head.1,
s_a.head.1, );
); next.head.orientation = Quaternion::rotation_z(move1 * -1.5 + move2 * 3.2);
next.head.orientation = Quaternion::rotation_z(move1 * -1.5 + move2 * 3.2); next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1);
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1); },
_ => {},
} }
match hands {
(Some(Hands::Two), _) => match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Hammer) | Some(ToolKind::HammerSimple) => {
next.hand_l.position =
Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2 + (move2 * -8.0));
next.hand_l.orientation =
Quaternion::rotation_x(s_a.hhl.3) * Quaternion::rotation_y(s_a.hhl.4);
next.hand_r.position = Vec3::new(s_a.hhr.0, s_a.hhr.1, s_a.hhr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.hhr.3) * Quaternion::rotation_y(s_a.hhr.4);
next.control.position = Vec3::new(
s_a.hc.0 + (move1 * -2.0 + move2 * -8.0),
s_a.hc.1 + (move1 * 2.0 + move2 * 6.0),
s_a.hc.2 + (move1 * -2.0 + slowrise * 8.0),
);
next.control.orientation = Quaternion::rotation_x(s_a.hc.3 + (move2 * 0.0))
* Quaternion::rotation_y(
s_a.hc.4
+ (tension * 0.08 + move1 * 0.7 + move2 * -1.0 + slowrise * 2.0),
)
* Quaternion::rotation_z(s_a.hc.5 + (move1 * 0.2 + move2 * -1.0));
},
_ => {},
},
(_, _) => {},
};
match hands {
(Some(Hands::One), Some(Hands::One)) | (Some(Hands::One), None) => {
match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Hammer) | Some(ToolKind::HammerSimple) => {
next.control_l.position = Vec3::new(
-7.0 + move1 * 4.0,
8.0 + move1 * 2.0 + move2 * 4.0,
2.0 + move1 * -1.0 + slowrise * 8.0,
);
next.control_l.orientation =
Quaternion::rotation_x(-0.3 + move2 * 1.0 + slowrise * -1.5)
* Quaternion::rotation_y(
tension * 0.07 + move1 * -1.2 + slowrise * 0.5,
)
* Quaternion::rotation_z(move2 * 1.0);
next.hand_l.position = Vec3::new(0.0, -0.5, 0.0);
next.hand_l.orientation = Quaternion::rotation_x(1.57)
},
_ => {},
}
},
(_, _) => {},
};
match hands {
(Some(Hands::One), Some(Hands::One)) | (None, Some(Hands::One)) => {
match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Hammer) | Some(ToolKind::HammerSimple) => {
next.control_r.position = Vec3::new(
7.0 + move1 * 1.0 + move2 * -20.0,
8.0 + move1 * 1.0 + move2 * 4.0,
2.0 + move1 * -3.0 + slowrise * 8.0,
);
next.control_r.orientation = Quaternion::rotation_x(-0.3 + move2 * 1.0)
* Quaternion::rotation_y(
tension * -0.07 + move1 * -2.0 + slowrise * 0.5,
)
* Quaternion::rotation_z(move2 * 1.0);
next.hand_r.position = Vec3::new(0.0, -0.5, 0.0);
next.hand_r.orientation = Quaternion::rotation_x(1.57)
},
_ => {},
}
},
(_, _) => {},
};
match hands {
(None, None) | (None, Some(Hands::One)) => {
next.hand_l.position = Vec3::new(-4.5, 8.0, 5.0);
next.hand_l.orientation = Quaternion::rotation_x(1.9) * Quaternion::rotation_y(-0.5)
},
(_, _) => {},
};
match hands {
(None, None) | (Some(Hands::One), None) => {
next.hand_r.position = Vec3::new(4.5, 8.0, 5.0);
next.hand_r.orientation = Quaternion::rotation_x(1.9) * Quaternion::rotation_y(0.5)
},
(_, _) => {},
};
next next
} }
} }

View File

@ -2,7 +2,10 @@ use super::{
super::{vek::*, Animation}, super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr, CharacterSkeleton, SkeletonAttr,
}; };
use common::{comp::item::ToolKind, states::utils::StageSection}; use common::{
comp::item::{Hands, ToolKind},
states::utils::{AbilityInfo, StageSection},
};
use std::f32::consts::PI; use std::f32::consts::PI;
pub struct DashAnimation; pub struct DashAnimation;
@ -11,8 +14,10 @@ impl Animation for DashAnimation {
type Dependency = ( type Dependency = (
Option<ToolKind>, Option<ToolKind>,
Option<ToolKind>, Option<ToolKind>,
(Option<Hands>, Option<Hands>),
f32, f32,
Option<StageSection>, Option<StageSection>,
Option<AbilityInfo>,
); );
type Skeleton = CharacterSkeleton; type Skeleton = CharacterSkeleton;
@ -23,7 +28,7 @@ impl Animation for DashAnimation {
#[allow(clippy::single_match)] // TODO: Pending review in #587 #[allow(clippy::single_match)] // TODO: Pending review in #587
fn update_skeleton_inner( fn update_skeleton_inner(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
(active_tool_kind, _second_tool_kind, _global_time, stage_section): Self::Dependency, (active_tool_kind, _second_tool_kind, hands, _global_time, stage_section, ability_info): Self::Dependency,
anim_time: f32, anim_time: f32,
rate: &mut f32, rate: &mut f32,
s_a: &SkeletonAttr, s_a: &SkeletonAttr,
@ -31,13 +36,17 @@ impl Animation for DashAnimation {
*rate = 1.0; *rate = 1.0;
let mut next = (*skeleton).clone(); let mut next = (*skeleton).clone();
let (movement1, movement2, movement3, movement4) = match stage_section { let (movement1, movement2, movement3, move4) = match stage_section {
Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0, 0.0), Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0, 0.0),
Some(StageSection::Charge) => (1.0, anim_time, 0.0, 0.0), Some(StageSection::Charge) => (1.0, anim_time, 0.0, 0.0),
Some(StageSection::Swing) => (1.0, 1.0, anim_time.powf(0.01), 0.0), Some(StageSection::Swing) => (1.0, 1.0, anim_time.powf(0.01), 0.0),
Some(StageSection::Recover) => (1.1, 1.0, 1.0, anim_time.powi(4)), Some(StageSection::Recover) => (1.1, 1.0, 1.0, anim_time.powi(4)),
_ => (0.0, 0.0, 0.0, 0.0), _ => (0.0, 0.0, 0.0, 0.0),
}; };
let pullback = (1.0 - move4);
let move1 = movement1 * pullback;
let move2 = movement2 * pullback;
let move3 = movement3 * pullback;
fn slow(x: f32) -> f32 { fn slow(x: f32) -> f32 {
((5.0 / (1.1 + 3.9 * ((x * 12.4).sin()).powi(2))).sqrt()) * ((x * 12.4).sin()) ((5.0 / (1.1 + 3.9 * ((x * 12.4).sin()).powi(2))).sqrt()) * ((x * 12.4).sin())
@ -50,56 +59,31 @@ impl Animation for DashAnimation {
fn shortalt(x: f32) -> f32 { (x * 5.0 + PI / 2.0).sin() } fn shortalt(x: f32) -> f32 { (x * 5.0 + PI / 2.0).sin() }
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.second.position = Vec3::new(0.0, 0.0, 0.0);
match active_tool_kind { next.second.orientation = Quaternion::rotation_z(0.0);
match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Sword) => { Some(ToolKind::Sword) => {
next.main.position = Vec3::new(0.0, 0.0, 0.0); next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0); next.main.orientation = Quaternion::rotation_x(0.0);
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
next.hand_r.position = Vec3::new(s_a.shr.0, s_a.shr.1, s_a.shr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.shr.3) * Quaternion::rotation_y(s_a.shr.4);
next.control.position = Vec3::new(
s_a.sc.0 + (movement1 * -5.0 + movement3 * -2.0) * (1.0 - movement4),
s_a.sc.1 + (movement2.min(1.0) * -2.0) * (1.0 - movement4),
s_a.sc.2 + (movement2.min(1.0) * 2.0) * (1.0 - movement4),
);
next.control.orientation = Quaternion::rotation_x(
s_a.sc.3 + (movement1 * -1.0 + movement3 * -0.5) * (1.0 - movement4),
) * Quaternion::rotation_y(
s_a.sc.4 + (movement1 * 1.5 + movement3 * -2.5) * (1.0 - movement4),
);
next.head.position = next.head.position =
Vec3::new(0.0, 0.0 + s_a.head.0, s_a.head.1 + movement2.min(1.0) * 1.0); Vec3::new(0.0, 0.0 + s_a.head.0, s_a.head.1 + move2.min(1.0) * 1.0);
next.head.orientation = next.head.orientation = Quaternion::rotation_y(move2.min(1.0) * -0.3 + move3 * 0.3)
Quaternion::rotation_y(movement2.min(1.0) * -0.3 + movement3 * 0.3) * Quaternion::rotation_z(move1 * -0.9 + move3 * 1.6);
* (1.0 - movement4)
* Quaternion::rotation_z(movement1 * -0.9 + movement3 * 1.6)
* (1.0 - movement4);
next.chest.position = Vec3::new( next.chest.position = Vec3::new(
0.0, 0.0,
s_a.chest.0, s_a.chest.0,
s_a.chest.1 + (2.0 + shortalt(movement2) * -2.5) * (1.0 - movement4), s_a.chest.1 + (2.0 + shortalt(move2) * -2.5) + move3 * -3.0,
);
next.chest.orientation = Quaternion::rotation_x(
(movement2.min(1.0) * -0.4 + movement3 * 0.4) * (1.0 - movement4),
) * Quaternion::rotation_y(
(movement2.min(1.0) * -0.2 + movement3 * 0.3) * (1.0 - movement4),
) * Quaternion::rotation_z(
(movement1 * 1.1 + movement3 * -2.2) * (1.0 - movement4),
); );
next.chest.orientation =
Quaternion::rotation_x((move2.min(1.0) * -0.4 + move3 * 0.4))
* Quaternion::rotation_y((move2.min(1.0) * -0.2 + move3 * 0.3))
* Quaternion::rotation_z((move1 * 1.1 + move3 * -2.2));
next.shorts.orientation = next.shorts.orientation = Quaternion::rotation_z((short(move2).min(1.0) * 0.25));
Quaternion::rotation_z((short(movement2).min(1.0) * 0.25) * (1.0 - movement4));
next.belt.orientation = next.belt.orientation = Quaternion::rotation_z((short(move2).min(1.0) * 0.1));
Quaternion::rotation_z((short(movement2).min(1.0) * 0.1) * (1.0 - movement4));
}, },
_ => {}, _ => {},
} }
@ -107,6 +91,86 @@ impl Animation for DashAnimation {
next.lantern.orientation = Quaternion::rotation_x(slow(anim_time) * -0.7 + 0.4) next.lantern.orientation = Quaternion::rotation_x(slow(anim_time) * -0.7 + 0.4)
* Quaternion::rotation_y(slow(anim_time) * 0.4); * Quaternion::rotation_y(slow(anim_time) * 0.4);
match hands {
(Some(Hands::Two), _) => match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
next.hand_r.position = Vec3::new(s_a.shr.0, s_a.shr.1, s_a.shr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.shr.3) * Quaternion::rotation_y(s_a.shr.4);
next.control.position = Vec3::new(
s_a.sc.0 + (move1 * -5.0 + move3 * -2.0),
s_a.sc.1 + (move2.min(1.0) * -2.0),
s_a.sc.2 + (move2.min(1.0) * 2.0),
);
next.control.orientation =
Quaternion::rotation_x(s_a.sc.3 + (move1 * -1.0 + move3 * -0.5))
* Quaternion::rotation_y(s_a.sc.4 + (move1 * 1.5 + move3 * -2.5));
},
_ => {},
},
(_, _) => {},
};
match hands {
(Some(Hands::One), Some(Hands::One)) | (Some(Hands::One), None) => {
match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.control_l.position =
Vec3::new(-7.0, 8.0 + move3 * 5.0, 2.0 + move1 * 4.0);
next.control_l.orientation =
Quaternion::rotation_x(-0.3 + move2 * 1.0 + move3 * 1.0)
* Quaternion::rotation_y(move1 * -1.2 + move3 * -1.5)
* Quaternion::rotation_z(move2 * 1.0 + move3 * 1.5);
next.hand_l.position = Vec3::new(0.0, -0.5, 0.0);
next.hand_l.orientation = Quaternion::rotation_x(1.57)
},
_ => {},
}
},
(_, _) => {},
};
match hands {
(Some(Hands::One), Some(Hands::One)) | (None, Some(Hands::One)) => {
match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.control_r.position = Vec3::new(
7.0 + move1 * 5.0 + move3 * -30.0,
8.0 + move3 * -5.0,
2.0 + move1 * 1.0,
);
next.control_r.orientation =
Quaternion::rotation_x(-0.3 + move1 * -3.0 + move3 * -0.5)
* Quaternion::rotation_y(move1 * 1.5 + move2 * 1.0 + move3 * 1.5)
* Quaternion::rotation_z(move3 * 1.5);
next.hand_r.position = Vec3::new(0.0, -0.5, 0.0);
next.hand_r.orientation = Quaternion::rotation_x(1.57)
},
_ => {},
}
},
(_, _) => {},
};
match hands {
(None, None) | (None, Some(Hands::One)) => {
next.hand_l.position = Vec3::new(-4.5, 8.0, 5.0);
next.hand_l.orientation = Quaternion::rotation_x(1.9) * Quaternion::rotation_y(-0.5)
},
(_, _) => {},
};
match hands {
(None, None) | (Some(Hands::One), None) => {
next.hand_r.position = Vec3::new(4.5, 8.0, 5.0);
next.hand_r.orientation = Quaternion::rotation_x(1.9) * Quaternion::rotation_y(0.5)
},
(_, _) => {},
};
next next
} }
} }

View File

@ -2,7 +2,10 @@ use super::{
super::{vek::*, Animation}, super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr, CharacterSkeleton, SkeletonAttr,
}; };
use common::{comp::item::ToolKind, states::utils::StageSection}; use common::{
comp::item::{Hands, ToolKind},
states::utils::{AbilityInfo, StageSection},
};
use std::f32::consts::PI; use std::f32::consts::PI;
pub struct LeapAnimation; pub struct LeapAnimation;
@ -10,9 +13,11 @@ impl Animation for LeapAnimation {
type Dependency = ( type Dependency = (
Option<ToolKind>, Option<ToolKind>,
Option<ToolKind>, Option<ToolKind>,
(Option<Hands>, Option<Hands>),
Vec3<f32>, Vec3<f32>,
f32, f32,
Option<StageSection>, Option<StageSection>,
Option<AbilityInfo>,
); );
type Skeleton = CharacterSkeleton; type Skeleton = CharacterSkeleton;
@ -23,7 +28,15 @@ impl Animation for LeapAnimation {
#[allow(clippy::approx_constant)] // TODO: Pending review in #587 #[allow(clippy::approx_constant)] // TODO: Pending review in #587
fn update_skeleton_inner( fn update_skeleton_inner(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
(active_tool_kind, _second_tool_kind, _velocity, _global_time, stage_section): Self::Dependency, (
active_tool_kind,
_second_tool_kind,
hands,
_velocity,
_global_time,
stage_section,
ability_info,
): Self::Dependency,
anim_time: f32, anim_time: f32,
rate: &mut f32, rate: &mut f32,
s_a: &SkeletonAttr, s_a: &SkeletonAttr,

View File

@ -27,49 +27,48 @@ impl Animation for SitAnimation {
let slow = (anim_time * 1.0).sin(); let slow = (anim_time * 1.0).sin();
let slowa = (anim_time * 1.0 + PI / 2.0).sin(); let slowa = (anim_time * 1.0 + PI / 2.0).sin();
let stop = (anim_time * 3.0).min(PI / 2.0).sin(); let stop = (anim_time * 3.0).min(PI / 2.0).sin();
let pet = (anim_time * 6.0).sin();
let head_look = Vec2::new(
(global_time + anim_time / 18.0).floor().mul(7331.0).sin() * 0.25,
(global_time + anim_time / 18.0).floor().mul(1337.0).sin() * 0.125,
);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + slow * 0.1 + stop * -0.8); next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + slow * 0.1 + stop * -0.8);
next.head.orientation = Quaternion::rotation_z(head_look.x + slow * 0.2 - slow * 0.1) next.head.orientation =
* Quaternion::rotation_x((slowa * -0.1 + slow * 0.1 + head_look.y).abs()); Quaternion::rotation_z(stop * 0.4) * Quaternion::rotation_x(slow * 0.1 + pet * 0.01);
next.chest.position = Vec3::new( next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + slow * 0.1 + stop * -0.8);
0.0, next.chest.orientation =
s_a.chest.0 + stop * -0.4, Quaternion::rotation_z(stop * -0.4 + pet * 0.04) * Quaternion::rotation_x(stop * -0.2);
s_a.chest.1 + slow * 0.1 + stop * -0.8,
);
next.chest.orientation = Quaternion::rotation_x(stop * 0.15);
next.belt.position = Vec3::new(0.0, s_a.belt.0 + stop * 1.2, s_a.belt.1); next.belt.position = Vec3::new(0.0, s_a.belt.0 + stop * 1.2, s_a.belt.1);
next.belt.orientation = Quaternion::rotation_x(stop * 0.3); next.belt.orientation =
Quaternion::rotation_x(stop * 0.2) * Quaternion::rotation_z(pet * -0.02);
next.back.position = Vec3::new(0.0, s_a.back.0, s_a.back.1); next.back.position = Vec3::new(0.0, s_a.back.0, s_a.back.1);
next.shorts.position = Vec3::new(0.0, s_a.shorts.0 + stop * 2.5, s_a.shorts.1 + stop * 0.6); next.shorts.position = Vec3::new(0.0, s_a.shorts.0 + stop * 2.5, s_a.shorts.1 + stop * 0.6);
next.shorts.orientation = Quaternion::rotation_x(stop * 0.6); next.shorts.orientation =
Quaternion::rotation_x(stop * 0.4) * Quaternion::rotation_z(pet * -0.03);
next.hand_l.position = Vec3::new( next.hand_l.position = Vec3::new(
-s_a.hand.0, -s_a.hand.0 + stop * 3.0 + pet * 2.0,
s_a.hand.1 + slowa * 0.15, s_a.hand.1 + stop * 10.0 + pet * -1.0,
s_a.hand.2 + slow * 0.7 + stop * -2.0, s_a.hand.2 + slow * 0.7 + stop * 6.0,
); );
next.hand_l.orientation = Quaternion::rotation_x(slowa * -0.1 + slow * 0.1); next.hand_l.orientation = Quaternion::rotation_x(stop * 2.0)
* Quaternion::rotation_y(stop * -0.2 + pet * -0.2)
* Quaternion::rotation_z(stop * -1.0);
next.hand_r.position = Vec3::new( next.hand_r.position = Vec3::new(
s_a.hand.0, s_a.hand.0 + stop * -1.0,
s_a.hand.1 + slowa * 0.15, s_a.hand.1 + stop * 4.0,
s_a.hand.2 + slow * 0.7 + stop * -2.0, s_a.hand.2 + slow * 0.7 + stop * 0.0,
); );
next.hand_r.orientation = Quaternion::rotation_x(slow * -0.1 + slowa * 0.1); next.hand_r.orientation =
Quaternion::rotation_x(stop * 1.5) * Quaternion::rotation_z(stop * 0.0);
next.foot_l.position = Vec3::new(-s_a.foot.0, 4.0 + s_a.foot.1, 3.0 + s_a.foot.2); next.foot_l.position = Vec3::new(-s_a.foot.0, 4.0 + s_a.foot.1, 1.0 + s_a.foot.2);
next.foot_l.orientation = Quaternion::rotation_x(slow * 0.1 + stop * 1.2 + slow * 0.1); next.foot_l.orientation = Quaternion::rotation_x(0.0);
next.foot_r.position = Vec3::new(s_a.foot.0, 4.0 + s_a.foot.1, 3.0 + s_a.foot.2); next.foot_r.position = Vec3::new(s_a.foot.0, stop * -3.0 + s_a.foot.1, 1.0 + s_a.foot.2);
next.foot_r.orientation = Quaternion::rotation_x(slowa * 0.1 + stop * 1.2 + slowa * 0.1); next.foot_r.orientation = Quaternion::rotation_x(stop * -0.5);
next.shoulder_l.position = Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2); next.shoulder_l.position = Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_l.orientation = Quaternion::rotation_x(0.0); next.shoulder_l.orientation = Quaternion::rotation_x(0.0);
@ -77,7 +76,7 @@ impl Animation for SitAnimation {
next.shoulder_r.position = Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2); next.shoulder_r.position = Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_r.orientation = Quaternion::rotation_x(0.0); next.shoulder_r.orientation = Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, -0.2, stop * -0.16) * s_a.scaler; next.torso.position = Vec3::new(0.0, 0.0, stop * -0.10) * s_a.scaler;
next next
} }

View File

@ -2,7 +2,10 @@ use super::{
super::{vek::*, Animation}, super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr, CharacterSkeleton, SkeletonAttr,
}; };
use common::{comp::item::ToolKind, states::utils::StageSection}; use common::{
comp::item::{Hands, ToolKind},
states::utils::{AbilityInfo, StageSection},
};
use std::f32::consts::PI; use std::f32::consts::PI;
pub struct SpinAnimation; pub struct SpinAnimation;
@ -11,9 +14,11 @@ impl Animation for SpinAnimation {
type Dependency = ( type Dependency = (
Option<ToolKind>, Option<ToolKind>,
Option<ToolKind>, Option<ToolKind>,
(Option<Hands>, Option<Hands>),
Vec3<f32>, Vec3<f32>,
f32, f32,
Option<StageSection>, Option<StageSection>,
Option<AbilityInfo>,
); );
type Skeleton = CharacterSkeleton; type Skeleton = CharacterSkeleton;
@ -23,7 +28,15 @@ impl Animation for SpinAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_spin")] #[cfg_attr(feature = "be-dyn-lib", export_name = "character_spin")]
fn update_skeleton_inner( fn update_skeleton_inner(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
(active_tool_kind, _second_tool_kind, _velocity, _global_time, stage_section): Self::Dependency, (
active_tool_kind,
_second_tool_kind,
hands,
_velocity,
_global_time,
stage_section,
ability_info,
): Self::Dependency,
anim_time: f32, anim_time: f32,
rate: &mut f32, rate: &mut f32,
s_a: &SkeletonAttr, s_a: &SkeletonAttr,

View File

@ -2,7 +2,10 @@ use super::{
super::{vek::*, Animation}, super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr, CharacterSkeleton, SkeletonAttr,
}; };
use common::{comp::item::ToolKind, states::utils::StageSection}; use common::{
comp::item::{Hands, ToolKind},
states::utils::{AbilityInfo, StageSection},
};
use std::f32::consts::PI; use std::f32::consts::PI;
pub struct SpinMeleeAnimation; pub struct SpinMeleeAnimation;
@ -11,9 +14,11 @@ impl Animation for SpinMeleeAnimation {
type Dependency = ( type Dependency = (
Option<ToolKind>, Option<ToolKind>,
Option<ToolKind>, Option<ToolKind>,
(Option<Hands>, Option<Hands>),
Vec3<f32>, Vec3<f32>,
f32, f32,
Option<StageSection>, Option<StageSection>,
Option<AbilityInfo>,
); );
type Skeleton = CharacterSkeleton; type Skeleton = CharacterSkeleton;
@ -24,7 +29,15 @@ impl Animation for SpinMeleeAnimation {
#[allow(clippy::approx_constant)] // TODO: Pending review in #587 #[allow(clippy::approx_constant)] // TODO: Pending review in #587
fn update_skeleton_inner( fn update_skeleton_inner(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
(active_tool_kind, _second_tool_kind, _velocity, _global_time, stage_section): Self::Dependency, (
active_tool_kind,
_second_tool_kind,
hands,
_velocity,
_global_time,
stage_section,
ability_info,
): Self::Dependency,
anim_time: f32, anim_time: f32,
rate: &mut f32, rate: &mut f32,
s_a: &SkeletonAttr, s_a: &SkeletonAttr,

View File

@ -903,6 +903,7 @@ impl FigureMgr {
rel_vel.magnitude(), rel_vel.magnitude(),
time, time,
Some(s.stage_section), Some(s.stage_section),
Some(s.static_data.ability_info),
), ),
stage_progress, stage_progress,
&mut state_animation_rate, &mut state_animation_rate,
@ -994,9 +995,11 @@ impl FigureMgr {
( (
active_tool_kind, active_tool_kind,
second_tool_kind, second_tool_kind,
hands,
rel_vel, rel_vel,
time, time,
Some(s.stage_section), Some(s.stage_section),
Some(s.static_data.ability_info),
), ),
stage_progress, stage_progress,
&mut state_animation_rate, &mut state_animation_rate,
@ -1062,6 +1065,7 @@ impl FigureMgr {
rel_vel.magnitude(), rel_vel.magnitude(),
time, time,
None, None,
None,
), ),
state.state_time, state.state_time,
&mut state_animation_rate, &mut state_animation_rate,
@ -1090,8 +1094,10 @@ impl FigureMgr {
( (
active_tool_kind, active_tool_kind,
second_tool_kind, second_tool_kind,
hands,
time, time,
Some(s.stage_section), Some(s.stage_section),
Some(s.static_data.ability_info),
), ),
stage_progress, stage_progress,
&mut state_animation_rate, &mut state_animation_rate,
@ -1185,9 +1191,11 @@ impl FigureMgr {
( (
active_tool_kind, active_tool_kind,
second_tool_kind, second_tool_kind,
hands,
rel_vel, rel_vel,
time, time,
Some(s.stage_section), Some(s.stage_section),
Some(s.static_data.ability_info),
), ),
stage_progress, stage_progress,
&mut state_animation_rate, &mut state_animation_rate,
@ -1221,9 +1229,11 @@ impl FigureMgr {
( (
active_tool_kind, active_tool_kind,
second_tool_kind, second_tool_kind,
hands,
rel_vel, rel_vel,
time, time,
Some(s.stage_section), Some(s.stage_section),
Some(s.static_data.ability_info),
), ),
stage_progress, stage_progress,
&mut state_animation_rate, &mut state_animation_rate,
@ -1367,6 +1377,7 @@ impl FigureMgr {
rel_vel.magnitude(), rel_vel.magnitude(),
time, time,
Some(s.stage_section), Some(s.stage_section),
Some(s.static_data.ability_info),
), ),
stage_progress, stage_progress,
&mut state_animation_rate, &mut state_animation_rate,
@ -1377,9 +1388,11 @@ impl FigureMgr {
( (
active_tool_kind, active_tool_kind,
second_tool_kind, second_tool_kind,
hands,
rel_vel, rel_vel,
time, time,
Some(s.stage_section), Some(s.stage_section),
Some(s.static_data.ability_info),
), ),
stage_progress, stage_progress,
&mut state_animation_rate, &mut state_animation_rate,
@ -1390,9 +1403,11 @@ impl FigureMgr {
( (
active_tool_kind, active_tool_kind,
second_tool_kind, second_tool_kind,
hands,
rel_vel.magnitude(), rel_vel.magnitude(),
time, time,
Some(s.stage_section), Some(s.stage_section),
Some(s.static_data.ability_info),
), ),
stage_progress, stage_progress,
&mut state_animation_rate, &mut state_animation_rate,