<?xml version="1.0" encoding="UTF-8"?>
<mod name="Alchemy System" version="3.0" author="soul4soul" enabled="yes">
<config name="recipeinfo"><![CDATA[
t = {
--[uid] = {newitemid, lvl, slots = {{item to be used, count},{item to be used, count}}, difficulty = 10-100 by 10's, destroy = 'yes' or 'no'},
[50001] = {item = 8474, alchemylvl = 10, slots = {{2007, 1}, {2795, 1}, {2760, 1}}, difficulty = 20, destroy = 'no'},
[50002] = {item = 2152, alchemylvl = 15, slots = {{2148, 10}, {10608, 2}}, difficulty = 20, destroy = 'no'},
[50003] = {item = 2178, alchemylvl = 20, slots = {{2177, 1}, {1295, 1}, {2146, 3}}, difficulty = 40, destroy = 'no'},
[50004] = {item = 5944, alchemylvl = 20, slots = {{2177, 1}, {1295, 1}, {2150, 3}}, difficulty = 40, destroy = 'no'},
[50005] = {item = 2363, alchemylvl = 25, slots = {{2177, 1}, {2177, 1}, {1295, 1}, {2798, 1}, {2788, 1}}, difficulty = 50, destroy = 'no'},
[50006] = {item = 10092, alchemylvl = 30, slots = {{2677, 3}, {1685, 1}, {2013, 1}, {2015, 1}}, difficulty = 60, destroy = 'no'},
[50007] = {item = 4864, alchemylvl = 35, slots = {{4850, 1}, {2913, 1}, {2144, 1}}, aid = 105, difficulty = 40, destroy = 'no'},
[50008] = {item = 2276, alchemylvl = 40, slots = {{10558, 1}, {2260, 1}, {10554, 1}, {2151, 1}, {5951, 1}, {2265, 1}}, difficulty = 40, destroy = 'no'},
[50009] = {item = 2160, alchemylvl = 45, slots = {{2152, 1}, {2145, 1}, {2146, 1}, {2800, 1}}, difficulty = 30, destroy = 'no'},
[50010] = {item = 11201, alchemylvl = 45, slots = {{2759, 1}, {10565, 1}, {2803, 1}, {2692, 1}}, difficulty = 40, destroy = 'no'},
[50011] = {item = 5892, alchemylvl = 50, slots = {{5468, 1}, {2393, 1}}, difficulty = 50, destroy = 'yes'},
[50012] = {item = 5887, alchemylvl = 50, slots = {{5468, 1}, {2487, 1}}, difficulty = 50, destroy = 'yes'},
[50013] = {item = 5888, alchemylvl = 50, slots = {{5468, 1}, {2462, 1}}, difficulty = 50, destroy = 'yes'},
[50014] = {item = 5889, alchemylvl = 50, slots = {{5468, 1}, {2516, 1}}, difficulty = 50, destroy = 'yes'},
[50015] = {item = 5891, alchemylvl = 55, slots = {{2195, 1}, {4265, 1}, {2151, 1}}, difficulty = 40, destroy = 'yes'},
[50016] = {item = 5884, alchemylvl = 55, slots = {{2498, 1}, {2498, 1}, {2913, 1}, {5865, 1}}, difficulty = 40, destroy = 'yes'},
[50017] = {item = 5885, alchemylvl = 55, slots = {{2475, 1}, {2475, 1}, {2475, 1}, {2475, 1}, {2015, 1}, {5865, 1}}, difficulty = 40, destroy = 'yes'},
[50018] = {item = 7439, alchemylvl = 60, slots = {{6558, 1}, {2007, 1}, {4993, 1}, {5480, 1}, {2796, 1}}, difficulty = 30, destroy = 'no'},
[50019] = {item = 7440, alchemylvl = 60, slots = {{6558, 1}, {2007, 1}, {4992, 1}, {3955, 1}, {7250, 1}}, difficulty = 30, destroy = 'no'},
[50020] = {item = 7443, alchemylvl = 60, slots = {{6558, 1}, {2007, 1}, {4994, 1}, {2193, 1}, {2031, 1}}, difficulty = 30, destroy = 'no'},
[50021] = {item = 7140, alchemylvl = 65, slots = {{7141, 1}, {2015, 1}, {5014, 1}, {2235, 1}, {7439, 1}, {7440, 1}, {7443, 1}, {4845, 1}}, difficulty = 60, destroy = 'no'},
[50022] = {item = 9971, alchemylvl = 70, slots = {{10552, 1}, {2157, 1}, {2159, 1}, {5906, 1}}, difficulty = 50, destroy = 'no'},
[50023] = {item = 2284, alchemylvl = 75, slots = {{10523, 1}, {2260, 1}, {10554, 1}, {2151, 1}, {2273, 1}}, difficulty = 30, destroy = 'no'},
[50024] = {item = 11387, alchemylvl = 80, slots = {{2805, 1}, {2798, 1}, {8582, 1}}, difficulty = 70, destroy = 'no'},
[50025] = {item = 8980, alchemylvl = 90, slots = {{5941, 1}, {10559, 1}, {2194, 1}, {2377, 1}}, difficulty = 80, destroy = 'no'},
[50026] = {item = 2184, alchemylvl = 90, slots = {{9942, 1}, {9941, 1}, {9980, 1}, {2445, 1}}, difficulty = 80, destroy = 'no'},
[50027] = {item = 2352, alchemylvl = 90, slots = {{2177, 1}, {2160, 1}, {2544, 1}, {2544, 1}, {2802, 1}}, difficulty = 80, destroy = 'no'},
[50028] = {item = 9969, alchemylvl = 100, slots = {{5741, 1}, {2229, 1}, {5669, 1}, {5809, 1}, {2143, 1}}, difficulty = 90, destroy = 'yes'},
[50029] = {item = 9006, alchemylvl = 110, slots = {{8859, 1}, {2289, 1}, {2807, 1}, {10556, 1}, {2545, 1}, {5879, 1}}, difficulty = 100, destroy = 'yes'},
[50030] = {item = 2348, alchemylvl = 120, slots = {{2153, 1}, {2154, 1}, {2155, 1}, {2156, 1}, {2158, 1}, {2260, 1}, {2260, 1}, {2600, 1}}, difficulty = 100, destroy = 'yes'}
}
--[CustomSkill]-- By:Athern
function getCustomSkill(cid, storage)
return getPlayerStorageValue(cid, storage)
end
function addCustomSkill(cid, skillName, storage)
local skillStorage = math.max(10, getPlayerStorageValue(cid, storage))
local skillTries = math.max(0, getPlayerStorageValue(cid, storage+1))
doPlayerSetStorageValue(cid, storage, skillStorage+1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You advanced in " .. skillName .. ".")
doPlayerSetStorageValue(cid, storage+1, 0)
end
function addCustomSkillTry(cid, skillName, storage)
local skillStorage = math.max(10, getPlayerStorageValue(cid, storage))
local skillTries = math.max(0, getPlayerStorageValue(cid, storage+1))
doPlayerSetStorageValue(cid, storage+1, 1)
if skillTries >= math.floor(20 * math.pow(1.1, (skillStorage-11)) / 40) then
addCustomSkill(cid, skillName, storage)
end
end
function getCustomSkillPercent(cid, storage)
local skillStorage = math.max(10, getPlayerStorageValue(cid, storage))
local skillTries = math.max(0, getPlayerStorageValue(cid, storage+1))
local triesNeeded = math.floor(20 * math.pow(1.1, (skillStorage-11)) / 40)
local percent = math.floor(100*(1-skillTries / triesNeeded))
if percent > 1 and percent <= 100 then
return percent
else
percent = 1
return percent
end
end
--[/CustomSkill]--
]]></config>
<action itemid="2217" event="script"><![CDATA[
function onUse(cid, item, toPosition, fromPosition)
local function burn()
local Cpos = getCreaturePosition(cid)
local north = {x = Cpos.x, y = Cpos.y-1, z = Cpos.z}
local south = {x = Cpos.x, y = Cpos.y+1, z = Cpos.z}
local west = {x = Cpos.x-1, y = Cpos.y, z = Cpos.z}
local east = {x = Cpos.x+1, y = Cpos.y, z = Cpos.z}
if getCreatureLookDirection(cid) == 0 then
doSendMagicEffect(north, 6)
elseif getCreatureLookDirection(cid) == 1 then
doSendMagicEffect(east, 6)
elseif getCreatureLookDirection(cid) == 2 then
doSendMagicEffect(south, 6)
elseif getCreatureLookDirection(cid) == 3 then
doSendMagicEffect(west, 6)
end
end
local learned = getPlayerStorageValue(cid, 50500)
if learned == -1 then
setPlayerStorageValue(cid, 50500, 10)
doRemoveItem(item.uid)
doPlayerSendTextMessage(cid, 25, "You have learned Alchemy, then the book burned to ashes after learning its Alchemic Secrets.")
addEvent(burn, 300, {cid = cid, toPosition = toPosition, fromPosition = fromPosition})
else
doPlayerSendCancel(cid, "You already know Alchemy.")
end
return true
end
]]></action>
<action itemid="1954" event="script"><![CDATA[
domodlib("recipeinfo")
function onUse(cid, item, toPosition, item2, fromPosition)
k = t[item.actionid]
if getPlayerStorageValue(cid, item.actionid) == -1 then
if getCustomSkill(cid, 50500) >= k.alchemylvl then
doPlayerSetStorageValue(cid, item.actionid, item.actionid-50000)
doPlayerSendTextMessage(cid, 25, "You learned how to make ".. getItemInfo(k.item).article.." "..getItemInfo(k.item).name..".")
doSendMagicEffect(getCreaturePosition(cid), 13)
else
doPlayerSendCancel(cid, "You require "..k.alchemylvl.." in Alchemy or you don't know Alchemy.")
end
else
doPlayerSendCancel(cid, "You have already learned this recipe.")
end
return true
end
]]></action>
<action itemid="1965" event="script"><![CDATA[
local skillIDs = {
{50500, "Alchemy"} -- The first ID is the skill value, the second ID is the name of the skill
}
domodlib("recipeinfo")
function onUse(cid, item, fromPosition, itemEx, toPosition)
local a = {}
skill = "Alchemy Level: " .. math.max(10, getCustomSkill(cid, skillIDs[1][1])) .. ". Percent to go: " .. getCustomSkillPercent(cid, skillIDs[1][1]) .. "%\n-------\n\n"
table.insert(a, skill)
table.insert(a, "Learned Recipes:\n\n")
recipe = ""
for i, k in pairs(t) do
if getPlayerStorageValue(cid, i) > 0 then
for i2 = 1, #k.slots do
test = k.slots[i2]
recipe = ""..recipe..", "..test[2].. " ".. getItemInfo(test[1]).name .. ""
end
recipe = "[" ..getItemInfo(k.item).name.. "]-Alchemy Level: " .. k.alchemylvl .. "\n Ingredients: ".. recipe .. ". \n\n"
table.insert(a, recipe)
recipe = ""
end
end
doSetItemText(item.uid, table.concat(a, ""))
end
]]></action>
<movevent type="AddItem" tileitem="1" itemid="1426" event="script"><![CDATA[
function onAddItem(moveItem, tileItem, position, cid)
domodlib("recipeinfo")
if getItemInfo(moveItem.itemid).type == ITEM_TYPE_CONTAINER then
container = getTileItemByType(position, 4)
inContainer = {
getContainerItem(container.uid, 0),
getContainerItem(container.uid, 1),
getContainerItem(container.uid, 2),
getContainerItem(container.uid, 3),
getContainerItem(container.uid, 4),
getContainerItem(container.uid, 5),
getContainerItem(container.uid, 6),
getContainerItem(container.uid, 7),
getContainerItem(container.uid, 8)
}
pass = 0
k = t[inContainer[1].actionid]
if getPlayerStorageValue(cid, inContainer[1].actionid) == inContainer[1].actionid-50000 then
for size = #k.slots + 1,2, -1 do
testin = k.slots[size-1]
if testin[1] == inContainer[size].itemid then
if doRemoveItem(inContainer[size].uid, testin[2]) == LUA_NO_ERROR then
pass = pass + 1
end
end
end
if pass == #k.slots then
if moveItem.itemid == 6104 then
chance = k.difficulty-10
else
chance = k.difficulty
end
if math.random(1, (90 + (getCustomSkill(cid, 50500) / 10))) > chance then
doPlayerAddItem(cid, k.item,1)
doSendMagicEffect(position, CONST_ME_HITBYFIRE)
doPlayerSendTextMessage(cid, 25, "You made ".. getItemInfo(k.item).article.." "..getItemInfo(k.item).name..".")
gain = (k.difficulty/10)
for i3=1, gain do
addCustomSkillTry(cid, "Alchemy", 50500)
end
if k.aid then
local getItem = getPlayerItemById(cid, true, k.item)
doItemSetAttribute(getItem.uid, "aid", k.aid)
end
else
doPlayerSendCancel(cid, "The mix went wrong.")
doCreatureAddHealth(cid, -getCreatureMaxHealth(cid)*0.01, CONST_ME_FIREAREA)
addCustomSkillTry(cid, "Alchemy", 50500)
end
if destroy == 'yes' then
doRemoveItem(container.uid)
end
else
doPlayerSendCancel(cid, "There are no Ingredients or some are missing.")
end
else
doPlayerSendCancel(cid, "You haven't learned this recipe yet or the container is empty.")
end
else
doPlayerSendCancel(cid, "You must use a container and place the ingredients inside.")
end
return true
end
]]></movevent>
</mod>