mirror of
https://github.com/ElCeejo/creatura.git
synced 2025-03-21 15:21:24 +00:00
Fix for NaN crash
This commit is contained in:
parent
bade5f4ac9
commit
2422efc3c3
2 changed files with 13 additions and 12 deletions
|
@ -331,7 +331,7 @@ function creatura.get_context_steering(self, goal, range, water)
|
||||||
score = interest - danger
|
score = interest - danger
|
||||||
output_dir = vector.add(output_dir, vector.multiply(dir, score))
|
output_dir = vector.add(output_dir, vector.multiply(dir, score))
|
||||||
end
|
end
|
||||||
return output_dir
|
return vec_normal(output_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------
|
-------------
|
||||||
|
|
23
mob_meta.lua
23
mob_meta.lua
|
@ -148,6 +148,7 @@ local function turn(self, tyaw, rate)
|
||||||
if not yaw then return end
|
if not yaw then return end
|
||||||
local step = math.min(self.dtime * rate, abs(diff(yaw, tyaw)) % (pi2))
|
local step = math.min(self.dtime * rate, abs(diff(yaw, tyaw)) % (pi2))
|
||||||
rot.y = interp_rad(yaw, tyaw, step)
|
rot.y = interp_rad(yaw, tyaw, step)
|
||||||
|
if rot.y ~= rot.y then return end
|
||||||
self.object:set_rotation(rot)
|
self.object:set_rotation(rot)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -205,7 +206,7 @@ function mob:do_velocity()
|
||||||
local data = self._movement_data or {}
|
local data = self._movement_data or {}
|
||||||
local vel = self.object:get_velocity()
|
local vel = self.object:get_velocity()
|
||||||
local yaw = self.object:get_yaw()
|
local yaw = self.object:get_yaw()
|
||||||
if not yaw then return end
|
if not vel or not yaw then return end
|
||||||
local horz_vel = data.horz_vel --or (data.gravity >= 0 and 0)
|
local horz_vel = data.horz_vel --or (data.gravity >= 0 and 0)
|
||||||
local vert_vel = data.vert_vel --or (data.gravity >= 0 and 0)
|
local vert_vel = data.vert_vel --or (data.gravity >= 0 and 0)
|
||||||
vel.x = (horz_vel and (sin(yaw) * -horz_vel)) or vel.x
|
vel.x = (horz_vel and (sin(yaw) * -horz_vel)) or vel.x
|
||||||
|
@ -1169,16 +1170,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
|
if fall_start then
|
||||||
and on_ground then
|
if 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
|
||||||
fall_start = nil
|
else
|
||||||
else
|
local resist = self.fall_resistance or 0
|
||||||
local resist = self.fall_resistance or 0
|
damage = damage - damage * resist
|
||||||
damage = damage - damage * resist
|
fall_start = nil
|
||||||
fall_start = nil
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self._fall_start = fall_start
|
self._fall_start = fall_start
|
||||||
|
|
Loading…
Add table
Reference in a new issue