Add hpregen for medics
This commit is contained in:
parent
34d891c6c5
commit
72c7563a85
4 changed files with 111 additions and 6 deletions
|
@ -34,7 +34,7 @@ function hp_bar:on_step(dtime)
|
|||
end
|
||||
|
||||
local hp = math.floor(20 * wielder:get_hp() / wielder:get_properties().hp_max)
|
||||
local breath = math.floor(20 * wielder:get_breath() / wielder:get_properties().breath_max)
|
||||
local breath = math.floor(11 * wielder:get_breath() / wielder:get_properties().breath_max)
|
||||
self.object:set_properties({
|
||||
textures = {
|
||||
"health_" .. tostring(hp) .. ".png^breath_" .. tostring(breath) .. ".png",
|
||||
|
|
|
@ -15,9 +15,21 @@ local function regen_all()
|
|||
if newhp > player:get_properties().hp_max then
|
||||
newhp = player:get_properties().hp_max
|
||||
end
|
||||
player:set_hp(newhp)
|
||||
if oldhp ~= newhp then
|
||||
player:set_hp(newhp)
|
||||
end
|
||||
end
|
||||
end
|
||||
minetest.after(regen_interval, regen_all)
|
||||
end
|
||||
minetest.after(regen_interval, regen_all)
|
||||
|
||||
|
||||
local update = 0
|
||||
minetest.register_globalstep(function(delta)
|
||||
update = update + delta
|
||||
if update < regen_interval then
|
||||
return
|
||||
end
|
||||
update = update - regen_interval
|
||||
|
||||
regen_all()
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue