diff --git a/.cargo/config b/.cargo/config index 89c3d55c3a..e78c87c91f 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,6 +1,6 @@ [target.x86_64-unknown-linux-gnu] rustflags = [ - "-C", "link-arg=-fuse-ld=mold", + "-C", "link-arg=-fuse-ld=gold", ] [target.x86_64-pc-windows-gnu] diff --git a/CHANGELOG.md b/CHANGELOG.md index cec261f3bb..7daf566c18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/assets/common/abilities/ability_set_manifest.ron b/assets/common/abilities/ability_set_manifest.ron index 3ada6d0154..215868a1c0 100644 --- a/assets/common/abilities/ability_set_manifest.ron +++ b/assets/common/abilities/ability_set_manifest.ron @@ -536,10 +536,10 @@ abilities: [], ), Custom("Rocksnapper"): ( - primary: Simple(None, "common.abilities.custom.rocksnapper.triplestrike"), - secondary: Simple(None, "common.abilities.custom.rocksnapper.singlestrike"), + primary: Simple(None, "common.abilities.custom.rocksnapper.dash"), + secondary: Simple(None, "common.abilities.custom.rocksnapper.leapshockwave"), abilities: [ - Simple(None, "common.abilities.custom.rocksnapper.dash"), + Simple(None, "common.abilities.custom.rocksnapper.triplestrike"), ], ), Custom("Quad Low Beam"): ( diff --git a/assets/common/abilities/custom/rocksnapper/dash.ron b/assets/common/abilities/custom/rocksnapper/dash.ron index eea0872892..aaac7a6f58 100644 --- a/assets/common/abilities/custom/rocksnapper/dash.ron +++ b/assets/common/abilities/custom/rocksnapper/dash.ron @@ -24,5 +24,5 @@ DashMelee( swing_duration: 2.0, recover_duration: 0.5, ori_modifier: 0.3, - charge_through: true, + auto_charge: true, ) diff --git a/assets/common/abilities/custom/rocksnapper/leapshockwave.ron b/assets/common/abilities/custom/rocksnapper/leapshockwave.ron new file mode 100644 index 0000000000..e6c2956084 --- /dev/null +++ b/assets/common/abilities/custom/rocksnapper/leapshockwave.ron @@ -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, +) diff --git a/assets/common/abilities/custom/rocksnapper/singlestrike.ron b/assets/common/abilities/custom/rocksnapper/singlestrike.ron deleted file mode 100644 index fd8b7ae6f6..0000000000 --- a/assets/common/abilities/custom/rocksnapper/singlestrike.ron +++ /dev/null @@ -1,25 +0,0 @@ -ComboMelee2( - strikes: [ - ( - melee_constructor: ( - kind: Bash( - damage: 36, - poise: 28, - knockback: 3, - energy_regen: 0, - ), - range: 3.0, - angle: 90.0, - ), - buildup_duration: 0.5, - swing_duration: 0.2, - hit_timing: 0.5, - recover_duration: 0.5, - movement: ( - swing: Some(Forward(0.1)), - ), - ori_modifier: 0.6, - ), - ], - energy_cost_per_strike: 0, -) diff --git a/server/agent/src/action_nodes.rs b/server/agent/src/action_nodes.rs index c46bd790de..56e5edde46 100644 --- a/server/agent/src/action_nodes.rs +++ b/server/agent/src/action_nodes.rs @@ -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) }, diff --git a/server/agent/src/attack.rs b/server/agent/src/attack.rs index 688cae91ef..d1e11832e6 100644 --- a/server/agent/src/attack.rs +++ b/server/agent/src/attack.rs @@ -4579,6 +4579,77 @@ 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 ActionStateFCounters { + FCounterRocksnapperDash = 0, + FCounterRocksnapperLeap = 1, + } + + agent.combat_state.counters[ActionStateFCounters::FCounterRocksnapperDash as usize] += + read_data.dt.0; + agent.combat_state.counters[ActionStateFCounters::FCounterRocksnapperLeap as usize] += + read_data.dt.0; + + if matches!(self.char_state, CharacterState::DashMelee(c) if !matches!(c.stage_section, StageSection::Recover)) + { + // If already charging, keep charging if not in recover + controller.push_basic_input(InputKind::Primary); + } else if agent.combat_state.counters + [ActionStateFCounters::FCounterRocksnapperDash as usize] + > DASH_TIMER + { + // Use dash if timer has gone for long enough + controller.push_basic_input(InputKind::Primary); + + if matches!(self.char_state, CharacterState::DashMelee(_)) { + // Resets action counter when using dash + agent.combat_state.counters + [ActionStateFCounters::FCounterRocksnapperDash as usize] = 0.0; + } + } else if attack_data.dist_sqrd < LEAP_RANGE.powi(2) && attack_data.angle < 90.0 { + if agent.combat_state.counters[ActionStateFCounters::FCounterRocksnapperLeap as usize] + > LEAP_TIMER + { + // Use shockwave if timer has gone for long enough + controller.push_basic_input(InputKind::Secondary); + + if matches!(self.char_state, CharacterState::LeapShockwave(_)) { + // Resets action counter when using leap shockwave + agent.combat_state.counters + [ActionStateFCounters::FCounterRocksnapperLeap 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::Ability(0)); + } + } 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::Ability(0)); + } + + // 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, diff --git a/server/agent/src/data.rs b/server/agent/src/data.rs index 2af684123b..ec6160c4e8 100755 --- a/server/agent/src/data.rs +++ b/server/agent/src/data.rs @@ -248,6 +248,7 @@ pub enum Tactic { Snaretongue, Cardinal, SeaBishop, + Rocksnapper, Roshwalr, FrostGigas, BorealHammer, diff --git a/voxygen/anim/src/lib.rs b/voxygen/anim/src/lib.rs index 4e8285547c..38f1c3ab18 100644 --- a/voxygen/anim/src/lib.rs +++ b/voxygen/anim/src/lib.rs @@ -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::*; diff --git a/voxygen/anim/src/quadruped_low/combomelee.rs b/voxygen/anim/src/quadruped_low/combomelee.rs index f11b9fe5b8..7c24437ef5 100644 --- a/voxygen/anim/src/quadruped_low/combomelee.rs +++ b/voxygen/anim/src/quadruped_low/combomelee.rs @@ -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( diff --git a/voxygen/anim/src/quadruped_low/dash.rs b/voxygen/anim/src/quadruped_low/dash.rs index 5b54d8321f..0098f4269d 100644 --- a/voxygen/anim/src/quadruped_low/dash.rs +++ b/voxygen/anim/src/quadruped_low/dash.rs @@ -1,5 +1,9 @@ use super::{ - super::{vek::*, Animation}, + super::{ + util::{bounce, elastic}, + vek::*, + Animation, + }, QuadrupedLowSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -27,122 +31,88 @@ impl Animation for DashAnimation { match ability_id { Some("common.abilities.custom.rocksnapper.dash") => { - let (movement1, charge, movement2, movement3) = match stage_section { + 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 subtract = global_time - timer; - let check = subtract - subtract.trunc(); - let mirror = (check - 0.5).signum(); - let twitch1 = (mirror * movement1.sqrt() * 9.5).sin(); - fn quintic(x: f32) -> f32 { x.powf(0.2) } - let quick_movement1 = movement1.powf(0.2); - //let quick_movement3 = movement3.powf(0.2); - let quick_movement3 = elastic(movement3); + 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_movement1 + quick_movement3) * 10.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 - movement1 + quick_movement3); + 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_movement1 + quick_movement3) * 10.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 - movement1 + quick_movement3); + next.head_lower.scale = Vec3::one() * (1.0 - buildup + elastic_recover); next.foot_fl.position = Vec3::new( - -s_a.feet_f.0 + (quick_movement1 - quick_movement3) * 8.0, - s_a.feet_f.1 + (-1.0 * quick_movement1 + quick_movement3) * 8.0, - s_a.feet_f.2 + (quick_movement1 - quick_movement3) * 8.0, + -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 - movement1 + quick_movement3); + next.foot_fl.scale = Vec3::one() * (1.0 - buildup + elastic_recover); next.foot_fr.position = Vec3::new( - s_a.feet_f.0 - (quick_movement1 - quick_movement3) * 8.0, - s_a.feet_f.1 + (-1.0 * quick_movement1 + quick_movement3) * 8.0, - s_a.feet_f.2 + (quick_movement1 - quick_movement3) * 8.0, + 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 - movement1 + quick_movement3); + next.foot_fr.scale = Vec3::one() * (1.0 - buildup + elastic_recover); next.foot_bl.position = Vec3::new( - -s_a.feet_b.0 + (quick_movement1 - quick_movement3) * 8.0, - s_a.feet_b.1 + (quick_movement1 - quick_movement3) * 8.0, - s_a.feet_b.2 + (quick_movement1 - quick_movement3) * 8.0, + -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 - movement1 + quick_movement3); + next.foot_bl.scale = Vec3::one() * (1.0 - buildup + elastic_recover); next.foot_br.position = Vec3::new( - s_a.feet_b.0 - (quick_movement1 - quick_movement3) * 8.0, - s_a.feet_b.1 + (quick_movement1 - quick_movement3) * 8.0, - s_a.feet_b.2 + (quick_movement1 - quick_movement3) * 8.0, + 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 - movement1 + quick_movement3); + 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_movement1 - quick_movement3) * 20.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 - movement1 + quick_movement3); + 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_movement1 - quick_movement3) * 20.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 - movement1 + movement3); - - 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 - } - } - - 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) - } + next.tail_rear.scale = Vec3::one() * (1.0 - buildup + recover); next.chest.position = Vec3::new( 0.0, 0.0, - s_a.chest.1 - bounce(movement1) * 5.0 + elastic(movement3) * 5.0, + s_a.chest.1 - bounce(buildup) * 5.0 + elastic(recover) * 5.0, ); - let smooth_end_charge = if charge < 0.5 { - charge - } else { - 3.0 * charge.powi(2) - 2.0 * charge.powi(3) - }; next.chest.orientation = - Quaternion::rotation_z(2.0 * PI * movement1 + 4.0 * PI * charge); + Quaternion::rotation_z(2.0 * PI * buildup + 4.0 * PI * charge); }, _ => { - let (movement1, chargemovementbase, movement2, movement3) = match stage_section { + 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 - movement3; + let pullback = 1.0 - recover; let subtract = global_time - timer; let check = subtract - subtract.trunc(); let mirror = (check - 0.5).signum(); - let twitch1 = (mirror * movement1 * 9.5).sin(); - let twitch1fast = (mirror * movement1 * 25.0).sin(); - //let twitch3 = (mirror * movement3 * 4.0).sin(); - //let movement1 = mirror * movement1 * pullback; - //let movement2 = mirror * movement2 * pullback; - let movement1abs = movement1 * pullback; - let movement2abs = movement2 * pullback; + 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()) @@ -153,29 +123,29 @@ impl Animation for DashAnimation { (anim_time * 16.0_f32 + PI * 0.25).sin() * chargemovementbase * pullback; next.head_upper.orientation = - Quaternion::rotation_x(movement1abs * 0.4 + movement2abs * 0.3) + Quaternion::rotation_x(buildup_abs * 0.4 + action_abs * 0.3) * Quaternion::rotation_z(short * -0.06 + twitch1 * -0.3); next.head_lower.orientation = - Quaternion::rotation_x(movement1abs * -0.4 + movement2abs * -0.5) + Quaternion::rotation_x(buildup_abs * -0.4 + action_abs * -0.5) * Quaternion::rotation_z(short * 0.15 + twitch1 * 0.3); next.jaw.orientation = Quaternion::rotation_x( twitch1fast * 0.2 - + movement1abs * -0.3 - + movement2abs * 1.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_front.orientation = Quaternion::rotation_x( - 0.15 + movement1abs * -0.4 + movement2abs * 0.2 + chargemovementbase * 0.2, + 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 + movement1abs * -0.4 + movement2abs * 0.2 + chargemovementbase * 0.2, + -0.12 + buildup_abs * -0.4 + action_abs * 0.2 + chargemovementbase * 0.2, ) * Quaternion::rotation_z(shortalt * 0.15 + twitch1fast * 0.3); }, } diff --git a/voxygen/anim/src/quadruped_low/leapshockwave.rs b/voxygen/anim/src/quadruped_low/leapshockwave.rs new file mode 100644 index 0000000000..fbd29d6417 --- /dev/null +++ b/voxygen/anim/src/quadruped_low/leapshockwave.rs @@ -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, Option); + 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 + } +} diff --git a/voxygen/anim/src/quadruped_low/mod.rs b/voxygen/anim/src/quadruped_low/mod.rs index 4acafd354a..9a60bf91b1 100644 --- a/voxygen/anim/src/quadruped_low/mod.rs +++ b/voxygen/anim/src/quadruped_low/mod.rs @@ -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}; diff --git a/voxygen/anim/src/util.rs b/voxygen/anim/src/util.rs new file mode 100644 index 0000000000..07d7e8d6db --- /dev/null +++ b/voxygen/anim/src/util.rs @@ -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 } diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index ad0c6c145f..87102a003c 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -3109,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, };