new ko stone, and proper board area search for removing smoke fx and ko stones

master
capitalthree 6 months ago
parent 141a6e6697
commit 655ffa5c9a
  1. 52
      rules.lua
  2. 60
      stones.lua

@ -182,6 +182,40 @@ local function connected_search(pos, final_result, early_termination_filter)
return final_result
end
local function board_clear_fx(basepos)
local group = {basepos}
local checked = {[minetest.hash_node_position(basepos)] = basepos}
local probe = 0
while probe < #group do
probe = probe + 1
local pos = group[probe]
for i,v in pairs(neighbor_dirs(pos)) do
local newpos = pos + directions[v]
if (math.abs(newpos.x - basepos.x) <= 18) and (math.abs(newpos.z - basepos.z) <= 18) then
local newhash = minetest.hash_node_position(newpos)
local groups = minetest.registered_nodes[minetest.get_node(newpos).name].groups
if groups then
if groups.ko_stone then
nodecore.set_loud(newpos, {name = "air"})
elseif groups.go_stone then
smokecontrol(newpos)
end
end
if (not checked[newhash]) then
group[#group+1] = newpos
checked[newhash] = true
end
end
end
end
end
local function _check_captures_filter(node, count)
if (count > global_search_maximum) or (node:sub(1, 1) == "E") then
return {capture = false}
@ -336,13 +370,7 @@ function lc_liberties.handle_placement(pos)
end
end
for x=pos.x-18, pos.x+18 do
for z=pos.z-18, pos.z+18 do
if (x ~= pos.x) or (z ~= pos.z) then
smokecontrol({x = x, y = pos.y, z = z})
end
end
end
board_clear_fx(pos)
smokecontrol(pos, 300, 2+#allcaptured)
@ -424,3 +452,13 @@ function lc_liberties.handle_dig(pos, node, digger)
return minetest.node_dig(pos, node, digger)
end
end
function lc_liberties.handle_click_ko(pos, node, clicker, itemstack, pointed_thing)
local handnode = minetest.registered_nodes[itemstack:get_name()]
if handnode and handnode.groups.go_stone and
handnode.go_team ~= minetest.registered_nodes[node.name].go_team then
nodecore.set_loud(pos, {name = handnode.name})
itemstack:set_count(itemstack:get_count() - 1)
end
return itemstack
end

@ -31,17 +31,16 @@ local function reg(name, basename, basedef)
if minetest.registered_nodes[piecename] then return end
local desc = basedef.description or name
local nodeDesc
local nodedesc_base
local nameStone = string.match(desc, "(.*)stone$")
if nameStone then
nodeDesc = nameStone .. " "
nodedesc_base = nameStone .. " "
elseif desc == "Stone" then
nodeDesc = ""
nodedesc_base = ""
else
nodeDesc = desc .. " "
nodedesc_base = desc .. " "
end
nodeDesc = nodeDesc .. "Go Stone"
local stone_selection_box = {
type = "fixed",
@ -49,7 +48,7 @@ local function reg(name, basename, basedef)
}
minetest.register_node(":" .. piecename, {
description = nodeDesc,
description = nodedesc_base .. "Go Stone",
drawtype = "mesh",
mesh = "go_stone.obj",
@ -88,8 +87,7 @@ local function reg(name, basename, basedef)
fixed = {-5/16, -8/16, -5/16, 5/16, -2/16, 5/16}
}
local territory_name = modname .. ":territory_" .. string_lower(name)
minetest.register_node(":" .. territory_name, {
minetest.register_node(":" .. modname .. ":territory_" .. string_lower(name), {
description = "Stop Stone",
drawtype = "nodebox",
@ -130,6 +128,52 @@ local function reg(name, basename, basedef)
on_dig = lc_liberties.handle_dig,
})
local ko_selection_box = {
type = "fixed",
fixed = {-8/16, -8/16, -8/16, 8/16, -4/16, 8/16}
}
minetest.register_node(":" .. modname .. ":ko_" .. string_lower(name), {
description = nodedesc_base .. "Ko Stone",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-7/16, -7/16, -7/16, 7/16, -5/16, -5/16},
{7/16, -7/16, -7/16, 5/16, -5/16, 7/16},
{7/16, -7/16, 7/16, -7/16, -5/16, 5/16},
{-7/16, -7/16, 7/16, -5/16, -5/16, -7/16},
}
},
selection_box = ko_selection_box,
collision_box = ko_selection_box,
tiles = {basedef.tiles[1]},
paramtype = "light",
sunlight_propagates = true,
groups = {
snappy = 1,
falling_node = 1,
stack_as_node = 1,
ko_stone = 1,
cheat = 1,
},
drop = "",
destroy_on_dig = true,
silktouch = false,
go_team = name,
sounds = basedef.sounds,
on_rightclick = lc_liberties.handle_click_ko,
})
reg_stone_craft(name, "crossy")
reg_stone_craft(name, "starcrossy")

Loading…
Cancel
Save