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

Action Item's upgrading by jewels ver. 3 [FOR TFS 0.3.6]

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Reaction score
53
Location
Włocławek
Hello, Im upgrade my script from TFS 0.3.4 to 0.3.6, because many people msg me for I do it. ; )
Not for commercial uses ! If you wan't add it to sms shop - pay me 5€! You earn money - me too want!
v.3.1 - Script is rewrote and is more optimized, readable (shortly) and have more functions : )

Now if you upgrading lose - you item back to +X level!!!


Old Versions:

How to install?
in data/actions/actions.xml
under:
PHP:
<actions>
add:
PHP:
<action itemid="2147" event="script" value="upgrading.lua"/>

and in folder data/actions/scripts/ make new file and rename it to upgrading.lua and paste to file this code:
PHP:
local conf = {}

conf["level"] = {
-- [item_level] = {successParcent=PARCENT FOR UPGRADING SUCCESS, downrageLevel = IF UPGRADING FAIL - ITEM WAS DECRASED TO LEVEL HERE}
 [1] = {successParcent = 85, downrageLevel = 0},
 [2] = {successParcent = 80, downrageLevel = 1},
 [3] = {successParcent = 75, downrageLevel = 2},
 [4] = {successParcent = 70, downrageLevel = 3},
 [5] = {successParcent = 65, downrageLevel = 4},
 [6] = {successParcent = 60, downrageLevel = 5},
 [7] = {successParcent = 55, downrageLevel = 0},
 [8] = {successParcent = 50, downrageLevel = 0},
 [9] = {successParcent = 45, downrageLevel = 0}
}
conf["upgrade"] = { -- how many parcent attributes are rised?
    attack = 5, -- attack %
    extraAttack = 10, -- extra Attack %
    defense = 5, -- defence %
    extraDefense = 10, -- extra defence %
    armor = 5, -- armor %
    hitChance = 5, -- hit chance %
}

-- // do not touch // -- 
-- Upgrading system v.3.1 by Azi [Ersiu] --
local upgrading = {
	upValue = function (value, level, parcent)
		if(not(value>0))then return 0 end 
		for i=1,level do
			value = math.ceil(((value/100)*parcent)+value)+1
		end
		return (value > 0) and value or 0
	end,

	getLevel = function (item)
		local name = string.explode(getItemName(item), '+')
		return (#name == 1) and 0 or math.abs(name[2])
	end,
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local getItem = getItemInfo(itemEx.itemid)
	if((getItem.weaponType > 0 or getItem.armor > 0) and not isItemStackable(itemEx.itemid))then
		local level = upgrading.getLevel(itemEx.uid)
		if(level < #conf["level"])then
			local nLevel = (conf["level"][(level+1)].successParcent >= math.random(1,100)) and (level+1) or conf["level"][level].downrageLevel
			if(nLevel > level)then
				doSendMagicEffect(toPosition, 30)
				doPlayerSendTextMessage(cid, 22, "Congratz! Upgraded was successful, your item has become stronger!")
			else
				doSendMagicEffect(toPosition, 2)
				doPlayerSendTextMessage(cid, 22, "Argh! Upgrading fail... you item lost some of strong!")
			end
			doItemSetAttribute(itemEx.uid, "name", getItem.name..((nLevel>0) and "+"..nLevel or "")) 
			doItemSetAttribute(itemEx.uid, "attack",  upgrading.upValue(getItem.attack, nLevel, conf["upgrade"].attack))
			doItemSetAttribute(itemEx.uid, "extraattack", upgrading.upValue(getItem.extraAttack, nLevel, conf["upgrade"].extraAttack))
			doItemSetAttribute(itemEx.uid, "defense", upgrading.upValue(getItem.defense,nLevel, conf["upgrade"].defense))
			doItemSetAttribute(itemEx.uid, "extradefense", upgrading.upValue(getItem.extraDefense, nLevel, conf["upgrade"].extraDefense))
			doItemSetAttribute(itemEx.uid, "armor", upgrading.upValue(getItem.armor, nLevel, conf["upgrade"].armor))
			doItemSetAttribute(itemEx.uid, "hitChance", upgrading.upValue(getItem.hitChance,nLevel, conf["upgrade"].hitChance))
			doRemoveItem(item.uid, 1)
		else
			doPlayerSendTextMessage(cid, 19, "Sorry this item is on max level.")
		end
	else
		doPlayerSendTextMessage(cid, 19, "You cannot upgrade this item.")
	end
end



All configurations in script - config section!


If you like it - rep me! :)
Please, don't copy this script to other forums.


Yours, Azi.
Thanks.
 
Last edited:
The size of this script can be minimized to almost nothing, therefor it will return faster.
 
The size of this script can be minimized to almost nothing, therefor it will return faster.
We don't need that, Lua is already fast enough.

But it's a bad idea to parse this every time the script is executed, why not just use getItemInfo(itemid) ?
 
#up
i anserwer you in Qwe thread. Maybe look first for anserwers and next post the same text? : ))
In doc/lua_functions this function is dont exists... if i have some time i post new version with getItemInfo, but now im scripting my PVP-Enfo. Maybe today at evening i post it. : )

Today at evening i post version 3.1! More optimized :)
 
good work.:p
Note it be nice when you get like the last upgrade it says like cograts you made a perfect upgraded weapon. and wont let you use upgrade gems on it anymore.
 
Last edited:
So, it's nice system and you no need my function for it, Im using this for older version, which haven't getItemInfo. Good job Azi! :)
 
upgrade level limit???

PHP:
-- [item_level] = {successParcent=PARCENT FOR UPGRADING SUCCESS, downrageLevel = IF UPGRADING FAIL - ITEM WAS DECRASED TO LEVEL HERE}
 [1] = {successParcent = 85, downrageLevel = 0},
 [2] = {successParcent = 80, downrageLevel = 1},
 [3] = {successParcent = 75, downrageLevel = 2},
 [4] = {successParcent = 70, downrageLevel = 3},
 [5] = {successParcent = 65, downrageLevel = 4},
 [6] = {successParcent = 60, downrageLevel = 5},
 [7] = {successParcent = 55, downrageLevel = 0},
 [8] = {successParcent = 50, downrageLevel = 0},
 [9] = {successParcent = 45, downrageLevel = 0}
}
Limit = upgrading table rows. in example - 9 : )
If you want less - delete some, if you need more add:

example:
Code:
 [1] = {successParcent = 85, downrageLevel = 0},
 [2] = {successParcent = 80, downrageLevel = 1},
 [3] = {successParcent = 75, downrageLevel = 2},
 [4] = {successParcent = 70, downrageLevel = 3},
 [5] = {successParcent = 65, downrageLevel = 4},
 [6] = {successParcent = 60, downrageLevel = 5},
 [7] = {successParcent = 55, downrageLevel = 0},
 [8] = {successParcent = 50, downrageLevel = 0},
 [9] = {successParcent = 45, downrageLevel = 0},
 [B][10] = {successParcent = 40, downrageLevel = 0}, 
 [11] = {successParcent = 35, downrageLevel = 0},
 [12] = {successParcent = 30, downrageLevel = 0},
 [13] = {successParcent = 25, downrageLevel = 0}
[/B]}
 
Well done, Azi! :D I rep'd you ^^
 
Last edited:
Hi men, i'd like to request some, i like your system is pretty smart, and i have a doubt

How can I add speed to an item?
For example, upgrade like 10% speed to a boots of haste, thanks in advance

and other thing, how can i put the continuation of the upgrades?

for example
x stone: lv 1,2,3,4,5... to 10
y stone: lv 11 -- 20
z stone: lv 21+

and so on.... thank you in advance
 
#up
1. cannot upgrade items speed increasing.

2. you can make 3 files upgrading1,upgrading2,upgrading3.lua

and make in files:
stone 1-
PHP:
conf["level"] = {
 [1] = {successParcent = 85, downrageLevel = 0},
 [2] = {successParcent = 80, downrageLevel = 1},
 [3] = {successParcent = 75, downrageLevel = 2},
 [4] = {successParcent = 70, downrageLevel = 3},
 [5] = {successParcent = 65, downrageLevel = 4},
 [6] = {successParcent = 60, downrageLevel = 5},
 [7] = {successParcent = 55, downrageLevel = 0},
 [8] = {successParcent = 50, downrageLevel = 0},
 [9] = {successParcent = 45, downrageLevel = 0},
 [10] = {successParcent = 40, downrageLevel = 0}, 
}
and in actions.xml:
<action itemid="STONE_ID" event="script" value="upgrading1.lua"/>
stone 2-:
PHP:
conf["level"] = {
 [11] = {successParcent = 85, downrageLevel = 0},
 [12] = {successParcent = 80, downrageLevel = 1},
 [13] = {successParcent = 75, downrageLevel = 2},
 [14] = {successParcent = 70, downrageLevel = 3},
 [15] = {successParcent = 65, downrageLevel = 4},
 [16] = {successParcent = 60, downrageLevel = 5},
 [17] = {successParcent = 55, downrageLevel = 0},
 [18] = {successParcent = 50, downrageLevel = 0},
 [19] = {successParcent = 45, downrageLevel = 0},
 [20] = {successParcent = 40, downrageLevel = 0}, 
}
and in actions.xml:
<action itemid="STONE_ID" event="script" value="upgrading2.lua"/>

stone3-:
PHP:
conf["level"] = {
 [21] = {successParcent = 85, downrageLevel = 0},
 [22] = {successParcent = 80, downrageLevel = 1},
 [23] = {successParcent = 75, downrageLevel = 2},
 [24] = {successParcent = 70, downrageLevel = 3},
 [25] = {successParcent = 65, downrageLevel = 4},
 [26] = {successParcent = 60, downrageLevel = 5},
 [27] = {successParcent = 55, downrageLevel = 0},
 [28] = {successParcent = 50, downrageLevel = 0},
 [29] = {successParcent = 45, downrageLevel = 0},
 [30] = {successParcent = 40, downrageLevel = 0}, 
}
and in actions.xml:
<action itemid="STONE_ID" event="script" value="upgrading3.lua"/>
 
azi i tried that first.. but it won't let me upgrade it :) anyways i've managed it.. thank you anyways for posting your code here! :)
 
Back
Top