diff --git a/assets/common/abilities/axe/leap.ron b/assets/common/abilities/axe/leap.ron index c59b733465..50cf49564b 100644 --- a/assets/common/abilities/axe/leap.ron +++ b/assets/common/abilities/axe/leap.ron @@ -1,5 +1,5 @@ LeapMelee( - energy_cost: 450, + energy_cost: 0, buildup_duration: 0.2, movement_duration: 0.2, swing_duration: 0.2, diff --git a/assets/common/abilities/axe/spin.ron b/assets/common/abilities/axe/spin.ron index 39045a1cbc..ef6f426a89 100644 --- a/assets/common/abilities/axe/spin.ron +++ b/assets/common/abilities/axe/spin.ron @@ -7,7 +7,7 @@ SpinMelee( knockback: ( strength: 0.0, direction: Away), range: 3.5, damage_effect: None, - energy_cost: 100, + energy_cost: 0, is_infinite: true, movement_behavior: AxeHover, is_interruptible: false, diff --git a/assets/common/abilities/hammer/charged.ron b/assets/common/abilities/hammer/charged.ron index 978143195e..a854d6aa4f 100644 --- a/assets/common/abilities/hammer/charged.ron +++ b/assets/common/abilities/hammer/charged.ron @@ -1,6 +1,6 @@ ChargedMelee( energy_cost: 1, - energy_drain: 300, + energy_drain: 0, initial_damage: 10, scaled_damage: 160, initial_poise_damage: 60, diff --git a/assets/common/abilities/hammer/leap.ron b/assets/common/abilities/hammer/leap.ron index 47f90adb77..41a02ac25c 100644 --- a/assets/common/abilities/hammer/leap.ron +++ b/assets/common/abilities/hammer/leap.ron @@ -1,5 +1,5 @@ LeapMelee( - energy_cost: 700, + energy_cost: 0, buildup_duration: 0.1, movement_duration: 0.8, swing_duration: 0.15, diff --git a/assets/common/abilities/sword/dash.ron b/assets/common/abilities/sword/dash.ron index 72ba6f4451..810160a61d 100644 --- a/assets/common/abilities/sword/dash.ron +++ b/assets/common/abilities/sword/dash.ron @@ -1,5 +1,5 @@ DashMelee( - energy_cost: 100, + energy_cost: 0, base_damage: 80, scaled_damage: 160, base_poise_damage: 60, @@ -8,7 +8,7 @@ DashMelee( scaled_knockback: 7.0, range: 5.0, angle: 45.0, - energy_drain: 600, + energy_drain: 0, forward_speed: 4.0, buildup_duration: 0.25, charge_duration: 0.6, diff --git a/assets/common/abilities/sword/spin.ron b/assets/common/abilities/sword/spin.ron index a0cef50ca7..f5f78f15df 100644 --- a/assets/common/abilities/sword/spin.ron +++ b/assets/common/abilities/sword/spin.ron @@ -7,7 +7,7 @@ SpinMelee( knockback: ( strength: 10.0, direction: Away), range: 3.5, damage_effect: None, - energy_cost: 150, + energy_cost: 0, is_infinite: false, movement_behavior: ForwardGround, is_interruptible: true, diff --git a/voxygen/anim/src/character/alpha.rs b/voxygen/anim/src/character/alpha.rs index 0a4d6144a4..42d0121c75 100644 --- a/voxygen/anim/src/character/alpha.rs +++ b/voxygen/anim/src/character/alpha.rs @@ -4,7 +4,7 @@ use super::{ }; use common::{ comp::item::{Hands, ToolKind}, - states::utils::StageSection, + states::utils::{AbilityInfo, StageSection}, }; use std::f32::consts::PI; @@ -18,6 +18,7 @@ impl Animation for AlphaAnimation { f32, f32, Option, + Option, ); type Skeleton = CharacterSkeleton; @@ -28,7 +29,15 @@ impl Animation for AlphaAnimation { #[allow(clippy::approx_constant)] // TODO: Pending review in #587 fn update_skeleton_inner( 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, rate: &mut f32, s_a: &SkeletonAttr, @@ -36,18 +45,20 @@ impl Animation for AlphaAnimation { *rate = 1.0; let mut next = (*skeleton).clone(); - let (move1, move2, move3) = match stage_section { - Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0), - Some(StageSection::Swing) => (1.0, anim_time, 0.0), - Some(StageSection::Recover) => (1.0, 1.0, anim_time.powi(4)), - _ => (0.0, 0.0, 0.0), + let (move1, move2, move3, move2h) = match stage_section { + Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0, 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), 1.0), /* hmm maybe don' */ + // 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.orientation = Quaternion::rotation_z(0.0); next.torso.position = Vec3::new(0.0, 0.0, 0.1) * s_a.scaler; 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) => { next.main.position = Vec3::new(0.0, 0.0, 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, ); }, - 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) => { next.main.position = Vec3::new(0.0, 0.0, 0.0); @@ -119,7 +125,7 @@ impl Animation for AlphaAnimation { } 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) => { next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2); next.hand_l.orientation = @@ -194,7 +200,7 @@ impl Animation for AlphaAnimation { match hands { (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) => { next.control_l.position = Vec3::new(-7.0, 8.0, 2.0); next.control_l.orientation = Quaternion::rotation_x(-0.3 + move2 * 2.0) @@ -238,7 +244,7 @@ impl Animation for AlphaAnimation { }; match hands { (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) => { 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) @@ -264,11 +270,11 @@ impl Animation for AlphaAnimation { | Some(ToolKind::Pick) => { next.control_r.position = Vec3::new( 7.0, - 8.0 + move1 * -4.0 + move2 * 4.0, - 2.0 + move1 * 16.0 + move2 * -21.0, + 8.0 + move1 * -4.0 + move2h * 4.0, + 2.0 + move1 * 16.0 + move2h * -21.0, ); 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_z(0.0); next.hand_r.position = Vec3::new(0.0, -0.5, 0.0); diff --git a/voxygen/anim/src/character/beta.rs b/voxygen/anim/src/character/beta.rs index bacbaa88ee..d6d977e9a5 100644 --- a/voxygen/anim/src/character/beta.rs +++ b/voxygen/anim/src/character/beta.rs @@ -2,7 +2,10 @@ use super::{ super::{vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; -use common::{comp::item::ToolKind, states::utils::StageSection}; +use common::{ + comp::item::{Hands, ToolKind}, + states::utils::{AbilityInfo, StageSection}, +}; pub struct BetaAnimation; @@ -10,9 +13,11 @@ impl Animation for BetaAnimation { type Dependency = ( Option, Option, + (Option, Option), f32, f32, Option, + Option, ); type Skeleton = CharacterSkeleton; @@ -22,7 +27,15 @@ impl Animation for BetaAnimation { #[cfg_attr(feature = "be-dyn-lib", export_name = "character_beta")] fn update_skeleton_inner( 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, rate: &mut f32, s_a: &SkeletonAttr, diff --git a/voxygen/anim/src/character/chargeswing.rs b/voxygen/anim/src/character/chargeswing.rs index ce805fe05a..c0ab4f9afc 100644 --- a/voxygen/anim/src/character/chargeswing.rs +++ b/voxygen/anim/src/character/chargeswing.rs @@ -2,16 +2,21 @@ use super::{ super::{vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; -use common::{comp::item::ToolKind, states::utils::StageSection}; +use common::{ + comp::item::{Hands, ToolKind}, + states::utils::{AbilityInfo, StageSection}, +}; pub struct ChargeswingAnimation; impl Animation for ChargeswingAnimation { type Dependency = ( Option, Option, + (Option, Option), Vec3, f32, Option, + Option, ); type Skeleton = CharacterSkeleton; @@ -22,7 +27,15 @@ impl Animation for ChargeswingAnimation { #[allow(clippy::approx_constant)] // TODO: Pending review in #587 fn update_skeleton_inner( 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, rate: &mut f32, s_a: &SkeletonAttr, @@ -36,9 +49,9 @@ impl Animation for ChargeswingAnimation { * ((anim_time * lab * 8.0).sin()); // end spin stuff - let (move1base, move2base, move3, tension, test) = match stage_section { + let (move1base, move2base, movement3, tension, test) = match stage_section { Some(StageSection::Charge) => ( - anim_time.min(1.0), + (anim_time.powf(0.25)).min(1.0), 0.0, 0.0, (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), _ => (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); - if let Some(ToolKind::Hammer) = active_tool_kind { - next.main.position = Vec3::new(0.0, 0.0, 0.0); - next.main.orientation = Quaternion::rotation_x(0.0); - 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); + let pullback = (1.0 - movement3); + let move1 = move1base * pullback; + let move2 = move2base * pullback; + let slowrise = test * pullback; + next.second.position = Vec3::new(0.0, 0.0, 0.0); + next.second.orientation = Quaternion::rotation_z(0.0); - 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)); - next.chest.orientation = - 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.shorts.orientation = Quaternion::rotation_z(short * 0.15 + (move1 * -1.0)); - next.head.position = Vec3::new( - 0.0 + (move1 * -1.0 + move2 * 2.0), - s_a.head.0 + (move1 * 1.0), - s_a.head.1, - ); - 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); + if let Some(ToolKind::Hammer) = active_tool_kind {} + + next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); + + match ability_info.and_then(|a| a.tool) { + Some(ToolKind::Hammer) => { + next.main.position = Vec3::new(0.0, 0.0, 0.0); + next.main.orientation = Quaternion::rotation_x(0.0); + + next.chest.orientation = + 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.shorts.orientation = Quaternion::rotation_z(short * 0.15 + (move1 * -1.0)); + next.head.position = Vec3::new( + 0.0 + (move1 * -1.0 + move2 * 2.0), + s_a.head.0 + (move1 * 1.0), + s_a.head.1, + ); + 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); + }, + _ => {}, } + + 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 } } diff --git a/voxygen/anim/src/character/dash.rs b/voxygen/anim/src/character/dash.rs index c9cd66eb85..cdb4979a97 100644 --- a/voxygen/anim/src/character/dash.rs +++ b/voxygen/anim/src/character/dash.rs @@ -2,7 +2,10 @@ use super::{ super::{vek::*, Animation}, 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; pub struct DashAnimation; @@ -11,8 +14,10 @@ impl Animation for DashAnimation { type Dependency = ( Option, Option, + (Option, Option), f32, Option, + Option, ); type Skeleton = CharacterSkeleton; @@ -23,7 +28,7 @@ impl Animation for DashAnimation { #[allow(clippy::single_match)] // TODO: Pending review in #587 fn update_skeleton_inner( 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, rate: &mut f32, s_a: &SkeletonAttr, @@ -31,13 +36,17 @@ impl Animation for DashAnimation { *rate = 1.0; 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::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::Recover) => (1.1, 1.0, 1.0, anim_time.powi(4)), _ => (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 { ((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() } next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); - - match active_tool_kind { + next.second.position = Vec3::new(0.0, 0.0, 0.0); + next.second.orientation = Quaternion::rotation_z(0.0); + match ability_info.and_then(|a| a.tool) { Some(ToolKind::Sword) => { next.main.position = Vec3::new(0.0, 0.0, 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 = - Vec3::new(0.0, 0.0 + s_a.head.0, s_a.head.1 + movement2.min(1.0) * 1.0); - next.head.orientation = - Quaternion::rotation_y(movement2.min(1.0) * -0.3 + movement3 * 0.3) - * (1.0 - movement4) - * Quaternion::rotation_z(movement1 * -0.9 + movement3 * 1.6) - * (1.0 - movement4); + Vec3::new(0.0, 0.0 + s_a.head.0, s_a.head.1 + move2.min(1.0) * 1.0); + next.head.orientation = Quaternion::rotation_y(move2.min(1.0) * -0.3 + move3 * 0.3) + * Quaternion::rotation_z(move1 * -0.9 + move3 * 1.6); next.chest.position = Vec3::new( 0.0, s_a.chest.0, - s_a.chest.1 + (2.0 + shortalt(movement2) * -2.5) * (1.0 - movement4), - ); - 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), + s_a.chest.1 + (2.0 + shortalt(move2) * -2.5) + move3 * -3.0, ); + 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 = - Quaternion::rotation_z((short(movement2).min(1.0) * 0.25) * (1.0 - movement4)); + next.shorts.orientation = Quaternion::rotation_z((short(move2).min(1.0) * 0.25)); - next.belt.orientation = - Quaternion::rotation_z((short(movement2).min(1.0) * 0.1) * (1.0 - movement4)); + next.belt.orientation = Quaternion::rotation_z((short(move2).min(1.0) * 0.1)); }, _ => {}, } @@ -107,6 +91,86 @@ impl Animation for DashAnimation { next.lantern.orientation = Quaternion::rotation_x(slow(anim_time) * -0.7 + 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 } } diff --git a/voxygen/anim/src/character/leapmelee.rs b/voxygen/anim/src/character/leapmelee.rs index 02d59719e5..c3b3e15923 100644 --- a/voxygen/anim/src/character/leapmelee.rs +++ b/voxygen/anim/src/character/leapmelee.rs @@ -2,7 +2,10 @@ use super::{ super::{vek::*, Animation}, 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; pub struct LeapAnimation; @@ -10,9 +13,11 @@ impl Animation for LeapAnimation { type Dependency = ( Option, Option, + (Option, Option), Vec3, f32, Option, + Option, ); type Skeleton = CharacterSkeleton; @@ -23,7 +28,15 @@ impl Animation for LeapAnimation { #[allow(clippy::approx_constant)] // TODO: Pending review in #587 fn update_skeleton_inner( 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, rate: &mut f32, s_a: &SkeletonAttr, diff --git a/voxygen/anim/src/character/sit.rs b/voxygen/anim/src/character/sit.rs index 74cd609d60..59d64f70a1 100644 --- a/voxygen/anim/src/character/sit.rs +++ b/voxygen/anim/src/character/sit.rs @@ -27,49 +27,48 @@ impl Animation for SitAnimation { let slow = (anim_time * 1.0).sin(); let slowa = (anim_time * 1.0 + 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.orientation = Quaternion::rotation_z(head_look.x + slow * 0.2 - slow * 0.1) - * Quaternion::rotation_x((slowa * -0.1 + slow * 0.1 + head_look.y).abs()); + next.head.orientation = + Quaternion::rotation_z(stop * 0.4) * Quaternion::rotation_x(slow * 0.1 + pet * 0.01); - next.chest.position = Vec3::new( - 0.0, - s_a.chest.0 + stop * -0.4, - s_a.chest.1 + slow * 0.1 + stop * -0.8, - ); - next.chest.orientation = Quaternion::rotation_x(stop * 0.15); + next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + slow * 0.1 + stop * -0.8); + next.chest.orientation = + Quaternion::rotation_z(stop * -0.4 + pet * 0.04) * Quaternion::rotation_x(stop * -0.2); 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.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( - -s_a.hand.0, - s_a.hand.1 + slowa * 0.15, - s_a.hand.2 + slow * 0.7 + stop * -2.0, + -s_a.hand.0 + stop * 3.0 + pet * 2.0, + s_a.hand.1 + stop * 10.0 + pet * -1.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( - s_a.hand.0, - s_a.hand.1 + slowa * 0.15, - s_a.hand.2 + slow * 0.7 + stop * -2.0, + s_a.hand.0 + stop * -1.0, + s_a.hand.1 + stop * 4.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.orientation = Quaternion::rotation_x(slow * 0.1 + stop * 1.2 + slow * 0.1); + 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(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.orientation = Quaternion::rotation_x(slowa * 0.1 + stop * 1.2 + slowa * 0.1); + 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(stop * -0.5); 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); @@ -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.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 } diff --git a/voxygen/anim/src/character/spin.rs b/voxygen/anim/src/character/spin.rs index e6e802e90f..74ce5a86c3 100644 --- a/voxygen/anim/src/character/spin.rs +++ b/voxygen/anim/src/character/spin.rs @@ -2,7 +2,10 @@ use super::{ super::{vek::*, Animation}, 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; pub struct SpinAnimation; @@ -11,9 +14,11 @@ impl Animation for SpinAnimation { type Dependency = ( Option, Option, + (Option, Option), Vec3, f32, Option, + Option, ); type Skeleton = CharacterSkeleton; @@ -23,7 +28,15 @@ impl Animation for SpinAnimation { #[cfg_attr(feature = "be-dyn-lib", export_name = "character_spin")] fn update_skeleton_inner( 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, rate: &mut f32, s_a: &SkeletonAttr, diff --git a/voxygen/anim/src/character/spinmelee.rs b/voxygen/anim/src/character/spinmelee.rs index f0ee2fd7ad..492c96b943 100644 --- a/voxygen/anim/src/character/spinmelee.rs +++ b/voxygen/anim/src/character/spinmelee.rs @@ -2,7 +2,10 @@ use super::{ super::{vek::*, Animation}, 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; pub struct SpinMeleeAnimation; @@ -11,9 +14,11 @@ impl Animation for SpinMeleeAnimation { type Dependency = ( Option, Option, + (Option, Option), Vec3, f32, Option, + Option, ); type Skeleton = CharacterSkeleton; @@ -24,7 +29,15 @@ impl Animation for SpinMeleeAnimation { #[allow(clippy::approx_constant)] // TODO: Pending review in #587 fn update_skeleton_inner( 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, rate: &mut f32, s_a: &SkeletonAttr, diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 1f7d7b1738..3ddc0416b0 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -903,6 +903,7 @@ impl FigureMgr { rel_vel.magnitude(), time, Some(s.stage_section), + Some(s.static_data.ability_info), ), stage_progress, &mut state_animation_rate, @@ -994,9 +995,11 @@ impl FigureMgr { ( active_tool_kind, second_tool_kind, + hands, rel_vel, time, Some(s.stage_section), + Some(s.static_data.ability_info), ), stage_progress, &mut state_animation_rate, @@ -1062,6 +1065,7 @@ impl FigureMgr { rel_vel.magnitude(), time, None, + None, ), state.state_time, &mut state_animation_rate, @@ -1090,8 +1094,10 @@ impl FigureMgr { ( active_tool_kind, second_tool_kind, + hands, time, Some(s.stage_section), + Some(s.static_data.ability_info), ), stage_progress, &mut state_animation_rate, @@ -1185,9 +1191,11 @@ impl FigureMgr { ( active_tool_kind, second_tool_kind, + hands, rel_vel, time, Some(s.stage_section), + Some(s.static_data.ability_info), ), stage_progress, &mut state_animation_rate, @@ -1221,9 +1229,11 @@ impl FigureMgr { ( active_tool_kind, second_tool_kind, + hands, rel_vel, time, Some(s.stage_section), + Some(s.static_data.ability_info), ), stage_progress, &mut state_animation_rate, @@ -1367,6 +1377,7 @@ impl FigureMgr { rel_vel.magnitude(), time, Some(s.stage_section), + Some(s.static_data.ability_info), ), stage_progress, &mut state_animation_rate, @@ -1377,9 +1388,11 @@ impl FigureMgr { ( active_tool_kind, second_tool_kind, + hands, rel_vel, time, Some(s.stage_section), + Some(s.static_data.ability_info), ), stage_progress, &mut state_animation_rate, @@ -1390,9 +1403,11 @@ impl FigureMgr { ( active_tool_kind, second_tool_kind, + hands, rel_vel.magnitude(), time, Some(s.stage_section), + Some(s.static_data.ability_info), ), stage_progress, &mut state_animation_rate,