From 0e374cac222ff165cc071c34d7ce5a42e59f52d3 Mon Sep 17 00:00:00 2001 From: npx Date: Thu, 2 Mar 2017 12:26:38 +0100 Subject: [PATCH] Modified attack routine --- mobs/tartacacia.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/mobs/tartacacia.lua b/mobs/tartacacia.lua index 5925c04..b6a56f4 100644 --- a/mobs/tartacacia.lua +++ b/mobs/tartacacia.lua @@ -55,4 +55,34 @@ mobs:register_mob("nssm:tartacacia", { die_start = 160, die_end = 180, }, + custom_attack = function (self) + local s = self.object:getpos() + local p = self.attack:getpos() + local d = vector.subtract (p,s) + local l = vector.length(d) + minetest.chat_send_all("l="..l) + + if math.random(1,5) == 1 then + if l <= 6 then + set_animation(self, "punch") + for y = 0,3 do + p.y = p.y - y + minetest.remove_node(p) + end + self.attack:punch(self.object, 1.0, { + full_punch_interval = 1.0, + damage_groups = {fleshy = self.damage} + }, nil) + end + else + set_animation(self, "punch2") + self.attack:punch(self.object, 1.0, { + full_punch_interval = 1.0, + damage_groups = {fleshy = self.damage} + }, nil) + if l < 4 then + self.attack:setpos(vector.subtract(p, {x=0, y=2, z=0})) + end + end + end, })