do_custom timing fixed, called every 1 second

This commit is contained in:
TenPlus1 2015-08-17 10:23:58 +01:00
parent e4149c45fc
commit 60820281e1

15
api.lua
View File

@ -383,14 +383,22 @@ function mobs:register_mob(name, def)
end
end
-- environmental damage timer
-- environmental damage timer (every 1 second)
self.env_damage_timer = self.env_damage_timer + dtime
if self.state == "attack"
and self.env_damage_timer > 1 then
self.env_damage_timer = 0
do_env_damage(self)
-- custom function (defined in mob lua file)
if self.do_custom then
self.do_custom(self)
end
elseif self.state ~= "attack" then
do_env_damage(self)
-- custom function
if self.do_custom then
self.do_custom(self)
end
end
-- find someone to attack
@ -584,11 +592,6 @@ function mobs:register_mob(name, def)
end
end
-- custom function (defined in mob lua file)
if self.do_custom then
self.do_custom(self)
end
if self.type == "npc"
and self.order == "follow"
and self.state ~= "attack" then