Various fixes to object animation, cleanup

This commit is contained in:
Snowram 2021-01-30 15:14:25 +01:00
parent f25b2b1500
commit 4078eeb877
29 changed files with 519 additions and 1672 deletions

View File

@ -0,0 +1,15 @@
BasicRanged(
energy_cost: 0,
buildup_duration: 1.0,
recover_duration: 0.3,
projectile: Arrow(
damage: 200.0,
knockback: 5.0,
energy_regen: 100,
),
projectile_body: Object(ArrowTurret),
projectile_light: None,
projectile_gravity: Some(Gravity(0.1)),
projectile_speed: 100.0,
can_continue: true,
)

View File

@ -1,12 +1,12 @@
BasicBeam(
buildup_duration: 250,
recover_duration: 250,
beam_duration: 500,
buildup_duration: 0.25,
recover_duration: 0.25,
beam_duration: 0.5,
base_hps: 0,
base_dps: 150,
base_dps: 9001,
tick_rate: 3.0,
range: 30.0,
max_angle: 5.0,
max_angle: 1.0,
lifesteal_eff: 0.0,
energy_regen: 0,
energy_cost: 0,

View File

@ -132,10 +132,10 @@
secondary: "common.abilities.unique.theropodbird.triplestrike",
abilities: [],
),
Unique(Turret): (
primary: "common.abilities.unique.turret.basic",
secondary: "common.abilities.unique.turret.basic",
skills: [],
Unique(ObjectTurret): (
primary: "common.abilities.unique.turret.arrows",
secondary: "common.abilities.unique.turret.arrows",
abilities: [],
),
Debug: (
primary: "common.abilities.debug.forwardboost",

View File

@ -3,13 +3,16 @@ ItemDef(
description: "Turret weapon",
kind: Tool(
(
kind: Unique(Turret),
stats: (
kind: Unique(ObjectTurret),
hands: Two,
stats: Direct((
equip_time_millis: 10,
power: 1.00,
poise_strength: 1.00,
speed: 1.00,
),
)),
)
),
quality: Low,
tags: [],
)

BIN
assets/voxygen/voxel/object/crossbow.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/voxel/object/crossbow/bone0.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/object/crossbow/bone1.vox (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -3,390 +3,650 @@
bone0: (
offset: (-0.5, -6.0, -1.5),
central: ("weapon.projectile.simple-arrow"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Bomb: (
bone0: (
offset: (-5.5, -5.5, 0.0),
central: ("object.bomb"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
FireworkBlue: (
bone0: (
offset: (0.0, 0.0, 0.0),
central: ("weapon.projectile.fireworks_blue-0"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
FireworkGreen: (
bone0: (
offset: (0.0, 0.0, 0.0),
central: ("weapon.projectile.fireworks_green-0"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
FireworkPurple: (
bone0: (
offset: (0.0, 0.0, 0.0),
central: ("weapon.projectile.fireworks_purple-0"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
FireworkRed: (
bone0: (
offset: (0.0, 0.0, 0.0),
central: ("weapon.projectile.fireworks_red-0"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
FireworkYellow: (
bone0: (
offset: (0.0, 0.0, 0.0),
central: ("weapon.projectile.fireworks_yellow-0"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Scarecrow: (
bone0: (
offset: (-9.5, -4.0, 0.0),
central: ("object.scarecrow"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Cauldron: (
bone0: (
offset: (-10.0, -10.0, 0.0),
central: ("object.cauldron"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
ChestVines: (
bone0: (
offset: (-7.5, -6.0, 0.0),
central: ("object.chest_vines"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Chest: (
bone0: (
offset: (-7.5, -6.0, 0.0),
central: ("object.chest"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
ChestDark: (
bone0: (
offset: (-7.5, -6.0, 0.0),
central: ("object.chest_dark"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
ChestDemon: (
bone0: (
offset: (-7.5, -6.0, 0.0),
central: ("object.chest_demon"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
ChestGold: (
bone0: (
offset: (-7.5, -6.0, 0.0),
central: ("object.chest_gold"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
ChestLight: (
bone0: (
offset: (-7.5, -6.0, 0.0),
central: ("object.chest_light"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
ChestOpen: (
bone0: (
offset: (-7.5, -6.0, 0.0),
central: ("object.chest_open"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
ChestSkull: (
bone0: (
offset: (-7.5, -6.0, 0.0),
central: ("object.chest_skull"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Pumpkin: (
bone0: (
offset: (-5.5, -4.0, 0.0),
central: ("object.pumpkin"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Pumpkin2: (
bone0: (
offset: (-5.0, -4.0, 0.0),
central: ("object.pumpkin_2"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Pumpkin3: (
bone0: (
offset: (-5.0, -4.0, 0.0),
central: ("object.pumpkin_3"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Pumpkin4: (
bone0: (
offset: (-5.0, -4.0, 0.0),
central: ("object.pumpkin_4"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Pumpkin5: (
bone0: (
offset: (-4.0, -5.0, 0.0),
central: ("object.pumpkin_5"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Campfire: (
bone0: (
offset: (-9.0, -10.0, 0.0),
central: ("object.campfire"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
CampfireLit: (
bone0: (
offset: (-9.0, -10.0, 0.0),
central: ("object.campfire_lit"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
LanternGround: (
bone0: (
offset: (-3.5, -3.5, 0.0),
central: ("object.lantern_ground"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
LanternGroundOpen: (
bone0: (
offset: (-3.5, -3.5, 0.0),
central: ("object.lantern_ground_open"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
LanternStanding: (
bone0: (
offset: (-7.5, -3.5, 0.0),
central: ("object.lantern_standing"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
LanternStanding2: (
bone0: (
offset: (-11.5, -3.5, 0.0),
central: ("object.lantern_standing_2"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
PotionRed: (
bone0: (
offset: (-2.0, -2.0, 0.0),
central: ("object.potion_red"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
PotionBlue: (
bone0: (
offset: (-2.0, -2.0, 0.0),
central: ("object.potion_blue"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
PotionGreen: (
bone0: (
offset: (-2.0, -2.0, 0.0),
central: ("object.potion_green"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Crate: (
bone0: (
offset: (-7.0, -7.0, 0.0),
central: ("object.crate"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Tent: (
bone0: (
offset: (-18.5, -19.5, 0.0),
central: ("object.tent"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
WindowSpooky: (
bone0: (
offset: (-15.0, -1.5, -1.0),
central: ("object.window_spooky"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
DoorSpooky: (
bone0: (
offset: (-15.0, -4.5, 0.0),
central: ("object.door_spooky"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Table: (
bone0: (
offset: (-12.0, -8.0, 0.0),
central: ("object.table"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Table2: (
bone0: (
offset: (-8.0, -8.0, 0.0),
central: ("object.table_2"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Table3: (
bone0: (
offset: (-10.0, -10.0, 0.0),
central: ("object.table_3"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Drawer: (
bone0: (
offset: (-11.0, -7.5, 0.0),
central: ("object.drawer"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
BedBlue: (
bone0: (
offset: (-11.0, -15.0, 0.0),
central: ("object.bed_human_blue"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Anvil: (
bone0: (
offset: (-3.0, -7.0, 0.0),
central: ("object.anvil"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Gravestone: (
bone0: (
offset: (-5.0, -2.0, 0.0),
central: ("object.gravestone"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Gravestone2: (
bone0: (
offset: (-8.5, -3.0, 0.0),
central: ("object.gravestone_2"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Chair: (
bone0: (
offset: (-5.0, -4.5, 0.0),
central: ("object.chair"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Chair2: (
bone0: (
offset: (-5.0, -4.5, 0.0),
central: ("object.chair_2"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Chair3: (
bone0: (
offset: (-5.0, -4.5, 0.0),
central: ("object.chair_3"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Bench: (
bone0: (
offset: (-8.8, -5.0, 0.0),
central: ("object.bench"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Carpet: (
bone0: (
offset: (-14.0, -14.0, -0.5),
central: ("object.carpet"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Bedroll: (
bone0: (
offset: (-11.0, -19.5, -0.5),
central: ("object.bedroll"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
CarpetHumanRound: (
bone0: (
offset: (-14.0, -14.0, -0.5),
central: ("object.carpet_human_round"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
CarpetHumanSquare: (
bone0: (
offset: (-13.5, -14.0, -0.5),
central: ("object.carpet_human_square"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
CarpetHumanSquare2: (
bone0: (
offset: (-13.5, -14.0, -0.5),
central: ("object.carpet_human_square_2"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
CarpetHumanSquircle: (
bone0: (
offset: (-21.0, -21.0, -0.5),
central: ("object.carpet_human_squircle"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Pouch: (
bone0: (
offset: (-5.5, -4.5, 0.0),
central: ("object.pouch"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
CraftingBench: (
bone0: (
offset: (-9.5, -7.0, 0.0),
central: ("object.crafting_bench"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
ArrowSnake: (
bone0: (
offset: (-1.5, -6.5, 0.0),
central: ("weapon.projectile.snake-arrow"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
BoltFire: (
bone0: (
offset: (-3.0, -5.5, -3.0),
central: ("weapon.projectile.fire-bolt-0"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
BoltFireBig: (
bone0: (
offset: (-6.0, -6.0, -6.0),
central: ("weapon.projectile.fire-bolt-1"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
TrainingDummy: (
bone0: (
offset: (-7.0, -5.0, 0.0),
central: ("object.training_dummy"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
MultiArrow: (
bone0: (
offset: (-4.0, -9.5, -5.0),
central: ("weapon.projectile.multi-arrow"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
BoltNature: (
bone0: (
offset: (-6.0, -6.0, -6.0),
central: ("weapon.projectile.nature-bolt"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
MeatDrop: (
bone0: (
offset: (-3.5, -8.0, 0.0),
central: ("object.meat_drop"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Steak: (
bone0: (
offset: (-3.5, -6.0, 0.0),
central: ("object.steak"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
Crossbow: (
bone0: (
offset: (-18.0, -15.5, 0.0),
central: ("object.crossbow"),
offset: (-18.0, -15.5, -8.0),
central: ("object.crossbow.bone0"),
),
bone1: (
offset: (-9.0, -7.0, -5.0 ),
central: ("object.crossbow.bone1"),
)
),
ArrowTurret: (
bone0: (
offset: (-1.5, -6.5, -1.5),
central: ("weapon.projectile.turret-arrow"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
})

View File

@ -222,9 +222,9 @@ pub enum CharacterAbility {
range: f32,
max_angle: f32,
lifesteal_eff: f32,
energy_regen: u32,
energy_cost: u32,
energy_drain: u32,
energy_regen: f32,
energy_cost: f32,
energy_drain: f32,
orientation_behavior: basic_beam::MovementBehavior,
},
}

View File

@ -29,6 +29,9 @@ pub enum Tactic {
QuadMedBasic,
Lavadrake,
Theropod,
Turret,
FixedTurret,
RotatingTurret,
}
#[derive(Copy, Clone, Debug, PartialEq)]

View File

@ -339,7 +339,11 @@ impl Body {
biped_large::Species::Mindflayer => 8000,
_ => 1000,
},
Body::Object(_) => 10000,
Body::Object(object) => match object {
object::Body::TrainingDummy => 10000,
object::Body::Crossbow => 800,
_ => 10000,
},
Body::Golem(_) => 2740,
Body::Theropod(theropod) => match theropod.species {
theropod::Species::Archaeos => 3000,

View File

@ -295,5 +295,5 @@ pub enum UniqueKind {
QuadSmallBasic,
TheropodBasic,
TheropodBird,
Turret,
ObjectTurret,
}

View File

@ -227,14 +227,10 @@ impl LoadoutBuilder {
));
},
},
#[allow(clippy::collapsible_match)] // to be removed when more entries are added
Body::Object(object) => match object {
object::Body::Crossbow => {
main_tool = Some(Item::new_from_asset_expect(
"common.items.npc_weapons.unique.turret",
));
},
_ => {},
Body::Object(object::Body::Crossbow) => {
main_tool = Some(Item::new_from_asset_expect(
"common.items.npc_weapons.unique.turret",
));
},
_ => {},
};

View File

@ -10,7 +10,6 @@ use crate::{
utils::*,
},
uid::Uid,
Damage, DamageSource, GroupTarget,
};
use serde::{Deserialize, Serialize};
use std::time::Duration;
@ -43,7 +42,7 @@ pub struct StaticData {
/// Energy consumed per second for heal ticks
pub energy_cost: f32,
/// Energy drained per
pub energy_drain: u32,
pub energy_drain: f32,
/// Used to dictate how orientation functions in this state
pub orientation_behavior: MovementBehavior,
/// What key is used to press ability
@ -70,7 +69,7 @@ impl CharacterBehavior for Data {
match self.static_data.orientation_behavior {
MovementBehavior::Normal => {},
MovementBehavior::Turret => {
update.ori.0 = data.inputs.look_dir;
update.ori = Ori::from(data.inputs.look_dir);
},
}
@ -106,8 +105,8 @@ impl CharacterBehavior for Data {
});
// Gets offsets
let body_offsets = Vec3::new(
(data.body.radius() + 1.0) * data.ori.0.x,
(data.body.radius() + 1.0) * data.ori.0.y,
(data.body.radius() + 1.0) * data.inputs.look_dir.x,
(data.body.radius() + 1.0) * data.inputs.look_dir.y,
data.body.eye_height(),
) * 0.55;
// Build up

View File

@ -116,7 +116,7 @@ impl Body {
Body::BirdSmall(_) => 35.0,
Body::FishSmall(_) => 10.0,
Body::BipedLarge(_) => 12.0,
Body::Object(_) => 0.0,
Body::Object(_) => 10.0,
Body::Golem(_) => 8.0,
Body::Theropod(theropod) => match theropod.species {
theropod::Species::Archaeos => 2.5,

File diff suppressed because it is too large Load Diff

View File

@ -525,6 +525,7 @@ impl<'a> System<'a> for Sys {
Some(ToolKind::Unique(UniqueKind::QuadLowBreathe)) => Tactic::Lavadrake,
Some(ToolKind::Unique(UniqueKind::TheropodBasic)) => Tactic::Theropod,
Some(ToolKind::Unique(UniqueKind::TheropodBird)) => Tactic::Theropod,
Some(ToolKind::Unique(UniqueKind::ObjectTurret)) => Tactic::Turret,
_ => Tactic::Melee,
};
@ -1429,6 +1430,38 @@ impl<'a> System<'a> for Sys {
do_idle = true;
}
},
Tactic::Turret => {
if can_see_tgt(&*terrain, pos, tgt_pos, dist_sqrd)
{
inputs.primary.set_state(true);
} else {
do_idle = true;
}
},
Tactic::FixedTurret => {
inputs.look_dir = ori.look_dir();
if can_see_tgt(&*terrain, pos, tgt_pos, dist_sqrd)
{
inputs.primary.set_state(true);
} else {
do_idle = true;
}
},
Tactic::RotatingTurret => {
inputs.look_dir = Dir::new(
Quaternion::from_xyzw(ori.look_dir().x, ori.look_dir().y, 0.0, 0.0)
.rotated_z(6.0 * dt.0 as f32)
.into_vec3()
.try_normalized()
.unwrap_or_default(),
);
if can_see_tgt(&*terrain, pos, tgt_pos, dist_sqrd)
{
inputs.primary.set_state(true);
} else {
do_idle = true;
}
},
}
} else {
do_idle = true;

View File

@ -160,11 +160,7 @@ impl Animation for RunAnimation {
Quaternion::rotation_x(0.6 * speednorm + (footrotr * -1.2) * speednorm)
* Quaternion::rotation_y(footrotr * 0.4 * speednorm);
next.hand_r.position = Vec3::new(
s_a.hand.0 + foothoril * 1.3 * speednorm,
3.0 * speednorm + s_a.hand.1 + foothoril * -7.0 * speednorm,
1.5 * speednorm + s_a.hand.2 - foothoril * 5.5 * speednorm,
);
next.hand_r.position = -next.hand_l.position;
next.hand_r.orientation =
Quaternion::rotation_x(0.6 * speednorm + (footrotl * -1.2) * speednorm)
* Quaternion::rotation_y(footrotl * -0.4 * speednorm);

View File

@ -0,0 +1,45 @@
use super::{
super::{vek::*, Animation},
ObjectSkeleton, SkeletonAttr,
};
use common::{
comp::{item::ToolKind, object::Body},
states::utils::StageSection,
};
pub struct BeamAnimation;
type BeamAnimationDependency = (
Option<ToolKind>,
Option<ToolKind>,
Option<StageSection>,
Body,
);
impl Animation for BeamAnimation {
type Dependency = BeamAnimationDependency;
type Skeleton = ObjectSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"object_beam\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "object_beam")]
#[allow(clippy::approx_constant)] // TODO: Pending review in #587
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_active_tool_kind, _second_tool_kind, _stage_section, _body): Self::Dependency,
_anim_time: f64,
rate: &mut f32,
s_a: &SkeletonAttr,
) -> Self::Skeleton {
*rate = 1.0;
let mut next = (*skeleton).clone();
next.bone0.position = Vec3::new(s_a.bone0.0, s_a.bone0.1, s_a.bone0.2) / 11.0;
next.bone0.orientation = Quaternion::rotation_z(0.0);
next.bone1.position = Vec3::new(s_a.bone1.0, s_a.bone1.1, s_a.bone1.2) / 11.0;
next.bone1.orientation = Quaternion::rotation_z(0.0);
next
}
}

View File

@ -24,8 +24,9 @@ impl Animation for IdleAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.bone0.position = Vec3::new(s_a.bone0.0, s_a.bone0.1, s_a.bone0.2);
next.bone0.orientation = Quaternion::rotation_z(0.0);
next.bone0.position = Vec3::new(s_a.bone0.0, s_a.bone0.1, s_a.bone0.2) / 11.0;
next.bone1.position = Vec3::new(s_a.bone1.0, s_a.bone1.1, s_a.bone1.2) / 11.0;
next
}

View File

@ -1,8 +1,9 @@
pub mod beam;
pub mod idle;
pub mod shoot;
// Reexports
pub use self::{idle::IdleAnimation, shoot::ShootAnimation};
pub use self::{beam::BeamAnimation, idle::IdleAnimation, shoot::ShootAnimation};
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
use common::comp::{self};
@ -12,13 +13,14 @@ pub type Body = comp::object::Body;
skeleton_impls!(struct ObjectSkeleton {
+ bone0,
+ bone1,
});
impl Skeleton for ObjectSkeleton {
type Attr = SkeletonAttr;
type Body = Body;
const BONE_COUNT: usize = 1;
const BONE_COUNT: usize = 2;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"object_compute_mats\0";
@ -30,14 +32,17 @@ impl Skeleton for ObjectSkeleton {
) -> Vec3<f32> {
let bone0_mat = base_mat * Mat4::<f32>::from(self.bone0);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) =
[make_bone(bone0_mat * Mat4::scaling_3d(1.0 / 11.0))];
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(bone0_mat * Mat4::scaling_3d(1.0 / 11.0)),
make_bone(Mat4::<f32>::from(self.bone1) * Mat4::scaling_3d(1.0 / 11.0)), /* Decorellated from ori */
];
Vec3::default()
}
}
pub struct SkeletonAttr {
bone0: (f32, f32, f32),
bone1: (f32, f32, f32),
}
impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr {
@ -55,6 +60,7 @@ impl Default for SkeletonAttr {
fn default() -> Self {
Self {
bone0: (0.0, 0.0, 0.0),
bone1: (0.0, 0.0, 0.0),
}
}
}
@ -64,8 +70,11 @@ impl<'a> From<&'a Body> for SkeletonAttr {
use comp::object::Body::*;
Self {
bone0: match body {
CampfireLit => (2.0, 0.5, 1.0),
Pouch => (2.0, 0.5, 1.0),
Crossbow => (0.0, 0.0, 14.0),
_ => (0.0, 0.0, 0.0),
},
bone1: match body {
Crossbow => (0.0, 0.0, 8.0),
_ => (0.0, 0.0, 0.0),
},
}

View File

@ -2,17 +2,17 @@ use super::{
super::{vek::*, Animation},
ObjectSkeleton, SkeletonAttr,
};
use common::{comp::item::ToolKind, states::utils::StageSection};
use common::{
comp::{item::ToolKind, object::Body},
states::utils::StageSection,
};
pub struct ShootAnimation;
type ShootAnimationDependency = (
Option<ToolKind>,
Option<ToolKind>,
f32,
Vec3<f32>,
Vec3<f32>,
f64,
Option<StageSection>,
Body,
);
impl Animation for ShootAnimation {
type Dependency = ShootAnimationDependency;
@ -25,15 +25,7 @@ impl Animation for ShootAnimation {
#[allow(clippy::approx_constant)] // TODO: Pending review in #587
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(
_active_tool_kind,
_second_tool_kind,
_velocity,
orientation,
last_ori,
_global_time,
_stage_section,
): Self::Dependency,
(_active_tool_kind, _second_tool_kind, stage_section, body): Self::Dependency,
anim_time: f64,
rate: &mut f32,
s_a: &SkeletonAttr,
@ -42,22 +34,28 @@ impl Animation for ShootAnimation {
let mut next = (*skeleton).clone();
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 (movement1, movement2, movement3) = match stage_section {
Some(StageSection::Buildup) => (anim_time as f32, 0.0, 0.0),
Some(StageSection::Swing) => (1.0, (anim_time as f32).powf(0.25), 0.0),
Some(StageSection::Recover) => (1.0, 1.0, anim_time as f32),
_ => (0.0, 0.0, 0.0),
};
next.bone0.position = Vec3::new(s_a.bone0.0, s_a.bone0.1, s_a.bone0.2);
next.bone0.orientation = Quaternion::rotation_z(anim_time as f32 * 1.0);
next.bone0.position = Vec3::new(s_a.bone0.0, s_a.bone0.1, s_a.bone0.2) / 11.0;
next.bone1.position = Vec3::new(s_a.bone1.0, s_a.bone1.1, s_a.bone1.2) / 11.0;
#[allow(clippy::single_match)]
match body {
Body::Crossbow => {
next.bone0.position = Vec3::new(s_a.bone0.0, s_a.bone0.1, s_a.bone0.2) / 11.0;
next.bone0.orientation =
Quaternion::rotation_x(movement1 * 0.05 + movement2 * 0.1) * (1.0 - movement3);
next.bone1.position = Vec3::new(s_a.bone1.0, s_a.bone1.1, s_a.bone1.2) / 11.0;
next.bone1.orientation = Quaternion::rotation_z(0.0);
},
_ => {},
}
next
}

View File

@ -317,7 +317,10 @@ impl SfxMgr {
// TODO: from sfx config?
match body {
Body::Object(
object::Body::Arrow | object::Body::MultiArrow | object::Body::ArrowSnake,
object::Body::Arrow
| object::Body::MultiArrow
| object::Body::ArrowSnake
| object::Body::ArrowTurret,
) => {
let file_ref = vec![
"voxygen.audio.sfx.abilities.arrow_shot_1",

View File

@ -23,22 +23,22 @@ impl<'a> System<'a> for Sys {
fn run(
&mut self,
(entities, dt, positions, orientations, velocities, mut interpolated, bodies): Self::SystemData,
(entities, dt, positions, orientations, velocities, bodies, mut interpolated): Self::SystemData,
) {
// Update interpolated positions and orientations
for (pos, ori, i, vel, body) in (
for (pos, ori, i, body, vel) in (
&positions,
&orientations,
&mut interpolated,
&velocities,
&bodies,
&velocities,
)
.join()
{
// Update interpolation values
if i.pos.distance_squared(pos.0) < 64.0 * 64.0 {
i.pos = Lerp::lerp(i.pos, pos.0 + vel.0 * 0.03, 5.0 * dt.0);
i.ori = Dir::slerp(i.ori, ori.0, base_ori_interp(body) * dt.0);
i.pos = Lerp::lerp(i.pos, pos.0 + vel.0 * 0.03, 10.0 * dt.0);
i.ori = Ori::slerp(i.ori, *ori, base_ori_interp(body) * dt.0);
} else {
i.pos = pos.0;
i.ori = *ori;

View File

@ -3747,6 +3747,7 @@ struct ObjectCentralSpec(HashMap<object::Body, SidedObjectCentralVoxSpec>);
#[derive(Deserialize)]
struct SidedObjectCentralVoxSpec {
bone0: ObjectCentralSubSpec,
bone1: ObjectCentralSubSpec,
}
#[derive(Deserialize)]
struct ObjectCentralSubSpec {
@ -3764,7 +3765,9 @@ make_vox_spec!(
Some(spec.central.read().0.mesh_bone0(
body,
)),
None,
Some(spec.central.read().0.mesh_bone1(
body,
)),
None,
None,
None,
@ -3796,4 +3799,17 @@ impl ObjectCentralSpec {
(central, Vec3::from(spec.bone0.offset))
}
fn mesh_bone1(&self, obj: &object::Body) -> BoneMeshes {
let spec = match self.0.get(&obj) {
Some(spec) => spec,
None => {
error!("No specification exists for {:?}", obj);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let central = graceful_load_segment(&spec.bone1.central.0);
(central, Vec3::from(spec.bone1.offset))
}
}

View File

@ -3490,7 +3490,9 @@ impl FigureMgr {
let (character, last_character) = match (character, last_character) {
(Some(c), Some(l)) => (c, l),
_ => continue,
_ => (&CharacterState::Idle, &Last {
0: CharacterState::Idle,
}),
};
if !character.same_variant(&last_character.0) {
@ -3538,11 +3540,33 @@ impl FigureMgr {
(
active_tool_kind,
second_tool_kind,
vel.0.magnitude(),
ori,
state.last_ori,
time,
Some(s.stage_section),
*body,
),
stage_progress,
&mut state_animation_rate,
skeleton_attr,
)
},
CharacterState::BasicBeam(s) => {
let stage_time = s.timer.as_secs_f64();
let stage_progress = match s.stage_section {
StageSection::Buildup => {
stage_time / s.static_data.buildup_duration.as_secs_f64()
},
StageSection::Cast => s.timer.as_secs_f64(),
StageSection::Recover => {
stage_time / s.static_data.recover_duration.as_secs_f64()
},
_ => 0.0,
};
anim::object::BeamAnimation::update_skeleton(
&target_base,
(
active_tool_kind,
second_tool_kind,
Some(s.stage_section),
*body,
),
stage_progress,
&mut state_animation_rate,

View File

@ -8,6 +8,7 @@ use crate::{
};
use common::{
assets::{AssetExt, DotVoxAsset},
combat::CombatEffect,
comp::{item::Reagent, object, BeamSegment, Body, CharacterState, Ori, Pos, Shockwave},
figure::Segment,
outcome::Outcome,
@ -376,7 +377,12 @@ impl ParticleMgr {
.filter(|(_, _, b)| b.creation.map_or(true, |c| (c + dt as f64) >= time))
{
let range = beam.properties.speed * beam.properties.duration.as_secs_f32();
if beam.properties.lifesteal_eff > 0.0 {
if beam
.properties
.attack
.effects()
.any(|e| matches!(e.effect(), CombatEffect::Heal(h) if *h > 0.0))
{
// Emit a light when using healing
lights.push(Light::new(pos.0, Rgb::new(0.1, 1.0, 0.15), 1.0));
for i in 0..self.scheduler.heartbeats(Duration::from_millis(1)) {
@ -385,25 +391,25 @@ impl ParticleMgr {
time + i as f64 / 1000.0,
ParticleMode::HealingBeam,
pos.0,
pos.0 + *ori.0 * range,
pos.0 + *ori.look_dir() * range,
));
}
} else {
let mut rng = thread_rng();
let (from, to) = (Vec3::<f32>::unit_z(), *ori.0);
let (from, to) = (Vec3::<f32>::unit_z(), *ori.look_dir());
let m = Mat3::<f32>::rotation_from_to_3d(from, to);
// Emit a light when using flames
lights.push(Light::new(
pos.0,
Rgb::new(1.0, 0.25, 0.05).map(|e| e * rng.gen_range(0.8, 1.2)),
Rgb::new(1.0, 0.25, 0.05).map(|e| e * rng.gen_range(0.8..1.2)),
2.0,
));
self.particles.resize_with(
self.particles.len()
+ 2 * usize::from(self.scheduler.heartbeats(Duration::from_millis(1))),
|| {
let phi: f32 = rng.gen_range(0.0, beam.properties.angle.to_radians());
let theta: f32 = rng.gen_range(0.0, 2.0 * PI);
let phi: f32 = rng.gen_range(0.0..beam.properties.angle.to_radians());
let theta: f32 = rng.gen_range(0.0..2.0 * PI);
let offset_z =
Vec3::new(phi.sin() * theta.cos(), phi.sin() * theta.sin(), phi.cos());
let random_ori = offset_z * m * Vec3::new(-1.0, -1.0, 1.0);

View File

@ -701,6 +701,12 @@ impl Floor {
.with_main_tool(comp::Item::new_from_asset_expect(
"common.items.weapons.staff.cultist_staff",
)),
1 => entity
.with_body(comp::Body::Object(comp::object::Body::Crossbow))
.with_name("Possessed Turret".to_string())
.with_loot_drop(comp::Item::new_from_asset_expect(
"common.items.crafting_ing.twigs",
)),
_ => entity
.with_name("Cultist Warlord")
.with_loadout_config(loadout_builder::LoadoutConfig::Warlord)

View File

@ -884,7 +884,7 @@ impl Settlement {
.with_body(match dynamic_rng.gen_range(0..5) {
_ if is_dummy => {
is_human = false;
object::Body::Crossbow.into()
object::Body::TrainingDummy.into()
},
0 => {
let species = match dynamic_rng.gen_range(0..3) {
@ -916,9 +916,9 @@ impl Settlement {
comp::Body::Humanoid(humanoid::Body::random())
},
})
.with_agency(true) // TEMPORARY
.with_agency(!is_dummy)
.with_alignment(if is_dummy {
comp::Alignment::Enemy // TEMPORARY
comp::Alignment::Passive
} else if is_human {
comp::Alignment::Npc
} else {