Added specific abilities (steal food and runaway)
This commit is contained in:
parent
ab0cac7dd2
commit
76ab932f31
117
morgut.lua
117
morgut.lua
@ -9,10 +9,10 @@ mobs:register_mob("nssm:morgut", {
|
|||||||
textures = {{"morgut.png"}},
|
textures = {{"morgut.png"}},
|
||||||
visual_size = {x=5, y=5},
|
visual_size = {x=5, y=5},
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
view_range = 20,
|
view_range = 10,
|
||||||
walk_velocity = 0.5,
|
walk_velocity = 0.5,
|
||||||
reach =2,
|
reach =2,
|
||||||
run_velocity = 3.5,
|
run_velocity = 4,
|
||||||
damage = 4,
|
damage = 4,
|
||||||
runaway = true,
|
runaway = true,
|
||||||
jump = true,
|
jump = true,
|
||||||
@ -36,7 +36,7 @@ mobs:register_mob("nssm:morgut", {
|
|||||||
attack_type = "dogfight",
|
attack_type = "dogfight",
|
||||||
animation = {
|
animation = {
|
||||||
speed_normal = 15,
|
speed_normal = 15,
|
||||||
speed_run = 25,
|
speed_run = 30,
|
||||||
stand_start = 10,
|
stand_start = 10,
|
||||||
stand_end = 40,
|
stand_end = 40,
|
||||||
walk_start = 50,
|
walk_start = 50,
|
||||||
@ -50,32 +50,121 @@ mobs:register_mob("nssm:morgut", {
|
|||||||
do_custom = function (self)
|
do_custom = function (self)
|
||||||
self.flag = (self.flag or 0)
|
self.flag = (self.flag or 0)
|
||||||
|
|
||||||
--[[if self.flag == 1 then
|
if self.inv_flag ~= 1 then
|
||||||
local pyaw = self.curr_attack:get_look_yaw()
|
self.inventory = {}
|
||||||
self.object:setyaw(pyaw + self.rotate)
|
for i=1,32 do
|
||||||
set_velocity(self, run_velocity)
|
self.inventory[i]={name = '', num = 0}
|
||||||
end
|
end
|
||||||
]]
|
end
|
||||||
|
self.inv_flag = (self.inv_flag or 1)
|
||||||
|
|
||||||
|
if self.flag == 1 then
|
||||||
|
self.state = ""
|
||||||
|
set_animation(self, "run")
|
||||||
|
self.object:setyaw(self.dir)
|
||||||
|
set_velocity(self, 4)
|
||||||
|
|
||||||
|
if os.time() - self.morgut_timer > 3 then
|
||||||
|
self.flag = 0
|
||||||
|
self.state = "stand"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end,
|
end,
|
||||||
custom_attack = function (self)
|
custom_attack = function (self)
|
||||||
self.curr_attack = (self.curr_attack or self.attack)
|
self.curr_attack = (self.curr_attack or self.attack)
|
||||||
self.morgut_timer = (self.morgut_timer or os.time())
|
self.morgut_timer = (self.morgut_timer or os.time())
|
||||||
|
|
||||||
|
self.dir = (self.dir or 0)
|
||||||
if (os.time() - self.morgut_timer) > 1 then
|
if (os.time() - self.morgut_timer) > 1 then
|
||||||
self.morgut_timer = os.time()
|
|
||||||
|
|
||||||
local s = self.object:getpos()
|
local s = self.object:getpos()
|
||||||
local p = self.attack:getpos()
|
local p = self.attack:getpos()
|
||||||
|
|
||||||
set_animation(self, "punch")
|
set_animation(self, "punch")
|
||||||
|
local m = 2
|
||||||
|
|
||||||
|
minetest.add_particlespawner(
|
||||||
|
6, --amount
|
||||||
|
1, --time
|
||||||
|
{x=p.x-0.5, y=p.y-0.5, z=p.z-0.5}, --minpos
|
||||||
|
{x=p.x+0.5, y=p.y+0.5, z=p.z+0.5}, --maxpos
|
||||||
|
{x=(s.x-p.x)*m, y=(s.y-p.y+1)*m, z=(s.z-p.z)*m}, --minvel
|
||||||
|
{x=(s.x-p.x)*m, y=(s.y-p.y+1)*m, z=(s.z-p.z)*m}, --maxvel
|
||||||
|
{x=s.x-p.x, y=s.y-p.y+1, z=s.z-p.z}, --minacc
|
||||||
|
{x=s.x-p.x, y=s.y-p.y+1, z=s.z-p.z}, --maxacc
|
||||||
|
0.2, --minexptime
|
||||||
|
0.3, --maxexptime
|
||||||
|
2, --minsize
|
||||||
|
3, --maxsize
|
||||||
|
false, --collisiondetection
|
||||||
|
"roasted_duck_legs.png" --texture
|
||||||
|
)
|
||||||
|
|
||||||
|
minetest.after(1, function (self)
|
||||||
|
if self.attack:is_player() then
|
||||||
|
local pname = self.attack:get_player_name()
|
||||||
|
local player_inv = minetest.get_inventory({type='player', name = pname})
|
||||||
|
|
||||||
|
if player_inv:is_empty('main') then
|
||||||
|
--minetest.chat_send_all("Inventory empty")
|
||||||
|
else
|
||||||
|
for i = 1,32 do
|
||||||
|
--minetest.chat_send_all("Inventory is not empty")
|
||||||
|
local items = player_inv:get_stack('main', i)
|
||||||
|
local n = items:get_name()
|
||||||
|
if minetest.get_item_group(n, "eatable")==1 then
|
||||||
|
local index
|
||||||
|
local found = 0
|
||||||
|
for j = 1,32 do
|
||||||
|
if found == 0 then
|
||||||
|
if self.inventory[j].num == 0 then
|
||||||
|
found = 2
|
||||||
|
index = j
|
||||||
|
else
|
||||||
|
if self.inventory[j].name == n then
|
||||||
|
self.inventory[j].num = self.inventory[j].num +1
|
||||||
|
found = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if found == 2 then
|
||||||
|
self.inventory[index].name = n
|
||||||
|
self.inventory[index].num = 1
|
||||||
|
end
|
||||||
|
items:take_item()
|
||||||
|
player_inv:set_stack('main', i, items)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
set_animation(self, "run")
|
||||||
self.flag = 1
|
self.flag = 1
|
||||||
|
self.morgut_timer = os.time()
|
||||||
self.curr_attack = self.attack
|
self.curr_attack = self.attack
|
||||||
self.state = "runaway"
|
self.state = ""
|
||||||
local pyaw = self.curr_attack: get_look_yaw()
|
local pyaw = self.curr_attack: get_look_yaw()
|
||||||
|
self.dir = pyaw
|
||||||
self.object:setyaw(pyaw)
|
self.object:setyaw(pyaw)
|
||||||
set_velocity(self, self.run_velocity)
|
set_velocity(self, 4)
|
||||||
|
end
|
||||||
minetest.chat_send_all("Stato = "..self.state)
|
end,self)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_die = function(self)
|
||||||
|
local pos = self.object:getpos()
|
||||||
|
if (self.inventory ~= nil) then
|
||||||
|
local elem
|
||||||
|
for i = 1,32 do
|
||||||
|
if self.inventory[i].num~=0 then
|
||||||
|
local items = ItemStack(self.inventory[i].name.." "..self.inventory[i].num)
|
||||||
|
local obj = minetest.add_item(pos, items)
|
||||||
|
obj:setvelocity({
|
||||||
|
x = math.random(-1, 1),
|
||||||
|
y = 6,
|
||||||
|
z = math.random(-1, 1)
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user