local mindstoneId = 2178
local config = {
[2187] = {2, 18409, 50}, -- [wand_of_inferno] = {amountRequired, wand_of_everblazing, chanceOfFailing}
--[1111] = {2, 3333, 50}, -- [itemToBeCombined] = {amountRequired, itemTheyTurnInto, chanceOfFailing/100}
--[1111] = {2, 3333, 50}
}
local action = Action()
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not target then
return true
end
local targetId = target:getId()
local index = config[targetId]
if not index then
player:sendCancelMessage("This item cannot be combined.")
return true
end
if player:getItemCount(targetId) < index[1] then
player:sendCancelMessage("Not enough materials to combine. (Requires: " .. index[1] .. " " .. ItemType(targetId):getName() .. " in inventory)")
return true
end
item:remove(1)
player:removeItem(targetId, index[1])
if math.random(100) <= index[3] then
player:say("Failed.", TALKTYPE_MONSTER_SAY)
return true
end
player:say("Succeeded!", TALKTYPE_MONSTER_SAY)
player:addItem(index[2], 1, true)
return true
end
action:id(mindstoneId)
action:register()