726f385e52
- Players heal over time at variable speed, depending on subtle environmental factors. - This frees us up to work on the death mechanic, since it's no longer the only way to restore health and prevent an untimely death.
18 lines
590 B
Lua
18 lines
590 B
Lua
-- LUALOCALS < ---------------------------------------------------------
|
|
local math, nodecore, tonumber, tostring
|
|
= math, nodecore, tonumber, tostring
|
|
local math_ceil
|
|
= math.ceil
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
function nodecore.addphealth(player, hp)
|
|
local total = player:get_hp() + hp
|
|
+ tonumber(player:get_attribute("dhp") or "0")
|
|
if total > 20 then total = 20 end
|
|
if total < 0 then total = 0 end
|
|
local whole = math_ceil(total)
|
|
local dhp = total - whole
|
|
player:set_attribute("dhp", tostring(dhp))
|
|
return player:set_hp(whole)
|
|
end
|