1
0
Fork 0

Mobs: Prevent jump sound spam

objects
Wuzzy 2019-01-31 02:44:05 +01:00
parent 7465d7a107
commit a2b39ed943
2 changed files with 9 additions and 2 deletions

View File

@ -787,7 +787,10 @@ local do_jump = function(self)
end, self, v) end, self, v)
if get_velocity(self) > 0 then if get_velocity(self) > 0 then
mob_sound(self, self.sounds.jump) if self.jump_sound_cooloff <= 0 then
mob_sound(self, self.sounds.jump)
self.jump_sound_cooloff = 0.5
end
end end
else else
self.facing_fence = true self.facing_fence = true
@ -2698,6 +2701,7 @@ local mob_activate = function(self, staticdata, def, dtime)
self.selectionbox = selbox self.selectionbox = selbox
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
-- check existing nametag -- check existing nametag
if not self.nametag then if not self.nametag then
@ -2769,6 +2773,9 @@ local mob_step = function(self, dtime)
end end
end end
if self.jump_sound_cooloff > 0 then
self.jump_sound_cooloff = self.jump_sound_cooloff - dtime
end
falling(self, pos) falling(self, pos)
-- smooth rotation by ThomasMonroe314 -- smooth rotation by ThomasMonroe314

View File

@ -137,7 +137,7 @@ functions needed for the mob to work properly which contains the following:
'shoot_attack' sound played when mob shoots. 'shoot_attack' sound played when mob shoots.
'damage' sound heard when mob is hurt. 'damage' sound heard when mob is hurt.
'death' played when mob is killed. 'death' played when mob is killed.
'jump' played when mob jumps. 'jump' played when mob jumps. There's a built-in cooloff timer to avoid sound spam
'fuse' sound played when mob explode timer starts. 'fuse' sound played when mob explode timer starts.
'explode' sound played when mob explodes. 'explode' sound played when mob explodes.