local recipes = {
--herbalism (big mushrooms)
[4167] = {tool = 2550, skill = 0, loot = {{2801, 1}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
[4168] = {tool = 2550, skill = 0, loot = {{2801, 1}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
[4169] = {tool = 2550, skill = 0, loot = {{2801, 1}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
[4174] = {tool = 2550, skill = 0, loot = {{2801, 1}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
[4175] = {tool = 2550, skill = 0, loot = {{2801, 1}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
[4172] = {tool = 2550, skill = 0, loot = {{2801, 1}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
[4173] = {tool = 2550, skill = 0, loot = {{2801, 1}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
--mining (minerals, metals)
[5753] = {tool = 2553, skill = 0, loot = {{7762, 1}}, effect = CONST_ME_HITAREA, profession = "mining", skillpoints = 10},
[5868] = {tool = 2553, skill = 20, loot = {{7760, 1}}, effect = CONST_ME_HITAREA, profession = "mining", skillpoints = 15},
[5866] = {tool = 2553, skill = 30, loot = {{7761, 1}}, effect = CONST_ME_HITAREA, profession = "mining", skillpoints = 25},
[5751] = {tool = 2553, skill = 50, loot = {{7759, 1}}, effect = CONST_ME_HITAREA, profession = "mining", skillpoints = 35}
--woodcutting (wood)
[2786] = {tool = 2388, skill = 10, loot = {{5901, 1}}, effect = CONST_ME_HITAREA, profession = "woodcutting", skillpoints = 10},
[2768] = {tool = 2388, skill = 10, loot = {{5901, 1}}, effect = CONST_ME_HITAREA, profession = "woodcutting", skillpoints = 10},
[2767] = {tool = 2388, skill = 10, loot = {{5901, 1}}, effect = CONST_ME_HITAREA, profession = "woodcutting", skillpoints = 10}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local profession = {
["mining"] = {skill = SKILL_CLUB}
["woodcutting"] = {skill = SKILL_FIST}
}
if recipes[itemEx.itemid] then
if itemEx.actionid > 0 then
doCreatureSay(cid, "You can't do that.", TALKTYPE_ORANGE_1)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end
lootTable = {}
lootName = "You recive: "
if recipes[itemEx.itemid].profession == "mining" or recipes[itemEx.itemid].profession == "woodcutting" then
professionSkill = getPlayerSkillLevel(cid, profession[recipes[itemEx.itemid].profession].skill)
else
professionSkill = 0
end
itemPos = getThingPos(itemEx.uid)
if item.itemid == recipes[itemEx.itemid].tool then
if professionSkill >= recipes[itemEx.itemid].skill then
if item.actionid ~= 5001 then
if math.random(1, 3) < 2 then
doRemoveItem(itemEx.uid, 1)
doSendMagicEffect(itemPos, recipes[itemEx.itemid].effect)
if recipes[itemEx.itemid].profession ~= "skinning" then
addEvent(doCreateItem, 30000, itemEx.itemid, 1, itemPos)
addEvent(doSendMagicEffect, 30000, itemPos, recipes[itemEx.itemid].effect)
end
repeat
if #recipes[itemEx.itemid].loot == 0 then
break
end
for i = 1, #recipes[itemEx.itemid].loot do
if math.random(1, 2) < 2 then
table.insert(lootTable, (recipes[itemEx.itemid].loot)[i])
end
end
until lootTable ~= {}
for i = 1, #lootTable do
lootCount = math.random(1, lootTable[i][2])
doPlayerAddItem(cid, lootTable[i][1], lootCount)
if i == #lootTable then
lootName = lootName..""..lootCount.."x ".. getItemNameById(lootTable[i][1]) .."."
else
lootName = lootName..""..lootCount.."x ".. getItemNameById(lootTable[i][1]) ..", "
end
end
if lootName == "You recive: " then
lootName = "You don't recive any loot."
end
if recipes[itemEx.itemid].profession == "mining" then
doPlayerAddSkillTry(cid, profession[recipes[itemEx.itemid].profession].skill, recipes[itemEx.itemid].skillpoints)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, lootName)
else
doSendMagicEffect(itemPos, CONST_ME_BLOCKHIT)
doCreatureSay(cid, "Keep trying! This plant, tree or rock is tough!", TALKTYPE_ORANGE_1)
end
else
doSendMagicEffect(itemPos, CONST_ME_BLOCKHIT)
doCreatureSay(cid, "This tree was cut recenlty by someone else!", TALKTYPE_ORANGE_1)
end
else
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
doCreatureSay(cid, "You don't have required skill to do that!", TALKTYPE_ORANGE_1)
end
else
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_BLOCKHIT)
doCreatureSay(cid, "This tool doesn't match!", TALKTYPE_ORANGE_1)
end
end
return true
end