tweak moskito spread

This commit is contained in:
Gundul 2023-05-20 18:22:32 +02:00
parent 04e3f9260e
commit 9adc613d3b
3 changed files with 30 additions and 12 deletions

View File

@ -129,9 +129,9 @@ end
minetest.register_entity("water_life:croc",{ minetest.register_entity("water_life:croc",{
physical = true, physical = true,
stepheight = 0.5, stepheight = 1.1,
collide_with_objects = true, collide_with_objects = true,
collisionbox = {-0.5, 0, -0.5, 0.5, 0.3, 0.5}, collisionbox = {-0.49, -0.01, -0.49, 0.49, 0.3, 0.49},
visual = "mesh", visual = "mesh",
mesh = "water_life_crocodile.b3d", mesh = "water_life_crocodile.b3d",
textures = {"water_life_crocodile.png"}, textures = {"water_life_crocodile.png"},

View File

@ -9,6 +9,15 @@ local pow = math.pow
local sign = math.sign local sign = math.sign
local rad = math.rad local rad = math.rad
local function MoskitosAround(pos)
if not pos then
return 0
end
local nodes = minetest.find_nodes_in_area({x=pos.x-1, y=pos.y-1, z=pos.z-1},
{x=pos.x+1, y=pos.y+1, z=pos.z+1}, {"water_life:moskito"})
return #nodes
end
minetest.register_on_player_hpchange(function(player, hp_change, reason) minetest.register_on_player_hpchange(function(player, hp_change, reason)
if not player then return hp_change end if not player then return hp_change end
if hp_change > 0 then return hp_change end if hp_change > 0 then return hp_change end
@ -96,7 +105,7 @@ minetest.register_node("water_life:moskito", {
spos.y > water_life.moskito_minpos and spos.y > water_life.moskito_minpos and
spos.y < water_life.moskito_maxpos and spos.y < water_life.moskito_maxpos and
not water_life.ihateinsects then not water_life.ihateinsects then
if rnd < bdata.humid then if rnd < bdata.humid and MoskitosAround(spos) < 3 then
minetest.set_node(spos, {name = "water_life:moskito"}) minetest.set_node(spos, {name = "water_life:moskito"})
minetest.get_node_timer(spos):start(random(mmintime, mmaxtime)) minetest.get_node_timer(spos):start(random(mmintime, mmaxtime))
local pmeta = minetest.get_meta(spos) local pmeta = minetest.get_meta(spos)

View File

@ -592,13 +592,19 @@ function water_life.hq_slow_roam(self,prty,idle)
local func=function(self) local func=function(self)
if self.isinliquid then return true end if self.isinliquid then return true end
if mobkit.is_queue_empty_low(self) and self.isonground then if mobkit.is_queue_empty_low(self) then
local pos = mobkit.get_stand_pos(self)
local neighbor = random(8) local neighbor = random(8)
local height, tpos, liquidflag = mobkit.is_neighbor_node_reachable( local height, tpos, liquidflag = mobkit.is_neighbor_node_reachable(
self,neighbor) self,neighbor)
if height and not liquidflag then if tpos then
mobkit.dumbstep(self,height,tpos,1,idle) minetest.chat_send_all(minetest.pos_to_string(tpos))
else
minetest.chat_send_all("NIL")
end
if height and tpos then
mobkit.dumbstep(self,height,tpos,0.1)--,idle)
else
return true
end end
end end
end end
@ -610,13 +616,16 @@ function water_life.hq_go2water(self,prty,speed)
local pos = mobkit.get_stand_pos(self) local pos = mobkit.get_stand_pos(self)
local target = minetest.find_node_near(pos, self.view_range, {"group:water"}) local target = minetest.find_node_near(pos, self.view_range, {"group:water"})
if not speed then speed = 0.1 end if not speed then speed = 0.1 end
if not target then
return true
end
local func=function(self) local func=function(self)
if self.isinliquid or not target then return true end if self.isinliquid then
if mobkit.is_queue_empty_low(self) and self.isonground then return true
pos = mobkit.get_stand_pos(self) end
local height = target.y - pos.y if mobkit.is_queue_empty_low(self) or self.isonground then
mobkit.dumbstep(self,height,target,speed,0) mobkit.dumbstep(self,0,target,speed,0)
end end
end end
mobkit.queue_high(self,func,prty) mobkit.queue_high(self,func,prty)