2023-08-13 11:56:57 +02:00
|
|
|
-- Translation support
|
|
|
|
local S = minetest.get_translator("mobs_animal")
|
2017-02-21 16:23:03 +01:00
|
|
|
|
2016-04-15 15:59:43 +02:00
|
|
|
-- Bunny by ExeterDad
|
|
|
|
|
|
|
|
mobs:register_mob("mobs_animal:bunny", {
|
|
|
|
type = "animal",
|
2023-05-28 13:22:00 +02:00
|
|
|
passive = true,
|
2016-04-15 15:59:43 +02:00
|
|
|
reach = 1,
|
2023-05-28 13:19:49 +02:00
|
|
|
stepheight = 0.6,
|
2016-04-15 15:59:43 +02:00
|
|
|
hp_min = 1,
|
|
|
|
hp_max = 4,
|
|
|
|
armor = 200,
|
2022-10-11 12:09:19 +02:00
|
|
|
collisionbox = {-0.268, -0.5, -0.268, 0.268, 0.167, 0.268},
|
2016-04-15 15:59:43 +02:00
|
|
|
visual = "mesh",
|
|
|
|
mesh = "mobs_bunny.b3d",
|
|
|
|
drawtype = "front",
|
|
|
|
textures = {
|
|
|
|
{"mobs_bunny_grey.png"},
|
|
|
|
{"mobs_bunny_brown.png"},
|
2022-09-27 10:15:59 +02:00
|
|
|
{"mobs_bunny_white.png"}
|
2016-04-15 15:59:43 +02:00
|
|
|
},
|
|
|
|
sounds = {},
|
|
|
|
makes_footstep_sound = false,
|
|
|
|
walk_velocity = 1,
|
|
|
|
run_velocity = 2,
|
|
|
|
runaway = true,
|
2018-01-26 16:32:16 +01:00
|
|
|
runaway_from = {"mobs_animal:pumba", "player"},
|
2016-04-15 15:59:43 +02:00
|
|
|
jump = true,
|
2018-01-26 15:29:15 +01:00
|
|
|
jump_height = 6,
|
2016-04-15 15:59:43 +02:00
|
|
|
drops = {
|
2018-01-26 15:29:15 +01:00
|
|
|
{name = "mobs:rabbit_raw", chance = 1, min = 1, max = 1},
|
2022-09-27 10:15:59 +02:00
|
|
|
{name = "mobs:rabbit_hide", chance = 1, min = 0, max = 1}
|
2016-04-15 15:59:43 +02:00
|
|
|
},
|
2023-02-08 12:58:49 +01:00
|
|
|
water_damage = 0.01,
|
2016-04-15 15:59:43 +02:00
|
|
|
lava_damage = 4,
|
|
|
|
light_damage = 0,
|
|
|
|
fear_height = 2,
|
|
|
|
animation = {
|
|
|
|
speed_normal = 15,
|
|
|
|
stand_start = 1,
|
|
|
|
stand_end = 15,
|
|
|
|
walk_start = 16,
|
|
|
|
walk_end = 24,
|
|
|
|
punch_start = 16,
|
2022-09-27 10:15:59 +02:00
|
|
|
punch_end = 24
|
2016-04-15 15:59:43 +02:00
|
|
|
},
|
2017-05-20 16:35:07 +02:00
|
|
|
follow = {"farming:carrot", "farming_plus:carrot_item", "default:grass_1"},
|
2016-04-15 15:59:43 +02:00
|
|
|
view_range = 8,
|
|
|
|
replace_rate = 10,
|
|
|
|
replace_what = {"farming:carrot_7", "farming:carrot_8", "farming_plus:carrot"},
|
|
|
|
replace_with = "air",
|
2022-09-27 10:15:59 +02:00
|
|
|
|
2016-04-15 15:59:43 +02:00
|
|
|
on_rightclick = function(self, clicker)
|
|
|
|
|
|
|
|
-- feed or tame
|
2017-04-27 15:00:57 +02:00
|
|
|
if mobs:feed_tame(self, clicker, 4, true, true) then return end
|
|
|
|
if mobs:protect(self, clicker) then return end
|
|
|
|
if mobs:capture_mob(self, clicker, 30, 50, 80, false, nil) then return end
|
2016-04-15 15:59:43 +02:00
|
|
|
|
|
|
|
-- Monty Python tribute
|
|
|
|
local item = clicker:get_wielded_item()
|
2023-05-28 13:19:49 +02:00
|
|
|
local player_name = clicker:get_player_name()
|
2016-04-15 15:59:43 +02:00
|
|
|
|
2023-05-28 13:19:49 +02:00
|
|
|
if self.owner == player_name
|
|
|
|
and item:get_name() == "mobs:lava_orb" then
|
2016-04-15 15:59:43 +02:00
|
|
|
|
2023-05-28 13:19:49 +02:00
|
|
|
-- take orb
|
2017-10-09 12:57:20 +02:00
|
|
|
if not mobs.is_creative(clicker:get_player_name()) then
|
2016-04-15 15:59:43 +02:00
|
|
|
item:take_item()
|
|
|
|
clicker:set_wielded_item(item)
|
|
|
|
end
|
|
|
|
|
2023-05-28 13:19:49 +02:00
|
|
|
-- set special bunny attributes
|
|
|
|
local staticdata = minetest.serialize({
|
|
|
|
type = "monster",
|
2023-05-28 13:22:00 +02:00
|
|
|
attack_type = "dogfight",
|
2023-05-28 13:19:49 +02:00
|
|
|
health = 20,
|
|
|
|
damage = 5,
|
|
|
|
run_velocity = 3,
|
|
|
|
passive = false,
|
|
|
|
runaway = false,
|
|
|
|
runaway_from = {},
|
|
|
|
runaway_timer = 0,
|
|
|
|
tamed = false,
|
|
|
|
base_texture = {"mobs_bunny_evil.png"}
|
2016-04-15 15:59:43 +02:00
|
|
|
})
|
|
|
|
|
2023-05-28 13:19:49 +02:00
|
|
|
-- add evil bunny
|
|
|
|
local obj = minetest.add_entity(
|
|
|
|
self.object:get_pos(), "mobs_animal:bunny", staticdata)
|
2016-04-15 15:59:43 +02:00
|
|
|
|
2023-10-07 13:01:27 +02:00
|
|
|
obj:set_properties({textures = {"mobs_bunny_evil.png"}, hp_max = 20})
|
|
|
|
|
2023-05-28 13:19:49 +02:00
|
|
|
-- remove old bunny
|
|
|
|
if obj:get_luaentity() then
|
|
|
|
mobs:remove(self, true)
|
|
|
|
end
|
2016-04-15 15:59:43 +02:00
|
|
|
end
|
|
|
|
end,
|
2022-10-11 12:09:19 +02:00
|
|
|
|
2017-09-01 13:28:10 +02:00
|
|
|
on_spawn = function(self)
|
|
|
|
|
2017-10-09 16:16:05 +02:00
|
|
|
local pos = self.object:get_pos() ; pos.y = pos.y - 1
|
2017-09-01 13:28:10 +02:00
|
|
|
|
2017-09-15 16:27:56 +02:00
|
|
|
-- white snowy bunny
|
|
|
|
if minetest.find_node_near(pos, 1,
|
|
|
|
{"default:snow", "default:snowblock", "default:dirt_with_snow"}) then
|
2017-09-01 13:28:10 +02:00
|
|
|
self.base_texture = {"mobs_bunny_white.png"}
|
|
|
|
self.object:set_properties({textures = self.base_texture})
|
2022-09-27 10:15:59 +02:00
|
|
|
|
2017-09-15 16:27:56 +02:00
|
|
|
-- brown desert bunny
|
|
|
|
elseif minetest.find_node_near(pos, 1,
|
|
|
|
{"default:desert_sand", "default:desert_stone"}) then
|
2017-09-01 13:28:10 +02:00
|
|
|
self.base_texture = {"mobs_bunny_brown.png"}
|
|
|
|
self.object:set_properties({textures = self.base_texture})
|
2022-09-27 10:15:59 +02:00
|
|
|
|
2017-09-15 16:27:56 +02:00
|
|
|
-- grey stone bunny
|
|
|
|
elseif minetest.find_node_near(pos, 1,
|
|
|
|
{"default:stone", "default:gravel"}) then
|
|
|
|
self.base_texture = {"mobs_bunny_grey.png"}
|
|
|
|
self.object:set_properties({textures = self.base_texture})
|
2017-09-01 13:28:10 +02:00
|
|
|
end
|
2016-04-15 15:59:43 +02:00
|
|
|
|
2023-05-28 13:19:49 +02:00
|
|
|
return true -- run only once, false/nil runs every activation
|
|
|
|
end
|
2016-04-15 15:59:43 +02:00
|
|
|
})
|
|
|
|
|
2017-02-21 16:23:03 +01:00
|
|
|
|
|
|
|
local spawn_on = "default:dirt_with_grass"
|
|
|
|
|
|
|
|
if minetest.get_modpath("ethereal") then
|
|
|
|
spawn_on = "ethereal:prairie_dirt"
|
|
|
|
end
|
|
|
|
|
2020-09-21 10:48:45 +02:00
|
|
|
if not mobs.custom_spawn_animal then
|
2022-09-27 10:15:59 +02:00
|
|
|
|
|
|
|
mobs:spawn({
|
|
|
|
name = "mobs_animal:bunny",
|
|
|
|
nodes = {spawn_on},
|
|
|
|
neighbors = {"group:grass"},
|
|
|
|
min_light = 14,
|
|
|
|
interval = 60,
|
|
|
|
chance = 8000,
|
|
|
|
min_height = 5,
|
|
|
|
max_height = 200,
|
|
|
|
day_toggle = true
|
|
|
|
})
|
2020-09-21 10:48:45 +02:00
|
|
|
end
|
2016-04-15 15:59:43 +02:00
|
|
|
|
2017-02-21 16:23:03 +01:00
|
|
|
|
2016-06-11 12:14:08 +02:00
|
|
|
mobs:register_egg("mobs_animal:bunny", S("Bunny"), "mobs_bunny_inv.png", 0)
|
2016-04-15 15:59:43 +02:00
|
|
|
|
2017-02-21 16:23:03 +01:00
|
|
|
|
|
|
|
mobs:alias_mob("mobs:bunny", "mobs_animal:bunny") -- compatibility
|
2018-01-26 15:29:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
-- raw rabbit
|
|
|
|
minetest.register_craftitem(":mobs:rabbit_raw", {
|
|
|
|
description = S("Raw Rabbit"),
|
|
|
|
inventory_image = "mobs_rabbit_raw.png",
|
|
|
|
on_use = minetest.item_eat(3),
|
2022-09-27 10:15:59 +02:00
|
|
|
groups = {food_meat_raw = 1, food_rabbit_raw = 1, flammable = 2}
|
2018-01-26 15:29:15 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
-- cooked rabbit
|
|
|
|
minetest.register_craftitem(":mobs:rabbit_cooked", {
|
|
|
|
description = S("Cooked Rabbit"),
|
|
|
|
inventory_image = "mobs_rabbit_cooked.png",
|
|
|
|
on_use = minetest.item_eat(5),
|
2022-09-27 10:15:59 +02:00
|
|
|
groups = {food_meat = 1, food_rabbit = 1, flammable = 2}
|
2018-01-26 15:29:15 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
type = "cooking",
|
|
|
|
output = "mobs:rabbit_cooked",
|
|
|
|
recipe = "mobs:rabbit_raw",
|
2022-09-27 10:15:59 +02:00
|
|
|
cooktime = 5
|
2018-01-26 15:29:15 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
-- rabbit hide
|
|
|
|
minetest.register_craftitem(":mobs:rabbit_hide", {
|
|
|
|
description = S("Rabbit Hide"),
|
|
|
|
inventory_image = "mobs_rabbit_hide.png",
|
2022-09-27 10:15:59 +02:00
|
|
|
groups = {flammable = 2, pelt = 1}
|
2018-01-26 15:29:15 +01:00
|
|
|
})
|
|
|
|
|
2018-02-06 21:59:40 +01:00
|
|
|
minetest.register_craft({
|
|
|
|
type = "fuel",
|
|
|
|
recipe = "mobs:rabbit_hide",
|
2022-09-27 10:15:59 +02:00
|
|
|
burntime = 2
|
2018-02-06 21:59:40 +01:00
|
|
|
})
|
|
|
|
|
2018-01-26 15:29:15 +01:00
|
|
|
minetest.register_craft({
|
|
|
|
output = "mobs:leather",
|
|
|
|
recipe = {
|
2021-04-13 22:13:35 +02:00
|
|
|
{"mobs:rabbit_hide", "mobs:rabbit_hide"},
|
|
|
|
{"mobs:rabbit_hide", "mobs:rabbit_hide"}
|
2018-01-26 15:29:15 +01:00
|
|
|
}
|
|
|
|
})
|