mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
animal stuns
Fix rebase
This commit is contained in:
parent
661764f4aa
commit
d456271921
@ -155,7 +155,7 @@ impl Damage {
|
||||
HealthChange {
|
||||
amount: -damage as i32,
|
||||
cause: HealthSource::World,
|
||||
},
|
||||
}
|
||||
},
|
||||
DamageSource::Buff(_) => HealthChange {
|
||||
amount: -damage as i32,
|
||||
|
@ -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",
|
||||
|
@ -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();
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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};
|
||||
|
60
voxygen/anim/src/quadruped_low/stunned.rs
Normal file
60
voxygen/anim/src/quadruped_low/stunned.rs
Normal file
@ -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<StageSection>, 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
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
||||
|
@ -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};
|
||||
|
91
voxygen/anim/src/quadruped_medium/stunned.rs
Normal file
91
voxygen/anim/src/quadruped_medium/stunned.rs
Normal file
@ -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<StageSection>, 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
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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};
|
||||
|
70
voxygen/anim/src/quadruped_small/stunned.rs
Normal file
70
voxygen/anim/src/quadruped_small/stunned.rs
Normal file
@ -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<StageSection>, 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
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user