diff --git a/resources/sounds/hit/whoosh1.ogg b/resources/sounds/hit/whoosh1.ogg new file mode 100644 index 0000000..efa1a04 Binary files /dev/null and b/resources/sounds/hit/whoosh1.ogg differ diff --git a/resources/sounds/hit/whoosh2.ogg b/resources/sounds/hit/whoosh2.ogg new file mode 100644 index 0000000..e4dfd54 Binary files /dev/null and b/resources/sounds/hit/whoosh2.ogg differ diff --git a/resources/sounds/hit/whoosh3.ogg b/resources/sounds/hit/whoosh3.ogg new file mode 100644 index 0000000..7ffda42 Binary files /dev/null and b/resources/sounds/hit/whoosh3.ogg differ diff --git a/resources/sounds/hit/whoosh4.ogg b/resources/sounds/hit/whoosh4.ogg new file mode 100644 index 0000000..5e2b4a2 Binary files /dev/null and b/resources/sounds/hit/whoosh4.ogg differ diff --git a/src/effects/damage.rs b/src/effects/damage.rs index 779940c..88342f9 100644 --- a/src/effects/damage.rs +++ b/src/effects/damage.rs @@ -15,6 +15,7 @@ use crate::{ HungerState, Bleeds, HasDamageModifiers, + DamageType, }; use crate::gui::with_article; use crate::consts::visuals::{ DEFAULT_PARTICLE_LIFETIME, LONG_PARTICLE_LIFETIME }; @@ -99,6 +100,27 @@ pub fn inflict_damage(ecs: &mut World, damage: &EffectSpawner, target: Entity) { } else if let Some(_destructible) = ecs.read_storage::().get(target) { add_effect(damage.source, EffectType::EntityDeath, Targets::Entity { target }); } + if let EffectType::Damage { amount: _, damage_type } = &damage.effect_type { + get_random_damage_sound(ecs, damage_type, target); + } +} + +fn get_random_damage_sound(ecs: &World, damage_type: &DamageType, target: Entity) { + let mut rng = ecs.write_resource::(); + match damage_type { + DamageType::Physical => { + let sound = ( + match rng.roll_dice(1, 4) { + 1 => "whoosh1", + 2 => "whoosh2", + 3 => "whoosh3", + _ => "whoosh4", + } + ).to_string(); + add_effect(None, EffectType::Sound { sound }, Targets::Entity { target }); + } + _ => {} + } } pub fn heal_damage(ecs: &mut World, heal: &EffectSpawner, target: Entity) { diff --git a/src/effects/sound.rs b/src/effects/sound.rs index 1f8cb40..1b84a2b 100644 --- a/src/effects/sound.rs +++ b/src/effects/sound.rs @@ -76,6 +76,10 @@ pub fn init_sounds(app: &mut App) { let sound_data: &[(&str, &[u8], AudioType)] = &[ // (key, file_path, audiotype) ("a_relax", include_bytes!("../../resources/sounds/amb/relaxed.ogg"), AudioType::Ambient), + ("whoosh1", include_bytes!("../../resources/sounds/hit/whoosh1.ogg"), AudioType::SFX), + ("whoosh2", include_bytes!("../../resources/sounds/hit/whoosh2.ogg"), AudioType::SFX), + ("whoosh3", include_bytes!("../../resources/sounds/hit/whoosh3.ogg"), AudioType::SFX), + ("whoosh4", include_bytes!("../../resources/sounds/hit/whoosh4.ogg"), AudioType::SFX), ("d_blocked1", include_bytes!("../../resources/sounds/door/blocked1.wav"), AudioType::SFX), ("d_blocked2", include_bytes!("../../resources/sounds/door/blocked2.wav"), AudioType::SFX), ("d_blocked3", include_bytes!("../../resources/sounds/door/blocked3.wav"), AudioType::SFX),