animalia/mobs/turkey.lua

158 lines
3.5 KiB
Lua
Raw Normal View History

2020-11-25 00:27:54 -08:00
------------
-- Turkey --
------------
2022-02-10 18:00:06 -08:00
creatura.register_mob("animalia:turkey", {
2023-03-15 14:27:40 -07:00
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_turkey.b3d",
female_textures = {"animalia_turkey_hen.png"},
male_textures = {"animalia_turkey_tom.png"},
child_textures = {"animalia_turkey_chick.png"},
makes_footstep_sound = true,
2023-03-15 14:27:40 -07:00
-- Creatura Props
max_health = 8,
armor_groups = {fleshy = 100},
damage = 0,
speed = 2,
tracking_range = 8,
max_boids = 3,
despawn_after = 500,
max_fall = 0,
stepheight = 1.1,
sounds = {
random = {
2023-03-15 14:27:40 -07:00
name = "animalia_turkey",
gain = 0.5,
distance = 8
},
hurt = {
name = "animalia_turkey_hurt",
2023-03-15 14:27:40 -07:00
gain = 0.5,
distance = 8
},
death = {
name = "animalia_turkey_death",
2023-03-15 14:27:40 -07:00
gain = 0.5,
distance = 8
}
},
2023-03-15 14:27:40 -07:00
hitbox = {
width = 0.3,
height = 0.6
},
animations = {
stand = {range = {x = 0, y = 0}, speed = 1, frame_blend = 0.3, loop = true},
walk = {range = {x = 10, y = 30}, speed = 30, frame_blend = 0.3, loop = true},
run = {range = {x = 40, y = 60}, speed = 45, frame_blend = 0.3, loop = true},
fall = {range = {x = 70, y = 90}, speed = 30, frame_blend = 0.3, loop = true},
},
follow = animalia.food_seeds,
drops = {
2023-03-15 14:27:40 -07:00
{name = "animalia:poultry_raw", min = 1, max = 4, chance = 1},
{name = "animalia:feather", min = 1, max = 3, chance = 2}
},
2023-03-15 14:27:40 -07:00
-- Animalia Props
group_wander = true,
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = true,
head_data = {
offset = {x = 0, y = 0.15, z = 0},
pitch_correction = 45,
pivot_h = 0.45,
pivot_v = 0.65
},
move_chance = 2,
idle_time = 1,
2023-03-15 14:27:40 -07:00
-- Functions
2022-02-10 18:00:06 -08:00
utility_stack = {
2022-08-12 22:17:42 -07:00
{
2023-03-15 14:27:40 -07:00
utility = "animalia:wander",
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
{
2023-03-15 14:27:40 -07:00
utility = "animalia:swim_to_land",
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.5, {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",
2023-03-15 14:27:40 -07:00
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.4, {self}
2022-02-10 18:00:06 -08:00
end
return 0
end
2022-08-12 22:17:42 -07:00
},
2022-10-17 17:23:26 -07:00
animalia.global_utils.basic_flee
2022-02-10 18:00:06 -08:00
},
2023-03-15 14:27:40 -07:00
add_child = function(self)
local pos = self.object:get_pos()
if not pos then return end
animalia.particle_spawner(pos, "animalia_egg_fragment.png", "splash", pos, pos)
local object = minetest.add_entity(pos, self.name)
local ent = object:get_luaentity()
ent.growth_scale = 0.7
animalia.initialize_api(ent)
animalia.protect_from_despawn(ent)
end,
activate_func = function(self)
2022-02-10 18:00:06 -08:00
animalia.initialize_api(self)
animalia.initialize_lasso(self)
end,
2023-03-15 14:27:40 -07:00
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)
animalia.random_sound(self)
2022-08-12 22:17:42 -07:00
if self.fall_start then
self:set_gravity(-4.9)
self:animate("fall")
end
2022-08-31 15:02:00 -07:00
if (self.growth_scale or 1) > 0.8
and self.gender == "female"
and self:timer(60) then
animalia.random_drop_item(self, "animalia:turkey_egg", 10)
2022-08-13 23:15:43 -07:00
end
end,
2023-03-15 14:27:40 -07:00
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,
2023-03-15 14:27:40 -07:00
2022-02-10 18:00:06 -08:00
on_rightclick = function(self, clicker)
if animalia.feed(self, clicker, false, true) then
return
end
2023-03-15 14:27:40 -07:00
animalia.set_nametag(self, clicker)
2020-11-25 00:27:54 -08:00
end,
2023-03-15 14:27:40 -07:00
2022-10-17 17:23:26 -07:00
on_punch = animalia.punch
2020-11-25 00:27:54 -08:00
})
2023-03-15 14:27:40 -07:00
creatura.register_spawn_item("animalia:turkey", {
col1 = "352b22",
col2 = "2f2721"
})