Sheep drop meat when killed
parent
ca8f78cec8
commit
daca4f6c0e
15
items.lua
15
items.lua
|
@ -16,7 +16,7 @@ minetest.register_craft({
|
||||||
minetest.register_craftitem("creatures:flesh", {
|
minetest.register_craftitem("creatures:flesh", {
|
||||||
description = "Flesh",
|
description = "Flesh",
|
||||||
inventory_image = "creatures_flesh.png",
|
inventory_image = "creatures_flesh.png",
|
||||||
on_use = minetest.item_eat(4),
|
on_use = minetest.item_eat(2),
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("creatures:rotten_flesh", {
|
minetest.register_craftitem("creatures:rotten_flesh", {
|
||||||
|
@ -25,6 +25,19 @@ minetest.register_craftitem("creatures:rotten_flesh", {
|
||||||
on_use = minetest.item_eat(1),
|
on_use = minetest.item_eat(1),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- food
|
||||||
|
minetest.register_craftitem("creatures:meat", {
|
||||||
|
description = "Cooked Meat",
|
||||||
|
inventory_image = "creatures_meat.png",
|
||||||
|
on_use = minetest.item_eat(4),
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
type = "cooking",
|
||||||
|
output = "creatures:meat",
|
||||||
|
recipe = "creatures:flesh",
|
||||||
|
})
|
||||||
|
|
||||||
-- spawn-eggs
|
-- spawn-eggs
|
||||||
minetest.register_craftitem("creatures:zombie_spawn_egg", {
|
minetest.register_craftitem("creatures:zombie_spawn_egg", {
|
||||||
description = "Zombie spawn-egg",
|
description = "Zombie spawn-egg",
|
||||||
|
|
18
sheep.lua
18
sheep.lua
|
@ -5,6 +5,7 @@ local s_texture = {"creatures_sheep.png"}
|
||||||
local s_hp = 8
|
local s_hp = 8
|
||||||
local s_life_max = 80 --~5min
|
local s_life_max = 80 --~5min
|
||||||
local s_drop = "wool:white"
|
local s_drop = "wool:white"
|
||||||
|
local s_drop2 = "creatures:flesh"
|
||||||
|
|
||||||
local s_player_radius = 14
|
local s_player_radius = 14
|
||||||
|
|
||||||
|
@ -158,6 +159,9 @@ SHEEP_DEF.on_punch = function(self, puncher, time_from_last_punch, tool_capabili
|
||||||
self.has_wool = false
|
self.has_wool = false
|
||||||
creatures.drop(my_pos, {{name=s_drop, count=math.random(1,2)}}, dir)
|
creatures.drop(my_pos, {{name=s_drop, count=math.random(1,2)}}, dir)
|
||||||
end
|
end
|
||||||
|
if self.object:get_hp() < 1 then
|
||||||
|
creatures.drop(my_pos, {{name=s_drop2, count=1}}, dir)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -204,9 +208,13 @@ SHEEP_DEF.on_step = function(self, dtime)
|
||||||
self.dead = true
|
self.dead = true
|
||||||
minetest.sound_play(s_sound_dead, {pos = current_pos, max_hear_distance = 10, gain = 0.9})
|
minetest.sound_play(s_sound_dead, {pos = current_pos, max_hear_distance = 10, gain = 0.9})
|
||||||
self.object:set_animation({x=self.anim.lay_START,y=self.anim.lay_END}, s_animation_speed, 0)
|
self.object:set_animation({x=self.anim.lay_START,y=self.anim.lay_END}, s_animation_speed, 0)
|
||||||
minetest.after(1, function()
|
minetest.after(0.5, function()
|
||||||
if self.has_wool and creatures.drop_on_death then
|
if creatures.drop_on_death then
|
||||||
local obj = minetest.env:add_item(current_pos, s_drop)
|
local drop = {{name=s_drop2, count=1}}
|
||||||
|
if self.has_wool then
|
||||||
|
drop[2] = {name=s_drop, count=math.random(1,2)}
|
||||||
|
end
|
||||||
|
creatures.drop(current_pos, drop, dir)
|
||||||
end
|
end
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end)
|
end)
|
||||||
|
@ -214,7 +222,7 @@ SHEEP_DEF.on_step = function(self, dtime)
|
||||||
|
|
||||||
-- die if old and alone
|
-- die if old and alone
|
||||||
if self.lifetime > s_life_max then
|
if self.lifetime > s_life_max then
|
||||||
if creatures.find_mates(current_pos, "sheep", 12) then
|
if creatures.find_mates(current_pos, "sheep", 18) then
|
||||||
self.lifetime = 0
|
self.lifetime = 0
|
||||||
else
|
else
|
||||||
self.object:set_hp(0)
|
self.object:set_hp(0)
|
||||||
|
@ -376,8 +384,8 @@ SHEEP_DEF.on_step = function(self, dtime)
|
||||||
self.timer = 0.45
|
self.timer = 0.45
|
||||||
end
|
end
|
||||||
minetest.after(1.8,function()
|
minetest.after(1.8,function()
|
||||||
minetest.set_node(p,{name="default:dirt"})
|
|
||||||
self.has_wool = true
|
self.has_wool = true
|
||||||
|
minetest.set_node(p,{name="default:dirt"})
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 404 B |
Loading…
Reference in New Issue