new spawning

This commit is contained in:
berengma 2020-12-12 18:01:23 +01:00
parent 25b325491c
commit c110ee43d2
6 changed files with 65 additions and 52 deletions

View File

@ -78,13 +78,14 @@ function wildcow.hq_overrun(self,prty,target)
local func = function(self)
if not mobkit.is_alive(target) then return true end
if water_life.dist2tgt(self,target) > self.view_range then return true end
if water_life.dist2tgt(self,target) < 1 then
target:punch(self.object,1,self.attack) --wildcow.knockback(target,dir,3)
target:punch(self.object,1,self.attack)
end
if mobkit.is_queue_empty_low(self) and self.isonground then
local pos = mobkit.get_stand_pos(self)
if vector.distance(pos,tpos) >= 1.1 then
if vector.distance(pos,tpos) >= 1.3 then
wildcow.goto_next_waypoint(self,tpos,2)
else
return true
@ -169,7 +170,7 @@ end
function wildcow.hq_stare(self,prty,target)
local init = true
local gethim = 10
local gethim = 7
local func = function(self)
if not mobkit.is_alive(target) then return true end

View File

@ -52,7 +52,7 @@ local function calf_brain(self)
if wildcow.debug then
obj:set_nametag_attributes({
color = '#ff7373',
text = tostring(math.floor(self.time_total*100)/100).."s lifetime\n"..tostring(water_life.hunger(self)),
text = tostring(wildcow.btime - math.floor(self.time_total*100)/100).."\n"..tostring(water_life.is_alive(self)),
})
end
@ -111,8 +111,8 @@ minetest.register_entity("wildcow:auroch_calf",{
view_range = 10,
lung_capacity = 20, -- seconds
max_hp = 25,
timeout = 0,
attack={range=0.5,damage_groups={fleshy=10}},
timeout = 1440,
attack={range=0.5,damage_groups={fleshy=5}},
sounds = {
--scared='deer_scared',
--hurt = 'deer_hurt',
@ -126,8 +126,8 @@ minetest.register_entity("wildcow:auroch_calf",{
attack={range={x=145,y=160},speed=20,loop=true},
},
drops = {
{name = "default:diamond", chance = 20, min = 1, max = 3,},
{name = "water_life:meat_raw", chance = 2, min = 1, max = 3,},
{name = "default:diamond", chance = 20, min = 1, max = 1,},
{name = "water_life:meat_raw", chance = 2, min = 1, max = 1,},
},
mama = {},

View File

@ -123,7 +123,7 @@ local function female_brain(self)
})
end
if prty < 20 and self.isinliquid then
if prty < 20 and water_life.inwater(self.object) then
mobkit.hq_liquid_recovery(self,20)
water_life.hunger(self,-5)
return
@ -184,7 +184,7 @@ minetest.register_entity("wildcow:auroch_female",{
physical = true,
stepheight = 0.1, --EVIL!
collide_with_objects = false,
collisionbox = {-0.45, 0, -0.45, 0.45, 0.95, 0.45},
collisionbox = {-0.45, 0, -0.45, 0.45, 0.85, 0.45},
visual = "mesh",
mesh = "wildcow_auroch_female.b3d",
textures = {"wildcow_auroch_female.png"},

View File

@ -9,12 +9,12 @@ local path = minetest.get_modpath(minetest.get_current_modname())
wildcow = {}
wildcow.spawnfreq = 10 -- spawn frequency
wildcow.herdsize = 5 -- max member in a herd
wildcow.ptime = 720 -- time in secs until baby is born
wildcow.btime = 1440 -- time for a calf until it is grewn up
wildcow.spawnfreq = 30 -- spawn frequency
wildcow.herdsize = 5 -- max member in a herd
wildcow.ptime = 720 -- time in secs until baby is born
wildcow.btime = 1440 -- time needed for a calf to grew up to an adult
wildcow.lifetime = (wildcow.btime+wildcow.ptime)*4 -- lifetime in seconds
wildcow.debug = false -- show debug
wildcow.debug = false -- show debug

View File

@ -29,7 +29,7 @@ local function male_brain(self)
if prty < 30 and water_life.is_boss(self) == 1 and horny < 70 and hunger > horny then
mobkit.clear_queue_high(self)
wildcow.hq_meetmygirl(self,30)
wildcow.hq_meetmygirl(self,8)
end
end
@ -95,7 +95,7 @@ local function male_brain(self)
})
end
if prty < 20 and self.isinliquid then
if prty < 20 and water_life.inwater(self.object) then
mobkit.hq_liquid_recovery(self,20)
water_life.hunger(self,-5)
end
@ -147,7 +147,7 @@ minetest.register_entity("wildcow:auroch_male",{
physical = true,
stepheight = 0.1, --EVIL!
collide_with_objects = false,
collisionbox = {-0.45, 0, -0.45, 0.45, 0.95, 0.45},
collisionbox = {-0.45, 0, -0.45, 0.45, 0.85, 0.45},
visual = "mesh",
mesh = "wildcow_auroch_male.b3d",
textures = {"wildcow_auroch_male.png"},

View File

@ -3,48 +3,60 @@ local random = water_life.random
local abr = tonumber(minetest.get_mapgen_setting('active_block_range')) or 2
local abs = math.abs
local function getcount(name)
if not name then
return 0
else
return name
end
end
local function spawnstep(dtime)
spawntimer = spawntimer + dtime
if spawntimer < 30 then return end
for _,plyr in ipairs(minetest.get_connected_players()) do
spawntimer = 0
local borg = random(1000)
local mobname = 'wildcow:auroch_male'
if borg > 500 then mobname = 'wildcow:auroch_female' end
local yaw = plyr:get_look_horizontal() + random()*0.35 - 0.75
local pos = plyr:get_pos()
local dir = vector.multiply(minetest.yaw_to_dir(yaw),abr*16)
local pos2 = vector.add(pos,dir)
pos2.y=pos2.y-5
local height, liquidflag = mobkit.get_terrain_height(pos2,32)
local friends = water_life.count_objects(pos,abr*16, mobname)
if not friends[mobname] then friends[mobname] = 0 end
if random(100) < (100 - (100/wildcow.herdsize * friends[mobname])) then
if spawntimer < wildcow.spawnfreq then return end
--minetest.chat_send_all("SpawnTime")
if height and height >= 0 and height <= 100 and not liquidflag
and mobkit.nodeatpos({x=pos2.x,y=height-0.01,z=pos2.z}).is_ground_content then
for _,plyr in ipairs(minetest.get_connected_players()) do
local mobname = "wildcow:auroch_male"
spawntimer = 0
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
local radius = (water_life.abr * 12) -- 75% from 16 = 12 nodes
radius = random(16,radius) -- not nearer than 7 nodes in front of player
local angel = math.rad(random(90)) -- 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 bdata = water_life_get_biome_data(pos2) -- get biome data at spawn position
local landpos = water_life.find_node_under_air(pos2,5,{"group:crumbly"})
local cows = getcount(animal["wildcow:auroch_female"])
local bulls = getcount(animal["wildcow:auroch_male"])
local calf = getcount(animal["wildcow:auroch_calf"])
if cows + bulls + calf > wildcow.herdsize * 2 then toomuch = true end
if bulls > cows then mobname = "wildcow:auroch_female" end
pos2.y = height+0.5
if not minetest.is_protected(pos2,mobname) then
local obj = minetest.add_entity(pos2,mobname)
if obj then
local entity = obj:get_luaentity()
water_life.init_bio(entity)
end
if landpos and not toomuch then
if not minetest.is_protected(landpos,mobname) then
local obj = minetest.add_entity(landpos,mobname)
if obj then
local entity = obj:get_luaentity()
water_life.init_bio(entity)
end
end
end
end