veloren_voxygen_anim/quadruped_medium/
combomelee.rs

1use super::{
2    super::{Animation, vek::*},
3    QuadrupedMediumSkeleton, SkeletonAttr, quadruped_medium_alpha, quadruped_medium_beta,
4};
5use common::states::utils::StageSection;
6
7pub struct ComboAnimation;
8impl Animation for ComboAnimation {
9    type Dependency<'a> = (Option<&'a str>, StageSection, usize, f32, f32, f32);
10    type Skeleton = QuadrupedMediumSkeleton;
11
12    #[cfg(feature = "use-dyn-lib")]
13    const UPDATE_FN: &'static [u8] = b"quadruped_medium_combo\0";
14
15    #[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_medium_combo")]
16    fn update_skeleton_inner(
17        skeleton: &Self::Skeleton,
18        (ability_id, stage_section, current_strike, speed, global_time, timer): Self::Dependency<
19            '_,
20        >,
21        anim_time: f32,
22        rate: &mut f32,
23        s_a: &SkeletonAttr,
24    ) -> Self::Skeleton {
25        *rate = 1.0;
26        let mut next = (*skeleton).clone();
27
28        let _multi_strike_pullback = 1.0
29            - if matches!(stage_section, StageSection::Recover) {
30                anim_time.powi(4)
31            } else {
32                0.0
33            };
34
35        for strike in 0..=current_strike {
36            match ability_id {
37                Some(
38                    "common.abilities.custom.frostfang.singlestrike"
39                    | "common.abilities.custom.frostfang.triplestrike",
40                ) => {
41                    let (movement1base, movement2base, movement3) = match stage_section {
42                        StageSection::Buildup => (anim_time.sqrt(), 0.0, 0.0),
43                        StageSection::Action => (1.0, anim_time.powi(4), 0.0),
44                        StageSection::Recover => (1.0, 1.0, anim_time),
45                        _ => (0.0, 0.0, 0.0),
46                    };
47                    let pullback = 1.0 - movement3;
48                    let subtract = global_time - timer;
49                    let check = subtract - subtract.trunc();
50                    let mirror = (check - 0.5).signum();
51                    let twitch3 = (mirror * movement3 * 9.0).sin();
52                    let movement1 = mirror * movement1base * pullback;
53                    let movement2 = mirror * movement2base * pullback;
54                    let movement1abs = movement1base * pullback;
55                    let movement2abs = movement2base * pullback;
56
57                    match strike {
58                        0 | 2 => {
59                            next.head.orientation = Quaternion::rotation_z(twitch3 * -0.7);
60
61                            next.head.orientation =
62                                Quaternion::rotation_x(movement1abs * 0.35 + movement2abs * -0.9)
63                                    * Quaternion::rotation_y(movement1 * 0.7 + movement2 * -1.0);
64
65                            next.jaw.orientation =
66                                Quaternion::rotation_x(movement1abs * -0.5 + movement2abs * 0.5);
67                            next.torso_front.orientation =
68                                Quaternion::rotation_y(movement1 * -0.08 + movement2 * 0.15)
69                                    * Quaternion::rotation_z(movement1 * -0.2 + movement2 * 0.6);
70
71                            next.torso_back.orientation = Quaternion::rotation_x(0.15)
72                                * Quaternion::rotation_z(movement1 * -0.4 + movement2 * -0.2);
73
74                            next.tail.orientation = Quaternion::rotation_x(-0.12)
75                                * Quaternion::rotation_z(movement1 * -0.4 + movement2 * -0.2);
76                        },
77                        1 => {
78                            next.head.orientation = Quaternion::rotation_z(twitch3 * 0.2);
79
80                            next.neck.orientation =
81                                Quaternion::rotation_x(movement1abs * 0.15 + movement2abs * -0.6)
82                                    * Quaternion::rotation_y(movement1 * -0.1 + movement2 * 0.15);
83
84                            next.jaw.orientation =
85                                Quaternion::rotation_x(movement1abs * -0.9 + movement2abs * 0.9);
86                            next.torso_front.orientation =
87                                Quaternion::rotation_y(movement1 * 0.08 + movement2 * -0.15)
88                                    * Quaternion::rotation_z(movement1 * 0.2 + movement2 * -0.3);
89
90                            next.torso_back.orientation = Quaternion::rotation_x(0.15)
91                                * Quaternion::rotation_z(movement1 * 0.4 + movement2 * 0.2);
92
93                            next.tail.orientation = Quaternion::rotation_x(-0.12)
94                                * Quaternion::rotation_z(movement1 * 0.4 + movement2 * 0.2);
95                        },
96                        _ => {},
97                    }
98                },
99                Some("common.abilities.custom.quadmedbasic.singlestrike") => match strike {
100                    0 => {
101                        quadruped_medium_alpha(
102                            &mut next,
103                            s_a,
104                            speed,
105                            stage_section,
106                            anim_time,
107                            global_time,
108                            timer,
109                        );
110                    },
111                    _ => {},
112                },
113                Some(
114                    "common.abilities.custom.quadmedbasic.triplestrike"
115                    | "common.abilities.custom.quadmedquick.triplestrike",
116                ) => match strike {
117                    0 | 2 => {
118                        quadruped_medium_alpha(
119                            &mut next,
120                            s_a,
121                            speed,
122                            stage_section,
123                            anim_time,
124                            global_time,
125                            timer,
126                        );
127                    },
128                    1 => {
129                        quadruped_medium_beta(
130                            &mut next,
131                            s_a,
132                            speed,
133                            stage_section,
134                            anim_time,
135                            global_time,
136                            timer,
137                        );
138                    },
139                    _ => {},
140                },
141                Some(
142                    "common.abilities.custom.quadmedcharge.doublestrike"
143                    | "common.abilities.custom.quadmedjump.doublestrike"
144                    | "common.abilities.custom.roshwalr.doublehusk",
145                ) => match strike {
146                    0 => {
147                        quadruped_medium_alpha(
148                            &mut next,
149                            s_a,
150                            speed,
151                            stage_section,
152                            anim_time,
153                            global_time,
154                            timer,
155                        );
156                    },
157                    1 => {
158                        quadruped_medium_beta(
159                            &mut next,
160                            s_a,
161                            speed,
162                            stage_section,
163                            anim_time,
164                            global_time,
165                            timer,
166                        );
167                    },
168                    _ => {},
169                },
170                _ => {},
171            }
172        }
173        next
174    }
175}