From 3ec5306ed0057e501908256b8ec266dfe5577f91 Mon Sep 17 00:00:00 2001 From: Snowram Date: Sun, 27 Jun 2021 23:45:07 +0200 Subject: [PATCH] Adds an outcome to death with SFX and VFX --- CHANGELOG.md | 1 + assets/voxygen/audio/sfx.ron | 8 ++++++++ assets/voxygen/audio/sfx/character/death_1.ogg | 3 +++ assets/voxygen/audio/sfx/character/death_2.ogg | 3 +++ assets/voxygen/audio/sfx/character/death_3.ogg | 3 +++ assets/voxygen/shaders/particle-vert.glsl | 15 ++++++++++++++- common/src/outcome.rs | 4 ++++ server/src/events/entity_manipulation.rs | 15 +++++++++++++++ voxygen/src/audio/sfx/mod.rs | 5 +++++ voxygen/src/render/pipelines/particle.rs | 1 + voxygen/src/scene/particle.rs | 13 +++++++++++++ 11 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 assets/voxygen/audio/sfx/character/death_1.ogg create mode 100644 assets/voxygen/audio/sfx/character/death_2.ogg create mode 100644 assets/voxygen/audio/sfx/character/death_3.ogg diff --git a/CHANGELOG.md b/CHANGELOG.md index e7c26d1a12..4b4690b7f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Made strafing slightly slower - Food now has limited regeneration strength but longer duration. - Harvester boss now has new abilities and AI +- Death particles and SFX ### Removed diff --git a/assets/voxygen/audio/sfx.ron b/assets/voxygen/audio/sfx.ron index eaac0f0241..9a794c203a 100644 --- a/assets/voxygen/audio/sfx.ron +++ b/assets/voxygen/audio/sfx.ron @@ -777,6 +777,14 @@ ], threshold: 0.2, ), + Death: ( + files: [ + "voxygen.audio.sfx.character.death_1", + "voxygen.audio.sfx.character.death_2", + "voxygen.audio.sfx.character.death_3", + ], + threshold: 0.2, + ), Block: ( files: [ "voxygen.audio.sfx.character.block_1", diff --git a/assets/voxygen/audio/sfx/character/death_1.ogg b/assets/voxygen/audio/sfx/character/death_1.ogg new file mode 100644 index 0000000000..b7914f991c --- /dev/null +++ b/assets/voxygen/audio/sfx/character/death_1.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9cddb5ffb0c2a953d53ff5d1c3c7a409550aca39e5887872edecda56d7bc7515 +size 11029 diff --git a/assets/voxygen/audio/sfx/character/death_2.ogg b/assets/voxygen/audio/sfx/character/death_2.ogg new file mode 100644 index 0000000000..c7be6586f1 --- /dev/null +++ b/assets/voxygen/audio/sfx/character/death_2.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6956521655723d4d8754658a4791455ac7b646f4f87cef315ea883eb3416eabc +size 11038 diff --git a/assets/voxygen/audio/sfx/character/death_3.ogg b/assets/voxygen/audio/sfx/character/death_3.ogg new file mode 100644 index 0000000000..a22c7585db --- /dev/null +++ b/assets/voxygen/audio/sfx/character/death_3.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:13eee7ce6b6ac555b77a1e432518a5c8a9205a89d07f1e2fe8ca347ffc5ca2b6 +size 11060 diff --git a/assets/voxygen/shaders/particle-vert.glsl b/assets/voxygen/shaders/particle-vert.glsl index 3cd9721a47..7a2396d69f 100644 --- a/assets/voxygen/shaders/particle-vert.glsl +++ b/assets/voxygen/shaders/particle-vert.glsl @@ -72,6 +72,7 @@ const int WATER = 30; const int ICE_SPIKES = 31; const int DRIP = 32; const int TORNADO = 33; +const int DEATH = 34; // meters per second squared (acceleration) const float earth_gravity = 9.807; @@ -553,13 +554,25 @@ void main() { spin_in_axis(vec3(rand6, rand7, rand8), percent() * 10 + 3 * rand9) ); break; + case DEATH: + f_reflect = 0.0; + attr = Attr( + linear_motion( + vec3(0), + vec3(rand2 * 0.02, rand3 * 0.02, 2.0 + rand4 * 0.6) + ), + vec3((1.2 * (1 - slow_start(.1)))), + vec4(vec3(1.2 + 0.5 * percent()), 1), + spin_in_axis(vec3(rand6, rand7, rand8), percent() * 10 + 3 * rand9) + ); + break; default: attr = Attr( linear_motion( vec3(rand0 * 0.25, rand1 * 0.25, 1.7 + rand5), vec3(rand2 * 0.1, rand3 * 0.1, 1.0 + rand4 * 0.5) ), - vec3(exp_scale(-0.2)), + vec3(exp_scale(-0.2)) * rand0, vec4(1), spin_in_axis(vec3(1,0,0),0) ); diff --git a/common/src/outcome.rs b/common/src/outcome.rs index feeb1e8fec..51d87d54ce 100644 --- a/common/src/outcome.rs +++ b/common/src/outcome.rs @@ -61,6 +61,9 @@ pub enum Outcome { Damage { pos: Vec3, }, + Death { + pos: Vec3, + }, Block { pos: Vec3, parry: bool, @@ -90,6 +93,7 @@ impl Outcome { | Outcome::SkillPointGain { pos, .. } | Outcome::SummonedCreature { pos, .. } | Outcome::Damage { pos, .. } + | Outcome::Death { pos, .. } | Outcome::Block { pos, .. } | Outcome::PoiseChange { pos, .. } | Outcome::GroundSlam { pos } diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index b01f17e13a..e7ae6e47f1 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -138,6 +138,21 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc } }; + // Push an outcome + if state + .ecs() + .read_storage::() + .get(entity) + .is_none() + { + if let Some(pos) = state.ecs().read_storage::().get(entity) { + state + .ecs() + .write_resource::>() + .push(Outcome::Death { pos: pos.0 }); + } + } + // Chat message // If it was a player that died if let Some(_player) = state.ecs().read_storage::().get(entity) { diff --git a/voxygen/src/audio/sfx/mod.rs b/voxygen/src/audio/sfx/mod.rs index 061cd592ca..0bc8f53c5f 100644 --- a/voxygen/src/audio/sfx/mod.rs +++ b/voxygen/src/audio/sfx/mod.rs @@ -171,6 +171,7 @@ pub enum SfxEvent { Inventory(SfxInventoryEvent), Explosion, Damage, + Death, Parry, Block, BreakBlock, @@ -505,6 +506,10 @@ impl SfxMgr { let sfx_trigger_item = triggers.get_key_value(&SfxEvent::Damage); audio.emit_sfx(sfx_trigger_item, *pos, Some(1.5), false); }, + Outcome::Death { pos, .. } => { + let sfx_trigger_item = triggers.get_key_value(&SfxEvent::Death); + audio.emit_sfx(sfx_trigger_item, *pos, Some(1.5), false); + }, Outcome::Block { pos, parry, .. } => { if *parry { let sfx_trigger_item = triggers.get_key_value(&SfxEvent::Parry); diff --git a/voxygen/src/render/pipelines/particle.rs b/voxygen/src/render/pipelines/particle.rs index 381ff30cd2..d064348eea 100644 --- a/voxygen/src/render/pipelines/particle.rs +++ b/voxygen/src/render/pipelines/particle.rs @@ -84,6 +84,7 @@ pub enum ParticleMode { IceSpikes = 31, Drip = 32, Tornado = 33, + Death = 34, } impl ParticleMode { diff --git a/voxygen/src/scene/particle.rs b/voxygen/src/scene/particle.rs index 1b70bd660f..9465868dc3 100644 --- a/voxygen/src/scene/particle.rs +++ b/voxygen/src/scene/particle.rs @@ -242,6 +242,19 @@ impl ParticleMgr { ) }); }, + Outcome::Death { pos, .. } => { + self.particles.resize_with(self.particles.len() + 40, || { + Particle::new( + Duration::from_millis(400 + rng.gen_range(0..100)), + time, + ParticleMode::Death, + *pos + Vec3::unit_z() + + Vec3::::zero() + .map(|_| rng.gen_range(-0.1..0.1)) + .normalized(), + ) + }); + }, Outcome::ProjectileShot { .. } | Outcome::Beam { .. } | Outcome::ExpChange { .. }