animalia/mobs/chicken.lua

144 lines
3.3 KiB
Lua
Raw Normal View History

2020-11-11 23:16:50 -08:00
-------------
-- Chicken --
-------------
2022-02-10 18:00:06 -08:00
creatura.register_mob("animalia:chicken", {
2023-03-15 14:27:40 -07:00
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_chicken.b3d",
2020-11-11 23:16:50 -08:00
female_textures = {
"animalia_chicken_1.png",
"animalia_chicken_2.png",
"animalia_chicken_3.png"
2020-11-11 23:16:50 -08:00
},
male_textures = {
"animalia_rooster_1.png",
"animalia_rooster_2.png",
"animalia_rooster_3.png"
2020-11-11 23:16:50 -08:00
},
2022-08-12 22:17:42 -07:00
child_textures = {"animalia_chicken_child.png"},
makes_footstep_sound = true,
2023-03-15 14:27:40 -07:00
-- Creatura Props
max_health = 5,
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_chicken",
gain = 0.5,
distance = 8
},
hurt = {
name = "animalia_chicken_hurt",
gain = 0.5,
distance = 8
},
death = {
name = "animalia_chicken_death",
gain = 0.5,
distance = 8
}
},
2023-03-15 14:27:40 -07:00
hitbox = {
width = 0.25,
height = 0.5
},
animations = {
stand = {range = {x = 1, y = 39}, speed = 20, frame_blend = 0.3, loop = true},
walk = {range = {x = 41, y = 59}, speed = 30, frame_blend = 0.3, loop = true},
run = {range = {x = 41, y = 59}, speed = 45, frame_blend = 0.3, loop = true},
eat = {range = {x = 61, y = 89}, speed = 45, frame_blend = 0.3, loop = true},
fall = {range = {x = 91, y = 99}, speed = 70, frame_blend = 0.3, loop = true}
},
follow = animalia.food_seeds,
drops = {
{name = "animalia:poultry_raw", min = 1, max = 3, chance = 1},
2022-02-10 18:00:06 -08:00
{name = "animalia:feather", min = 1, max = 3, chance = 2}
},
2023-03-15 14:27:40 -07:00
2023-12-28 21:28:05 -08:00
-- Behavior Parameters
is_herding_mob = true,
2023-03-15 14:27:40 -07:00
-- Animalia Props
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = true,
head_data = {
2022-08-12 22:17:42 -07:00
offset = {x = 0, y = 0.45, z = 0},
pitch_correction = 40,
pivot_h = 0.25,
pivot_v = 0.55
2020-11-11 23:16:50 -08:00
},
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 = {
2024-01-04 11:15:02 -08:00
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.tamed_follow_owner,
animalia.mob_ai.basic_breed,
animalia.mob_ai.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:chicken_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)
2020-11-11 23:16:50 -08:00
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)
2022-02-10 18:00:06 -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-11 23:16:50 -08:00
})
2023-03-15 14:27:40 -07:00
creatura.register_spawn_item("animalia:chicken", {
col1 = "c6c6c6",
col2 = "d22222"
})