mirror of
https://github.com/ElCeejo/creatura.git
synced 2025-03-21 15:21:24 +00:00
Fixes
This commit is contained in:
parent
4f3f596fbd
commit
bade5f4ac9
3 changed files with 27 additions and 23 deletions
|
@ -294,6 +294,7 @@ local function get_collision_single(pos, water)
|
||||||
end
|
end
|
||||||
|
|
||||||
function creatura.get_context_steering(self, goal, range, water)
|
function creatura.get_context_steering(self, goal, range, water)
|
||||||
|
if not goal then return end
|
||||||
local pos, yaw = self.object:get_pos(), self.object:get_yaw()
|
local pos, yaw = self.object:get_pos(), self.object:get_yaw()
|
||||||
if not pos or not yaw then return end
|
if not pos or not yaw then return end
|
||||||
range = range or 8; if range < 2 then range = 2 end
|
range = range or 8; if range < 2 then range = 2 end
|
||||||
|
@ -578,7 +579,7 @@ creatura.register_movement_method("creatura:context_based_steering", function(se
|
||||||
self:set_gravity(-9.8)
|
self:set_gravity(-9.8)
|
||||||
local function func(_self, goal, speed_factor)
|
local function func(_self, goal, speed_factor)
|
||||||
local pos = _self.object:get_pos()
|
local pos = _self.object:get_pos()
|
||||||
if not pos then return end
|
if not pos or not goal then return end
|
||||||
if vec_dist(pos, goal) < clamp(self.width, 0.5, 1) then
|
if vec_dist(pos, goal) < clamp(self.width, 0.5, 1) then
|
||||||
_self:halt()
|
_self:halt()
|
||||||
return true
|
return true
|
||||||
|
|
32
mob_meta.lua
32
mob_meta.lua
|
@ -391,13 +391,13 @@ function mob:get_wander_pos_3d(min_range, max_range, dir, vert_bias)
|
||||||
return pos2
|
return pos2
|
||||||
end
|
end
|
||||||
|
|
||||||
function mob:is_pos_safe(pos)
|
function mob:is_pos_safe(pos, ignore_liquid)
|
||||||
if not pos then return end
|
if not pos then return end
|
||||||
local node = minetest.get_node(pos)
|
local n_def = creatura.get_node_def(pos)
|
||||||
if not node then return false end
|
if minetest.get_item_group(n_def.name, "igniter") > 0
|
||||||
if minetest.get_item_group(node.name, "igniter") > 0
|
or (not ignore_liquid
|
||||||
or creatura.get_node_def(node.name).drawtype == "liquid"
|
and (n_def.drawtype == "liquid"
|
||||||
or creatura.get_node_def(vec_raise(pos, -1)).drawtype == "liquid" then return false end
|
or creatura.get_node_def(vec_raise(pos, -1)).drawtype == "liquid")) then return false end
|
||||||
local fall_safe = false
|
local fall_safe = false
|
||||||
if self.max_fall ~= 0 then
|
if self.max_fall ~= 0 then
|
||||||
for i = 1, self.max_fall or 3 do
|
for i = 1, self.max_fall or 3 do
|
||||||
|
@ -1169,16 +1169,16 @@ function mob:_vitals()
|
||||||
if max_fall > 0
|
if max_fall > 0
|
||||||
and not in_liquid then
|
and not in_liquid then
|
||||||
local fall_start = self._fall_start or (not on_ground and pos.y)
|
local fall_start = self._fall_start or (not on_ground and pos.y)
|
||||||
if fall_start then
|
if fall_start
|
||||||
if on_ground then
|
and on_ground then
|
||||||
damage = fall_start - pos.y
|
damage = fall_start - pos.y
|
||||||
if damage < max_fall then
|
if damage < max_fall then
|
||||||
damage = 0
|
damage = 0
|
||||||
else
|
fall_start = nil
|
||||||
local resist = self.fall_resistance or 0
|
else
|
||||||
damage = damage - damage * resist
|
local resist = self.fall_resistance or 0
|
||||||
fall_start = nil
|
damage = damage - damage * resist
|
||||||
end
|
fall_start = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self._fall_start = fall_start
|
self._fall_start = fall_start
|
||||||
|
|
15
spawning.lua
15
spawning.lua
|
@ -19,8 +19,10 @@ end)
|
||||||
-- Math --
|
-- Math --
|
||||||
|
|
||||||
local abs = math.abs
|
local abs = math.abs
|
||||||
|
local ceil = math.ceil
|
||||||
local pi = math.pi
|
local pi = math.pi
|
||||||
local random = math.random
|
local random = math.random
|
||||||
|
local min, max = math.min, math.max
|
||||||
|
|
||||||
local function vec_raise(v, n)
|
local function vec_raise(v, n)
|
||||||
return {x = v.x, y = v.y + n, z = v.z}
|
return {x = v.x, y = v.y + n, z = v.z}
|
||||||
|
@ -237,7 +239,7 @@ local function execute_spawns(player)
|
||||||
spawn_on)
|
spawn_on)
|
||||||
if spawn_y_array[1] then
|
if spawn_y_array[1] then
|
||||||
local spawn_pos = spawn_y_array[1]
|
local spawn_pos = spawn_y_array[1]
|
||||||
local dist = vector.distance(pos, spawn_pos)
|
local dist = vec_dist(pos, spawn_pos)
|
||||||
if dist < min_spawn_radius or dist > max_spawn_radius then
|
if dist < min_spawn_radius or dist > max_spawn_radius then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -273,13 +275,14 @@ local function execute_spawns(player)
|
||||||
|
|
||||||
local mob_def = minetest.registered_entities[mob]
|
local mob_def = minetest.registered_entities[mob]
|
||||||
local mob_width = mob_def.collisionbox[4]
|
local mob_width = mob_def.collisionbox[4]
|
||||||
local mob_height = math.max(0, mob_def.collisionbox[5] - mob_def.collisionbox[2])
|
local mob_height = max(0, mob_def.collisionbox[5] - mob_def.collisionbox[2])
|
||||||
|
|
||||||
if not creatura.is_pos_moveable(spawn_pos, mob_width, mob_height) then
|
if not creatura.is_pos_moveable(spawn_pos, mob_width, mob_height) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local group_size = random(spawn.min_group or 1, spawn.max_group or 1)
|
local group_size = random(spawn.min_group or 1, spawn.max_group or 1)
|
||||||
|
group_size = min(spawn.spawn_cap - object_count, group_size)
|
||||||
|
|
||||||
if spawn.spawn_cluster then
|
if spawn.spawn_cluster then
|
||||||
minetest.add_node(spawn_pos, {name = "creatura:spawn_node"})
|
minetest.add_node(spawn_pos, {name = "creatura:spawn_node"})
|
||||||
|
@ -496,8 +499,8 @@ local min_abm_dist = tonumber(minetest.settings:get("creatura_min_abm_dist")) or
|
||||||
|
|
||||||
local function can_spawn(pos, width, height)
|
local function can_spawn(pos, width, height)
|
||||||
local pos2
|
local pos2
|
||||||
local w_iter = width / math.ceil(width)
|
local w_iter = width / ceil(width)
|
||||||
for y = 0, height, height / math.ceil(height) do
|
for y = 0, height, height / ceil(height) do
|
||||||
for z = -width, width, w_iter do
|
for z = -width, width, w_iter do
|
||||||
for x = -width, width, w_iter do
|
for x = -width, width, w_iter do
|
||||||
pos2 = {x = pos.x + x, y = pos.y + y, z = pos.z + z}
|
pos2 = {x = pos.x + x, y = pos.y + y, z = pos.z + z}
|
||||||
|
@ -621,11 +624,11 @@ function creatura.register_abm_spawn(mob, def)
|
||||||
|
|
||||||
if group_size > 1 then
|
if group_size > 1 then
|
||||||
for _ = 1, group_size do
|
for _ = 1, group_size do
|
||||||
local offset = math.ceil(mob_width)
|
local offset = ceil(mob_width)
|
||||||
local spawn_pos = creatura.get_ground_level({
|
local spawn_pos = creatura.get_ground_level({
|
||||||
x = pos.x + random(-offset, offset),
|
x = pos.x + random(-offset, offset),
|
||||||
y = pos.y,
|
y = pos.y,
|
||||||
z = pos.x + random(-offset, offset),
|
z = pos.z + random(-offset, offset)
|
||||||
}, 3)
|
}, 3)
|
||||||
if not can_spawn(spawn_pos, mob_width, mob_height) then
|
if not can_spawn(spawn_pos, mob_width, mob_height) then
|
||||||
spawn_pos = pos
|
spawn_pos = pos
|
||||||
|
|
Loading…
Add table
Reference in a new issue