From 19948ad6fd7dd2d5f7ebda95fd1c9ad987f93259 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 14 Aug 2022 18:21:44 -0400 Subject: [PATCH] Animation for defensive combo --- voxygen/anim/src/character/combomelee.rs | 59 ++++++++++++++++++++++++ voxygen/anim/src/character/divemelee.rs | 16 +++---- voxygen/anim/src/character/mod.rs | 19 ++++---- voxygen/src/scene/figure/mod.rs | 13 ++---- 4 files changed, 82 insertions(+), 25 deletions(-) diff --git a/voxygen/anim/src/character/combomelee.rs b/voxygen/anim/src/character/combomelee.rs index 4d58478ced..c5a1d14bf2 100644 --- a/voxygen/anim/src/character/combomelee.rs +++ b/voxygen/anim/src/character/combomelee.rs @@ -523,6 +523,65 @@ impl Animation for ComboAnimation { next.control.orientation.rotate_z(move2 * -1.8); next.control.position += Vec3::new(move2 * 14.0, 0.0, 0.0); }, + Some("common.abilities.sword.defensive_combo") => { + let (move1, move2, move3) = if strike == current_strike { + match stage_section { + Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0), + Some(StageSection::Action) => (1.0, anim_time.powf(0.5), 0.0), + Some(StageSection::Recover) => (1.0, 1.0, anim_time.powi(4)), + _ => (0.0, 0.0, 0.0), + } + } else { + (1.0, 1.0, 0.0) + }; + + match strike { + 0 => { + let s1_move1_hack = if current_strike == 1 { move1 } else { 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.sc.0 + 6.0 + move1 * -12.0, + -4.0 + move1 * 3.0, + -2.0, + ); + next.hand_r.orientation = Quaternion::rotation_x(0.9 + move1 * 0.5); + next.control.position = Vec3::new(s_a.sc.0, s_a.sc.1, s_a.sc.2); + next.control.orientation = Quaternion::rotation_x(s_a.sc.3) + * Quaternion::rotation_z(s1_move1_hack * PI); + + next.chest.orientation = Quaternion::rotation_z(move1 * 0.8); + next.head.orientation = Quaternion::rotation_z(move1 * -0.3); + next.belt.orientation = Quaternion::rotation_z(move1 * -0.2); + next.shorts.orientation = Quaternion::rotation_z(move1 * -0.6); + next.control.position += Vec3::new(0.0, 0.0, move1 * 5.0); + + next.chest.orientation.rotate_z(move2 * -1.9); + next.head.orientation.rotate_z(move2 * 1.3); + next.belt.orientation.rotate_z(move2 * 0.7); + next.shorts.orientation.rotate_z(move2 * 1.5); + next.control.orientation.rotate_y(move2 * -1.6); + next.control.orientation.rotate_z(move2 * -1.1); + next.control.position += + Vec3::new(move2 * 12.0, move2 * 5.0, move2 * -1.0); + }, + 1 => { + next.belt.orientation.rotate_z(move1 * 0.2); + next.shorts.orientation.rotate_z(move1 * 0.3); + next.control.position += Vec3::new(0.0, move1 * -5.0, move1 * 1.0); + + next.chest.orientation.rotate_z(move2 * 2.1); + next.head.orientation.rotate_z(move2 * -1.2); + next.belt.orientation.rotate_z(move2 * -1.0); + next.shorts.orientation.rotate_z(move2 * -1.8); + next.control.orientation.rotate_z(move2 * 0.9); + next.control.position += + Vec3::new(move2 * -12.0, move2 * 2.0, move2 * -1.0); + }, + _ => {}, + } + }, _ => {}, } } diff --git a/voxygen/anim/src/character/divemelee.rs b/voxygen/anim/src/character/divemelee.rs index 080959859c..c353f59844 100644 --- a/voxygen/anim/src/character/divemelee.rs +++ b/voxygen/anim/src/character/divemelee.rs @@ -38,7 +38,12 @@ impl Animation for DiveMeleeAnimation { match ability_id { Some("common.abilities.sword.cleaving_dive") => { let (move1, move2, move3, move4) = match stage_section { - Some(StageSection::Movement) => (anim_time.min(1.0).powi(2), (1.0 - ground_dist).powi(2), 0.0, 0.0), + Some(StageSection::Movement) => ( + anim_time.min(1.0).powi(2), + (1.0 - ground_dist).powi(2), + 0.0, + 0.0, + ), Some(StageSection::Action) => (1.0, 1.0, anim_time.powf(0.25), 0.0), Some(StageSection::Recover) => (1.0, 1.0, 1.0, anim_time.powi(4)), _ => (0.0, 0.0, 0.0, 0.0), @@ -50,13 +55,8 @@ impl Animation for DiveMeleeAnimation { next.hand_r.position = Vec3::new(-s_a.sc.0 + 6.0 + move1 * -12.0, -4.0 + move1 * 3.0, -2.0); next.hand_r.orientation = Quaternion::rotation_x(0.9 + move1 * 0.5); - next.control.position = Vec3::new( - s_a.sc.0, - s_a.sc.1, - s_a.sc.2, - ); - next.control.orientation = - Quaternion::rotation_x(s_a.sc.3); + next.control.position = Vec3::new(s_a.sc.0, s_a.sc.1, s_a.sc.2); + next.control.orientation = Quaternion::rotation_x(s_a.sc.3); next.torso.orientation.rotate_x(move1 * -0.8); next.control.orientation.rotate_x(move1 * 1.5); diff --git a/voxygen/anim/src/character/mod.rs b/voxygen/anim/src/character/mod.rs index 46d2dd5bd1..e442fdcbe0 100644 --- a/voxygen/anim/src/character/mod.rs +++ b/voxygen/anim/src/character/mod.rs @@ -44,15 +44,16 @@ pub use self::{ alpha::AlphaAnimation, beam::BeamAnimation, beta::BetaAnimation, block::BlockAnimation, chargeswing::ChargeswingAnimation, climb::ClimbAnimation, collect::CollectAnimation, combomelee::ComboAnimation, consume::ConsumeAnimation, dance::DanceAnimation, - dash::DashAnimation, equip::EquipAnimation, finishermelee::FinisherMeleeAnimation, - glidewield::GlideWieldAnimation, gliding::GlidingAnimation, idle::IdleAnimation, - jump::JumpAnimation, leapmelee::LeapAnimation, mount::MountAnimation, music::MusicAnimation, - repeater::RepeaterAnimation, roll::RollAnimation, run::RunAnimation, - shockwave::ShockwaveAnimation, shoot::ShootAnimation, sit::SitAnimation, sneak::SneakAnimation, - sneakequip::SneakEquipAnimation, sneakwield::SneakWieldAnimation, spin::SpinAnimation, - spinmelee::SpinMeleeAnimation, staggered::StaggeredAnimation, stand::StandAnimation, - stunned::StunnedAnimation, swim::SwimAnimation, swimwield::SwimWieldAnimation, - talk::TalkAnimation, wallrun::WallrunAnimation, wield::WieldAnimation, divemelee::DiveMeleeAnimation, + dash::DashAnimation, divemelee::DiveMeleeAnimation, equip::EquipAnimation, + finishermelee::FinisherMeleeAnimation, glidewield::GlideWieldAnimation, + gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, leapmelee::LeapAnimation, + mount::MountAnimation, music::MusicAnimation, repeater::RepeaterAnimation, roll::RollAnimation, + run::RunAnimation, shockwave::ShockwaveAnimation, shoot::ShootAnimation, sit::SitAnimation, + sneak::SneakAnimation, sneakequip::SneakEquipAnimation, sneakwield::SneakWieldAnimation, + spin::SpinAnimation, spinmelee::SpinMeleeAnimation, staggered::StaggeredAnimation, + stand::StandAnimation, stunned::StunnedAnimation, swim::SwimAnimation, + swimwield::SwimWieldAnimation, talk::TalkAnimation, wallrun::WallrunAnimation, + wield::WieldAnimation, }; use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton, TrailSource}; use common::comp; diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 815ea66434..d9a66be9db 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -40,9 +40,9 @@ use common::{ mounting::Rider, resources::{DeltaTime, Time}, states::{equipping, idle, utils::StageSection, wielding}, - terrain::{TerrainChunk, TerrainGrid, Block}, + terrain::{Block, TerrainChunk, TerrainGrid}, uid::UidAllocator, - vol::{RectRasterableVol, ReadVol}, + vol::{ReadVol, RectRasterableVol}, }; use common_base::span; use common_state::State; @@ -1191,9 +1191,7 @@ impl FigureMgr { CharacterState::DiveMelee(s) => { let stage_time = s.timer.as_secs_f32(); let stage_progress = match s.stage_section { - StageSection::Movement => { - stage_time - }, + StageSection::Movement => stage_time, StageSection::Action => { stage_time / s.static_data.swing_duration.as_secs_f32() }, @@ -1202,9 +1200,8 @@ impl FigureMgr { }, _ => 0.0, }; - let convert_vec3 = |vec3: anim::vek::Vec3<_>| { - Vec3::new(vec3.x, vec3.y, vec3.z) - }; + let convert_vec3 = + |vec3: anim::vek::Vec3<_>| Vec3::new(vec3.x, vec3.y, vec3.z); let ground_dist = terrain_grid .ray(convert_vec3(pos.0), convert_vec3(pos.0 + vel.0)) .until(Block::is_solid)