Action Item's Upgrading by Jewels! : )

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Best answers
0
Reaction score
51
Location
Włocławek
Items upgrading ala mu online, you can upgrade (+1 level) items by jewel, each upgrade set item attributes more than x% of item status. If upgrading failed you item has been destroyed.
Not for commercial uses ! If you wan't add it to sms shop - pay me 5€! You earn money - me too want!
in actions.xml:
PHP:
<action itemid="2147" script="upgrade.lua"/>
you cann add more upgrading jewels, only copy this line and set jewel item id on itemid="HERE" ; )

and
actions/scripts/upgrade.lua
PHP:
-- Azi's item upgrading system -- 
config = {
    brokeChance = 10, -- % chance to broke upgrading item
    upgradePercent = 10, -- % of rise upgrading item atributtes 
    maxUpgrade = 100, -- maximum level of item
    notAllowed = {} -- items id between comma which you cannot upgrade it
}
function onUse(cid, item, fromPosition, itemEx, toPosition)

    local getUpgraded = itemEx.actionid-10000
    if getUpgraded < 0 then
    getUpgraded = 0
    end
    if getUpgraded < config.maxUpgrade then
        if itemEx.itemid > 100 then
            if isItemMoveable(itemEx.itemid) == 1 and isItemRune(itemEx.itemid) == 0 and isCorpse(itemEx.uid) == 0 and isContainer(itemEx.uid) == 0 and isItemStackable(itemEx.itemid) == 0 and isItemFluidContainer(itemEx.itemid) == 0 and isInArray(config.notAllowed, itemEx.itemid) == 0 then
                if config.brokeChance <= math.random(1,100) then
                    setItemName(itemEx.uid, getItemNameById(itemEx.itemid) .. "+" .. (getUpgraded+1))
                    doSetItemActionId(itemEx.uid, 10000+(getUpgraded+1))
                    doSendMagicEffect(toPosition, 30)
                    doPlayerSendTextMessage(cid, 22, "You successfuly upgraded " .. getItemNameById(itemEx.itemid) .. " to " .. (getUpgraded+1) .. " level.")
                    if getItemAttack(itemEx.uid) > 0 then
                        setItemAttack(itemEx.uid, (getItemAttack(itemEx.uid)+((getItemAttack(itemEx.uid)/100)*config.upgradePercent))+1)
                    end        
                    if getItemExtraAttack(itemEx.uid) > 0 then
                        setExtraItemAttack(itemEx.uid, (getExtraItemAttack(itemEx.uid)+((getExtraItemAttack(itemEx.uid)/100)*config.upgradePercent))+1)
                    end            
                    if getItemDefense(itemEx.uid) > 0 then
                        setItemDefense(itemEx.uid, (getItemDefense(itemEx.uid)+((getItemDefense(itemEx.uid)/100)*config.upgradePercent))+1)
                    end            
                    if getItemExtraDefense(itemEx.uid) > 0 then
                        setItemExtraDefense(itemEx.uid, (getItemExtraDefense(itemEx.uid)+((getItemExtraDefense(itemEx.uid)/100)*config.upgradePercent))+1)
                    end        
                    if getItemArmor(itemEx.uid) > 0 then
                        setItemArmor(itemEx.uid, (getItemArmor(itemEx.uid)+((getItemArmor(itemEx.uid)/100)*config.upgradePercent))+1)
                    end        
                    if getItemAttackSpeed(itemEx.uid) > 0 then
                        setItemAttackSpeed(itemEx.uid, (getItemAttackSpeed(itemEx.uid)+((getItemAttackSpeed(itemEx.uid)/100)*config.upgradePercent))+1)
                    end        
                    if getItemHitChance(itemEx.uid) > 0 then
                        setItemHitChance(itemEx.uid, (getItemHitChance(itemEx.uid)+((getItemHitChance(itemEx.uid)/100)*config.upgradePercent))+1)
                    end
                else
                    doPlayerSendTextMessage(cid, 22, getItemNameById(itemEx.itemid).." upgrading to level " .. (getUpgraded+1) .. " fail! You lose item!")
                    doRemoveItem(itemEx.uid, 1)
                    doSendMagicEffect(toPosition, 34)
                end
                doRemoveItem(item.uid, 1)
            else
                doPlayerSendCancel(cid, "You cannot upgrade this item!")
            end
        end
    else
        doPlayerSendCancel(cid, "This item is already upgraded to maximum item level.")
    end
        return TRUE
end
please set config in the script. : ))

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

azi. :)
 
Last edited:
OP
Azi

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Best answers
0
Reaction score
51
Location
Włocławek
error fixed (please take new version)
and this script made for tfs 0.3b2
 

Kaorus

Unleash Dreams Staff
Joined
May 18, 2008
Messages
1,087
Best answers
0
Reaction score
8
Location
Iquique, Chile
This version (3.1 cry) dont show any error from scripts :S
 
OP
Azi

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Best answers
0
Reaction score
51
Location
Włocławek
download 0.3b2 and look please, bacause i go sleep now. ;<
 

Zikerus

Nutria Developer
Joined
Mar 13, 2008
Messages
193
Best answers
0
Reaction score
0
Location
Poole, UK
Pretty nice ;p you could also make function for adding/changing attributes ;) Then u can check if item is armor/weapon/shield or whatever and use different attributes (armor, attack, def, speed~ ect.) for them, that should speed-up script, you can also make random number of attributes updated and random attributes as well :D I did that for my server, but it's hardcoded in C++ ;< I like yours :D So I'll re-write it to my version's usability.
 

Gsp

RP
Joined
Jan 3, 2008
Messages
237
Best answers
0
Reaction score
3
doesnt work for me using beta 2
 

elf

Sing, sing blue silver
Joined
Dec 11, 2007
Messages
3,665
Best answers
1
Reaction score
116
Location
Cracow, Poland
I see you enjoy very well TFS-only functions, ersiu ;D
 

koliber66

New Member
Joined
Oct 28, 2008
Messages
196
Best answers
0
Reaction score
0
Location
Black(Recife)
Doesn't work for me :( i have the latest engine : [8.4] The Forgotten Server v0.3.1 (Crying Damson) can any1 help?
 
OP
Azi

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Best answers
0
Reaction score
51
Location
Włocławek
ok, fixed 100% : )

Code:
19:02 You see a magic plate armor+13 (Arm:46).
It can only be wielded properly by knights and paladins.
It weighs 85.00 oz.
An enchanted gem glows on the plate armor.
update in top post
 

Xevis

thornera.net
Joined
Dec 26, 2008
Messages
164
Best answers
0
Reaction score
3
Location
Włocławek
Seems to be good.
I dont have 0,3 2b, So i Wont test that.

++
 

Oniper

New Member
Joined
Jan 8, 2009
Messages
2
Best answers
0
Reaction score
0
And if I wanna do this for levers?

For example (I put a picture because i don't know inglish and i think this is better):


EDIT: A lot of thanks, this script is very nice
 
Last edited:

Oxious

Amateur Mapper & Scripter
Joined
Jan 25, 2009
Messages
89
Best answers
0
Reaction score
0
Location
Germany
Thanks for the script! :) I will modify it to my needs.
 
Top