• 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.

NPC That enchants all 8.1 weapons for you, 1 npc each element or all-in-one.

1: Tested on the TFS servers from the 0.2 series.

100% sure it work with:
0.2.10
0.2.11
0.2.12
0.2.13

2:
data/npc

allenchant.xml
PHP:
<?xml version="1.0"?>

<npc name="All Enchanter" script="data/npc/scripts/allenchant.lua" access="5" lookdir="2" autowalk="25">
	<mana now="800" max="800"/>
	<health now="200" max="200"/>
<look type="133" head="57" body="79" legs="110" feet="91" addons="1" />
</npc>

data/npc/script
allenchant.lua
PHP:
local FireEnch = {vocs={1, 5}, lvl=30, ing1=2152, count1=60, ing2=2795, count2=5}
local EnergyEnch = {vocs={1, 5}, lvl=30, ing1=2152, count1=60, ing2=2124, count2=1}
local IceEnch = {vocs={2, 6}, lvl=30, ing1=2152, count1=60, ing2=7290, count2=5}
local EarthEnch = {vocs={2, 6}, lvl=30, ing1=2152, count1=60, ing2=4850, count2=1}
 
 
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false
 
function onCreatureDisappear(cid, pos)
      if focus == cid then
          selfSay('Good bye then.')
          focus = 0
          talk_start = 0
      end
end
 
local Weapons = {
        ["spike sword"]={n=2383, F=7744, E=7869, I=7763, N=7854},
        ["barbarian axe"]={n=2429, F=7749, E=7874, I=7768, N=7859},
        ["relic sword"]={n=7383, F=7745, E=7870, I=7764, N=7855},
        ["blacksteel sword"]={n=7406, F=7747, E=7872, I=7766, N=7857},
        ["dragon slayer"]={n=7402, F=7748, E=7873, I=7767, N=7858},
        ["mystic blade"]={n=7384, F=7746, E=7871, I=7765, N=7856},
        ["knight axe"]={n=2430, F=7750, E=7875, I=7769, N=7860},
        ["heroic axe"]={n=7389, F=7751, E=7876, I=7770, N=7861},
        ["headchopper"]={n=7380, F=7752, E=7877, I=7771, N=7862},
        ["war axe"]={n=2454, F=7753, E=7878, I=7772, N=7863},
        ["clerical mace"]={n=2423, F=7754, E=7879, I=7773, N=7864},
        ["crystal mace"]={n=2445, F=7755, E=7880, I=7774, N=7865},
        ["cranial basher"]={n=7415, F=7756, E=7881, I=7775, N=7866},
        ["orcish maul"]={n=7392, F=7757, E=7882, I=7776, N=7867},
        ["war hammer"]={n=2391, F=7758, E=7883, I=7777, N=7868}
        }
 
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, I am an enchanter, what do you seek?')
          focus = cid
          talk_start = os.clock()
 
      elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
          selfSay('Sorry, ill talk you in a minute.')
 
    elseif focus == cid then
        talk_start = os.clock()
        local pVoc = getPlayerVocation(cid)
        local pLvl = getPlayerLevel(cid)
        if msgcontains(msg, 'enchant') then
            selfSay('What element you want to enchant ?')
            talk_state = 1
        elseif talk_state == 1 then
            if msgcontains(msg, 'fire') then
                if isInArray(FireEnch.vocs, pVoc) == TRUE then
                    if pLvl >= FireEnch.lvl then 
                        selfSay('What weapon do you want to enchant to the fire version?')
                        talk_state = 2
                    else
                        selfSay('sorry, you don\'t have the enough level.')
                    end
                else
                    selfSay('sorry, you don\'t have the required vocation.')
                end
            elseif msgcontains(msg, 'energy') then
                if isInArray(EnergyEnch.vocs, pVoc) == TRUE then
                    if pLvl >= EnergyEnch.lvl then 
                        selfSay('What weapon do you want to enchant to the energy version?')
                        talk_state = 3
                    else
                        selfSay('sorry, you don\'t have the enough level.')
                    end
                else
                    selfSay('sorry, you don\'t have the required vocation.')
                end                        
            elseif msgcontains(msg, 'ice') then
                if isInArray(IceEnch.vocs, pVoc) == TRUE then
                    if pLvl >= IceEnch.lvl then             
                        selfSay('What weapon do you want to enchant to the ice version?')
                        talk_state = 4
                    else
                        selfSay('sorry, you don\'t have the enough level.')
                    end
                else
                    selfSay('sorry, you don\'t have the required vocation.')
                end        
            elseif msgcontains(msg, 'nature') or msgcontains(msg, 'earth') then
                if isInArray(EarthEnch.vocs, pVoc) == TRUE then
                    if pLvl >= EarthEnch.lvl then    
                        selfSay('What weapon do you want to enchant to the nature version?')
                        talk_state = 5
                    else
                        selfSay('sorry, you don\'t have the enough level.')
                    end
                else
                    selfSay('sorry, you don\'t have the required vocation.')
                end        
            end
        elseif talk_state == 2 then
            local Ench = Weapons[msg]
            if Ench then
                if getPlayerItemCount(cid, FireEnch.ing1) >= FireEnch.count1 and getPlayerItemCount(cid, FireEnch.ing2) >= FireEnch.count2 then
                    if getPlayerItemCount(cid, Ench.n) >= 1 then
                        doPlayerRemoveItem(cid, FireEnch.ing1, FireEnch.count1)
                        doPlayerRemoveItem(cid, FireEnch.ing2, FireEnch.count2)
                        doPlayerRemoveItem(cid, Ench.n, 1)
                        selfSay('Enchantmenth completed, here is your weapon.')
                        doPlayerAddItem(cid, Ench.F, 1)
                    else
                        selfSay("I need ".. FireEnch.count1 .." ".. getItemName(FireEnch.ing1) ..", ".. FireEnch.count2 .." ".. getItemName(FireEnch.ing2) .." and borrow the weapon, or else i cant enchant the weapon for you.")
                    end
                else
                     selfSay("I need ".. FireEnch.count1 .." ".. getItemName(FireEnch.ing1) ..", ".. FireEnch.count2 .." ".. getItemName(FireEnch.ing2) .." and borrow the weapon, or else i cant enchant the weapon for you.")
                end
            else
                selfSay('This weapon is not in the list.')
            end
        elseif talk_state == 3 then
            local Ench = Weapons[msg]
            if Ench then
                if getPlayerItemCount(cid, EnergyEnch.ing1) >= EnergyEnch.count1 and getPlayerItemCount(cid, EnergyEnch.ing2) >= EnergyEnch.count2 then
                    if getPlayerItemCount(cid, Ench.n) >= 1 then
                        doPlayerRemoveItem(cid, EnergyEnch.ing1, EnergyEnch.count1)
                        doPlayerRemoveItem(cid, EnergyEnch.ing2, EnergyEnch.count2)
                        doPlayerRemoveItem(cid, Ench.n, 1)
                        selfSay('Enchantmenth completed, here is your weapon.')
                        doPlayerAddItem(cid, Ench.E, 1)
                    else
                        selfSay("I need ".. EnergyEnch.count1 .." ".. getItemName(EnergyEnch.ing1) ..", ".. EnergyEnch.count2 .." ".. getItemName(EnergyEnch.ing2) .." and borrow the weapon, or else i cant enchant the weapon for you.")
                    end
                else
                    selfSay("I need ".. EnergyEnch.count1 .." ".. getItemName(EnergyEnch.ing1) ..", ".. EnergyEnch.count2 .." ".. getItemName(EnergyEnch.ing2) .." and borrow the weapon, or else i cant enchant the weapon for you.")
                end
            else
                selfSay('This weapon is not in the list.')
            end
        elseif talk_state == 4 then
            local Ench = Weapons[msg]
            if Ench then
                if getPlayerItemCount(cid, IceEnch.ing1) >= IceEnch.count1 and getPlayerItemCount(cid, IceEnch.ing2) >= IceEnch.count2 then
                    if getPlayerItemCount(cid, Ench.n) >= 1 then
                        doPlayerRemoveItem(cid, IceEnch.ing1, IceEnch.count1)
                        doPlayerRemoveItem(cid, IceEnch.ing2, IceEnch.count2)
                        doPlayerRemoveItem(cid, Ench.n, 1)
                        selfSay('Enchantmenth completed, here is your weapon.')
                        doPlayerAddItem(cid, Ench.I, 1)
                    else
                        selfSay("I need ".. IceEnch.count1 .." ".. getItemName(IceEnch.ing1) ..", ".. IceEnch.count2 .." ".. getItemName(IceEnch.ing2) .." and borrow the weapon, or else i cant enchant the weapon for you.")
                    end
                else
                    selfSay("I need ".. IceEnch.count1 .." ".. getItemName(IceEnch.ing1) ..", ".. IceEnch.count2 .." ".. getItemName(IceEnch.ing2) .." and borrow the weapon, or else i cant enchant the weapon for you.")
                end
            else
                selfSay('This weapon is not in the list.')
            end
        elseif talk_state == 5 then
            local Ench = Weapons[msg]
            if Ench then
                if getPlayerItemCount(cid, EarthEnch.ing1) >= EarthEnch.count1 and getPlayerItemCount(cid, EarthEnch.ing2) >= EarthEnch.count2 then
                    if getPlayerItemCount(cid, Ench.n) >= 1 then
                        doPlayerRemoveItem(cid, EarthEnch.ing1, EarthEnch.count1)
                        doPlayerRemoveItem(cid, EarthEnch.ing2, EarthEnch.count2)
                        doPlayerRemoveItem(cid, Ench.n, 1)
                        selfSay('Enchantmenth completed, here is your weapon.')
                        doPlayerAddItem(cid, Ench.N, 1)
                    else
                        selfSay("I need ".. EarthEnch.count1 .." ".. getItemName(EarthEnch.ing1) ..", ".. EarthEnch.count2 .." ".. getItemName(EarthEnch.ing2) .." and borrow the weapon, or else i cant enchant the weapon for you.")
                    end
                else
                    selfSay("I need ".. EarthEnch.count1 .." ".. getItemName(EarthEnch.ing1) ..", ".. EarthEnch.count2 .." ".. getItemName(EarthEnch.ing2) .." and borrow the weapon, or else i cant enchant the weapon for you.")
                end
            else
                selfSay('This weapon is not in the list.')
            end
        end
    elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
        selfSay('Goodbye!')
        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
 
get error at starting:

I already edit weapons and weapon script's ;p

The problem comes after i edit the weapons.xml
 

Attachments

Last edited:
have you not considered doing it more like RL tibia?
Or do you just prefer it this way?
Just wondering. I might use the items.xml and other things but get rid of the npc and use the gems and make it more like rl tibia. Thanks for sharing it:p
 
Znote,

Maybe u will post here the arrow.lua's at your first post too. Without the .luas not working bzw. get erros at starting. i fixed it now but the link to the .lua's abit small. It's only my opinion but your work stay great:wub:




2.) I get scared now, i using tfs 0.2.13 and i dont know if the itme's who the player needs for the enhanted weapons are working. what itms needed?
 

Attachments

Last edited:
Ahh, ye, well its working, its just that the arrows arent working, the other weapons are working! :p

data/weapons/scripts

flash_arrow.lua

PHP:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FLASHARROW)
--setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, 0, 0, 0)

function getSpellDamage(cid, weaponSkill, weaponAttack, attackStrength)
	local level = getPlayerLevel(cid)
	local attack = 25
	local skill = getPlayerSkill(cid, CONST_SKILL_DISTANCE)
	
	local min = 0
	local max = -(attack/20*skill+attack+skill+level/10)/10*10

	return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "getSpellDamage")

function onUseWeapon(cid, var)
	return doCombat(cid, combat, var)
end

flaming_arrow.lua
PHP:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FLAMMINGARROW)
--setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, 0, 0, 0)

function getSpellDamage(cid, weaponSkill, weaponAttack, attackStrength)
	local level = getPlayerLevel(cid)
	local attack = 25
	local skill = getPlayerSkill(cid, CONST_SKILL_DISTANCE)
	
	local min = 0
	local max = -(attack/20*skill+attack+skill+level/10)/10*10

	return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "getSpellDamage")

function onUseWeapon(cid, var)
	return doCombat(cid, combat, var)
end

shiver_arrow.lua
PHP:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SHIVERARROW)
--setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, 0, 0, 0)

function getSpellDamage(cid, weaponSkill, weaponAttack, attackStrength)
	local level = getPlayerLevel(cid)
	local attack = 25
	local skill = getPlayerSkill(cid, CONST_SKILL_DISTANCE)
	
	local min = 0
	local max = -(attack/20*skill+attack+skill+level/10)/10*10

	return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "getSpellDamage")

function onUseWeapon(cid, var)
	return doCombat(cid, combat, var)
end

earth_arrow.lua
PHP:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_STONES)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTHARROW)
--setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, 0, 0, 0)

function getSpellDamage(cid, weaponSkill, weaponAttack, attackStrength)
	local level = getPlayerLevel(cid)
	local attack = 25
	local skill = getPlayerSkill(cid, CONST_SKILL_DISTANCE)
	
	local min = 0
	local max = -(attack/20*skill+attack+skill+level/10)/10*10

	return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "getSpellDamage")

function onUseWeapon(cid, var)
	return doCombat(cid, combat, var)
end
 
Last edited:
Just use my script? And change the ID's?

My script was generally an "trade item for another item" script.
 
Yeah but, i want learn it. When i do something i want learn it. Idk why but when u would say this this and this and gimme links for it i will read a whole day and would learn it. I have fun at learn.



But thank you for suggestion
 
Yeah but, i want learn it. When i do something i want learn it. Idk why but when u would say this this and this and gimme links for it i will read a whole day and would learn it. I have fun at learn.



But thank you for suggestion

Open the script in a program called notepad++, then its very easy to read, especially for newbeginners. To read and understand the language lua.

Also you can easily shorten my script there :p
 
Don't use that link, I won't bother downloading stuff for a so advertising site, use otland please.
 
Hey, could someone put all that in organised files already? So that all you have to do is, copy -> paste. It would save a lot of time to futur users.
 
Man, I tested it on TFS 2.12
All worked fine...But the enchanted weapons don't have Charges...
I revised the Items.xml and it have Charges on...But in game, doesn't show, and with one hit it dissapears...
And when I enchant any weapon and I relog, it just appear a normal weapon again, without any enchant

Can anyone help?

Thanks
 
Last edited:
Remove
Code:
		<attribute key="decayTo" value="xxxx"/>

In items.xml on the weapons, I believe this will work?

If you want it unlimited, then also remove the charges.
 
Thank you for your wonderful work! rep+

I don't know if it should be but when you change char the echant change? And I hit one time whit a ice enchants weapon and the ice enchant was gone.
 
Last edited:
Nharuto's all in one, no.

But if you do it the long way piece by piece I think so, since I use pretty common lua functions.
 
Back
Top