mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-19 16:50:31 +01:00
fix bobber and worms removed when on_place
fix wrong condition cause remove bobber and worms when on_place if several player connected
This commit is contained in:
parent
c5ad8e22a1
commit
2cb1438e99
@ -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
|
||||
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,
|
||||
})
|
||||
minetest.sound_play("fishing_bobber1", {pos = self.object:getpos(),gain = 0.5,})
|
||||
self.object:remove()
|
||||
end
|
||||
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)
|
||||
|
@ -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
|
||||
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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user