new spawning
This commit is contained in:
parent
25b325491c
commit
c110ee43d2
@ -78,13 +78,14 @@ function wildcow.hq_overrun(self,prty,target)
|
|||||||
|
|
||||||
local func = function(self)
|
local func = function(self)
|
||||||
if not mobkit.is_alive(target) then return true end
|
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
|
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
|
end
|
||||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
if mobkit.is_queue_empty_low(self) and self.isonground then
|
||||||
local pos = mobkit.get_stand_pos(self)
|
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)
|
wildcow.goto_next_waypoint(self,tpos,2)
|
||||||
else
|
else
|
||||||
return true
|
return true
|
||||||
@ -169,7 +170,7 @@ end
|
|||||||
|
|
||||||
function wildcow.hq_stare(self,prty,target)
|
function wildcow.hq_stare(self,prty,target)
|
||||||
local init = true
|
local init = true
|
||||||
local gethim = 10
|
local gethim = 7
|
||||||
|
|
||||||
local func = function(self)
|
local func = function(self)
|
||||||
if not mobkit.is_alive(target) then return true end
|
if not mobkit.is_alive(target) then return true end
|
||||||
|
10
calf.lua
10
calf.lua
@ -52,7 +52,7 @@ local function calf_brain(self)
|
|||||||
if wildcow.debug then
|
if wildcow.debug then
|
||||||
obj:set_nametag_attributes({
|
obj:set_nametag_attributes({
|
||||||
color = '#ff7373',
|
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
|
end
|
||||||
|
|
||||||
@ -111,8 +111,8 @@ minetest.register_entity("wildcow:auroch_calf",{
|
|||||||
view_range = 10,
|
view_range = 10,
|
||||||
lung_capacity = 20, -- seconds
|
lung_capacity = 20, -- seconds
|
||||||
max_hp = 25,
|
max_hp = 25,
|
||||||
timeout = 0,
|
timeout = 1440,
|
||||||
attack={range=0.5,damage_groups={fleshy=10}},
|
attack={range=0.5,damage_groups={fleshy=5}},
|
||||||
sounds = {
|
sounds = {
|
||||||
--scared='deer_scared',
|
--scared='deer_scared',
|
||||||
--hurt = 'deer_hurt',
|
--hurt = 'deer_hurt',
|
||||||
@ -126,8 +126,8 @@ minetest.register_entity("wildcow:auroch_calf",{
|
|||||||
attack={range={x=145,y=160},speed=20,loop=true},
|
attack={range={x=145,y=160},speed=20,loop=true},
|
||||||
},
|
},
|
||||||
drops = {
|
drops = {
|
||||||
{name = "default:diamond", chance = 20, min = 1, max = 3,},
|
{name = "default:diamond", chance = 20, min = 1, max = 1,},
|
||||||
{name = "water_life:meat_raw", chance = 2, min = 1, max = 3,},
|
{name = "water_life:meat_raw", chance = 2, min = 1, max = 1,},
|
||||||
},
|
},
|
||||||
mama = {},
|
mama = {},
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ local function female_brain(self)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if prty < 20 and self.isinliquid then
|
if prty < 20 and water_life.inwater(self.object) then
|
||||||
mobkit.hq_liquid_recovery(self,20)
|
mobkit.hq_liquid_recovery(self,20)
|
||||||
water_life.hunger(self,-5)
|
water_life.hunger(self,-5)
|
||||||
return
|
return
|
||||||
@ -184,7 +184,7 @@ minetest.register_entity("wildcow:auroch_female",{
|
|||||||
physical = true,
|
physical = true,
|
||||||
stepheight = 0.1, --EVIL!
|
stepheight = 0.1, --EVIL!
|
||||||
collide_with_objects = false,
|
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",
|
visual = "mesh",
|
||||||
mesh = "wildcow_auroch_female.b3d",
|
mesh = "wildcow_auroch_female.b3d",
|
||||||
textures = {"wildcow_auroch_female.png"},
|
textures = {"wildcow_auroch_female.png"},
|
||||||
|
10
init.lua
10
init.lua
@ -9,12 +9,12 @@ local path = minetest.get_modpath(minetest.get_current_modname())
|
|||||||
|
|
||||||
|
|
||||||
wildcow = {}
|
wildcow = {}
|
||||||
wildcow.spawnfreq = 10 -- spawn frequency
|
wildcow.spawnfreq = 30 -- spawn frequency
|
||||||
wildcow.herdsize = 5 -- max member in a herd
|
wildcow.herdsize = 5 -- max member in a herd
|
||||||
wildcow.ptime = 720 -- time in secs until baby is born
|
wildcow.ptime = 720 -- time in secs until baby is born
|
||||||
wildcow.btime = 1440 -- time for a calf until it is grewn up
|
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.lifetime = (wildcow.btime+wildcow.ptime)*4 -- lifetime in seconds
|
||||||
wildcow.debug = false -- show debug
|
wildcow.debug = false -- show debug
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
6
male.lua
6
male.lua
@ -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
|
if prty < 30 and water_life.is_boss(self) == 1 and horny < 70 and hunger > horny then
|
||||||
mobkit.clear_queue_high(self)
|
mobkit.clear_queue_high(self)
|
||||||
wildcow.hq_meetmygirl(self,30)
|
wildcow.hq_meetmygirl(self,8)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -95,7 +95,7 @@ local function male_brain(self)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if prty < 20 and self.isinliquid then
|
if prty < 20 and water_life.inwater(self.object) then
|
||||||
mobkit.hq_liquid_recovery(self,20)
|
mobkit.hq_liquid_recovery(self,20)
|
||||||
water_life.hunger(self,-5)
|
water_life.hunger(self,-5)
|
||||||
end
|
end
|
||||||
@ -147,7 +147,7 @@ minetest.register_entity("wildcow:auroch_male",{
|
|||||||
physical = true,
|
physical = true,
|
||||||
stepheight = 0.1, --EVIL!
|
stepheight = 0.1, --EVIL!
|
||||||
collide_with_objects = false,
|
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",
|
visual = "mesh",
|
||||||
mesh = "wildcow_auroch_male.b3d",
|
mesh = "wildcow_auroch_male.b3d",
|
||||||
textures = {"wildcow_auroch_male.png"},
|
textures = {"wildcow_auroch_male.png"},
|
||||||
|
80
spawn.lua
80
spawn.lua
@ -3,48 +3,60 @@ local random = water_life.random
|
|||||||
local abr = tonumber(minetest.get_mapgen_setting('active_block_range')) or 2
|
local abr = tonumber(minetest.get_mapgen_setting('active_block_range')) or 2
|
||||||
local abs = math.abs
|
local abs = math.abs
|
||||||
|
|
||||||
|
|
||||||
|
local function getcount(name)
|
||||||
|
if not name then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local function spawnstep(dtime)
|
local function spawnstep(dtime)
|
||||||
|
|
||||||
spawntimer = spawntimer + dtime
|
spawntimer = spawntimer + dtime
|
||||||
if spawntimer < 30 then return end
|
|
||||||
|
if spawntimer < wildcow.spawnfreq then return end
|
||||||
for _,plyr in ipairs(minetest.get_connected_players()) do
|
--minetest.chat_send_all("SpawnTime")
|
||||||
|
|
||||||
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 height and height >= 0 and height <= 100 and not liquidflag
|
for _,plyr in ipairs(minetest.get_connected_players()) do
|
||||||
and mobkit.nodeatpos({x=pos2.x,y=height-0.01,z=pos2.z}).is_ground_content then
|
|
||||||
|
|
||||||
|
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 landpos and not toomuch then
|
||||||
|
if not minetest.is_protected(landpos,mobname) then
|
||||||
if not minetest.is_protected(pos2,mobname) then
|
local obj = minetest.add_entity(landpos,mobname)
|
||||||
local obj = minetest.add_entity(pos2,mobname)
|
if obj then
|
||||||
if obj then
|
local entity = obj:get_luaentity()
|
||||||
local entity = obj:get_luaentity()
|
water_life.init_bio(entity)
|
||||||
water_life.init_bio(entity)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user