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)
|
creatura.register_utility("animalia:boid_wander", function(self, group)
|
||||||
local idle_time = 3
|
local idle_time = 3
|
||||||
local move_probability = 5
|
local move_probability = 5
|
||||||
local group_tick = 0
|
local group_tick = 1
|
||||||
local function func(self)
|
local function func(self)
|
||||||
local pos = self.object:get_pos()
|
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
|
if not self:get_action() then
|
||||||
|
local goal
|
||||||
local move = random(move_probability) < 2
|
local move = random(move_probability) < 2
|
||||||
if self.lasso_pos
|
if self.lasso_pos
|
||||||
and vec_dist(pos, self.lasso_pos) > 10 then
|
and vec_dist(pos, self.lasso_pos) > 10 then
|
||||||
|
@ -737,14 +724,34 @@ creatura.register_utility("animalia:boid_wander", function(self, group)
|
||||||
end
|
end
|
||||||
if not goal
|
if not goal
|
||||||
and move then
|
and move then
|
||||||
goal = self:get_wander_pos(1, 3)
|
goal = self:get_wander_pos(1, 2)
|
||||||
end
|
end
|
||||||
if move
|
if group
|
||||||
and goal then
|
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)
|
animalia.action_boid_walk(self, goal, 6, "creatura:neighbors", 0.35)
|
||||||
else
|
else
|
||||||
creatura.action_idle(self, idle_time)
|
creatura.action_idle(self, idle_time)
|
||||||
end
|
end
|
||||||
|
group_tick = group_tick + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:set_utility(func)
|
self:set_utility(func)
|
||||||
|
@ -1632,7 +1639,7 @@ creatura.register_utility("animalia:mount", function(self, player)
|
||||||
speed_factor = speed_factor * 0.5
|
speed_factor = speed_factor * 0.5
|
||||||
end
|
end
|
||||||
local total_speed = vector.length(vel)
|
local total_speed = vector.length(vel)
|
||||||
if total_speed > 0.1 then
|
if total_speed > 0.2 then
|
||||||
anim = "walk"
|
anim = "walk"
|
||||||
if control.aux1 then
|
if control.aux1 then
|
||||||
anim = "run"
|
anim = "run"
|
||||||
|
|
|
@ -214,40 +214,58 @@ local chunk_spawn_add_int = tonumber(minetest.settings:get("chunk_spawn_add_int"
|
||||||
|
|
||||||
animalia.spawn_queue = {}
|
animalia.spawn_queue = {}
|
||||||
|
|
||||||
|
local c_air = minetest.get_content_id("air")
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp, maxp)
|
minetest.register_on_generated(function(minp, maxp)
|
||||||
if not mapgen_spawning then return end
|
if not mapgen_spawning then return end
|
||||||
animalia.chunks_since_last_spawn = animalia.chunks_since_last_spawn + 1
|
animalia.chunks_since_last_spawn = animalia.chunks_since_last_spawn + 1
|
||||||
local heightmap = minetest.get_mapgen_object("heightmap")
|
local max_y = maxp.y
|
||||||
if not heightmap then return end
|
local min_x = minp.x
|
||||||
local pos = {
|
local max_x = maxp.x
|
||||||
x = minp.x + math.floor((maxp.x - minp.x) / 2),
|
local min_z = minp.z
|
||||||
y = minp.y,
|
local max_z = maxp.z
|
||||||
z = minp.z + math.floor((maxp.z - minp.z) / 2)
|
|
||||||
}
|
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||||
local hm_i = (pos.x - minp.x + 1) + (((pos.z - minp.z)) * 80)
|
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||||
pos.y = heightmap[hm_i]
|
local data = vm:get_data()
|
||||||
if animalia.chunks_since_last_spawn > chunk_spawn_add_int
|
|
||||||
and pos.y > 0 then
|
local spawn_added = false
|
||||||
local heightmap = minetest.get_mapgen_object("heightmap")
|
|
||||||
if not heightmap then return end
|
for xcen = min_x + 8, max_x - 7, 8 do
|
||||||
local center = {
|
if spawn_added then break end
|
||||||
x = math.floor(minp.x + ((maxp.x - minp.x) * 0.5) + 0.5),
|
for zcen = min_z + 8, max_z - 7, 8 do
|
||||||
y = minp.y,
|
local surface = false -- y of above surface node
|
||||||
z = math.floor(minp.z + ((maxp.z - minp.z) * 0.5) + 0.5),
|
for y = max_y, 2, -1 do
|
||||||
}
|
local vi = area:index(xcen, y, zcen)
|
||||||
local light = minetest.get_natural_light(center)
|
local c_node = data[vi]
|
||||||
while center.y < maxp.y
|
local c_name = minetest.get_name_from_content_id(c_node)
|
||||||
and light < 10 do
|
local c_def = minetest.registered_nodes[c_name]
|
||||||
center.y = center.y + 1
|
if y == max_y and c_node ~= c_air then -- if top node solid
|
||||||
light = minetest.get_natural_light(center)
|
break
|
||||||
end
|
elseif minetest.get_item_group(c_name, "leaves") > 0 then
|
||||||
local spawnable_mobs = get_spawnable_mobs(center)
|
break
|
||||||
if spawnable_mobs then
|
elseif c_def.walkable then
|
||||||
local mob = spawnable_mobs[random(#spawnable_mobs)]
|
surface = y + 1
|
||||||
table.insert(animalia.spawn_queue, {pos = center, mob = mob, group = random(3, 4)})
|
break
|
||||||
table.insert(animalia.spawn_points, center)
|
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
|
end
|
||||||
animalia.chunks_since_last_spawn = 0
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,8 @@ creatura.register_mob("animalia:cow", {
|
||||||
[5] = {
|
[5] = {
|
||||||
utility = "animalia:mammal_breed",
|
utility = "animalia:mammal_breed",
|
||||||
get_score = function(self)
|
get_score = function(self)
|
||||||
if self.breeding then
|
if self.breeding
|
||||||
|
and animalia.get_nearby_mate(self, self.name) then
|
||||||
return 0.9, {self}
|
return 0.9, {self}
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -162,11 +162,6 @@ creatura.register_mob("animalia:horse", {
|
||||||
and type(self.lasso_origin) == "userdata" then
|
and type(self.lasso_origin) == "userdata" then
|
||||||
return 0.8, {self, self.lasso_origin, true}
|
return 0.8, {self, self.lasso_origin, true}
|
||||||
end
|
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
|
return 0
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
|
@ -68,7 +68,6 @@ creatura.register_mob("animalia:sheep", {
|
||||||
walk = {range = {x = 70, y = 110}, speed = 40, 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},
|
run = {range = {x = 70, y = 110}, speed = 50, frame_blend = 0.3, loop = true},
|
||||||
},
|
},
|
||||||
use_texture_alpha = true,
|
|
||||||
-- Misc
|
-- Misc
|
||||||
catch_with_net = true,
|
catch_with_net = true,
|
||||||
catch_with_lasso = true,
|
catch_with_lasso = true,
|
||||||
|
|
Loading…
Add table
Reference in a new issue