• 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 [ULTRA RELEASE]Upgrading System By Click V3.0

jajajiji

New Member
Joined
Jan 20, 2009
Messages
23
Reaction score
1
Updated from:
Upgrading System by Click V 2.0
Upgrading System by Click V 1.0

Tested on the last version of TFS 0.3.1PL1
Also works with TFS 0.3+

Features:
* Modified many times can upgrade one item
* Now the minimum and the maximum is random
* Instead of breaking it resets
* Fixed when u use it with bows and crossbows


1.- \data\actions\scripts\upgrade.lua
Lua:
-- Script Made By Jajajiji

-- Config
local maxupgradetimes = 50 -- How many times can upgrade the item
local messagetype = 25 -- Color of the message
-- End Config

local upgrades = {
    [7800] = {chance = 100, amount = {1, 5}, set = setItemAttack, get = getItemAttack, name = "attack"},
    [7801] = {chance = 80, amount = {6, 10}, set = setItemAttack, get = getItemAttack, name = "attack"},
    [7802] = {chance = 60, amount = {11, 15}, set = setItemAttack, get = getItemAttack, name = "attack"},
    [7803] = {chance = 40, amount = {16, 20}, set = setItemAttack, get = getItemAttack, name = "attack", reset = TRUE},
    [7804] = {chance = 20, amount = {21, 30}, set = setItemAttack, get = getItemAttack, name = "attack", reset = TRUE},
    [7805] = {chance = 100, amount = {1, 5}, set = setItemDefense, get = getItemDefense, name = "defense"},
    [7806] = {chance = 80, amount = {6, 10}, set = setItemDefense, get = getItemDefense, name = "defense"},
    [7807] = {chance = 60, amount = {11, 15}, set = setItemDefense, get = getItemDefense, name = "defense"},
    [7808] = {chance = 40, amount = {16, 20}, set = setItemDefense, get = getItemDefense, name = "defense", reset = TRUE},
    [7809] = {chance = 20, amount = {26, 30}, set = setItemDefense, get = getItemDefense, name = "defense", reset = TRUE},
    [7810] = {chance = 100, amount = {1, 5}, set = setItemArmor, get = getItemArmor, name = "armor"},
    [7811] = {chance = 80, amount = {6, 10}, set = setItemArmor, get = getItemArmor, name = "armor"},
    [7812] = {chance = 60, amount = {11, 15}, set = setItemArmor, get = getItemArmor, name = "armor"},
    [7813] = {chance = 40, amount = {16, 20}, set = setItemArmor, get = getItemArmor, name = "armor", reset = TRUE},
    [7814] = {chance = 20, amount = {21, 30}, set = setItemArmor, get = getItemArmor, name = "armor", reset = TRUE},
    [7815] = {chance = 100, amount = {1, 5}, set = setItemHitChance, get = getItemHitChance, name = "hit"},
    [7816] = {chance = 80, amount = {6, 10}, set = setItemHitChance, get = getItemHitChance, name = "hit"},
    [7817] = {chance = 60, amount = {11, 15}, set = setItemHitChance, get = getItemHitChance, name = "hit"},
    [7818] = {chance = 40, amount = {16, 20}, set = setItemHitChance, get = getItemHitChance, name = "hit", reset = TRUE},
    [7819] = {chance = 20, amount = {21, 30}, set = setItemHitChance, get = getItemHitChance, name = "hit", reset = TRUE},
    [7850] = {chance = 100, amount = {100, 100}, set = setItemAttack, get = getItemAttack, name = "attack"}, -- Only give when your acces is >= 5
    [7851] = {chance = 100, amount = {100, 100}, set = setItemDefense, get = getItemDefense, name = "defense"}, -- Only give when your acces is >= 5
    [7852] = {chance = 100, amount = {100, 100}, set = setItemArmor, get = getItemArmor, name = "armor"}, -- Only give when your acces is >= 5
    [7853] = {chance = 100, amount = {100, 100}, set = setItemHitChance, get = getItemHitChance, name = "hit"} -- Only give when your acces is >= 5
}
local minmax = {
    min1 = 7800, -- Minimum actionid for access < 5
    max1 = 7819, -- Maximum actionid for access < 5
    min2 = 7850, -- Minimum actionid for access >= 5
    max2 = 7853, -- Maximum actionid for access >= 5
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
-- From here on down is a bit difficult (for the noob) understand the structure
    if item.actionid == 0 then
        local new = getPlayerAccess(cid) >= 5 and math.random(minmax.min2, minmax.max2) or math.random(minmax.min1, minmax.max1)
        local text = "You remove the dust and revealed that it is a "..upgrades[new].chance.."% upgrade for "..upgrades[new].name.." +("..upgrades[new].amount[1].."~"..upgrades[new].amount[2]..")."..(upgrades[new].reset ~= nil and "It has a slight chance of reset your item." or "")
        local description = "This crystal has "..upgrades[new].chance.."% upgrade for "..upgrades[new].name.." +("..upgrades[new].amount[1].."~"..upgrades[new].amount[2]..")."..(upgrades[new].reset ~= nil and "It has a slight chance of reset your item." or "")
        doPlayerSendTextMessage(cid, messagetype, text)
        doSetItemActionId(item.uid, new)
        doSetItemSpecialDescription(item.uid, description)
        setItemName(item.uid, "active upgrade crystal")
    elseif upgrades[item.actionid] ~= nil then
        if upgrades[item.actionid].get(itemEx.uid) >= 0 then
            if itemEx.actionid < 100+maxupgradetimes then
                local randomamount = math.ceil(math.random(upgrades[item.actionid].amount[1],upgrades[item.actionid].amount[2]))
                local amount = math.max(0, itemEx.actionid - 100)
                local chance = math.random(0, 100)
                local text = "Upgrade of "..getItemName(itemEx.uid).." failed in "..upgrades[item.actionid].name.." +"..randomamount.."."
                local animation = "Failed!"
                --doSetItemActionId(itemEx.uid, 100+(amount+1))
                --setItemName(itemEx.uid, getItemNameById(itemEx.itemid).." (+"..(amount+1)..")")
                if chance <= upgrades[item.actionid].chance then
                    text = "Upgrade of "..getItemName(itemEx.uid).." up in "..upgrades[item.actionid].name.." +"..randomamount.."."
                    upgrades[item.actionid].set(itemEx.uid, (upgrades[item.actionid].get(itemEx.uid)+randomamount))
                    setItemName(itemEx.uid, getItemNameById(itemEx.itemid).." (+"..(amount+1)..")")
                    doSetItemActionId(itemEx.uid, 100+(amount+1))
                elseif upgrades[item.actionid].reset ~= nil or upgrades[item.actionid].reset == TRUE then
                    if math.random(0, 1) == 1 then
                        text = "The item "..getItemName(itemEx.uid).." was reset."
                        animation = "Reset!"
                        doRemoveItem(itemEx.uid)
                        doPlayerAddItem(cid, getItemIdByName(getItemNameById(itemEx.itemid)))
                    end
                end
                    if (not text == "The item "..getItemName(itemEx.uid).." was reset.") then
                        if getItemAttack(itemEx.uid) >= 0 then
                            setItemAttackSpeed(itemEx.uid, 1)
                        end
                    end
                doPlayerSendTextMessage(cid, messagetype, text)
                doSendMagicEffect(toPosition, (chance <= upgrades[item.actionid].chance and 13 or 2))
                doSendAnimatedText(toPosition, (chance <= upgrades[item.actionid].chance and "Success!" or animation),(chance <= upgrades[item.actionid].chance and TEXTCOLOR_WHITE or TEXTCOLOR_RED))
                doRemoveItem(item.uid)
            else
                doPlayerSendCancel(cid, "This item already has "..maxupgradetimes.." times of upgrades.")
            end
        else
            doPlayerSendCancel(cid, "This item can't upgrade.")
        end
    else
        doPlayerSendCancel(cid, "Sorry, not possible.")
    end
        return TRUE
end

2.- \data\actions\actions.xml
Code:
<action fromid="9743" toid="9744" event="script" value="upgrade.lua"/>

3.- \data\items\items.xml
Code:
<item fromid="9743" toid="9744" name="upgrade crystal">
	<attribute key="weight" value="10"/>
</item>

Enjoy this script
Credits:
Created by jordanhenry
Modified and customized by Jajajiji(me)


NOTE: I don't have any image for post
 
Last edited:
Very nice but...

PHP:
Tested on the last version of TFS 0.3.1PL1

Dont you mean 0.3.5? xD
 
I get this error sometimes
Code:
[12/09/2009 21:11:23] Lua Script Error: [Action Interface] 
[12/09/2009 21:11:23] data/actions/scripts/custom/upgrade.lua:onUse

[12/09/2009 21:11:23] luaGetItemDescriptions(). Item not found

[12/09/2009 21:11:23] Lua Script Error: [Action Interface] 
[12/09/2009 21:11:23] data/actions/scripts/custom/upgrade.lua:onUse

[12/09/2009 21:11:23] data/lib/function.lua:234: attempt to index a boolean value
[12/09/2009 21:11:23] stack traceback:
[12/09/2009 21:11:23] 	data/lib/function.lua:234: in function 'getItemName'
[12/09/2009 21:11:23] 	data/actions/scripts/custom/upgrade.lua:62: in function <data/actions/scripts/custom/upgrade.lua:27>
 
u can change this sript?
for example:
if item for defense, it add defense...
for dmg, it add dmg
speed, add speed

and if item for +0~+5, item have chance for broken but the item for after +6 can broken?
can u make this?

and... this sript can up anything...
You see a engraved wedding ring (+10) (Arm:30).
It weighs 0.40 oz.
You see an amulet of loss (+10) (Arm:30).
It weighs 4.20 oz.
 
personally i like V2 better but not bad for a V3 ill use a lil of both scripts that a lot for your work =]
 
This script is awesome. Just got two questions. The item id of these 2 crystals. They cannot be looted right? Not unless someone made custom monster to loot it?

If I dont right click on it and right click on a item to "activate it" It says 23:07 You see an item of type 9744, please report it to gamemaster. same as in the other item just type 9743.

I havent added any "crystals" in loot. So i hope it cant be looted :)

Now here comes the question. It is way to much to give either +1 extra defence/attack. Especially when it gives also 100 armor or 100 atk per use. :O

Where can I change this?
 
This script is awesome. Just got two questions. The item id of these 2 crystals. They cannot be looted right? Not unless someone made custom monster to loot it?

If I dont right click on it and right click on a item to "activate it" It says 23:07 You see an item of type 9744, please report it to gamemaster. same as in the other item just type 9743.

I havent added any "crystals" in loot. So i hope it cant be looted :)

Now here comes the question. It is way to much to give either +1 extra defence/attack. Especially when it gives also 100 armor or 100 atk per use. :O

Where can I change this?

Really i don't know what you want to do because my english is bad.
If you can send a private with this but in spanish i can help you.
Sorry.
 
is there a fix for being able to upgrade other things besides weapons and armors? for example: i can upgrade a floor or a lamp or a coin.

otherwise its awesome script
 
this is for what? upgrade what? how work etc? srry if is a noob question hehe :X
 
[12/01/2010 14:16:27] Description:
[12/01/2010 14:16:27] data/actions/scripts/upgrade.lua:47: attempt to call global 'doSetItemActionId' (a nil value)
[12/01/2010 14:16:27] stack traceback:
[12/01/2010 14:16:27] data/actions/scripts/upgrade.lua:47: in function <data/actions/scripts/upgrade.lua:40>

14:15 You remove the dust and revealed that it is a 20% upgrade for hit +?21?30?.It has a slight chance of reset your item.
14:15 You see a demonrage sword (Atk:47, Def:22).
It can only be wielded properly by knights of level 60 or higher.
It weighs 150.00 oz.

????????????????????????

8.54 please all help :(
 
Back
Top