veloren_voxygen_anim/quadruped_low/
shoot.rs

1use super::{
2    super::{Animation, vek::*},
3    QuadrupedLowSkeleton, SkeletonAttr,
4};
5use common::states::utils::StageSection;
6
7pub struct ShootAnimation;
8
9impl Animation for ShootAnimation {
10    type Dependency<'a> = (Option<&'a str>, f32, f32, Option<StageSection>);
11    type Skeleton = QuadrupedLowSkeleton;
12
13    #[cfg(feature = "use-dyn-lib")]
14    const UPDATE_FN: &'static [u8] = b"quadruped_low_shoot\0";
15
16    #[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_low_shoot")]
17    fn update_skeleton_inner(
18        skeleton: &Self::Skeleton,
19        (ability_id, velocity, _global_time, stage_section): Self::Dependency<'_>,
20        anim_time: f32,
21        _rate: &mut f32,
22        s_a: &SkeletonAttr,
23    ) -> Self::Skeleton {
24        let mut next = (*skeleton).clone();
25
26        let (movement1, movement2, movement3) = match stage_section {
27            Some(StageSection::Buildup) => (anim_time, 0.0, 0.0),
28            Some(StageSection::Action) => (1.0, anim_time.powf(0.25), 0.0),
29            Some(StageSection::Recover) => (1.0, 1.0, anim_time),
30            _ => (0.0, 0.0, 0.0),
31        };
32
33        let twitch1 = (movement1 * 18.0).sin();
34        match ability_id {
35            Some("common.abilities.custom.dwarves.snaretongue.bombs") => {
36                next.head_c_upper.position =
37                    Vec3::new(0.0, s_a.head_upper.0, s_a.head_upper.1 - movement1 * 2.0);
38                next.head_c_upper.orientation =
39                    Quaternion::rotation_x((movement1 * 0.3 + movement2 * 0.2) * (1.0 - movement3))
40                        * Quaternion::rotation_z((twitch1 * 0.1) * (1.0 - movement3));
41
42                next.head_c_lower.position =
43                    Vec3::new(0.0, s_a.head_lower.0, s_a.head_lower.1 - movement1 * 0.5);
44                next.head_c_lower.orientation = Quaternion::rotation_x(
45                    (twitch1 * 0.05 + movement1 * 0.3 + movement2 * 0.2) * (0.5 - movement3),
46                );
47
48                next.jaw_c.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1);
49                next.jaw_c.orientation = Quaternion::rotation_x(movement1 * -0.5 + movement3 * 0.5);
50
51                next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + movement1 * 0.5);
52                next.chest.orientation = Quaternion::rotation_x(0.0 + movement1 * 0.1);
53
54                next.tail_front.scale = Vec3::one() * 0.1;
55                next.tail_rear.scale = Vec3::one() * 0.1;
56
57                next.foot_fl.orientation = Quaternion::rotation_x(movement1 * -0.2);
58
59                next.foot_fr.orientation = Quaternion::rotation_x(movement1 * -0.2);
60
61                next.foot_bl.orientation = Quaternion::rotation_x(movement1 * -0.2);
62
63                next.foot_br.orientation = Quaternion::rotation_x(movement1 * -0.2);
64                if velocity < 0.5 {
65                    next.foot_fl.position = Vec3::new(-s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2);
66
67                    next.foot_fr.position = Vec3::new(s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2);
68
69                    next.foot_bl.position = Vec3::new(-s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2);
70
71                    next.foot_br.position = Vec3::new(s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2);
72                };
73            },
74            Some("common.abilities.custom.dagon.dagonbombs") => {
75                next.head_c_upper.position =
76                    Vec3::new(0.0, s_a.head_upper.0, s_a.head_upper.1 - movement1 * 2.0);
77                next.head_c_upper.orientation =
78                    Quaternion::rotation_x((movement1 * 0.3 + movement2 * 0.2) * (1.0 - movement3))
79                        * Quaternion::rotation_z((twitch1 * 0.1) * (1.0 - movement3));
80
81                next.head_c_lower.position =
82                    Vec3::new(0.0, s_a.head_lower.0, s_a.head_lower.1 - movement1 * 0.5);
83                next.head_c_lower.orientation = Quaternion::rotation_x(
84                    (twitch1 * 0.05 + movement1 * 0.3 + movement2 * 0.2) * (0.5 - movement3),
85                );
86
87                next.jaw_c.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1);
88                next.jaw_c.orientation = Quaternion::rotation_x(movement1 * -0.5 + movement3 * 0.5);
89
90                next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + movement1 * 0.5);
91                next.chest.orientation = Quaternion::rotation_x(0.0 + movement1 * 0.1);
92
93                next.tail_front.position =
94                    Vec3::new(0.0, s_a.tail_front.0 + movement1 * 1.5, s_a.tail_front.1);
95                next.tail_front.orientation =
96                    Quaternion::rotation_x(movement1 * -0.4 + movement2 * 0.3);
97
98                next.tail_rear.position =
99                    Vec3::new(0.0, s_a.tail_rear.0 + movement1 * 1.5, s_a.tail_rear.1);
100                next.tail_rear.orientation =
101                    Quaternion::rotation_x(movement1 * -0.4 + movement2 * 0.3);
102                next.foot_fl.orientation = Quaternion::rotation_x(movement1 * -0.2);
103
104                next.foot_fr.orientation = Quaternion::rotation_x(movement1 * -0.2);
105
106                next.foot_bl.orientation = Quaternion::rotation_x(movement1 * -0.2);
107
108                next.foot_br.orientation = Quaternion::rotation_x(movement1 * -0.2);
109                if velocity < 0.5 {
110                    next.foot_fl.position = Vec3::new(-s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2);
111
112                    next.foot_fr.position = Vec3::new(s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2);
113
114                    next.foot_bl.position = Vec3::new(-s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2);
115
116                    next.foot_br.position = Vec3::new(s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2);
117                };
118            },
119            _ => {
120                // Center head
121                next.head_c_upper.position = Vec3::new(0.0, s_a.head_upper.0, s_a.head_upper.1);
122                next.head_c_upper.orientation =
123                    Quaternion::rotation_x((movement1 * 0.6 + movement2 * 0.7) * (1.0 - movement3))
124                        * Quaternion::rotation_z((twitch1 * 0.1) * (1.0 - movement3));
125
126                next.head_c_lower.position = Vec3::new(0.0, s_a.head_lower.0, s_a.head_lower.1);
127                next.head_c_lower.orientation = Quaternion::rotation_x(
128                    (twitch1 * 0.05 + movement1 * 0.3 + movement2 * 0.6) * (1.0 - movement3),
129                );
130
131                next.jaw_c.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1);
132                next.jaw_c.orientation = Quaternion::rotation_x(movement1 * -0.5);
133
134                // Left head
135                next.head_l_upper.position = Vec3::new(
136                    -s_a.side_head_upper.0,
137                    s_a.side_head_upper.1,
138                    s_a.side_head_upper.2,
139                );
140                next.head_l_upper.orientation =
141                    Quaternion::rotation_x((movement1 * 0.6 + movement2 * 0.7) * (1.0 - movement3))
142                        * Quaternion::rotation_z((twitch1 * 0.1) * (1.0 - movement3));
143
144                next.head_l_lower.position = Vec3::new(
145                    -s_a.side_head_lower.0,
146                    s_a.side_head_lower.1,
147                    s_a.side_head_lower.2,
148                );
149                next.head_l_lower.orientation = Quaternion::rotation_x(
150                    (twitch1 * 0.05 + movement1 * 0.3 + movement2 * 0.6) * (1.0 - movement3),
151                );
152
153                next.jaw_l.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1);
154                next.jaw_l.orientation = Quaternion::rotation_x(movement1 * -0.5);
155
156                // Right head
157                next.head_r_upper.position = Vec3::new(
158                    s_a.side_head_upper.0,
159                    s_a.side_head_upper.1,
160                    s_a.side_head_upper.2,
161                );
162                next.head_r_upper.orientation =
163                    Quaternion::rotation_x((movement1 * 0.6 + movement2 * 0.7) * (1.0 - movement3))
164                        * Quaternion::rotation_z((twitch1 * 0.1) * (1.0 - movement3));
165
166                next.head_r_lower.position = Vec3::new(
167                    s_a.side_head_lower.0,
168                    s_a.side_head_lower.1,
169                    s_a.side_head_lower.2,
170                );
171                next.head_r_lower.orientation = Quaternion::rotation_x(
172                    (twitch1 * 0.05 + movement1 * 0.3 + movement2 * 0.6) * (1.0 - movement3),
173                );
174
175                next.jaw_r.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1);
176                next.jaw_r.orientation = Quaternion::rotation_x(movement1 * -0.5);
177
178                next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1);
179                next.chest.orientation = Quaternion::rotation_x(0.0);
180
181                next.tail_front.position = Vec3::new(0.0, s_a.tail_front.0, s_a.tail_front.1);
182                next.tail_front.orientation = Quaternion::rotation_x(movement1 * 0.15);
183
184                next.tail_rear.position = Vec3::new(0.0, s_a.tail_rear.0, s_a.tail_rear.1);
185                next.tail_rear.orientation = Quaternion::rotation_x(0.0);
186                if velocity < 0.5 {
187                    next.foot_fl.position = Vec3::new(-s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2);
188
189                    next.foot_fr.position = Vec3::new(s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2);
190
191                    next.foot_bl.position = Vec3::new(-s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2);
192
193                    next.foot_br.position = Vec3::new(s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2);
194                };
195            },
196        }
197        next
198    }
199}