• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action [MOD]Alchemy System - New UPDATE!

Where do I change the position of the basin or where you have to put your recipes to make the item?
 
3394-explain.png

find in the MOD for this line and change itemid inside the red box for the
itemid of the basin and you're set, also you can use any container for
alchemy but only the alchemy kit will give you a slight boost on success rate,
you have to go to items.xml and find this itemid '6104' and edit the name
and the slots to '9' and you have an Alchemy Kit!
 
if u want it to work with only 1 basin change what shinmaru has in red to a uid or actionid. also make sure to set it in your map editor to the same id

@ trader copy this into the bottom of your mod
<item id="6104" article="a" name="alchemy kit" override="yes">
<attribute key="weight" value="170" />
<attribute key="containerSize" value="10" />
</item>

also shinmaru if u want edit your first post and add it to the bottom that way its automatically there. then nothing will need to be edited outside of the mod.
 
it should work. Shinmaru has 0.4 so i would say yes. and i used 0.4 and everything seemed okay.
 
When I ask my npc for recipes, it says im not high enough, and I cant see any recipes in my book, how can people know what to cook?
 
When I ask my npc for recipes, it says im not high enough, and I cant see any recipes in my book, how can people know what to cook?

i think your using an old NPC. with the new 1 you can buy recipes no matter what alch skill you have. after u get the recipe paper use it to learn the recipe then use the book to find out what the recipe is.

BUMP AND UPDATED!!

Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Alchemy System" version="3.0" author="soul4soul" enabled="yes">
    <item id="1954" article="a" name="recipe paper" override="yes">
        <attribute key="weight" value="100" />
    </item>
    <item id="1965" article="a" name="book of alchemy" override="yes">
        <attribute key="weight" value="1300" />
    </item>
    <item id="6104" article="a" name="alchemy kit" override="yes">
        <attribute key="weight" value="170" />
        <attribute key="containerSize" value="10" />
    </item>
    <item id="8977" article="a" name="top characters encyclopedia" override="yes">
        <attribute key="description" value="A list of the best alchemists are inside." />
        <attribute key="weight" value="1337" />
    </item>
    <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 = 5, slots = {{5468, 1}, {2393, 1}}, difficulty = 50, destroy = 'yes'},
        [50012] = {item = 5887, alchemylvl = 5, slots = {{5468, 1}, {2487, 1}}, difficulty = 50, destroy = 'yes'},
        [50013] = {item = 5888, alchemylvl = 5, slots = {{5468, 1}, {2462, 1}}, difficulty = 50, destroy = 'yes'},
        [50014] = {item = 5889, alchemylvl = 5, slots = {{5468, 1}, {2516, 1}}, difficulty = 50, destroy = 'yes'},
        [50015] = {item = 5891, alchemylvl = 10, slots = {{2195, 1}, {4265, 1}, {2151, 1}}, difficulty = 40, destroy = 'yes'},
        [50016] = {item = 5884, alchemylvl = 10, slots = {{2498, 1}, {2498, 1}, {2913, 1}, {5865, 1}}, difficulty = 40, destroy = 'yes'},
        [50017] = {item = 5885, alchemylvl = 10, 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, skillTries + 1)
 
        if skillTries > math.floor(20 * math.pow(1.1, (skillStorage-11)) / 10) 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)) / 10)
        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]--     
    
    --[highscore book]--
function doPlayerShowHighscore(uid, storage, name)
    -- Function made by Ragheed and Zyntax from OTFans. --
    -- small edit by soul4soul
    if storage then
        if(isNumber(storage) == true) then
            if(isPlayer(uid)) then
                if name then
                    if(type(name)== 'string') then
                        if(string.len(name) <= 20) then
                            gameName = name
                        else
                            print("[ERROR] : doPlayerShowHighscore: name cannot be longer then 20 characters.")
                            return false
                        end
                    else
                        print("[ERROR] : doPlayerShowHighscore: name is not a string.")
                        return false
                    end
                else
                    gameName = "Game"
                end
                local shownPlayers = 10
                local str = ""..gameName.." Highscore:\n#  Player - [Score]\n"
                local result = db.getResult('SELECT `value`, `player_id` FROM `player_storage` WHERE `key`='..storage..' ORDER BY `value` DESC;')
                if(result:getID() ~= -1) then
                    local i = 1
                    while TRUE do
                        str = str .. "\n " .. i .. ". "..getPlayerNameByGUID(result:getDataInt("player_id")).." - [" .. result:getDataInt("value") .. "]"
                        if not(result:next()) or i > shownPlayers then
                            break
                        end
                        i = i+1
                    end
                    result:free()
                else
                    str = ""..gameName.." Highscore is empty."
                end
                if(str ~= "") then
                    doShowTextDialog(uid, 8977, str)
                end
            else
                print("[ERROR] : doPlayerShowHighscore: player not found.")
                return false
            end
        else
            print("[ERROR] : doPlayerSetHighscore: storage is not a number value.")
            return false
        end
    else
        print("[ERROR] : doPlayerShowHighscore: storage not found.")
        return false
    end
    return true
end    
--[/highscore book]--        
    ]]></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, 500, {cid = cid, toPosition = toPosition, fromPosition = fromPosition})
        else
            doPlayerSendCancel(cid, "You already know Alchemy.")
        end
        return true
    end    
    ]]></action>
    <action itemid="8977" event="buffer"><![CDATA[
        if item.actionid == 50500 then
            doPlayerShowHighscore(cid, item.actionid, "Alchemy")
        else
            _result = false
        end
    ]]></action>
    <action  itemid="1954"  event="script"><![CDATA[
        domodlib("recipeinfo")
        function onUse(cid, item, toPosition, item2, fromPosition)
            if item.actionid == nil then
                return true
            end
            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.. "]\n-Alchemy Level: " .. k.alchemylvl .. ", Difficulty: " .. k.difficulty .. "\n--Ingredients: recipe paper".. 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>

better recipe book better design fixed the random starting comma also shows the recipe difficulty
alchemy leveling is 100% fixed
highscore book displays the top players with the top skills

alch.png
 
Last edited:
I've posted the script for TFS 0.3.5 here, because it does not fit in OP due to characters limit.

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|| Alchemy System for TFS 0.3.5 ||
|| DISCONTINUED ||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

But I will leave the old one for those what still use TFS 0.3.5[/FONT]
Alchemy System TFS 0.3.5 MOD

[Install [Alchemy NPC 0.3.5] = Start]
Script Name: alchemyNPC.lua
Type: NPC
Lua Location: data/npc/scripts/
Lua Code:
Lua:
local focus = 0
local talk_start = 0

function onCreatureDisappear(cid, pos)
	if focus == cid then
		selfSay('Good bye then.')
		focus = 0
		talk_start = 0
	end
end

function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end

function onCreatureSay(cid, type, msg)
msg = string.lower(msg)

	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
		selfSay('Hello ' .. getCreatureName(cid) .. '! I sell all things related to "alchemy".')
		focus = cid
		talk_start = os.clock()

	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
		selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

	elseif focus == cid then
		talk_start = os.clock()

		if msgcontains(msg, 'alchemy') then
				selfSay('Ahh, yes I have "recipes", "recipe book", and "alchemic kits" , for sale which do you want to know more about?')
				talk_state = 1

		elseif talk_state == 1 then
			if msgcontains(msg, 'recipe book') then
					price = 1000
					selfSay('I have this recipe book that you can use to see the recipes you have learned, do you want to buy it for '.. price ..' gold?')
					talk_state = 4
					item = 1965
					rtrn = 1
			elseif msgcontains(msg, 'recipes') then
				if getPlayerStorageValue(cid, 50500) == -1 then
					selfSay('You don\'t seem to know much about alchemy go study first.')
					talk_state = 1
				else
					selfSay('Yes, I have a list of recipes for "beginner" and "advanced" Alchemists, which would you like to see?.')
					talk_state = 2
				end
			elseif msgcontains(msg, 'alchemic kit') then
					price = 10000
					selfSay('This is a special kit used just for alchemy, would you like to buy it for '.. price ..' gold?.')
					talk_state = 4
					item = 6104
					rtrn = 1
			elseif msgcontains(msg, 'bye') then
				selfSay('Good bye, ' .. getCreatureName(cid) .. '!')
				focus = 0
				talk_start = 0	
			end	
		elseif talk_state == 2 then
			if msgcontains(msg, 'beginner') then
				selfSay('At the beginner level I sell recipes for: "antidote", "platinum coin", "mind stone", "soul orb", "blood orb", "love potion", "ectoplasm", "weak mana rune", "crystal coin", "sparkling mummy doll". which one do you want?')
				talk_state = 3
			elseif msgcontains(msg, 'advanced') then
				selfSay('At the Advanced level I sell recipes for: "berserk potion", "mastermind potion", "bullseye potion", "mead horn", "gold bar", "mana rune", "clover amulet", "sword", "magic", "arrow". which one do you want?')
				talk_state = 3
			else
				selfSay('That\'s too bad, maybe next time.')
				talk_state = 1
			end
		elseif talk_state == 3 then
			item = 1954
			rtrn = 2
			if msgcontains(msg, 'antidote') then
				price = 1000
				selfSay('Do you want to buy an Antidote recipe for ' ..price.. ' gold?')
				action = 50001
				desc = 'This contains the recipe to make an Antidote.'
				talk_state = 4
			elseif msgcontains(msg, 'platinum coin') then
				price = 2000
				selfSay('For ' .. price ..' gold i can sell you the secert to minting platinum coins?')
				action = 50002
				desc = 'This contains the formula for minting Platinum Coins.'
				talk_state = 4
			elseif msgcontains(msg, 'mind stone') then
				price = 2000
				selfSay('Do you want to buy a Mind Stone recipe for ' ..price.. ' gold?')
				action = 50003
				desc = 'This contains the recipe to make a Mind Stones.'
				talk_state = 4	
			elseif msgcontains(msg, 'soul orb') then
				price = 2000
				selfSay('Do you want to buy a Soul Orb recipe for ' ..price.. ' gold?')
				action = 50004
				desc = 'This contains the recipe to make a Soul Orbs.'
				talk_state = 4	
			elseif msgcontains(msg, 'blood orb') then
				price = 5000
				selfSay('Do you want to buy a Blood Orb recipe for ' ..price.. ' gold?')
				action = 50005
				desc = 'This contains the recipe to make a Blood Orbs.'
				talk_state = 4
			elseif msgcontains(msg, 'love potion') then
				price = 30000
				selfSay('Do you want to buy a Love Potion recipe for ' ..price.. ' gold?')
				action = 50006
				desc = 'This contains the recipe to make a Love Potions.'
				talk_state = 4
			elseif msgcontains(msg, 'ectoplasm') then
				price = 20000
				selfSay('Do you want to buy a Ectoplasm recipe for ' ..price.. ' gold?')
				action = 50007
				desc = 'This contains the recipe to make some Ectoplasm.'
				talk_state = 4
			elseif msgcontains(msg, 'intense mana rune') then
				price = 60000
				selfSay('Do you want to buy a Intense Mana Rune recipe for ' ..price.. ' gold?')
				action = 50008
				desc = 'This contains the recipe to make a Intense Mana Runes.'
				talk_state = 4
			elseif msgcontains(msg, 'crystal coin') then
				price = 100000
				selfSay('For ' .. price ..' gold i can sell you the secert to minting crystal coins?')
				action = 50009
				desc = 'This contains the formula for minting Crystal coins.'
				talk_state = 4	
			elseif msgcontains(msg, 'sparkling mummy doll') then
				price = 100000
				selfSay('Do you want to buy a Sparkling Mummy Doll Recipe for ' ..price.. ' gold?')
				action = 50010
				desc = 'This contains the recipe to make a Sparkling Mummy Doll.'
				talk_state = 4
			elseif msgcontains(msg, 'berserk potion') then
				price = 100000	
				selfSay('Do you want to buy a Berserk Potion recipe for ' ..price.. ' gold?')
				action = 50018
				desc = 'This contains the recipe to make a Beserk Potion.'
				talk_state = 4	
			elseif msgcontains(msg, 'mastermind potion') then
				price = 100000
				selfSay('Do you want to buy a Mastermind Potion recipe for ' ..price.. ' gold?')
				action = 50019
				desc = 'This contains the recipe to make a Mastermind Potion.'
				talk_state = 4
			elseif msgcontains(msg, 'bullseye potion') then
				price = 100000
				selfSay('Do you want to buy a Bullseye Potion Recipe for ' ..price.. ' gold?')
				action = 50020
				desc = 'This contains the recipe to make a Bullseye Potion.'
				talk_state = 4	
			elseif msgcontains(msg, 'mead horn') then
				price = 200000
				selfSay('Do you want to buy a Mead Horn Recipe for ' ..price.. ' gold?')
				action = 50021
				desc = 'This contains the recipe to make a Mean Horn.'
				talk_state = 4	
			elseif msgcontains(msg, 'gold bar') then
				price = 10000000
				selfSay('For ' .. price ..' gold i can sell you the secret to minting gold bars?')
				action = 50022
				desc = 'This contains the formula for minting Gold Bars.'
				talk_state = 4
			elseif msgcontains(msg, 'ultimate mana rune') then
				price = 500000
				selfSay('Do you want to buy a Potion of Ultimate Mana Recipe for ' ..price.. ' gold?')
				action = 50023
				desc = 'This contains the recipe to make a Ultimate Mana rune.'
				talk_state = 4	
			elseif msgcontains(msg, 'clover amulet') then
				price = 1000000
				selfSay('Do you want to buy a Clover Amulet Recipe for ' ..price.. ' gold?')
				action = 50024
				desc = 'This contains the recipe to make a Clover Amulet.'
				talk_state = 4
			elseif msgcontains(msg, 'sword') then
				price = 2000000
				selfSay('Do you want to buy a sword Recipe for ' ..price.. ' gold?')
				action = 50025
				desc = 'This contains the recipe to make a sword.'
				talk_state = 4
			elseif msgcontains(msg, 'magic') then
				price = 2000000
				selfSay('Do you want to buy magic Recipe for ' ..price.. ' gold?')
				action = 50026
				desc = 'This contains the recipe to make magic.'
				talk_state = 4
			elseif msgcontains(msg, 'arrow') then
				price = 2000000
				selfSay('Do you want to buy an arrow Recipe for ' ..price.. ' gold?')
				action = 50027
				desc = 'This contains the recipe to make arrow.'
				talk_state = 4
			elseif msgcontains(msg, 'bye') then
				selfSay('Good bye, ' .. getCreatureName(cid) .. '!')
				focus = 0
				talk_start = 0	
			end	
		elseif talk_state == 4 then
			if msgcontains(msg, 'yes') then
				if getPlayerMoney(cid) >= price then
					selfSay('Here you go!')
					doPlayerRemoveMoney(cid, price)
					doPlayerAddItem(cid, item, 1)
					if action then
						doSetItemActioId(getPlayerItemById(cid, true, 1954).uid, action)
					end
					if desc then
						doSetItemSpecialDescription(getPlayerItemById(cid, true, 1954).uid, desc)
					end	
					if rtrn == 1 then
						talk_state = 2
					else	
						talk_state = 3
					end	
				else
					selfSay('You don\'t seem to have enough money.')
					if rtrn == 1 then
						talk_state = 2
					else	
						talk_state = 3
					end	
				end
			else
				selfSay('That\'s too bad, maybe next time.')
				if rtrn == 1 then
					talk_state = 2
				else	
					talk_state = 3
				end		
			end	
		elseif msgcontains(msg, 'bye') then
			selfSay('Good bye, ' .. getCreatureName(cid) .. '!')
			focus = 0
			talk_start = 0
		end
	elseif msgcontains(msg, 'bye') and focus == cid then
		selfSay('Good bye, ' .. getCreatureName(cid) .. '!')
		focus = 0
		talk_start = 0	
	end
end

function onThink()
	doNpcSetCreatureFocus(focus)
	if (os.clock() - talk_start) > 30 then
		if focus > 0 then
			selfSay('Next Please...')
		end
		focus = 0
	end
	if focus ~= 0 then
		if getDistanceToCreature(focus) > 5 then
			selfSay('Good bye then.')
			focus = 0
		end
	end
end
XML Location: data/npc/elric.xml
XML Code:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Elric" script="data/npc/scripts/alchemy.lua" walkinterval="3000">
<health now="100" max="100"/>
<look type="333"/>
</npc>
Extra Details: N/A
Description: NPC that sells all things related to Alchemy.
[Install [Alchemy NPC 0.3.5] = End]



[Install [Alchemy MOD 0.3.5] = Start]
Script Name: AlchemySystem.xml
Type: Action
MOD Location: mods/
MOD Code:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Alchemy System" version="2.0" author="375311/soul4soul" enabled="yes">
	<config name="recipeinfo"><![CDATA[
	t =  {
		--[uid] = {newitemid, lvl, slots = {items to be used},  difficulty = 10-90 by 10's}, 
        [50001] = {item = 8474, alchemylvl = 10, slots = {2007, 2795, 2760}, difficulty = 20},
        [50002] = {item = 2152, alchemylvl = 15, slots = {2148, 10608}, difficulty = 20},
        [50003] = {item = 2178, alchemylvl = 20, slots = {2177, 1295, 2146}, difficulty = 40},
        [50004] = {item = 5944, alchemylvl = 20, slots = {2177, 1295, 2150}, difficulty = 40},
        [50005] = {item = 2363, alchemylvl = 25, slots = {2177, 2177, 1295, 2798, 2788}, difficulty = 50},
        [50006] = {item = 10092, alchemylvl = 30, slots = {2677, 2677, 2677, 2677, 2677, 2013, 2015}, difficulty = 60},
        [50007] = {item = 4864, alchemylvl = 35, slots = {4850, 2913, 2144}, aid = 105, difficulty = 40},
        [50008] = {item = 2276, alchemylvl = 40, slots = {10558, 2260, 10554, 2151, 5951, 2265}, difficulty = 40},
        [50009] = {item = 2160, alchemylvl = 45, slots = {2152, 2145, 2146, 2800}, difficulty = 30},
        [50010] = {item = 11201, alchemylvl = 45, slots = {2759, 10565, 2803, 2692}, difficulty = 40},
        [50011] = {item = 5892, alchemylvl = 50, slots = {5468, 2393}, difficulty = 50},
        [50012] = {item = 5887, alchemylvl = 50, slots = {5468, 2487}, difficulty = 50},
        [50013] = {item = 5888, alchemylvl = 50, slots = {5468, 2462}, difficulty = 50},
        [50014] = {item = 5889, alchemylvl = 50, slots = {5468, 2516}, difficulty = 50},
        [50015] = {item = 5891, alchemylvl = 55, slots = {2195, 4265, 2151}, difficulty = 40},
        [50016] = {item = 5884, alchemylvl = 55, slots = {2498, 2498, 2913, 5865}, difficulty = 40},
        [50017] = {item = 5885, alchemylvl = 55, slots = {2475, 2475, 2475, 2475, 2015, 5865}, difficulty = 40},
        [50018] = {item = 7439, alchemylvl = 60, slots = {6558, 2007, 4993, 5480, 2796}, difficulty = 30},
        [50019] = {item = 7440, alchemylvl = 60, slots = {6558, 2007, 4992, 3955, 7250}, difficulty = 30},
        [50020] = {item = 7443, alchemylvl = 60, slots = {6558, 2007, 4994, 2193, 2031}, difficulty = 30},
        [50021] = {item = 7140, alchemylvl = 65, slots = {7141, 2015, 5014, 2235, 7439, 7440, 7443, 4845}, difficulty = 60},
        [50022] = {item = 9971, alchemylvl = 70, slots = {10552, 2157, 2159, 5906}, difficulty = 50},
		[50023] = {item = 2284, alchemylvl = 75, slots = {10523, 2260, 10554, 2151, 2273}, difficulty = 30},
		[50024] = {item = 11387, alchemylvl = 80, slots = {2805, 2798, 8582}, difficulty = 70},
		[50025] = {item = 8980, alchemylvl = 90, slots = {5941, 10559, 2194, 2377}, difficulty = 80},
		[50026] = {item = 2184, alchemylvl = 90, slots = {9942, 9941, 9980, 2445}, difficulty = 80},
		[50027] = {item = 2352, alchemylvl = 90, slots = {2177, 2160, 2544, 2544, 2802}, difficulty = 80},
		[50028] = {item = 9969, alchemylvl = 100, slots = {5741, 2229, 5669, 5809, 2143}, difficulty = 90},
		[50029] = {item = 9006, alchemylvl = 110, slots = {8859, 2289, 2807, 10556, 2545, 5879}, difficulty = 100},
		[50030] = {item = 2348, alchemylvl = 120, slots = {2153, 2154, 2155, 2156, 2158, 2260, 2260, 2600}, difficulty = 100}
        }    
		]]></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[
		function onUse(cid, item, toPosition, item2, fromPosition)
		domodlib("recipeinfo")
			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 "..getItemNameById(k.item)..".")
                    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
					recipe = ""..recipe..", ".. getItemNameById(k.slots[i2]) .. ""
				end
				recipe = "[" ..getItemNameById(k.item).. "]-Alchemy Level: " .. k.alchemylvl .. "\n Ingredients: ".. recipe .. ". \n\n"
				table.insert(a, recipe)
				recipe = ""
			end
		end
		doShowTextDialog(cid, item.itemid, table.concat(a, ""))		
	end
	]]></action>
	<movevent type="AddItem" tileitem="1" itemid="1426" event="script"><![CDATA[		
function onAddItem(moveItem, tileItem, position, cid) 
	domodlib("recipeinfo")
	if isContainer(moveItem.uid) then  
		local container = getTileItemByType(position, 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 k.slots[1] == inContainer2.itemid and k.slots[2] == inContainer3.itemid and k.slots[3] == inContainer4.itemid and k.slots[4] == inContainer5.itemid and k.slots[5] == inContainer6.itemid and k.slots[6] == inContainer7.itemid and k.slots[7] == inContainer8.itemid and k.slots[8] == inContainer9.itemid then
					for i2 = 1, #k.slots do
						doRemoveItem(inContainers[i2].uid,1 )
					end
					pass = 1				
				end            
			elseif #k.slots == 7 then
				if k.slots[1] == inContainer2.itemid and k.slots[2] == inContainer3.itemid and k.slots[3] == inContainer4.itemid and k.slots[4] == inContainer5.itemid and k.slots[5] == inContainer6.itemid and k.slots[6] == inContainer7.itemid and k.slots[7] == inContainer8.itemid then          
					for i2 = 1, #k.slots do
						doRemoveItem(inContainers[i2].uid,1 )
					end
					pass = 1
				end            
			elseif #k.slots == 6 then
				if k.slots[1] == inContainer2.itemid and k.slots[2] == inContainer3.itemid and k.slots[3] == inContainer4.itemid and k.slots[4] == inContainer5.itemid and k.slots[5] == inContainer6.itemid and k.slots[6] == inContainer7.itemid then
					for i2 = 1, #k.slots do
						doRemoveItem(inContainers[i2].uid, 1)
					end
					pass = 1
				end             
			elseif #k.slots == 5 then
				if k.slots[1] == inContainer2.itemid and k.slots[2] == inContainer3.itemid and k.slots[3] == inContainer4.itemid and k.slots[4] == inContainer5.itemid and k.slots[5] == inContainer6.itemid then      
					for i2 = 1, #k.slots do
						doRemoveItem(inContainers[i2].uid, 1)
					end
					pass = 1
				end            
			elseif #k.slots == 4 then
				if k.slots[1] == inContainer2.itemid and k.slots[2] == inContainer3.itemid and k.slots[3] == inContainer4.itemid and k.slots[4] == inContainer5.itemid then    
					for i2 = 1, #k.slots do
						doRemoveItem(inContainers[i2].uid, 1)
					end
					pass = 1  
				end            
			elseif #k.slots == 3 then
				if k.slots[1] == inContainer2.itemid and k.slots[2] == inContainer3.itemid and k.slots[3] == inContainer4.itemid then
					for i2 = 1, #k.slots do
						doRemoveItem(inContainers[i2].uid, 1)
					end
					pass = 1
				end              
			elseif #k.slots == 2 then
				if k.slots[1] == inContainer2.itemid and k.slots[2] == inContainer3.itemid then
					doRemoveItem(inContainer2.uid, 1)
					doRemoveItem(inContainer3.uid, 1)
					pass = 1						
				end            
			end
			if pass == 1 then
				if moveItem.itemid == 6104 then
					chance = k.difficulty-10
				else
					chance = k.difficulty
				end
				if math.random(1, (100 + (getCustomSkill(cid, 50500) / 10))) >= chance then
					doPlayerAddItem(cid, k.item,1)
					doSendMagicEffect(position, CONST_ME_HITBYFIRE)
					doPlayerSendTextMessage(cid, 25, "You made..."..getItemNameById(k.item)..".")
					local 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)
						doSetItemActionId(getItem.uid, k.aid)
					end
				else
					doPlayerSendCancel(cid, "The mix went wrong.")
					doCreatureAddHealth(cid, -getCreatureMaxHealth(cid)*0.01)
					doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREAREA)
					addCustomSkillTry(cid, "Alchemy", 50500)
				end
			else
					doPlayerSendCancel(cid, "There are no ingredients, some are missing or they are out of their order.")
			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>
Extra Details: When making potions, you need to make sure
you place them in their respective order.
Description: This MOD is contains all of the other scripts which allows the player to learn
recipes, learn alchemy, get their alchemy skill and read their ingredients book.
[Install [Alchemy MOD 0.3.5] = End]
 
I still have the problem of: You don't seem to know much about alchemy go study first.
I'm already using TFS 0.3.6
 
@up2 its possible, just add line about getplayervocation etc either when talking with NPC or using book of alchemy.

I want you to help me with one thing Shinmaru. Actually can you change this script to make command with talkactions which will tell player what skill and % he has instead of clicking a book ? Also is there option to add new skill like mining and just add line like "AddSkillTries" in any custom action script level up in skill on action ?

http://otland.net/f132/important-mod-request-help-186562/
 
Yeah, TFS 1.0 would be appriciated.
Good job tho.

Kind Regards,
Eldin.
 
Back
Top