Diezal
Newbie
- Joined
- Oct 13, 2011
- Messages
- 50
- Reaction score
- 0
Hello fellow otlanders,
I wanted to transform a certain weapon (dragon slayer) to a stronger weapon (avanger) by using an item (glimmering soil), so I copied the standard enchantment script that was located in one of my server folders and modified it a little.
Now my question is: If I want to add more items to be transformed what is the best thing to do?
Thanks in advance!
I wanted to transform a certain weapon (dragon slayer) to a stronger weapon (avanger) by using an item (glimmering soil), so I copied the standard enchantment script that was located in one of my server folders and modified it a little.
Lua:
local config = {
manaCost = 0,
soulCost = 100
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(item.itemid == 8299 and itemEx.itemid == 7402) then
doTransformItem(itemEx.uid, 6528)
doDecayItem(itemEx.uid)
doRemoveItem(item.uid, 1)
doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
return true
end
if(isInArray(enchantableGems, item.itemid)) then
local subtype = item.type
if(subtype == 0) then
subtype = 1
end
local mana = config.manaCost * subtype
if(getPlayerMana(cid) < mana) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHMANA)
return true
end
local soul = config.soulCost * subtype
if(getPlayerSoul(cid) < soul) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHSOUL)
return true
end
local a = table.find(enchantableGems, item.itemid)
if(a == nil or not isInArray(enchantingAltars[a], itemEx.itemid)) then
return false
end
doTransformItem(item.uid, enchantedGems[a])
doPlayerAddMana(cid, -mana)
doPlayerAddSoul(cid, -soul)
doPlayerAddSpentMana(cid, mana)
doSendMagicEffect(fromPosition, CONST_ME_HOLYDAMAGE)
return true
end
if(isInArray(enchantedGems, item.itemid)) then
if(not isInArray(enchantableItems, itemEx.itemid)) then
doSendMagicEffect(fromPosition, CONST_ME_POFF)
return false
end
local b = table.find(enchantedGems, item.itemid)
if(b == nil) then
return false
end
local subtype = itemEx.type
if(not isInArray({2544, 8905}, itemEx.itemid)) then
subtype = 1000
end
doTransformItem(itemEx.uid, enchantedItems[itemEx.itemid][b], subtype)
doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_HOLYDAMAGE)
doDecayItem(itemEx.uid)
doRemoveItem(item.uid, 1)
return true
end
return false
end
Now my question is: If I want to add more items to be transformed what is the best thing to do?
Thanks in advance!