Merge pull request #93 from berengma/dev

Dev
This commit is contained in:
Gundul 2023-05-21 19:44:19 +02:00 committed by GitHub
commit b5648fff22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 67 additions and 34 deletions

View File

@ -19,6 +19,7 @@ local function fish_brain(self)
end
end
if mobkit.timer(self,1) then
local prty = mobkit.get_queue_priority(self)
if not self.isinliquid then
mobkit.hurt(self,1)
end
@ -30,10 +31,13 @@ local function fish_brain(self)
if self.isinliquid and self.isinliquid =="default:river_water_source" then
water_life.hq_swimto(self,30,1,"default:water_source")
end
if mobkit.is_queue_empty_high(self) then
if mobkit.is_queue_empty_high(self) and self.isinliquid then
mobkit.animate(self,"def")
mobkit.hq_aqua_roam(self,10,0.5)
water_life.hq_aqua_roam(self,10,0.5,false,true)
end
if prty < 90 and not self.isinliquid then
water_life.hq_go2water(self,99,2)
end
end
end

View File

@ -12,6 +12,7 @@ local rad = math.rad
local function croc_brain(self)
local prty = mobkit.get_queue_priority(self)
-- minetest.chat_send_all(dump(prty))
--die
if self.hp <= 0 then
@ -66,13 +67,13 @@ local function croc_brain(self)
and water_life.isinliquid(target) then
local dist = water_life.dist2tgt(self,target)
if dist > 2 and dist < 16 then
water_life.hq_water_attack(self,target,24,7,true)
water_life.hq_water_attack(self,target,26,7,true)
end
end
if food and mobkit.is_in_deep(food) and not aliveinwater then
local dist = water_life.dist2tgt(self,food)
if dist > 2 and dist < 16 then
water_life.hq_water_attack(self,food,25,7,true)
water_life.hq_water_attack(self,food,26,7,true)
end
end
if self.isinliquid then
@ -85,7 +86,7 @@ local function croc_brain(self)
end
if food and mobkit.is_alive(food) and not water_life.isinliquid(food) then
local dist = water_life.dist2tgt(self,food)
if dist < 10 then
if dist < 16 then
water_life.hq_go2land(self,15,food)
end
end
@ -99,13 +100,13 @@ local function croc_brain(self)
end
if target and mobkit.is_alive(target) then
local dist = water_life.dist2tgt(self,target)
if dist < 7 then
if dist < 8 and prty < 24 then
water_life.hq_hunt(self,24,target,7)
end
end
if food and mobkit.is_alive(food) then
local dist = water_life.dist2tgt(self,food)
if dist < 7 then
if dist < 8 and prty < 25 then
water_life.hq_hunt(self,25,food,7)
end
end
@ -129,9 +130,9 @@ end
minetest.register_entity("water_life:croc",{
physical = true,
stepheight = 0.5,
collide_with_objects = true,
collisionbox = {-0.5, 0, -0.5, 0.5, 0.3, 0.5},
stepheight = 1.1,
collide_with_objects = false,
collisionbox = {-0.49, -0.01, -0.49, 0.49, 0.3, 0.49},
visual = "mesh",
mesh = "water_life_crocodile.b3d",
textures = {"water_life_crocodile.png"},

View File

@ -9,6 +9,15 @@ local pow = math.pow
local sign = math.sign
local rad = math.rad
local function MoskitosAround(pos)
if not pos then
return 0
end
local nodes = minetest.find_nodes_in_area({x=pos.x-1, y=pos.y-1, z=pos.z-1},
{x=pos.x+1, y=pos.y+1, z=pos.z+1}, {"water_life:moskito"})
return #nodes
end
minetest.register_on_player_hpchange(function(player, hp_change, reason)
if not player then return hp_change end
if hp_change > 0 then return hp_change end
@ -96,7 +105,7 @@ minetest.register_node("water_life:moskito", {
spos.y > water_life.moskito_minpos and
spos.y < water_life.moskito_maxpos and
not water_life.ihateinsects then
if rnd < bdata.humid then
if rnd < bdata.humid and MoskitosAround(spos) < 3 then
minetest.set_node(spos, {name = "water_life:moskito"})
minetest.get_node_timer(spos):start(random(mmintime, mmaxtime))
local pmeta = minetest.get_meta(spos)

View File

@ -5,6 +5,11 @@ water_life.urchinspawn = {
"default:coral_green",
"default:coral_pink",
"default:coral_orange",
"default:sand_with_kelp",
"water_life:kelpbrown",
"water_life:kelpgreen",
"water_life:seagrassgreen",
"water_life:seagrassred",
"water_life:coralmagenta",
"water_life:coralskyblue",
"seacoral:seacoralsandaqua",

View File

@ -260,7 +260,7 @@ function water_life.get_close_drops(self,name)
if #objs < 1 then return nil end
for i = #objs,1,-1 do
local entity = objs[i]:get_luaentity()
if not entity or not entity.name == "__builtin:item" then
if not entity or entity.name ~= "__builtin:item" then
table.remove(objs,i)
end
end
@ -299,11 +299,14 @@ function water_life.aqua_radar_dumb(pos,yaw,range,reverse,shallow)
local function okpos(p)
local node = mobkit.nodeatpos(p)
if node then
if node.drawtype == 'liquid' then
if node.drawtype == 'liquid' then
if shallow then
return true
end
local nodeu = mobkit.nodeatpos(mobkit.pos_shift(p,{y=1}))
local noded = mobkit.nodeatpos(mobkit.pos_shift(p,{y=-1}))
if ((nodeu and nodeu.drawtype == 'liquid') or (noded and
noded.drawtype == 'liquid')) or shallow then
noded.drawtype == 'liquid')) then
return true
else
return false

View File

@ -474,12 +474,15 @@ function water_life.hq_aqua_roam(self,prty,speed,anim)
mobkit.animate(self,anim)
init = false
end
if mobkit.timer(self,1) and self.isonground then
return true
end
local pos = mobkit.get_stand_pos(self)
local yaw = self.object:get_yaw()
local scanpos = mobkit.get_node_pos(mobkit.pos_translate2d(pos,yaw,speed))
if not vector.equals(prvscanpos,scanpos) then
prvscanpos=scanpos
local nyaw,height = water_life.aqua_radar_dumb(pos,yaw,speed,true,true)
local nyaw,height = water_life.aqua_radar_dumb(pos,yaw,speed,false,true)
if height and height > pos.y then
local vel = self.object:get_velocity()
vel.y = vel.y+1
@ -488,7 +491,7 @@ function water_life.hq_aqua_roam(self,prty,speed,anim)
if yaw ~= nyaw then
tyaw=nyaw
mobkit.hq_aqua_turn(self,prty + 1,tyaw,speed)
--return
return true
end
end
if mobkit.timer(self,1) then
@ -528,12 +531,16 @@ function water_life.hq_attack(self,prty,tgtobj)
noob = 0
end
if (dist and dist > 3) or poison > 0 or noob > 0 then
if (self.name == "water_life.rattlesnake") and ((dist and dist > 3)
or poison > 0 or noob > 0) then
return true
else
if dist and dist > 8 then
return true
end
mobkit.lq_turn2pos(self,tpos)
local height = tgtobj:is_player() and 0.35 or
tgtobj:get_luaentity().height*0.6
tgtobj:get_luaentity().height*0.3
if tpos.y+height>pos.y then
mobkit.make_sound(self,"attack")
water_life.lq_jumpattack(self,tpos.y+height-pos.y,tgtobj)
@ -592,13 +599,14 @@ function water_life.hq_slow_roam(self,prty,idle)
local func=function(self)
if self.isinliquid then return true end
if mobkit.is_queue_empty_low(self) and self.isonground then
local pos = mobkit.get_stand_pos(self)
if mobkit.is_queue_empty_low(self) then
local neighbor = random(8)
local height, tpos, liquidflag = mobkit.is_neighbor_node_reachable(
self,neighbor)
if height and not liquidflag then
mobkit.dumbstep(self,height,tpos,1,idle)
if height and tpos then
mobkit.dumbstep(self,height,tpos,0.1)--,idle)
else
return true
end
end
end
@ -610,13 +618,16 @@ function water_life.hq_go2water(self,prty,speed)
local pos = mobkit.get_stand_pos(self)
local target = minetest.find_node_near(pos, self.view_range, {"group:water"})
if not speed then speed = 0.1 end
if not target then
return true
end
local func=function(self)
if self.isinliquid or not target then return true end
if mobkit.is_queue_empty_low(self) and self.isonground then
pos = mobkit.get_stand_pos(self)
local height = target.y - pos.y
mobkit.dumbstep(self,height,target,speed,0)
if self.isinliquid then
return true
end
if mobkit.is_queue_empty_low(self) or self.isonground then
mobkit.dumbstep(self,0,target,speed,0)
end
end
mobkit.queue_high(self,func,prty)

View File

@ -114,7 +114,7 @@ if not water_life.apionly then
on_place = function(itemstack, placer, pointed_thing)
if placer and not placer:is_player() then return itemstack end
if not pointed_thing then return itemstack end
if not pointed_thing.type == "node" then return itemstack end
if pointed_thing.type ~= "node" then return itemstack end
local pos = pointed_thing.above
local number = water_life.count_objects(pos)
if number.all > water_life.maxmobs or number.fish > 10 then return itemstack end
@ -140,7 +140,7 @@ if not water_life.apionly then
on_place = function(itemstack, placer, pointed_thing)
if placer and not placer:is_player() then return itemstack end
if not pointed_thing then return itemstack end
if not pointed_thing.type == "node" then return itemstack end
if pointed_thing.type ~= "node" then return itemstack end
local pos = pointed_thing.above
local number = water_life.count_objects(pos,nil,"water_life:piranha")
if number.all > water_life.maxmobs or number.name > 10 then return itemstack end
@ -165,7 +165,7 @@ if not water_life.apionly then
on_place = function(itemstack, placer, pointed_thing)
if placer and not placer:is_player() then return itemstack end
if not pointed_thing then return itemstack end
if not pointed_thing.type == "node" then return itemstack end
if pointed_thing.type ~= "node" then return itemstack end
local pos = pointed_thing.above
local number = water_life.count_objects(pos,nil,"water_life:coralfish_tamed")
if number.all > water_life.maxmobs or number.name > 10 then return itemstack end
@ -195,7 +195,7 @@ if not water_life.apionly then
on_place = function(itemstack, placer, pointed_thing)
if placer and not placer:is_player() then return itemstack end
if not pointed_thing then return itemstack end
if not pointed_thing.type == "node" then return itemstack end
if pointed_thing.type ~= "node" then return itemstack end
local pos = pointed_thing.above
local number = water_life.count_objects(pos,nil,"water_life:clownfish_tamed")
if number.all > water_life.maxmobs or number.name > 10 then
@ -223,7 +223,7 @@ if not water_life.apionly then
on_place = function(itemstack, placer, pointed_thing)
if placer and not placer:is_player() then return itemstack end
if not pointed_thing then return itemstack end
if not pointed_thing.type == "node" then return itemstack end
if pointed_thing.type ~= "node" then return itemstack end
local pos = pointed_thing.above
local number = water_life.count_objects(pos,10,"water_life:urchin")
if number.all > water_life.maxmobs or number.name > 10 then return itemstack end
@ -248,7 +248,7 @@ if not water_life.apionly then
on_place = function(itemstack, placer, pointed_thing)
if placer and not placer:is_player() then return itemstack end
if not pointed_thing then return itemstack end
if not pointed_thing.type == "node" then return itemstack end
if pointed_thing.type ~= "node" then return itemstack end
local pos = pointed_thing.above
local number = water_life.count_objects(pos,10,"water_life:jellyfish")
if number.all > water_life.maxmobs or number.name > 10 then return itemstack end
@ -272,7 +272,7 @@ if not water_life.apionly then
on_place = function(itemstack, placer, pointed_thing)
if placer and not placer:is_player() then return itemstack end
if not pointed_thing then return itemstack end
if not pointed_thing.type == "node" then return itemstack end
if pointed_thing.type ~= "node" then return itemstack end
local pos = pointed_thing.above
local number = water_life.count_objects(pos,water_life.abr * 16,"water_life:snake")
if number.all > water_life.maxmobs or number.name > 5 then return itemstack end