What's new

Upgrade system by Gelio

Batonek

Senior User
Joined
Apr 26, 2008
Messages
605
Reaction score
25
Siema. Ot?? chcia?em u?y? starszego upgrade systemu by Gelio na nowym TFSie 0.3.6 jednak co? nie idzie i nie wiem jak to zmieni? :p
O to skrypt:
Code:
-- Upgrade system by Gelio v. 3
-- Dodane:
-- Szansa na zniszczenie przedmiotu
-- Zmienione:
-- zniszczenie przedmiotu -> anty upgade (zamiast dodawa? odejmuje)
local znika = "tak"     -- Czy item ma znika? po upgrade (item upgraduj?cy)
local ileProcent = 1    -- O ile procent powi?ksza atrybuty czego?. Jak wyjdzie liczba rzeczywista to podnosi o tyle, ?eby by?a liczba ca?kowita.
local maksProcent = 3    -- Ile maksymalnie procent mo?e by? upgradowane. 0 - niesko?czono??
local antyUlepszenieProcent = 0     -- Ile procent szansy na anty-ulepszenie przedmiotu. 0 - 0% szans na anty upgrade, zawsze upgraduje
local antyUlepszenieZabieraProcent = 5   -- Ile procent ka?dego atrybutu zabiera je?eli nie uda si? upgreade
function onUse(cid, item, frompos, item2, topos)
if(item2.uid ~= 0) then
    local arm = getItemArmor(item2.uid)
    local def = getItemDefense(item2.uid)
    local atk = getItemAttack(item2.uid)
    local descr = ""
    local action = item2.actionid-100
    if(action < 0) then
        action = 0
    end
    if(maksProcent > 0 and action >= maksProcent) then
        doPlayerSendCancel(cid,"You can't upgrade it anymore.")
        return TRUE
    end
    if(arm ~= 0 or def ~= 0 or atk ~= 0) then
        if(znika == "tak") then
            if(item.type > 1) then
                doChangeTypeItem(item.uid, item.type-1)
            else
                doRemoveItem(item.uid,1)
            end
        end
        if(antyUlepszenieProcent > 0) then
            if(math.random(1,100) <= antyUlepszenieProcent) then
                descr = "Values: "
                if(arm ~= 0) then
                    setItemArmor(item2.uid,math.floor(arm * (antyUlepszenieZabieraProcent/100)))
                    descr = descr .."armor incrased by ".. action-antyUlepszenieZabieraProcent .." percents "
                    doSetItemActionId(item2.uid,100+action-antyUlepszenieZabieraProcent)
                end
                if(def ~= 0) then
                    setItemDefense(item2.uid,math.floor(def * (antyUlepszenieZabieraProcent/100)))
                    descr = descr .."defense incrased by ".. action-antyUlepszenieZabieraProcent .." percents "
                    doSetItemActionId(item2.uid,100+action-antyUlepszenieZabieraProcent)
                end
                if(atk ~= 0) then
                    setItemAttack(item2.uid,math.floor(atk * (antyUlepszenieZabieraProcent/100)))
                    descr = descr .."attack incrased by ".. action-antyUlepszenieZabieraProcent .." percents "
                    doSetItemActionId(item2.uid,100+action-antyUlepszenieZabieraProcent)
                end
                doSetItemSpecialDescription(item2.uid,descr)
                doPlayerSendCancel(cid,"You have anty-upgraded this item.")
                return TRUE
            end
        end
        descr = "Values: "
        if(arm ~= 0) then
            descr = descr .."armor increased ".. ileProcent+action .. " levels up "
            local ilePowieksza = math.ceil(arm * (ileProcent/100))
            setItemArmor(item2.uid, arm+ilePowieksza)
            doSetItemActionId(item2.uid,100+action+ileProcent)
        end
        if(def ~= 0) then
            descr = descr .."defense increased ".. ileProcent+action .." levels up "
            local ilePowieksza = math.ceil(def * (ileProcent/100))
            setItemDefense(item2.uid, def+ilePowieksza)
            doSetItemActionId(item2.uid,100+action+ileProcent)
        end
        if(atk ~= 0) then
            descr = descr .."attack increased ".. ileProcent+action .." levels up "
            local ilePowieksza = math.ceil(atk * (ileProcent/100))
            setItemAttack(item2.uid, atk+ilePowieksza)
            doSetItemActionId(item2.uid,100+action+ileProcent)
        end
        doSetItemSpecialDescription(item2.uid,descr)
        doSendMagicEffect(topos,CONST_ME_MAGIC_GREEN)
    else
        doPlayerSendCancel(cid,"You can't upgrade this.")
    end
    return TRUE
end
return FALSE
end
A tu m?j b??d:
Code:
[19/05/2010 20:52:47] [Error - Action Interface] 
[19/05/2010 20:52:47] data/actions/scripts/upgrade.lua:onUse
[19/05/2010 20:52:47] Description: 
[19/05/2010 20:52:47] data/actions/scripts/upgrade.lua:13: attempt to call global 'getItemArmor' (a nil value)
[19/05/2010 20:52:47] stack traceback:
[19/05/2010 20:52:47]     data/actions/scripts/upgrade.lua:13: in function <data/actions/scripts/upgrade.lua:11>
Z g?ry dzi?ki za pomoc,
pozdrawiam.
 
T

Tairens

Guest
Odp: Upgrade system by Gelio

Niestety w tej wersji TFS jest powa?ny problem z pobieraniem warto?ci item?w. Musisz poczeka? na ?atk? do tego.
 

Aragornkk

Senior User
Joined
Oct 11, 2008
Messages
705
Reaction score
44
Odp: Upgrade system by Gelio

local arm = getItemArmor(item2.uid)
local def = getItemDefense(item2.uid)
local atk = getItemAttack(item2.uid)

Zosta?o zamienione jedn? komend?. setitematribute i getitem atribute.
masz tutaj gotowca.



Jest to jedyny sprawny system uprage(dost?pny za darmo)


#Taires.
Oni nie zamierzaj? tego naprawia?. Wed?ug nich wszystko dzia?a jak nale?y.
 

Batonek

Senior User
Joined
Apr 26, 2008
Messages
605
Reaction score
25
Odp: Upgrade system by Gelio

A nie da si? tego:
Code:
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 = 45, downrageLevel = 0}
}
conf["upgrade"] = { -- how many parcent attributes are rised?
    attack = 5, -- attack %
    extraAttack = 5, -- extra Attack %
    defense = 5, -- defence %
    extraDefense = 5, -- 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
Przerobi? tak, ?eby zamiast % dodawa?o po 1 att, defa i arma? Bo jak przerobi?em ?eby dawa?o po 1% to i tak p armor dostawa? 2 arma ;/
Z g?ry dzi?ki,
pozdro.
 

Aragornkk

Senior User
Joined
Oct 11, 2008
Messages
705
Reaction score
44
Odp: Upgrade system by Gelio

Niestety, nie da si?. Tak jak taires napisa? pobieranie warto?ci jest zbugowane wi?c nie mo?esz tak napisa?.

jedynie co mo?esz zrobi? to skrypt kt?ry by dodawa? +1 do ataku itd.
 

Batonek

Senior User
Joined
Apr 26, 2008
Messages
605
Reaction score
25
Odp: Upgrade system by Gelio

No w?a?nie o to mi chodzi ?eby ka?dy poziom upgrade dawa? tylko 1 arma wi?cej.
 

Aragornkk

Senior User
Joined
Oct 11, 2008
Messages
705
Reaction score
44
Odp: Upgrade system by Gelio

Poda?em linka wy?ej, tylko confing wed?ug uznania zmie? i b?dzie ?miaga? wszystko.
 

Batonek

Senior User
Joined
Apr 26, 2008
Messages
605
Reaction score
25
Odp: Upgrade system by Gelio

To co poda?em p??niej to jest z Twego linku i w tym rzecz ?e jak wpisuje ?eby dodawa?o 1% to do p arma dodaje 2... czyli 20%...
 

Batonek

Senior User
Joined
Apr 26, 2008
Messages
605
Reaction score
25
Odp: Upgrade system by Gelio

O.K Dzia?a. Tylko jeszcze jedno pytanie :p Jak to przerobi? ?eby przy failu nie zabiera?o np. z +2 na +1? ?eby item upgraduj?cy normalnie znika? ale ?eby z itemem upgradowanym nic si? nie dzia?o.
Z g?ry dzi?ki,
pozdrawiam.
 
Top