diff --git a/common/src/combat.rs b/common/src/combat.rs index 02c9433822..eb905c135f 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -155,7 +155,7 @@ impl Damage { HealthChange { amount: -damage as i32, cause: HealthSource::World, - }, + } }, DamageSource::Buff(_) => HealthChange { amount: -damage as i32, diff --git a/common/src/comp/inventory/loadout_builder.rs b/common/src/comp/inventory/loadout_builder.rs index 5f7353fc86..11c7bc7b74 100644 --- a/common/src/comp/inventory/loadout_builder.rs +++ b/common/src/comp/inventory/loadout_builder.rs @@ -57,7 +57,7 @@ impl LoadoutBuilder { "common.items.armor.pants.rugged_pants", ))) .feet(Some(Item::new_from_asset_expect( - "common.items.armor.starter.sandals_0", + "common.items.armor.foot.sandals_0", ))) .lantern(Some(Item::new_from_asset_expect( "common.items.lantern.black_0", diff --git a/common/src/comp/inventory/test.rs b/common/src/comp/inventory/test.rs index 45de613774..acb566cc06 100644 --- a/common/src/comp/inventory/test.rs +++ b/common/src/comp/inventory/test.rs @@ -204,7 +204,7 @@ fn equip_replace_already_equipped_item() { let boots = Item::new_from_asset_expect("common.items.testing.test_boots"); let starting_sandles = Some(Item::new_from_asset_expect( - "common.items.armor.starter.sandals_0", + "common.items.armor.foot.sandals_0", )); let mut inv = Inventory::new_empty(); diff --git a/common/sys/src/stats.rs b/common/sys/src/stats.rs index b06e34bf59..f49bce1c83 100644 --- a/common/sys/src/stats.rs +++ b/common/sys/src/stats.rs @@ -74,13 +74,11 @@ impl<'a> System<'a> for Sys { poises.set_event_emission(true); // Update stats - for (entity, uid, mut stats, mut health, mut poise, character_state, pos) in ( + for (entity, uid, mut stats, mut health, pos) in ( &entities, &uids, &mut stats.restrict_mut(), &mut healths.restrict_mut(), - &mut poises.restrict_mut(), - &mut character_states, &positions, ) .join() @@ -158,74 +156,6 @@ impl<'a> System<'a> for Sys { let mut stat = stats.get_mut_unchecked(); stat.skill_set.modify_energy = false; } - - let was_wielded = character_state.is_wield(); - let poise = poise.get_mut_unchecked(); - match poise.poise_state() { - PoiseState::Normal => {}, - PoiseState::Interrupted => { - poise.reset(); - *character_state = CharacterState::Stunned(common::states::stunned::Data { - static_data: common::states::stunned::StaticData { - buildup_duration: Duration::from_millis(150), - recover_duration: Duration::from_millis(150), - movement_speed: 0.3, - }, - timer: Duration::default(), - stage_section: common::states::utils::StageSection::Buildup, - was_wielded, - }); - }, - PoiseState::Stunned => { - poise.reset(); - *character_state = CharacterState::Stunned(common::states::stunned::Data { - static_data: common::states::stunned::StaticData { - buildup_duration: Duration::from_millis(500), - recover_duration: Duration::from_millis(500), - movement_speed: 0.1, - }, - timer: Duration::default(), - stage_section: common::states::utils::StageSection::Buildup, - was_wielded, - }); - server_event_emitter.emit(ServerEvent::Knockback { - entity, - impulse: 5.0 * poise.knockback(), - }); - }, - PoiseState::Dazed => { - poise.reset(); - *character_state = CharacterState::Staggered(common::states::staggered::Data { - static_data: common::states::staggered::StaticData { - buildup_duration: Duration::from_millis(1000), - recover_duration: Duration::from_millis(1000), - }, - timer: Duration::default(), - stage_section: common::states::utils::StageSection::Buildup, - was_wielded, - }); - server_event_emitter.emit(ServerEvent::Knockback { - entity, - impulse: 10.0 * poise.knockback(), - }); - }, - PoiseState::KnockedDown => { - poise.reset(); - *character_state = CharacterState::Staggered(common::states::staggered::Data { - static_data: common::states::staggered::StaticData { - buildup_duration: Duration::from_millis(3000), - recover_duration: Duration::from_millis(500), - }, - timer: Duration::default(), - stage_section: common::states::utils::StageSection::Buildup, - was_wielded, - }); - server_event_emitter.emit(ServerEvent::Knockback { - entity, - impulse: 10.0 * poise.knockback(), - }); - }, - } } // Update energies and poises @@ -327,6 +257,79 @@ impl<'a> System<'a> for Sys { | CharacterState::Staggered { .. } => {}, } } + + // Assign poise states + for (entity, mut character_state, mut poise) in + (&entities, &mut character_states, &mut poises.restrict_mut()).join() + { + let was_wielded = character_state.is_wield(); + let poise = poise.get_mut_unchecked(); + match poise.poise_state() { + PoiseState::Normal => {}, + PoiseState::Interrupted => { + poise.reset(); + *character_state = CharacterState::Stunned(common::states::stunned::Data { + static_data: common::states::stunned::StaticData { + buildup_duration: Duration::from_millis(150), + recover_duration: Duration::from_millis(150), + movement_speed: 0.3, + }, + timer: Duration::default(), + stage_section: common::states::utils::StageSection::Buildup, + was_wielded, + }); + }, + PoiseState::Stunned => { + poise.reset(); + *character_state = CharacterState::Stunned(common::states::stunned::Data { + static_data: common::states::stunned::StaticData { + buildup_duration: Duration::from_millis(500), + recover_duration: Duration::from_millis(500), + movement_speed: 0.1, + }, + timer: Duration::default(), + stage_section: common::states::utils::StageSection::Buildup, + was_wielded, + }); + server_event_emitter.emit(ServerEvent::Knockback { + entity, + impulse: 5.0 * poise.knockback(), + }); + }, + PoiseState::Dazed => { + poise.reset(); + *character_state = CharacterState::Staggered(common::states::staggered::Data { + static_data: common::states::staggered::StaticData { + buildup_duration: Duration::from_millis(1000), + recover_duration: Duration::from_millis(1000), + }, + timer: Duration::default(), + stage_section: common::states::utils::StageSection::Buildup, + was_wielded, + }); + server_event_emitter.emit(ServerEvent::Knockback { + entity, + impulse: 10.0 * poise.knockback(), + }); + }, + PoiseState::KnockedDown => { + poise.reset(); + *character_state = CharacterState::Staggered(common::states::staggered::Data { + static_data: common::states::staggered::StaticData { + buildup_duration: Duration::from_millis(3000), + recover_duration: Duration::from_millis(500), + }, + timer: Duration::default(), + stage_section: common::states::utils::StageSection::Buildup, + was_wielded, + }); + server_event_emitter.emit(ServerEvent::Knockback { + entity, + impulse: 10.0 * poise.knockback(), + }); + }, + } + } sys_metrics.stats_ns.store( start_time.elapsed().as_nanos() as u64, std::sync::atomic::Ordering::Relaxed, diff --git a/voxygen/anim/src/character/run.rs b/voxygen/anim/src/character/run.rs index 8b96ea838f..685e1f2061 100644 --- a/voxygen/anim/src/character/run.rs +++ b/voxygen/anim/src/character/run.rs @@ -117,7 +117,8 @@ impl Animation for RunAnimation { * 0.1, ); - next.head.position = Vec3::new(0.0, -1.0 + s_a.head.0, s_a.head.1 + short * 0.1); + next.head.position = + Vec3::new(0.0, -1.0 * speednorm + s_a.head.0, s_a.head.1 + short * 0.1); next.head.orientation = Quaternion::rotation_z(tilt * -2.5 + head_look.x * 0.2 - short * 0.02) * Quaternion::rotation_x(head_look.y + 0.45 * speednorm); diff --git a/voxygen/anim/src/character/stunned.rs b/voxygen/anim/src/character/stunned.rs index c214a605de..0d260410c0 100644 --- a/voxygen/anim/src/character/stunned.rs +++ b/voxygen/anim/src/character/stunned.rs @@ -52,7 +52,6 @@ impl Animation for StunnedAnimation { let mirror = (check - 0.5).signum() as f32; let movement1 = movement1base * pullback * mirror; let movement1abs = movement1base * pullback; - println!("wield {}", wield_status); next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); next.head.orientation = Quaternion::rotation_z(movement1 * 0.3); diff --git a/voxygen/anim/src/quadruped_low/jump.rs b/voxygen/anim/src/quadruped_low/jump.rs index 953a8f1a1f..ee1d101619 100644 --- a/voxygen/anim/src/quadruped_low/jump.rs +++ b/voxygen/anim/src/quadruped_low/jump.rs @@ -28,27 +28,20 @@ impl Animation for JumpAnimation { next.tail_rear.scale = Vec3::one() * 0.98; next.head_upper.position = Vec3::new(0.0, s_a.head_upper.0, s_a.head_upper.1); - next.head_upper.orientation = Quaternion::rotation_z(0.4) * Quaternion::rotation_x(0.0); next.head_lower.position = Vec3::new(0.0, s_a.head_lower.0, s_a.head_lower.1); - next.head_lower.orientation = Quaternion::rotation_z(0.2); next.jaw.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1); - next.jaw.orientation = Quaternion::rotation_x(-0.3); next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1) * s_a.scaler / 11.0; next.tail_front.position = Vec3::new(0.0, s_a.tail_front.0, s_a.tail_front.1); - next.tail_front.orientation = Quaternion::rotation_x(0.15) * Quaternion::rotation_z(-0.2); next.tail_rear.position = Vec3::new(0.0, s_a.tail_rear.0, s_a.tail_rear.1); - next.tail_rear.orientation = Quaternion::rotation_z(-0.4) * Quaternion::rotation_x(-0.12); next.foot_fl.position = Vec3::new(-s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2); - next.foot_fl.orientation = Quaternion::rotation_z(0.3); next.foot_fr.position = Vec3::new(s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2); - next.foot_fr.orientation = Quaternion::rotation_z(0.3); next.foot_bl.position = Vec3::new(-s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2); diff --git a/voxygen/anim/src/quadruped_low/mod.rs b/voxygen/anim/src/quadruped_low/mod.rs index e8ee046102..e7c936a5d1 100644 --- a/voxygen/anim/src/quadruped_low/mod.rs +++ b/voxygen/anim/src/quadruped_low/mod.rs @@ -6,13 +6,14 @@ pub mod idle; pub mod jump; pub mod run; pub mod shoot; +pub mod stunned; pub mod tailwhip; // Reexports pub use self::{ alpha::AlphaAnimation, beta::BetaAnimation, breathe::BreatheAnimation, dash::DashAnimation, idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation, shoot::ShootAnimation, - tailwhip::TailwhipAnimation, + stunned::StunnedAnimation, tailwhip::TailwhipAnimation, }; use super::{make_bone, vek::*, FigureBoneData, Skeleton}; diff --git a/voxygen/anim/src/quadruped_low/stunned.rs b/voxygen/anim/src/quadruped_low/stunned.rs new file mode 100644 index 0000000000..86794cef52 --- /dev/null +++ b/voxygen/anim/src/quadruped_low/stunned.rs @@ -0,0 +1,60 @@ +use super::{ + super::{vek::*, Animation}, + QuadrupedLowSkeleton, SkeletonAttr, +}; +use common::states::utils::StageSection; +//use std::ops::Rem; + +pub struct StunnedAnimation; + +impl Animation for StunnedAnimation { + type Dependency = (f32, f64, Option, f64); + type Skeleton = QuadrupedLowSkeleton; + + #[cfg(feature = "use-dyn-lib")] + const UPDATE_FN: &'static [u8] = b"quadruped_low_stunned\0"; + + #[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_low_stunned")] + fn update_skeleton_inner( + skeleton: &Self::Skeleton, + (_velocity, global_time, stage_section, timer): Self::Dependency, + anim_time: f64, + _rate: &mut f32, + _s_a: &SkeletonAttr, + ) -> Self::Skeleton { + let mut next = (*skeleton).clone(); + + let (movement1base, movement2, twitch) = match stage_section { + Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), + Some(StageSection::Recover) => ( + 1.0, + (anim_time as f32).powf(3.0), + ((1.0 - anim_time as f32) * 7.0).sin(), + ), + _ => (0.0, 0.0, 0.0), + }; + let pullback = 1.0 - movement2; + let subtract = global_time - timer; + let check = subtract - subtract.trunc(); + let mirror = (check - 0.5).signum() as f32; + let movement1 = mirror * movement1base * pullback; + let movement1abs = movement1base * pullback; + + next.head_upper.orientation = Quaternion::rotation_x(movement1abs * -0.18) + * Quaternion::rotation_z(twitch * 0.13 * mirror); + + next.head_lower.orientation = + Quaternion::rotation_x(movement1abs * -0.18) * Quaternion::rotation_y(movement1 * 0.3); + + next.jaw.orientation = Quaternion::rotation_x(0.0); + next.chest.orientation = + Quaternion::rotation_y(movement1 * -0.08) * Quaternion::rotation_z(movement1 * -0.15); + + next.tail_front.orientation = + Quaternion::rotation_x(0.15) * Quaternion::rotation_z(movement1 * -0.4); + + next.tail_rear.orientation = + Quaternion::rotation_x(-0.12) * Quaternion::rotation_z(movement1 * -0.4); + next + } +} diff --git a/voxygen/anim/src/quadruped_medium/jump.rs b/voxygen/anim/src/quadruped_medium/jump.rs index 87029d0c8b..fc7127b274 100644 --- a/voxygen/anim/src/quadruped_medium/jump.rs +++ b/voxygen/anim/src/quadruped_medium/jump.rs @@ -36,43 +36,33 @@ impl Animation for JumpAnimation { next.ears.scale = Vec3::one() * 1.02; next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); - next.head.orientation = Quaternion::rotation_z(0.4) * Quaternion::rotation_x(0.3); next.neck.position = Vec3::new(0.0, s_a.neck.0, s_a.neck.1); - next.neck.orientation = Quaternion::rotation_z(0.2) * Quaternion::rotation_x(0.3); next.jaw.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1); - next.jaw.orientation = Quaternion::rotation_x(-0.4); + next.jaw.orientation = Quaternion::rotation_x(0.0); next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1); - next.tail.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.3); next.torso_front.position = Vec3::new(0.0, s_a.torso_front.0, s_a.torso_front.1) * s_a.scaler / 11.0; next.torso_front.orientation = Quaternion::rotation_y(0.0); next.torso_back.position = Vec3::new(0.0, s_a.torso_back.0, s_a.torso_back.1); - next.torso_back.orientation = Quaternion::rotation_z(-0.3); next.ears.position = Vec3::new(0.0, s_a.ears.0, s_a.ears.1); - next.ears.orientation = Quaternion::rotation_x(0.6); next.leg_fl.position = Vec3::new(-s_a.leg_f.0, s_a.leg_f.1, s_a.leg_f.2); - next.leg_fl.orientation = Quaternion::rotation_x(-0.4); next.leg_fr.position = Vec3::new(s_a.leg_f.0, s_a.leg_f.1, s_a.leg_f.2); - next.leg_fr.orientation = Quaternion::rotation_x(0.4); next.leg_bl.position = Vec3::new(-s_a.leg_b.0, s_a.leg_b.1, s_a.leg_b.2); next.leg_br.position = Vec3::new(s_a.leg_b.0, s_a.leg_b.1, s_a.leg_b.2); - next.leg_br.orientation = Quaternion::rotation_y(0.0); next.foot_fl.position = Vec3::new(-s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2); - next.foot_fl.orientation = Quaternion::rotation_x(-0.3); next.foot_fr.position = Vec3::new(s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2); - next.foot_fr.orientation = Quaternion::rotation_x(0.2); next.foot_bl.position = Vec3::new(-s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2); diff --git a/voxygen/anim/src/quadruped_medium/mod.rs b/voxygen/anim/src/quadruped_medium/mod.rs index 5a4b025dc4..10f87dd25c 100644 --- a/voxygen/anim/src/quadruped_medium/mod.rs +++ b/voxygen/anim/src/quadruped_medium/mod.rs @@ -7,12 +7,13 @@ pub mod idle; pub mod jump; pub mod leapmelee; pub mod run; +pub mod stunned; // Reexports pub use self::{ alpha::AlphaAnimation, beta::BetaAnimation, dash::DashAnimation, feed::FeedAnimation, hoof::HoofAnimation, idle::IdleAnimation, jump::JumpAnimation, leapmelee::LeapMeleeAnimation, - run::RunAnimation, + run::RunAnimation, stunned::StunnedAnimation, }; use super::{make_bone, vek::*, FigureBoneData, Skeleton}; diff --git a/voxygen/anim/src/quadruped_medium/stunned.rs b/voxygen/anim/src/quadruped_medium/stunned.rs new file mode 100644 index 0000000000..22dff2f904 --- /dev/null +++ b/voxygen/anim/src/quadruped_medium/stunned.rs @@ -0,0 +1,91 @@ +use super::{ + super::{vek::*, Animation}, + QuadrupedMediumSkeleton, SkeletonAttr, +}; +use common::states::utils::StageSection; + +pub struct StunnedAnimation; + +impl Animation for StunnedAnimation { + type Dependency = (f32, f64, Option, f64); + type Skeleton = QuadrupedMediumSkeleton; + + #[cfg(feature = "use-dyn-lib")] + const UPDATE_FN: &'static [u8] = b"quadruped_medium_stunned\0"; + + #[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_medium_stunned")] + fn update_skeleton_inner( + skeleton: &Self::Skeleton, + (_velocity, global_time, stage_section, timer): Self::Dependency, + anim_time: f64, + _rate: &mut f32, + s_a: &SkeletonAttr, + ) -> Self::Skeleton { + let mut next = (*skeleton).clone(); + + let (movement1base, movement2, twitch) = match stage_section { + Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), + Some(StageSection::Recover) => ( + 1.0, + (anim_time as f32).powf(3.0), + ((1.0 - anim_time as f32) * 7.0).sin(), + ), + _ => (0.0, 0.0, 0.0), + }; + let pullback = 1.0 - movement2; + let subtract = global_time - timer; + let check = subtract - subtract.trunc(); + let mirror = (check - 0.5).signum() as f32; + let movement1 = movement1base * mirror * pullback; + let movement1abs = movement1base * pullback; + + next.head.orientation = Quaternion::rotation_x(movement1abs * -0.45) + * Quaternion::rotation_y(movement1 * 0.35) + * Quaternion::rotation_z(movement1 * 0.15 + twitch * 0.3 * mirror); + + next.neck.orientation = Quaternion::rotation_x(movement1abs * -0.3) + * Quaternion::rotation_y(movement1 * 0.0) + * Quaternion::rotation_z(movement1 * 0.10 + movement1 * -0.15); + + next.jaw.orientation = Quaternion::rotation_x(0.0); + + next.tail.orientation = Quaternion::rotation_z(movement1 * 0.5); + next.torso_front.position = Vec3::new( + 0.0, + s_a.torso_front.0 + movement1abs * -4.0, + s_a.torso_front.1, + ) * s_a.scaler + / 11.0; + next.torso_front.orientation = + Quaternion::rotation_y(0.0) * Quaternion::rotation_z(movement1 * 0.35); + + next.torso_back.orientation = + Quaternion::rotation_y(movement1 * 0.18) * Quaternion::rotation_z(movement1 * -0.4); + + next.ears.orientation = Quaternion::rotation_x(twitch * 0.1 * mirror); + + next.leg_fl.position = Vec3::new(-s_a.leg_f.0, s_a.leg_f.1, s_a.leg_f.2); + next.leg_fl.orientation = Quaternion::rotation_y(0.0); + + next.leg_fr.position = Vec3::new(s_a.leg_f.0, s_a.leg_f.1, s_a.leg_f.2); + next.leg_fr.orientation = Quaternion::rotation_y(0.0); + + next.leg_bl.position = Vec3::new(-s_a.leg_b.0, s_a.leg_b.1, s_a.leg_b.2); + next.leg_bl.orientation = Quaternion::rotation_y(movement1 * -0.3); + + next.leg_br.position = Vec3::new(s_a.leg_b.0, s_a.leg_b.1, s_a.leg_b.2); + next.leg_br.orientation = Quaternion::rotation_y(movement1 * -0.3); + + next.foot_fl.position = Vec3::new(-s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2); + next.foot_fl.orientation = Quaternion::rotation_x(movement1abs * 0.2); + + next.foot_fr.position = Vec3::new(s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2); + next.foot_fr.orientation = Quaternion::rotation_x(movement1abs * 0.2); + + next.foot_bl.position = Vec3::new(-s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2); + + next.foot_br.position = Vec3::new(s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2); + + next + } +} diff --git a/voxygen/anim/src/quadruped_small/jump.rs b/voxygen/anim/src/quadruped_small/jump.rs index 1bbc072d4c..4af9adadb1 100644 --- a/voxygen/anim/src/quadruped_small/jump.rs +++ b/voxygen/anim/src/quadruped_small/jump.rs @@ -23,7 +23,6 @@ impl Animation for JumpAnimation { let mut next = (*skeleton).clone(); next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); - next.head.orientation = Quaternion::rotation_z(-0.8) * Quaternion::rotation_x(0.5); next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1) * s_a.scaler / 11.0; next.chest.orientation = Quaternion::rotation_y(0.0); @@ -42,7 +41,6 @@ impl Animation for JumpAnimation { next.leg_br.orientation = Quaternion::rotation_x(0.0); next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1); - next.tail.orientation = Quaternion::rotation_x(-0.3); next } } diff --git a/voxygen/anim/src/quadruped_small/mod.rs b/voxygen/anim/src/quadruped_small/mod.rs index 2d09ae38c4..f48d05c471 100644 --- a/voxygen/anim/src/quadruped_small/mod.rs +++ b/voxygen/anim/src/quadruped_small/mod.rs @@ -3,11 +3,12 @@ pub mod feed; pub mod idle; pub mod jump; pub mod run; +pub mod stunned; // Reexports pub use self::{ alpha::AlphaAnimation, feed::FeedAnimation, idle::IdleAnimation, jump::JumpAnimation, - run::RunAnimation, + run::RunAnimation, stunned::StunnedAnimation, }; use super::{make_bone, vek::*, FigureBoneData, Skeleton}; diff --git a/voxygen/anim/src/quadruped_small/stunned.rs b/voxygen/anim/src/quadruped_small/stunned.rs new file mode 100644 index 0000000000..a449436991 --- /dev/null +++ b/voxygen/anim/src/quadruped_small/stunned.rs @@ -0,0 +1,70 @@ +use super::{ + super::{vek::*, Animation}, + QuadrupedSmallSkeleton, SkeletonAttr, +}; +use common::states::utils::StageSection; +//use std::ops::Rem; + +pub struct StunnedAnimation; + +impl Animation for StunnedAnimation { + type Dependency = (f32, f64, Option, f64); + type Skeleton = QuadrupedSmallSkeleton; + + #[cfg(feature = "use-dyn-lib")] + const UPDATE_FN: &'static [u8] = b"quadruped_small_stunned\0"; + + #[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_small_stunned")] + fn update_skeleton_inner( + skeleton: &Self::Skeleton, + (_velocity, global_time, stage_section, timer): Self::Dependency, + anim_time: f64, + _rate: &mut f32, + s_a: &SkeletonAttr, + ) -> Self::Skeleton { + let mut next = (*skeleton).clone(); + + let (movement1base, movement2, twitch) = match stage_section { + Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), + Some(StageSection::Recover) => ( + 1.0, + (anim_time as f32).powf(3.0), + ((1.0 - anim_time as f32) * 10.0).sin(), + ), + _ => (0.0, 0.0, 0.0), + }; + let pullback = 1.0 - movement2; + let subtract = global_time - timer; + let check = subtract - subtract.trunc(); + let mirror = (check - 0.5).signum() as f32; + let movement1 = mirror * movement1base * pullback; + let movement1abs = movement1base * pullback; + next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); + + next.chest.position = + Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + movement1abs * -1.5) / 11.0 * s_a.scaler; + next.head.orientation = Quaternion::rotation_x(movement1abs * -0.2) + * Quaternion::rotation_y(movement1 * -0.6) + * Quaternion::rotation_z(movement1 * 0.4 + twitch * 0.2 * mirror); + + next.chest.orientation = + Quaternion::rotation_x(movement1abs * -0.2) * Quaternion::rotation_z(0.0); + + next.leg_fl.position = Vec3::new(-s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2); + next.leg_fl.orientation = Quaternion::rotation_x(movement1abs * 0.8); + + next.leg_fr.position = Vec3::new(s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2); + next.leg_fr.orientation = Quaternion::rotation_x(movement1abs * 0.8); + + next.leg_bl.position = Vec3::new(-s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2); + next.leg_bl.orientation = Quaternion::rotation_x(movement1abs * -0.2); + + next.leg_br.position = Vec3::new(s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2); + next.leg_br.orientation = Quaternion::rotation_x(movement1abs * -0.2); + + next.tail.orientation = + Quaternion::rotation_x(movement1abs * 0.5) * Quaternion::rotation_z(movement1 * -0.4); + + next + } +} diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index d6aecc486e..0224175c4e 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -1523,6 +1523,54 @@ impl FigureMgr { ) } }, + CharacterState::Stunned(s) => { + let stage_time = s.timer.as_secs_f64(); + let stage_progress = match s.stage_section { + StageSection::Buildup => { + stage_time / s.static_data.buildup_duration.as_secs_f64() + }, + StageSection::Recover => { + stage_time / s.static_data.recover_duration.as_secs_f64() + }, + _ => 0.0, + }; + anim::quadruped_small::StunnedAnimation::update_skeleton( + &target_base, + ( + vel.0.magnitude(), + time, + Some(s.stage_section), + state.state_time, + ), + stage_progress, + &mut state_animation_rate, + skeleton_attr, + ) + }, + CharacterState::Staggered(s) => { + let stage_time = s.timer.as_secs_f64(); + let stage_progress = match s.stage_section { + StageSection::Buildup => { + stage_time / s.static_data.buildup_duration.as_secs_f64() + }, + StageSection::Recover => { + stage_time / s.static_data.recover_duration.as_secs_f64() + }, + _ => 0.0, + }; + anim::quadruped_small::StunnedAnimation::update_skeleton( + &target_base, + ( + vel.0.magnitude(), + time, + Some(s.stage_section), + state.state_time, + ), + stage_progress, + &mut state_animation_rate, + skeleton_attr, + ) + }, CharacterState::Sit { .. } => { anim::quadruped_small::FeedAnimation::update_skeleton( &target_base, @@ -1800,6 +1848,54 @@ impl FigureMgr { ), } }, + CharacterState::Stunned(s) => { + let stage_time = s.timer.as_secs_f64(); + let stage_progress = match s.stage_section { + StageSection::Buildup => { + stage_time / s.static_data.buildup_duration.as_secs_f64() + }, + StageSection::Recover => { + stage_time / s.static_data.recover_duration.as_secs_f64() + }, + _ => 0.0, + }; + anim::quadruped_medium::StunnedAnimation::update_skeleton( + &target_base, + ( + vel.0.magnitude(), + time, + Some(s.stage_section), + state.state_time, + ), + stage_progress, + &mut state_animation_rate, + skeleton_attr, + ) + }, + CharacterState::Staggered(s) => { + let stage_time = s.timer.as_secs_f64(); + let stage_progress = match s.stage_section { + StageSection::Buildup => { + stage_time / s.static_data.buildup_duration.as_secs_f64() + }, + StageSection::Recover => { + stage_time / s.static_data.recover_duration.as_secs_f64() + }, + _ => 0.0, + }; + anim::quadruped_medium::StunnedAnimation::update_skeleton( + &target_base, + ( + vel.0.magnitude(), + time, + Some(s.stage_section), + state.state_time, + ), + stage_progress, + &mut state_animation_rate, + skeleton_attr, + ) + }, CharacterState::Sit { .. } => { anim::quadruped_medium::FeedAnimation::update_skeleton( &target_base, @@ -1959,6 +2055,7 @@ impl FigureMgr { skeleton_attr, ) }, + CharacterState::ChargedMelee(s) => { let stage_time = s.timer.as_secs_f64(); @@ -1988,6 +2085,54 @@ impl FigureMgr { skeleton_attr, ) }, + CharacterState::Stunned(s) => { + let stage_time = s.timer.as_secs_f64(); + let stage_progress = match s.stage_section { + StageSection::Buildup => { + stage_time / s.static_data.buildup_duration.as_secs_f64() + }, + StageSection::Recover => { + stage_time / s.static_data.recover_duration.as_secs_f64() + }, + _ => 0.0, + }; + anim::quadruped_low::StunnedAnimation::update_skeleton( + &target_base, + ( + vel.0.magnitude(), + time, + Some(s.stage_section), + state.state_time, + ), + stage_progress, + &mut state_animation_rate, + skeleton_attr, + ) + }, + CharacterState::Staggered(s) => { + let stage_time = s.timer.as_secs_f64(); + let stage_progress = match s.stage_section { + StageSection::Buildup => { + stage_time / s.static_data.buildup_duration.as_secs_f64() + }, + StageSection::Recover => { + stage_time / s.static_data.recover_duration.as_secs_f64() + }, + _ => 0.0, + }; + anim::quadruped_low::StunnedAnimation::update_skeleton( + &target_base, + ( + vel.0.magnitude(), + time, + Some(s.stage_section), + state.state_time, + ), + stage_progress, + &mut state_animation_rate, + skeleton_attr, + ) + }, CharacterState::ComboMelee(s) => { let stage_index = (s.stage - 1) as usize; let stage_time = s.timer.as_secs_f64();