clean spawning, fix hq_slow_roam
This commit is contained in:
parent
6bb163e4e7
commit
63406d4447
@ -77,7 +77,10 @@ minetest.register_node("water_life:moskito", {
|
||||
local level = minetest.get_node_light(pos)
|
||||
local mmeta = minetest.get_meta(pos)
|
||||
local killer = math.floor(os.time()) - mmeta:get_int("mlife")
|
||||
local mmintime = water_life.moskitolifetime / 3
|
||||
local mmaxtime = water_life.moskitolifetime
|
||||
if (ptime and ptime < 3 and level and level > 7) or killer > water_life.moskitolifetime then
|
||||
mmeta:set_int("mlife", 0)
|
||||
minetest.set_node(pos, {name = "air"})
|
||||
else
|
||||
local bdata = water_life_get_biome_data(pos)
|
||||
@ -86,11 +89,12 @@ minetest.register_node("water_life:moskito", {
|
||||
if nodes and #nodes > 0 then
|
||||
local spos = nodes[random(#nodes)]
|
||||
local rnd = random (200)
|
||||
--minetest.chat_send_all("Temp = "..bdata.temp.." Humidity = "..bdata.humid.." <<< "..dump(rnd))
|
||||
if bdata.temp > 20 and spos and spos.y > -10 and spos.y < 100 and not
|
||||
water_life.ihateinsects then
|
||||
if rnd < bdata.humid then
|
||||
minetest.set_node(spos, {name = "water_life:moskito"})
|
||||
minetest.get_node_timer(spos):start(random(15,45))
|
||||
minetest.get_node_timer(spos):start(random(mmintime, mmaxtime))
|
||||
local pmeta = minetest.get_meta(spos)
|
||||
pmeta:set_int("mlife",math.floor(os.time()))
|
||||
end
|
||||
|
6
api.lua
6
api.lua
@ -75,8 +75,12 @@ function water_life.get_game_time()
|
||||
if hour > 20 or hour < 5 then return 4 end
|
||||
end
|
||||
|
||||
|
||||
--compatibility function
|
||||
function water_life_get_biome_data(pos)
|
||||
return water_life.get_biome_data(pos)
|
||||
end
|
||||
|
||||
function water_life.get_biome_data(pos)
|
||||
if not pos then return nil end
|
||||
local table = minetest.get_biome_data(pos)
|
||||
if not table then return nil end
|
||||
|
@ -598,7 +598,7 @@ function water_life.hq_slow_roam(self,prty,idle)
|
||||
local height, tpos, liquidflag = mobkit.is_neighbor_node_reachable(
|
||||
self,neighbor)
|
||||
if height and not liquidflag then
|
||||
water_life.dumbstep(self,height,tpos,1,idle)
|
||||
mobkit.dumbstep(self,height,tpos,1,idle)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -616,7 +616,7 @@ function water_life.hq_go2water(self,prty,speed)
|
||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
||||
pos = mobkit.get_stand_pos(self)
|
||||
local height = target.y - pos.y
|
||||
water_life.dumbstep(self,height,target,speed,0)
|
||||
mobkit.dumbstep(self,height,target,speed,0)
|
||||
end
|
||||
end
|
||||
mobkit.queue_high(self,func,prty)
|
||||
|
4
init.lua
4
init.lua
@ -17,7 +17,7 @@ water_life.mobsredo = minetest.get_modpath("mobs")
|
||||
water_life.farming = minetest.get_modpath("farming")
|
||||
water_life.swampz = minetest.get_modpath("swaz")
|
||||
water_life.abr = tonumber(minetest.settings:get('active_block_range')) or 2
|
||||
water_life.abo = tonumber(minetest.settings:get('active_object_send_range_blocks')) or 3
|
||||
water_life.abo = tonumber(minetest.settings:get('active_object_send_range_blocks')) or 2
|
||||
water_life.avg_dtime = 0
|
||||
water_life.max_dtime = 0
|
||||
|
||||
@ -36,6 +36,8 @@ water_life.soundadjust = tonumber(minetest.settings:get("water_life_soundadjust"
|
||||
|
||||
-- lifetime in sec. ( <15 = no reproducing)
|
||||
water_life.moskitolifetime = tonumber(minetest.settings:get("water_life_moskitolifetime")) or 120
|
||||
water_life.moskito_minpos = tonumber(minetest.settings:get("water_life_moskito_minpos")) or -10
|
||||
water_life.moskito_maxpos = tonumber(minetest.settings:get("water_life_moskito_maxpos")) or 100
|
||||
water_life.radar_debug = minetest.settings:get_bool("water_life_radar_debug") or false
|
||||
water_life.muddy_water = minetest.settings:get_bool("water_life_muddy_water") or false
|
||||
|
||||
|
@ -43,6 +43,13 @@ water_life_maxsharks (Max possible sharks in aktive area) int 5
|
||||
# max lifetime of a moskito (default 120 = 2 minutes)
|
||||
water_life_moskitolifetime (Max lifetime of a moskito in seconds) int 120
|
||||
|
||||
# -
|
||||
# moskitos do not spawn in heights below this value (default -10)
|
||||
water_life_water_life_moskito_minpos (no moskitos in heights smaller than this) int -10
|
||||
|
||||
# -
|
||||
# moskitos do not spawn in heights larger than this value (default 100)
|
||||
water_life_water_life_moskito_maxpos (no moskitos in heights larger than this) int 100
|
||||
|
||||
# -
|
||||
# total max number of animals in an aktive area
|
||||
|
22
spawn.lua
22
spawn.lua
@ -7,8 +7,8 @@ local dtmax=0
|
||||
local dttimer = 10
|
||||
local pi = math.pi
|
||||
local random = water_life.random
|
||||
local landinterval = 120
|
||||
local waterinterval = 30
|
||||
local landinterval = 20
|
||||
local waterinterval = 10
|
||||
|
||||
|
||||
local function getcount(name)
|
||||
@ -97,7 +97,7 @@ local function spawnstep(dtime)
|
||||
local angel = math.rad(random(75))
|
||||
local pos2 = mobkit.pos_translate2d(pos,yaw,radius)
|
||||
local depth, stype, surface = water_life.water_depth(pos2,25)
|
||||
local bdata = water_life_get_biome_data(pos2)
|
||||
local bdata = water_life.get_biome_data(pos2)
|
||||
local ground = {}
|
||||
local dalam = depth
|
||||
local landpos = nil
|
||||
@ -128,27 +128,28 @@ local function spawnstep(dtime)
|
||||
moskitopos = water_life.find_node_under_air(pos2,5,
|
||||
{"group:water","group:flora","group:crumbly"})
|
||||
end
|
||||
landtimer = 0
|
||||
end
|
||||
-- mosqitos only bettween -10 < y < 100
|
||||
if moskitopos and not water_life.dangerous
|
||||
and moskitopos.y > -10 and moskitopos.y < 100 then
|
||||
and moskitopos.y > water_life.moskito_minpos and moskitopos.y < water_life.moskito_maxpos then
|
||||
local mlevel = minetest.get_node_light(moskitopos)
|
||||
local ptime = water_life.get_game_time()
|
||||
local mdata = water_life_get_biome_data(moskitopos)
|
||||
local mdata = water_life.get_biome_data(moskitopos)
|
||||
local mmintime = water_life.moskitolifetime / 3
|
||||
local mmaxtime = water_life.moskitolifetime
|
||||
if ((ptime and ptime > 2) or mlevel < 8)
|
||||
and mdata.temp > 20 then
|
||||
minetest.set_node(moskitopos,
|
||||
{name = "water_life:moskito"})
|
||||
minetest.get_node_timer(moskitopos):start(
|
||||
random(15,45))
|
||||
random(mmintime, mmaxtime))
|
||||
local pmeta = minetest.get_meta(moskitopos)
|
||||
pmeta:set_int("mlife",math.floor(os.time()))
|
||||
end
|
||||
end
|
||||
|
||||
if landpos then
|
||||
local landdata = water_life_get_biome_data(landpos)
|
||||
local landdata = water_life.get_biome_data(landpos)
|
||||
if not water_life.dangerous then
|
||||
mobname = 'water_life:snake'
|
||||
local faktor = (100 - getcount(animal[mobname]) * 50)
|
||||
@ -175,7 +176,7 @@ local function spawnstep(dtime)
|
||||
end
|
||||
|
||||
if geckopos then
|
||||
local landdata = water_life_get_biome_data(geckopos)
|
||||
local landdata = water_life.get_biome_data(geckopos)
|
||||
mobname = 'water_life:gecko'
|
||||
local faktor = (100 - getcount(animal[mobname]) * 50)
|
||||
if random(100) < faktor then
|
||||
@ -414,6 +415,9 @@ local function spawnstep(dtime)
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
if landtimer > landinterval then
|
||||
landtimer = 0
|
||||
end
|
||||
timer = 0
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user