Merge branch 'james/rock-snapper' into 'master'

Better Rocksnapper Abilities and Moveset

See merge request veloren/veloren!4454
This commit is contained in:
Samuel Keiffer 2024-05-15 02:37:33 +00:00
commit dcce436483
19 changed files with 530 additions and 53 deletions

View File

@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Recipe for orichalcum ingots changed to use new alchemical ingredients
- Refresh of voxel models for orichalcum armour
- Toned down the health of most wild entities.
- Rocksnapper received new abilities and AI
### Removed

View File

@ -535,6 +535,13 @@
secondary: Simple(None, "common.abilities.custom.quadlowbasic.singlestrike"),
abilities: [],
),
Custom("Rocksnapper"): (
primary: Simple(None, "common.abilities.custom.rocksnapper.triplestrike"),
secondary: Simple(None, "common.abilities.custom.rocksnapper.dash"),
abilities: [
Simple(None, "common.abilities.custom.rocksnapper.leapshockwave"),
],
),
Custom("Quad Low Beam"): (
primary: Simple(None, "common.abilities.custom.quadlowbeam.lifestealbeam"),
secondary: Simple(None, "common.abilities.custom.quadlowbreathe.triplestrike"),

View File

@ -0,0 +1,28 @@
DashMelee(
energy_cost: 0,
melee_constructor: (
kind: Bash(
damage: 16.0,
poise: 0.0,
knockback: 4.0,
energy_regen: 0.0,
),
scaled: Some((
kind: Bash(
damage: 36.0,
poise: 8.0,
knockback: 23.0,
energy_regen: 0.0,
))),
range: 2.5,
angle: 360.0,
),
energy_drain: 0,
forward_speed: 5.0,
buildup_duration: 1.0,
charge_duration: 2.0,
swing_duration: 2.0,
recover_duration: 0.5,
ori_modifier: 0.3,
auto_charge: true,
)

View File

@ -0,0 +1,21 @@
LeapShockwave(
energy_cost: 0,
buildup_duration: 1.4,
movement_duration: 0.8,
swing_duration: 0.15,
recover_duration: 2.0,
damage: 15.0,
poise_damage: 10,
knockback: (strength: 15.0, direction: Up),
shockwave_angle: 360.0,
shockwave_vertical_angle: 15.0,
shockwave_speed: 15.0,
shockwave_duration: 1.5,
dodgeable: Jump,
move_efficiency: 0.2,
damage_kind: Crushing,
specifier: Ground,
damage_effect: None,
forward_leap_strength: 13.0,
vertical_leap_strength: 7.0,
)

View File

@ -0,0 +1,65 @@
ComboMelee2(
strikes: [
(
melee_constructor: (
kind: Slash(
damage: 36,
poise: 24,
knockback: 3,
energy_regen: 0,
),
range: 4.0,
angle: 30.0,
),
buildup_duration: 0.75,
swing_duration: 0.45,
hit_timing: 0.5,
recover_duration: 0.4,
movement: (
swing: Some(Forward(0.4)),
),
ori_modifier: 0.65,
),
(
melee_constructor: (
kind: Stab(
damage: 18,
poise: 18,
knockback: 15,
energy_regen: 0,
),
range: 3.5,
angle: 75.0,
),
buildup_duration: 0.35,
swing_duration: 0.35,
hit_timing: 0.5,
recover_duration: 0.3,
movement: (
swing: Some(Forward(0.2)),
),
ori_modifier: 0.65,
),
(
melee_constructor: (
kind: Bash(
damage: 28,
poise: 36,
knockback: 3,
energy_regen: 0,
),
range: 3.0,
angle: 55.0,
),
buildup_duration: 0.55,
swing_duration: 0.25,
hit_timing: 0.5,
recover_duration: 0.6,
movement: (
swing: Some(Forward(0.3)),
),
ori_modifier: 0.65,
),
],
energy_cost_per_strike: 0,
)

View File

@ -2676,6 +2676,9 @@
Simple(
"common.items.npc_weapons.unique.darkhound",
): "common-items-npc_weapons-unique-darkhound",
Simple(
"common.items.npc_weapons.unique.rocksnapper",
): "common-items-npc_weapons-unique-rocksnapper",
Simple(
"common.items.npc_weapons.unique.roshwalr",
): "common-items-npc_weapons-unique-roshwalr",

View File

@ -0,0 +1,20 @@
ItemDef(
legacy_name: "Rocksnapper",
legacy_description: "Rocksnapper's totally awesome legacy description",
kind: Tool((
kind: Natural,
hands: Two,
stats: (
equip_time_secs: 0.01,
power: 1.0,
effect_power: 1.0,
speed: 1.0,
range: 1.0,
energy_efficiency: 1.0,
buff_strength: 1.0,
),
)),
quality: Low,
tags: [],
ability_spec: Some(Custom("Rocksnapper")),
)

View File

@ -283,6 +283,9 @@ common-items-npc_weapons-unique-quadsmallbasic = Quad Small Basic
common-items-npc_weapons-unique-darkhound = Darkhound
.desc = testing123
common-items-npc_weapons-unique-rocksnapper = Rocksnapper
.desc = testing123
common-items-npc_weapons-unique-roshwalr = Roshwalr
.desc = testing123

View File

@ -686,6 +686,9 @@ fn default_main_tool(body: &Body) -> Item {
quadruped_low::Species::Driggle => Some(Item::new_from_asset_expect(
"common.items.npc_weapons.unique.driggle",
)),
quadruped_low::Species::Rocksnapper => Some(Item::new_from_asset_expect(
"common.items.npc_weapons.unique.rocksnapper",
)),
_ => Some(Item::new_from_asset_expect(
"common.items.npc_weapons.unique.quadlowbasic",
)),

View File

@ -1097,6 +1097,7 @@ impl<'a> AgentData<'a> {
"Quad Med Basic" => Tactic::QuadMedBasic,
"Quad Med Hoof" => Tactic::QuadMedHoof,
"ClaySteed" => Tactic::ClaySteed,
"Rocksnapper" => Tactic::Rocksnapper,
"Roshwalr" => Tactic::Roshwalr,
"Asp" | "Maneater" => Tactic::QuadLowRanged,
"Quad Low Breathe" | "Quad Low Beam" | "Basilisk" => {
@ -1473,6 +1474,9 @@ impl<'a> AgentData<'a> {
tgt_data,
read_data,
),
Tactic::Rocksnapper => {
self.handle_rocksnapper_attack(agent, controller, &attack_data, tgt_data, read_data)
},
Tactic::Roshwalr => {
self.handle_roshwalr_attack(agent, controller, &attack_data, tgt_data, read_data)
},

View File

@ -4579,6 +4579,74 @@ impl<'a> AgentData<'a> {
);
}
pub fn handle_rocksnapper_attack(
&self,
agent: &mut Agent,
controller: &mut Controller,
attack_data: &AttackData,
tgt_data: &TargetData,
read_data: &ReadData,
) {
const LEAP_TIMER: f32 = 3.0;
const DASH_TIMER: f32 = 5.0;
const LEAP_RANGE: f32 = 20.0;
const MELEE_RANGE: f32 = 5.0;
enum ActionStateTimers {
TimerRocksnapperDash = 0,
TimerRocksnapperLeap = 1,
}
agent.combat_state.timers[ActionStateTimers::TimerRocksnapperDash as usize] +=
read_data.dt.0;
agent.combat_state.timers[ActionStateTimers::TimerRocksnapperLeap as usize] +=
read_data.dt.0;
if matches!(self.char_state, CharacterState::DashMelee(c) if !matches!(c.stage_section, StageSection::Recover))
{
// If already dashing, keep dashing if not in recover stage
controller.push_basic_input(InputKind::Secondary);
} else if agent.combat_state.timers[ActionStateTimers::TimerRocksnapperDash as usize]
> DASH_TIMER
{
// Use dash if timer has gone for long enough
controller.push_basic_input(InputKind::Secondary);
if matches!(self.char_state, CharacterState::DashMelee(_)) {
// Resets action counter when using dash
agent.combat_state.timers[ActionStateTimers::TimerRocksnapperDash as usize] = 0.0;
}
} else if attack_data.dist_sqrd < LEAP_RANGE.powi(2) && attack_data.angle < 90.0 {
if agent.combat_state.timers[ActionStateTimers::TimerRocksnapperLeap as usize]
> LEAP_TIMER
{
// Use shockwave if timer has gone for long enough
controller.push_basic_input(InputKind::Ability(0));
if matches!(self.char_state, CharacterState::LeapShockwave(_)) {
// Resets action timer when using leap shockwave
agent.combat_state.timers[ActionStateTimers::TimerRocksnapperLeap as usize] =
0.0;
}
} else if attack_data.dist_sqrd < MELEE_RANGE.powi(2) {
// Basic attack if in melee range
controller.push_basic_input(InputKind::Primary);
}
} else if attack_data.dist_sqrd < MELEE_RANGE.powi(2) && attack_data.angle < 135.0 {
// Basic attack if in melee range
controller.push_basic_input(InputKind::Primary);
}
// Always attempt to path towards target
self.path_toward_target(
agent,
controller,
tgt_data.pos.0,
read_data,
Path::Partial,
None,
);
}
pub fn handle_roshwalr_attack(
&self,
agent: &mut Agent,

View File

@ -248,6 +248,7 @@ pub enum Tactic {
Snaretongue,
Cardinal,
SeaBishop,
Rocksnapper,
Roshwalr,
FrostGigas,
BorealHammer,

View File

@ -66,6 +66,7 @@ pub mod quadruped_medium;
pub mod quadruped_small;
pub mod ship;
pub mod theropod;
pub mod util;
pub mod vek;
use self::vek::*;

View File

@ -113,7 +113,8 @@ impl Animation for ComboAnimation {
"common.abilities.custom.basilisk.triplestrike"
| "common.abilities.custom.quadlowbasic.triplestrike"
| "common.abilities.custom.quadlowbreathe.triplestrike"
| "common.abilities.custom.quadlowtail.triplestrike",
| "common.abilities.custom.quadlowtail.triplestrike"
| "common.abilities.custom.rocksnapper.triplestrike",
) => match strike {
0 | 2 => {
quadruped_low_alpha(

View File

@ -1,5 +1,9 @@
use super::{
super::{vek::*, Animation},
super::{
util::{bounce, elastic},
vek::*,
Animation,
},
QuadrupedLowSkeleton, SkeletonAttr,
};
use common::states::utils::StageSection;
@ -9,7 +13,7 @@ use std::f32::consts::PI;
pub struct DashAnimation;
impl Animation for DashAnimation {
type Dependency<'a> = (f32, f32, Option<StageSection>, f32);
type Dependency<'a> = (Option<&'a str>, f32, f32, Option<StageSection>, f32);
type Skeleton = QuadrupedLowSkeleton;
#[cfg(feature = "use-dyn-lib")]
@ -18,64 +22,133 @@ impl Animation for DashAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_low_dash")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_velocity, global_time, stage_section, timer): Self::Dependency<'_>,
(ability_id, _velocity, global_time, stage_section, timer): Self::Dependency<'_>,
anim_time: f32,
_rate: &mut f32,
_s_a: &SkeletonAttr,
s_a: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let (movement1base, chargemovementbase, movement2base, movement3) = match stage_section {
Some(StageSection::Buildup) => (anim_time.sqrt(), 0.0, 0.0, 0.0),
Some(StageSection::Charge) => (1.0, 1.0, 0.0, 0.0),
Some(StageSection::Action) => (1.0, 1.0, anim_time.powi(4), 0.0),
Some(StageSection::Recover) => (1.0, 1.0, 1.0, anim_time),
_ => (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 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_f32 + PI * 0.25).sin())
* chargemovementbase
* pullback;
let shortalt = (anim_time * 16.0_f32 + PI * 0.25).sin() * chargemovementbase * pullback;
match ability_id {
Some("common.abilities.custom.rocksnapper.dash") => {
let (buildup, charge, _action, recover) = match stage_section {
Some(StageSection::Buildup) => (anim_time, 0.0, 0.0, 0.0),
Some(StageSection::Charge) => (1.0, anim_time, 0.0, 0.0),
Some(StageSection::Action) => (1.0, 1.0, anim_time, 0.0),
Some(StageSection::Recover) => (1.0, 1.0, 1.0, anim_time),
_ => (0.0, 0.0, 0.0, 0.0),
};
let quick_buildup = buildup.powf(0.2);
let elastic_recover = elastic(recover);
next.head_upper.position = Vec3::new(
0.0,
s_a.head_upper.0 + (-1.0 * quick_buildup + elastic_recover) * 10.0,
s_a.head_upper.1,
);
next.head_upper.scale = Vec3::one() * (1.0 - buildup + elastic_recover);
next.head_lower.position = Vec3::new(
0.0,
s_a.head_lower.0 + (-1.0 * quick_buildup + elastic_recover) * 10.0,
s_a.head_lower.1,
);
next.head_lower.scale = Vec3::one() * (1.0 - buildup + elastic_recover);
next.foot_fl.position = Vec3::new(
-s_a.feet_f.0 + (quick_buildup - elastic_recover) * 8.0,
s_a.feet_f.1 + (-1.0 * quick_buildup + elastic_recover) * 8.0,
s_a.feet_f.2 + (quick_buildup - elastic_recover) * 8.0,
);
next.foot_fl.scale = Vec3::one() * (1.0 - buildup + elastic_recover);
next.foot_fr.position = Vec3::new(
s_a.feet_f.0 - (quick_buildup - elastic_recover) * 8.0,
s_a.feet_f.1 + (-1.0 * quick_buildup + elastic_recover) * 8.0,
s_a.feet_f.2 + (quick_buildup - elastic_recover) * 8.0,
);
next.foot_fr.scale = Vec3::one() * (1.0 - buildup + elastic_recover);
next.foot_bl.position = Vec3::new(
-s_a.feet_b.0 + (quick_buildup - elastic_recover) * 8.0,
s_a.feet_b.1 + (quick_buildup - elastic_recover) * 8.0,
s_a.feet_b.2 + (quick_buildup - elastic_recover) * 8.0,
);
next.foot_bl.scale = Vec3::one() * (1.0 - buildup + elastic_recover);
next.foot_br.position = Vec3::new(
s_a.feet_b.0 - (quick_buildup - elastic_recover) * 8.0,
s_a.feet_b.1 + (quick_buildup - elastic_recover) * 8.0,
s_a.feet_b.2 + (quick_buildup - elastic_recover) * 8.0,
);
next.foot_br.scale = Vec3::one() * (1.0 - buildup + elastic_recover);
next.tail_front.position = Vec3::new(
0.0,
s_a.tail_front.0 + (quick_buildup - elastic_recover) * 20.0,
s_a.tail_front.1,
);
next.tail_front.scale = Vec3::one() * (1.0 - buildup + elastic_recover);
next.tail_rear.position = Vec3::new(
0.0,
s_a.tail_rear.0 + (quick_buildup - elastic_recover) * 20.0,
s_a.tail_rear.1,
);
next.tail_rear.scale = Vec3::one() * (1.0 - buildup + recover);
next.head_upper.orientation =
Quaternion::rotation_x(movement1abs * 0.4 + movement2abs * 0.3)
* Quaternion::rotation_z(short * -0.06 + twitch1 * -0.3);
next.chest.position = Vec3::new(
0.0,
0.0,
s_a.chest.1 - bounce(buildup) * 5.0 + elastic(recover) * 5.0,
);
next.chest.orientation =
Quaternion::rotation_z(2.0 * PI * buildup + 4.0 * PI * charge);
},
_ => {
let (buildup, chargemovementbase, action, recover) = match stage_section {
Some(StageSection::Buildup) => (anim_time.sqrt(), 0.0, 0.0, 0.0),
Some(StageSection::Charge) => (1.0, 1.0, 0.0, 0.0),
Some(StageSection::Action) => (1.0, 1.0, anim_time.powi(4), 0.0),
Some(StageSection::Recover) => (1.0, 1.0, 1.0, anim_time),
_ => (0.0, 0.0, 0.0, 0.0),
};
let pullback = 1.0 - recover;
let subtract = global_time - timer;
let check = subtract - subtract.trunc();
let mirror = (check - 0.5).signum();
let twitch1 = (mirror * buildup * 9.5).sin();
let twitch1fast = (mirror * buildup * 25.0).sin();
let buildup_abs = buildup * pullback;
let action_abs = action * 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_f32 + PI * 0.25).sin())
* chargemovementbase
* pullback;
let shortalt =
(anim_time * 16.0_f32 + PI * 0.25).sin() * chargemovementbase * pullback;
next.head_lower.orientation =
Quaternion::rotation_x(movement1abs * -0.4 + movement2abs * -0.5)
* Quaternion::rotation_z(short * 0.15 + twitch1 * 0.3);
next.head_upper.orientation =
Quaternion::rotation_x(buildup_abs * 0.4 + action_abs * 0.3)
* Quaternion::rotation_z(short * -0.06 + twitch1 * -0.3);
next.jaw.orientation = Quaternion::rotation_x(
twitch1fast * 0.2
+ movement1abs * -0.3
+ movement2abs * 1.2
+ chargemovementbase * -0.5,
);
next.chest.orientation =
Quaternion::rotation_z(twitch1 * 0.06) * Quaternion::rotation_y(short * 0.06);
next.head_lower.orientation =
Quaternion::rotation_x(buildup_abs * -0.4 + action_abs * -0.5)
* Quaternion::rotation_z(short * 0.15 + twitch1 * 0.3);
next.tail_front.orientation = Quaternion::rotation_x(
0.15 + movement1abs * -0.4 + movement2abs * 0.2 + chargemovementbase * 0.2,
) * Quaternion::rotation_z(shortalt * 0.15);
next.jaw.orientation = Quaternion::rotation_x(
twitch1fast * 0.2
+ buildup_abs * -0.3
+ action_abs * 1.2
+ chargemovementbase * -0.5,
);
next.chest.orientation =
Quaternion::rotation_z(twitch1 * 0.06) * Quaternion::rotation_y(short * 0.06);
next.tail_rear.orientation =
Quaternion::rotation_x(
-0.12 + movement1abs * -0.4 + movement2abs * 0.2 + chargemovementbase * 0.2,
) * Quaternion::rotation_z(shortalt * 0.15 + twitch1fast * 0.3);
next.tail_front.orientation = Quaternion::rotation_x(
0.15 + buildup_abs * -0.4 + action_abs * 0.2 + chargemovementbase * 0.2,
) * Quaternion::rotation_z(shortalt * 0.15);
next.tail_rear.orientation =
Quaternion::rotation_x(
-0.12 + buildup_abs * -0.4 + action_abs * 0.2 + chargemovementbase * 0.2,
) * Quaternion::rotation_z(shortalt * 0.15 + twitch1fast * 0.3);
},
}
next
}
}

View File

@ -0,0 +1,117 @@
use super::{
super::{
util::{elastic, out_and_in},
vek::*,
Animation,
},
QuadrupedLowSkeleton, SkeletonAttr,
};
use common::states::utils::StageSection;
use core::f32::consts::PI;
pub struct LeapShockAnimation;
impl Animation for LeapShockAnimation {
type Dependency<'a> = (Option<&'a str>, Vec3<f32>, f32, Option<StageSection>);
type Skeleton = QuadrupedLowSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"quadruped_low_leapshockwave\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_low_leapshockwave")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(ability_id, _velocity, _global_time, stage_section): Self::Dependency<'_>,
anim_time: f32,
_rate: &mut f32,
s_a: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let (buildup, movement, action, recover) = match stage_section {
Some(StageSection::Buildup) => (anim_time, 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::Recover) => (1.0, 1.0, 1.0, anim_time),
_ => (0.0, 0.0, 0.0, 0.0),
};
match ability_id {
Some("common.abilities.custom.rocksnapper.leapshockwave") => {
let elastic_recover = elastic(recover);
next.head_upper.scale = Vec3::one() * (1.0 - movement + elastic_recover);
next.head_upper.position = Vec3::new(
0.0,
s_a.head_upper.0 + (-1.0 * movement + elastic_recover) * 10.0,
s_a.head_upper.1,
);
next.head_lower.scale = Vec3::one() * (1.0 - movement + elastic_recover);
next.head_lower.position = Vec3::new(
0.0,
s_a.head_lower.0 + (-1.0 * movement + elastic_recover) * 15.0,
s_a.head_lower.1,
);
next.tail_front.scale = Vec3::one() * (1.0 - movement + elastic_recover);
next.tail_rear.position = Vec3::new(
0.0,
s_a.tail_rear.0 + (movement - elastic_recover) * 20.0,
s_a.tail_rear.1,
);
next.tail_rear.scale = Vec3::one() * (1.0 - movement + recover);
next.foot_fl.scale = Vec3::one() * (1.0 - movement + elastic_recover);
next.foot_fl.position = Vec3::new(
-s_a.feet_f.0 + (movement - elastic_recover) * 8.0,
s_a.feet_f.1 + (-1.0 * movement + elastic_recover) * 8.0,
s_a.feet_f.2 - out_and_in(buildup) * 15.0 + (movement - elastic_recover) * 8.0,
);
next.foot_fr.scale = Vec3::one() * (1.0 - movement + elastic_recover);
next.foot_fr.position = Vec3::new(
s_a.feet_f.0 - (movement - elastic_recover) * 8.0,
s_a.feet_f.1 - (movement - elastic_recover) * 8.0,
s_a.feet_f.2 - out_and_in(buildup) * 15.0 + (movement - elastic_recover) * 8.0,
);
next.foot_bl.scale = Vec3::one() * (1.0 - movement + elastic_recover);
next.foot_bl.position = Vec3::new(
-s_a.feet_b.0 + (movement - elastic_recover) * 8.0,
s_a.feet_b.1 + (movement - elastic_recover) * 8.0,
s_a.feet_b.2 - out_and_in(buildup) * 15.0 + (movement - elastic_recover) * 8.0,
);
next.foot_br.scale = Vec3::one() * (1.0 - movement + elastic_recover);
next.foot_br.position = Vec3::new(
s_a.feet_b.0 - (movement - elastic_recover) * 8.0,
s_a.feet_b.1 + (movement - elastic_recover) * 8.0,
s_a.feet_b.2 - out_and_in(buildup) * 15.0 + (movement - elastic_recover) * 8.0,
);
next.chest.position = Vec3::new(
0.0,
0.0,
s_a.chest.1
+ out_and_in(buildup) * 15.0
+ ((action - 1.0).powi(2) - 1.0) * 15.0
+ elastic_recover * 15.0,
);
next.chest.orientation = Quaternion::rotation_z(4.0 * PI * movement);
},
_ => {
let (movement1base, movement2base, _movement3base, movement4) = match stage_section
{
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 movement1abs = movement1base * pullback;
let movement2abs = movement2base * pullback;
next.chest.scale = Vec3::one() * s_a.scaler;
next.chest.position =
Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + movement1abs * -0.25);
next.chest.orientation = Quaternion::rotation_x(movement2abs * 0.15)
* Quaternion::rotation_z((movement1abs * 4.0 * PI).sin() * 0.08);
},
}
next
}
}

View File

@ -4,6 +4,7 @@ pub mod combomelee;
pub mod dash;
pub mod idle;
pub mod jump;
pub mod leapshockwave;
pub mod run;
pub mod shockwave;
pub mod shoot;
@ -14,9 +15,10 @@ pub mod tailwhip;
// Reexports
pub use self::{
beta::BetaAnimation, breathe::BreatheAnimation, combomelee::ComboAnimation,
dash::DashAnimation, idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation,
shockwave::ShockwaveAnimation, shoot::ShootAnimation, spritesummon::SpriteSummonAnimation,
stunned::StunnedAnimation, tailwhip::TailwhipAnimation,
dash::DashAnimation, idle::IdleAnimation, jump::JumpAnimation,
leapshockwave::LeapShockAnimation, run::RunAnimation, shockwave::ShockwaveAnimation,
shoot::ShootAnimation, spritesummon::SpriteSummonAnimation, stunned::StunnedAnimation,
tailwhip::TailwhipAnimation,
};
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};

33
voxygen/anim/src/util.rs Normal file
View File

@ -0,0 +1,33 @@
use std::f32::consts::PI;
// Useful easing functions
// Source: https://easings.net/
pub fn bounce(x: f32) -> f32 {
if x < (1.0 / 2.75) {
7.5625 * x.powi(2)
} else if x < (2.0 / 2.75) {
7.5625 * (x - (1.5 / 2.75)).powi(2) + 0.75
} else if x < (2.5 / 2.75) {
7.5625 * (x - (2.25 / 2.75)).powi(2) + 0.9375
} else {
7.5625 * (x - (2.625 / 2.75)).powi(2) + 0.984375
}
}
// Source: https://easings.net/
pub fn elastic(x: f32) -> f32 {
fn f(x: f32, a: f32, b: f32) -> f32 {
let p = 0.8;
b + a * 2.0_f32.powf(a * 10.0 * x) * ((4.0 * PI * x) / p).cos()
}
f(x, -1.0, 1.0) / f(1.0, -1.0, 1.0)
}
// Source: https://easings.net/
pub fn ease_in_back(x: f32) -> f32 {
let a = 1.70158;
let b = a + 1.0;
b * x.powi(3) - a * x.powi(2)
}
pub fn out_and_in(x: f32) -> f32 { (x - 0.5).powi(2) - 0.25 }

View File

@ -3098,6 +3098,7 @@ impl FigureMgr {
anim::quadruped_low::DashAnimation::update_skeleton(
&target_base,
(
ability_id,
rel_vel.magnitude(),
time,
Some(s.stage_section),
@ -3108,6 +3109,31 @@ impl FigureMgr {
skeleton_attr,
)
},
CharacterState::LeapShockwave(s) => {
let stage_time = s.timer.as_secs_f32();
let stage_progress = match s.stage_section {
StageSection::Buildup => {
stage_time / s.static_data.buildup_duration.as_secs_f32()
},
StageSection::Movement => {
stage_time / s.static_data.buildup_duration.as_secs_f32()
},
StageSection::Action => {
stage_time / s.static_data.swing_duration.as_secs_f32()
},
StageSection::Recover => {
stage_time / s.static_data.recover_duration.as_secs_f32()
},
_ => 0.0,
};
anim::quadruped_low::LeapShockAnimation::update_skeleton(
&target_base,
(ability_id, rel_vel, time, Some(s.stage_section)),
stage_progress,
&mut state_animation_rate,
skeleton_attr,
)
},
// TODO!
_ => target_base,
};