add more maskito adjustments

This commit is contained in:
Gundul 2023-04-23 17:21:46 +02:00
parent 63406d4447
commit f9f28cb97f
4 changed files with 42 additions and 21 deletions

View File

@ -79,19 +79,23 @@ minetest.register_node("water_life:moskito", {
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"})
if (ptime and ptime < 3 and level and
level > water_life.moskito_lightmax) 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)
local nodes = minetest.find_nodes_in_area({x=pos.x-4, y=pos.y-2, z=pos.z-4},
{x=pos.x+4, y=pos.y+1, z=pos.z+4}, {"air"})
if nodes and #nodes > 0 then
local spos = nodes[random(#nodes)]
local rnd = random (200)
local rnd = random (water_life.moskito_humidity)
--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 bdata.temp > water_life.moskito_mintemp and spos and
spos.y > water_life.moskito_minpos and
spos.y < water_life.moskito_maxpos 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(mmintime, mmaxtime))

View File

@ -38,6 +38,10 @@ water_life.soundadjust = tonumber(minetest.settings:get("water_life_soundadjust"
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.moskito_lightmax = tonumber(minetest.settings:get("water_life_moskito_lightmax")) or 8
water_life.moskito_humidity = tonumber(minetest.settings:get("water_life_moskito_humidity")) or 200
water_life.moskito_mintemp = tonumber(minetest.settings:get("water_life_moskito_mintemp")) or 20
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

View File

@ -51,6 +51,18 @@ water_life_water_life_moskito_minpos (no moskitos in heights smaller than this)
# 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
# -
# moskitos will die in areas with lightlevel above this (default 8)
water_life_water_life_moskito_lightmax (die if brighter than this) int 8
# -
# moskitos need at least this temperature to show up (default 20)
water_life_water_life_moskito_mintemp (noshow if colder than this) int 20
# -
# moskitos love humid biomes, small values will make them love dry biomes as well (default 200)
water_life_water_life_moskito_humidity (the smaller the more likely) int 200
# -
# total max number of animals in an aktive area
# other mods might not care about this setting

View File

@ -131,21 +131,22 @@ local function spawnstep(dtime)
end
-- mosqitos only bettween -10 < y < 100
if moskitopos and not water_life.dangerous
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 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(mmintime, mmaxtime))
local pmeta = minetest.get_meta(moskitopos)
pmeta:set_int("mlife",math.floor(os.time()))
end
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 mmintime = water_life.moskitolifetime / 3
local mmaxtime = water_life.moskitolifetime
if ((ptime and ptime > 2) or mlevel < water_life.moskito_lightmax)
and mdata.temp > water_life.moskito_mintemp then
minetest.set_node(moskitopos,
{name = "water_life:moskito"})
minetest.get_node_timer(moskitopos):start(
random(mmintime, mmaxtime))
local pmeta = minetest.get_meta(moskitopos)
pmeta:set_int("mlife",math.floor(os.time()))
end
end
if landpos then