mirror of
https://github.com/Poikilos/mobs.git
synced 2023-10-03 07:28:50 -07:00
dm shoot sound
This commit is contained in:
parent
c49cc4726c
commit
2fdcd61b95
55
api.lua
55
api.lua
@ -533,9 +533,55 @@ function mobs:register_arrow(name, def)
|
|||||||
hit_player = def.hit_player,
|
hit_player = def.hit_player,
|
||||||
hit_node = def.hit_node,
|
hit_node = def.hit_node,
|
||||||
|
|
||||||
|
count = 0,
|
||||||
|
sounds = {},
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
|
self.object:set_properties({textures = {"mobs_fireball.png^[transform"..math.random(0,7)}})
|
||||||
|
local vel = self.object:getvelocity()
|
||||||
|
local quiet = vector.equals(vel, {x=0,y=0,z=0})
|
||||||
|
if quiet
|
||||||
|
and (not self.vel or vector.equals(self.vel, {x=0,y=0,z=0})) then
|
||||||
|
for _,i in pairs(self.sounds) do
|
||||||
|
minetest.sound_stop(i)
|
||||||
|
end
|
||||||
|
self.object:remove()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not self.vel then
|
||||||
|
self.vel = vel
|
||||||
|
self.object:setvelocity({x=0,y=0,z=0})
|
||||||
|
local newp = vector.normalize({x=vel.x, y=0, z=vel.z})
|
||||||
|
self.object:setpos(vector.add(self.object:getpos(), newp))
|
||||||
|
for _,i in pairs(self.sounds) do
|
||||||
|
minetest.sound_stop(i)
|
||||||
|
end
|
||||||
|
end
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
if minetest.env:get_node(self.object:getpos()).name ~= "air" then
|
if quiet then
|
||||||
|
local count = self.count
|
||||||
|
if count >= 60 then
|
||||||
|
minetest.sound_play("mobs_fireball", {pos = pos})
|
||||||
|
for _,i in pairs(self.sounds) do
|
||||||
|
minetest.sound_stop(i)
|
||||||
|
end
|
||||||
|
self.object:setvelocity(self.vel)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
count = count+1
|
||||||
|
self.sounds[count] = minetest.sound_play("mobs_dm", {
|
||||||
|
pos = pos,
|
||||||
|
gain = count/50,
|
||||||
|
loop = true
|
||||||
|
})
|
||||||
|
self.count = count
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for _,i in pairs(self.sounds) do
|
||||||
|
minetest.sound_stop(i)
|
||||||
|
end
|
||||||
|
|
||||||
|
if minetest.env:get_node(pos).name ~= "air" then
|
||||||
self.hit_node(self, pos, node)
|
self.hit_node(self, pos, node)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
@ -548,6 +594,13 @@ function mobs:register_arrow(name, def)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_serialize = function(self)
|
||||||
|
self.object:remove()
|
||||||
|
for _,i in pairs(self.sounds) do
|
||||||
|
minetest.sound_stop(i)
|
||||||
end
|
end
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
4
init.lua
4
init.lua
@ -376,9 +376,9 @@ mobs:register_mob("mobs:dungeon_master", {
|
|||||||
attack_type = "shoot",
|
attack_type = "shoot",
|
||||||
arrow = "mobs:fireball",
|
arrow = "mobs:fireball",
|
||||||
shoot_interval = 2.5,
|
shoot_interval = 2.5,
|
||||||
sounds = {
|
--[[sounds = {
|
||||||
attack = "mobs_fireball",
|
attack = "mobs_fireball",
|
||||||
},
|
},--]]
|
||||||
animation = {
|
animation = {
|
||||||
stand_start = 0,
|
stand_start = 0,
|
||||||
stand_end = 19,
|
stand_end = 19,
|
||||||
|
BIN
sounds/mobs_dm.ogg
Normal file
BIN
sounds/mobs_dm.ogg
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user