Merge pull request #72 from berengma/dev

better support for islands - better spawning
This commit is contained in:
Gundul 2021-02-07 16:28:55 +01:00 committed by GitHub
commit 6b4ad15f4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 60 additions and 4 deletions

View File

@ -49,6 +49,7 @@ local function croc_brain(self)
end
if mobkit.timer(self,1) then
local prty = mobkit.get_queue_priority(self)
if not mobkit.recall(self,"landlife") and not mobkit.recall(self,"waterlife") then
mobkit.remember(self,"waterlife",os.time())
@ -68,7 +69,7 @@ local function croc_brain(self)
end
end
local prty = mobkit.get_queue_priority(self)
if prty < 20 then
local target = mobkit.get_nearby_player(self)

12
api.lua
View File

@ -98,6 +98,18 @@ function water_life_get_biome_data(pos)
return biome
end
-- get list of biome names
function water_life.get_biomes()
local biomes = {}
for k,v in pairs(minetest.registered_biomes) do
table.insert(biomes, k)
end
if #biomes > 0 then return biomes else return nil end
end
-- returns closest enemy or player, if player is true enemies must be in entity definition: predators = {[name1]=1,[name2]=1,.....}

View File

@ -73,6 +73,26 @@ minetest.register_chatcommand("wl_kill", {
end
})
minetest.register_chatcommand("wl_lb", {
params = "",
description = "list biomes",
privs = {interact = true},
func = function()
local biom = water_life.get_biomes()
if not biom then return end
for i=1,#biom,1 do
minetest.chat_send_all(dump(i)..") "..dump(biom[i]))
end
end
})
minetest.register_chatcommand("wl_test", {
params = "<mob_name>",
description = "test",

19
compat.lua Normal file
View File

@ -0,0 +1,19 @@
-- check for islands mod
if minetest.get_modpath("islands") then
local bnames = water_life.get_biomes()
water_life.spawn_on_islands = true
if bnames then
for i=1,#bnames,1 do
local keep = string.match(bnames[i],"savanna") or string.match(bnames[i],"rainforest")
if not keep then minetest.unregister_biome(bnames[i]) end
end
end
end

View File

@ -6,7 +6,7 @@
-----------------------------------------------------------
water_life = {}
water_life.version = "210206"
water_life.version = "210207"
water_life.shark_food = {}
water_life.repellant = {}
water_life.gull_bait = {}
@ -43,7 +43,9 @@ water_life.bloody = minetest.settings:get_bool("water_life_bloody") or true
local path = minetest.get_modpath(minetest.get_current_modname())
dofile(path.."/api.lua") -- load water_life api
dofile(path.."/compat.lua")
dofile(path.."/paths.lua") -- load pathfinding
if water_life.muddy_water then dofile(path.."/mapgen.lua") end -- load muddy_water
dofile(path.."/crafts.lua") -- load crafts

View File

@ -379,11 +379,13 @@ local function spawnstep(dtime)
--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
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")) or (water_life.spawn_on_islands and not water_life.check_for_pool(nil,2,3,pos2) and
water_life.check_for_pool(nil,2,16,pos2))) then
local table = minetest.get_biome_data(pos)
if not water_life.dangerous and table and water_life.piranha_biomes[minetest.get_biome_name(table.biome)] then
if not water_life.dangerous and ((table and water_life.piranha_biomes[minetest.get_biome_name(table.biome)])
or water_life.spawn_on_islands) then
mobname = "water_life:piranha"
end