add function for spawning on land

This commit is contained in:
berengma 2020-08-09 18:12:02 +02:00
parent 96087b6f05
commit 451f4bca5d
8 changed files with 470 additions and 196 deletions

204
animals/snake.lua Normal file
View File

@ -0,0 +1,204 @@
local random = water_life.random
local abs = math.abs
local pi = math.pi
local floor = math.floor
local sqrt = math.sqrt
local max = math.max
local min = math.min
local pow = math.pow
local sign = math.sign
local rad = math.rad
local function snake_brain(self)
-- handling death
if self.hp <= 0 then
mobkit.clear_queue_high(self)
water_life.handle_drops(self)
mobkit.hq_die(self)
return
end
-- handling life in water and on land
if mobkit.timer(self,5) then
local land = mobkit.recall(self,"landlife")
local water = mobkit.recall(self,"waterlife")
if land then
land = math.floor(os.clock()-land)
if random(120,600) < land then
--minetest.chat_send_all("Go to water")
mobkit.clear_queue_high(self)
water_life.hq_go2water(self,15)
end
end
if water then
water = math.floor(os.clock()-water)
if random (30,120) < water then
--minetest.chat_send_all("Go to land")
mobkit.clear_queue_high(self)
water_life.hq_go2land(self,15)
end
end
--minetest.chat_send_all("Land: "..dump(land).." : Water: "..dump(water))
end
if mobkit.timer(self,1) then
if not mobkit.recall(self,"landlife") and not mobkit.recall(self,"waterlife") then
mobkit.remember(self,"waterlife",os.clock())
end
if self.isinliquid then
if mobkit.recall(self,"landlife") then
mobkit.remember(self,"waterlife",os.clock())
mobkit.forget(self,"landlife")
end
end
if self.isonground then
if mobkit.recall(self,"waterlife") then
mobkit.remember(self,"landlife",os.clock())
mobkit.forget(self,"waterlife")
end
end
local prty = mobkit.get_queue_priority(self)
if prty < 20 then
local target = mobkit.get_nearby_player(self)
local aliveinwater = target and mobkit.is_alive(target) and mobkit.is_in_deep(target)
if target and mobkit.is_alive(target) and target:get_attach() == nil and aliveinwater then
local dist = water_life.dist2tgt(self,target)
if dist < self.view_range then
end
end
if self.isinliquid then
if target and mobkit.is_alive(target) and target:get_attach() == nil and not water_life.isinliquid(target) then --.is_in_deep(target) then
local dist = water_life.dist2tgt(self,target)
if dist < 10 then
mobkit.clear_queue_high(self)
water_life.hq_go2land(self,20,target)
end
end
end
if self.isonground then
if target and mobkit.is_alive(target) then
local action = mobkit.recall(self,"warned")
local pname = target:get_player_name()
local dist = water_life.dist2tgt(self,target)
if dist > 4 and dist < self.view_range and not action then
mobkit.clear_queue_high(self)
mobkit.clear_queue_low(self)
water_life.hq_snake_warn(self,target,30,8)
elseif dist < 5 or action == pname then
mobkit.forget(self,"warned")
water_life.hq_hunt(self,31,target)
end
end
end
end
end
if mobkit.is_queue_empty_high(self) then
if self.isinliquid then water_life.hq_aqua_roam(self,10,1,"swim") end
if self.isonground then water_life.hq_slow_roam(self,10) end
end
end
minetest.register_entity("water_life:snake",{
-- common props
physical = true,
stepheight = 0.5, --EVIL!
collide_with_objects = false,
collisionbox = {-0.35, -0.01, -0.35, 0.35, 0.2, 0.35},
visual = "mesh",
mesh = "water_life_snake.b3d",
textures = {"water_life_snake.png"},
visual_size = {x = 0.05, y = 0.05},
static_save = false,
makes_footstep_sound = false,
on_step = mobkit.stepfunc, -- required
on_activate = mobkit.actfunc, -- required
get_staticdata = mobkit.statfunc,
-- api props
springiness=0,
buoyancy = 0.99, -- portion of hitbox submerged
max_speed = 7,
jump_height = 2.5, --1.26,
view_range = 7,
-- lung_capacity = 0, -- seconds
max_hp = 20,
timeout=300,
drops = {
{name = "default:diamond", chance = 5, min = 1, max = 5,},
{name = "water_life:meat_raw", chance = 2, min = 1, max = 2,},
},
attack={range=0.8,damage_groups={fleshy=7}},
animation = {
def={range={x=80,y=100},speed=20,loop=true},
stand={range={x=80,y=100},speed=20,loop=false},
walk={range={x=80,y=100},speed=20,loop=true},
swim={range={x=140,y=160},speed=20,loop=true},
warn={range={x=1000,y=1320},speed=40,loop=true},
bite={range={x=1350,y=1420},speed=20,loop=false},
sleep={range={x=1504,y=2652},speed=20,loop=false},
look={range={x=2660,y=2920},speed=20,loop=false},
},
sounds = {
warn='water_life_snake',
},
brainfunc = snake_brain,
on_punch=function(self, puncher, time_from_last_punch, tool_capabilities, dir)
if mobkit.is_alive(self) then
local hvel = vector.multiply(vector.normalize({x=dir.x,y=0,z=dir.z}),4)
self.object:set_velocity({x=hvel.x,y=2,z=hvel.z})
mobkit.hurt(self,tool_capabilities.damage_groups.fleshy or 1)
if type(puncher)=='userdata' and puncher:is_player() then -- if hit by a player
mobkit.clear_queue_high(self) -- abandon whatever they've been doing
if self.isinliquid then
water_life.hq_water_attack(self,puncher,31,4,true)
end
if self.isonground then
water_life.hq_hunt(self,31,puncher)
end
end
end
end,
})

20
api.lua
View File

@ -433,6 +433,24 @@ function water_life.radar(pos, yaw, radius, water)
end
--find a spawn position under air
function water_life.find_node_under_air(pos,radius,name)
if not pos then return nil end
if not radius then radius = 3 end
if not name then name={"group:crumbly","group:stone","group:tree"} end
local pos1 = mobkit.pos_shift(pos,{x=radius*-1,y=radius*-1,z=radius*-1})
local pos2 = mobkit.pos_shift(pos,{x=radius,y=radius,z=radius})
local spawner = minetest.find_nodes_in_area_under_air(pos1, pos2, name)
if not spawner or #spawner < 1 then
return nil
else
local rpos = spawner[random(#spawner)]
rpos = mobkit.pos_shift(rpos,{y=1})
return rpos
end
end
-- function to find liquid surface and depth at that position
function water_life.water_depth(pos,max)
@ -613,6 +631,8 @@ function water_life.get_next_waypoint(self,tpos)
table.remove(self.pos_history,2)
self.path_dir = self.path_dir*-1 -- subtle change in pathfinding
end
-- Entity definitions
-- entity for showing positions in debug

View File

@ -844,7 +844,11 @@ function water_life.hq_snake_warn(self,target,prty,duration,anim)
self.object:set_yaw(yaw)
duration = duration-self.dtime
local dist = water_life.dist2tgt(self,target)
if dist > self.view_range then return true end
if dist > self.view_range then
minetest.after(3,function()
return true
end)
end
if duration <= 0 or dist < 4 then
mobkit.remember(self,"warned",target:get_player_name())
return true

View File

@ -52,6 +52,7 @@ if not water_life.apionly then
dofile(path.."/animals/gulls.lua") -- load gulls
dofile(path.."/animals/gecko.lua") -- load tokays
dofile(path.."/animals/beaver.lua") -- load beavers
dofile(path.."/animals/snake.lua") -- load snakes
end

BIN
models/water_life_snake.b3d Normal file

Binary file not shown.

BIN
sounds/water_life_snake.ogg Normal file

Binary file not shown.

435
spawn.lua
View File

@ -1,6 +1,8 @@
local timer = 0
local landtimer = 0
local pi = math.pi
local random = water_life.random
local landinterval = 45 -- check every 45 seconds for spawnpos on land
local function getcount(name)
@ -15,236 +17,279 @@ end
local function spawnstep(dtime)
timer = timer + dtime
landtimer = landtimer + dtime
if timer > 10 then
for _,plyr in ipairs(minetest.get_connected_players()) do
local toomuch = false
if plyr and plyr:is_player() and plyr:get_pos().y > -50 and plyr:get_pos().y < 150 then -- each player gets a spawn chance every 10s on average
local pos = plyr:get_pos()
local yaw = plyr:get_look_horizontal()
local animal = water_life.count_objects(pos)
if animal.all > water_life.maxmobs then toomuch = true end
-- find a pos randomly in look direction of player
local radius = (water_life.abr * 12) -- 75% from 16 = 12 nodes
radius = random(7,radius) -- not nearer than 7 nodes in front of player
local angel = math.rad(random(75)) -- look for random angel 0 - 75 degrees
if water_life.leftorright() then yaw = yaw + angel else yaw = yaw - angel end -- add or substract to/from yaw
local pos2 = mobkit.pos_translate2d(pos,yaw,radius) -- calculate position
local depth, stype, surface = water_life.water_depth(pos2,25) -- get surface pos and water depth
local bdata = water_life_get_biome_data(pos2) -- get biome data at spaen position
local ground = {}
local dalam = depth
for _,plyr in ipairs(minetest.get_connected_players()) do
local toomuch = false
if plyr and plyr:is_player() and plyr:get_pos().y > -50 and plyr:get_pos().y < 150 then -- each player gets a spawn chance every 10s on average
local pos = plyr:get_pos()
local yaw = plyr:get_look_horizontal()
local animal = water_life.count_objects(pos)
if animal.all > water_life.maxmobs then toomuch = true end
if depth and depth > 0 then
if water_life.radar_debug then
water_life.temp_show(surface,9,5)
minetest.chat_send_all(">>> Depth ="..dump(depth).." <<< "..dump(stype))
minetest.chat_send_all(dump(bdata.name))
-- find a pos randomly in look direction of player
local radius = (water_life.abr * 12) -- 75% from 16 = 12 nodes
radius = random(7,radius) -- not nearer than 7 nodes in front of player
local angel = math.rad(random(75)) -- look for random angel 0 - 75 degrees
if water_life.leftorright() then yaw = yaw + angel else yaw = yaw - angel end -- add or substract to/from yaw
local pos2 = mobkit.pos_translate2d(pos,yaw,radius) -- calculate position
local depth, stype, surface = water_life.water_depth(pos2,25) -- get surface pos and water depth
local bdata = water_life_get_biome_data(pos2) -- get biome data at spaen position
local ground = {}
local dalam = depth
local landpos = nil
-- no need of so many postions on land
if landtimer > landinterval then
landpos = water_life.find_node_under_air(pos2)
end
pos2 = surface
end
local liquidflag = nil
if stype == "default:water_source" then
liquidflag = "sea"
elseif stype == "default:river_water_source" then
liquidflag = "river"
elseif stype == "water_life:muddy_river_water_source" then
liquidflag = "muddy"
end
if liquidflag and not toomuch and surface then
ground = mobkit.pos_shift(surface,{y=(dalam*-1)})
--snakes spawn on land, too
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
local mobname = 'water_life:croc'
local faktor = 100 - getcount(animal[mobname]) * 33
if random(100) < faktor then
local fits = false
if string.match(bdata.name,"rainforest") or string.match(bdata.name,"savanna") then fits = true end
if landpos then
local landdata = water_life_get_biome_data(landpos)
if depth < 4 and fits then --shark min water depth
local obj=minetest.add_entity(surface,mobname) -- ok spawn it already damnit
end
end
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
local mobname = "water_life:gull"
local faktor = 100 - getcount(animal[mobname]) * 20
if random(100) < faktor and liquidflag == "sea" then
if depth > 4 then
local spawn = mobkit.pos_shift(surface,{y=12})
--spawn.y = spawn.y + 12
local obj=minetest.add_entity(spawn,mobname) -- ok spawn it already damnit
local mobname = 'water_life:snake'
local faktor = 100 - getcount(animal[mobname]) * 50
if random(100) < faktor then
local fits = false
if string.match(landdata.name,"desert") or string.match(landdata.name,"savanna") then
local obj=minetest.add_entity(landpos,mobname) -- ok spawn it already damnit
end
end
end
--water spawn
if depth and depth > 0 then
if water_life.radar_debug then
water_life.temp_show(surface,9,5)
minetest.chat_send_all(">>> Depth ="..dump(depth).." <<< "..dump(stype))
minetest.chat_send_all(dump(bdata.name))
end
pos2 = surface
local mobname = 'water_life:shark'
if water_life.shark_spawn_rate >= random(1000) then
end
local liquidflag = nil
if stype == "default:water_source" then
liquidflag = "sea"
elseif stype == "default:river_water_source" then
liquidflag = "river"
local bcheck = water_life.count_objects(pos2,12)
if getcount(animal[mobname]) < water_life.maxsharks and liquidflag == "sea" and not bcheck["water_life:shark_buoy"]
and not animal["water_life:croc"] then
if depth > 4 then --shark min water depth
local obj=minetest.add_entity(mobkit.pos_shift(ground,{y=2}),mobname) -- spawn it 2 nodes above sea ground
elseif stype == "water_life:muddy_river_water_source" then
liquidflag = "muddy"
end
if liquidflag and not toomuch and surface then
ground = mobkit.pos_shift(surface,{y=(dalam*-1)})
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
local mobname = 'water_life:croc'
local faktor = 100 - getcount(animal[mobname]) * 33
if random(100) < faktor then
local fits = false
if string.match(bdata.name,"rainforest") or string.match(bdata.name,"savanna") then fits = true end
if depth < 4 and fits then --shark min water depth
local obj=minetest.add_entity(surface,mobname) -- ok spawn it already damnit
end
end
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
local mobname = 'water_life:snake'
local faktor = (100 - getcount(animal[mobname]) * 50) +25
if random(100) < faktor then
local fits = false
if string.match(bdata.name,"desert") or string.match(bdata.name,"savanna") then fits = true end
if depth < 3 and fits then --snake max water depth
local obj=minetest.add_entity(surface,mobname) -- ok spawn it already damnit
end
end
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
local mobname = "water_life:gull"
local faktor = 100 - getcount(animal[mobname]) * 20
if random(100) < faktor and liquidflag == "sea" then
if depth > 4 then
local spawn = mobkit.pos_shift(surface,{y=12})
--spawn.y = spawn.y + 12
local obj=minetest.add_entity(spawn,mobname) -- ok spawn it already damnit
end
end
end
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
mobname = "water_life:urchin"
if water_life.urchin_spawn_rate >= random(1000) then
local mobname = 'water_life:shark'
if water_life.shark_spawn_rate >= random(1000) then
local upos1 = mobkit.pos_shift(ground,{x=-5,y=-2,z=-5})
local upos2 = mobkit.pos_shift(ground,{x=5,y=2,z=5})
local coraltable = minetest.find_nodes_in_area(upos1, upos2, water_life.urchinspawn)
--local nearlife = water_life.count_objects(ground,5,"water_life:urchin")
if coraltable and #coraltable > 0 and getcount(animal[mobname]) < 15 and liquidflag == "sea" then
local coralpos = coraltable[random(#coraltable)]
coralpos.y = coralpos.y +1
local node = minetest.get_node(coralpos)
local bcheck = water_life.count_objects(pos2,12)
if getcount(animal[mobname]) < water_life.maxsharks and liquidflag == "sea" and not bcheck["water_life:shark_buoy"]
and not animal["water_life:croc"] then
if depth > 4 then --shark min water depth
local obj=minetest.add_entity(mobkit.pos_shift(ground,{y=2}),mobname) -- spawn it 2 nodes above sea ground
end
end
end
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
mobname = "water_life:urchin"
if water_life.urchin_spawn_rate >= random(1000) then
if node.name == "default:water_source" then
local obj= water_life.set_urchin(coralpos) --minetest.add_entity(coralpos,mobname)
local upos1 = mobkit.pos_shift(ground,{x=-5,y=-2,z=-5})
local upos2 = mobkit.pos_shift(ground,{x=5,y=2,z=5})
local coraltable = minetest.find_nodes_in_area(upos1, upos2, water_life.urchinspawn)
--local nearlife = water_life.count_objects(ground,5,"water_life:urchin")
if coraltable and #coraltable > 0 and getcount(animal[mobname]) < 15 and liquidflag == "sea" then
local coralpos = coraltable[random(#coraltable)]
coralpos.y = coralpos.y +1
local node = minetest.get_node(coralpos)
if node.name == "default:water_source" then
local obj= water_life.set_urchin(coralpos) --minetest.add_entity(coralpos,mobname)
end
end
end
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
mobname = "water_life:clams"
if water_life.clams_spawn_rate >= random(1000) then
local clpos1 = mobkit.pos_shift(ground,{x=-8, y=-2, z=8})
local clpos2 = mobkit.pos_shift(ground,{x=8, y=2, z=8})
local coraltable = minetest.find_nodes_in_area(clpos1, clpos2, water_life.clams_spawn)
----minetest.chat_send_all("seagrass ="..dump(#coraltable))
local nearlife = water_life.count_objects(ground,8,"water_life:clams")
if coraltable and #coraltable > 0 and getcount(animal[mobname]) < 10 and liquidflag == "sea" then
local coralpos = mobkit.pos_shift(coraltable[random(#coraltable)],{y=1})
local node = minetest.get_node(coralpos)
if node.name == "default:water_source" then
local obj= water_life.set_urchin(coralpos,"water_life:clams")
end
end
end
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
mobname = "water_life:jellyfish"
local faktor = 100 - getcount(animal[mobname]) * 20
if random(100) < faktor and liquidflag == "sea" then
local obj=minetest.add_entity(mobkit.pos_shift(ground,{y=2}),mobname)
end
mobname = "water_life:coralfish"
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
local cfpos1 = mobkit.pos_shift(ground,{x=-5,y=-2,z=-5})
local cfpos2 = mobkit.pos_shift(ground,{x=5,y=2,z=5})
local coraltable = minetest.find_nodes_in_area(cfpos1,cfpos2,water_life.urchinspawn)
--local nearlife = water_life.count_objects(ground,nil,mobname)
faktor = 100 - getcount(animal[mobname]) * 6.66
if random(100) < faktor and liquidflag == "sea" and #coraltable > 1 then
local cfish = coraltable[random(#coraltable)]
cfish.y = cfish.y +1
local maxfish = random(3,7)
for i = 1,maxfish,1 do
local obj=minetest.add_entity(cfish,mobname)
if obj then
local entity = obj:get_luaentity()
entity.base = cfish
entity.head = random(65535)
end
end
end
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
mobname = "water_life:clams"
if water_life.clams_spawn_rate >= random(1000) then
local clpos1 = mobkit.pos_shift(ground,{x=-8, y=-2, z=8})
local clpos2 = mobkit.pos_shift(ground,{x=8, y=2, z=8})
local coraltable = minetest.find_nodes_in_area(clpos1, clpos2, water_life.clams_spawn)
----minetest.chat_send_all("seagrass ="..dump(#coraltable))
local nearlife = water_life.count_objects(ground,8,"water_life:clams")
if coraltable and #coraltable > 0 and getcount(animal[mobname]) < 10 and liquidflag == "sea" then
local coralpos = mobkit.pos_shift(coraltable[random(#coraltable)],{y=1})
local node = minetest.get_node(coralpos)
if node.name == "default:water_source" then
local obj= water_life.set_urchin(coralpos,"water_life:clams")
end
end
end
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
mobname = "water_life:jellyfish"
local faktor = 100 - getcount(animal[mobname]) * 20
if random(100) < faktor and liquidflag == "sea" then
local obj=minetest.add_entity(mobkit.pos_shift(ground,{y=2}),mobname)
end
mobname = "water_life:coralfish"
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
local cfpos1 = mobkit.pos_shift(ground,{x=-5,y=-2,z=-5})
local cfpos2 = mobkit.pos_shift(ground,{x=5,y=2,z=5})
local coraltable = minetest.find_nodes_in_area(cfpos1,cfpos2,water_life.urchinspawn)
--local nearlife = water_life.count_objects(ground,nil,mobname)
faktor = 100 - getcount(animal[mobname]) * 6.66
if random(100) < faktor and liquidflag == "sea" and #coraltable > 1 then
local cfish = coraltable[random(#coraltable)]
cfish.y = cfish.y +1
local maxfish = random(3,7)
for i = 1,maxfish,1 do
end
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
mobname = "water_life:clownfish"
faktor = 100 - getcount(animal[mobname]) * 50
if random(100) < faktor and liquidflag == "sea" and #coraltable > 1 then
local cfish = coraltable[random(#coraltable)]
cfish.y = cfish.y +1
local obj=minetest.add_entity(cfish,mobname)
if obj then
local entity = obj:get_luaentity()
entity.base = cfish
entity.head = random(65535)
end
end
end
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
mobname = "water_life:clownfish"
faktor = 100 - getcount(animal[mobname]) * 50
if random(100) < faktor and liquidflag == "sea" and #coraltable > 1 then
local cfish = coraltable[random(#coraltable)]
cfish.y = cfish.y +1
local obj=minetest.add_entity(cfish,mobname)
if obj then
local entity = obj:get_luaentity()
entity.base = cfish
end
end
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
mobname = 'water_life:fish'
--local nearlife = water_life.count_objects(pos2,24,"water_life:piranha")
if water_life.fish_spawn_rate >= random(1000) and ((animal.all < (water_life.maxmobs-5)) or getcount(animal[mobname]) < 5) and (liquidflag == "river" or liquidflag == "muddy") then
local table = minetest.get_biome_data(pos)
if table and water_life.piranha_biomes[minetest.get_biome_name(table.biome)] then mobname = "water_life:piranha" end
if depth > 2 then -- min water depth for piranha and riverfish
if mobname == "water_life:fish" then
local obj=minetest.add_entity(pos2,mobname) -- ok spawn it already damnit
else
if getcount(animal[mobname]) < 10 then
for i = 1,3,1 do
local obj=minetest.add_entity(pos2,mobname) -- ok spawn it already damnit
end
end
end
end
end
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
mobname = 'water_life:whale'
if water_life.whale_spawn_rate >= random(1000) and getcount(animal[mobname]) < (water_life.maxwhales) and liquidflag == "sea" then
mobname = 'water_life:fish'
--local nearlife = water_life.count_objects(pos2,24,"water_life:piranha")
if water_life.fish_spawn_rate >= random(1000) and ((animal.all < (water_life.maxmobs-5)) or getcount(animal[mobname]) < 5) and (liquidflag == "river" or liquidflag == "muddy") then
if depth > 8 then -- min water depth for whales
local gotwhale = true
local whpos = mobkit.pos_shift(surface,{y=-3})
for i = 0,3,1 do
local whpos2 = mobkit.pos_translate2d(whpos,math.rad(i*90),30)
local under = water_life.find_collision(whpos,whpos2, false)
----minetest.chat_send_all(dump(under))
if under and under < 25 then
gotwhale = false
break
end
local table = minetest.get_biome_data(pos)
if table and water_life.piranha_biomes[minetest.get_biome_name(table.biome)] then mobname = "water_life:piranha" end
if depth > 2 then -- min water depth for piranha and riverfish
if mobname == "water_life:fish" then
local obj=minetest.add_entity(pos2,mobname) -- ok spawn it already damnit
else
if getcount(animal[mobname]) < 10 then
for i = 1,3,1 do
local obj=minetest.add_entity(pos2,mobname) -- ok spawn it already damnit
end
end
end
end
if gotwhale then local obj=minetest.add_entity(surface,mobname) end -- ok spawn it already damnit
end
--minetest.chat_send_all(dump(minetest.pos_to_string(surface)).." "..dump(minetest.pos_to_string(ground)))
mobname = 'water_life:whale'
if water_life.whale_spawn_rate >= random(1000) and getcount(animal[mobname]) < (water_life.maxwhales) and liquidflag == "sea" then
if depth > 8 then -- min water depth for whales
local gotwhale = true
local whpos = mobkit.pos_shift(surface,{y=-3})
for i = 0,3,1 do
local whpos2 = mobkit.pos_translate2d(whpos,math.rad(i*90),30)
local under = water_life.find_collision(whpos,whpos2, false)
----minetest.chat_send_all(dump(under))
if under and under < 25 then
gotwhale = false
break
end
end
if gotwhale then local obj=minetest.add_entity(surface,mobname) end -- ok spawn it already damnit
end
end
end
end
end
end
timer = 0
timer = 0
if landtimer > landinterval then landtimer = 0 end
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB