From b8d3e7473b8094cc7afd676594e9043fb2ba1596 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 8 Mar 2019 23:11:44 +0100 Subject: [PATCH] Mob sfx: Random pitch, higher pitch for children --- mods/ENTITIES/mcl_mobs/api.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index dfc4c7733..f443be5c3 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -105,10 +105,20 @@ local mob_sound = function(self, sound, is_opinion) if is_opinion and self.opinion_sound_cooloff > 0 then return end + local pitch + if self.child then + -- Children have high pitch + pitch = 1.5 + else + pitch = 1.0 + end + -- randomize the pitch a bit + local pitch = pitch + math.random(-10, 10) * 0.005 minetest.sound_play(sound, { object = self.object, gain = 1.0, - max_hear_distance = self.sounds.distance + max_hear_distance = self.sounds.distance, + pitch = pitch, }) self.opinion_sound_cooloff = 1 end