From d22f270e231a993368faccab3f498e244300804d Mon Sep 17 00:00:00 2001 From: npx Date: Fri, 2 Sep 2016 17:25:38 +0200 Subject: [PATCH] Tweaked some parameters --- mobs/morde.lua | 21 ++++++++++++++++++++- mobs/morvy.lua | 26 +++++++++++++++----------- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/mobs/morde.lua b/mobs/morde.lua index a380906..e5fcf4a 100644 --- a/mobs/morde.lua +++ b/mobs/morde.lua @@ -102,7 +102,18 @@ minetest.register_entity("nssm:mortick", { visual = "mesh", mesh = "mortick.x", visual_size = {x=3, y=3}, + lifetime = 10, + damage = 1, on_step = function(self, dtime) + self.mortick_timer = self.mortick_timer or os.time() + self.timer = self.timer or 0 + self.timer = self.timer+dtime + + if (os.time()-self.mortick_timer > self.lifetime) then + self.object:remove() + end + + --Find player to attack: self.attack = (self.attack or 0) local s = self.object:getpos() local objects = minetest.env:get_objects_inside_radius(s, 8) @@ -111,6 +122,8 @@ minetest.register_entity("nssm:mortick", { self.attack = obj end end + + --If found a player follow him if self.attack ~= 0 then local p = self.attack:getpos() local yawp = self.attack:get_look_yaw() @@ -123,9 +136,15 @@ minetest.register_entity("nssm:mortick", { local v = {x=-(s.x-p.x)*m, y=-(s.y-p.y)*m, z=-(s.z-p.z)*m} local yaws = yawp +pi + --stay attached to players back: self.object:setvelocity(v) - --self.object:setpos(p) self.object:setyaw(yaws) + + --damage player every second: + if (self.timer>1) then + self.timer = 0 + self.attack:set_hp(self.attack:get_hp() - self.damage) + end end end }) diff --git a/mobs/morvy.lua b/mobs/morvy.lua index 32ddcfb..209dd5f 100644 --- a/mobs/morvy.lua +++ b/mobs/morvy.lua @@ -43,8 +43,10 @@ mobs:register_mob("nssm:morvy", { }, custom_attack = function(self) + set_animation(self, "stand") self.morvy_counter = (self.morvy_counter or 0) + 1 if self.morvy_counter == 4 then + set_animation(self, "punch") self.morvy_counter = 0 local counter = 0 @@ -73,6 +75,19 @@ mobs:register_mob("nssm:morvy", { if (minetest.env:get_node(pos1).name == "air") and (counter < 5) then + local bat + local which = math.random(1,3) + if which == 1 then + bat = "nssm:morbat1" + elseif which == 2 then + bat = "nssm:morbat2" + elseif which == 3 then + bat = "nssm:morbat3" + end + if (bat=="nssm:morbat3") then + pos1.y=pos1.y+1.5 + end + minetest.add_entity(pos1, bat) minetest.add_particlespawner( 20, --amount 0.1, --time @@ -89,17 +104,6 @@ mobs:register_mob("nssm:morvy", { false, --collisiondetection "morparticle.png" --texture ) - - local bat - local which = math.random(1,3) - if which == 1 then - bat = "nssm:morbat1" - elseif which == 2 then - bat = "nssm:morbat2" - elseif which == 3 then - bat = "nssm:morbat3" - end - minetest.add_entity(pos1, bat) end end end