veloren_voxygen_anim/biped_small/
ripostemelee.rs1use super::{
2 super::{Animation, vek::*},
3 BipedSmallSkeleton, SkeletonAttr, biped_small_wield_sword, init_biped_small_alpha,
4};
5use common::states::utils::StageSection;
6
7pub struct RiposteMeleeAnimation;
8impl Animation for RiposteMeleeAnimation {
9 type Dependency<'a> = (Option<&'a str>, StageSection);
10 type Skeleton = BipedSmallSkeleton;
11
12 #[cfg(feature = "use-dyn-lib")]
13 const UPDATE_FN: &'static [u8] = b"biped_small_riposte_melee\0";
14
15 #[cfg_attr(feature = "be-dyn-lib", export_name = "biped_small_riposte_melee")]
16 fn update_skeleton_inner(
17 skeleton: &Self::Skeleton,
18 (ability_id, stage_section): Self::Dependency<'_>,
19 anim_time: f32,
20 rate: &mut f32,
21 s_a: &SkeletonAttr,
22 ) -> Self::Skeleton {
23 *rate = 1.0;
24 let mut next = (*skeleton).clone();
25
26 init_biped_small_alpha(&mut next, s_a);
27
28 match ability_id {
29 Some("common.abilities.haniwa.soldier.riposte") => {
30 let slow = (anim_time * 2.0).sin();
31 biped_small_wield_sword(&mut next, s_a, 0.0, slow);
32
33 let (move1, move2, move3) = match stage_section {
34 StageSection::Buildup => (anim_time.powf(0.25), 0.0, 0.0),
35 StageSection::Action => (1.0, anim_time, 0.0),
36 StageSection::Recover => (1.0, 1.0, anim_time),
37 _ => (0.0, 0.0, 0.0),
38 };
39 let pullback = 1.0 - move3;
40 let move1 = move1 * pullback;
41 let move2 = move2 * pullback;
42 let move2fast = move2.max(0.001).powf(0.25) * pullback;
43 let move2slow = move2.powi(4) * pullback;
44
45 next.detach_right = true;
46 next.control_r.position += next.control.position
49 + Vec3::new(0.0, -2.0, 1.0)
50 + Vec3::new(2.0 * move3, -1.0 * move3, 2.0 * move3);
51 next.control_r.orientation = next.control.orientation * next.control_r.orientation;
52
53 next.control.orientation.rotate_z(move1 * 1.9);
54 next.control.position += Vec3::new(0.0 * move1, 2.0 * move1, 13.0 * move1);
55 next.control.orientation.rotate_y(move1 * 2.7);
56
57 next.control.orientation.rotate_y(move2fast * -2.1);
58 next.control.orientation.rotate_z(move2 * -1.8);
59 next.control.orientation.rotate_x(move2slow * -3.2);
60 next.control.position += Vec3::new(move2 * 3.0, move2 * -2.0, move2 * -10.0);
61 },
62 _ => {},
63 }
64
65 next
66 }
67}