animalia/mobs/reindeer.lua

142 lines
3.1 KiB
Lua
Raw Normal View History

2022-02-10 18:00:06 -08:00
--------------
-- Reindeer --
--------------
local follows = {}
minetest.register_on_mods_loaded(function()
for name in pairs(minetest.registered_items) do
if (name:match(":wheat")
2022-02-10 18:00:06 -08:00
or minetest.get_item_group(name, "food_wheat") > 0)
and not name:find("seed") then
table.insert(follows, name)
end
end
2022-02-10 18:00:06 -08:00
end)
2021-12-24 11:47:35 -08:00
2022-02-10 18:00:06 -08:00
local random = math.random
2021-12-24 11:47:35 -08:00
2022-02-10 18:00:06 -08:00
creatura.register_mob("animalia:reindeer", {
-- Stats
max_health = 20,
armor_groups = {fleshy = 125},
damage = 0,
speed = 3,
2022-02-10 18:00:06 -08:00
boid_seperation = 1,
tracking_range = 16,
despawn_after = 1500,
2022-02-10 18:00:06 -08:00
-- Entity Physics
stepheight = 1.1,
turn_rate = 4,
-- Visuals
mesh = "animalia_reindeer.b3d",
2022-02-10 18:00:06 -08:00
hitbox = {
width = 0.45,
height = 0.9
2021-12-24 11:47:35 -08:00
},
visual_size = {x = 10, y = 10},
2022-02-10 18:00:06 -08:00
textures = {"animalia_reindeer.png"},
child_textures = {"animalia_reindeer_calf.png"},
2021-12-24 11:47:35 -08:00
animations = {
stand = {range = {x = 1, y = 60}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 70, y = 110}, speed = 40, frame_blend = 0.3, loop = true},
run = {range = {x = 70, y = 110}, speed = 50, frame_blend = 0.3, loop = true},
},
-- Misc
makes_footstep_sound = true,
2022-10-17 17:23:26 -07:00
flee_puncher = true,
2022-02-10 18:00:06 -08:00
catch_with_net = true,
catch_with_lasso = true,
drops = {
{name = "animalia:venison_raw", min = 1, max = 3, chance = 1},
2022-02-10 18:00:06 -08:00
{name = "animalia:leather", min = 1, max = 3, chance = 2}
},
follow = follows,
2022-02-10 18:00:06 -08:00
consumable_nodes = {
{
name = "default:dirt_with_grass",
replacement = "default:dirt"
},
{
name = "default:dry_dirt_with_dry_grass",
replacement = "default:dry_dirt"
}
2021-12-24 11:47:35 -08:00
},
head_data = {
offset = {x = 0, y = 0.7, z = 0},
pitch_correction = -45,
pivot_h = 1,
pivot_v = 1
},
move_chance = 2,
idle_time = 1,
-- Function
2022-02-10 18:00:06 -08:00
utility_stack = {
2022-08-12 22:17:42 -07:00
{
utility = "animalia:wander_group",
step_delay = 0.25,
2022-02-10 18:00:06 -08:00
get_score = function(self)
2022-08-12 22:17:42 -07:00
return 0.1, {self}
2022-02-10 18:00:06 -08:00
end
},
2022-08-12 22:17:42 -07:00
{
utility = "animalia:eat_turf",
step_delay = 0.25,
2022-02-10 18:00:06 -08:00
get_score = function(self)
2022-08-12 22:17:42 -07:00
if random(64) < 2 then
return 0.2, {self}
2022-02-10 18:00:06 -08:00
end
return 0
end
},
2022-08-12 22:17:42 -07:00
{
2022-02-10 18:00:06 -08:00
utility = "animalia:swim_to_land",
2022-08-12 22:17:42 -07:00
step_delay = 0.25,
2022-02-10 18:00:06 -08:00
get_score = function(self)
if self.in_liquid then
2022-08-12 22:17:42 -07:00
return 0.3, {self}
2022-02-10 18:00:06 -08:00
end
return 0
end
},
2022-10-17 17:23:26 -07:00
animalia.global_utils.basic_follow,
2022-08-12 22:17:42 -07:00
{
utility = "animalia:breed",
step_delay = 0.25,
2022-02-10 18:00:06 -08:00
get_score = function(self)
2022-02-22 20:27:38 -08:00
if self.breeding
and animalia.get_nearby_mate(self, self.name) then
2022-08-12 22:17:42 -07:00
return 0.5, {self}
end
return 0
end
},
2022-10-17 17:23:26 -07:00
animalia.global_utils.basic_flee
2022-02-10 18:00:06 -08:00
},
activate_func = function(self)
2022-02-10 18:00:06 -08:00
animalia.initialize_api(self)
animalia.initialize_lasso(self)
end,
step_func = function(self)
2022-02-10 18:00:06 -08:00
animalia.step_timers(self)
animalia.head_tracking(self, 0.75, 0.75)
animalia.do_growth(self, 60)
animalia.update_lasso_effects(self)
end,
death_func = function(self)
2022-02-10 18:00:06 -08:00
if self:get_utility() ~= "animalia:die" then
self:initiate_utility("animalia:die", self)
end
end,
2021-12-24 11:47:35 -08:00
on_rightclick = function(self, clicker)
2022-02-10 18:00:06 -08:00
if animalia.feed(self, clicker, false, true) then
return
end
if animalia.set_nametag(self, clicker) then
return
end
2021-12-24 11:47:35 -08:00
end,
2022-10-17 17:23:26 -07:00
on_punch = animalia.punch
2021-12-24 11:47:35 -08:00
})
2022-10-17 17:23:26 -07:00
creatura.register_spawn_egg("animalia:reindeer", "413022" ,"d5c0a3")