mirror of
https://github.com/ElCeejo/creatura.git
synced 2025-04-30 13:51:41 -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
|
end
|
||||||
|
|
||||||
local vec_dist = vector.distance
|
local vec_dist = vector.distance
|
||||||
|
local vec_multi = vector.multiply
|
||||||
local vec_equals = vector.equals
|
local vec_equals = vector.equals
|
||||||
local vec_add = vector.add
|
local vec_add = vector.add
|
||||||
|
|
||||||
|
@ -443,7 +444,16 @@ function creatura.basic_punch_func(self, puncher, time_from_last_punch, tool_cap
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
self:apply_knockback(direction)
|
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
|
if random(4) < 2 then
|
||||||
self:play_sound("hurt")
|
self:play_sound("hurt")
|
||||||
end
|
end
|
||||||
|
|
14
mob_meta.lua
14
mob_meta.lua
|
@ -225,6 +225,7 @@ end
|
||||||
function mob:hurt(health)
|
function mob:hurt(health)
|
||||||
if self.protected then return end
|
if self.protected then return end
|
||||||
self.hp = self.hp - math.ceil(health)
|
self.hp = self.hp - math.ceil(health)
|
||||||
|
if self.hp < 0 then self.hp = 0 end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add HP to mob
|
-- Add HP to mob
|
||||||
|
@ -429,9 +430,16 @@ function mob:set_texture(id, tbl)
|
||||||
or not _table[id] then
|
or not _table[id] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local tex = _table[id]
|
||||||
|
if type(tex) == "table" then
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
textures = {_table[id]}
|
textures = {unpack(tex)}
|
||||||
})
|
})
|
||||||
|
else
|
||||||
|
self.object:set_properties({
|
||||||
|
textures = {tex}
|
||||||
|
})
|
||||||
|
end
|
||||||
return _table[id]
|
return _table[id]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -696,7 +704,7 @@ function mob:activate(staticdata, dtime)
|
||||||
|
|
||||||
-- Initialize Stats and Visuals
|
-- Initialize Stats and Visuals
|
||||||
if not self.textures then
|
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
|
if textures then self.textures = textures end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -706,7 +714,7 @@ function mob:activate(staticdata, dtime)
|
||||||
else
|
else
|
||||||
self.perm_data = {}
|
self.perm_data = {}
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
if self:recall("despawn_after") ~= nil then
|
if self:recall("despawn_after") ~= nil then
|
||||||
|
|
Loading…
Add table
Reference in a new issue