<?xml version="1.0" encoding="UTF-8"?>
<mod name="Alchemy System" version="2.0" author="375311/soul4soul" enabled="yes">
<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, 50000)
if learned == -1 then
for i = 41508, 41509 do
setPlayerStorageValue(cid, i, 0)
end
for i = 50001, 50022 do
setPlayerStorageValue(cid, i, 0)
end
setPlayerStorageValue(cid, 50500, 10)
setPlayerStorageValue(cid, 50000, 1)
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[
local t = {
[50001] = {ref = 50001, recipe = "Antidote", pStorage = 1, alchemylvl = 10},
[50002] = {ref = 50002, recipe = "Lesser Mana Potion", pStorage = 2, alchemylvl = 15},
[50003] = {ref = 50003, recipe = "Medium Mana Potion", pStorage = 3, alchemylvl = 25},
[50004] = {ref = 50004, recipe = "Strong Mana Potion", pStorage = 4, alchemylvl = 35},
[50005] = {ref = 50005, recipe = "Small Health Potion", pStorage = 5, alchemylvl = 10},
[50006] = {ref = 50006, recipe = "Lesser Health Potion", pStorage = 6, alchemylvl = 15},
[50007] = {ref = 50007, recipe = "Medium Health Potion", pStorage = 7, alchemylvl = 25},
[50008] = {ref = 50008, recipe = "Strong Health Potion", pStorage = 8, alchemylvl = 35},
[50009] = {ref = 50009, recipe = "Great Health Potion", pStorage = 9, alchemylvl = 40},
[50010] = {ref = 50010, recipe = "Spirit Potion", pStorage = 10, alchemylvl = 50},
[50011] = {ref = 50011, recipe = "Speed Potion", pStorage = 11, alchemylvl = 50},
[50012] = {ref = 50012, recipe = "Potion of Strength", pStorage = 12, alchemylvl = 70},
[50013] = {ref = 50013, recipe = "Potion of Dexterity", pStorage = 13, alchemylvl = 70},
[50014] = {ref = 50014, recipe = "Potion of Endurance", pStorage = 14, alchemylvl = 70},
[50015] = {ref = 50015, recipe = "Potion of Magic Level", pStorage = 15, alchemylvl = 80},
[50016] = {ref = 50016, recipe = "Potion of Health", pStorage = 16, alchemylvl = 60},
[50017] = {ref = 50017, recipe = "Potion of Mana", pStorage = 17, alchemylvl = 60},
[50018] = {ref = 50018, recipe = "Elixir", pStorage = 18, alchemylvl = 100},
[50019] = {ref = 50019, recipe = "Blood Orb", pStorage = 19, alchemylvl = 40},
[50020] = {ref = 50020, recipe = "Soul Orb", pStorage = 20, alchemylvl = 90},
[50021] = {ref = 50021, recipe = "Mind Orb", pStorage = 21, alchemylvl = 90},
[50022] = {ref = 50022, recipe = "Philosopher's Stone", pStorage = 22, alchemylvl = 100}
}
function onUse(cid, item, toPosition, item2, fromPosition)
for i, k in pairs(t) do
if item.actionid == i then
if getPlayerStorageValue(cid, k.ref) == 0 then
if getCustomSkill(cid, 50500) >= k.alchemylvl then
doPlayerSetStorageValue(cid, k.ref, k.pStorage)
doPlayerSendTextMessage(cid, 25, "You learned how to make "..k.recipe..".")
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
end
end
return true
end
]]></action>
<action itemid="1965" event="script"><![CDATA[
local recipeIDs = {
{50001, "Mushroom, Goat Grass and Hydrargyrum", "[Antidote]", 10},
{50002, "White Mushroom, Shadow Herb and Aquamarine", "[Lesser Mana Potion]", 15},
{50003, "White Mushroom, Powder Herb and Aquamarine", "[Medium Mana Potion]", 25},
{50004, "White Mushroom, Siling Herb and Aquamarine", "[Strong Mana Potion]", 35},
{50005, "Mushroom and Stone Herb", "[Small Health Potion]", 10},
{50006, "Wood Mushroom, Star Herb and Vermillion", "[Lesser Health Potion]", 15},
{50007, "Wood Mushroom, Orange Star and Vermillion", "[Medium Health Potion]", 25},
{50008, "Wood Mushroom, Fern and Vermillion", "[Strong Health Potion]", 35},
{50009, "Wood Mushroom, Heaven Blossom and Vermillion", "[Great Health Potion]", 40},
{50010, "Brown Mushroom, Troll Green and Powder", "[Spirit Potion]", 50},
{50011, "Brown Mushroom, Seeds, Quartzite and Hydrargyrum", "[Speed Potion]", 50},
{50012, "Blood Orb, Dark Mushroom and Vitriol", "[Potion of Strength]", 70},
{50013, "Blood Orb, Green Mushroom and Vitriol", "[Potion of Dexterity]", 70},
{50014, "Blood Orb, Fire Mushroom and Vitriol", "[Potion of Endurance]", 70},
{50015, "Little Mushroom, Quebrith and Crystal", "[Potion of Magic Level]", 80},
{50016, "Red Mushroom, Mandrake and Tar", "[Potion of Health]", 60},
{50017, "Orange Mushroom, Ancient Orchid and Tar", "[Potion of Mana]", 60},
{50018, "Dragrot and Crystal", "[Elixir]", 100},
{50019, "Hydrargyrum, Vermillion and Powder", "[Blood Orb]", 40},
{50020, "Hydrargyrum, Crystal, Quarzite and Tar", "[Soul Orb]", 90},
{50021, "Hydrargyrum, Crystal, Vitriol and Quebrith","[Mind Orb]", 90},
{50022, "Mind Orb, Soul Orb, Blood Orb, Violet Gem, Yellow Gem, Green Gem, Red Gem, Blue Gem", "[Philosopher's Stone]", 100}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local a = {}
table.insert(a, "Learned Recipe:\n\n")
for i=1, #recipeIDs, 1 do
if getPlayerStorageValue(cid, recipeIDs[1]) > 0 then
recipe = recipeIDs[3] .. ": 'Ingredients': " .. recipeIDs[2] .. ". 'Alchemy Level': " .. recipeIDs[4] .. ".\n"
table.insert(a, recipe)
end
end
doShowTextDialog(cid, item.itemid, table.concat(a, ""))
end
]]></action>
<action itemid="1950" event="script"><![CDATA[
local skillIDs = {
{50500, "Alchemy"} -- The first ID is the skill value, the second ID is the name of the skill
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local a = {}
table.insert(a, "Current Skills:\n\n")
skill = skillIDs[1][2] .. ": " .. math.max(10, getCustomSkill(cid, skillIDs[1][1])) .. ". Percent to go: " .. getCustomSkillPercent(cid, skillIDs[1][1]) .. "%\n"
table.insert(a, skill)
doShowTextDialog(cid, item.itemid, table.concat(a, ""))
end
]]></action>
<action uniqueid="9900" event="script"> <![CDATA[
local cfg = {
chance = 10, -- Change this to raise up the success chance--
}
local t = {
[50001] = {slots = {2794, 2760, 2007}, name = "Antidote", item = 8474},
[50002] = {slots = {2787, 2804, 8302}, name = "Lesser Mana Potion", item = 7620},
[50003] = {slots = {2787, 2803, 8302}, name = "Medium Mana Potion", item = 7589},
[50004] = {slots = {2787, 2802, 8302}, name = "Strong Mana Potion", item = 7590},
[50005] = {slots = {2794, 2799}, name = "Small Health Potion", item = 8704},
[50006] = {slots = {2791, 2800, 8303}, name = "Lesser Health Potion", item = 7618},
[50007] = {slots = {2791, 2759, 8303}, name = "Medium Health Potion", item = 7588},
[50008] = {slots = {2791, 2801, 8303}, name = "Strong Health Potion", item = 7591},
[50009] = {slots = {2791, 5921, 8303}, name = "Great Health Potion", item = 8473},
[50010] = {slots = {2789, 2806, 8298}, name = "Spirit Potion", item = 8472},
[50011] = {slots = {2789, 7732, 8305, 2007}, name = "Speed Potion", item = 7439, aid = 41501},
[50012] = {slots = {2363, 2782, 8315}, name = "Potion of Strength", item = 7443, aid = 41502, desc = "This is a potion of strength."},
[50013] = {slots = {2363, 2796, 8315}, name = "Potion of Dexterity", item = 7443, aid = 41503, desc = "This is a potion of dexterity."},
[50014] = {slots = {2363, 2795, 8315}, name = "Potion of Endurance", item = 7443, aid = 41504, desc = "This is a potion of endurance."},
[50015] = {slots = {2783, 8301, 2177}, name = "Potion of Magic Level", item = 7443, aid = 41505, desc = "This is a potion of magic level."},
[50016] = {slots = {2788, 5015, 8299}, name = "Potion of Health", item = 7443, aid = 41506, desc = "This is a potion of health."},
[50017] = {slots = {2790, 5922, 8299}, name = "Potion of Mana", item = 7443, aid = 41507, desc = "This is a potion of mana."},
[50018] = {slots = {2798, 2177}, name = "Elixir", item = 7440, aid = 41508},
[50019] = {slots = {2007, 8303, 8298}, name = "Blood Orb", item = 2363},
[50020] = {slots = {2007, 2177, 8305, 8299}, name = "Soul Orb", item = 5944},
[50021] = {slots = {2007, 2177, 8315, 8301}, name = "Mind Orb", item = 2178,},
[50022] = {slots = {2178, 5944, 2363, 2153, 2154, 2155, 2156, 2158}, name = "Philosopher's Stone", item = 2348, aid = 41509}
}
function onUse(cid, item, toPosition, itemEx, fromPosition)
local container = getTileItemByType({x = toPosition.x+1, y = toPosition.y, z = toPosition.z}, 4)
local inContainer1, inContainer2, inContainer3, inContainer4, inContainer5, inContainer6, inContainer7, inContainer8, inContainer9 = 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)
local pass = 0
local inContainers = {inContainer2, inContainer3, inContainer4, inContainer5, inContainer6, inContainer7, inContainer8}
local k = t[inContainer1.actionid]
if getPlayerStorageValue(cid, inContainer1.actionid) == inContainer1.actionid-50000 then
if #k.slots == 8 then
if (isInArray(k.slots, inContainer2.itemid)) and (isInArray(k.slots, inContainer3.itemid)) and (isInArray(k.slots, inContainer4.itemid)) and (isInArray(k.slots, inContainer5.itemid)) and (isInArray(k.slots, inContainer6.itemid)) and (isInArray(k.slots, inContainer7.itemid)) and (isInArray(k.slots, inContainer8.itemid)) and (isInArray(k.slots, inContainer9.itemid)) then
for i2 = 1, #k.slots do
doRemoveItem(inContainers[i2].uid)
end
pass = 1
addCustomSkillTry(cid, "Alchemy", 50500)
else
doPlayerSendCancel(cid, "There are no Ingredients or the order of the ingredients are wrong.")
end
elseif #k.slots == 7 then
if (isInArray(k.slots, inContainer2.itemid)) and (isInArray(k.slots, inContainer3.itemid)) and (isInArray(k.slots, inContainer4.itemid)) and (isInArray(k.slots, inContainer5.itemid)) and (isInArray(k.slots, inContainer6.itemid)) and (isInArray(k.slots, inContainer7.itemid)) and (isInArray(k.slots, inContainer8.itemid)) then
for i2 = 1, #k.slots do
doRemoveItem(inContainers[i2].uid)
end
pass = 1
addCustomSkillTry(cid, "Alchemy", 50500)
else
doPlayerSendCancel(cid, "There are no Ingredients or the order of the ingredients are wrong.")
end
elseif #k.slots == 6 then
if (isInArray(k.slots, inContainer2.itemid)) and (isInArray(k.slots, inContainer3.itemid)) and (isInArray(k.slots, inContainer4.itemid)) and (isInArray(k.slots, inContainer5.itemid)) and (isInArray(k.slots, inContainer6.itemid)) and (isInArray(k.slots, inContainer7.itemid)) then
for i2 = 1, #k.slots do
doRemoveItem(inContainers[i2].uid)
end
pass = 1
addCustomSkillTry(cid, "Alchemy", 50500)
else
doPlayerSendCancel(cid, "There are no Ingredients or the order of the ingredients are wrong.")
end
elseif #k.slots == 5 then
if (isInArray(k.slots, inContainer2.itemid)) and (isInArray(k.slots, inContainer3.itemid)) and (isInArray(k.slots, inContainer4.itemid)) and (isInArray(k.slots, inContainer5.itemid)) and (isInArray(k.slots, inContainer6.itemid)) then
for i2 = 1, #k.slots do
doRemoveItem(inContainers[i2].uid)
end
pass = 1
addCustomSkillTry(cid, "Alchemy", 50500)
else
doPlayerSendCancel(cid, "There are no Ingredients or the order of the ingredients are wrong.")
end
elseif #k.slots == 4 then
if (isInArray(k.slots, inContainer2.itemid)) and (isInArray(k.slots, inContainer3.itemid)) and (isInArray(k.slots, inContainer4.itemid)) and (isInArray(k.slots, inContainer5.itemid)) then
for i2 = 1, #k.slots do
doRemoveItem(inContainers[i2].uid)
end
pass = 1
addCustomSkillTry(cid, "Alchemy", 50500)
else
doPlayerSendCancel(cid, "There are no Ingredients or the order of the ingredients are wrong.")
end
elseif #k.slots == 3 then
if (isInArray(k.slots, inContainer2.itemid)) and (isInArray(k.slots, inContainer3.itemid)) and (isInArray(k.slots, inContainer4.itemid)) then
for i2 = 1, #k.slots do
doRemoveItem(inContainers[i2].uid)
end
pass = 1
addCustomSkillTry(cid, "Alchemy", 50500)
else
doPlayerSendCancel(cid, "There are no Ingredients or the order of the ingredients are wrong.")
end
elseif #k.slots == 2 then
if (isInArray(k.slots, inContainer2.itemid)) and (isInArray(k.slots, inContainer3.itemid)) then
doRemoveItem(inContainer2.uid)
doRemoveItem(inContainer3.uid)
pass = 1
addCustomSkillTry(cid, "Alchemy", 50500)
else
doPlayerSendCancel(cid, "There are no Ingredients or the order of the ingredients are wrong.")
end
end
if pass == 1 and math.random(1, (100 + (getCustomSkill(cid, 50500) / 10))) <= getCustomSkill(cid, 50500) + cfg.chance then
doPlayerAddItem(cid, k.item,1)
doPlayerSendTextMessage(cid, 25, "You made..."..k.name..".")
if k.aid then
local getItem = getPlayerItemById(cid, true, k.item)
doItemSetAttribute(getItem.uid, "aid", k.aid)
end
if k.desc then
doItemSetAttribute(getItem.uid, "description", k.desc)
end
else
doPlayerSendCancel(cid, "The mix went wrong.")
end
else
doPlayerSendCancel(cid, "You haven't learned this recipe yet.")
end
return true
end
]]></action>
</mod>