forked from VoxeLibre/VoxeLibre
Add in sound_handling and make explosion type mobs make their attack sound before explosion animation
This commit is contained in:
parent
0b763f54b5
commit
bf367fffd0
|
@ -157,6 +157,7 @@ dofile(api_path .. "interaction.lua")
|
||||||
dofile(api_path .. "movement.lua")
|
dofile(api_path .. "movement.lua")
|
||||||
dofile(api_path .. "set_up.lua")
|
dofile(api_path .. "set_up.lua")
|
||||||
dofile(api_path .. "attack_type_instructions.lua")
|
dofile(api_path .. "attack_type_instructions.lua")
|
||||||
|
dofile(api_path .. "sound_handling.lua")
|
||||||
|
|
||||||
|
|
||||||
mobs.spawning_mobs = {}
|
mobs.spawning_mobs = {}
|
||||||
|
|
|
@ -14,8 +14,6 @@ mobs.explode_attack_walk = function(self,dtime)
|
||||||
mobs.set_yaw_while_attacking(self)
|
mobs.set_yaw_while_attacking(self)
|
||||||
|
|
||||||
--make mob walk up to player within 2 nodes distance then start exploding
|
--make mob walk up to player within 2 nodes distance then start exploding
|
||||||
|
|
||||||
--THIS NEEDS TO BE RECODED TO TAKE COLLISION BOXES INTO ACCOUNT!!!
|
|
||||||
if vector_distance(self.object:get_pos(), self.attacking:get_pos()) >= self.reach then
|
if vector_distance(self.object:get_pos(), self.attacking:get_pos()) >= self.reach then
|
||||||
mobs.set_velocity(self, self.run_velocity)
|
mobs.set_velocity(self, self.run_velocity)
|
||||||
mobs.set_mob_animation(self,"run")
|
mobs.set_mob_animation(self,"run")
|
||||||
|
@ -28,12 +26,17 @@ mobs.explode_attack_walk = function(self,dtime)
|
||||||
if not self.explosion_animation then
|
if not self.explosion_animation then
|
||||||
self.explosion_animation = 0
|
self.explosion_animation = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--play ignite sound
|
||||||
|
if self.explosion_animation == 0 then
|
||||||
|
mobs.play_sound(self,"attack")
|
||||||
|
end
|
||||||
|
|
||||||
mobs.set_mob_animation(self,"stand")
|
mobs.set_mob_animation(self,"stand")
|
||||||
|
|
||||||
mobs.handle_explosion_animation(self)
|
mobs.handle_explosion_animation(self)
|
||||||
|
|
||||||
self.explosion_animation = self.explosion_animation + (dtime/2)
|
self.explosion_animation = self.explosion_animation + (dtime/2)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--make explosive mobs jump
|
--make explosive mobs jump
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
local math_random = math.random
|
||||||
|
|
||||||
|
|
||||||
|
--generic call for sound handler for mobs (data access)
|
||||||
|
mobs.play_sound = function(self,sound)
|
||||||
|
local soundinfo = self.sounds
|
||||||
|
|
||||||
|
if not soundinfo then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local play_sound = soundinfo[sound]
|
||||||
|
|
||||||
|
if not play_sound then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
mobs.play_sound_handler(self, play_sound)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--generic sound handler for mobs
|
||||||
|
mobs.play_sound_handler = function(self, sound)
|
||||||
|
local pitch = (100 + math_random(-15,15) + math_random()) / 100
|
||||||
|
|
||||||
|
minetest.sound_play(sound, {
|
||||||
|
object = self.object,
|
||||||
|
gain = 1.0,
|
||||||
|
max_hear_distance = self.sounds.distance,
|
||||||
|
pitch = pitch,
|
||||||
|
}, true)
|
||||||
|
end
|
Loading…
Reference in New Issue