Added ability for multiple animations per action

This commit is contained in:
TenPlus1 2018-08-03 09:43:50 +01:00
parent 4badcec318
commit 0482581f18
2 changed files with 28 additions and 7 deletions

30
api.lua
View File

@ -3,7 +3,7 @@
mobs = {}
mobs.mod = "redo"
mobs.version = "20180719"
mobs.version = "20180803"
-- Intllib
@ -182,6 +182,23 @@ local set_animation = function(self, anim)
self.animation.current = self.animation.current or ""
-- check for more than one animation
local num = 0
for n = 1, 4 do
if self.animation[anim .. n .. "_start"]
and self.animation[anim .. n .. "_end"] then
num = n
end
end
-- choose random animation from set
if num > 0 then
num = random(0, num)
anim = anim .. (num ~= 0 and num or "")
end
if anim == self.animation.current
or not self.animation[anim .. "_start"]
or not self.animation[anim .. "_end"] then
@ -1190,6 +1207,7 @@ local smart_mobs = function(self, s, p, dist, dtime)
if self.fear_height ~= 0 then dropheight = self.fear_height end
self.path.way = minetest.find_path(s, p1, 16, self.stepheight, dropheight, "Dijkstra")
--[[
-- show path using particles
if self.path.way and #self.path.way > 0 then
@ -2121,12 +2139,12 @@ local do_states = function(self, dtime)
self.timer = 0
if self.double_melee_attack
and random(1, 2) == 1 then
set_animation(self, "punch2")
else
-- if self.double_melee_attack
-- and random(1, 2) == 1 then
-- set_animation(self, "punch2")
-- else
set_animation(self, "punch")
end
-- end
local p2 = p
local s2 = s

View File

@ -172,7 +172,7 @@ functions needed for the mob to work properly which contains the following:
'rotate' custom model rotation, 0 = front, 90 = side, 180 = back,
270 = other side.
'double_melee_attack' when true has the api choose between 'punch' and
'punch2' animations.
'punch2' animations. [DEPRECATED]
'animation' holds a table containing animation names and settings for use with mesh models:
'stand_start' start frame for when mob stands still.
@ -207,6 +207,9 @@ functions needed for the mob to work properly which contains the following:
'speed_normal' is used for animation speed for compatibility with some
older mobs.
Note: Up to 5 different animations can be used per action e.g.
stand_start, stand_end, stand1_start, stand1_end .. up to stand4_start
Node Replacement
----------------