fix strange spawn bug
This commit is contained in:
parent
3bacb70d19
commit
662caac9ae
3
api.lua
3
api.lua
@ -496,6 +496,9 @@ function water_life.get_next_waypoint_fast(self,tpos,nogopos)
|
||||
local dir=vector.direction(pos,tpos)
|
||||
local neighbor = mobkit.dir2neighbor(dir)
|
||||
local height, pos2, liquidflag = mobkit.is_neighbor_node_reachable(self,neighbor)
|
||||
local heightr = nil
|
||||
local heightl = nil
|
||||
local liq = nil
|
||||
|
||||
if height then
|
||||
local fast = false
|
||||
|
2
init.lua
2
init.lua
@ -1,5 +1,5 @@
|
||||
water_life = {}
|
||||
water_life.version = "200620"
|
||||
water_life.version = "210620"
|
||||
water_life.shark_food = {}
|
||||
water_life.petz = minetest.get_modpath("petz")
|
||||
water_life.mobsredo = minetest.get_modpath("mobs")
|
||||
|
36
spawn.lua
36
spawn.lua
@ -38,6 +38,11 @@ local function spawnstep(dtime)
|
||||
local pos2 = mobkit.pos_translate2d(pos,yaw,radius) -- calculate position
|
||||
local depth = 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 savepos = pos2
|
||||
local dalam = depth.depth
|
||||
local ground = {}
|
||||
ground = depth.surface
|
||||
|
||||
|
||||
if depth.depth > 0 then
|
||||
if water_life.radar_debug then
|
||||
@ -45,7 +50,8 @@ local function spawnstep(dtime)
|
||||
minetest.chat_send_all(">>> Depth ="..dump(depth.depth).." <<< "..dump(depth.type))
|
||||
minetest.chat_send_all(dump(bdata.name))
|
||||
end
|
||||
pos2 = depth.surface
|
||||
pos2 = depth.surface
|
||||
ground.y = ground.y -dalam + 1
|
||||
end
|
||||
|
||||
local liquidflag = nil
|
||||
@ -62,7 +68,7 @@ local function spawnstep(dtime)
|
||||
end
|
||||
|
||||
if liquidflag and not toomuch then
|
||||
|
||||
--minetest.chat_send_all(dump(depth.surface))
|
||||
local mobname = 'water_life:croc'
|
||||
local faktor = 100 - getcount(animal[mobname]) * 33
|
||||
if random(100) < faktor then
|
||||
@ -75,7 +81,7 @@ local function spawnstep(dtime)
|
||||
|
||||
|
||||
end
|
||||
|
||||
--minetest.chat_send_all(dump(depth.surface))
|
||||
local mobname = 'water_life:shark'
|
||||
if water_life.shark_spawn_rate >= random(1000) then
|
||||
|
||||
@ -89,11 +95,10 @@ local function spawnstep(dtime)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--minetest.chat_send_all(dump(depth.surface).." "..dump(pos2))
|
||||
mobname = "water_life:urchin"
|
||||
if water_life.urchin_spawn_rate >= random(1000) then
|
||||
local ground = depth.surface
|
||||
ground.y = ground.y - depth.depth
|
||||
|
||||
local coraltable = minetest.find_nodes_in_area({x=ground.x-5, y=ground.y-2, z=ground.z-5}, {x=ground.x+5, y=ground.y+2, z=ground.z+5}, 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
|
||||
@ -107,10 +112,11 @@ local function spawnstep(dtime)
|
||||
end
|
||||
end
|
||||
|
||||
depth = water_life.water_depth(savepos,25) -- do not ask why, but this is a must. Maybe I will discover later. Leave it and all .y val will be wrong
|
||||
--minetest.chat_send_all(dump(depth.surface).." "..dump(pos2))
|
||||
mobname = "water_life:clams"
|
||||
if water_life.clams_spawn_rate >= random(1000) then
|
||||
local ground = depth.surface
|
||||
ground.y = ground.y - depth.depth
|
||||
|
||||
local coraltable = minetest.find_nodes_in_area({x=ground.x-8, y=ground.y-2, z=ground.z-8}, {x=ground.x+8, y=ground.y+2, z=ground.z+8}, water_life.clams_spawn)
|
||||
--local nearlife = water_life.count_objects(ground,8,"water_life:clams")
|
||||
if coraltable and #coraltable > 0 and getcount(animal[mobname]) < 15 and liquidflag == "sea" then
|
||||
@ -124,10 +130,10 @@ local function spawnstep(dtime)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--minetest.chat_send_all(dump(depth.surface).." "..dump(pos2))
|
||||
mobname = "water_life:jellyfish"
|
||||
|
||||
local ground = depth.surface
|
||||
|
||||
local faktor = 100 - getcount(animal[mobname]) * 20
|
||||
if random(100) < faktor and liquidflag == "sea" then
|
||||
local obj=minetest.add_entity(ground,mobname)
|
||||
@ -136,8 +142,8 @@ local function spawnstep(dtime)
|
||||
|
||||
mobname = "water_life:coralfish"
|
||||
|
||||
--minetest.chat_send_all(dump(depth.surface).." "..dump(pos2))
|
||||
|
||||
ground.y = ground.y - depth.depth
|
||||
local coraltable = minetest.find_nodes_in_area({x=ground.x-5, y=ground.y-2, z=ground.z-5}, {x=ground.x+5, y=ground.y+2, z=ground.z+5}, water_life.urchinspawn)
|
||||
--local nearlife = water_life.count_objects(ground,nil,mobname)
|
||||
faktor = 100 - getcount(animal[mobname]) * 6.66
|
||||
@ -156,7 +162,7 @@ local function spawnstep(dtime)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--minetest.chat_send_all(dump(depth.surface).." "..dump(pos2))
|
||||
mobname = "water_life:clownfish"
|
||||
|
||||
faktor = 100 - getcount(animal[mobname]) * 50
|
||||
@ -170,7 +176,7 @@ local function spawnstep(dtime)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--minetest.chat_send_all(dump(depth.surface).." "..dump(pos2))
|
||||
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
|
||||
@ -192,6 +198,8 @@ local function spawnstep(dtime)
|
||||
|
||||
|
||||
end
|
||||
|
||||
--minetest.chat_send_all(dump(depth.surface).." "..dump(pos2))
|
||||
|
||||
if water_life.whale_spawn_rate >= random(1000) and getcount(animal[mobname]) < (water_life.maxwhales) and liquidflag == "sea" then
|
||||
mobname = 'water_life:whale'
|
||||
@ -203,7 +211,7 @@ local function spawnstep(dtime)
|
||||
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))
|
||||
----minetest.chat_send_all(dump(under))
|
||||
if under and under < 25 then
|
||||
gotwhale = false
|
||||
break
|
||||
|
Loading…
x
Reference in New Issue
Block a user