Arthropod jump attack, hitboxes

This commit is contained in:
Snowram 2021-09-10 02:16:34 +02:00
parent 1e6ead4005
commit 6da42e61ab
8 changed files with 129 additions and 91 deletions

View File

@ -403,17 +403,17 @@ impl Body {
theropod::Species::Yale => Vec3::new(1.5, 3.2, 4.0),
},
Body::Arthropod(body) => match body.species {
arthropod::Species::Tarantula => Vec3::new(2.0, 3.0, 2.6),
arthropod::Species::Blackwidow => Vec3::new(2.0, 3.0, 2.6),
arthropod::Species::Antlion => Vec3::new(2.0, 3.0, 2.6),
arthropod::Species::Hornbeetle => Vec3::new(2.0, 3.0, 2.6),
arthropod::Species::Leafbeetle => Vec3::new(2.0, 3.0, 2.6),
arthropod::Species::Stagbeetle => Vec3::new(2.0, 3.0, 2.6),
arthropod::Species::Weevil => Vec3::new(2.0, 3.0, 2.6),
arthropod::Species::Cavespider => Vec3::new(2.0, 3.0, 2.6),
arthropod::Species::Moltencrawler => Vec3::new(2.0, 3.0, 2.6),
arthropod::Species::Mosscrawler => Vec3::new(2.0, 3.0, 2.6),
arthropod::Species::Sandcrawler => Vec3::new(2.0, 3.0, 2.6),
arthropod::Species::Tarantula => Vec3::new(4.0, 4.0, 1.8),
arthropod::Species::Blackwidow => Vec3::new(4.0, 4.0, 2.0),
arthropod::Species::Antlion => Vec3::new(4.0, 4.0, 2.2),
arthropod::Species::Hornbeetle => Vec3::new(4.0, 4.0, 1.6),
arthropod::Species::Leafbeetle => Vec3::new(4.0, 4.0, 1.6),
arthropod::Species::Stagbeetle => Vec3::new(4.0, 4.0, 1.6),
arthropod::Species::Weevil => Vec3::new(4.0, 4.0, 1.6),
arthropod::Species::Cavespider => Vec3::new(4.0, 4.0, 1.8),
arthropod::Species::Moltencrawler => Vec3::new(4.0, 5.0, 1.9),
arthropod::Species::Mosscrawler => Vec3::new(4.0, 5.0, 1.8),
arthropod::Species::Sandcrawler => Vec3::new(4.0, 5.0, 1.8),
},
}
}

View File

@ -16,27 +16,27 @@ impl Animation for AlphaAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "arthropod_alpha")]
fn update_skeleton_inner<'a>(
skeleton: &Self::Skeleton,
(_velocity, global_time, stage_section, timer): Self::Dependency<'a>,
(_velocity, _global_time, stage_section, _timer): Self::Dependency<'a>,
anim_time: f32,
_rate: &mut f32,
s_a: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let (movement1base, movement2base, movement3) = match stage_section {
let (_movement1base, _movement2base, _movement3) = match stage_section {
Some(StageSection::Buildup) => (anim_time.powi(2), 0.0, 0.0),
Some(StageSection::Action) => (1.0, anim_time.powi(4), 0.0),
Some(StageSection::Recover) => (1.0, 1.0, anim_time),
_ => (0.0, 0.0, 0.0),
};
let pullback = 1.0 - movement3;
let subtract = global_time - timer;
let check = subtract - subtract.trunc();
let mirror = (check - 0.5).signum();
let movement1 = mirror * movement1base * pullback;
let movement2 = mirror * movement2base * pullback;
let movement1abs = movement1base * pullback;
let movement2abs = movement2base * pullback;
//let pullback = 1.0 - movement3;
//let subtract = global_time - timer;
//let check = subtract - subtract.trunc();
//let mirror = (check - 0.5).signum();
//let movement1 = mirror * movement1base * pullback;
//let movement2 = mirror * movement2base * pullback;
//let movement1abs = movement1base * pullback;
//let movement2abs = movement2base * pullback;
next.chest.scale = Vec3::one() / s_a.scaler;

View File

@ -16,7 +16,7 @@ impl Animation for DashAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "arthropod_dash")]
fn update_skeleton_inner<'a>(
skeleton: &Self::Skeleton,
(_velocity, global_time, stage_section, timer): Self::Dependency<'a>,
(_velocity, _global_time, stage_section, _timer): Self::Dependency<'a>,
anim_time: f32,
_rate: &mut f32,
s_a: &SkeletonAttr,
@ -31,21 +31,21 @@ impl Animation for DashAnimation {
_ => (0.0, 0.0, 0.0, 0.0),
};
let pullback = 1.0 - movement3;
let subtract = global_time - timer;
let check = subtract - subtract.trunc();
let mirror = (check - 0.5).signum();
let twitch1 = (mirror * movement1base * 9.5).sin();
let twitch1fast = (mirror * movement1base * 25.0).sin();
//let subtract = global_time - timer;
//let check = subtract - subtract.trunc();
//let mirror = (check - 0.5).signum();
//let twitch1 = (mirror * movement1base * 9.5).sin();
//let twitch1fast = (mirror * movement1base * 25.0).sin();
//let twitch3 = (mirror * movement3 * 4.0).sin();
//let movement1 = mirror * movement1base * pullback;
//let movement2 = mirror * movement2base * pullback;
let movement1abs = movement1base * pullback;
let movement2abs = movement2base * pullback;
let short = ((1.0 / (0.72 + 0.28 * ((anim_time * 16.0_f32 + PI * 0.25).sin()).powi(2)))
.sqrt())
* ((anim_time * 16.0 + PI * 0.25).sin())
* chargemovementbase
* pullback;
//let short = ((1.0 / (0.72 + 0.28 * ((anim_time * 16.0_f32 + PI *
// 0.25).sin()).powi(2))) .sqrt())
// * ((anim_time * 16.0 + PI * 0.25).sin())
// * chargemovementbase
// * pullback;
let shortalt = (anim_time * 200.0 + PI * 0.25).sin() * chargemovementbase * pullback;
next.chest.scale = Vec3::one();

View File

@ -14,8 +14,8 @@ impl Animation for IdleAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "arthropod_idle")]
fn update_skeleton_inner<'a>(
skeleton: &Self::Skeleton,
global_time: Self::Dependency<'a>,
anim_time: f32,
_global_time: Self::Dependency<'a>,
_anim_time: f32,
_rate: &mut f32,
s_a: &SkeletonAttr,
) -> Self::Skeleton {

View File

@ -1,3 +1,5 @@
use std::f32::consts::PI;
use super::{
super::{vek::*, Animation},
ArthropodSkeleton, SkeletonAttr,
@ -16,7 +18,7 @@ impl Animation for LeapMeleeAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "arthropod_leapmelee")]
fn update_skeleton_inner<'a>(
skeleton: &Self::Skeleton,
(_velocity, global_time, stage_section, timer): Self::Dependency<'a>,
(_velocity, _global_time, stage_section, _timer): Self::Dependency<'a>,
anim_time: f32,
_rate: &mut f32,
s_a: &SkeletonAttr,
@ -25,32 +27,43 @@ impl Animation for LeapMeleeAnimation {
//let speed = (Vec2::<f32>::from(velocity).magnitude()).min(24.0);
let (movement1base, movement2base, movement3base, movement4) = match stage_section {
Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0, 0.0),
Some(StageSection::Movement) => (1.0, anim_time, 0.0, 0.0),
Some(StageSection::Action) => (1.0, 1.0, anim_time, 0.0),
Some(StageSection::Buildup) => (anim_time, 0.0, 0.0, 0.0),
Some(StageSection::Movement) => (1.0, anim_time.powf(0.1), 0.0, 0.0),
Some(StageSection::Action) => (1.0, 1.0, anim_time.powf(0.1), 0.0),
Some(StageSection::Recover) => (0.0, 1.0, 1.0, anim_time.powi(4)),
_ => (0.0, 0.0, 0.0, 0.0),
};
let pullback = 1.0 - movement4;
let subtract = global_time - timer;
let check = subtract - subtract.trunc();
let mirror = (check - 0.5).signum();
//let subtract = global_time - timer;
//let check = subtract - subtract.trunc();
//let mirror = (check - 0.5).signum();
let movement1abs = movement1base * pullback;
let movement2abs = movement2base * pullback;
let movement3abs = movement3base * pullback;
let twitch1 = (movement1base * 10.0).sin() * (1.0 - movement2base);
let twitch3 = (movement3base * 5.0).sin() * mirror;
let twitch1abs = twitch1 * mirror;
//let twitch1 = (movement1base * 10.0).sin() * (1.0 - movement2base);
//let twitch3 = (movement3base * 5.0).sin() * mirror;
//let twitch1abs = twitch1 * mirror;
next.chest.scale = Vec3::one() / s_a.scaler;
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.head.orientation =
Quaternion::rotation_x(movement1abs * -0.2 + movement2abs * 0.4 + movement3abs * -1.0)
* Quaternion::rotation_z((movement1abs * 4.0 * PI).sin() * 0.08);
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1);
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + movement1abs * -2.0);
next.chest.orientation = Quaternion::rotation_x(movement2abs * 0.3)
* Quaternion::rotation_z((movement1abs * 4.0 * PI).sin() * 0.08);
next.mandible_l.position = Vec3::new(-s_a.mandible.0, s_a.mandible.1, s_a.mandible.2);
next.mandible_r.position = Vec3::new(s_a.mandible.0, s_a.mandible.1, s_a.mandible.2);
next.mandible_l.orientation = Quaternion::rotation_x(
(movement1abs * 4.0 * PI).sin() * 0.08 + movement2abs * 0.3 + movement3abs * -0.4,
);
next.mandible_r.orientation = Quaternion::rotation_x(
(movement1abs * 4.0 * PI).sin() * 0.08 + movement2abs * 0.3 + movement3abs * -0.4,
);
next.wing_fl.position = Vec3::new(-s_a.wing_f.0, s_a.wing_f.1, s_a.wing_f.2);
next.wing_fr.position = Vec3::new(s_a.wing_f.0, s_a.wing_f.1, s_a.wing_f.2);
@ -60,15 +73,36 @@ impl Animation for LeapMeleeAnimation {
next.leg_fl.position = Vec3::new(-s_a.leg_f.0, s_a.leg_f.1, s_a.leg_f.2);
next.leg_fr.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(movement1abs * 0.2 + movement2abs * -1.0 + movement3abs * 0.8)
* Quaternion::rotation_z(s_a.leg_ori.0);
next.leg_fr.orientation =
Quaternion::rotation_x(movement1abs * 0.2 + movement2abs * -1.0 + movement3abs * 0.8)
* Quaternion::rotation_z(-s_a.leg_ori.0);
next.leg_fcl.position = Vec3::new(-s_a.leg_fc.0, s_a.leg_fc.1, s_a.leg_fc.2);
next.leg_fcr.position = Vec3::new(s_a.leg_fc.0, s_a.leg_fc.1, s_a.leg_fc.2);
next.leg_fcl.orientation =
Quaternion::rotation_y(movement1abs * 0.2 + movement2abs * -1.0 + movement3abs * 0.8)
* Quaternion::rotation_z(s_a.leg_ori.1);
next.leg_fcr.orientation = Quaternion::rotation_y(movement1abs * -0.2 + movement2abs * 1.0)
* Quaternion::rotation_z(-s_a.leg_ori.1);
next.leg_bcl.position = Vec3::new(-s_a.leg_bc.0, s_a.leg_bc.1, s_a.leg_bc.2);
next.leg_bcr.position = Vec3::new(s_a.leg_bc.0, s_a.leg_bc.1, s_a.leg_bc.2);
next.leg_bcl.orientation =
Quaternion::rotation_y(movement1abs * 0.2 + movement2abs * -1.0 + movement3abs * 0.8)
* Quaternion::rotation_z(s_a.leg_ori.2);
next.leg_bcr.orientation = Quaternion::rotation_y(movement1abs * -0.2 + movement2abs * 1.0)
* Quaternion::rotation_z(-s_a.leg_ori.2);
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_bl.orientation =
Quaternion::rotation_y(movement1abs * 0.2 + movement2abs * -1.0 + movement3abs * 0.8)
* Quaternion::rotation_z(s_a.leg_ori.3);
next.leg_br.orientation = Quaternion::rotation_y(movement1abs * -0.2 + movement2abs * 1.0)
* Quaternion::rotation_z(-s_a.leg_ori.3);
next
}

View File

@ -53,7 +53,7 @@ impl Skeleton for ArthropodSkeleton {
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let base_mat = base_mat * Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 4.0);
let base_mat = base_mat * Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 6.0);
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
let head_mat = chest_mat * Mat4::<f32>::from(self.head);
@ -177,17 +177,17 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Sandcrawler, _) => (4.0, -1.0),
},
chest: match (body.species, body.body_type) {
(Tarantula, _) => (-9.0, 6.0),
(Blackwidow, _) => (-9.0, 10.0),
(Antlion, _) => (-9.0, 8.5),
(Hornbeetle, _) => (-9.0, 7.5),
(Leafbeetle, _) => (-9.0, 6.0),
(Stagbeetle, _) => (-9.0, 6.5),
(Weevil, _) => (-9.0, 6.0),
(Cavespider, _) => (-9.0, 7.0),
(Moltencrawler, _) => (-9.0, 6.0),
(Mosscrawler, _) => (-9.0, 6.5),
(Sandcrawler, _) => (-9.0, 6.0),
(Tarantula, _) => (-5.0, 6.0),
(Blackwidow, _) => (-5.0, 10.0),
(Antlion, _) => (-5.0, 8.5),
(Hornbeetle, _) => (-5.0, 7.5),
(Leafbeetle, _) => (-5.0, 6.0),
(Stagbeetle, _) => (-5.0, 6.5),
(Weevil, _) => (-5.0, 6.0),
(Cavespider, _) => (-5.0, 7.0),
(Moltencrawler, _) => (-7.0, 6.0),
(Mosscrawler, _) => (-7.0, 6.5),
(Sandcrawler, _) => (-7.0, 6.0),
},
mandible: match (body.species, body.body_type) {
(Tarantula, _) => (1.5, 7.0, -0.5),

View File

@ -15,46 +15,50 @@ impl Animation for RunAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "arthropod_run")]
fn update_skeleton_inner<'a>(
skeleton: &Self::Skeleton,
(velocity, orientation, last_ori, _global_time, avg_vel, acc_vel): Self::Dependency<'a>,
(_velocity, _orientation, _last_ori, _global_time, _avg_vel, acc_vel): Self::Dependency<'a>,
anim_time: f32,
rate: &mut f32,
s_a: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let speed = (Vec2::<f32>::from(velocity).magnitude()).min(22.0);
//let speed = (Vec2::<f32>::from(velocity).magnitude()).min(22.0);
*rate = 1.0;
//let speednorm = speed / 13.0;
let speednorm = (speed / 13.0).powf(0.25);
//let speednorm = (speed / 13.0).powf(0.25);
let mixed_vel = (acc_vel + anim_time * 6.0) * 0.8; //sets run frequency using speed, with anim_time setting a floor
let speedmult = 1.0;
let lab: f32 = 0.6; //6
//let speedmult = 1.0;
//let lab: f32 = 0.6; //6
let short = ((1.0
/ (0.72
+ 0.28 * ((mixed_vel * 1.0 * lab * speedmult + PI * -0.15 - 0.5).sin()).powi(2)))
.sqrt())
* ((mixed_vel * 1.0 * lab * speedmult + PI * -0.15 - 0.5).sin())
* speednorm;
//let short = ((1.0
// / (0.72
// + 0.28 * ((mixed_vel * 1.0 * lab * speedmult + PI * -0.15 -
// 0.5).sin()).powi(2)))
//.sqrt())
//
// * ((mixed_vel * 1.0 * lab * speedmult + PI * -0.15 - 0.5).sin())
// * speednorm;
//
let shortalt = (mixed_vel * 1.0 * lab * speedmult + PI * 3.0 / 8.0 - 0.5).sin() * speednorm;
//let shortalt = (mixed_vel * 1.0 * lab * speedmult + PI * 3.0 / 8.0 -
// 0.5).sin() * speednorm;
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()
&& ori.angle_between(last_ori).is_finite()
{
ori.angle_between(last_ori).min(0.2)
* last_ori.determine_side(Vec2::zero(), ori).signum()
} else {
0.0
} * 1.3;
let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude()) * speednorm;
//let ori: Vec2<f32> = Vec2::from(orientation);
//let last_ori = Vec2::from(last_ori);
//let tilt = if ::vek::Vec2::new(ori, last_ori)
// .map(|o| o.magnitude_squared())
// .map(|m| m > 0.001 && m.is_finite())
// .reduce_and()
// && ori.angle_between(last_ori).is_finite()
//{
// ori.angle_between(last_ori).min(0.2)
// * last_ori.determine_side(Vec2::zero(), ori).signum()
//} else {
// 0.0
//}
//} * 1.3;
//let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude()) * speednorm;
next.chest.scale = Vec3::one() / s_a.scaler;
next.wing_bl.scale = Vec3::one() * 0.98;

View File

@ -17,26 +17,26 @@ impl Animation for StunnedAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "arthropod_stunned")]
fn update_skeleton_inner<'a>(
skeleton: &Self::Skeleton,
(_velocity, global_time, stage_section, timer): Self::Dependency<'a>,
(_velocity, _global_time, stage_section, _timer): Self::Dependency<'a>,
anim_time: f32,
_rate: &mut f32,
s_a: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let (movement1base, movement2, twitch) = match stage_section {
let (_movement1base, _movement2, _twitch) = match stage_section {
Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0),
Some(StageSection::Recover) => {
(1.0, anim_time.powf(3.0), ((1.0 - anim_time) * 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();
let movement1 = mirror * movement1base * pullback;
let movement1abs = movement1base * pullback;
//let pullback = 1.0 - movement2;
//let subtract = global_time - timer;
//let check = subtract - subtract.trunc();
//let mirror = (check - 0.5).signum();
//let movement1 = mirror * movement1base * pullback;
//let movement1abs = movement1base * pullback;
next.chest.scale = Vec3::one() / s_a.scaler;