parent
7e08ecb8c1
commit
e100c980e2
|
@ -3,7 +3,7 @@
|
|||
|
||||
bt.register_action("Destroy", {
|
||||
tick = function(node, data)
|
||||
print("Destroying target")
|
||||
-- debug -- print("Destroying target")
|
||||
if data.targetPos == nil then
|
||||
return "failed"
|
||||
end
|
||||
|
@ -41,7 +41,7 @@ bt.register_action("BashWalls", {
|
|||
|
||||
bt.register_action("SetFire", {
|
||||
tick = function(node, data)
|
||||
print("setting fire to target")
|
||||
-- debug -- print("setting fire to target")
|
||||
if data.targetPos == nil then
|
||||
return "failed"
|
||||
end
|
||||
|
@ -102,7 +102,7 @@ bt.register_action("IsNode", {
|
|||
|
||||
bt.register_action("ExtinguishFire", {
|
||||
tick = function(node, data)
|
||||
print("Extinguishing nearby fire")
|
||||
-- debug -- print("Extinguishing nearby fire")
|
||||
|
||||
local pos = minetest.find_node_near(data.pos, data.mob.reach, {"fire:basic_flame"})
|
||||
if pos == nil then
|
||||
|
@ -120,13 +120,13 @@ bt.register_action("DigNode", {
|
|||
tick = function(node, data)
|
||||
|
||||
if data.targetPos == nil then
|
||||
print("! [DigNode] no target position\n")
|
||||
-- debug -- print("! [DigNode] no target position\n")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
local n = minetest.get_node_or_nil(data.targetPos)
|
||||
if n == nil then
|
||||
print("! [DigNode] node is nil\n")
|
||||
-- debug -- print("! [DigNode] node is nil\n")
|
||||
return "success"
|
||||
end
|
||||
|
||||
|
@ -144,25 +144,25 @@ bt.register_action("DigNode", {
|
|||
bt.register_action("PutInChest", {
|
||||
tick = function(node, data)
|
||||
if data.targetPos == nil then
|
||||
print("! [PutInChest] no target position\n")
|
||||
-- debug -- print("! [PutInChest] no target position\n")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
local inv = minetest.get_inventory({type="node", pos=data.targetPos})
|
||||
if inv == nil then
|
||||
print("! [PutInChest] failed to get inv for "..dump(data.targetPos).."\n")
|
||||
-- debug -- print("! [PutInChest] failed to get inv for "..dump(data.targetPos).."\n")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
local list = data.inv:get_list("main")
|
||||
if list == nil then
|
||||
print("@ [PutInChest] main list is nil\n")
|
||||
-- debug -- print("@ [PutInChest] main list is nil\n")
|
||||
return "success"
|
||||
end
|
||||
local to_move = {}
|
||||
for k,i in ipairs(list) do
|
||||
if node.sel == nil or i:get_name() == node.sel then
|
||||
print("adding item")
|
||||
-- debug -- print("adding item")
|
||||
inv:add_item("main", i)
|
||||
list[k] = nil
|
||||
--table.insert(to_move, i)
|
||||
|
@ -183,19 +183,19 @@ bt.register_action("PutInChest", {
|
|||
bt.register_action("RobChestRandom", {
|
||||
tick = function(node, data)
|
||||
if data.targetPos == nil then
|
||||
print("! [RobChestRandom] no target position\n")
|
||||
-- debug -- print("! [RobChestRandom] no target position\n")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
local inv = minetest.get_inventory({type="node", pos=data.targetPos})
|
||||
if inv == nil then
|
||||
print("! [RobChestRandom] failed to get inv for "..dump(data.targetPos).."\n")
|
||||
-- debug -- print("! [RobChestRandom] failed to get inv for "..dump(data.targetPos).."\n")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
local mainsz = inv:get_size("main")
|
||||
if mainsz == nil then
|
||||
print("@ [RobChestRandom] main list is nil\n")
|
||||
-- debug -- print("@ [RobChestRandom] main list is nil\n")
|
||||
return "success"
|
||||
end
|
||||
|
||||
|
@ -239,7 +239,7 @@ bt.register_action("RobChestRandom", {
|
|||
|
||||
bt.register_action("Die", {
|
||||
tick = function(node, data)
|
||||
print("Dying now")
|
||||
-- debug -- print("Dying now")
|
||||
|
||||
-- TODO: remove inv and global data
|
||||
|
||||
|
@ -295,7 +295,7 @@ bt.register_action("PickUpNearbyItems", {
|
|||
|
||||
bt.register_action("Punch", {
|
||||
tick = function(node, data)
|
||||
print("Punching with " .. node.tool)
|
||||
-- debug -- print("Punching with " .. node.tool)
|
||||
|
||||
if data.targetPos == nil then
|
||||
return "failed"
|
||||
|
@ -303,7 +303,7 @@ bt.register_action("Punch", {
|
|||
|
||||
local ret = data.mob.object:set_wielded_item(node.tool)
|
||||
if ret == false then
|
||||
print("failed to set tool")
|
||||
-- debug -- print("failed to set tool")
|
||||
return "failed"
|
||||
end
|
||||
local n = minetest.get_node(data.targetPos)
|
||||
|
|
|
@ -28,7 +28,7 @@ bt.register_action("Sequence", {
|
|||
|
||||
-- tick the current node
|
||||
ret = bt.tick(cn, data)
|
||||
print(" sequence '"..node.name.."' got status ["..ret.."] from kid "..node.current_kid)
|
||||
-- debug -- print(" sequence '"..node.name.."' got status ["..ret.."] from kid "..node.current_kid)
|
||||
if ret == "running" or ret == "failed" then
|
||||
return ret
|
||||
end
|
||||
|
@ -70,13 +70,13 @@ bt.register_action("Selector", {
|
|||
|
||||
-- reset fresh nodes
|
||||
if ret == "failed" then
|
||||
print("resetting kid "..node.current_kid)
|
||||
-- debug -- print("resetting kid "..node.current_kid)
|
||||
bt.reset(cn, data)
|
||||
end
|
||||
|
||||
-- tick the current node
|
||||
ret = bt.tick(cn, data)
|
||||
print(" selector '"..node.name.."' got status ["..ret.."] from kid "..node.current_kid)
|
||||
-- debug -- print(" selector '"..node.name.."' got status ["..ret.."] from kid "..node.current_kid)
|
||||
if ret == "running" or ret == "success" then
|
||||
return ret
|
||||
end
|
||||
|
@ -89,7 +89,7 @@ bt.register_action("Selector", {
|
|||
end,
|
||||
|
||||
reset = function(node, data)
|
||||
print("selector resetting")
|
||||
-- debug -- print("selector resetting")
|
||||
node.current_kid = -1
|
||||
end,
|
||||
|
||||
|
@ -132,13 +132,13 @@ bt.register_action("Priority", {
|
|||
|
||||
-- reset fresh nodes
|
||||
if ret == "failed" then
|
||||
print("resetting kid "..node.current_kid)
|
||||
-- debug -- print("resetting kid "..node.current_kid)
|
||||
bt.reset(cn, data)
|
||||
end
|
||||
|
||||
-- tick the current node
|
||||
ret = bt.tick(cn, data)
|
||||
print(" selector '"..node.name.."' got status ["..ret.."] from kid "..node.current_kid)
|
||||
-- debug -- print(" selector '"..node.name.."' got status ["..ret.."] from kid "..node.current_kid)
|
||||
if ret == "running" or ret == "success" then
|
||||
return ret
|
||||
end
|
||||
|
@ -151,7 +151,7 @@ bt.register_action("Priority", {
|
|||
end,
|
||||
|
||||
reset = function(node, data)
|
||||
print("priority resetting - PRIORITY IS BROKEN")
|
||||
-- debug -- print("priority resetting - PRIORITY IS BROKEN")
|
||||
node.current_kid = -1
|
||||
node.fallback_kid = -1
|
||||
end,
|
||||
|
@ -294,7 +294,7 @@ bt.register_action("Random", {
|
|||
|
||||
reset = function(node, data)
|
||||
node.chosen_kid = math.random(1, table.getn(node.kids))
|
||||
print("chosen: "..node.chosen_kid)
|
||||
-- debug -- print("chosen: "..node.chosen_kid)
|
||||
bt.reset(node.kids[node.chosen_kid], data)
|
||||
end,
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ bt.register_action("Approach", {
|
|||
|
||||
local d = distance(data.pos, data.targetPos)
|
||||
|
||||
print("dist: "..d)
|
||||
--print("dist: "..d)
|
||||
|
||||
if d <= node.dist then
|
||||
print("arrived at target")
|
||||
|
@ -20,11 +20,11 @@ bt.register_action("Approach", {
|
|||
|
||||
reset = function(node, data)
|
||||
if data.targetPos ~= nil then
|
||||
print("Approaching target ("..data.targetPos.x..","..data.targetPos.y..","..data.targetPos.z..")")
|
||||
-- debug -- print("Approaching target ("..data.targetPos.x..","..data.targetPos.y..","..data.targetPos.z..")")
|
||||
data.mob.destination = data.targetPos
|
||||
data.mob.approachDistance = node.dist
|
||||
else
|
||||
print("Approach: targetPos is nil")
|
||||
-- debug -- print("Approach: targetPos is nil")
|
||||
end
|
||||
end,
|
||||
|
||||
|
@ -46,7 +46,7 @@ bt.register_action("TryApproach", {
|
|||
local d = distance(data.pos, data.targetPos)
|
||||
|
||||
if d <= node.dist then
|
||||
print("arrived at target")
|
||||
-- debug -- print("arrived at target")
|
||||
node.last_d = nil
|
||||
return "success"
|
||||
end
|
||||
|
@ -73,11 +73,11 @@ bt.register_action("TryApproach", {
|
|||
node.last_d = nil
|
||||
|
||||
if data.targetPos ~= nil then
|
||||
print("Approaching target ("..data.targetPos.x..","..data.targetPos.y..","..data.targetPos.z..")")
|
||||
-- debug -- print("Approaching target ("..data.targetPos.x..","..data.targetPos.y..","..data.targetPos.z..")")
|
||||
data.mob.destination = data.targetPos
|
||||
data.mob.approachDistance = node.dist
|
||||
else
|
||||
print("Approach: targetPos is nil")
|
||||
-- debug -- print("Approach: targetPos is nil")
|
||||
end
|
||||
end,
|
||||
|
||||
|
@ -97,10 +97,10 @@ bt.register_action("FindPath", {
|
|||
|
||||
local d = distance(data.pos, data.targetPos)
|
||||
|
||||
print("dist: "..d)
|
||||
-- debug -- print("dist: "..d)
|
||||
|
||||
if d <= .1 then
|
||||
print("arrived at target")
|
||||
-- debug -- print("arrived at target")
|
||||
return "success"
|
||||
end
|
||||
|
||||
|
@ -114,7 +114,7 @@ bt.register_action("FindPath", {
|
|||
|
||||
data.mob.path = path
|
||||
else
|
||||
print("FindPath: targetPos is nil")
|
||||
-- debug -- print("FindPath: targetPos is nil")
|
||||
end
|
||||
end,
|
||||
|
||||
|
|
|
@ -15,17 +15,19 @@ bt.register_action("FindNodeInRange", {
|
|||
return
|
||||
end
|
||||
local list = minetest.find_nodes_in_area(r.min, r.max, node.sel)
|
||||
--[[
|
||||
print("searching for node in region "..node.sel[1].."\n")
|
||||
print("search range: y="..r.min.y.." @ "..
|
||||
"["..r.min.x..", "..r.min.y..", "..r.min.z.."], "..
|
||||
"["..r.max.x..", "..r.max.y..", "..r.max.z.."]\n")
|
||||
print("found "..#list.." nodes\n")
|
||||
]]
|
||||
if list ~= nil and #list > 0 then
|
||||
node.regionEmpty = false
|
||||
local n = list[1]
|
||||
local node = minetest.get_node(n)
|
||||
print("name: " .. node.name .. "\n")
|
||||
print("targeting node ["..n.x..", "..n.y..", "..n.z.."]\n")
|
||||
-- debug -- print("name: " .. node.name .. "\n")
|
||||
-- debug -- print("targeting node ["..n.x..", "..n.y..", "..n.z.."]\n")
|
||||
data.targetPos = n
|
||||
else
|
||||
node.regionEmpty = true
|
||||
|
@ -44,7 +46,7 @@ bt.register_action("FindNodeInRange", {
|
|||
bt.register_action("FindPerimeterNodeInRegion", {
|
||||
tick = function(node, data)
|
||||
if data.region == nil or node.regionEmpty == true then
|
||||
print("could not find edge node in active region")
|
||||
-- debug -- print("could not find edge node in active region")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
|
@ -74,8 +76,8 @@ bt.register_action("FindPerimeterNodeInRegion", {
|
|||
if list ~= nil and #list > 0 then
|
||||
local n = list[1]
|
||||
local node = minetest.get_node(n)
|
||||
print("name: " .. node.name .. "\n")
|
||||
print("targeting node ["..n.x..", "..n.y..", "..n.z.."]\n")
|
||||
-- debug -- print("name: " .. node.name .. "\n")
|
||||
-- debug -- print("targeting node ["..n.x..", "..n.y..", "..n.z.."]\n")
|
||||
data.targetPos = n
|
||||
|
||||
return
|
||||
|
@ -94,8 +96,8 @@ bt.register_action("FindPerimeterNodeInRegion", {
|
|||
if list ~= nil and #list > 0 then
|
||||
local n = list[1]
|
||||
local node = minetest.get_node(n)
|
||||
print("name: " .. node.name .. "\n")
|
||||
print("targeting node ["..n.x..", "..n.y..", "..n.z.."]\n")
|
||||
-- debug -- print("name: " .. node.name .. "\n")
|
||||
-- debug -- print("targeting node ["..n.x..", "..n.y..", "..n.z.."]\n")
|
||||
data.targetPos = n
|
||||
|
||||
return
|
||||
|
@ -115,8 +117,8 @@ bt.register_action("FindPerimeterNodeInRegion", {
|
|||
if list ~= nil and #list > 0 then
|
||||
local n = list[1]
|
||||
local node = minetest.get_node(n)
|
||||
print("name: " .. node.name .. "\n")
|
||||
print("targeting node ["..n.x..", "..n.y..", "..n.z.."]\n")
|
||||
-- debug -- print("name: " .. node.name .. "\n")
|
||||
-- debug -- print("targeting node ["..n.x..", "..n.y..", "..n.z.."]\n")
|
||||
data.targetPos = n
|
||||
|
||||
return
|
||||
|
@ -135,8 +137,8 @@ bt.register_action("FindPerimeterNodeInRegion", {
|
|||
if list ~= nil and #list > 0 then
|
||||
local n = list[1]
|
||||
local node = minetest.get_node(n)
|
||||
print("name: " .. node.name .. "\n")
|
||||
print("targeting node ["..n.x..", "..n.y..", "..n.z.."]\n")
|
||||
-- debug -- print("name: " .. node.name .. "\n")
|
||||
-- debug -- print("targeting node ["..n.x..", "..n.y..", "..n.z.."]\n")
|
||||
data.targetPos = n
|
||||
|
||||
return
|
||||
|
@ -160,7 +162,7 @@ bt.register_action("FindPerimeterNodeInRegion", {
|
|||
bt.register_action("ScaleRegion", {
|
||||
tick = function(node, data)
|
||||
if data.region == nil then
|
||||
print("no active region")
|
||||
-- debug -- print("no active region")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
|
@ -179,10 +181,11 @@ bt.register_action("ScaleRegion", {
|
|||
}
|
||||
|
||||
r = data.region
|
||||
--[[
|
||||
print("region scaled to: y="..r.min.y.." @ "..
|
||||
"["..r.min.x..", "..r.min.y..", "..r.min.z.."], "..
|
||||
"["..r.max.x..", "..r.max.y..", "..r.max.z.."]\n")
|
||||
|
||||
]]
|
||||
end,
|
||||
|
||||
ctor = function(scale)
|
||||
|
@ -196,7 +199,7 @@ bt.register_action("ScaleRegion", {
|
|||
bt.register_action("MoveRegion", {
|
||||
tick = function(node, data)
|
||||
if data.region == nil then
|
||||
print("no active region")
|
||||
-- debug -- print("no active region")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
|
@ -215,10 +218,11 @@ bt.register_action("MoveRegion", {
|
|||
}
|
||||
|
||||
r = data.region
|
||||
--[[
|
||||
print("region moved to: y="..r.min.y.." @ "..
|
||||
"["..r.min.x..", "..r.min.y..", "..r.min.z.."], "..
|
||||
"["..r.max.x..", "..r.max.y..", "..r.max.z.."]\n")
|
||||
|
||||
]]
|
||||
end,
|
||||
|
||||
ctor = function(scale)
|
||||
|
@ -233,7 +237,7 @@ bt.register_action("MoveRegion", {
|
|||
bt.register_action("FindRegionAround", {
|
||||
tick = function(node, data)
|
||||
if data.targetPos == nil then
|
||||
print("could not find spot on ground")
|
||||
-- debug -- print("could not find spot on ground")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
|
@ -250,9 +254,11 @@ bt.register_action("FindRegionAround", {
|
|||
max= {x=tp.x + node.radius, y=tp.y, z=tp.z + node.radius},
|
||||
}
|
||||
|
||||
--[[
|
||||
print("range set to y="..tp.y.." @ "..
|
||||
"["..data.region.min.x..", "..data.region.min.z.."], "..
|
||||
"["..data.region.max.x..", "..data.region.max.z.."]\n")
|
||||
]]
|
||||
end
|
||||
end,
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
bt.register_action("FindNodeNear", {
|
||||
tick = function(node, data)
|
||||
if data.targetPos == nil then
|
||||
print("could not find node near")
|
||||
-- debug -- print("could not find node near")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
|
@ -25,7 +25,7 @@ bt.register_action("FindNodeNear", {
|
|||
bt.register_action("FindSpotOnGround", {
|
||||
tick = function(node, data)
|
||||
if data.targetPos == nil then
|
||||
print("could not find spot on ground")
|
||||
-- debug -- print("could not find spot on ground")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
|
@ -62,7 +62,7 @@ end
|
|||
function vector_normalize(a)
|
||||
local len = vector_len(a)
|
||||
if len == 0 then
|
||||
print("attempting to normalize zero-length vector\n")
|
||||
-- debug -- print("attempting to normalize zero-length vector\n")
|
||||
len = 1 -- just do something kinda sorta sane so we don't div/0.
|
||||
end
|
||||
return {
|
||||
|
@ -80,12 +80,12 @@ end
|
|||
bt.register_action("DirectionTo", {
|
||||
tick = function(node, data)
|
||||
if data.targetPos == nil then
|
||||
print("no target position\n")
|
||||
-- debug -- print("no target position\n")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
if data.waypoints[node.wpname] == nil then
|
||||
print("no such waypoint: " .. node.wpname .. "\n")
|
||||
-- debug -- print("no such waypoint: " .. node.wpname .. "\n")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
|
@ -120,7 +120,7 @@ bt.register_action("RandomDirection", {
|
|||
bt.register_action("MoveInDirection", {
|
||||
tick = function(node, data)
|
||||
if data.direction == nil then
|
||||
print("no current direction \n")
|
||||
-- debug -- print("no current direction \n")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
|
@ -145,12 +145,12 @@ bt.register_action("MoveInDirection", {
|
|||
bt.register_action("MoveInDirectionFromWaypoint", {
|
||||
tick = function(node, data)
|
||||
if data.waypoints[node.wpname] == nil then
|
||||
print("no such waypoint: " .. node.wpname .. "\n")
|
||||
-- debug -- print("no such waypoint: " .. node.wpname .. "\n")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
if data.direction == nil then
|
||||
print("no current direction \n")
|
||||
-- debug -- print("no current direction \n")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
|
@ -178,7 +178,7 @@ bt.register_action("MoveInDirectionFromWaypoint", {
|
|||
bt.register_action("FindNewNodeNear", {
|
||||
tick = function(node, data)
|
||||
if data.targetPos == nil then
|
||||
print("could not find node near")
|
||||
-- debug -- print("could not find node near")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
|
@ -236,10 +236,10 @@ bt.register_action("FindPath", {
|
|||
|
||||
local d = distance(data.pos, data.targetPos)
|
||||
|
||||
print("dist: "..d)
|
||||
-- debug -- print("dist: "..d)
|
||||
|
||||
if d <= .1 then
|
||||
print("arrived at target")
|
||||
-- debug -- print("arrived at target")
|
||||
return "success"
|
||||
end
|
||||
|
||||
|
@ -253,7 +253,7 @@ bt.register_action("FindPath", {
|
|||
|
||||
data.mob.path = path
|
||||
else
|
||||
print("FindPath: targetPos is nil")
|
||||
-- debug -- print("FindPath: targetPos is nil")
|
||||
end
|
||||
end,
|
||||
|
||||
|
@ -331,7 +331,7 @@ bt.register_action("AddToVisited", {
|
|||
bt.register_action("FindAreaCorners", {
|
||||
tick = function(node, data)
|
||||
if data.targetPos == nil then
|
||||
print("could not find spot on ground")
|
||||
-- debug -- print("could not find spot on ground")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
|
@ -361,7 +361,7 @@ bt.register_action("FindAreaCorners", {
|
|||
bt.register_action("MoveTarget", {
|
||||
tick = function(node, data)
|
||||
if data.targetPos == nil then
|
||||
print("no active target")
|
||||
-- debug -- print("no active target")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
|
@ -389,7 +389,7 @@ bt.register_action("MoveTarget", {
|
|||
bt.register_action("MoveTargetRandom", {
|
||||
tick = function(node, data)
|
||||
if data.targetPos == nil then
|
||||
print("no active target")
|
||||
-- debug -- print("no active target")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
|
@ -419,8 +419,8 @@ bt.register_action("FindGroupCampfire", {
|
|||
tick = function(node, data)
|
||||
if data.groupID ~= nil then -- already has a group
|
||||
if mobehavior.groupData[data.groupID] ~= nil then
|
||||
print("@ joined group " .. data.groupID .. "\n")
|
||||
print(dump(mobehavior.groupData[data.groupID]))
|
||||
-- debug -- print("@ joined group " .. data.groupID .. "\n")
|
||||
-- debug -- print(dump(mobehavior.groupData[data.groupID]))
|
||||
return "success"
|
||||
end
|
||||
end
|
||||
|
@ -430,18 +430,18 @@ bt.register_action("FindGroupCampfire", {
|
|||
local key = cf.x..":"..cf.y..":"..cf.z
|
||||
|
||||
if mobehavior.groupData[key] == nil then
|
||||
print(dump(mobehavior))
|
||||
-- debug -- print(dump(mobehavior))
|
||||
-- print(dump(mobehavior.groupData))
|
||||
print("! failed to find group for key "..key.."\n")
|
||||
-- debug -- print("! failed to find group for key "..key.."\n")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
data.groupID = key
|
||||
print("@ joined group 2 " .. key .. "\n")
|
||||
print(dump(mobehavior.groupData[data.groupID]))
|
||||
-- debug -- print("@ joined group 2 " .. key .. "\n")
|
||||
-- debug -- print(dump(mobehavior.groupData[data.groupID]))
|
||||
return "success"
|
||||
else
|
||||
print("! failed to find group\n")
|
||||
-- debug -- print("! failed to find group\n")
|
||||
return "failed"
|
||||
end
|
||||
end,
|
||||
|
|
|
@ -78,8 +78,8 @@ bt.register_action("GetGroupWaypoint", {
|
|||
or mobehavior.groupData[data.groupID].waypoints == nil
|
||||
or mobehavior.groupData[data.groupID].waypoints[node.wpname] == nil then
|
||||
|
||||
print(dump(mobehavior.groupData[data.groupID]))
|
||||
print("! failed to find group ("..data.groupID..") waypoint " .. node.wpname .. "\n")
|
||||
-- debug -- print(dump(mobehavior.groupData[data.groupID]))
|
||||
-- debug -- print("! failed to find group ("..data.groupID..") waypoint " .. node.wpname .. "\n")
|
||||
return "failed"
|
||||
end
|
||||
|
||||
|
|
56
entities.lua
56
entities.lua
|
@ -236,3 +236,59 @@ end
|
|||
|
||||
|
||||
|
||||
|
||||
function make_NPC(name, behavior_fn)
|
||||
|
||||
mobs:register_simple_mob(mn..":"..name, {
|
||||
type = "monster",
|
||||
passive = false,
|
||||
attack_type = "dogfight",
|
||||
reach = 2,
|
||||
damage = 1,
|
||||
hp_min = 4,
|
||||
hp_max = 20,
|
||||
armor = 100,
|
||||
collisionbox = {-0.35,-1.0,-0.35, 0.35,0.8,0.35},
|
||||
visual = "mesh",
|
||||
mesh = "character.b3d",
|
||||
drawtype = "front",
|
||||
textures = {
|
||||
{"mobs_npc.png"},
|
||||
},
|
||||
makes_footstep_sound = true,
|
||||
walk_velocity = 1.5,
|
||||
run_velocity = 4,
|
||||
view_range = 15,
|
||||
jump = true,
|
||||
floats = 0,
|
||||
drops = {
|
||||
{name = "default:iron_lump",
|
||||
chance = 1, min = 3, max = 5},
|
||||
},
|
||||
water_damage = 0,
|
||||
lava_damage = 4,
|
||||
light_damage = 0,
|
||||
fear_height = 3,
|
||||
animation = {
|
||||
speed_normal = 30,
|
||||
speed_run = 30,
|
||||
stand_start = 0,
|
||||
stand_end = 79,
|
||||
walk_start = 168,
|
||||
walk_end = 187,
|
||||
run_start = 168,
|
||||
run_end = 187,
|
||||
punch_start = 200,
|
||||
punch_end = 219,
|
||||
},
|
||||
|
||||
pre_activate = function(self, s,d)
|
||||
self.bt = bt.Repeat("root", nil, {
|
||||
behavior_fn();
|
||||
})
|
||||
|
||||
end
|
||||
})
|
||||
|
||||
mobs:register_egg(mn..":"..name, name, "default_grass.png", 1)
|
||||
end
|
||||
|
|
38
giant.lua
38
giant.lua
|
@ -476,28 +476,6 @@ end
|
|||
|
||||
|
||||
|
||||
local sdfadsf = function(name, behavior_fn)
|
||||
|
||||
mobs:register_simple_mob(mn..":"..name, {
|
||||
|
||||
|
||||
|
||||
|
||||
on_rightclick = function(self, clicker)
|
||||
|
||||
end,
|
||||
pre_activate = function(self, s,d)
|
||||
self.bt = bt.Repeat("root", nil, {
|
||||
behavior_fn();
|
||||
})
|
||||
|
||||
end
|
||||
})
|
||||
|
||||
mobs:register_egg(mn..":"..name, name.." Egg", "default_desert_sand.png", 1)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -520,18 +498,8 @@ end)
|
|||
make_bear("bear", function()
|
||||
return wander_around(6)
|
||||
end)
|
||||
--[[
|
||||
make_giant("lumberjack", function()
|
||||
return lumberjack()
|
||||
|
||||
make_NPC("npc", function()
|
||||
return wander_around(6)
|
||||
end)
|
||||
|
||||
make_giant("digger", function()
|
||||
return dig_hole({"default:dirt", "default:dirt_with_grass", "default:sand", "default:stone"})
|
||||
end)]]
|
||||
|
||||
|
||||
|
||||
|
||||
--mobs:register_spawn(mn..":giant", {"default:desert_sand"}, 20, 0, 7000, 2, 31000)
|
||||
|
||||
--mobs:register_egg(mn..":giant", "Giant", "default_desert_sand.png", 1)
|
||||
|
|
4
init.lua
4
init.lua
|
@ -44,7 +44,9 @@ dofile(path.."/simple_api.lua")
|
|||
|
||||
dofile(path.."/scripts/init.lua")
|
||||
dofile(path.."/entities.lua")
|
||||
dofile(path.."/giant.lua")
|
||||
dofile(path.."/giant.lua")
|
||||
|
||||
dofile(path.."/spawning.lua")
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ minetest.register_entity(name, {
|
|||
|
||||
if self.bt_timer > 2 then
|
||||
|
||||
print("\n<<< start >>>")
|
||||
-- debug -- print("\n<<< start >>>")
|
||||
|
||||
-- inventories cannot be serialized and cause the game to crash if
|
||||
-- placed in the entity's table
|
||||
|
@ -143,7 +143,7 @@ minetest.register_entity(name, {
|
|||
btdata.inv = inv
|
||||
|
||||
bt.tick(self.bt, btdata)
|
||||
print("<<< end >>>\n")
|
||||
-- debug -- print("<<< end >>>\n")
|
||||
|
||||
-- so clear it out after running the behavior trees
|
||||
btdata.inv = nil
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
-- rats
|
||||
minetest.register_abm({
|
||||
nodenames = {
|
||||
"default:dirt",
|
||||
"default:dirt_with_grass",
|
||||
"seasons:spring_default_dirt_with_grass",
|
||||
"seasons:fall_default_dirt_with_grass",
|
||||
"seasons:winter_default_dirt_with_grass",
|
||||
"default:dirt_with_rainforest_litter",
|
||||
"default:dirt_with_coniferous_litter",
|
||||
"default:desert_sand",
|
||||
"default:silver_sand",
|
||||
},
|
||||
neighbors = {"air"},
|
||||
interval = 2,
|
||||
chance = 10,
|
||||
catch_up = false,
|
||||
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if active_object_count_wider > 0 then
|
||||
--print("too many local objs")
|
||||
return
|
||||
end
|
||||
|
||||
local nearobjs = minetest.get_objects_inside_radius(pos, 10)
|
||||
if #nearobjs > 5 then
|
||||
-- print("too many near objs")
|
||||
return
|
||||
end
|
||||
|
||||
--print("----------spawning rat")
|
||||
local p = minetest.find_node_near(pos, 3, "air")
|
||||
if p then
|
||||
local mob = minetest.add_entity(p, "mobehavior:rat")
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- wolves
|
||||
minetest.register_abm({
|
||||
nodenames = {
|
||||
"default:dirt_with_coniferous_litter",
|
||||
},
|
||||
neighbors = {"air"},
|
||||
interval = 2,
|
||||
chance = 10,
|
||||
catch_up = false,
|
||||
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if active_object_count_wider > 0 then
|
||||
--print("too many local objs")
|
||||
return
|
||||
end
|
||||
|
||||
local nearobjs = minetest.get_objects_inside_radius(pos, 20)
|
||||
if #nearobjs > 3 then
|
||||
-- print("too many near objs")
|
||||
return
|
||||
end
|
||||
|
||||
--print("----------spawning rat")
|
||||
local p = minetest.find_node_near(pos, 3, "air")
|
||||
if p then
|
||||
local mob = minetest.add_entity(p, "mobehavior:wolf")
|
||||
end
|
||||
end
|
||||
})
|
Loading…
Reference in New Issue