Before Width: | Height: | Size: 416 B |
Before Width: | Height: | Size: 397 B |
Before Width: | Height: | Size: 265 B |
Before Width: | Height: | Size: 341 B |
Before Width: | Height: | Size: 412 B |
Before Width: | Height: | Size: 435 B |
Before Width: | Height: | Size: 509 B |
Before Width: | Height: | Size: 410 B |
Before Width: | Height: | Size: 390 B |
Before Width: | Height: | Size: 303 B |
Before Width: | Height: | Size: 434 B |
Before Width: | Height: | Size: 237 B |
Before Width: | Height: | Size: 310 B |
Before Width: | Height: | Size: 283 B |
Before Width: | Height: | Size: 414 B |
Before Width: | Height: | Size: 442 B |
Before Width: | Height: | Size: 492 B |
Before Width: | Height: | Size: 294 B |
Before Width: | Height: | Size: 270 B |
Before Width: | Height: | Size: 343 B |
Before Width: | Height: | Size: 414 B |
@ -1,4 +1,4 @@
|
||||
|
||||
local random = water_life.random
|
||||
|
||||
|
||||
local function fish_brain(self)
|
||||
@ -8,6 +8,18 @@ local function fish_brain(self)
|
||||
mobkit.hq_die(self)
|
||||
return
|
||||
end
|
||||
|
||||
if mobkit.timer(self,5) then
|
||||
local pos = self.object:get_pos()
|
||||
local obj = self.object
|
||||
if self.base and vector.distance(self.base,pos) > 5 then
|
||||
water_life.hq_swimto(self,20,0.5,nil,self.base)
|
||||
else
|
||||
local coraltable = minetest.find_nodes_in_area({x=pos.x-5, y=pos.y-5, z=pos.z-5}, {x=pos.x+5, y=pos.y+5, z=pos.z+5},water_life.urchinspawn)
|
||||
if #coraltable > 0 then self.base = coraltable[random(#coraltable)] end
|
||||
end
|
||||
end
|
||||
|
||||
if mobkit.timer(self,1) then
|
||||
if not self.isinliquid then
|
||||
--minetest.chat_send_all(dump(self.isinliquid))
|
||||
@ -59,7 +71,8 @@ minetest.register_entity("water_life:clownfish",{
|
||||
-- lung_capacity = 0, -- seconds
|
||||
max_hp = 5,
|
||||
timeout=300,
|
||||
wild = true,
|
||||
wild = true,
|
||||
base = nil,
|
||||
drops = {},
|
||||
-- {name = "default:diamond", chance = 20, min = 1, max = 1,},
|
||||
-- {name = "water_life:meat_raw", chance = 2, min = 1, max = 1,},
|
||||
@ -115,8 +128,9 @@ minetest.register_entity("water_life:clownfish_tamed",{
|
||||
-- lung_capacity = 0, -- seconds
|
||||
max_hp = 5,
|
||||
-- timeout=60,
|
||||
wild = false,
|
||||
owner = "",
|
||||
wild = false,
|
||||
base = nil,
|
||||
owner = "",
|
||||
drops = {},
|
||||
-- {name = "default:diamond", chance = 20, min = 1, max = 1,},
|
||||
-- {name = "water_life:meat_raw", chance = 2, min = 1, max = 1,},
|
@ -1,4 +1,4 @@
|
||||
|
||||
local random = water_life.random
|
||||
|
||||
|
||||
local function fish_brain(self)
|
||||
@ -8,6 +8,53 @@ local function fish_brain(self)
|
||||
mobkit.hq_die(self)
|
||||
return
|
||||
end
|
||||
|
||||
if mobkit.timer(self,2) then
|
||||
local members = water_life.get_herd_members(self,5)
|
||||
local score = 0
|
||||
local entity = {}
|
||||
if #members > 1 then
|
||||
for i = #members,1,-1 do
|
||||
entity = members[i]:get_luaentity()
|
||||
if entity then
|
||||
--minetest.chat_send_all(dump(entity.head).." : "..dump(score))
|
||||
|
||||
if entity.head <= score then
|
||||
table.remove(members,i)
|
||||
else
|
||||
score = entity.head
|
||||
end
|
||||
else
|
||||
table.remove(members,i)
|
||||
end
|
||||
end
|
||||
|
||||
local hpos = members[1]:get_pos()
|
||||
--minetest.chat_send_all(dump("Boss-POS :"..minetest.pos_to_string(hpos)).." score= "..dump(score))
|
||||
if self.head ~= score then self.base = hpos end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
if mobkit.timer(self,2) then
|
||||
local pos = self.object:get_pos()
|
||||
local obj = self.object
|
||||
local prio = mobkit.get_queue_priority(self)
|
||||
|
||||
if prio < 50 then
|
||||
if self.base and vector.distance(self.base,pos) > 3 then
|
||||
mobkit.clear_queue_high(self)
|
||||
mobkit.clear_queue_low(self)
|
||||
water_life.hq_swimto(self,20,0.5,nil,self.base)
|
||||
else
|
||||
local coraltable = minetest.find_nodes_in_area({x=pos.x-5, y=pos.y-5, z=pos.z-5}, {x=pos.x+5, y=pos.y+5, z=pos.z+5},water_life.urchinspawn)
|
||||
if #coraltable > 0 then self.base = coraltable[random(#coraltable)] end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if mobkit.timer(self,1) then
|
||||
if not self.isinliquid then
|
||||
--minetest.chat_send_all(dump(self.isinliquid))
|
||||
@ -55,11 +102,14 @@ minetest.register_entity("water_life:coralfish",{
|
||||
buoyancy = 1.0, -- portion of hitbox submerged
|
||||
max_speed = 2,
|
||||
jump_height = 0.5,
|
||||
view_range = 2,
|
||||
view_range = 3,
|
||||
-- lung_capacity = 0, -- seconds
|
||||
max_hp = 5,
|
||||
timeout=300,
|
||||
wild = true,
|
||||
wild = true,
|
||||
swarm = {},
|
||||
base = nil,
|
||||
head = 65535,
|
||||
drops = {},
|
||||
-- {name = "default:diamond", chance = 20, min = 1, max = 1,},
|
||||
-- {name = "water_life:meat_raw", chance = 2, min = 1, max = 1,},
|
||||
@ -115,7 +165,10 @@ minetest.register_entity("water_life:coralfish_tamed",{
|
||||
-- lung_capacity = 0, -- seconds
|
||||
max_hp = 5,
|
||||
-- timeout=60,
|
||||
wild = false,
|
||||
wild = false,
|
||||
swarm = {},
|
||||
base = nil,
|
||||
head = 65535,
|
||||
owner = "",
|
||||
drops = {},
|
||||
-- {name = "default:diamond", chance = 20, min = 1, max = 1,},
|
98
api.lua
@ -210,16 +210,50 @@ for _,obj in ipairs(all_objects) do
|
||||
end
|
||||
if entity and entity.name == "water_life:whale" then
|
||||
hasil.whales = hasil.whales +1
|
||||
elseif entity and entity.name == "water_life:shark" then
|
||||
elseif entity and entity.name == "water_life:shark" then
|
||||
hasil.sharks = hasil.sharks +1
|
||||
elseif entity and (entity.name == "water_life:fish" or entity.name == "water_life:fish_tamed") then
|
||||
hasil.fish = hasil.fish +1
|
||||
elseif entity and (entity.name == "water_life:fish" or entity.name == "water_life:fish_tamed") then
|
||||
hasil.fish = hasil.fish +1
|
||||
end
|
||||
|
||||
if entity and entity.name then
|
||||
if not hasil[entity.name] then
|
||||
hasil[entity.name] = 1
|
||||
else
|
||||
hasil[entity.name] = hasil[entity.name] +1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return hasil
|
||||
end
|
||||
|
||||
|
||||
function water_life.get_herd_members(self,radius)
|
||||
|
||||
local pos = mobkit.get_stand_pos(self)
|
||||
local name = self.name
|
||||
|
||||
if not radius then radius = water_life.abo * 16 end
|
||||
|
||||
local all_objects = minetest.get_objects_inside_radius(pos, radius)
|
||||
if #all_objects < 1 then return nil end
|
||||
|
||||
for i = #all_objects,1,-1 do
|
||||
local entity = all_objects[i]:get_luaentity()
|
||||
|
||||
if entity and entity.name ~= name then
|
||||
table.remove(all_objects,i)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if #all_objects < 1 then
|
||||
return nil
|
||||
else
|
||||
return all_objects
|
||||
end
|
||||
end
|
||||
return hasil
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- returns 2D angle from self to target in radians
|
||||
@ -393,21 +427,27 @@ function water_life.hq_swimto(self,prty,speed,node,tgtpos)
|
||||
if not mobkit.is_alive(self) then return true end
|
||||
local pos = self.object:get_pos()
|
||||
|
||||
|
||||
if vector.distance(pos,endpos) > 1 then
|
||||
if mobkit.timer(self,1) then
|
||||
if vector.distance(pos,endpos) > 1 then
|
||||
|
||||
--minetest.chat_send_all(vector.distance(pos,endpos))
|
||||
if endpos.y > pos.y then
|
||||
local vel = self.object:get_velocity()
|
||||
vel.y = vel.y+0.4
|
||||
self.object:set_velocity(vel)
|
||||
end
|
||||
if endpos.y < pos.y then
|
||||
local vel = self.object:get_velocity()
|
||||
vel.y = vel.y-0.1
|
||||
self.object:set_velocity(vel)
|
||||
end
|
||||
mobkit.hq_aqua_turn(self,prty+5,yaw,speed)
|
||||
pos = self.object:get_pos() --mobkit.get_stand_pos(self)
|
||||
yaw = water_life.get_yaw_to_pos(self,endpos)
|
||||
|
||||
--minetest.chat_send_all(vector.distance(pos,endpos))
|
||||
if endpos.y > pos.y then
|
||||
local vel = self.object:get_velocity()
|
||||
vel.y = vel.y+0.3
|
||||
self.object:set_velocity(vel)
|
||||
end
|
||||
mobkit.hq_aqua_turn(self,prty+5,yaw,speed)
|
||||
pos = self.object:get_pos() --mobkit.get_stand_pos(self)
|
||||
yaw = water_life.get_yaw_to_pos(self,endpos)
|
||||
|
||||
else
|
||||
return true
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@ -660,3 +700,19 @@ minetest.register_chatcommand("wl_version", {
|
||||
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("wl_objects", {
|
||||
params = "",
|
||||
description = "find #objects in abo",
|
||||
privs = {server = true},
|
||||
func = function(name, action)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then return false end
|
||||
local pos = player:get_pos()
|
||||
|
||||
showit = water_life.count_objects(pos)
|
||||
minetest.chat_send_player(name,dump(showit))
|
||||
|
||||
|
||||
end
|
||||
})
|
||||
|
11
crafts.lua
@ -1,4 +1,4 @@
|
||||
|
||||
local random = water_life.random
|
||||
|
||||
-- raw meat
|
||||
minetest.register_craftitem("water_life:meat_raw", {
|
||||
@ -161,9 +161,14 @@ minetest.register_craftitem("water_life:coralfish", {
|
||||
if minetest.is_protected(pos,name) then return itemstack end
|
||||
|
||||
local obj = minetest.add_entity(pos, "water_life:coralfish_tamed")
|
||||
obj = obj:get_luaentity()
|
||||
if obj then
|
||||
local entity = obj:get_luaentity()
|
||||
entity.base = nil
|
||||
entity.owner = name
|
||||
entity.head = random(65535)
|
||||
end
|
||||
itemstack:take_item()
|
||||
obj.owner = name
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
@ -1,6 +0,0 @@
|
||||
default
|
||||
mobkit
|
||||
bucket?
|
||||
fireflies?
|
||||
petz?
|
||||
wildlife?
|
@ -86,20 +86,16 @@ register enitiy "name" as shark food. Will be attacked by sharks if in water and
|
||||
|
||||
|
||||
##########################################
|
||||
water_life.count_objects(pos,radius,name)
|
||||
water_life.count_objects(pos,radius)
|
||||
##########################################
|
||||
|
||||
if radius is nil radius will be the active_object_send_range_blocks * 16
|
||||
counts objects around >pos< with >radius< in nodes and returns a table:
|
||||
(>name< is a string or nil)
|
||||
|
||||
|
||||
table.all - total number of all objects
|
||||
table.sharks - total number of sharks
|
||||
table.whales - total number of whales
|
||||
table.fish - total number of fish wild/tamed
|
||||
table.name - total number of mob "name"
|
||||
table["objectname"] = nil or number of found objects
|
||||
|
||||
if radius is nil radius will be the active_object_send_range_blocks * 16
|
||||
if name is nil table.name is 0
|
||||
|
||||
|
||||
#############################
|
22
init.lua
@ -26,17 +26,17 @@ dofile(path.."/crafts.lua") -- load crafts
|
||||
dofile(path.."/buoy.lua") -- load buoy
|
||||
if not water_life.apionly then
|
||||
dofile(path.."/spawn.lua") -- load spawn function
|
||||
dofile(path.."/whale.lua") -- load whales
|
||||
dofile(path.."/shark.lua") -- load sharks
|
||||
dofile(path.."/riverfish.lua") -- load riverfish
|
||||
dofile(path.."/piranha.lua") -- load piranha
|
||||
dofile(path.."/sea_urchin.lua") -- load sea urchin
|
||||
dofile(path.."/clams.lua") -- load clams
|
||||
dofile(path.."/plants.lua") -- load water plants
|
||||
dofile(path.."/corals.lua") -- load corals
|
||||
dofile(path.."/jellyfish.lua") -- load jellyfish
|
||||
dofile(path.."/coralfish.lua") -- load coralfish
|
||||
dofile(path.."/clownfish.lua") -- load clownfish
|
||||
dofile(path.."/animals/whale.lua") -- load whales
|
||||
dofile(path.."/animals/shark.lua") -- load sharks
|
||||
dofile(path.."/animals/riverfish.lua") -- load riverfish
|
||||
dofile(path.."/animals/piranha.lua") -- load piranha
|
||||
dofile(path.."/animals/sea_urchin.lua") -- load sea urchin
|
||||
dofile(path.."/animals/clams.lua") -- load clams
|
||||
dofile(path.."/flora/plants.lua") -- load water plants
|
||||
dofile(path.."/flora/corals.lua") -- load corals
|
||||
dofile(path.."/animals/jellyfish.lua") -- load jellyfish
|
||||
dofile(path.."/animals/coralfish.lua") -- load coralfish
|
||||
dofile(path.."/animals/clownfish.lua") -- load clownfish
|
||||
end
|
||||
|
||||
|
||||
|
64
spawn.lua
@ -3,6 +3,14 @@ local pi = math.pi
|
||||
local random = water_life.random
|
||||
|
||||
|
||||
local function getcount(name)
|
||||
if not name then
|
||||
return 0
|
||||
else
|
||||
return name
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function spawnstep(dtime)
|
||||
|
||||
@ -56,8 +64,8 @@ local function spawnstep(dtime)
|
||||
local mobname = 'water_life:shark'
|
||||
if water_life.shark_spawn_rate >= random(1000) then
|
||||
|
||||
local bcheck = water_life.count_objects(pos2,12,"water_life:shark_buoy")
|
||||
if animal.sharks < (water_life.maxsharks) and liquidflag == "sea" and bcheck.name == 0 then
|
||||
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"] then
|
||||
|
||||
if depth.depth > 4 then --shark min water depth
|
||||
local obj=minetest.add_entity({x=pos2.x,y=pos2.y-depth.depth+1,z=pos2.z},mobname) -- ok spawn it already damnit
|
||||
@ -71,8 +79,8 @@ local function spawnstep(dtime)
|
||||
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 nearlife.name < 5 and liquidflag == "sea" then
|
||||
--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)
|
||||
@ -88,10 +96,10 @@ local function spawnstep(dtime)
|
||||
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 nearlife.name < 5 and liquidflag == "sea" then
|
||||
--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
|
||||
local coralpos = coraltable[random(#coraltable)]
|
||||
coralpos.y = coralpos.y +1
|
||||
coralpos.y = coralpos.y +0.5
|
||||
local node = minetest.get_node(coralpos)
|
||||
|
||||
if node.name == "default:water_source" then
|
||||
@ -103,9 +111,8 @@ local function spawnstep(dtime)
|
||||
|
||||
mobname = "water_life:jellyfish"
|
||||
|
||||
local ground = depth.surface
|
||||
local nearlife = water_life.count_objects(ground,nil,"water_life:jellyfish")
|
||||
local faktor = 100 - nearlife.name * 20
|
||||
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)
|
||||
end
|
||||
@ -113,35 +120,44 @@ local function spawnstep(dtime)
|
||||
|
||||
mobname = "water_life:coralfish"
|
||||
|
||||
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,nil,mobname)
|
||||
local faktor = 100 - nearlife.name * 6.66
|
||||
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
|
||||
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)
|
||||
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
|
||||
|
||||
|
||||
|
||||
mobname = "water_life:clownfish"
|
||||
|
||||
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,nil,mobname)
|
||||
local faktor = 100 - nearlife.name * 50
|
||||
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
|
||||
|
||||
|
||||
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 nearlife.fish < 5) and (liquidflag == "river" or liquidflag == "muddy") then
|
||||
--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
|
||||
@ -150,7 +166,7 @@ local function spawnstep(dtime)
|
||||
if mobname == "water_life:fish" then
|
||||
local obj=minetest.add_entity(pos2,mobname) -- ok spawn it already damnit
|
||||
else
|
||||
if nearlife.name < 10 then
|
||||
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
|
||||
@ -161,7 +177,7 @@ local function spawnstep(dtime)
|
||||
|
||||
end
|
||||
|
||||
if water_life.whale_spawn_rate >= random(1000) and animal.whales < (water_life.maxwhales) and liquidflag == "sea" then
|
||||
if water_life.whale_spawn_rate >= random(1000) and getcount(animal[mobname]) < (water_life.maxwhales) and liquidflag == "sea" then
|
||||
mobname = 'water_life:whale'
|
||||
|
||||
if depth.depth > 8 then -- min water depth for whales
|
||||
|