diff --git a/api.lua b/api.lua index 41b3b80..dffb97e 100644 --- a/api.lua +++ b/api.lua @@ -19,6 +19,7 @@ local function clamp(val, min, max) end local vec_dist = vector.distance +local vec_multi = vector.multiply local vec_equals = vector.equals local vec_add = vector.add @@ -443,7 +444,16 @@ function creatura.basic_punch_func(self, puncher, time_from_last_punch, tool_cap return end self:apply_knockback(direction) - self:hurt((tool_capabilities.damage_groups.fleshy or damage) or 2) + if not tool_capabilities + or not tool_capabilities.damage_groups + or not tool_capabilities.damage_groups.fleshy then + tool_capabilities = { + damage_groups = { + fleshy = 2 + } + } + end + self:hurt(tool_capabilities.damage_groups.fleshy) if random(4) < 2 then self:play_sound("hurt") end diff --git a/mob_meta.lua b/mob_meta.lua index 6007be1..2f78583 100644 --- a/mob_meta.lua +++ b/mob_meta.lua @@ -225,6 +225,7 @@ end function mob:hurt(health) if self.protected then return end self.hp = self.hp - math.ceil(health) + if self.hp < 0 then self.hp = 0 end end -- Add HP to mob @@ -429,9 +430,16 @@ function mob:set_texture(id, tbl) or not _table[id] then return end - self.object:set_properties({ - textures = {_table[id]} - }) + local tex = _table[id] + if type(tex) == "table" then + self.object:set_properties({ + textures = {unpack(tex)} + }) + else + self.object:set_properties({ + textures = {tex} + }) + end return _table[id] end @@ -696,7 +704,7 @@ function mob:activate(staticdata, dtime) -- Initialize Stats and Visuals if not self.textures then - local textures = self.properties.textures + local textures = minetest.registered_entities[self.name].textures if textures then self.textures = textures end end @@ -706,7 +714,7 @@ function mob:activate(staticdata, dtime) else self.perm_data = {} end - if #self.textures > 1 then self.texture_no = random(#self.textures) end + if #self.textures > 0 then self.texture_no = random(#self.textures) end end if self:recall("despawn_after") ~= nil then