Reworked breeding
This commit is contained in:
parent
ace1582821
commit
992dc9a4b5
14
api.lua
14
api.lua
@ -370,8 +370,8 @@ rotate = def.rotate or 0,
|
||||
|
||||
-- if animal is horny, find another same animal who is horny and mate
|
||||
if self.horny == true and self.hornytimer <= 40 then
|
||||
local pos = self.object:getpos()
|
||||
effect(pos, 4, "heart.png")
|
||||
local pos = self.object:getpos() ; pos.y = pos.y + 1
|
||||
effect(pos, 4, "heart.png") ; pos.y = pos.y - 1
|
||||
local ents = minetest.get_objects_inside_radius(pos, self.view_range)
|
||||
local num = 0
|
||||
local ent = nil
|
||||
@ -381,14 +381,8 @@ rotate = def.rotate or 0,
|
||||
if ent and ent.name == self.name and ent.horny == true and ent.hornytimer <= 40 then num = num + 1 end
|
||||
|
||||
if num > 1 then
|
||||
self.following = ent
|
||||
ent.following = self
|
||||
self.horny = false
|
||||
self.hornytimer = 0
|
||||
self.following = nil
|
||||
ent.horny = false
|
||||
ent.following = nil
|
||||
ent.hornytimer = 0
|
||||
self.hornytimer = 41
|
||||
ent.hornytimer = 41
|
||||
minetest.after(7, function(dtime)
|
||||
local mob = minetest.add_entity(pos, self.name)
|
||||
local ent2 = mob:get_luaentity()
|
||||
|
44
chicken.lua
44
chicken.lua
@ -2,13 +2,11 @@
|
||||
-- Chicken by JK Murray
|
||||
|
||||
mobs:register_mob("mobs:chicken", {
|
||||
-- animal, monster, npc, barbarian
|
||||
type = "animal",
|
||||
-- is it aggressive
|
||||
passive = true,
|
||||
-- health & armor
|
||||
hp_min = 5, hp_max = 10, armor = 200,
|
||||
-- textures and model
|
||||
hp_min = 5,
|
||||
hp_max = 10,
|
||||
armor = 200,
|
||||
collisionbox = {-0.3, -0.75, -0.3, 0.3, 0.1, 0.3},
|
||||
visual = "mesh",
|
||||
mesh = "mobs_chicken.x",
|
||||
@ -23,26 +21,21 @@ mobs:register_mob("mobs:chicken", {
|
||||
"mobs_chick.png", "mobs_chick.png", "mobs_chick.png", "mobs_chick.png", "mobs_chick.png"},
|
||||
},
|
||||
blood_texture = "mobs_blood.png",
|
||||
-- sounds
|
||||
makes_footstep_sound = true,
|
||||
sounds = {
|
||||
random = "mobs_chicken",
|
||||
},
|
||||
-- speed and jump
|
||||
walk_velocity = 1,
|
||||
jump = true,
|
||||
-- drops raw chicken when dead
|
||||
drops = {
|
||||
{name = "mobs:chicken_raw",
|
||||
chance = 1, min = 2, max = 2},
|
||||
},
|
||||
-- damaged by
|
||||
water_damage = 1,
|
||||
lava_damage = 5,
|
||||
light_damage = 0,
|
||||
fall_damage = 0,
|
||||
fall_speed = -8,
|
||||
-- model animation
|
||||
animation = {
|
||||
speed_normal = 15,
|
||||
stand_start = 0,
|
||||
@ -50,48 +43,49 @@ mobs:register_mob("mobs:chicken", {
|
||||
walk_start = 20,
|
||||
walk_end = 40,
|
||||
},
|
||||
-- follows wheat
|
||||
follow = "farming:seed_wheat", view_range = 5,
|
||||
-- replace air with egg (lay)
|
||||
follow = "farming:seed_wheat",
|
||||
view_range = 5,
|
||||
replace_rate = 2000,
|
||||
replace_what = {"air"},
|
||||
replace_with = "mobs:egg",
|
||||
-- right click to pick up chicken
|
||||
on_rightclick = function(self, clicker)
|
||||
local tool = clicker:get_wielded_item()
|
||||
|
||||
if tool:get_name() == "farming:seed_wheat" then -- and self.gotten then
|
||||
if tool:get_name() == "farming:seed_wheat" then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
tool:take_item(1)
|
||||
clicker:set_wielded_item(tool)
|
||||
end
|
||||
self.food = (self.food or 0) + 1
|
||||
if self.child == true then
|
||||
self.hornytimer = self.hornytimer + 10
|
||||
return tool
|
||||
end
|
||||
self.food = (self.food or 0) + 1
|
||||
if self.food >= 8 then
|
||||
self.food = 0
|
||||
if self.child == false then self.horny = true end
|
||||
self.gotten = false -- reset
|
||||
if self.hornytimer == 0 then
|
||||
self.horny = true
|
||||
end
|
||||
self.tamed = true
|
||||
minetest.sound_play("mobs_chicken", {object = self.object,gain = 1.0,max_hear_distance = 15,loop = false,})
|
||||
end
|
||||
return tool
|
||||
end
|
||||
|
||||
if clicker:is_player() and clicker:get_inventory() and self.child == false
|
||||
if clicker:is_player()
|
||||
and clicker:get_inventory()
|
||||
and self.child == false
|
||||
and clicker:get_inventory():room_for_item("main", "mobs:chicken") then
|
||||
clicker:get_inventory():add_item("main", "mobs:chicken")
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
})
|
||||
-- spawn on default or bamboo grass between 8 and 20 light, 1 in 9000 change, 1 chicken in area up to 31000 in height
|
||||
|
||||
mobs:register_spawn("mobs:chicken", {"default:dirt_with_grass", "ethereal:bamboo_dirt"}, 20, 8, 9000, 1, 31000)
|
||||
-- register spawn egg
|
||||
|
||||
mobs:register_egg("mobs:chicken", "Chicken", "mobs_chicken_inv.png", 0)
|
||||
|
||||
-- Egg
|
||||
-- egg
|
||||
minetest.register_node("mobs:egg", {
|
||||
description = "Chicken Egg",
|
||||
tiles = {"mobs_chicken_egg.png"},
|
||||
@ -115,7 +109,7 @@ minetest.register_node("mobs:egg", {
|
||||
end
|
||||
})
|
||||
|
||||
-- Fried egg
|
||||
-- fried egg
|
||||
minetest.register_craftitem("mobs:chicken_egg_fried", {
|
||||
description = "Fried Egg",
|
||||
inventory_image = "mobs_chicken_egg_fried.png",
|
||||
@ -128,7 +122,7 @@ minetest.register_craft({
|
||||
output = "mobs:chicken_egg_fried",
|
||||
})
|
||||
|
||||
-- Chicken (raw and cooked)
|
||||
-- chicken (raw and cooked)
|
||||
minetest.register_craftitem("mobs:chicken_raw", {
|
||||
description = "Raw Chicken",
|
||||
inventory_image = "mobs_chicken_raw.png",
|
||||
|
50
cow.lua
50
cow.lua
@ -2,45 +2,37 @@
|
||||
-- Cow by Krupnovpavel
|
||||
|
||||
mobs:register_mob("mobs:cow", {
|
||||
-- animal, monster, npc, barbarian
|
||||
type = "animal",
|
||||
-- aggressive, does 4 damage to player when threatened
|
||||
passive = false,
|
||||
attack_type = "dogfight",
|
||||
damage = 4,
|
||||
-- health & armor
|
||||
hp_min = 5, hp_max = 20, armor = 200,
|
||||
-- textures and model
|
||||
hp_min = 5,
|
||||
hp_max = 20,
|
||||
armor = 200,
|
||||
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4},
|
||||
visual = "mesh",
|
||||
mesh = "mobs_cow.x",
|
||||
drawtype = "front",
|
||||
textures = {
|
||||
{"mobs_cow.png"},
|
||||
},
|
||||
blood_texture = "mobs_blood.png",
|
||||
visual_size = {x=1,y=1},
|
||||
-- sounds
|
||||
makes_footstep_sound = true,
|
||||
sounds = {
|
||||
random = "mobs_cow",
|
||||
},
|
||||
-- speed and jump
|
||||
walk_velocity = 1,
|
||||
run_velocity = 2,
|
||||
jump = true,
|
||||
-- drops raw meat when dead
|
||||
drops = {
|
||||
{name = "mobs:meat_raw",
|
||||
chance = 1, min = 5, max = 10},
|
||||
{name = "mobs:leather",
|
||||
chance = 1, min = 0, max = 3},
|
||||
},
|
||||
-- damaged by
|
||||
water_damage = 1,
|
||||
lava_damage = 5,
|
||||
light_damage = 0,
|
||||
-- model animation
|
||||
animation = {
|
||||
speed_normal = 15, speed_run = 15,
|
||||
stand_start = 0, stand_end = 30,
|
||||
@ -48,20 +40,20 @@ mobs:register_mob("mobs:cow", {
|
||||
run_start = 105, run_end = 135,
|
||||
punch_start = 70, punch_end = 100,
|
||||
},
|
||||
-- follows wheat
|
||||
follow = "farming:wheat", view_range = 7,
|
||||
-- replace grass/wheat with air (eat)
|
||||
follow = "farming:wheat",
|
||||
view_range = 7,
|
||||
replace_rate = 50,
|
||||
replace_what = {"default:grass_3", "default:grass_4", "default:grass_5", "farming:wheat_8"},
|
||||
replace_with = "air",
|
||||
-- right-click cow with empty bucket to get milk, then feed 8 wheat to replenish milk
|
||||
on_rightclick = function(self, clicker)
|
||||
local tool = clicker:get_wielded_item()
|
||||
if tool:get_name() == "bucket:bucket_empty" and self.child == false then
|
||||
if self.gotten then return end
|
||||
if tool:get_name() == "bucket:bucket_empty" then
|
||||
if self.gotten == true
|
||||
or self.child == true then
|
||||
return
|
||||
end
|
||||
local inv = clicker:get_inventory()
|
||||
inv:remove_item("main", "bucket:bucket_empty")
|
||||
-- if room add bucket of milk to inventory, otherwise drop as item
|
||||
if inv:room_for_item("main", {name="mobs:bucket_milk"}) then
|
||||
clicker:get_inventory():add_item("main", "mobs:bucket_milk")
|
||||
else
|
||||
@ -71,18 +63,22 @@ mobs:register_mob("mobs:cow", {
|
||||
end
|
||||
self.gotten = true -- milked
|
||||
end
|
||||
if tool:get_name() == "farming:wheat" then -- and self.gotten then
|
||||
|
||||
if tool:get_name() == "farming:wheat" then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
tool:take_item(1)
|
||||
clicker:set_wielded_item(tool)
|
||||
end
|
||||
self.food = (self.food or 0) + 1
|
||||
if self.child == true then
|
||||
self.hornytimer = self.hornytimer + 10
|
||||
return tool
|
||||
end
|
||||
self.food = (self.food or 0) + 1
|
||||
if self.food >= 8 then
|
||||
self.food = 0
|
||||
if self.child == false then self.horny = true end
|
||||
if self.hornytimer == 0 then
|
||||
self.horny = true
|
||||
end
|
||||
self.gotten = false -- ready to be milked again
|
||||
self.tamed = true
|
||||
minetest.sound_play("mobs_cow", {object = self.object,gain = 1.0,max_hear_distance = 32,loop = false,})
|
||||
@ -92,18 +88,18 @@ mobs:register_mob("mobs:cow", {
|
||||
|
||||
end,
|
||||
})
|
||||
-- spawn on default;green;prairie grass between 0 and 20 light, 1 in 11000 chance, 1 cow in area up to 31000 in height
|
||||
|
||||
mobs:register_spawn("mobs:cow", {"default:dirt_with_grass", "ethereal:green_dirt_top"}, 20, 0, 11000, 1, 31000)
|
||||
-- register spawn egg
|
||||
|
||||
mobs:register_egg("mobs:cow", "Cow", "default_grass.png", 1)
|
||||
|
||||
-- Leather
|
||||
-- leather
|
||||
minetest.register_craftitem("mobs:leather", {
|
||||
description = "Leather",
|
||||
inventory_image = "mobs_leather.png",
|
||||
})
|
||||
|
||||
-- Bucket of Milk
|
||||
-- bucket of milk
|
||||
minetest.register_craftitem("mobs:bucket_milk", {
|
||||
description = "Bucket of Milk",
|
||||
inventory_image = "mobs_bucket_milk.png",
|
||||
@ -111,7 +107,7 @@ minetest.register_craftitem("mobs:bucket_milk", {
|
||||
on_use = minetest.item_eat(8, 'bucket:bucket_empty'),
|
||||
})
|
||||
|
||||
-- Cheese Wedge
|
||||
-- cheese wedge
|
||||
minetest.register_craftitem("mobs:cheese", {
|
||||
description = "Cheese",
|
||||
inventory_image = "mobs_cheese.png",
|
||||
@ -126,7 +122,7 @@ minetest.register_craft({
|
||||
replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}}
|
||||
})
|
||||
|
||||
-- Cheese Block
|
||||
-- cheese block
|
||||
minetest.register_node("mobs:cheeseblock", {
|
||||
description = "Cheese Block",
|
||||
tiles = {"mobs_cheeseblock.png"},
|
||||
|
40
sheep.lua
40
sheep.lua
@ -2,58 +2,46 @@
|
||||
-- Sheep by PilzAdam
|
||||
|
||||
mobs:register_mob("mobs:sheep", {
|
||||
-- animal, monster, npc, barbarian
|
||||
type = "animal",
|
||||
-- not aggressive
|
||||
passive = true,
|
||||
-- health & armor
|
||||
hp_min = 8, hp_max = 10, armor = 200,
|
||||
-- textures and model
|
||||
hp_min = 8,
|
||||
hp_max = 10,
|
||||
armor = 200,
|
||||
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4},
|
||||
visual = "mesh",
|
||||
mesh = "mobs_sheep.x",
|
||||
drawtype = "front",
|
||||
textures = {
|
||||
{"mobs_sheep.png"},
|
||||
},
|
||||
blood_texture = "mobs_blood.png",
|
||||
visual_size = {x=1,y=1},
|
||||
-- specific texture and mesh for gotten
|
||||
gotten_texture = {"mobs_sheep_shaved.png"},
|
||||
gotten_mesh = "mobs_sheep_shaved.x",
|
||||
-- sounds
|
||||
makes_footstep_sound = true,
|
||||
sounds = {
|
||||
random = "mobs_sheep",
|
||||
},
|
||||
-- speed and jump
|
||||
walk_velocity = 1,
|
||||
jump = true,
|
||||
-- drops raw meat when dead
|
||||
drops = {
|
||||
{name = "mobs:meat_raw",
|
||||
chance = 1, min = 2, max = 3},
|
||||
{name = "wool:white",
|
||||
chance = 1, min = 1, max = 1},
|
||||
},
|
||||
-- damaged by
|
||||
water_damage = 1,
|
||||
lava_damage = 5,
|
||||
light_damage = 0,
|
||||
-- model animation
|
||||
animation = {
|
||||
speed_normal = 15, speed_run = 15,
|
||||
stand_start = 0, stand_end = 80,
|
||||
walk_start = 81, walk_end = 100,
|
||||
},
|
||||
-- follows wheat
|
||||
follow = "farming:wheat",
|
||||
view_range = 5,
|
||||
-- replace grass/wheat with air (eat)
|
||||
replace_rate = 50,
|
||||
replace_what = {"default:grass_3", "default:grass_4", "default:grass_5", "farming:wheat_8"},
|
||||
replace_with = "air",
|
||||
-- right click sheep to shear sheep and get wood, feed 8 wheat for wool to grow back
|
||||
on_rightclick = function(self, clicker)
|
||||
local item = clicker:get_wielded_item()
|
||||
if item:get_name() == "farming:wheat" then
|
||||
@ -61,13 +49,16 @@ mobs:register_mob("mobs:sheep", {
|
||||
item:take_item()
|
||||
clicker:set_wielded_item(item)
|
||||
end
|
||||
self.food = (self.food or 0) + 1
|
||||
if self.child == true then
|
||||
self.hornytimer = self.hornytimer + 10
|
||||
return tool
|
||||
end
|
||||
self.food = (self.food or 0) + 1
|
||||
if self.food >= 8 then
|
||||
self.food = 0
|
||||
if self.child == false then self.horny = true end
|
||||
if self.hornytimer == 0 then
|
||||
self.horny = true
|
||||
end
|
||||
self.gotten = false -- can be shaved again
|
||||
self.tamed = true
|
||||
self.object:set_properties({
|
||||
@ -76,11 +67,12 @@ mobs:register_mob("mobs:sheep", {
|
||||
})
|
||||
minetest.sound_play("mobs_sheep", {object = self.object,gain = 1.0,max_hear_distance = 32,loop = false,})
|
||||
end
|
||||
return
|
||||
return tool
|
||||
end
|
||||
-- need shears to get wool from sheep
|
||||
local inv = clicker:get_inventory()
|
||||
if inv and item:get_name() == "mobs:shears" and not self.gotten and self.child == false then
|
||||
|
||||
if item:get_name() == "mobs:shears"
|
||||
and self.gotten == false
|
||||
and self.child == false then
|
||||
self.gotten = true -- shaved
|
||||
if minetest.registered_items["wool:white"] then
|
||||
local pos = self.object:getpos()
|
||||
@ -99,12 +91,12 @@ mobs:register_mob("mobs:sheep", {
|
||||
end
|
||||
end,
|
||||
})
|
||||
-- spawn on default;green grass between 8 and 20 light, 1 in 9000 chance, 1 sheep in area up to 31000 in height
|
||||
|
||||
mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass", "ethereal:green_dirt_top"}, 20, 8, 9000, 1, 31000)
|
||||
-- register spawn egg
|
||||
|
||||
mobs:register_egg("mobs:sheep", "Sheep", "wool_white.png", 1)
|
||||
|
||||
-- shears tool (right click sheep to shear)
|
||||
-- shears (right click sheep to shear wool)
|
||||
minetest.register_tool("mobs:shears", {
|
||||
description = "Steel Shears (right-click sheep to shear)",
|
||||
inventory_image = "mobs_shears.png",
|
||||
|
Loading…
x
Reference in New Issue
Block a user