mirror of
https://github.com/ElCeejo/animalia.git
synced 2025-04-30 13:31:39 -04:00
Fix sheared Sheep texture, Improve behaviors, Improve mapgen spawning
This commit is contained in:
parent
31c0232697
commit
fc6af4b455
5 changed files with 76 additions and 56 deletions
|
@ -712,24 +712,11 @@ end)
|
|||
creatura.register_utility("animalia:boid_wander", function(self, group)
|
||||
local idle_time = 3
|
||||
local move_probability = 5
|
||||
local group_tick = 0
|
||||
local group_tick = 1
|
||||
local function func(self)
|
||||
local pos = self.object:get_pos()
|
||||
local goal
|
||||
if group
|
||||
and self:timer(3) then
|
||||
local range = self.tracking_range * 0.5
|
||||
local group_positions = animalia.get_group_positions(self.name, pos, range + 1)
|
||||
if #group_positions > 2 then
|
||||
local center = animalia.get_average_pos(group_positions)
|
||||
if center
|
||||
and vec_dist(pos, center) > range then
|
||||
goal = center
|
||||
end
|
||||
end
|
||||
group_tick = 2
|
||||
end
|
||||
if not self:get_action() then
|
||||
local goal
|
||||
local move = random(move_probability) < 2
|
||||
if self.lasso_pos
|
||||
and vec_dist(pos, self.lasso_pos) > 10 then
|
||||
|
@ -737,14 +724,34 @@ creatura.register_utility("animalia:boid_wander", function(self, group)
|
|||
end
|
||||
if not goal
|
||||
and move then
|
||||
goal = self:get_wander_pos(1, 3)
|
||||
goal = self:get_wander_pos(1, 2)
|
||||
end
|
||||
if move
|
||||
and goal then
|
||||
if group
|
||||
and goal
|
||||
and group_tick > 3 then
|
||||
local range = self.tracking_range * 0.5
|
||||
local group_positions = animalia.get_group_positions(self.name, pos, range + 1)
|
||||
if #group_positions > 2 then
|
||||
local center = animalia.get_average_pos(group_positions)
|
||||
if center
|
||||
and vec_dist(pos, center) > range * 0.33
|
||||
or vec_dist(goal, center) > range * 0.33 then
|
||||
goal = center
|
||||
far_from_group = true
|
||||
else
|
||||
far_from_group = false
|
||||
end
|
||||
end
|
||||
group_tick = 0
|
||||
end
|
||||
if (move
|
||||
and goal)
|
||||
or far_from_group then
|
||||
animalia.action_boid_walk(self, goal, 6, "creatura:neighbors", 0.35)
|
||||
else
|
||||
creatura.action_idle(self, idle_time)
|
||||
end
|
||||
group_tick = group_tick + 1
|
||||
end
|
||||
end
|
||||
self:set_utility(func)
|
||||
|
@ -1632,7 +1639,7 @@ creatura.register_utility("animalia:mount", function(self, player)
|
|||
speed_factor = speed_factor * 0.5
|
||||
end
|
||||
local total_speed = vector.length(vel)
|
||||
if total_speed > 0.1 then
|
||||
if total_speed > 0.2 then
|
||||
anim = "walk"
|
||||
if control.aux1 then
|
||||
anim = "run"
|
||||
|
|
|
@ -214,40 +214,58 @@ local chunk_spawn_add_int = tonumber(minetest.settings:get("chunk_spawn_add_int"
|
|||
|
||||
animalia.spawn_queue = {}
|
||||
|
||||
local c_air = minetest.get_content_id("air")
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp)
|
||||
if not mapgen_spawning then return end
|
||||
animalia.chunks_since_last_spawn = animalia.chunks_since_last_spawn + 1
|
||||
local heightmap = minetest.get_mapgen_object("heightmap")
|
||||
if not heightmap then return end
|
||||
local pos = {
|
||||
x = minp.x + math.floor((maxp.x - minp.x) / 2),
|
||||
y = minp.y,
|
||||
z = minp.z + math.floor((maxp.z - minp.z) / 2)
|
||||
}
|
||||
local hm_i = (pos.x - minp.x + 1) + (((pos.z - minp.z)) * 80)
|
||||
pos.y = heightmap[hm_i]
|
||||
if animalia.chunks_since_last_spawn > chunk_spawn_add_int
|
||||
and pos.y > 0 then
|
||||
local heightmap = minetest.get_mapgen_object("heightmap")
|
||||
if not heightmap then return end
|
||||
local center = {
|
||||
x = math.floor(minp.x + ((maxp.x - minp.x) * 0.5) + 0.5),
|
||||
y = minp.y,
|
||||
z = math.floor(minp.z + ((maxp.z - minp.z) * 0.5) + 0.5),
|
||||
}
|
||||
local light = minetest.get_natural_light(center)
|
||||
while center.y < maxp.y
|
||||
and light < 10 do
|
||||
center.y = center.y + 1
|
||||
light = minetest.get_natural_light(center)
|
||||
end
|
||||
local spawnable_mobs = get_spawnable_mobs(center)
|
||||
if spawnable_mobs then
|
||||
local mob = spawnable_mobs[random(#spawnable_mobs)]
|
||||
table.insert(animalia.spawn_queue, {pos = center, mob = mob, group = random(3, 4)})
|
||||
table.insert(animalia.spawn_points, center)
|
||||
local max_y = maxp.y
|
||||
local min_x = minp.x
|
||||
local max_x = maxp.x
|
||||
local min_z = minp.z
|
||||
local max_z = maxp.z
|
||||
|
||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||
local data = vm:get_data()
|
||||
|
||||
local spawn_added = false
|
||||
|
||||
for xcen = min_x + 8, max_x - 7, 8 do
|
||||
if spawn_added then break end
|
||||
for zcen = min_z + 8, max_z - 7, 8 do
|
||||
local surface = false -- y of above surface node
|
||||
for y = max_y, 2, -1 do
|
||||
local vi = area:index(xcen, y, zcen)
|
||||
local c_node = data[vi]
|
||||
local c_name = minetest.get_name_from_content_id(c_node)
|
||||
local c_def = minetest.registered_nodes[c_name]
|
||||
if y == max_y and c_node ~= c_air then -- if top node solid
|
||||
break
|
||||
elseif minetest.get_item_group(c_name, "leaves") > 0 then
|
||||
break
|
||||
elseif c_def.walkable then
|
||||
surface = y + 1
|
||||
break
|
||||
end
|
||||
end
|
||||
if animalia.chunks_since_last_spawn > chunk_spawn_add_int
|
||||
and surface then
|
||||
local center = {
|
||||
x = xcen,
|
||||
y = surface,
|
||||
z = zcen,
|
||||
}
|
||||
local spawnable_mobs = get_spawnable_mobs(center)
|
||||
if spawnable_mobs then
|
||||
local mob = spawnable_mobs[random(#spawnable_mobs)]
|
||||
table.insert(animalia.spawn_queue, {pos = center, mob = mob, group = random(3, 4)})
|
||||
table.insert(animalia.spawn_points, center)
|
||||
end
|
||||
spawn_added = true
|
||||
animalia.chunks_since_last_spawn = 0
|
||||
end
|
||||
end
|
||||
animalia.chunks_since_last_spawn = 0
|
||||
end
|
||||
end)
|
||||
|
||||
|
|
|
@ -141,7 +141,8 @@ creatura.register_mob("animalia:cow", {
|
|||
[5] = {
|
||||
utility = "animalia:mammal_breed",
|
||||
get_score = function(self)
|
||||
if self.breeding then
|
||||
if self.breeding
|
||||
and animalia.get_nearby_mate(self, self.name) then
|
||||
return 0.9, {self}
|
||||
end
|
||||
return 0
|
||||
|
|
|
@ -162,11 +162,6 @@ creatura.register_mob("animalia:horse", {
|
|||
and type(self.lasso_origin) == "userdata" then
|
||||
return 0.8, {self, self.lasso_origin, true}
|
||||
end
|
||||
local player = creatura.get_nearby_player(self)
|
||||
if player
|
||||
and self:follow_wielded_item(player) then
|
||||
return 0.8, {self, player}
|
||||
end
|
||||
return 0
|
||||
end
|
||||
},
|
||||
|
|
|
@ -68,7 +68,6 @@ creatura.register_mob("animalia:sheep", {
|
|||
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},
|
||||
},
|
||||
use_texture_alpha = true,
|
||||
-- Misc
|
||||
catch_with_net = true,
|
||||
catch_with_lasso = true,
|
||||
|
|
Loading…
Add table
Reference in a new issue