mirror of
https://git.minetest.land/Mineclonia/Mineclonia.git
synced 2024-12-01 00:13:05 +00:00
Add more mob sound cooloffs
This commit is contained in:
parent
626f7f6e97
commit
e1e7d5215e
2 changed files with 17 additions and 7 deletions
|
@ -98,14 +98,18 @@ local mod_tnt = minetest.get_modpath("mcl_tnt") ~= nil
|
||||||
local mod_mobspawners = minetest.get_modpath("mcl_mobspawners") ~= nil
|
local mod_mobspawners = minetest.get_modpath("mcl_mobspawners") ~= nil
|
||||||
|
|
||||||
-- play sound
|
-- play sound
|
||||||
local mob_sound = function(self, sound)
|
local mob_sound = function(self, sound, is_opinion)
|
||||||
|
|
||||||
if sound then
|
if sound then
|
||||||
|
if is_opinion and self.opinion_sound_cooloff > 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
minetest.sound_play(sound, {
|
minetest.sound_play(sound, {
|
||||||
object = self.object,
|
object = self.object,
|
||||||
gain = 1.0,
|
gain = 1.0,
|
||||||
max_hear_distance = self.sounds.distance
|
max_hear_distance = self.sounds.distance
|
||||||
})
|
})
|
||||||
|
self.opinion_sound_cooloff = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -121,7 +125,7 @@ local do_attack = function(self, player)
|
||||||
self.state = "attack"
|
self.state = "attack"
|
||||||
|
|
||||||
if random(0, 100) < 90 then
|
if random(0, 100) < 90 then
|
||||||
mob_sound(self, self.sounds.war_cry)
|
mob_sound(self, self.sounds.war_cry, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1291,10 +1295,10 @@ local smart_mobs = function(self, s, p, dist, dtime)
|
||||||
self.path.stuck_timer = stuck_timeout - 2
|
self.path.stuck_timer = stuck_timeout - 2
|
||||||
|
|
||||||
-- frustration! cant find the damn path :(
|
-- frustration! cant find the damn path :(
|
||||||
mob_sound(self, self.sounds.random)
|
mob_sound(self, self.sounds.random, true)
|
||||||
else
|
else
|
||||||
-- yay i found path
|
-- yay i found path
|
||||||
mob_sound(self, self.sounds.war_cry)
|
mob_sound(self, self.sounds.war_cry, true)
|
||||||
set_velocity(self, self.walk_velocity)
|
set_velocity(self, self.walk_velocity)
|
||||||
|
|
||||||
-- follow path now that it has it
|
-- follow path now that it has it
|
||||||
|
@ -2702,6 +2706,7 @@ local mob_activate = function(self, staticdata, def, dtime)
|
||||||
self.visual_size = vis_size
|
self.visual_size = vis_size
|
||||||
self.standing_in = ""
|
self.standing_in = ""
|
||||||
self.jump_sound_cooloff = 0 -- used to prevent jump sound from being played too often in short time
|
self.jump_sound_cooloff = 0 -- used to prevent jump sound from being played too often in short time
|
||||||
|
self.opinion_sound_cooloff = 0 -- used to prevent sound spam of particular sound types
|
||||||
|
|
||||||
-- check existing nametag
|
-- check existing nametag
|
||||||
if not self.nametag then
|
if not self.nametag then
|
||||||
|
@ -2776,6 +2781,9 @@ local mob_step = function(self, dtime)
|
||||||
if self.jump_sound_cooloff > 0 then
|
if self.jump_sound_cooloff > 0 then
|
||||||
self.jump_sound_cooloff = self.jump_sound_cooloff - dtime
|
self.jump_sound_cooloff = self.jump_sound_cooloff - dtime
|
||||||
end
|
end
|
||||||
|
if self.opinion_sound_cooloff > 0 then
|
||||||
|
self.opinion_sound_cooloff = self.opinion_sound_cooloff - dtime
|
||||||
|
end
|
||||||
falling(self, pos)
|
falling(self, pos)
|
||||||
|
|
||||||
-- smooth rotation by ThomasMonroe314
|
-- smooth rotation by ThomasMonroe314
|
||||||
|
@ -2854,7 +2862,7 @@ local mob_step = function(self, dtime)
|
||||||
|
|
||||||
-- mob plays random sound at times
|
-- mob plays random sound at times
|
||||||
if random(1, 100) == 1 then
|
if random(1, 100) == 1 then
|
||||||
mob_sound(self, self.sounds.random)
|
mob_sound(self, self.sounds.random, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- environmental damage timer (every 1 second)
|
-- environmental damage timer (every 1 second)
|
||||||
|
@ -3662,7 +3670,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- make sound when fed so many times
|
-- make sound when fed so many times
|
||||||
mob_sound(self, self.sounds.random)
|
mob_sound(self, self.sounds.random, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -131,7 +131,9 @@ functions needed for the mob to work properly which contains the following:
|
||||||
'makes_footstep_sound' when true you can hear mobs walking.
|
'makes_footstep_sound' when true you can hear mobs walking.
|
||||||
'sounds' this is a table with sounds of the mob
|
'sounds' this is a table with sounds of the mob
|
||||||
'distance' maximum distance sounds can be heard, default is 10.
|
'distance' maximum distance sounds can be heard, default is 10.
|
||||||
'random' random sound that plays during gameplay.
|
'random' played randomly from time to time.
|
||||||
|
also played when mob is frustrated for not finding the path.
|
||||||
|
also played for overfeeding animal.
|
||||||
'war_cry' what you hear when mob starts to attack player.
|
'war_cry' what you hear when mob starts to attack player.
|
||||||
'attack' what you hear when being attacked.
|
'attack' what you hear when being attacked.
|
||||||
'shoot_attack' sound played when mob shoots.
|
'shoot_attack' sound played when mob shoots.
|
||||||
|
|
Loading…
Reference in a new issue