diff --git a/mods/fishing/bobber.lua b/mods/fishing/bobber.lua index 31f3e388..de168328 100644 --- a/mods/fishing/bobber.lua +++ b/mods/fishing/bobber.lua @@ -242,19 +242,23 @@ local FISHING_BOBBER_ENTITY={ if math.random(1, 4) == 1 then self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/2880*math.pi)) end + local remove_entity = true for _,player in pairs(minetest.get_connected_players()) do local s = self.object:getpos() local p = player:getpos() local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5 - if dist > self.view_range then - -- make sound and remove bobber - minetest.sound_play("fishing_bobber1", { - pos = self.object:getpos(), - gain = 0.5, - }) - self.object:remove() + if dist < self.view_range then + remove_entity = false + break end end + if remove_entity then + -- make sound and remove bobber + minetest.sound_play("fishing_bobber1", {pos = self.object:getpos(),gain = 0.5,}) + self.object:remove() + end + + if self.object:get_hp() > 310 then local find_fish = minetest.get_objects_inside_radius({x=pos.x,y=pos.y+0.5,z=pos.z}, 1) diff --git a/mods/fishing/bobber_shark.lua b/mods/fishing/bobber_shark.lua index ede4de25..75f5ff15 100644 --- a/mods/fishing/bobber_shark.lua +++ b/mods/fishing/bobber_shark.lua @@ -172,18 +172,21 @@ local FISHING_BOBBER_ENTITY_SHARK={ if math.random(1, 4) == 1 then self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/2880*math.pi)) end + local remove_entity = true for _,player in pairs(minetest.get_connected_players()) do local s = self.object:getpos() local p = player:getpos() local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5 - if dist > self.view_range then - minetest.sound_play("fishing_bobber1", { - pos = self.object:getpos(), - gain = 0.5, - }) - self.object:remove() + if dist < self.view_range then + remove_entity = false + break end - end + end + if remove_entity then + -- make sound and remove bobber + minetest.sound_play("fishing_bobber1", {pos = self.object:getpos(),gain = 0.5,}) + self.object:remove() + end local do_env_damage = function(self) self.object:set_hp(self.object:get_hp()-self.water_damage) if self.object:get_hp() == 600 then diff --git a/mods/fishing/worm.lua b/mods/fishing/worm.lua index a9e08925..2a76a2aa 100644 --- a/mods/fishing/worm.lua +++ b/mods/fishing/worm.lua @@ -63,15 +63,6 @@ minetest.register_entity("fishing:bait_worm_entity", { on_step = function(self, dtime) local pos = self.object:getpos() local n = minetest.env:get_node({x=pos.x,y=pos.y-0.3,z=pos.z}) - -- despawn when no player in range - for _,player in pairs(minetest.get_connected_players()) do - local s = self.object:getpos() - local p = player:getpos() - local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5 - if dist > self.view_range then - self.object:remove() - end - end -- move in world local look_whats_up = function(self) self.object:set_hp(self.object:get_hp()-self.damage_over_time) -- creature is getting older