2012-09-19 16:50:47 +02:00
|
|
|
mobs = {}
|
2012-09-15 16:12:25 +02:00
|
|
|
function mobs:register_monster(name, def)
|
|
|
|
minetest.register_entity(name, {
|
|
|
|
hp_max = def.hp_max,
|
2012-09-16 20:35:15 +02:00
|
|
|
physical = true,
|
2012-09-15 16:12:25 +02:00
|
|
|
collisionbox = def.collisionbox,
|
|
|
|
visual = def.visual,
|
|
|
|
visual_size = def.visual_size,
|
|
|
|
textures = def.textures,
|
|
|
|
makes_footstep_sound = def.makes_footstep_sound,
|
2012-09-15 16:26:31 +02:00
|
|
|
view_range = def.view_range,
|
|
|
|
walk_velocity = def.walk_velocity,
|
|
|
|
run_velocity = def.run_velocity,
|
2012-09-15 16:40:06 +02:00
|
|
|
damage = def.damage,
|
2012-09-15 16:48:38 +02:00
|
|
|
light_resistant = def.light_resistant,
|
|
|
|
drop = def.drop,
|
2012-09-16 14:20:30 +02:00
|
|
|
drop_count = def.drop_count,
|
2012-09-16 16:10:03 +02:00
|
|
|
armor = def.armor,
|
2012-09-19 16:58:34 +02:00
|
|
|
drawtype = def.drawtype,
|
2012-09-15 15:22:33 +02:00
|
|
|
|
2012-09-15 16:12:25 +02:00
|
|
|
timer = 0,
|
|
|
|
attack = {player=nil, dist=nil},
|
|
|
|
state = "stand",
|
|
|
|
v_start = false,
|
2012-09-15 15:22:33 +02:00
|
|
|
|
|
|
|
|
2012-09-15 16:12:25 +02:00
|
|
|
set_velocity = function(self, v)
|
|
|
|
local yaw = self.object:getyaw()
|
2012-09-19 16:58:34 +02:00
|
|
|
if self.drawtype == "side" then
|
|
|
|
yaw = yaw+(math.pi/2)
|
|
|
|
end
|
2012-09-15 16:12:25 +02:00
|
|
|
local x = math.sin(yaw) * -v
|
|
|
|
local z = math.cos(yaw) * v
|
|
|
|
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z})
|
|
|
|
end,
|
2012-09-15 15:22:33 +02:00
|
|
|
|
2012-09-15 16:12:25 +02:00
|
|
|
get_velocity = function(self)
|
|
|
|
local v = self.object:getvelocity()
|
|
|
|
return (v.x^2 + v.z^2)^(0.5)
|
|
|
|
end,
|
2012-09-15 15:22:33 +02:00
|
|
|
|
2012-09-15 16:12:25 +02:00
|
|
|
on_step = function(self, dtime)
|
|
|
|
if self.object:getvelocity().y > 0.1 then
|
|
|
|
local yaw = self.object:getyaw()
|
2012-09-19 16:58:34 +02:00
|
|
|
if self.drawtype == "side" then
|
|
|
|
yaw = yaw+(math.pi/2)
|
|
|
|
end
|
2012-09-15 16:12:25 +02:00
|
|
|
local x = math.sin(yaw) * -2
|
|
|
|
local z = math.cos(yaw) * 2
|
|
|
|
self.object:setacceleration({x=x, y=-10, z=z})
|
|
|
|
else
|
|
|
|
self.object:setacceleration({x=0, y=-10, z=0})
|
2012-09-15 15:22:33 +02:00
|
|
|
end
|
2012-09-15 16:12:25 +02:00
|
|
|
|
|
|
|
self.timer = self.timer+dtime
|
|
|
|
if self.state ~= "attack" then
|
|
|
|
if self.timer < 1 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
self.timer = 0
|
2012-09-15 15:22:33 +02:00
|
|
|
end
|
2012-09-15 16:12:25 +02:00
|
|
|
|
2012-09-15 16:48:38 +02:00
|
|
|
if not self.light_resistant and minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8 and minetest.env:get_node_light(self.object:getpos()) > 3 then
|
2012-09-15 16:12:25 +02:00
|
|
|
self.object:punch(self.object, 1.0, {
|
|
|
|
full_punch_interval=1.0,
|
|
|
|
groupcaps={
|
|
|
|
fleshy={times={[3]=1/10}},
|
|
|
|
}
|
|
|
|
}, nil)
|
2012-09-15 15:22:33 +02:00
|
|
|
end
|
2012-09-15 16:12:25 +02:00
|
|
|
|
|
|
|
if string.find(minetest.env:get_node(self.object:getpos()).name, "default:water") then
|
|
|
|
self.object:punch(self.object, 1.0, {
|
|
|
|
full_punch_interval=1.0,
|
|
|
|
groupcaps={
|
|
|
|
fleshy={times={[3]=1/1}},
|
|
|
|
}
|
|
|
|
}, nil)
|
2012-09-15 15:22:33 +02:00
|
|
|
end
|
|
|
|
|
2012-09-15 16:12:25 +02:00
|
|
|
if string.find(minetest.env:get_node(self.object:getpos()).name, "default:lava") then
|
|
|
|
self.object:punch(self.object, 1.0, {
|
|
|
|
full_punch_interval=1.0,
|
|
|
|
groupcaps={
|
|
|
|
fleshy={times={[3]=1/2}},
|
|
|
|
}
|
|
|
|
}, nil)
|
2012-09-15 15:22:33 +02:00
|
|
|
end
|
2012-09-15 16:12:25 +02:00
|
|
|
|
|
|
|
for _,player in pairs(minetest.get_connected_players()) do
|
|
|
|
local s = self.object:getpos()
|
|
|
|
local p = player:getpos()
|
|
|
|
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
2012-09-15 16:26:31 +02:00
|
|
|
if dist < self.view_range then
|
2012-09-15 16:12:25 +02:00
|
|
|
if self.attack.dist then
|
|
|
|
if self.attack.dist < dist then
|
|
|
|
self.state = "attack"
|
|
|
|
self.attack.player = player
|
|
|
|
self.attack.dist = dist
|
|
|
|
end
|
|
|
|
else
|
|
|
|
self.state = "attack"
|
|
|
|
self.attack.player = player
|
|
|
|
self.attack.dist = dist
|
2012-09-15 15:22:33 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-09-15 16:12:25 +02:00
|
|
|
|
|
|
|
if self.state == "stand" then
|
|
|
|
if math.random(1, 2) == 1 then
|
|
|
|
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
2012-09-15 15:22:33 +02:00
|
|
|
end
|
2012-09-15 16:12:25 +02:00
|
|
|
if math.random(1, 100) <= 50 then
|
2012-09-15 16:26:31 +02:00
|
|
|
self.set_velocity(self, self.walk_velocity)
|
2012-09-15 16:12:25 +02:00
|
|
|
self.state = "walk"
|
|
|
|
end
|
|
|
|
elseif self.state == "walk" then
|
|
|
|
if math.random(1, 100) <= 30 then
|
|
|
|
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
|
|
|
self.set_velocity(self, self.get_velocity(self))
|
|
|
|
end
|
|
|
|
if math.random(1, 100) <= 10 then
|
|
|
|
self.set_velocity(self, 0)
|
|
|
|
self.state = "stand"
|
|
|
|
end
|
|
|
|
if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
|
|
|
|
local v = self.object:getvelocity()
|
|
|
|
v.y = 5
|
|
|
|
self.object:setvelocity(v)
|
|
|
|
end
|
|
|
|
elseif self.state == "attack" then
|
|
|
|
local s = self.object:getpos()
|
|
|
|
local p = self.attack.player:getpos()
|
|
|
|
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
2012-09-15 16:26:31 +02:00
|
|
|
if dist > self.view_range or self.attack.player:get_hp() <= 0 then
|
2012-09-15 16:12:25 +02:00
|
|
|
self.state = "stand"
|
|
|
|
self.v_start = false
|
|
|
|
self.set_velocity(self, 0)
|
|
|
|
self.attack = {player=nil, dist=nil}
|
|
|
|
return
|
|
|
|
else
|
|
|
|
self.attack.dist = dist
|
|
|
|
end
|
|
|
|
|
|
|
|
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
|
|
|
|
local yaw = math.atan(vec.z/vec.x)+math.pi/2
|
2012-09-19 16:58:34 +02:00
|
|
|
if self.drawtype == "side" then
|
|
|
|
yaw = yaw+(math.pi/2)
|
|
|
|
end
|
2012-09-15 16:12:25 +02:00
|
|
|
if p.x > s.x then
|
|
|
|
yaw = yaw+math.pi
|
|
|
|
end
|
|
|
|
self.object:setyaw(yaw)
|
|
|
|
if self.attack.dist > 2 then
|
|
|
|
if not self.v_start then
|
|
|
|
self.v_start = true
|
2012-09-15 16:26:31 +02:00
|
|
|
self.set_velocity(self, self.run_velocity)
|
2012-09-15 16:12:25 +02:00
|
|
|
else
|
|
|
|
if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
|
|
|
|
local v = self.object:getvelocity()
|
|
|
|
v.y = 5
|
|
|
|
self.object:setvelocity(v)
|
2012-09-15 15:22:33 +02:00
|
|
|
end
|
2012-09-15 16:26:31 +02:00
|
|
|
self.set_velocity(self, self.run_velocity)
|
2012-09-15 16:12:25 +02:00
|
|
|
end
|
|
|
|
else
|
|
|
|
self.set_velocity(self, 0)
|
|
|
|
self.v_start = false
|
|
|
|
if self.timer > 1 then
|
|
|
|
self.timer = 0
|
2012-09-17 16:59:05 +02:00
|
|
|
local d1 = 10
|
|
|
|
local d2 = 10
|
|
|
|
local d3 = 10
|
|
|
|
if self.damage > 0 then
|
|
|
|
d3 = 1/self.damage
|
2012-09-15 16:40:06 +02:00
|
|
|
end
|
2012-09-17 16:59:05 +02:00
|
|
|
if self.damage > 1 then
|
|
|
|
d2 = 1/(self.damage-1)
|
|
|
|
end
|
|
|
|
if self.damage > 2 then
|
|
|
|
d1 = 1/(self.damage-2)
|
|
|
|
end
|
|
|
|
self.attack.player:punch(self.object, 1.0, {
|
|
|
|
full_punch_interval=1.0,
|
|
|
|
groupcaps={
|
|
|
|
fleshy={times={[1]=d1, [2]=d2, [3]=d3}},
|
|
|
|
}
|
|
|
|
}, vec)
|
2012-09-15 16:12:25 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
on_activate = function(self, staticdata)
|
2012-09-16 15:48:58 +02:00
|
|
|
self.object:set_armor_groups({fleshy=self.armor})
|
2012-09-15 16:12:25 +02:00
|
|
|
self.object:setacceleration({x=0, y=-10, z=0})
|
|
|
|
self.state = "stand"
|
|
|
|
self.object:setvelocity({x=0, y=self.object:getvelocity().y, z=0})
|
|
|
|
self.object:setyaw(math.random(1, 360)/180*math.pi)
|
|
|
|
end,
|
|
|
|
|
|
|
|
on_punch = function(self, hitter)
|
|
|
|
if self.object:get_hp() <= 0 then
|
|
|
|
if hitter and hitter:is_player() and hitter:get_inventory() then
|
2012-09-16 14:20:30 +02:00
|
|
|
for i=1,math.random(0,2)-1+self.drop_count do
|
2012-09-15 16:48:38 +02:00
|
|
|
hitter:get_inventory():add_item("main", ItemStack(self.drop))
|
2012-09-15 16:12:25 +02:00
|
|
|
end
|
|
|
|
else
|
2012-09-16 14:20:30 +02:00
|
|
|
for i=1,math.random(0,2)-1+self.drop_count do
|
|
|
|
local obj = minetest.env:add_item(self.object:getpos(), self.drop)
|
|
|
|
if obj then
|
|
|
|
obj:get_luaentity().collect = true
|
|
|
|
local x = math.random(1, 5)
|
|
|
|
if math.random(1,2) == 1 then
|
|
|
|
x = -x
|
|
|
|
end
|
|
|
|
local z = math.random(1, 5)
|
|
|
|
if math.random(1,2) == 1 then
|
|
|
|
z = -z
|
|
|
|
end
|
|
|
|
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
function mobs:register_animal(name, def)
|
|
|
|
minetest.register_entity(name, {
|
|
|
|
hp_max = def.hp_max,
|
2012-09-16 20:35:15 +02:00
|
|
|
physical = true,
|
2012-09-16 14:20:30 +02:00
|
|
|
collisionbox = def.collisionbox,
|
|
|
|
visual = def.visual,
|
|
|
|
visual_size = def.visual_size,
|
|
|
|
textures = def.textures,
|
|
|
|
makes_footstep_sound = def.makes_footstep_sound,
|
|
|
|
walk_velocity = def.walk_velocity,
|
|
|
|
drop = def.drop,
|
|
|
|
on_rightclick = def.on_rightclick,
|
|
|
|
drop_count = def.drop_count,
|
2012-09-19 16:58:34 +02:00
|
|
|
drawtype = def.drawtype,
|
2012-09-16 14:20:30 +02:00
|
|
|
|
|
|
|
timer = 0,
|
|
|
|
state = "stand",
|
|
|
|
|
|
|
|
|
|
|
|
set_velocity = function(self, v)
|
|
|
|
local yaw = self.object:getyaw()
|
2012-09-19 16:58:34 +02:00
|
|
|
if self.drawtype == "side" then
|
|
|
|
yaw = yaw+(math.pi/2)
|
|
|
|
end
|
2012-09-16 14:20:30 +02:00
|
|
|
local x = math.sin(yaw) * -v
|
|
|
|
local z = math.cos(yaw) * v
|
|
|
|
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z})
|
|
|
|
end,
|
|
|
|
|
|
|
|
get_velocity = function(self)
|
|
|
|
local v = self.object:getvelocity()
|
|
|
|
return (v.x^2 + v.z^2)^(0.5)
|
|
|
|
end,
|
|
|
|
|
|
|
|
on_step = function(self, dtime)
|
|
|
|
if self.object:getvelocity().y > 0.1 then
|
|
|
|
local yaw = self.object:getyaw()
|
2012-09-19 16:58:34 +02:00
|
|
|
if self.drawtype == "side" then
|
|
|
|
yaw = yaw+(math.pi/2)
|
|
|
|
end
|
2012-09-16 14:20:30 +02:00
|
|
|
local x = math.sin(yaw) * -2
|
|
|
|
local z = math.cos(yaw) * 2
|
|
|
|
self.object:setacceleration({x=x, y=-10, z=z})
|
|
|
|
else
|
|
|
|
self.object:setacceleration({x=0, y=-10, z=0})
|
|
|
|
end
|
|
|
|
|
|
|
|
self.timer = self.timer+dtime
|
|
|
|
if self.timer < 1 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
self.timer = 0
|
|
|
|
|
|
|
|
if string.find(minetest.env:get_node(self.object:getpos()).name, "default:lava") then
|
|
|
|
self.object:punch(self.object, 1.0, {
|
|
|
|
full_punch_interval=1.0,
|
|
|
|
groupcaps={
|
|
|
|
fleshy={times={[3]=1/2}},
|
|
|
|
}
|
|
|
|
}, nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
if self.state == "stand" then
|
|
|
|
if math.random(1, 2) == 1 then
|
|
|
|
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
|
|
|
end
|
|
|
|
if math.random(1, 100) <= 50 then
|
|
|
|
self.set_velocity(self, self.walk_velocity)
|
|
|
|
self.state = "walk"
|
|
|
|
end
|
|
|
|
elseif self.state == "walk" then
|
|
|
|
if math.random(1, 100) <= 30 then
|
|
|
|
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
|
|
|
self.set_velocity(self, self.get_velocity(self))
|
|
|
|
end
|
|
|
|
if math.random(1, 100) <= 10 then
|
|
|
|
self.set_velocity(self, 0)
|
|
|
|
self.state = "stand"
|
|
|
|
end
|
|
|
|
if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
|
|
|
|
local v = self.object:getvelocity()
|
|
|
|
v.y = 5
|
|
|
|
self.object:setvelocity(v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
on_activate = function(self, staticdata)
|
|
|
|
self.object:set_armor_groups({fleshy=3})
|
|
|
|
self.object:setacceleration({x=0, y=-10, z=0})
|
|
|
|
self.state = "stand"
|
|
|
|
self.object:setvelocity({x=0, y=self.object:getvelocity().y, z=0})
|
|
|
|
self.object:setyaw(math.random(1, 360)/180*math.pi)
|
|
|
|
end,
|
|
|
|
|
|
|
|
on_punch = function(self, hitter)
|
|
|
|
if self.object:get_hp() <= 0 then
|
|
|
|
if hitter and hitter:is_player() and hitter:get_inventory() then
|
|
|
|
for i=1,math.random(0,2)-1+self.drop_count do
|
|
|
|
hitter:get_inventory():add_item("main", ItemStack(self.drop))
|
|
|
|
end
|
|
|
|
else
|
|
|
|
for i=1,math.random(0,2)-1+self.drop_count do
|
2012-09-15 16:48:38 +02:00
|
|
|
local obj = minetest.env:add_item(self.object:getpos(), self.drop)
|
2012-09-15 16:12:25 +02:00
|
|
|
if obj then
|
|
|
|
obj:get_luaentity().collect = true
|
|
|
|
local x = math.random(1, 5)
|
|
|
|
if math.random(1,2) == 1 then
|
|
|
|
x = -x
|
|
|
|
end
|
|
|
|
local z = math.random(1, 5)
|
|
|
|
if math.random(1,2) == 1 then
|
|
|
|
z = -z
|
|
|
|
end
|
|
|
|
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
2012-09-15 15:22:33 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-09-15 16:12:25 +02:00
|
|
|
end,
|
|
|
|
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2012-09-17 17:13:31 +02:00
|
|
|
function mobs:register_spawn(name, nodes, max_light, min_light)
|
2012-09-16 15:08:31 +02:00
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = nodes,
|
|
|
|
neighbors = nodes,
|
2012-09-19 17:22:12 +02:00
|
|
|
interval = 30,
|
2012-09-15 15:22:33 +02:00
|
|
|
chance = 5000,
|
|
|
|
action = function(pos, node)
|
|
|
|
pos.y = pos.y+1
|
2012-09-16 14:20:30 +02:00
|
|
|
if not minetest.env:get_node_light(pos) then
|
|
|
|
return
|
|
|
|
end
|
2012-09-16 15:08:31 +02:00
|
|
|
if minetest.env:get_node_light(pos) > max_light then
|
2012-09-15 15:22:33 +02:00
|
|
|
return
|
|
|
|
end
|
2012-09-17 17:13:31 +02:00
|
|
|
if minetest.env:get_node_light(pos) < min_light then
|
|
|
|
return
|
|
|
|
end
|
2012-09-15 15:22:33 +02:00
|
|
|
if minetest.env:get_node(pos).name ~= "air" then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
pos.y = pos.y+1
|
|
|
|
if minetest.env:get_node(pos).name ~= "air" then
|
|
|
|
return
|
|
|
|
end
|
2012-09-16 17:07:38 +02:00
|
|
|
|
|
|
|
local count = 0
|
2012-09-17 19:54:50 +02:00
|
|
|
for _,obj in pairs(minetest.env:get_objects_inside_radius(pos, 30)) do
|
2012-09-16 15:08:31 +02:00
|
|
|
if obj:is_player() then
|
|
|
|
return
|
2012-09-17 17:10:27 +02:00
|
|
|
elseif obj:get_luaentity().name == name then
|
2012-09-16 17:07:38 +02:00
|
|
|
count = count+1
|
2012-09-16 15:08:31 +02:00
|
|
|
end
|
|
|
|
end
|
2012-09-16 17:07:38 +02:00
|
|
|
if count > 5 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-09-16 16:10:03 +02:00
|
|
|
--minetest.chat_send_all("[mobs] Add "..name.." at "..minetest.pos_to_string(pos))
|
2012-09-16 15:08:31 +02:00
|
|
|
minetest.env:add_entity(pos, name)
|
2012-09-15 15:22:33 +02:00
|
|
|
end
|
|
|
|
})
|
2012-09-16 15:08:31 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
mobs:register_monster("mobs:dirt_monster", {
|
|
|
|
hp_max = 5,
|
|
|
|
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
|
|
|
visual = "upright_sprite",
|
|
|
|
visual_size = {x=1, y=2},
|
|
|
|
textures = {"mobs_dirt_monster.png", "mobs_dirt_monster_back.png"},
|
|
|
|
makes_footstep_sound = true,
|
|
|
|
view_range = 15,
|
|
|
|
walk_velocity = 1,
|
|
|
|
run_velocity = 3,
|
|
|
|
damage = 2,
|
|
|
|
drop = "default:dirt",
|
|
|
|
drop_count = 3,
|
2012-09-16 15:48:58 +02:00
|
|
|
armor = 3,
|
2012-09-19 16:58:34 +02:00
|
|
|
drawtype = "front",
|
2012-09-16 15:08:31 +02:00
|
|
|
})
|
2012-09-17 17:13:31 +02:00
|
|
|
mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1)
|
2012-09-15 16:26:31 +02:00
|
|
|
|
|
|
|
mobs:register_monster("mobs:stone_monster", {
|
|
|
|
hp_max = 10,
|
|
|
|
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
|
|
|
visual = "upright_sprite",
|
|
|
|
visual_size = {x=1, y=2},
|
|
|
|
textures = {"mobs_stone_monster.png", "mobs_stone_monster_back.png"},
|
|
|
|
makes_footstep_sound = true,
|
|
|
|
view_range = 10,
|
|
|
|
walk_velocity = 0.5,
|
|
|
|
run_velocity = 2,
|
2012-09-15 16:40:06 +02:00
|
|
|
damage = 3,
|
2012-09-15 16:48:38 +02:00
|
|
|
drop = "default:mossycobble",
|
2012-09-16 14:20:30 +02:00
|
|
|
drop_count = 3,
|
2012-09-16 15:10:50 +02:00
|
|
|
light_resistant = true,
|
2012-09-16 15:48:58 +02:00
|
|
|
armor = 2,
|
2012-09-19 16:58:34 +02:00
|
|
|
drawtype = "front",
|
2012-09-15 16:26:31 +02:00
|
|
|
})
|
2012-09-17 17:13:31 +02:00
|
|
|
mobs:register_spawn("mobs:stone_monster", {"default:stone"}, 3, -1)
|
2012-09-15 16:26:31 +02:00
|
|
|
|
2012-09-15 16:40:06 +02:00
|
|
|
|
|
|
|
mobs:register_monster("mobs:sand_monster", {
|
2012-09-15 16:48:38 +02:00
|
|
|
hp_max = 3,
|
2012-09-15 16:40:06 +02:00
|
|
|
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
|
|
|
visual = "upright_sprite",
|
|
|
|
visual_size = {x=1, y=2},
|
|
|
|
textures = {"mobs_sand_monster.png", "mobs_sand_monster_back.png"},
|
|
|
|
makes_footstep_sound = true,
|
|
|
|
view_range = 15,
|
|
|
|
walk_velocity = 1.5,
|
|
|
|
run_velocity = 4,
|
|
|
|
damage = 1,
|
2012-09-15 16:48:38 +02:00
|
|
|
drop = "default:sand",
|
2012-09-16 14:20:30 +02:00
|
|
|
drop_count = 3,
|
2012-09-15 16:48:38 +02:00
|
|
|
light_resistant = true,
|
2012-09-16 15:48:58 +02:00
|
|
|
armor = 3,
|
2012-09-19 16:58:34 +02:00
|
|
|
drawtype = "front",
|
2012-09-15 16:40:06 +02:00
|
|
|
})
|
2012-09-17 17:13:31 +02:00
|
|
|
mobs:register_spawn("mobs:sand_monster", {"default:desert_sand"}, 20, -1)
|
2012-09-16 14:20:30 +02:00
|
|
|
|
|
|
|
mobs:register_animal("mobs:sheep", {
|
|
|
|
hp_max = 5,
|
|
|
|
collisionbox = {-0.6, -0.625, -0.6, 0.6, 0.625, 0.6},
|
|
|
|
visual = "upright_sprite",
|
|
|
|
visual_size = {x=2, y=1.25},
|
|
|
|
textures = {"mobs_sheep.png", "mobs_sheep.png"},
|
|
|
|
makes_footstep_sound = true,
|
|
|
|
walk_velocity = 1,
|
|
|
|
drop = "mobs:meat_raw",
|
|
|
|
drop_count = 2,
|
2012-09-19 16:58:34 +02:00
|
|
|
drawtype = "side",
|
2012-09-16 14:20:30 +02:00
|
|
|
|
|
|
|
on_rightclick = function(self, clicker)
|
|
|
|
if self.naked then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
if clicker:get_inventory() then
|
|
|
|
self.naked = true,
|
|
|
|
clicker:get_inventory():add_item("main", ItemStack("wool:white "..math.random(1,3)))
|
|
|
|
self.object:set_properties({
|
|
|
|
textures = {"mobs_sheep_naked.png", "mobs_sheep_naked.png"},
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
2012-09-17 17:13:31 +02:00
|
|
|
mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass"}, 20, 8)
|
2012-09-16 14:20:30 +02:00
|
|
|
|
|
|
|
minetest.register_craftitem("mobs:meat_raw", {
|
|
|
|
description = "Raw Meat",
|
|
|
|
inventory_image = "mobs_meat_raw.png",
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craftitem("mobs:meat", {
|
|
|
|
description = "Meat",
|
|
|
|
inventory_image = "mobs_meat.png",
|
|
|
|
on_use = minetest.item_eat(8),
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
type = "cooking",
|
|
|
|
output = "mobs:meat",
|
|
|
|
recipe = "mobs:meat_raw",
|
|
|
|
cooktime = 5,
|
|
|
|
})
|