Compare commits

..

33 Commits

Author SHA1 Message Date
capitalthree 197257b559 add pseudoexponential decay to last-move smoke intensity (so it doesn't stay intense indefinitely after a large capture) 8 months ago
capitalthree e79655e851 prototype of persistent smoke 8 months ago
capitalthree 6d17da9f72 changing workspaces (partial work on improved smoke) 8 months ago
capitalthree bb41211163 factored out nodedefs with underride 1 year ago
capitalthree 0b24f22b71 add mapcolors to nodes. The difficult decision was made to make meta-markers invisible on map, to maximize readability of actual stone positions at low zoom levels 1 year ago
capitalthree a5a1c69975 clear all smoke when clearing smoke, including captured stone smoke 1 year ago
capitalthree 670388bed7 aaa I screwed up. fix crafting markers 1 year ago
capitalthree 7ab28611c5 place ko blockers as appropriate 1 year ago
capitalthree 655ffa5c9a new ko stone, and proper board area search for removing smoke fx and ko stones 1 year ago
capitalthree 141a6e6697 handle smoke removal with on_destruct 1 year ago
capitalthree f08ed693cf smoke effect for captures, on captured stones, and increased smoke for capturing stone 1 year ago
capitalthree 0a2a4e4cda stop stones will default to placing a single stone, and matching color, if placed on top of a go stone 1 year ago
capitalthree 1c66e4e6c5 do placement sound on overridden stop stone placement behavior 1 year ago
capitalthree 032cb586fa more puns to hopefully please warr so we can be on ncc! 1 year ago
capitalthree 853519c335 better second hint req 1 year ago
capitalthree 33510cf32a hints! 1 year ago
capitalthree 07c7ec00f8 rip nodebox rendering, you will be missed, but yay hexagons! also naming clarification (all stones now say "Go" in the name) 1 year ago
capitalthree 02163d903b territory markers properly defer to all node rightclick actions rather than specialcasing stacks, overridden with sneak 1 year ago
capitalthree 8fb6fcc381 sneak works in addition to aux1, for inverting pickup-as-group or placing single territory markers 1 year ago
capitalthree cbc2d2c1a7 enable smoke effects only if nodecore.smokeclear is present, to prevent bad behavior on current nodecore stable 1 year ago
capitalthree bcf19f8096 territory markers don't fall (to allow use as longer-term last-played-stone indicator) 1 year ago
capitalthree 3ef3425261 better fire effect, and apply smoke even when making a capture 1 year ago
capitalthree ad6d4c9c67 proper smoke handling (maybe), and nice restacking of tokens grabbed as group 1 year ago
capitalthree b1828a3e4c simplified collision box matching selection box 1 year ago
lizzie 3bd9a68534 Merge pull request 'Use edgy on the sides of corny' (#5) from Warr1024/lc_liberties:cornedgy into master 1 year ago
Aaron Suen e00bdba953 Use edgy on the sides of corny 1 year ago
capitalthree 300ec81e08 testing last-played-stone smoke effect, based on experimental function added to nodecore 1 year ago
capitalthree 625b3e9fa1 enable search depth limit in all search types, and limit previously-unlimited searches to 361 spaces (the size of a 19x19 board) 1 year ago
capitalthree f72072fd0e invert goban corners/edges... I'm so sorry to change this after release, but it was done for 2 reasons: 1 year ago
capitalthree 651ac2fc54 improved/optimized go stone nodebox from wolfie, and optimized placement marker nodebox 1 year ago
capitalthree 1848d03b5c no place prediction for territory markers (since they are picky about allowing placement and might change color) 1 year ago
capitalthree d788495988 enable crafting go stones with crossy as well as starcrossy 1 year ago
capitalthree 78da25d42b territory marker changes/fixes: now stack_as_node. now pickup as group by default. now correctly right-clicks into existing stack. go stone now blocks optics 1 year ago
  1. 22
      abm.lua
  2. 25
      goban.lua
  3. 7
      hints.lua
  4. 2
      init.lua
  5. 158
      models/go_stone.obj
  6. 255
      rules.lua
  7. 173
      stones.lua
  8. BIN
      textures/nc_concrete_pattern_corny.png
  9. BIN
      textures/nc_concrete_pattern_edgy.png

@ -0,0 +1,22 @@
-- LUALOCALS < ---------------------------------------------------------
local include, nodecore, math
= include, nodecore, math
-- LUALOCALS > ---------------------------------------------------------
minetest.register_abm({
label = "go smoke",
interval = 15,
chance = 1,
nodenames = {"group:go_stone"},
action = function(pos, node)
if not (node.param2 == 0) then
-- if smoke level is higher than 1, it can decay (lazy pseudoexponential decay)
if math.random() < (0.01 * (node.param2 - 1)) then
node.param2 = node.param2 - 1
minetest.swap_node(pos, node)
end
nodecore.smokefx(pos, 60, node.param2)
end
end
})

@ -3,7 +3,30 @@ local include, nodecore
= include, nodecore = include, nodecore
-- LUALOCALS > --------------------------------------------------------- -- LUALOCALS > ---------------------------------------------------------
local is_corny_pattern = {}
local function edgify(s)
return string.gsub(s, "nc_concrete_pattern_corny.png",
"nc_concrete_pattern_edgy.png")
end
nodecore.register_on_register_item(function(_, def)
if not def[is_corny_pattern] then return end
local tiles = def.tiles
if not tiles then return end
while #tiles < 6 do tiles[#tiles + 1] = tiles[#tiles] end
for i = 3, 6 do
local t = tiles[i]
if type(t) == "string" then
tiles[i] = edgify(t)
elseif type(t) == "table" and t.name then
t.name = edgify(t.name)
end
end
end)
nodecore.register_concrete_pattern({description = "Crossy"}) nodecore.register_concrete_pattern({description = "Crossy"})
nodecore.register_concrete_pattern({description = "Starcrossy"}) nodecore.register_concrete_pattern({description = "Starcrossy"})
nodecore.register_concrete_pattern({description = "Edgy", paramtype2 = "4dir"}) nodecore.register_concrete_pattern({description = "Edgy", paramtype2 = "4dir"})
nodecore.register_concrete_pattern({description = "Corny", paramtype2 = "4dir"}) nodecore.register_concrete_pattern({description = "Corny", paramtype2 = "4dir",
[is_corny_pattern] = true})

@ -0,0 +1,7 @@
-- LUALOCALS < ---------------------------------------------------------
local include, nodecore
= include, nodecore
-- LUALOCALS > ---------------------------------------------------------
nodecore.register_hint("chop scored cement into go stones", "chop stones", "toolcap:choppy:3")
nodecore.register_hint("smash go stones into stop stones, for scoring your games", "smash stones", "chop stones")

@ -8,3 +8,5 @@ lc_liberties = {}
include("goban") include("goban")
include("rules") include("rules")
include("stones") include("stones")
include("hints")
include("abm")

@ -0,0 +1,158 @@
# Blender 4.0.1
# www.blender.org
o Cylinder
v -0.266270 -0.410835 -0.266147
v -0.366339 -0.237928 -0.366242
v 0.097370 -0.410835 -0.363585
v 0.133951 -0.237928 -0.500295
v 0.363573 -0.410835 -0.097381
v 0.500188 -0.237928 -0.134057
v 0.266136 -0.410835 0.266259
v 0.366136 -0.237928 0.366233
v -0.097504 -0.410835 0.363696
v -0.134154 -0.237928 0.500286
v -0.363707 -0.410835 0.097493
v -0.500392 -0.237928 0.134048
v 0.097555 -0.065020 -0.363264
v -0.266085 -0.065020 -0.265827
v 0.363758 -0.065020 -0.097061
v 0.266321 -0.065020 0.266579
v -0.097319 -0.065020 0.364016
v -0.363522 -0.065020 0.097813
v -0.155787 -0.496897 -0.155636
v 0.056983 -0.496897 -0.212647
v 0.212741 -0.496897 -0.056889
v 0.155729 -0.496897 0.155880
v -0.057040 -0.496897 0.212891
v -0.212798 -0.496897 0.057133
v 0.057091 0.021041 -0.212460
v -0.155678 0.021041 -0.155448
v 0.212849 0.021041 -0.056702
v 0.155837 0.021041 0.156067
v -0.056932 0.021041 0.213079
v -0.212690 0.021041 0.057321
vn -0.2111 -0.5784 -0.7880
vn 0.5769 -0.5782 -0.5769
vn 0.7882 -0.5780 0.2112
vn 0.2112 -0.5779 0.7883
vn 0.5768 0.5785 -0.5768
vn -0.5770 -0.5781 0.5770
vn -0.7880 -0.5783 -0.2112
vn 0.5187 -0.8436 0.1390
vn -0.5187 0.8436 -0.1390
vn -0.5771 0.5778 0.5771
vn -0.2109 0.5795 -0.7872
vn 0.7888 0.5772 0.2114
vn -0.7875 0.5791 -0.2110
vn 0.2114 0.5768 0.7890
vn -0.0000 -1.0000 -0.0000
vn -0.5184 -0.8438 -0.1389
vn 0.1390 -0.8436 0.5187
vn 0.3795 -0.8437 -0.3795
vn -0.3796 -0.8437 0.3796
vn -0.1389 -0.8438 -0.5183
vn -0.0000 1.0000 -0.0000
vn 0.1389 0.8438 0.5183
vn 0.3796 0.8437 -0.3796
vn -0.3795 0.8437 0.3795
vn 0.5184 0.8438 0.1389
vn -0.1390 0.8436 -0.5187
vt 0.595545 0.188484
vt 0.679281 0.437142
vt 0.071110 0.438746
vt 0.153491 0.189649
vt 0.595530 0.188589
vt 0.679282 0.437228
vt 0.071110 0.438729
vt 0.153475 0.189680
vt 0.595518 0.188653
vt 0.679281 0.437236
vt 0.071110 0.438817
vt 0.153464 0.189802
vt 0.595589 0.188672
vt 0.679281 0.437239
vt 0.071110 0.438841
vt 0.153534 0.189835
vt 0.596340 0.686344
vt 0.154285 0.687435
vt 0.596927 0.189709
vt 0.679285 0.438736
vt 0.071113 0.437217
vt 0.154872 0.188605
vt 0.596904 0.189648
vt 0.679278 0.438723
vt 0.071107 0.437190
vt 0.154850 0.188534
vt 0.244613 0.001363
vt 0.503263 0.000690
vt 0.153902 0.686444
vt 0.595957 0.687558
vt 0.503717 0.875528
vt 0.245066 0.874876
vt 0.596103 0.687285
vt 0.154048 0.686181
vt 0.596746 0.686482
vt 0.154692 0.687648
vt 0.596505 0.686074
vt 0.154450 0.687224
vt 0.597011 0.686002
vt 0.154956 0.687166
vt 0.583942 0.501917
vt 0.420255 0.665604
vt 0.196654 0.605690
vt 0.136740 0.382090
vt 0.300427 0.218402
vt 0.524028 0.278316
vt 0.247090 0.000457
vt 0.505740 0.001108
vt 0.244764 0.001412
vt 0.503415 0.000731
vt 0.244625 0.001179
vt 0.503276 0.000540
vt 0.247131 0.000598
vt 0.505782 0.001244
vt 0.244673 0.001079
vt 0.503323 0.000397
vt 0.421104 0.668772
vt 0.194334 0.608010
vt 0.133572 0.381240
vt 0.299578 0.215234
vt 0.526348 0.275996
vt 0.587110 0.502766
vt 0.505781 0.874572
vt 0.247131 0.875253
vt 0.505189 0.874805
vt 0.246538 0.875444
vt 0.503843 0.875331
vt 0.245193 0.874684
vt 0.505356 0.874621
vt 0.246705 0.875294
vt 0.505564 0.874905
vt 0.246913 0.875587
s 0
f 1/1/1 2/2/1 4/3/1 3/4/1
f 3/5/2 4/6/2 6/7/2 5/8/2
f 5/9/3 6/10/3 8/11/3 7/12/3
f 7/13/4 8/14/4 10/15/4 9/16/4
f 6/7/5 4/6/5 13/17/5 15/18/5
f 9/19/6 10/20/6 12/21/6 11/22/6
f 11/23/7 12/24/7 2/25/7 1/26/7
f 5/9/8 7/12/8 22/27/8 21/28/8
f 14/29/9 18/30/9 30/31/9 26/32/9
f 12/21/10 10/20/10 17/33/10 18/34/10
f 4/3/11 2/2/11 14/35/11 13/36/11
f 8/11/12 6/10/12 15/37/12 16/38/12
f 2/25/13 12/24/13 18/30/13 14/29/13
f 10/15/14 8/14/14 16/39/14 17/40/14
f 19/41/15 20/42/15 21/43/15 22/44/15 23/45/15 24/46/15
f 11/23/16 1/26/16 19/47/16 24/48/16
f 7/13/17 9/16/17 23/49/17 22/50/17
f 3/5/18 5/8/18 21/51/18 20/52/18
f 9/19/19 11/22/19 24/53/19 23/54/19
f 1/1/20 3/4/20 20/55/20 19/56/20
f 25/57/21 26/58/21 30/59/21 29/60/21 28/61/21 27/62/21
f 17/40/22 16/39/22 28/63/22 29/64/22
f 15/18/23 13/17/23 25/65/23 27/66/23
f 18/34/24 17/33/24 29/67/24 30/68/24
f 16/38/25 15/37/25 27/69/25 28/70/25
f 13/36/26 14/35/26 26/71/26 25/72/26

@ -11,6 +11,8 @@ local modname = minetest.get_current_modname()
local cache = {} local cache = {}
local global_search_maximum = 361
local directions = { [0] = local directions = { [0] =
vector.new(0, 0, -1), vector.new(0, 0, -1),
vector.new(-1, 0, 0), vector.new(-1, 0, 0),
@ -58,9 +60,9 @@ local function _check_position_uncached(pos)
if reg_item.pattern_def then if reg_item.pattern_def then
if reg_item.pattern_def.name == "edgy" then if reg_item.pattern_def.name == "edgy" then
return "WE" .. node.param2 return "WE" .. ((node.param2+2)%4)
elseif reg_item.pattern_def.name == "corny" then elseif reg_item.pattern_def.name == "corny" then
return "WC" .. node.param2 return "WC" .. ((node.param2+2)%4)
elseif reg_item.pattern_def.name == "crossy" then elseif reg_item.pattern_def.name == "crossy" then
return "WB" return "WB"
elseif reg_item.pattern_def.name == "starcrossy" then elseif reg_item.pattern_def.name == "starcrossy" then
@ -86,6 +88,42 @@ local function check_position(pos)
return ret return ret
end end
local function set_and_cache(pos, value)
nodecore.set_loud(pos, value)
cache[minetest.hash_node_position(pos)] = _check_position_uncached(pos)
end
local smokecontrol
if nodecore.smokeclear then
smokecontrol = function(pos, smoke)
local existing = check_position(pos)
if existing:sub(1, 1) == "S" then
local node = minetest.get_node(pos)
node.param2 = smoke
minetest.swap_node(pos, node)
if smoke then
nodecore.smokefx(pos, 60, smoke)
else
nodecore.smokeclear(pos)
end
else
if smoke then
nodecore.smokefx(pos, smoke, 1)
else
nodecore.smokeclear(pos)
end
end
end
else
smokecontrol = function(pos, smoke) end
end
-- check for walls, physical or implied -- check for walls, physical or implied
local function edge_check(pos, dir, terminate) local function edge_check(pos, dir, terminate)
local under = check_position(pos + down) local under = check_position(pos + down)
@ -143,36 +181,71 @@ local function connected_search(pos, final_result, early_termination_filter)
if (not stones[newhash]) and (not checked[newhash]) then if (not stones[newhash]) and (not checked[newhash]) then
local newnode = check_position(newpos) local newnode = check_position(newpos)
if newnode == piece then
stones[newhash] = newpos
group[#group+1] = newpos
else
checked[newhash] = true
end
local filter_result local filter_result
if early_termination_filter then if early_termination_filter then
filter_result = early_termination_filter(newnode) filter_result = early_termination_filter(newnode, #group)
end end
if filter_result then if filter_result then
filter_result.stones = stones filter_result.stones = stones
return filter_result return filter_result
elseif newnode == piece then
stones[newhash] = newpos
group[#group+1] = newpos
else
checked[newhash] = true
end end
end end
end end
end end
final_result = final_result() final_result = final_result(#group)
final_result.stones = stones final_result.stones = stones
return final_result return final_result
end end
local function _check_captures_filter(node) local function board_clear_fx(basepos)
if node:sub(1, 1) == "E" then 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
set_and_cache(newpos, {name = "air"})
end
smokecontrol(newpos)
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} return {capture = false}
end end
end end
local function _check_captures_final() local function _check_captures_final(count)
return {capture = true} return {capture = count}
end end
local function check_captures(pos) local function check_captures(pos)
@ -180,11 +253,22 @@ local function check_captures(pos)
end end
local function _connected_group_final() local function _connected_group_final()
return {complete = true}
end
local function _connected_group_filter(node, count)
if (count > global_search_maximum) then
return {} return {}
end
end end
local function connected_group(pos) local function connected_group(pos)
return connected_search(pos, _connected_group_final) local search = connected_search(pos, _connected_group_final, _connected_group_filter)
if search.complete then
return search.stones
else
return {pos}
end
end end
local function territory_search(pos, max) local function territory_search(pos, max)
@ -197,13 +281,12 @@ local function territory_search(pos, max)
function() function()
return {team = team} return {team = team}
end, end,
function(node) function(node, count)
if node == "E" then if (count > max) then
max = max - 1
if max <= 0 then
return {} return {}
end end
elseif node ~= "E_" and ((node:sub(1, 1) == "E") or (node:sub(1, 1) == "S")) and node:len() > 1 then
if node ~= "E_" and ((node:sub(1, 1) == "E") or (node:sub(1, 1) == "S")) and node:len() > 1 then
node = node:sub(2, -1) node = node:sub(2, -1)
if team then if team then
if team ~= node then if team ~= node then
@ -217,10 +300,24 @@ local function territory_search(pos, max)
) )
end end
local function multi_eject(proximal, stone, speed, count, inv)
local stack_max = minetest.registered_items[stone].stack_max
while count > 0 do
local items = stone .. " " .. math.min(count, stack_max)
if inv then items = inv:add_item("main", items) end
nodecore.item_eject(proximal, items, speed)
count = count - stack_max
end
end
local firenode = "nc_fire:fire_burst"
if not minetest.registered_nodes["nc_fire:fire_burst"] then
firenode = "nc_fire:fire"
end
function lc_liberties.handle_placement(pos) function lc_liberties.handle_placement(pos)
cache = {} cache = {}
--minetest.chat_send_all(tostring(pos)) --minetest.chat_send_all(tostring(pos))
--nodecore.node_sound(pos, "dug")
local our_stone = check_position(pos) local our_stone = check_position(pos)
if our_stone:sub(1, 1) ~= "S" then if our_stone:sub(1, 1) ~= "S" then
@ -246,28 +343,55 @@ function lc_liberties.handle_placement(pos)
local node = check_position(new_pos) local node = check_position(new_pos)
if (node:sub(1, 1) == "S") and (node:sub(2, -1) ~= our_stone) then if (node:sub(1, 1) == "S") and (node:sub(2, -1) ~= our_stone) then
local captures = check_captures(new_pos) local captures = check_captures(new_pos)
captured = captured or captures.capture if captures.capture then
captured = (captured or 0) + captures.capture
end
captureses[#captureses+1] = captures captureses[#captureses+1] = captures
end end
end end
end end
local allcaptured = {}
local ko
if captured then if captured then
if captured == 1 then
for i,v in pairs(neighbor_dirs(pos)) do
local new_stone = check_position(pos + directions[v])
if (new_stone:sub(2, -1) == our_stone) or (new_stone:sub(1, 1) == "E") then
goto noko
end
end
ko = true
::noko::
end
for i,v in pairs(captureses) do for i,v in pairs(captureses) do
if v.capture then if v.capture then
local stone = minetest.get_node(v.stones[next(v.stones)]).name local stone = check_position(v.stones[next(v.stones)]):sub(2, -1) -- minetest.get_node().name)
local count = 0 local count = 0
local proximal local proximal
local proximal_c = 0 local proximal_c = 0
for i2, v2 in pairs(v.stones) do for i2, v2 in pairs(v.stones) do
allcaptured[#allcaptured + 1] = v2
if ko then
-- save ko capture position, for adding ko marker in fx phase
ko = {stone = stone, pos = v2}
end
local under = check_position(v2 + down) local under = check_position(v2 + down)
if (under:sub(1, 1) == "W") and (under:len() > 1) then if (under:sub(1, 1) == "W") and (under:len() > 1) then
nodecore.set_loud(v2, {name = "nc_fire:fire"}) nodecore.sound_play("nc_fire_ignite", {gain = 1, pos = pos})
set_and_cache(v2, {name = firenode})
else else
nodecore.set_loud(v2, {name = "air"}) set_and_cache(v2, {name = "air"})
end end
count = count + 1 count = count + 1
if (v2:distance(pos) < 2.3) then if (v2:distance(pos) < 2.3) then
proximal_c = proximal_c + 1 proximal_c = proximal_c + 1
@ -277,37 +401,74 @@ function lc_liberties.handle_placement(pos)
end end
end end
local stack_max = minetest.registered_items[stone].stack_max multi_eject(proximal, modname .. ":stone_" .. stone, 3, count)
while count > 0 do
nodecore.item_eject(proximal, stone .. " " .. math.min(count, stack_max), 3)
count = count - stack_max
end
end end
end end
else else
-- if no capture was made, check for a self-capture and reject the move
local captures = check_captures(pos) local captures = check_captures(pos)
if captures.capture then if captures.capture then
local stone = minetest.get_node(pos).name local stone = minetest.get_node(pos).name
nodecore.set_loud(pos, {name = "air"}) set_and_cache(pos, {name = "air"})
nodecore.item_eject(pos, stone, 5) nodecore.item_eject(pos, stone, 5)
return
end
end end
board_clear_fx(pos)
smokecontrol(pos, 2+#allcaptured)
for i = #allcaptured, 1, -1 do
local chosen = math.random(1, i)
smokecontrol(allcaptured[chosen], 90)
allcaptured[chosen] = allcaptured[i]
end
if ko then
set_and_cache(ko.pos, {name = modname .. ":ko_" .. ko.stone})
end end
end end
function lc_liberties.handle_territory_fill(itemstack, placer, pointed_thing) function lc_liberties.handle_territory_fill(itemstack, placer, pointed_thing)
cache = {} local control = placer.get_player_control and placer:get_player_control()
if placer.get_player_control and placer:get_player_control().aux1 then if (control and (control.aux1 or control.sneak)) then
return minetest.item_place(itemstack, placer, pointed_thing) local ret = minetest.item_place(itemstack, placer, pointed_thing)
if (pointed_thing and pointed_thing.under) then
nodecore.node_sound(pointed_thing.under, "place")
end
return ret
end
local under
if (pointed_thing and pointed_thing.under) then
under = minetest.get_node(pointed_thing.under)
local override_rightclick = minetest.registered_nodes[under.name].on_rightclick
if override_rightclick then
return override_rightclick(pointed_thing.under, under, placer, itemstack, pointed_thing)
end
end end
if pointed_thing and pointed_thing.above then if pointed_thing and pointed_thing.above then
if under then
local reg_item = minetest.registered_items[under.name]
if reg_item and reg_item.groups and reg_item.groups.go_stone then
set_and_cache(pointed_thing.above, {name = modname .. ":territory_" .. reg_item.go_team})
itemstack:set_count(itemstack:get_count() - 1)
return itemstack
end
end
cache = {}
local territories = territory_search(pointed_thing.above, itemstack:get_count()) local territories = territory_search(pointed_thing.above, itemstack:get_count())
if territories.team then if territories.team then
local piece = modname .. ":territory_" .. territories.team local piece = modname .. ":territory_" .. territories.team
local count = 0 local count = 0
for i, v in pairs(territories.stones) do for i, v in pairs(territories.stones) do
nodecore.set_loud(v, {name = piece}) set_and_cache(v, {name = piece})
count = count + 1 count = count + 1
end end
itemstack:set_count(itemstack:get_count() - count) itemstack:set_count(itemstack:get_count() - count)
@ -318,15 +479,35 @@ function lc_liberties.handle_territory_fill(itemstack, placer, pointed_thing)
end end
function lc_liberties.handle_dig(pos, node, digger) function lc_liberties.handle_dig(pos, node, digger)
local control = digger.get_player_control and digger:get_player_control()
if (control and (control.aux1 or control.sneak))
~=
(minetest.registered_items[node.name].groups.go_territory_marker ~= nil)
then
cache = {} cache = {}
if digger.get_player_control and digger:get_player_control().aux1 then local stone = minetest.get_node(pos).name
for i, v in pairs(connected_group(pos).stones) do
minetest.node_dig(v, node, digger) local count = 0
for i, v in pairs(connected_group(pos)) do
count = count + 1
set_and_cache(v, {name = "air"})
end end
multi_eject(pos, stone, 1, count, digger and digger:get_inventory())
return true return true
else else
return minetest.node_dig(pos, node, digger) return minetest.node_dig(pos, node, digger)
end end
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
set_and_cache(pos, {name = handnode.name})
itemstack:set_count(itemstack:get_count() - 1)
end
return itemstack
end

@ -9,119 +9,164 @@ include("rules")
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
local function reg_stone_craft(name, pattern)
local piecename = modname .. ":stone_" .. string_lower(name)
nodecore.register_craft({
label = "chop stones",
action = "pummel",
toolgroups = {choppy = 3},
nodes = {
{
match = "nc_concrete:" .. name .. "_" .. pattern .. "_ply",
replace = "air"
}
},
items = {{name = piecename, count = 3, scatter = 4}},
})
end
local function reg(name, basename, basedef) local function reg(name, basename, basedef)
local piecename = modname .. ":stone_" .. string_lower(name) local piecename = modname .. ":stone_" .. string_lower(name)
if minetest.registered_nodes[piecename] then return end if minetest.registered_nodes[piecename] then return end
local desc = basedef.description or name local desc = basedef.description or name
local nodeDesc = desc .. " Go Stone" local nodedesc_base
minetest.register_node(":" .. piecename, { local nameStone = string.match(desc, "(.*)stone$")
description = nodeDesc, if nameStone then
drawtype = "nodebox", nodedesc_base = nameStone .. " "
elseif desc == "Stone" then
nodedesc_base = ""
else
nodedesc_base = desc .. " "
end
node_box = { local stone_selection_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {-7/16, -8/16, -7/16, 7/16, 0/16, 7/16}
{-3/16, -8/16, -3/16, 3/16, -7/16, 3/16},
{-5/16, -7/16, -5/16, 5/16, -6/16, 5/16},
{-6/16, -6/16, -6/16, 6/16, -4/16, 6/16},
{-7/16, -4/16, -7/16, 7/16, -2/16, 7/16},
{-6/16, -2/16, -6/16, 6/16, 0/16, 6/16},
{-5/16, 0/16, -5/16, 5/16, 1/16, 5/16},
{-3/16, 1/16, -3/16, 3/16, 2/16, 3/16},
} }
},
selection_box = {
type = "fixed",
fixed = {-7/16, -8/16, -7/16, 7/16, 2/16, 7/16}
},
local go_node_base = {
tiles = { tiles = {basedef.tiles[1]},
basedef.tiles[1] sounds = basedef.sounds,
},
paramtype = "light", paramtype = "light",
paramtype2 = "none",
sunlight_propagates = true,
groups = { groups = {
snappy = 1, snappy = 1,
falling_node = 1, falling_node = 1,
falling_repose = 1,
go_stone = 1
}, },
go_team = name, go_team = name,
}
sounds = basedef.sounds, minetest.register_node(":" .. piecename, nodecore.underride({
description = nodedesc_base .. "Go Stone",
drawtype = "mesh",
mesh = "go_stone.obj",
selection_box = stone_selection_box,
collision_box = stone_selection_box,
mapcolor = basedef.mapcolor,
groups = {
falling_repose = 1,
optic_opaque = 1,
go_stone = 1
},
on_construct = lc_liberties.handle_placement, on_construct = lc_liberties.handle_placement,
on_dig = lc_liberties.handle_dig, on_dig = lc_liberties.handle_dig,
})
on_destruct = nodecore.smokeclear,
}, go_node_base))
local territory_selection_box = {
type = "fixed",
fixed = {-5/16, -8/16, -5/16, 5/16, -2/16, 5/16}
}
-- base properties for token nodes only, which are more ephemeral than stones
go_node_base = nodecore.underride({
mapcolor = {a = 0},
sunlight_propagates = true,
groups = {
stack_as_node = 1,
},
}, go_node_base)
local territory_name = modname .. ":territory_" .. string_lower(name) local territory_name = modname .. ":territory_" .. string_lower(name)
minetest.register_node(":" .. territory_name, { minetest.register_node(":" .. territory_name, nodecore.underride({
description = "Territory Marker", description = "Stop Stone",
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-2/16, -8/16, -2/16, 2/16, -7/16, 2/16}, {-2/16, -8/16, -2/16, 2/16, -5/16, 2/16},
{-3/16, -7/16, -3/16, 3/16, -6/16, 3/16}, {-3/16, -7/16, -3/16, 3/16, -6/16, 3/16},
{-2/16, -6/16, -2/16, 2/16, -5/16, 2/16},
} }
}, },
selection_box = { selection_box = territory_selection_box,
type = "fixed", collision_box = territory_selection_box,
fixed = {-6/16, -8/16, -6/16, 6/16, 0/16, 6/16}
},
tiles = {
basedef.tiles[1]
},
paramtype = "light",
sunlight_propagates = true, node_placement_prediction = "",
groups = { groups = {
snappy = 1,
falling_node = 1,
falling_repose = 1,
go_territory_marker = 1, go_territory_marker = 1,
}, },
go_team = name,
sounds = basedef.sounds,
on_place = lc_liberties.handle_territory_fill, on_place = lc_liberties.handle_territory_fill,
on_dig = lc_liberties.handle_dig, on_dig = lc_liberties.handle_dig,
}) }, go_node_base))
nodecore.register_craft({ local ko_selection_box = {
label = "Chop scored cement into go stones", type = "fixed",
action = "pummel", fixed = {-8/16, -8/16, -8/16, 8/16, -4/16, 8/16}
toolgroups = {choppy = 3}, }
nodes = {
{ minetest.register_node(":" .. modname .. ":ko_" .. string_lower(name), nodecore.underride({
match = "nc_concrete:" .. name .. "_starcrossy_ply", description = nodedesc_base .. "Ko Stone",
replace = "air" drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-5/16, -6/16, -5/16, 5/16, -5/16, -4/16},
{5/16, -6/16, -5/16, 4/16, -5/16, 5/16},
{5/16, -6/16, 5/16, -5/16, -5/16, 4/16},
{-5/16, -6/16, 5/16, -4/16, -5/16, -5/16},
} }
}, },
items = {{name = piecename, count = 3, scatter = 4}},
}) selection_box = ko_selection_box,
collision_box = ko_selection_box,
groups = {
falling_node = 0,
ko_stone = 1,
cheat = 1,
},
drop = "",
destroy_on_dig = true,
silktouch = false,
on_rightclick = lc_liberties.handle_click_ko,
}, go_node_base))
reg_stone_craft(name, "crossy")
reg_stone_craft(name, "starcrossy")
nodecore.register_craft({ nodecore.register_craft({
label = "Smash go stones into territory markers", label = "smash stones",
action = "pummel", action = "pummel",
toolgroups = {thumpy = 3}, toolgroups = {thumpy = 3},
nodes = { nodes = {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 B

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 B

After

Width:  |  Height:  |  Size: 103 B

Loading…
Cancel
Save