diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index a60bb68f71..d19ce99033 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -245,6 +245,10 @@ impl CharacterState { ) } + pub fn should_follow_look(&self) -> bool { + matches!(self, CharacterState::Boost(_)) || self.is_attack() + } + pub fn is_attack(&self) -> bool { matches!( self, diff --git a/common/src/states/boost.rs b/common/src/states/boost.rs index b453cb061f..8adf53d6f4 100644 --- a/common/src/states/boost.rs +++ b/common/src/states/boost.rs @@ -31,6 +31,7 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate { let mut update = StateUpdate::from(data); + handle_orientation(data, &mut update, 10.0, None); handle_move(data, &mut update, 1.0); if self.timer < self.static_data.movement_duration { diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 5001619aa3..e1b98b8821 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -654,7 +654,7 @@ pub fn handle_orientation( // else the current horizontal movement direction is used let target_ori = if let Some(dir_override) = dir_override { dir_override.into() - } else if is_strafing(data, update) || update.character.is_attack() { + } else if is_strafing(data, update) || update.character.should_follow_look() { data.inputs .look_dir .to_horizontal() diff --git a/voxygen/anim/src/character/boost.rs b/voxygen/anim/src/character/boost.rs new file mode 100644 index 0000000000..89e308d688 --- /dev/null +++ b/voxygen/anim/src/character/boost.rs @@ -0,0 +1,62 @@ +use super::{ + super::{vek::*, Animation}, + CharacterSkeleton, SkeletonAttr, +}; + +pub struct BoostAnimation; + +type BoostAnimationDependency<'a> = (); + +impl Animation for BoostAnimation { + type Dependency<'a> = BoostAnimationDependency<'a>; + type Skeleton = CharacterSkeleton; + + #[cfg(feature = "use-dyn-lib")] + const UPDATE_FN: &'static [u8] = b"character_boost\0"; + + #[cfg_attr(feature = "be-dyn-lib", export_name = "character_boost")] + #[allow(clippy::single_match)] // TODO: Pending review in #587 + fn update_skeleton_inner( + skeleton: &Self::Skeleton, + _dep: Self::Dependency<'_>, + anim_time: f32, + rate: &mut f32, + s_a: &SkeletonAttr, + ) -> Self::Skeleton { + *rate = 1.0; + let mut next = (*skeleton).clone(); + + next.main.position = Vec3::new(10.0, -10.0, -10.0); + next.main.orientation = Quaternion::rotation_z(0.0); + next.second.position = Vec3::new(0.0, 0.0, 0.0); + next.second.orientation = Quaternion::rotation_z(0.0); + + let (move1, move2, move3, tension) = ( + anim_time.powf(0.25).min(1.0), + 0.0, + 0.0, + (anim_time * 20.0).sin() - 0.5, + ); + let pullback = 1.0 - move3; + let move1 = move1 * pullback; + let move2 = move2 * pullback; + + 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(std::f32::consts::PI * 0.5); + next.control.position = Vec3::new(s_a.sc.0, s_a.sc.1, s_a.sc.2 + move2 * 5.0); + next.control.orientation = Quaternion::rotation_x(s_a.sc.3 + move1 * -0.9) + * Quaternion::rotation_y(move1 * 1.0 + move2 * -1.0) + * Quaternion::rotation_z(move1 * 1.3 + move2 * -1.3); + + next.chest.orientation = + Quaternion::rotation_z(move1 * 1.0 + tension * 0.02 + move2 * -1.2); + next.head.orientation = Quaternion::rotation_z(move1 * -0.4 + move2 * 0.3); + next.belt.orientation = Quaternion::rotation_z(move1 * -0.25 + move2 * 0.2); + next.shorts.orientation = Quaternion::rotation_z(move1 * -0.5 + move2 * 0.4); + + next + } +} diff --git a/voxygen/anim/src/character/mod.rs b/voxygen/anim/src/character/mod.rs index 22e448671a..0c09b9dc3c 100644 --- a/voxygen/anim/src/character/mod.rs +++ b/voxygen/anim/src/character/mod.rs @@ -2,6 +2,7 @@ pub mod alpha; pub mod beam; pub mod beta; pub mod block; +pub mod boost; pub mod chargeswing; pub mod climb; pub mod collect; @@ -45,10 +46,10 @@ pub mod wield; // Reexports 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, divemelee::DiveMeleeAnimation, equip::EquipAnimation, - finishermelee::FinisherMeleeAnimation, glidewield::GlideWieldAnimation, + boost::BoostAnimation, chargeswing::ChargeswingAnimation, climb::ClimbAnimation, + collect::CollectAnimation, combomelee::ComboAnimation, consume::ConsumeAnimation, + dance::DanceAnimation, dash::DashAnimation, divemelee::DiveMeleeAnimation, + equip::EquipAnimation, finishermelee::FinisherMeleeAnimation, glidewield::GlideWieldAnimation, gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, leapmelee::LeapAnimation, mount::MountAnimation, music::MusicAnimation, rapidmelee::RapidMeleeAnimation, repeater::RepeaterAnimation, ripostemelee::RiposteMeleeAnimation, roll::RollAnimation, diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index bddce5228d..ec3fd34dbb 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -1601,10 +1601,10 @@ impl FigureMgr { ) }, CharacterState::Boost(_) => { - anim::character::AlphaAnimation::update_skeleton( + anim::character::BoostAnimation::update_skeleton( &target_base, - (hands, None, None), - state.state_time, + (), + 0.5, &mut state_animation_rate, skeleton_attr, ) diff --git a/voxygen/src/scene/particle.rs b/voxygen/src/scene/particle.rs index 333d22b923..59fa3303c8 100644 --- a/voxygen/src/scene/particle.rs +++ b/voxygen/src/scene/particle.rs @@ -946,9 +946,9 @@ impl ParticleMgr { + usize::from(self.scheduler.heartbeats(Duration::from_millis(10))), || { Particle::new( - Duration::from_secs(15), + Duration::from_millis(250), time, - ParticleMode::CampfireSmoke, + ParticleMode::PortalFizz, interpolated.pos + vel.map_or(Vec3::zero(), |v| -v.0 * dt * rng.gen::()), )