From 75c0e3f4eba79003121ec35102870bcb10f01950 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 24 Mar 2021 13:58:28 -0400 Subject: [PATCH] Added particles for lifesteal effect --- common/src/comp/body.rs | 2 +- voxygen/src/scene/particle.rs | 50 +++++++++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index ddddfd04cd..70e16c6c96 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -285,7 +285,7 @@ impl Body { biped_large::Species::Slysaurok => 3.4, biped_large::Species::Occultsaurok => 3.4, biped_large::Species::Mightysaurok => 3.4, - biped_large::Species::Mindflayer => 6.3, + biped_large::Species::Mindflayer => 8.0, biped_large::Species::Minotaur => 8.0, biped_large::Species::Dullahan => 5.5, biped_large::Species::Cyclops => 6.5, diff --git a/voxygen/src/scene/particle.rs b/voxygen/src/scene/particle.rs index 5bfaf6e368..2706b4c878 100644 --- a/voxygen/src/scene/particle.rs +++ b/voxygen/src/scene/particle.rs @@ -423,7 +423,8 @@ impl ParticleMgr { let dt = scene_data.state.get_delta_time(); let mut rng = thread_rng(); - for (pos, vel, character_state, body) in ( + for (entity, pos, vel, character_state, body) in ( + &ecs.entities(), &ecs.read_storage::(), ecs.read_storage::().maybe(), &ecs.read_storage::(), @@ -451,16 +452,17 @@ impl ParticleMgr { match specifier { states::spin_melee::FrontendSpecifier::CultistVortex => { if matches!(spin.stage_section, StageSection::Swing) { + let range = spin.static_data.range; + // Particles for vortex let heartbeats = self.scheduler.heartbeats(Duration::from_millis(3)); self.particles.resize_with( self.particles.len() - + spin.static_data.range.powi(2) as usize - * usize::from(heartbeats) + + range.powi(2) as usize * usize::from(heartbeats) / 150, || { - let rand_dist = spin.static_data.range - * (1.0 - rng.gen::().powi(10)); + let rand_dist = + range * (1.0 - rng.gen::().powi(10)); let init_pos = Vec3::new( 2.0 * rng.gen::() - 1.0, 2.0 * rng.gen::() - 1.0, @@ -479,6 +481,44 @@ impl ParticleMgr { ) }, ); + // Particles for lifesteal effect + for (_entity_b, pos_b, body_b, _health_b) in ( + &ecs.entities(), + &ecs.read_storage::(), + &ecs.read_storage::(), + &ecs.read_storage::(), + ) + .join() + .filter(|(e, _, _, h)| !h.is_dead && entity != *e) + { + if pos.0.distance_squared(pos_b.0) < range.powi(2) { + let heartbeats = self + .scheduler + .heartbeats(Duration::from_millis(20)); + self.particles.resize_with( + self.particles.len() + + range.powi(2) as usize + * usize::from(heartbeats) + / 150, + || { + let start_pos = pos_b.0 + + Vec3::unit_z() * body_b.height() * 0.5 + + Vec3::::zero() + .map(|_| rng.gen_range(-1.0..1.0)) + .normalized() + * 1.0; + Particle::new_directed( + Duration::from_millis(900), + time, + ParticleMode::CultistFlame, + start_pos, + pos.0 + + Vec3::unit_z() * body.height() * 0.5, + ) + }, + ); + } + } } }, }