2019-04-06 21:23:14 -04:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
2019-04-06 23:51:05 -04:00
|
|
|
local minetest, nodecore
|
2019-04-08 08:52:59 -04:00
|
|
|
= minetest, nodecore
|
2019-04-06 21:23:14 -04:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
minetest.register_on_player_hpchange(function(player, hp)
|
2019-04-08 08:26:44 -04:00
|
|
|
local orig = player:get_hp()
|
2019-09-12 19:30:05 -04:00
|
|
|
if player:get_armor_groups().immortal then
|
|
|
|
return orig
|
|
|
|
end
|
2019-04-06 21:23:14 -04:00
|
|
|
if hp < 0 then
|
2019-04-08 08:26:44 -04:00
|
|
|
minetest.after(0, function()
|
|
|
|
local now = player:get_hp()
|
|
|
|
if now >= orig then return end
|
|
|
|
nodecore.sound_play_except("player_damage", {
|
|
|
|
pos = player:get_pos(),
|
|
|
|
gain = 0.5
|
2019-08-27 19:14:51 -04:00
|
|
|
}, player)
|
2019-04-08 08:26:44 -04:00
|
|
|
end)
|
2019-04-06 21:23:14 -04:00
|
|
|
end
|
2019-04-08 08:26:44 -04:00
|
|
|
if hp + orig <= 0 then
|
|
|
|
hp = 1 - orig
|
2019-04-06 21:23:14 -04:00
|
|
|
player:get_meta():set_float("dhp", -1)
|
|
|
|
end
|
|
|
|
return hp
|
2019-08-27 19:14:51 -04:00
|
|
|
end,
|
|
|
|
true
|
|
|
|
)
|