diff --git a/assets/common/abilities/unique/turret/basic.ron b/assets/common/abilities/unique/turret/basic.ron index 34880554e1..9a17bb4f0f 100644 --- a/assets/common/abilities/unique/turret/basic.ron +++ b/assets/common/abilities/unique/turret/basic.ron @@ -11,5 +11,5 @@ BasicBeam( energy_regen: 0, energy_cost: 0, energy_drain: 0, - orientation_behavior: Turret(5.0), + orientation_behavior: Turret, ) \ No newline at end of file diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 8e221167d4..17adf25c74 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -225,7 +225,7 @@ pub enum CharacterAbility { energy_regen: u32, energy_cost: u32, energy_drain: u32, - orientation_behavior: basic_beam::OrientationBehavior, + orientation_behavior: basic_beam::MovementBehavior, }, } diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index a71f9f810d..b814ce23ee 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -262,7 +262,10 @@ impl Body { _ => 4.6, }, Body::Golem(_) => 5.0, - Body::Object(_) => 1.0, + Body::Object(object) => match object { + object::Body::Crossbow => 1.7, + _ => 1.0, + }, } } diff --git a/common/src/comp/inventory/loadout_builder.rs b/common/src/comp/inventory/loadout_builder.rs index ece989aca2..5194ada70f 100644 --- a/common/src/comp/inventory/loadout_builder.rs +++ b/common/src/comp/inventory/loadout_builder.rs @@ -227,6 +227,7 @@ 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( diff --git a/common/src/states/basic_beam.rs b/common/src/states/basic_beam.rs index 888dd4a16d..c62741efe3 100644 --- a/common/src/states/basic_beam.rs +++ b/common/src/states/basic_beam.rs @@ -10,7 +10,6 @@ use crate::{ utils::*, }, uid::Uid, - util::Dir, Damage, DamageSource, GroupTarget, }; use serde::{Deserialize, Serialize}; @@ -46,7 +45,7 @@ pub struct StaticData { /// Energy drained per pub energy_drain: u32, /// Used to dictate how orientation functions in this state - pub orientation_behavior: OrientationBehavior, + pub orientation_behavior: MovementBehavior, /// What key is used to press ability pub ability_info: AbilityInfo, } @@ -69,16 +68,9 @@ impl CharacterBehavior for Data { let mut update = StateUpdate::from(data); match self.static_data.orientation_behavior { - OrientationBehavior::Normal => {}, - OrientationBehavior::Turret(speed) => { + MovementBehavior::Normal => {}, + MovementBehavior::Turret => { update.ori.0 = data.inputs.look_dir; - /*update.ori.0 = Dir::new( - Quaternion::from_xyzw(update.ori.0.x, update.ori.0.y, update.ori.0.z, 0.0) - .rotated_z(data.dt.0 as f32 * speed) - .into_vec3() - .try_normalized() - .unwrap_or_default(), - );*/ }, } @@ -114,8 +106,8 @@ impl CharacterBehavior for Data { }); // Gets offsets let body_offsets = Vec3::new( - (data.body.radius() + 1.0) * data.inputs.look_dir.x, - (data.body.radius() + 1.0) * data.inputs.look_dir.y, + (data.body.radius() + 1.0) * data.ori.0.x, + (data.body.radius() + 1.0) * data.ori.0.y, data.body.eye_height(), ) * 0.55; // Build up @@ -245,7 +237,7 @@ impl CharacterBehavior for Data { } #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] -pub enum OrientationBehavior { +pub enum MovementBehavior { Normal, - Turret(f32), + Turret, } diff --git a/voxygen/src/ecs/sys/interpolation.rs b/voxygen/src/ecs/sys/interpolation.rs index 6229f89306..26ea707c9d 100644 --- a/voxygen/src/ecs/sys/interpolation.rs +++ b/voxygen/src/ecs/sys/interpolation.rs @@ -1,6 +1,6 @@ use crate::ecs::comp::Interpolated; use common::{ - comp::{Ori, Pos, Vel}, + comp::{object, Body, Ori, Pos, Vel}, resources::DeltaTime, }; use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage}; @@ -17,20 +17,28 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, Pos>, ReadStorage<'a, Ori>, ReadStorage<'a, Vel>, + ReadStorage<'a, Body>, WriteStorage<'a, Interpolated>, ); fn run( &mut self, - (entities, dt, positions, orientations, velocities, mut interpolated): Self::SystemData, + (entities, dt, positions, orientations, velocities, mut interpolated, bodies): Self::SystemData, ) { // Update interpolated positions and orientations - for (pos, ori, i, vel) in (&positions, &orientations, &mut interpolated, &velocities).join() + for (pos, ori, i, vel, body) in ( + &positions, + &orientations, + &mut interpolated, + &velocities, + &bodies, + ) + .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, 10.0 * dt.0); - i.ori = Ori::slerp(i.ori, *ori, 5.0 * dt.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); } else { i.pos = pos.0; i.ori = *ori; @@ -72,3 +80,14 @@ impl<'a> System<'a> for Sys { } } } + +#[allow(clippy::collapsible_match)] +fn base_ori_interp(body: &Body) -> f32 { + match body { + Body::Object(object) => match object { + object::Body::Crossbow => 100.0, + _ => 10.0, + }, + _ => 10.0, + } +} diff --git a/voxygen/src/scene/particle.rs b/voxygen/src/scene/particle.rs index 0f79b4a1f8..1455c649ee 100644 --- a/voxygen/src/scene/particle.rs +++ b/voxygen/src/scene/particle.rs @@ -384,7 +384,7 @@ impl ParticleMgr { beam.properties.duration, time + i as f64 / 1000.0, ParticleMode::HealingBeam, - pos.0 + *ori.0 * 0.5, + pos.0, pos.0 + *ori.0 * range, )); } @@ -400,18 +400,12 @@ impl ParticleMgr { )); self.particles.resize_with( self.particles.len() - + 2 * usize::from( - self.scheduler.heartbeats(Duration::from_millis(1)), - ), + + 2 * usize::from(self.scheduler.heartbeats(Duration::from_millis(1))), || { - let phi: f32 = - rng.gen_range(0.0, beam.properties.angle.to_radians()); + 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 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); Particle::new_beam( beam.properties.duration,