tweak moskito spread
This commit is contained in:
parent
04e3f9260e
commit
9adc613d3b
@ -129,9 +129,9 @@ end
|
||||
|
||||
minetest.register_entity("water_life:croc",{
|
||||
physical = true,
|
||||
stepheight = 0.5,
|
||||
stepheight = 1.1,
|
||||
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",
|
||||
mesh = "water_life_crocodile.b3d",
|
||||
textures = {"water_life_crocodile.png"},
|
||||
|
@ -9,6 +9,15 @@ local pow = math.pow
|
||||
local sign = math.sign
|
||||
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)
|
||||
if not player 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_maxpos and
|
||||
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.get_node_timer(spos):start(random(mmintime, mmaxtime))
|
||||
local pmeta = minetest.get_meta(spos)
|
||||
|
@ -592,13 +592,19 @@ function water_life.hq_slow_roam(self,prty,idle)
|
||||
|
||||
local func=function(self)
|
||||
if self.isinliquid then return true end
|
||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
||||
local pos = mobkit.get_stand_pos(self)
|
||||
if mobkit.is_queue_empty_low(self) then
|
||||
local neighbor = random(8)
|
||||
local height, tpos, liquidflag = mobkit.is_neighbor_node_reachable(
|
||||
self,neighbor)
|
||||
if height and not liquidflag then
|
||||
mobkit.dumbstep(self,height,tpos,1,idle)
|
||||
if tpos then
|
||||
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
|
||||
@ -610,13 +616,16 @@ function water_life.hq_go2water(self,prty,speed)
|
||||
local pos = mobkit.get_stand_pos(self)
|
||||
local target = minetest.find_node_near(pos, self.view_range, {"group:water"})
|
||||
if not speed then speed = 0.1 end
|
||||
if not target then
|
||||
return true
|
||||
end
|
||||
|
||||
local func=function(self)
|
||||
if self.isinliquid or not target then return true end
|
||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
||||
pos = mobkit.get_stand_pos(self)
|
||||
local height = target.y - pos.y
|
||||
mobkit.dumbstep(self,height,target,speed,0)
|
||||
if self.isinliquid then
|
||||
return true
|
||||
end
|
||||
if mobkit.is_queue_empty_low(self) or self.isonground then
|
||||
mobkit.dumbstep(self,0,target,speed,0)
|
||||
end
|
||||
end
|
||||
mobkit.queue_high(self,func,prty)
|
||||
|
Loading…
x
Reference in New Issue
Block a user