mirror of
https://github.com/ElCeejo/creatura.git
synced 2025-04-30 05:41:46 -04:00
Add support for multiple mesh elements
This commit is contained in:
parent
3042279836
commit
2b62dc0f22
2 changed files with 24 additions and 6 deletions
12
api.lua
12
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
|
||||
|
|
18
mob_meta.lua
18
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
|
||||
|
|
Loading…
Add table
Reference in a new issue