Fixes and Bird Eggs

This commit is contained in:
ElCeejo 2022-11-05 21:07:25 -07:00
parent e4b8396be9
commit 21ad5faf7d
10 changed files with 54 additions and 26 deletions

View File

@ -455,7 +455,7 @@ function animalia.add_trust(self, player, amount)
self:memorize("trust", self.trust)
end
function animalia.feed(self, clicker, breed, tame)
function animalia.feed(self, clicker, tame, breed)
local yaw = self.object:get_yaw()
local pos = self.object:get_pos()
if not pos then return end
@ -507,10 +507,13 @@ function animalia.feed(self, clicker, breed, tame)
texture = "creatura_particle_green.png"
})
end
if breed
and self.owner
and self.owner == name then
-- TODO: Breeding
if breed then
if self.breeding then return false end
if self.breeding_cooldown <= 0 then
self.breeding = true
self.breeding_cooldown = 60
animalia.particle_spawner(pos, "heart.png", "float", minp, maxp)
end
end
self._despawn = self:memorize("_despawn", false)
self.despawn_after = self:memorize("despawn_after", false)

View File

@ -496,7 +496,7 @@ function animalia.action_move_boid(self, pos2, timeout, method, speed_factor, an
local safe = true
local max_fall = (_self.max_fall or 0) > 0 and _self.max_fall
if max_fall then
safe = _self:is_pos_safe(goal)
safe = _self:is_pos_safe(pos2)
end
-- Boid calculation
local boid_dir, boids = move_data.boid_dir or creatura.get_boid_dir(self)
@ -743,22 +743,25 @@ creatura.register_utility("animalia:wander_group", function(self)
local idle_duration = self.idle_time or 3
local center = self.object:get_pos()
if not center then return end
local group_tick = 500
local cntr_timer = 30
local move = self.wander_action or animalia.action_move_boid
local function func(_self)
group_tick = group_tick - 1
if group_tick <= 0 then
local pos = _self.object:get_pos()
if not pos then return end
local pos = _self.object:get_pos()
if not pos then return end
cntr_timer = cntr_timer - _self.dtime
if cntr_timer <= 0 then
local grp_pos = get_group_positions(_self)
center = animalia.get_average_pos(grp_pos) or pos
group_tick = 500
cntr_timer = 30
end
if not _self:get_action() then
local pos2 = _self:get_wander_pos(2, 3)
if random(move_chance) < 2
and vec_dist(pos2, center) < _self.tracking_range * 0.5 then
move(_self, pos2, 2, "creatura:obstacle_avoidance", 0.5, "walk", true)
if random(move_chance) < 2 then
local move_dir
if vec_dist(pos, center) > _self.tracking_range * 0.25 then
move_dir = vec_dir(pos, center)
end
local pos2 = _self:get_wander_pos(2, 3, move_dir)
move(_self, pos2, 2)
else
creatura.action_idle(_self, random(idle_duration))
end

View File

@ -37,6 +37,8 @@ minetest.register_entity("animalia:lasso_entity", {
if type(parent) == "string" then
parent = minetest.get_player_by_name(parent)
local tgt_pos = parent:get_pos()
tgt_pos.y = tgt_pos.y + 1
point_to.y = point_to.y + pointed_ent.height * 0.5
local dist = vec_dist(pos, tgt_pos)
if dist > 0.5 then
self.object:set_pos(tgt_pos)

View File

@ -168,10 +168,11 @@ creatura.register_abm_spawn("animalia:bird", {
min_light = 0,
min_height = 1,
max_height = 1024,
min_group = 12,
max_group = 16,
min_group = 6,
max_group = 12,
spawn_cap = 12,
nodes = {"group:leaves"}
nodes = {"group:leaves"},
neighbors = {"group:leaves"}
})
creatura.register_on_spawn("animalia:bird", function(self, pos)

View File

@ -30,17 +30,17 @@ local function register_egg(name, def)
minetest.register_entity(def.mob .. "_egg_entity", {
hp_max = 1,
physical = true,
collisionbox = {0, 0, 0, 0, 0, 0},
collisionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
visual = "sprite",
visual_size = {x = 0.5, y = 0.5},
textures = {"animalia_egg.png"},
textures = {def.inventory_image .. ".png"},
initial_sprite_basepos = {x = 0, y = 0},
is_visible = true,
on_step = function(self, _, moveresult)
local pos = self.object:get_pos()
if not pos then return end
if moveresult.collides then
for _, collision in ipairs(moveresult.collision) do
for _, collision in ipairs(moveresult.collisions) do
if collision.type == "nodes" then
minetest.add_particlespawner({
amount = 6,
@ -61,7 +61,7 @@ local function register_egg(name, def)
break
end
end
if random(1, 3) < 2 then
if random(3) < 2 then
local object = minetest.add_entity(pos, def.mob)
local ent = object and object:get_luaentity()
ent.growth_scale = 0.7
@ -313,6 +313,12 @@ register_egg("animalia:turkey_egg", {
mob = "animalia:turkey"
})
register_egg("animalia:song_bird_egg", {
description = "Song Bird Egg",
inventory_image = "animalia_song_bird_egg",
mob = "animalia:bird"
})
----------
-- Misc --
----------
@ -434,7 +440,7 @@ minetest.register_node("animalia:nest_song_bird", {
sunlight_propagates = true,
walkable = false,
stack_max = 1,
groups = {snappy = 3, flammable = 3},
groups = {snappy = 3, flammable = 3, falling_node = 1},
selection_box = {
type = "fixed",
fixed = {-5 / 16, -0.5, -5 / 16, 5 / 16, -0.31, 5 / 16},
@ -443,7 +449,21 @@ minetest.register_node("animalia:nest_song_bird", {
type = "fixed",
fixed = {-5 / 16, -0.5, -5 / 16, 5 / 16, -0.31, 5 / 16},
},
drops = "default:stick"
drop = {
items = {
{
items = {"animalia:song_bird_egg"},
rarity = 2,
},
{
items = {"animalia:song_bird_egg 2"},
rarity = 4,
},
{
items = {"default:stick"},
}
}
},
})
-----------

View File

@ -168,7 +168,6 @@ creatura.register_mob("animalia:horse", {
animalia.initialize_api(ent)
animalia.protect_from_despawn(ent)
end,
wander_action = animalia.action_move_flock,
utility_stack = {
{
utility = "animalia:wander_group",

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB