From 02ed6ffd60cd2f4891f4e806fbc18495ecea45e6 Mon Sep 17 00:00:00 2001 From: Snowram Date: Fri, 3 Sep 2021 01:57:55 +0200 Subject: [PATCH] More arthropod work --- .../common/abilities/ability_set_manifest.ron | 7 ++ .../custom/arthropodbasic/ensnaringweb.ron | 8 ++ .../abilities/custom/arthropodbasic/leap.ron | 15 ++++ .../custom/arthropodbasic/singlestrike.ron | 34 +++++++++ .../items/npc_armor/arthropod/generic.ron | 17 +++++ .../npc_weapons/unique/arthropodbasic.ron | 21 ++++++ .../common/loot_tables/creature/arthropod.ron | 3 + .../voxel/arthropod_lateral_manifest.ron | 8 +- .../voxygen/voxel/npc/antlion/male/leg_fr.vox | 2 +- .../voxel/sprite/misc/ensnaring_web.vox | 3 + common/src/comp/body.rs | 16 +++- common/src/comp/inventory/loadout_builder.rs | 3 +- common/src/states/utils.rs | 16 +++- common/src/terrain/block.rs | 2 +- server/src/sys/agent/attack.rs | 38 ++++++---- voxygen/anim/src/arthropod/idle.rs | 17 ++--- voxygen/anim/src/arthropod/leapmelee.rs | 75 +++++++++++++++++++ voxygen/anim/src/arthropod/mod.rs | 24 ++++-- voxygen/anim/src/arthropod/run.rs | 44 +++++------ voxygen/anim/src/arthropod/stunned.rs | 70 +++++++++++++++++ voxygen/src/scene/figure/mod.rs | 62 +++++++++++++++ 21 files changed, 420 insertions(+), 65 deletions(-) create mode 100644 assets/common/abilities/custom/arthropodbasic/ensnaringweb.ron create mode 100644 assets/common/abilities/custom/arthropodbasic/leap.ron create mode 100644 assets/common/abilities/custom/arthropodbasic/singlestrike.ron create mode 100644 assets/common/items/npc_armor/arthropod/generic.ron create mode 100644 assets/common/items/npc_weapons/unique/arthropodbasic.ron create mode 100644 assets/common/loot_tables/creature/arthropod.ron create mode 100644 assets/voxygen/voxel/sprite/misc/ensnaring_web.vox create mode 100644 voxygen/anim/src/arthropod/leapmelee.rs create mode 100644 voxygen/anim/src/arthropod/stunned.rs diff --git a/assets/common/abilities/ability_set_manifest.ron b/assets/common/abilities/ability_set_manifest.ron index bdfd91bf6b..3c40f5c754 100644 --- a/assets/common/abilities/ability_set_manifest.ron +++ b/assets/common/abilities/ability_set_manifest.ron @@ -228,6 +228,13 @@ secondary: "common.abilities.custom.theropodbasic.dash", abilities: [], ), + Custom("Arthropod Basic"): ( + primary: "common.abilities.custom.arthropodbasic.singlestrike", + secondary: "common.abilities.custom.arthropodbasic.ensnaringweb", + abilities: [ + (None, "common.abilities.custom.arthropodbasic.leap"), + ], + ), Custom("Turret"): ( primary: "common.abilities.custom.turret.arrows", secondary: "common.abilities.custom.turret.arrows", diff --git a/assets/common/abilities/custom/arthropodbasic/ensnaringweb.ron b/assets/common/abilities/custom/arthropodbasic/ensnaringweb.ron new file mode 100644 index 0000000000..a9a598615a --- /dev/null +++ b/assets/common/abilities/custom/arthropodbasic/ensnaringweb.ron @@ -0,0 +1,8 @@ +SpriteSummon( + buildup_duration: 0.6, + cast_duration: 0.4, + recover_duration: 0.3, + sprite: EnsnaringWeb, + summon_distance: (0, 8), + sparseness: 0.67, +) \ No newline at end of file diff --git a/assets/common/abilities/custom/arthropodbasic/leap.ron b/assets/common/abilities/custom/arthropodbasic/leap.ron new file mode 100644 index 0000000000..15a470ac97 --- /dev/null +++ b/assets/common/abilities/custom/arthropodbasic/leap.ron @@ -0,0 +1,15 @@ +LeapMelee( + energy_cost: 0, + buildup_duration: 0.5, + movement_duration: 0.4, + swing_duration: 0.075, + recover_duration: 0.2, + base_damage: 120, + base_poise_damage: 60, + knockback: 4.0, + range: 4.5, + max_angle: 180.0, + forward_leap_strength: 40.0, + vertical_leap_strength: 10.0, + damage_kind: Crushing, +) diff --git a/assets/common/abilities/custom/arthropodbasic/singlestrike.ron b/assets/common/abilities/custom/arthropodbasic/singlestrike.ron new file mode 100644 index 0000000000..a224bd9390 --- /dev/null +++ b/assets/common/abilities/custom/arthropodbasic/singlestrike.ron @@ -0,0 +1,34 @@ +ComboMelee( + stage_data: [ + ( + stage: 1, + base_damage: 100, + damage_increase: 0, + base_poise_damage: 28, + poise_damage_increase: 0, + knockback: 3.0, + range: 2.7, + angle: 60.0, + base_buildup_duration: 0.4, + base_swing_duration: 0.1, + hit_timing: 0.5, + base_recover_duration: 0.4, + forward_movement: 1.0, + damage_kind: Crushing, + damage_effect: Some(Buff(( + kind: Poisoned, + dur_secs: 10.0, + strength: DamageFraction(1.0), + chance: 1.0, + ))), + ), + ], + initial_energy_gain: 0, + max_energy_gain: 0, + energy_increase: 0, + speed_increase: 0.0, + max_speed_increase: 0.0, + scales_from_combo: 0, + is_interruptible: false, + ori_modifier: 0.7, +) diff --git a/assets/common/items/npc_armor/arthropod/generic.ron b/assets/common/items/npc_armor/arthropod/generic.ron new file mode 100644 index 0000000000..7c863f8456 --- /dev/null +++ b/assets/common/items/npc_armor/arthropod/generic.ron @@ -0,0 +1,17 @@ +ItemDef( + name: "Arthropod Armor", + description: "Worn by arthropods.", + kind: Armor(( + kind: Chest("Arthropod"), + stats: ( + protection: Normal(100.0), + poise_resilience: Normal(1.0), + energy_max: 0, + energy_reward: 0.0, + crit_power: 0.0, + stealth: 0.0, + ), + )), + quality: Legendary, + tags: [], +) \ No newline at end of file diff --git a/assets/common/items/npc_weapons/unique/arthropodbasic.ron b/assets/common/items/npc_weapons/unique/arthropodbasic.ron new file mode 100644 index 0000000000..d3626cbcbb --- /dev/null +++ b/assets/common/items/npc_weapons/unique/arthropodbasic.ron @@ -0,0 +1,21 @@ +ItemDef( + name: "Arthropod Basic", + description: "testing123", + kind: Tool(( + kind: Natural, + hands: Two, + stats: Direct(( + equip_time_secs: 0.01, + power: 1.0, + effect_power: 1.0, + speed: 1.0, + crit_chance: 0.1, + range: 1.0, + energy_efficiency: 1.0, + buff_strength: 1.0, + )), + )), + quality: Low, + tags: [], + ability_spec: Some(Custom("Arthropod Basic")), +) \ No newline at end of file diff --git a/assets/common/loot_tables/creature/arthropod.ron b/assets/common/loot_tables/creature/arthropod.ron new file mode 100644 index 0000000000..e924f10257 --- /dev/null +++ b/assets/common/loot_tables/creature/arthropod.ron @@ -0,0 +1,3 @@ +[ + (1.0, ItemQuantity("common.items.crafting_ing.cloth.silk", 1, 3)), +] \ No newline at end of file diff --git a/assets/voxygen/voxel/arthropod_lateral_manifest.ron b/assets/voxygen/voxel/arthropod_lateral_manifest.ron index b835c6bf65..046a54bdd1 100644 --- a/assets/voxygen/voxel/arthropod_lateral_manifest.ron +++ b/assets/voxygen/voxel/arthropod_lateral_manifest.ron @@ -257,11 +257,11 @@ lateral: ("armor.empty"), ), leg_fl: ( - offset: (-11.0, -0.5, -4.5), + offset: (-0.5, 0.0, -4.5), lateral: ("npc.antlion.male.leg_fr"), ), leg_fr: ( - offset: (-0.0, -0.5, -4.5), + offset: (-0.5, 0.0, -4.5), lateral: ("npc.antlion.male.leg_fr"), ), leg_fcl: ( @@ -315,11 +315,11 @@ lateral: ("armor.empty"), ), leg_fl: ( - offset: (-11.0, -0.5, -4.5), + offset: (-0.5, 0.0, -4.5), lateral: ("npc.antlion.male.leg_fr"), ), leg_fr: ( - offset: (-0.0, -0.5, -4.5), + offset: (-0.5, 0.0, -4.5), lateral: ("npc.antlion.male.leg_fr"), ), leg_fcl: ( diff --git a/assets/voxygen/voxel/npc/antlion/male/leg_fr.vox b/assets/voxygen/voxel/npc/antlion/male/leg_fr.vox index bd1cba5d03..ea0f4bce09 100644 --- a/assets/voxygen/voxel/npc/antlion/male/leg_fr.vox +++ b/assets/voxygen/voxel/npc/antlion/male/leg_fr.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a6a3d79d8efb38d4d57465d8d3e2d2d286283b6d5e1196dde562be36388aa3fb +oid sha256:14e1960f80b99da34b047419fb93e20b69e50703e51197c2f11ab26743e7d645 size 1212 diff --git a/assets/voxygen/voxel/sprite/misc/ensnaring_web.vox b/assets/voxygen/voxel/sprite/misc/ensnaring_web.vox new file mode 100644 index 0000000000..6be405d3d3 --- /dev/null +++ b/assets/voxygen/voxel/sprite/misc/ensnaring_web.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53244cb395f8cc42b83abb036e8541409fbd55c8118076ffd567b5a0c84a3a79 +size 1908 diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index a4568e1d03..6f6be1ea69 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -295,7 +295,7 @@ impl Body { theropod::Species::Yale => 1_000.0, }, Body::Ship(ship) => ship.mass().0, - Body::Arthropod(body) => 500.0, + Body::Arthropod(_) => 200.0, }; Mass(m) } @@ -402,7 +402,19 @@ impl Body { theropod::Species::Woodraptor => Vec3::new(2.0, 3.0, 2.6), theropod::Species::Yale => Vec3::new(1.5, 3.2, 4.0), }, - Body::Arthropod(body) => Vec3::new(4.0, 4.0, 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), + }, } } diff --git a/common/src/comp/inventory/loadout_builder.rs b/common/src/comp/inventory/loadout_builder.rs index 4f8f60a1c9..11ac89a7e0 100644 --- a/common/src/comp/inventory/loadout_builder.rs +++ b/common/src/comp/inventory/loadout_builder.rs @@ -267,7 +267,7 @@ fn default_main_tool(body: &Body) -> Item { }, Body::Arthropod(arthropod) => match arthropod.species { _ => Some(Item::new_from_asset_expect( - "common.items.npc_weapons.unique.theropodbasic", + "common.items.npc_weapons.unique.arthropodbasic", )), }, Body::BipedLarge(biped_large) => match (biped_large.species, biped_large.body_type) { @@ -476,6 +476,7 @@ impl LoadoutBuilder { | theropod::Species::Odonto => Some("common.items.npc_armor.theropod.rugged"), _ => None, }, + Body::Arthropod(_) => Some("common.items.npc_armor.arthropod.generic"), _ => None, }; diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index c9969989ff..49a2baedb3 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -129,7 +129,19 @@ impl Body { quadruped_low::Species::Deadwood => 140.0, }, Body::Ship(_) => 0.0, - Body::Arthropod(_) => 135.0, + Body::Arthropod(arthropod) => match arthropod.species { + arthropod::Species::Tarantula => 135.0, + arthropod::Species::Blackwidow => 110.0, + arthropod::Species::Antlion => 120.0, + arthropod::Species::Hornbeetle => 80.0, + arthropod::Species::Leafbeetle => 80.0, + arthropod::Species::Stagbeetle => 80.0, + arthropod::Species::Weevil => 110.0, + arthropod::Species::Cavespider => 110.0, + arthropod::Species::Moltencrawler => 70.0, + arthropod::Species::Mosscrawler => 70.0, + arthropod::Species::Sandcrawler => 70.0, + }, } } @@ -245,7 +257,7 @@ impl Body { | theropod::Species::Woodraptor => Some(0.4 * self.mass().0), _ => None, }, - Body::QuadrupedMedium(_) => Some(3.0 * self.mass().0), + Body::Arthropod(_) => Some(2.0 * self.mass().0), _ => Some(0.4 * self.mass().0), } .map(|f| f * GRAVITY) diff --git a/common/src/terrain/block.rs b/common/src/terrain/block.rs index c367a8c05b..ea515a8cd1 100644 --- a/common/src/terrain/block.rs +++ b/common/src/terrain/block.rs @@ -268,7 +268,7 @@ impl Block { | SpriteKind::SpinningWheel | SpriteKind::DismantlingBench | SpriteKind::TanningRack => None, - SpriteKind::EnsnaringVines => Some(0.1), + SpriteKind::EnsnaringVines | SpriteKind::EnsnaringWeb => Some(0.1), _ => Some(0.25), }), } diff --git a/server/src/sys/agent/attack.rs b/server/src/sys/agent/attack.rs index c5e6c475f8..8c94c73490 100644 --- a/server/src/sys/agent/attack.rs +++ b/server/src/sys/agent/attack.rs @@ -1689,25 +1689,33 @@ impl<'a> AgentData<'a> { tgt_data: &TargetData, read_data: &ReadData, ) { - if attack_data.angle < 70.0 - && attack_data.dist_sqrd < (1.3 * attack_data.min_attack_dist).powi(2) + agent.action_state.timer += read_data.dt.0; + dbg!(agent.action_state.timer); + if agent.action_state.timer > 6.0 + && attack_data.dist_sqrd < (1.5 * attack_data.min_attack_dist).powi(2) { controller.inputs.move_dir = Vec2::zero(); - if agent.action_state.timer > 5.0 { + controller + .actions + .push(ControlAction::basic_input(InputKind::Secondary)); + if matches!(self.char_state, CharacterState::SpriteSummon(c) if matches!(c.stage_section, StageSection::Recover)) + { + // Reset timer agent.action_state.timer = 0.0; - } else if agent.action_state.timer > 2.0 { - controller - .actions - .push(ControlAction::basic_input(InputKind::Secondary)); - agent.action_state.timer += read_data.dt.0; - } else { - controller - .actions - .push(ControlAction::basic_input(InputKind::Primary)); - agent.action_state.timer += read_data.dt.0; } - } else if attack_data.dist_sqrd < MAX_PATH_DIST.powi(2) { - self.path_toward_target(agent, controller, tgt_data, read_data, true, false, None); + } else if attack_data.angle < 90.0 + && attack_data.dist_sqrd < (1.5 * attack_data.min_attack_dist).powi(2) + { + controller.inputs.move_dir = Vec2::zero(); + controller + .actions + .push(ControlAction::basic_input(InputKind::Primary)); + } else if attack_data.angle < 15.0 + && attack_data.dist_sqrd < (6.0 * attack_data.min_attack_dist).powi(2) + { + controller + .actions + .push(ControlAction::basic_input(InputKind::Ability(0))); } else { self.path_toward_target(agent, controller, tgt_data, read_data, false, false, None); } diff --git a/voxygen/anim/src/arthropod/idle.rs b/voxygen/anim/src/arthropod/idle.rs index 91d32b3208..85b9a63db1 100644 --- a/voxygen/anim/src/arthropod/idle.rs +++ b/voxygen/anim/src/arthropod/idle.rs @@ -1,7 +1,6 @@ use super::{super::Animation, ArthropodSkeleton, SkeletonAttr}; //use std::{f32::consts::PI, ops::Mul}; use super::super::vek::*; -use std::ops::Mul; pub struct IdleAnimation; @@ -39,23 +38,23 @@ impl Animation for IdleAnimation { 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_z(0.1); - next.leg_fr.orientation = Quaternion::rotation_z(-0.1); + next.leg_fl.orientation = Quaternion::rotation_z(s_a.leg_ori.0); + next.leg_fr.orientation = 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_z(-0.3); - next.leg_fcr.orientation = Quaternion::rotation_z(0.3); + next.leg_fcl.orientation = Quaternion::rotation_z(s_a.leg_ori.1); + next.leg_fcr.orientation = 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_z(0.0); - next.leg_bcr.orientation = Quaternion::rotation_z(0.0); + next.leg_bcl.orientation = Quaternion::rotation_z(s_a.leg_ori.2); + next.leg_bcr.orientation = 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_z(0.4); - next.leg_br.orientation = Quaternion::rotation_z(-0.4); + next.leg_bl.orientation = Quaternion::rotation_z(s_a.leg_ori.3); + next.leg_br.orientation = Quaternion::rotation_z(-s_a.leg_ori.3); next } diff --git a/voxygen/anim/src/arthropod/leapmelee.rs b/voxygen/anim/src/arthropod/leapmelee.rs new file mode 100644 index 0000000000..9588b0b7f5 --- /dev/null +++ b/voxygen/anim/src/arthropod/leapmelee.rs @@ -0,0 +1,75 @@ +use super::{ + super::{vek::*, Animation}, + ArthropodSkeleton, SkeletonAttr, +}; +use common::states::utils::StageSection; + +pub struct LeapMeleeAnimation; + +impl Animation for LeapMeleeAnimation { + type Dependency<'a> = (f32, f32, Option, f32); + type Skeleton = ArthropodSkeleton; + + #[cfg(feature = "use-dyn-lib")] + const UPDATE_FN: &'static [u8] = b"arthropod_leapmelee\0"; + + #[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>, + anim_time: f32, + _rate: &mut f32, + s_a: &SkeletonAttr, + ) -> Self::Skeleton { + let mut next = (*skeleton).clone(); + //let speed = (Vec2::::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::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 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; + + next.chest.scale = Vec3::one() / s_a.scaler; + + 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); + + 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.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); + + next.wing_bl.position = Vec3::new(-s_a.wing_b.0, s_a.wing_b.1, s_a.wing_b.2); + next.wing_br.position = Vec3::new(s_a.wing_b.0, s_a.wing_b.1, s_a.wing_b.2); + + 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_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_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_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 + } +} diff --git a/voxygen/anim/src/arthropod/mod.rs b/voxygen/anim/src/arthropod/mod.rs index bd30782ce1..ba616069a1 100644 --- a/voxygen/anim/src/arthropod/mod.rs +++ b/voxygen/anim/src/arthropod/mod.rs @@ -1,11 +1,14 @@ pub mod alpha; pub mod idle; pub mod jump; +pub mod leapmelee; pub mod run; +pub mod stunned; // Reexports pub use self::{ - alpha::AlphaAnimation, idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation, + alpha::AlphaAnimation, idle::IdleAnimation, jump::JumpAnimation, leapmelee::LeapMeleeAnimation, + run::RunAnimation, stunned::StunnedAnimation, }; use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton}; @@ -87,7 +90,8 @@ impl Skeleton for ArthropodSkeleton { make_bone(leg_br_mat), ]; - use comp::arthropod::Species::*; + // TODO: mount points + //use comp::arthropod::Species::*; let (mount_bone_mat, mount_bone_ori) = match (body.species, body.body_type) { _ => (chest_mat, self.chest.orientation), }; @@ -122,6 +126,7 @@ pub struct SkeletonAttr { leg_bc: (f32, f32, f32), leg_b: (f32, f32, f32), scaler: f32, + leg_ori: (f32, f32, f32, f32), } impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr { @@ -148,6 +153,7 @@ impl Default for SkeletonAttr { leg_bc: (0.0, 0.0, 0.0), leg_b: (0.0, 0.0, 0.0), scaler: 0.0, + leg_ori: (0.0, 0.0, 0.0, 0.0), } } } @@ -224,7 +230,7 @@ impl<'a> From<&'a Body> for SkeletonAttr { leg_f: match (body.species, body.body_type) { (Tarantula, _) => (4.0, 11.0, -1.5), (Blackwidow, _) => (4.0, 13.5, -6.0), - (Antlion, _) => (1.5, 12.0, -4.0), + (Antlion, _) => (4.0, 11.5, -4.0), (Hornbeetle, _) => (5.0, 6.0, -3.0), (Leafbeetle, _) => (5.0, 6.0, -1.0), (Stagbeetle, _) => (5.0, 6.0, -2.0), @@ -237,7 +243,7 @@ impl<'a> From<&'a Body> for SkeletonAttr { leg_fc: match (body.species, body.body_type) { (Tarantula, _) => (1.5, 13.5, -1.5), (Blackwidow, _) => (2.5, 13.0, -5.5), - (Antlion, _) => (1.5, 8.0, -4.0), + (Antlion, _) => (1.5, 6.0, -4.0), (Hornbeetle, _) => (1.5, 7.5, -3.0), (Leafbeetle, _) => (1.5, 6.5, -1.5), (Stagbeetle, _) => (1.5, 7.5, -2.0), @@ -250,7 +256,7 @@ impl<'a> From<&'a Body> for SkeletonAttr { leg_bc: match (body.species, body.body_type) { (Tarantula, _) => (1.5, 10.5, -1.5), (Blackwidow, _) => (2.5, 10.0, -5.5), - (Antlion, _) => (7.0, 7.5, -4.0), + (Antlion, _) => (6.0, 7.5, -4.0), (Hornbeetle, _) => (6.0, 6.0, -3.0), (Leafbeetle, _) => (6.0, 5.0, -2.5), (Stagbeetle, _) => (6.0, 6.0, -2.0), @@ -286,12 +292,18 @@ impl<'a> From<&'a Body> for SkeletonAttr { (Mosscrawler, _) => (1.0), (Sandcrawler, _) => (1.0), }, + // Z ori (front, front center, back center, center) + leg_ori: match (body.species, body.body_type) { + (Antlion, _) => (0.7, -0.3, -0.4, 0.4), + (_, _) => (0.1, -0.3, 0.0, 0.4), + }, } } } fn mount_point(body: &Body) -> Vec3 { - use comp::arthropod::{BodyType::*, Species::*}; + // TODO: mount points + //use comp::arthropod::{BodyType::*, Species::*}; match (body.species, body.body_type) { (_, _) => (0.0, -6.0, 6.0), } diff --git a/voxygen/anim/src/arthropod/run.rs b/voxygen/anim/src/arthropod/run.rs index c8318a1e73..ec828ced00 100644 --- a/voxygen/anim/src/arthropod/run.rs +++ b/voxygen/anim/src/arthropod/run.rs @@ -1,7 +1,7 @@ use super::{super::Animation, ArthropodSkeleton, SkeletonAttr}; //use std::{f32::consts::PI, ops::Mul}; use super::super::vek::*; -use std::f32::consts::{FRAC_PI_2, PI}; +use std::f32::consts::PI; pub struct RunAnimation; @@ -26,7 +26,7 @@ impl Animation for RunAnimation { //let speednorm = speed / 13.0; let speednorm = (speed / 13.0).powf(0.25); - let mixed_vel = (acc_vel + anim_time * 6.0) * 0.6; //sets run frequency using speed, with anim_time setting a floor + 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 @@ -41,12 +41,6 @@ impl Animation for RunAnimation { // let shortalt = (mixed_vel * 1.0 * lab * speedmult + PI * 3.0 / 8.0 - 0.5).sin() * speednorm; - //FL - let foot1a = (mixed_vel * 1.0 * lab * speedmult + 0.0 + PI).sin() * speednorm; //1.5 - let foot1b = (mixed_vel * 1.0 * lab * speedmult + FRAC_PI_2 + PI).sin() * speednorm; //1.9 - //FR - let foot2a = (mixed_vel * 1.0 * lab * speedmult).sin() * speednorm; //1.2 - let foot2b = (mixed_vel * 1.0 * lab * speedmult + FRAC_PI_2).sin() * speednorm; //1.6 let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); let tilt = if ::vek::Vec2::new(ori, last_ori) @@ -63,11 +57,13 @@ impl Animation for RunAnimation { 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; + next.wing_br.scale = Vec3::one() * 0.98; next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); next.head.orientation = Quaternion::rotation_x((mixed_vel).sin() * 0.1) - * Quaternion::rotation_y((mixed_vel).sin().min(0.0) * 0.1) - * Quaternion::rotation_z((mixed_vel + PI * 1.5).sin() * 0.1); + * Quaternion::rotation_y((mixed_vel).sin().min(0.0) * 0.08) + * Quaternion::rotation_z((mixed_vel + PI * 1.5).sin() * 0.08); next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1); next.chest.orientation = Quaternion::rotation_x((mixed_vel).sin().max(0.0) * 0.06) @@ -85,36 +81,36 @@ impl Animation for RunAnimation { 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((mixed_vel + PI).sin().max(0.0) * 0.7) - * Quaternion::rotation_z(0.1 + (mixed_vel - PI / 2.0).sin() * 0.4); + * Quaternion::rotation_z(s_a.leg_ori.0 + (mixed_vel - PI / 2.0).sin() * 0.4); next.leg_fr.orientation = Quaternion::rotation_x((mixed_vel).sin().max(0.0) * 0.7) - * Quaternion::rotation_z(-0.1 - (mixed_vel + PI / 2.0).sin() * 0.4); + * Quaternion::rotation_z(-s_a.leg_ori.0 - (mixed_vel + PI / 2.0).sin() * 0.4); 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_x((mixed_vel + PI).sin() * 0.4) + next.leg_fcl.orientation = Quaternion::rotation_x((mixed_vel + PI).sin() * 0.2) * Quaternion::rotation_y((mixed_vel).sin().max(0.0) * 0.7) - * Quaternion::rotation_z(-0.3 + (mixed_vel + PI / 2.0).sin() * 0.2); - next.leg_fcr.orientation = Quaternion::rotation_x((mixed_vel).sin() * 0.4) + * Quaternion::rotation_z(s_a.leg_ori.1 + (mixed_vel + PI / 2.0).sin() * 0.2); + next.leg_fcr.orientation = Quaternion::rotation_x((mixed_vel).sin() * 0.2) * Quaternion::rotation_y((mixed_vel).sin().min(0.0) * 0.7) - * Quaternion::rotation_z(0.3 - (mixed_vel + PI * 1.5).sin() * 0.2); + * Quaternion::rotation_z(-s_a.leg_ori.1 - (mixed_vel + PI * 1.5).sin() * 0.2); 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_x((mixed_vel + PI).sin() * 0.4) + next.leg_bcl.orientation = Quaternion::rotation_x((mixed_vel + PI).sin() * 0.2) * Quaternion::rotation_y((mixed_vel + PI).sin().max(0.0) * 0.7) - * Quaternion::rotation_z((mixed_vel + PI * 1.5).sin() * 0.3); - next.leg_bcr.orientation = Quaternion::rotation_x((mixed_vel).sin() * 0.4) + * Quaternion::rotation_z(s_a.leg_ori.2 + (mixed_vel + PI * 1.5).sin() * 0.3); + next.leg_bcr.orientation = Quaternion::rotation_x((mixed_vel).sin() * 0.2) * Quaternion::rotation_y((mixed_vel + PI).sin().min(0.0) * 0.7) - * Quaternion::rotation_z(-(mixed_vel + PI / 2.0).sin() * 0.3); + * Quaternion::rotation_z(-s_a.leg_ori.2 - (mixed_vel + PI / 2.0).sin() * 0.3); 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_x((mixed_vel + PI).sin() * 0.4) + next.leg_bl.orientation = Quaternion::rotation_x((mixed_vel + PI).sin() * 0.2) * Quaternion::rotation_y((mixed_vel).sin().max(0.0) * 0.7) - * Quaternion::rotation_z(0.4 + (mixed_vel + PI / 2.0).sin() * 0.2); - next.leg_br.orientation = Quaternion::rotation_x((mixed_vel).sin() * 0.4) + * Quaternion::rotation_z(s_a.leg_ori.3 + (mixed_vel + PI / 2.0).sin() * 0.2); + next.leg_br.orientation = Quaternion::rotation_x((mixed_vel).sin() * 0.2) * Quaternion::rotation_y((mixed_vel).sin().min(0.0) * 0.7) - * Quaternion::rotation_z(-0.4 - (mixed_vel + PI * 1.5).sin() * 0.2); + * Quaternion::rotation_z(s_a.leg_ori.3 - (mixed_vel + PI * 1.5).sin() * 0.2); next } diff --git a/voxygen/anim/src/arthropod/stunned.rs b/voxygen/anim/src/arthropod/stunned.rs new file mode 100644 index 0000000000..de3aec173d --- /dev/null +++ b/voxygen/anim/src/arthropod/stunned.rs @@ -0,0 +1,70 @@ +use super::{ + super::{vek::*, Animation}, + ArthropodSkeleton, SkeletonAttr, +}; +use common::states::utils::StageSection; +//use std::ops::Rem; + +pub struct StunnedAnimation; + +impl Animation for StunnedAnimation { + type Dependency<'a> = (f32, f32, Option, f32); + type Skeleton = ArthropodSkeleton; + + #[cfg(feature = "use-dyn-lib")] + const UPDATE_FN: &'static [u8] = b"arthropod_stunned\0"; + + #[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>, + anim_time: f32, + _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.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; + + next.chest.scale = Vec3::one() / s_a.scaler; + + 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); + + 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.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); + + next.wing_bl.position = Vec3::new(-s_a.wing_b.0, s_a.wing_b.1, s_a.wing_b.2); + next.wing_br.position = Vec3::new(s_a.wing_b.0, s_a.wing_b.1, s_a.wing_b.2); + + 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_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_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_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 + } +} diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index a6d083040f..392464d1aa 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -3574,6 +3574,68 @@ impl FigureMgr { ), } }, + CharacterState::LeapMelee(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.movement_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::arthropod::LeapMeleeAnimation::update_skeleton( + &target_base, + ( + rel_vel.magnitude(), + time, + Some(s.stage_section), + state.state_time, + ), + stage_progress, + &mut state_animation_rate, + skeleton_attr, + ) + }, + CharacterState::Stunned(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::Recover => { + stage_time / s.static_data.recover_duration.as_secs_f32() + }, + _ => 0.0, + }; + match s.static_data.poise_state { + PoiseState::Normal + | PoiseState::Interrupted + | PoiseState::Stunned + | PoiseState::Dazed + | PoiseState::KnockedDown => { + anim::arthropod::StunnedAnimation::update_skeleton( + &target_base, + ( + rel_vel.magnitude(), + time, + Some(s.stage_section), + state.state_time, + ), + stage_progress, + &mut state_animation_rate, + skeleton_attr, + ) + }, + } + }, // TODO! _ => target_base, };