mobs_mc/cow.lua

202 lines
4.4 KiB
Lua
Raw Normal View History

2017-05-25 20:39:12 -04:00
--MCmobs v0.4
--maikerumine
--made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes
--dofile(minetest.get_modpath("mobs").."/api.lua")
--###################
--################### COW
--###################
2017-05-23 19:03:37 -04:00
--[[
mobs:register_mob("mobs_mc:0acow", {
type = "animal",
passive = true,
runaway = true,
stepheight = 1.2,
hp_min = 30,
hp_max = 60,
armor = 150,
collisionbox = {-0.35, -0.01, -0.35, 0.35, 2, 0.35},
rotate = -180,
visual = "mesh",
mesh = "cow.b3d",
textures = {
{"cow.png"},
},
visual_size = {x=3, y=3},
walk_velocity = 0.6,
run_velocity = 2,
jump = true,
animation = {
speed_normal = 25, speed_run = 50,
stand_start = 0, stand_end = 0,
walk_start = 0, walk_end = 40,
run_start = 0, run_end = 40,
},
})
mobs:register_egg("mobs_mc:0acow", "Cow", "cow_inv.png", 0)
2017-05-23 19:03:37 -04:00
]]
mobs:register_mob("mobs_mc:cow", {
type = "animal",
hp_max = 28,
collisionbox = {-0.6, -0.01, -0.6, 0.6, 1.8, 0.6},
2017-05-23 19:03:37 -04:00
rotate = -180,
visual = "mesh",
2017-05-23 19:03:37 -04:00
mesh = "cow.b3d",
textures = {
2017-05-23 19:03:37 -04:00
{"cow.png"},
},
2017-05-23 19:03:37 -04:00
visual_size = {x=3, y=3},
makes_footstep_sound = true,
walk_velocity = 1,
armor = 200,
drops = {
{name = "mobs:beef_raw",
chance = 1,
min = 1,
max = 3,},
{name = "mobs:leather",
chance = 1,
min = 0,
max = 2,},
},
drawtype = "front",
water_damage = 1,
lava_damage = 5,
light_damage = 0,
fear_height = 3,
sounds = {
random = "Cow1",
death = "Cowhurt1",
damage = "Cowhurt1",
},
animation = {
2017-05-23 19:03:37 -04:00
speed_normal = 25, speed_run = 50,
stand_start = 0, stand_end = 0,
walk_start = 0, walk_end = 40,
run_start = 0, run_end = 40,
},
2016-05-26 21:29:06 -04:00
--[[
follow = "farming:wheat",
view_range = 5,
on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item()
if item:get_name() == "bucket:bucket_empty" and clicker:get_inventory() then
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
local pos = self.object:getpos()
pos.y = pos.y + 0.5
minetest.add_item(pos, {name = "mobs:bucket_milk"})
end
end
end,
2016-05-26 21:29:06 -04:00
]]
--from mobs_animals
follow = "farming:wheat",
view_range = 7,
replace_rate = 10,
replace_what = {"default:grass_3", "default:grass_4", "default:grass_5", "farming:wheat_8"},
replace_with = "air",
fear_height = 2,
on_rightclick = function(self, clicker)
-- feed or tame
if mobs:feed_tame(self, clicker, 8, true, true) then
return
end
local tool = clicker:get_wielded_item()
-- milk cow with empty bucket
if tool:get_name() == "bucket:bucket_empty" then
--if self.gotten == true
if self.child == true then
return
end
if self.gotten == true then
minetest.chat_send_player(clicker:get_player_name(),
"Cow already milked!")
return
end
local inv = clicker:get_inventory()
inv:remove_item("main", "bucket:bucket_empty")
if inv:room_for_item("main", {name = "mobs:bucket_milk"}) then
clicker:get_inventory():add_item("main", "mobs:bucket_milk")
else
local pos = self.object:getpos()
pos.y = pos.y + 0.5
minetest.add_item(pos, {name = "mobs:bucket_milk"})
end
self.gotten = true -- milked
return
end
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
end,
})
2016-05-26 21:29:06 -04:00
2017-05-28 23:16:44 -04:00
mobs:register_spawn("mobs_mc:cow", {"default:dirt_with_grass"}, 20, 8, 17000, 2, 31000)
-- beef
minetest.register_craftitem(":mobs:beef_raw", {
description = "Raw Beef",
inventory_image = "beef_raw.png",
on_use = minetest.item_eat(3),
})
minetest.register_craftitem(":mobs:beef_cooked", {
description = "Steak",
inventory_image = "beef_cooked.png",
on_use = minetest.item_eat(8),
})
minetest.register_craft({
type = "cooking",
output = "mobs:beef_cooked",
recipe = "mobs:beef_raw",
cooktime = 5,
})
-- saddle
minetest.register_craftitem(":mobs:saddle", {
description = "Saddle",
inventory_image = "saddle.png",
})
minetest.register_craft({
output = "mobs:saddle",
recipe = {
{"mobs:leather", "mobs:leather", "mobs:leather"},
{"farming:string", "", "farming:string"},
{"default:steel_ingot", "", "default:steel_ingot"}
},
})
2017-05-23 19:03:37 -04:00
-- compatibility
2017-05-23 19:03:37 -04:00
mobs:alias_mob("mobs_animal:cow", "mobs_mc:cow")
2017-05-23 19:03:37 -04:00
-- spawn egg
mobs:register_egg("mobs_mc:cow", "Cow", "cow_inv.png", 0)
if minetest.setting_get("log_mods") then
minetest.log("action", "MC Cow loaded")
end