2017-01-16 17:40:08 +01:00
|
|
|
--MCmobs v0.2
|
|
|
|
--maikerumine
|
|
|
|
--made for MC like Survival game
|
|
|
|
--License for code WTFPL and otherwise stated in readmes
|
|
|
|
|
2017-02-28 02:13:14 +01:00
|
|
|
local colors = {
|
|
|
|
-- dyecolor = { woolcolor, textures }
|
|
|
|
white = { "white", { "mobs_sheep.png" } },
|
|
|
|
brown = { "brown", { "mobs_sheep_brown.png" } },
|
|
|
|
grey = { "silver", { "mobs_sheep_grey.png" } },
|
|
|
|
dark_grey = { "grey", { "mobs_sheep_dark_grey.png" } },
|
|
|
|
blue = { "blue", { "mobs_sheep_blue.png" } },
|
|
|
|
lightblue = { "light_blue", { "mobs_sheep_lightblue.png" } },
|
|
|
|
dark_green = { "green", { "mobs_sheep_dark_green.png" } },
|
|
|
|
green = { "lime", { "mobs_sheep_green.png" } },
|
|
|
|
violet = { "purple", { "mobs_sheep_violet.png" } },
|
|
|
|
pink = { "pink", { "mobs_sheep_pink.png" } },
|
|
|
|
yellow = { "yellow", { "mobs_sheep_yellow.png" } },
|
|
|
|
orange = { "orange", { "mobs_sheep_orange.png" } },
|
|
|
|
red = { "red", { "mobs_sheep_red.png" } },
|
|
|
|
cyan = { "cyan", { "mobs_sheep_cyan.png" } },
|
|
|
|
magenta = { "magenta", { "mobs_sheep_magenta.png" } },
|
|
|
|
black = { "black", { "mobs_sheep_black.png" } },
|
|
|
|
}
|
2017-01-16 17:40:08 +01:00
|
|
|
|
2017-02-23 19:03:26 +01:00
|
|
|
-- Sheep
|
2017-01-16 17:40:08 +01:00
|
|
|
mobs:register_mob("mobs_mc:sheep", {
|
|
|
|
type = "animal",
|
2017-01-20 21:24:56 +01:00
|
|
|
hp_min = 8,
|
2017-01-16 20:52:09 +01:00
|
|
|
hp_max = 8,
|
2017-02-23 19:12:18 +01:00
|
|
|
-- FIXME: Should be 1.3 blocks high
|
|
|
|
collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.09, 0.45},
|
2017-01-16 17:40:08 +01:00
|
|
|
|
|
|
|
visual = "mesh",
|
2017-02-23 19:03:26 +01:00
|
|
|
visual_size = {x=0.6, y=0.6},
|
2017-01-16 17:40:08 +01:00
|
|
|
mesh = "mobs_sheep.x",
|
2017-02-28 02:13:14 +01:00
|
|
|
textures = {{"mobs_sheep.png"}},
|
2017-01-16 17:40:08 +01:00
|
|
|
makes_footstep_sound = true,
|
|
|
|
walk_velocity = 1,
|
2017-01-16 20:52:09 +01:00
|
|
|
armor = 100,
|
2017-01-16 17:40:08 +01:00
|
|
|
drops = {
|
2017-02-23 14:13:50 +01:00
|
|
|
{name = "mcl_mobitems:mutton",
|
2017-01-16 17:40:08 +01:00
|
|
|
chance = 1,
|
|
|
|
min = 1,
|
|
|
|
max = 2,},
|
2017-01-30 15:25:24 +01:00
|
|
|
{name = "mcl_wool:white",
|
2017-01-16 17:40:08 +01:00
|
|
|
chance = 1,
|
|
|
|
min = 1,
|
|
|
|
max = 1,},
|
|
|
|
},
|
|
|
|
drawtype = "front",
|
2017-02-23 19:52:07 +01:00
|
|
|
lava_damage = minetest.registered_nodes["mcl_core:lava_source"].damage_per_second,
|
2017-01-16 17:40:08 +01:00
|
|
|
light_damage = 0,
|
2017-02-23 18:39:13 +01:00
|
|
|
fear_height = 4,
|
|
|
|
jump_height = 4.5,
|
2017-01-16 17:40:08 +01:00
|
|
|
sounds = {
|
2017-02-20 02:24:46 +01:00
|
|
|
random = "mobs_sheep",
|
|
|
|
death = "mobs_sheep",
|
2017-03-18 01:37:29 +01:00
|
|
|
damage = "mobs_sheep",
|
2017-01-16 17:40:08 +01:00
|
|
|
},
|
|
|
|
animation = {
|
|
|
|
speed_normal = 24,
|
|
|
|
stand_start = 0,
|
|
|
|
stand_end = 23,
|
|
|
|
walk_start = 24,
|
|
|
|
walk_end = 49,
|
|
|
|
hurt_start = 118,
|
|
|
|
hurt_end = 154,
|
|
|
|
death_start = 154,
|
|
|
|
death_end = 179,
|
|
|
|
eat_start = 49,
|
|
|
|
eat_end = 78,
|
|
|
|
look_start = 78,
|
|
|
|
look_end = 108,
|
|
|
|
},
|
2017-02-23 18:39:13 +01:00
|
|
|
follow = {"mcl_farming:wheat_item"},
|
2017-01-16 17:40:08 +01:00
|
|
|
view_range = 5,
|
2017-02-23 18:39:13 +01:00
|
|
|
|
|
|
|
replace_rate = 10,
|
2017-03-14 20:05:07 +01:00
|
|
|
replace_what = {"mcl_core:dirt_with_grass", "mcl_flowers:tallgrass"},
|
2017-02-23 18:39:13 +01:00
|
|
|
replace_with = "air",
|
2017-02-28 02:13:14 +01:00
|
|
|
do_custom = function(self)
|
|
|
|
if not self.initial_color_set then
|
|
|
|
local r = math.random(0,100000)
|
|
|
|
local textures
|
|
|
|
if r <= 81836 then
|
|
|
|
-- 81.836%
|
|
|
|
self.color = colors["white"][1]
|
|
|
|
textures = colors["white"][2]
|
|
|
|
elseif r <= 81836 + 5000 then
|
|
|
|
-- 5%
|
|
|
|
self.color = colors["grey"][1]
|
|
|
|
textures = colors["grey"][2]
|
|
|
|
elseif r <= 81836 + 5000 + 5000 then
|
|
|
|
-- 5%
|
|
|
|
self.color = colors["dark_grey"][1]
|
|
|
|
textures = colors["dark_grey"][2]
|
|
|
|
elseif r <= 81836 + 5000 + 5000 + 5000 then
|
|
|
|
-- 5%
|
|
|
|
self.color = colors["black"][1]
|
|
|
|
textures = colors["black"][2]
|
|
|
|
elseif r <= 81836 + 5000 + 5000 + 5000 + 3000 then
|
|
|
|
-- 3%
|
|
|
|
self.color = colors["brown"][1]
|
|
|
|
textures = colors["brown"][2]
|
|
|
|
else
|
|
|
|
-- 0.164%
|
|
|
|
self.color = colors["pink"][1]
|
|
|
|
textures = colors["pink"][2]
|
|
|
|
end
|
|
|
|
self.textures = { textures },
|
|
|
|
self.object:set_properties({ textures = textures })
|
|
|
|
self.drops = {
|
|
|
|
{name = "mcl_mobitems:mutton",
|
|
|
|
chance = 1,
|
|
|
|
min = 1,
|
|
|
|
max = 2,},
|
|
|
|
{name = "mcl_wool:"..self.color,
|
|
|
|
chance = 1,
|
|
|
|
min = 1,
|
|
|
|
max = 1,},
|
|
|
|
}
|
|
|
|
self.initial_color_set = true
|
|
|
|
end
|
|
|
|
end,
|
2017-01-16 17:40:08 +01:00
|
|
|
on_rightclick = function(self, clicker)
|
2017-02-23 18:39:13 +01:00
|
|
|
|
|
|
|
if mobs:feed_tame(self, clicker, 1, true, true) then
|
2017-01-16 17:40:08 +01:00
|
|
|
return
|
|
|
|
end
|
2017-02-23 18:39:13 +01:00
|
|
|
|
|
|
|
local item = clicker:get_wielded_item()
|
2017-02-28 02:13:14 +01:00
|
|
|
if item:get_name() == "mcl_tools:shears" and not self.gotten and not self.child then
|
2017-02-23 18:39:13 +01:00
|
|
|
self.gotten = true
|
2017-01-16 17:40:08 +01:00
|
|
|
local pos = self.object:getpos()
|
|
|
|
minetest.sound_play("shears", {pos = pos})
|
|
|
|
pos.y = pos.y + 0.5
|
|
|
|
if not self.color then
|
2017-01-30 15:25:24 +01:00
|
|
|
minetest.add_item(pos, ItemStack("mcl_wool:white "..math.random(1,3)))
|
2017-01-16 17:40:08 +01:00
|
|
|
else
|
2017-01-30 15:25:24 +01:00
|
|
|
minetest.add_item(pos, ItemStack("mcl_wool:"..self.color.." "..math.random(1,3)))
|
2017-01-16 17:40:08 +01:00
|
|
|
end
|
|
|
|
self.object:set_properties({
|
2017-02-17 05:12:58 +01:00
|
|
|
textures = {"mobs_sheep_sheared.png"},
|
2017-01-16 17:40:08 +01:00
|
|
|
})
|
|
|
|
if not minetest.setting_getbool("creative_mode") then
|
2017-02-23 14:25:09 +01:00
|
|
|
item:add_wear(65535/238)
|
2017-01-16 17:40:08 +01:00
|
|
|
clicker:get_inventory():set_stack("main", clicker:get_wield_index(), item)
|
|
|
|
end
|
|
|
|
end
|
2017-02-23 18:39:13 +01:00
|
|
|
if minetest.get_item_group(item:get_name(), "dye") == 1 and not self.gotten then
|
2017-01-16 17:40:08 +01:00
|
|
|
print(item:get_name(), minetest.get_item_group(item:get_name(), "dye"))
|
|
|
|
local name = item:get_name()
|
|
|
|
local pname = name:split(":")[2]
|
|
|
|
|
|
|
|
self.object:set_properties({
|
2017-02-28 02:13:14 +01:00
|
|
|
textures = colors[pname][2],
|
2017-01-16 17:40:08 +01:00
|
|
|
})
|
2017-02-28 02:13:14 +01:00
|
|
|
self.color = colors[pname][1]
|
2017-01-16 17:40:08 +01:00
|
|
|
self.drops = {
|
2017-02-23 14:13:50 +01:00
|
|
|
{name = "mcl_mobitems:mutton",
|
2017-01-16 17:40:08 +01:00
|
|
|
chance = 1,
|
|
|
|
min = 1,
|
|
|
|
max = 2,},
|
2017-01-30 15:25:24 +01:00
|
|
|
{name = "mcl_wool:"..self.color,
|
2017-01-16 17:40:08 +01:00
|
|
|
chance = 1,
|
|
|
|
min = 1,
|
|
|
|
max = 1,},
|
|
|
|
}
|
2017-03-01 05:27:23 +01:00
|
|
|
|
|
|
|
if not minetest.setting_getbool("creative_mode") then
|
|
|
|
item:take_item()
|
|
|
|
clicker:get_inventory():set_stack("main", clicker:get_wield_index(), item)
|
|
|
|
end
|
2017-01-16 17:40:08 +01:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
2017-02-20 03:00:03 +01:00
|
|
|
mobs:register_spawn("mobs_mc:sheep", {"mcl_core:dirt_with_grass"}, 20, 9, 5000, 2, 31000)
|
2017-01-16 17:40:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
-- compatibility
|
|
|
|
mobs:alias_mob("mobs:sheep", "mobs_mc:sheep")
|
|
|
|
|
|
|
|
-- spawn eggs
|
2017-01-17 00:05:12 +01:00
|
|
|
mobs:register_egg("mobs_mc:sheep", "Spawn Sheep", "spawn_egg_sheep.png")
|
2017-01-16 17:40:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
if minetest.setting_get("log_mods") then
|
|
|
|
minetest.log("action", "MC Sheep loaded")
|
|
|
|
end
|