diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index 9f4ec1787..ad2b9cb54 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -264,7 +264,6 @@ function mobs:register_mob(name, def) tamed = false, pause_timer = 0, gotten = false, - health = 0, reach = def.reach or 3, htimer = 0, texture_list = def.textures, @@ -362,6 +361,10 @@ function mobs:register_mob(name, def) ignores_cobwebs = def.ignores_cobwebs, breath = def.breath_max or 6, + + --random_sound_timer = 0, + random_sound_timer_min = 3, + random_sound_timer_max = 10, --end j4i stuff -- MCL2 extensions diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index a4b0df808..957b44ea0 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -829,9 +829,18 @@ mobs.mob_step = function(self, dtime) end end - --do death logic (animation, poof, explosion, etc) - if self.health <= 0 then + --color modifier which coincides with the pause_timer + if self.old_health and self.health < self.old_health then + self.object:set_texture_mod("^[colorize:red:120") + --fix double death sound + if self.health > 0 then + mobs.play_sound(self,"damage") + end + end + self.old_health = self.health + --do death logic (animation, poof, explosion, etc) + if self.health <= 0 or self.dead then --play death sound once if not self.played_death_sound then self.dead = true @@ -855,12 +864,9 @@ mobs.mob_step = function(self, dtime) return end - --color modifier which coincides with the pause_timer - if self.old_health and self.health < self.old_health then - self.object:set_texture_mod("^[colorize:red:120") - mobs.play_sound(self,"damage") - end - self.old_health = self.health + mobs.random_sound_handling(self,dtime) + + --mobs drowning mechanic diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua index b4de9a1c2..918373272 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua @@ -137,10 +137,17 @@ mobs.mob_activate = function(self, staticdata, def, dtime) } end - if not self.dead and self.health == 0 then + --stop mobs from reviving + if not self.dead and not self.health then self.health = math_random (self.hp_min, self.hp_max) end + + + if not self.random_sound_timer then + self.random_sound_timer = math_random(self.random_sound_timer_min,self.random_sound_timer_max) + end + if self.breath == nil then self.breath = self.breath_max end @@ -178,13 +185,21 @@ mobs.mob_activate = function(self, staticdata, def, dtime) self.opinion_sound_cooloff = 0 -- used to prevent sound spam of particular sound types self.texture_mods = {} - self.object:set_texture_mod("") + self.v_start = false self.timer = 0 self.blinktimer = 0 self.blinkstatus = false + + --continue mob effect on server restart + if self.dead or self.health <= 0 then + self.object:set_texture_mod("^[colorize:red:120") + else + self.object:set_texture_mod("") + end + -- check existing nametag if not self.nametag then self.nametag = def.nametag diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/sound_handling.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/sound_handling.lua index e699a1f29..182b762e2 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/sound_handling.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/sound_handling.lua @@ -22,11 +22,26 @@ end --generic sound handler for mobs mobs.play_sound_handler = function(self, sound) local pitch = (100 + math_random(-15,15) + math_random()) / 100 + local distance = self.sounds.distance or 16 minetest.sound_play(sound, { object = self.object, gain = 1.0, - max_hear_distance = self.sounds.distance, + max_hear_distance = distance, pitch = pitch, }, true) +end + + +--random sound timing handler +mobs.random_sound_handling = function(self,dtime) + + self.random_sound_timer = self.random_sound_timer - dtime + + --play sound and reset timer + if self.random_sound_timer <= 0 then + mobs.play_sound(self,"random") + self.random_sound_timer = math_random(self.random_sound_timer_min,self.random_sound_timer_max) + end + end \ No newline at end of file diff --git a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.4.ogg b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.4.ogg index 5c9ee492b..acb236445 100644 Binary files a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.4.ogg and b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.4.ogg differ diff --git a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.5.ogg b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.5.ogg index acb236445..1ef7a5227 100644 Binary files a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.5.ogg and b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.5.ogg differ diff --git a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.6.ogg b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.6.ogg index 1ef7a5227..c2743fbcc 100644 Binary files a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.6.ogg and b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.6.ogg differ diff --git a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.7.ogg b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.7.ogg deleted file mode 100644 index c2743fbcc..000000000 Binary files a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager.7.ogg and /dev/null differ diff --git a/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager_hurt.1.ogg b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager_hurt.1.ogg new file mode 100644 index 000000000..5c9ee492b Binary files /dev/null and b/mods/ENTITIES/mobs_mc/sounds/mobs_mc_villager_hurt.1.ogg differ diff --git a/mods/ENTITIES/mobs_mc/villager.lua b/mods/ENTITIES/mobs_mc/villager.lua index e6892253e..225008870 100644 --- a/mods/ENTITIES/mobs_mc/villager.lua +++ b/mods/ENTITIES/mobs_mc/villager.lua @@ -971,6 +971,8 @@ mobs:register_mob("mobs_mc:villager", { -- TODO: sounds sounds = { random = "mobs_mc_villager", + damage = "mobs_mc_villager_hurt", + death = "mobs_mc_villager_hurt", distance = 10, }, animation = {