add blood splatter and weapon sounds when player is hit

pull/2/head
Brandon 2014-05-17 00:09:17 -05:00
parent e6444d58d4
commit fe05e9f39b
2 changed files with 25 additions and 1 deletions

View File

@ -1,3 +1,3 @@
-- VARIOUS MISC ADVENTURETEST RELATED STUFF
dofile(minetest.get_modpath("adventuretest").."/privs.lua")
dofile(minetest.get_modpath("adventuretest").."/privs.lua")

View File

@ -207,3 +207,27 @@ minetest.register_globalstep(function(dtime)
end
end
end)
if minetest.register_on_punchplayer ~= nil then
minetest.register_on_punchplayer( function(player, hitter, time_from_last_punch, tool_capabilities, dir)
local weapon = hitter:get_wielded_item()
if tool_capabilities ~= nil then
local wear = ( tool_capabilities.full_punch_interval / 75 ) * 65535
weapon:add_wear(wear)
hitter:set_wielded_item(weapon)
end
if weapon:get_definition().sounds ~= nil then
local s = math.random(0,#weapon:get_definition().sounds)
minetest.sound_play(weapon:get_definition().sounds[s], {
object=hitter,
})
else
minetest.sound_play("default_sword_wood", {
object = hitter,
})
end
blood_particles(player:getpos(),0.25,27,"mobs_blood.png")
end)
end