From 9d6f2428714efa8990be5ae7d5296a24c0e5a9b6 Mon Sep 17 00:00:00 2001 From: ElCeejo Date: Fri, 9 Sep 2022 16:55:20 -0700 Subject: [PATCH] Fixes --- api/api.lua | 4 +--- api/behaviors.lua | 23 +++++++++++++++++++---- mobs/bat.lua | 4 ++-- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/api/api.lua b/api/api.lua index aecab96..cfae3d8 100644 --- a/api/api.lua +++ b/api/api.lua @@ -533,10 +533,8 @@ function animalia.mount(self, player, params) self.rider = nil return end - if player_api then - player_api.player_attached[player:get_player_name()] = true - end if minetest.get_modpath("player_api") then + player_api.player_attached[player:get_player_name()] = true animate_player(player, "sit", 30) end self.rider = player diff --git a/api/behaviors.lua b/api/behaviors.lua index 9242a4c..4fe488e 100644 --- a/api/behaviors.lua +++ b/api/behaviors.lua @@ -373,6 +373,14 @@ end function animalia.action_cling(self, time) local timer = time + local pos = self.object:get_pos() + if not pos then return end + pos.y = pos.y + 1 + if not creatura.get_node_def(pos).walkable then + self:forget("home_position") + self.home_position = nil + return + end local function func(_self) _self:set_gravity(0) _self:halt() @@ -645,15 +653,22 @@ creatura.register_utility("animalia:fly_to_roost", function(self) local home = self.home_position local roost = self.roost_action or creatura.action_idle local function func(_self) - local pos = self.object:get_pos() + local pos = _self.object:get_pos() if not pos then return end if not home then return true end if not _self:get_action() then if abs(pos.x - home.x) < 0.5 - and abs(pos.y - home.y) < 0.7 and abs(pos.z - home.z) < 0.5 then - roost(_self, 1, "stand") - return + local y_diff = abs(pos.y - home.y) + if y_diff < 0.7 then + roost(_self, 1, "stand") + return + end + if y_diff <= 2 + and not minetest.line_of_sight(pos, home) then + self.home_positon = nil + self:forget("home_position") + end end creatura.action_move(_self, home, 3, "animalia:fly_simple", 1, "fly") end diff --git a/mobs/bat.lua b/mobs/bat.lua index 77e54ba..3f899ba 100644 --- a/mobs/bat.lua +++ b/mobs/bat.lua @@ -69,7 +69,7 @@ creatura.register_mob("animalia:bat", { despawn_after = 2500, -- Entity Physics stepheight = 1.1, - max_fall = 100, + max_fall = 0, turn_rate = 12, -- Visuals mesh = "animalia_bat.b3d", @@ -207,7 +207,7 @@ creatura.register_mob("animalia:bat", { z = rot.z }) end - if self:timer(random(3,4)) then + if self:timer(random(3, 4)) then self:play_sound("random") if guano_accumulation and random(16) < 2