Added Durability buff
parent
8d828ba3bc
commit
61cb8cb14d
|
@ -152,43 +152,6 @@ minetest.register_tool("mushroom_tools:axe", {
|
|||
groups = {axe = 1},
|
||||
})
|
||||
|
||||
-- TO DO: This functionality is going to be removed from mushroom
|
||||
-- swords and added as a potential buff to rune swords.
|
||||
local prunable_trunk = {
|
||||
["default:tree"] = {
|
||||
leaves = {"default:apple", "default:apple_mark", "default:leaves"},
|
||||
range = 3,
|
||||
},
|
||||
["default:jungletree"] = {
|
||||
leaves = {"default:jungleleaves"},
|
||||
range = 2,
|
||||
},
|
||||
["default:pine_tree"] = {
|
||||
leaves = {"default:pine_needles"},
|
||||
range = 3,
|
||||
},
|
||||
["default:acacia_tree"] = {
|
||||
leaves = {"default:acacia_leaves"},
|
||||
range = 2,
|
||||
},
|
||||
["default:aspen_tree"] = {
|
||||
leaves = {"default:aspen_leaves"},
|
||||
range = 3,
|
||||
},
|
||||
["default:bush_stem"] = {
|
||||
leaves = {"default:bush_leaves"},
|
||||
range = 1,
|
||||
},
|
||||
["default:acacia_bush_stem"] = {
|
||||
leaves = {"default:acacia_bush_leaves"},
|
||||
range = 1,
|
||||
},
|
||||
["default:pine_bush_stem"] = {
|
||||
leaves = {"default:pine_bush_needles"},
|
||||
range = 1,
|
||||
},
|
||||
}
|
||||
|
||||
minetest.register_tool("mushroom_tools:sword", {
|
||||
description = "Mushroom Sword",
|
||||
inventory_image = "mushroom_tools.sword.png",
|
||||
|
@ -202,49 +165,6 @@ minetest.register_tool("mushroom_tools:sword", {
|
|||
},
|
||||
sound = {breaks = "default_tool_breaks"},
|
||||
groups = {sword = 1},
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
local potential_log = minetest.get_node(pointed_thing.under)
|
||||
if prunable_trunk[potential_log.name] then
|
||||
local to_prune = minetest.find_nodes_in_area({
|
||||
x = pointed_thing.under.x - prunable_trunk[potential_log.name].range,
|
||||
y = pointed_thing.under.y - prunable_trunk[potential_log.name].range,
|
||||
z = pointed_thing.under.z - prunable_trunk[potential_log.name].range,
|
||||
}, {
|
||||
x = pointed_thing.under.x + prunable_trunk[potential_log.name].range,
|
||||
y = pointed_thing.under.y + prunable_trunk[potential_log.name].range,
|
||||
z = pointed_thing.under.z + prunable_trunk[potential_log.name].range,
|
||||
}, prunable_trunk[potential_log.name].leaves)
|
||||
for _, pos in next, to_prune do
|
||||
local node = minetest.get_node(pos)
|
||||
minetest.node_dig(pos, node, user)
|
||||
-- Apple marks are dealt with separately because minetest.node_dig()
|
||||
-- doesn't work on them. It's probably because players can't normally
|
||||
-- dig them. We also assume that apples have left behind apple marks
|
||||
-- and remove those as well.
|
||||
if node.name == "default:apple_mark"
|
||||
or node.name == "default:apple" then
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end
|
||||
-- This seems a bit unclean, but I'm not sure how else to handle the
|
||||
-- situation. If no value is returned, Minetest restores the tool's
|
||||
-- durability that was used to prune the leaves because it sets the
|
||||
-- item stack to what it was before the player used this functionality.
|
||||
-- On the other hand, if we return the itemstack the engine passed to
|
||||
-- our callback, we've just restored the durability ourselves because
|
||||
-- that copy came from before the tool was used to prune the leaves.
|
||||
-- Likewise, we shouldn't manually add the wear ourselves because we
|
||||
-- don't know if each leaf was harvested successfully or not (for
|
||||
-- example, an area might be protected). The only thing to do seems to
|
||||
-- be to get the item now wielded and return it, basically overwriting
|
||||
-- the worn item with whatever the player now holds, which should
|
||||
-- hopefully always be itself (or an empty stack if it broke).
|
||||
return user:get_wielded_item()
|
||||
elseif minetest.registered_nodes[potential_log.name]
|
||||
and minetest.registered_nodes[potential_log.name].on_rightclick then
|
||||
return minetest.registered_nodes[potential_log.name].on_rightclick(pointed_thing.under, potential_log, user, itemstack, pointed_thing)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_tool("mushroom_tools:screwdriver", {
|
||||
|
|
|
@ -59,13 +59,13 @@ return {
|
|||
sword = "thirst",
|
||||
},
|
||||
mese_crystal = {
|
||||
axe = "debug",
|
||||
fire_starter = "debug",
|
||||
pick = "debug",
|
||||
hoe = "debug",
|
||||
screwdriver = "debug",
|
||||
shovel = "spreader",
|
||||
sword = "pruner",
|
||||
axe = "durability",
|
||||
fire_starter = "durability",
|
||||
pick = "durability",
|
||||
hoe = "durability",
|
||||
screwdriver = "durability",
|
||||
shovel = "durability",
|
||||
sword = "durability",
|
||||
},
|
||||
copper_lump = {
|
||||
axe = "debug",
|
||||
|
@ -77,13 +77,13 @@ return {
|
|||
sword = "pruner",
|
||||
},
|
||||
diamond = {
|
||||
axe = "debug",
|
||||
fire_starter = "debug",
|
||||
pick = "debug",
|
||||
hoe = "debug",
|
||||
screwdriver = "debug",
|
||||
shovel = "spreader",
|
||||
sword = "pruner",
|
||||
axe = "durability",
|
||||
fire_starter = "durability",
|
||||
pick = "durability",
|
||||
hoe = "durability",
|
||||
screwdriver = "durability",
|
||||
shovel = "durability",
|
||||
sword = "durability",
|
||||
},
|
||||
gold_lump = {
|
||||
axe = "debug",
|
||||
|
|
|
@ -51,6 +51,7 @@ local buff_name = {
|
|||
thirst = S("Thirst"),
|
||||
pruner = S("Pruner"),
|
||||
spreader = S("Spreader"),
|
||||
durability = S("Durability"),
|
||||
}
|
||||
|
||||
local rune_element_modname = {
|
||||
|
@ -152,6 +153,17 @@ local function generate_tool(tool_name, player_name, runes)
|
|||
end
|
||||
end
|
||||
meta:set_string("description", description)
|
||||
local overwrite = false
|
||||
if buffs.durability then
|
||||
local caps = tool:get_tool_capabilities()
|
||||
for _, group in next, caps.groupcaps do
|
||||
group.uses = group.uses * 1.5
|
||||
overwrite = true
|
||||
end
|
||||
if overwrite then
|
||||
tool:set_tool_capabilities(caps)
|
||||
end
|
||||
end
|
||||
return tool
|
||||
end
|
||||
|
||||
|
|
|
@ -308,11 +308,19 @@ minetest.register_tool("runes:screwdriver", {
|
|||
wield_overlay = "runes.tool_stone_screwdriver.png",
|
||||
groups = {tool = 1, disable_repair = 1},
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_FACE, 400)
|
||||
local uses = 500
|
||||
if itemstack:get_meta():get_string("durability") then
|
||||
uses = 750
|
||||
end
|
||||
screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_FACE, uses)
|
||||
return itemstack
|
||||
end,
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_AXIS, 400)
|
||||
local uses = 500
|
||||
if itemstack:get_meta():get_string("durability") then
|
||||
uses = 750
|
||||
end
|
||||
screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_AXIS, uses)
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
@ -357,7 +365,11 @@ minetest.register_tool("runes:fire_starter", {
|
|||
end
|
||||
-- Wear tool
|
||||
local wdef = itemstack:get_definition()
|
||||
itemstack:add_wear(500)
|
||||
local wear = 500
|
||||
if itemstack:get_meta():get_string("durability") then
|
||||
wear = 334
|
||||
end
|
||||
itemstack:add_wear(wear)
|
||||
-- Tool break sound
|
||||
if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then
|
||||
minetest.sound_play(wdef.sound.breaks, {pos = sound_pos, gain = 0.5})
|
||||
|
|
Loading…
Reference in New Issue