• 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 Item's upgrading by jewels ver. 2 [FOR TFS 0.3.4]

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Reaction score
53
Location
Włocławek
Hello, Im upgrade my scripts from tfs 0.3.2b to newest, because old not works on new version...
Not for commercial uses ! If you wan't add it to sms shop - pay me 5€! You earn money - me too want!
Script has been rewrited and code is more readable and more functionaly settings in config!

If you using TFS 0.3.2B version go to THIS THREAD, if you using higher version please use code from this thread!
If you like my script - you can give me a rep point.

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 = {}


-- // config // --
conf.maxItemLevel = 10 -- max item level 
conf.successChance = 50  -- succes upgrade chance

conf["upgrade"] = { -- how many parcent attributes are rised?
	attack = 5, -- attack %
	extraAttack = 10, -- extra Attack %
	defence = 5, -- defence %
	extraDefence = 10, -- extra defence %
	armor = 5, -- armor %
	attackSpeed = 3, -- attack speed %
	hitChance = 5, -- hit chance %
	shootRange = 2, -- shoot range %
}

--// end // --

function getItemInfo(item)

	local attr = {}
	local name = string.explode(getItemName(item), '+');
	if #name == 1 then
		attr.name = name[1]
		attr.level = math.abs(0)
	else
		attr.level = math.abs(name[2])
		attr.name = name[1]
	end
		attr.attack = (getItemAttack(item) > 0) and getItemAttack(item) or 0
		attr.extraAttack = (getItemExtraAttack(item) > 0) and getItemExtraAttack(item) or 0
		attr.defence = (getItemDefense(item) > 0) and getItemDefense(item) or 0
		attr.extraDefence = (getItemExtraDefense(item) > 0) and getItemExtraDefense(item) or 0
		attr.armor = (getItemArmor(item) > 0) and getItemArmor(item) or 0
		attr.attackSpeed = (getItemAttackSpeed(item) > 0) and getItemAttackSpeed(item) or 0
		attr.hitChance = (getItemHitChance(item) > 0) and getItemHitChance(item) or 0
		attr.shootRange = (getItemShootRange(item) > 0) and getItemShootRange(item) or 0
		attr.weight = (getItemWeight(item) > 0) and getItemWeight(item) or 0
		
	return attr
end

function upgradeValue(value, parcent)
	local newValue = math.ceil(((value/100)*parcent)+value)
	return (newValue > 0) and newValue or 0
end

function onUse(cid, item, fromPosition, itemEx, toPosition)

	if toPosition.x == 65535 then
		local upgradingItem = getItemInfo(itemEx.uid)
		if (upgradingItem.attack > 0 or upgradingItem.defence > 0 or upgradingItem.armor > 0 or upgradingItem.shootRange > 1) then
			if (upgradingItem.level < conf.maxItemLevel) then
				if conf.successChance >= math.random(1,100) then
					setItemName(itemEx.uid, upgradingItem.name.." + "..(upgradingItem.level+1))
					setItemAttack(itemEx.uid, upgradeValue(upgradingItem.attack, conf["upgrade"].attack))
					setItemExtraAttack(itemEx.uid, upgradeValue(upgradingItem.extraAttack, conf["upgrade"].extraAttack))
					setItemDefense(itemEx.uid, upgradeValue(upgradingItem.defence, conf["upgrade"].defence))
					setItemExtraDefense(itemEx.uid, upgradeValue(upgradingItem.extraDefence, conf["upgrade"].extraDefence))
					setItemArmor(itemEx.uid, upgradeValue(upgradingItem.armor, conf["upgrade"].armor))
					setItemAttackSpeed(itemEx.uid, upgradeValue(upgradingItem.attackSpeed, conf["upgrade"].attackSpeed))
					setItemHitChance(itemEx.uid, upgradeValue(upgradingItem.hitChance, conf["upgrade"].hitChance))
					setItemShootRange(itemEx.uid, upgradeValue(upgradingItem.shootRange, conf["upgrade"].shootRange))
					doSendMagicEffect(toPosition, 30)
					doPlayerSendTextMessage(cid, 22, "Upgraded was successful, your item has become stronger!")
				else
					doRemoveItem(itemEx.uid, itemEx.type)
					doSendMagicEffect(toPosition, 2)
					doPlayerSendTextMessage(cid, 22, "Upgrading fail... you lost upgraded item!")
				end
				doRemoveItem(item.uid, 1)
			else
				doPlayerSendCancel(cid, "This item is on max level!")
			end
		else
			doPlayerSendCancel(cid, "You cannot upgrade this item!")
		end
	else
		doPlayerSendCancel(cid, "You can upgrading items only in inventory!")
	end
	return TRUE;
end


All configurations in script - config section!


Please, don't copy this script to other forums.

Yours, Azi.
Thanks.
 
Last edited:
Good!

I had done so was launched the functions this script, but his is better prepared .. :]
You know how to make monsters drop these items with ATK edited?

and sorry for my english ..
 
if i use this on floor or any other items like wall etc it say this error:
[21/06/2009 22:23:04] data/actions/scripts/tools/upgrading.lua:24: attempt to get length of local 'name' (a nil value)
[21/06/2009 22:23:04] stack traceback:
[21/06/2009 22:23:04] data/actions/scripts/tools/upgrading.lua:24: in function 'getItemInfo'
[21/06/2009 22:23:04] data/actions/scripts/tools/upgrading.lua:50: in function <data/actions/scripts/tools/upgrading.lua:49>

People may spam and that may cause lag.
 
#up
i don't have this problem, but im updated script to upgrades only in our inventory.
 
#up
i don't have this problem, but im updated script to upgrades only in our inventory.

Thanks a lot :)

ps. can you make script that will start every (xx hours xx minutes<globalevents>) and it will create 2 portals and xx people can enter? And if you enter teleport your outfit will change also(config clours and look type) :p
(Oplata za skrypt tez możliwa :D)
 
Last edited:
Azi, could you update it and add a % to adding more ML to items that gives ml (Not %, just give +1 ml per upgrade)? And to the items that add speed, make them add more speed?

Bug FOUND: You can have 100 assassin stars, upgrade them to +10 without problems, if you fail, you loose 1 star, and you still have 99 more, but you can keep doing upgrading, and if you loose 99 stars, you can add 99 more and will keep having more damage... Nice xD
 
Last edited:
Azi it keeps with the bug... using 100 assassin star, I can upgrade it to max without problems, and I just loose one star per fail... Could you make it to loose all the count of all items, in this case the assassin star... If you have 99, and you fail, you lose 99.
 
Azi great script love it and am useing it.
Is there anyway to make it add to magiclevelpoints also?
Any help would be great
 
Azi how i can add a list of item that CAN'T be upgrade?


something like:

PHP:
local CAN'T_BE_UPGRADE = 'bla bla bla', 'bla bla bla...

Since i dont want this work with some armor, shield and other items, anyway thanks and REP++
 
i think its bug
Code:
                    doRemoveItem(itemEx.uid, item.type)
becouse item are never destroy, so i change to
Code:
                    doRemoveItem(itemEx.uid, 1)
and now its good. Im wrong?
 
Back
Top