Mera Mero
Guess Who?
- Joined
- Dec 27, 2014
- Messages
- 417
- Reaction score
- 86
Hi , I've found script that changes item id 2401 to 2433 to use item 2433 on attack But when I used it once it's returned to 2401 but i need this item 2433 to have charges Limit 500 hmm i mean with that after 500 hits item 2433 returns to 2401 and every charge need 1 x item
And I've added charges on items.xml
Action.xml
TFS 0.3.6
Code:
local config = {
manaCost = 300,
soulCost = 2
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(item.itemid == 2147 and itemEx.itemid == 2342) then
doTransformItem(itemEx.uid, 2343)
doDecayItem(itemEx.uid)
doRemoveItem(item.uid, 1)
doSendMagicEffect(toPosition, CONST_ME_MAGIC_RED)
return true
end
if(item.itemid == 2147 and isInArray({2401}, itemEx.itemid)) then
doTransformItem(itemEx.uid, 2433)
doRemoveItem(item.uid, 1)
doSendMagicEffect(toPosition, CONST_ME_MAGIC_RED)
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
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
Code:
<attribute key="charges" value="500"/>
<attribute key="decayTo" value="2401"/>
Code:
<action itemid="2147" event="script" value="Death.lua"/>