veloren_voxygen_anim/quadruped_medium/
combomelee.rs1use std::f32::consts::PI;
2
3use super::{
4 super::{Animation, vek::*},
5 QuadrupedMediumSkeleton, SkeletonAttr, quadruped_medium_alpha, quadruped_medium_beta,
6};
7use common::states::utils::StageSection;
8
9pub struct ComboAnimation;
10impl Animation for ComboAnimation {
11 type Dependency<'a> = (Option<&'a str>, StageSection, usize, f32, f32, f32);
12 type Skeleton = QuadrupedMediumSkeleton;
13
14 #[cfg(feature = "use-dyn-lib")]
15 const UPDATE_FN: &'static [u8] = b"quadruped_medium_combo\0";
16
17 #[cfg_attr(feature = "be-dyn-lib", unsafe(export_name = "quadruped_medium_combo"))]
18 fn update_skeleton_inner(
19 skeleton: &Self::Skeleton,
20 (ability_id, stage_section, current_strike, speed, global_time, timer): Self::Dependency<
21 '_,
22 >,
23 anim_time: f32,
24 rate: &mut f32,
25 s_a: &SkeletonAttr,
26 ) -> Self::Skeleton {
27 *rate = 1.0;
28 let mut next = (*skeleton).clone();
29
30 let _multi_strike_pullback = 1.0
31 - if matches!(stage_section, StageSection::Recover) {
32 anim_time.powi(4)
33 } else {
34 0.0
35 };
36
37 for strike in 0..=current_strike {
38 match ability_id {
39 Some("common.abilities.custom.elephant.gouge") => {
40 let (move1base, move2base, move3base) = match stage_section {
41 StageSection::Buildup => (anim_time, 0.0, 0.0),
42 StageSection::Action => (1.0, anim_time, 0.0),
43 StageSection::Recover => (1.0, 1.0, anim_time),
44 _ => (0.0, 0.0, 0.0),
45 };
46 let move2pullback = 1.0 - move2base;
47 let pullback = 1.0 - move3base;
48 let subtract = global_time - timer;
49 let check = subtract - subtract.trunc();
50 let mirror = (check - 0.5).signum();
51 let move1 = mirror * move1base * pullback;
52 let move2 = mirror * move2base * pullback;
53 let move1abs = move1base * pullback;
54 let move2abs = move2base * pullback;
55
56 if mirror > 0.0 {
57 next.leg_fl
58 .orientation
59 .rotate_x(-PI / 10.0 * move1base * move2pullback);
60 next.foot_fl.position +=
61 Vec3::new(0.0, 0.0, 0.0) * move1base * move2pullback;
62 next.foot_fl
63 .orientation
64 .rotate_x(-PI / 12.0 * move1base * move2pullback);
65 } else {
66 next.leg_fr
67 .orientation
68 .rotate_x(-PI / 10.0 * move1base * move2pullback);
69 next.foot_fr.position +=
70 Vec3::new(0.0, 0.0, 0.0) * move1base * move2pullback;
71 next.foot_fr
72 .orientation
73 .rotate_x(-PI / 12.0 * move1base * move2pullback);
74 }
75 next.head.orientation.rotate_x(-PI / 5.0 * move1abs);
76 next.head.orientation.rotate_y(PI / 8.0 * move1);
77
78 next.head.orientation.rotate_x(PI / 3.0 * move2abs);
79 next.head.orientation.rotate_z(-PI / 3.0 * move2);
80 next.jaw.orientation.rotate_x(PI / 3.0 * move2abs);
81 next.ears.orientation.rotate_x(PI / 6.0 * move2abs);
82 },
83 Some(
84 "common.abilities.custom.frostfang.singlestrike"
85 | "common.abilities.custom.frostfang.triplestrike",
86 ) => {
87 let (movement1base, movement2base, movement3) = match stage_section {
88 StageSection::Buildup => (anim_time.sqrt(), 0.0, 0.0),
89 StageSection::Action => (1.0, anim_time.powi(4), 0.0),
90 StageSection::Recover => (1.0, 1.0, anim_time),
91 _ => (0.0, 0.0, 0.0),
92 };
93 let pullback = 1.0 - movement3;
94 let subtract = global_time - timer;
95 let check = subtract - subtract.trunc();
96 let mirror = (check - 0.5).signum();
97 let twitch3 = (mirror * movement3 * 9.0).sin();
98 let movement1 = mirror * movement1base * pullback;
99 let movement2 = mirror * movement2base * pullback;
100 let movement1abs = movement1base * pullback;
101 let movement2abs = movement2base * pullback;
102
103 match strike {
104 0 | 2 => {
105 next.head.orientation = Quaternion::rotation_z(twitch3 * -0.7);
106
107 next.head.orientation =
108 Quaternion::rotation_x(movement1abs * 0.35 + movement2abs * -0.9)
109 * Quaternion::rotation_y(movement1 * 0.7 + movement2 * -1.0);
110
111 next.jaw.orientation =
112 Quaternion::rotation_x(movement1abs * -0.5 + movement2abs * 0.5);
113 next.torso_front.orientation =
114 Quaternion::rotation_y(movement1 * -0.08 + movement2 * 0.15)
115 * Quaternion::rotation_z(movement1 * -0.2 + movement2 * 0.6);
116
117 next.torso_back.orientation = Quaternion::rotation_x(0.15)
118 * Quaternion::rotation_z(movement1 * -0.4 + movement2 * -0.2);
119
120 next.tail.orientation = Quaternion::rotation_x(-0.12)
121 * Quaternion::rotation_z(movement1 * -0.4 + movement2 * -0.2);
122 },
123 1 => {
124 next.head.orientation = Quaternion::rotation_z(twitch3 * 0.2);
125
126 next.neck.orientation =
127 Quaternion::rotation_x(movement1abs * 0.15 + movement2abs * -0.6)
128 * Quaternion::rotation_y(movement1 * -0.1 + movement2 * 0.15);
129
130 next.jaw.orientation =
131 Quaternion::rotation_x(movement1abs * -0.9 + movement2abs * 0.9);
132 next.torso_front.orientation =
133 Quaternion::rotation_y(movement1 * 0.08 + movement2 * -0.15)
134 * Quaternion::rotation_z(movement1 * 0.2 + movement2 * -0.3);
135
136 next.torso_back.orientation = Quaternion::rotation_x(0.15)
137 * Quaternion::rotation_z(movement1 * 0.4 + movement2 * 0.2);
138
139 next.tail.orientation = Quaternion::rotation_x(-0.12)
140 * Quaternion::rotation_z(movement1 * 0.4 + movement2 * 0.2);
141 },
142 _ => {},
143 }
144 },
145 Some("common.abilities.custom.quadmedbasic.singlestrike") => 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 _ => {},
158 },
159 Some(
160 "common.abilities.custom.quadmedbasic.triplestrike"
161 | "common.abilities.custom.quadmedquick.triplestrike",
162 ) => match strike {
163 0 | 2 => {
164 quadruped_medium_alpha(
165 &mut next,
166 s_a,
167 speed,
168 stage_section,
169 anim_time,
170 global_time,
171 timer,
172 );
173 },
174 1 => {
175 quadruped_medium_beta(
176 &mut next,
177 s_a,
178 speed,
179 stage_section,
180 anim_time,
181 global_time,
182 timer,
183 );
184 },
185 _ => {},
186 },
187 Some(
188 "common.abilities.custom.quadmedcharge.doublestrike"
189 | "common.abilities.custom.quadmedjump.doublestrike"
190 | "common.abilities.custom.roshwalr.doublehusk",
191 ) => match strike {
192 0 => {
193 quadruped_medium_alpha(
194 &mut next,
195 s_a,
196 speed,
197 stage_section,
198 anim_time,
199 global_time,
200 timer,
201 );
202 },
203 1 => {
204 quadruped_medium_beta(
205 &mut next,
206 s_a,
207 speed,
208 stage_section,
209 anim_time,
210 global_time,
211 timer,
212 );
213 },
214 _ => {},
215 },
216 _ => {},
217 }
218 }
219 next
220 }
221}