Teach NPCs how to heal themselves

This commit is contained in:
Wuzzy 2021-08-08 02:21:21 +02:00
parent 64d603ae0e
commit 36de284545

View File

@ -118,8 +118,20 @@ for _, npc_type_table in pairs(npc_types) do
punch_start = 200,
punch_end = 219,
},
do_custom = function(self)
-- Slowly heal NPC over time
self.healing_counter = self.healing_counter + 1
if self.healing_counter > 5 then
local hp = self.object:get_hp()
hp = math.min(20, hp + 1)
self.object:set_hp(hp)
local hp = self.object:get_hp()
self.healing_counter = 0
end
end,
on_spawn = function(self)
self.npc_type = npc_type
self.healing_counter = 0
end,
on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item()