Request Enchanting System 1.2

Lopaskurwa

Banned User
Joined
Oct 6, 2017
Messages
694
Best answers
2
Reaction score
32
Need enchant system for weapons that would increase weapon atk by one so it should have functions like this

+1 = 70% success chance, 10% fail chance, 15% downgrade chance, 5% item break chance
+2 = 65% success chance, 15% fail chance, 15% downgrade chance, 5% item break chance
+3 = 60% success chance, 20% fail chance, 15% downgrade chance, 5% item break chance
and etc

so fail would mean nothing will happen it wont increase atk it wont brake item or it wont downgrade so basically you like failed enchanting. downgrade means it would remove +1 atk so if you had like +2 and it downgraded you would have now +1. item break means you braked your item so it would remove it. Ofc it should remove enchant from you every time you do this action.

that +1 should increase the sword dmg by one so it would look like this
You see a Test Sword (Atk:2, Def:1).

and now if you enchant it +1
You see a Test Sword+1 (Atk:3, Def:2).

and now if you enchant it +2
You see a Test Sword+2 (Atk:4, Def:3).

and now if you enchant it +3
You see a Test Sword+3 (Atk:5, Def:4).

and now if you enchant it +4
You see a Test Sword+4 (Atk:6, Def:5).
 

zxmatzx

Intermediate OT User
Joined
Dec 1, 2010
Messages
155
Best answers
5
Reaction score
39
After a quick search, found this system that Zbizu upgraded for 1.1 version(on thread have original post for 0.3.6 version), with few modifications should work as you need, take a look.

Upgrading Items By Jewels
 

zxmatzx

Intermediate OT User
Joined
Dec 1, 2010
Messages
155
Best answers
5
Reaction score
39
It miss functions that i mentioned.
Like i said, with few modifications, this gonna work. U have only to set a new chance to formula, im busy atm, when i finish i can do it for u, if u don't know how to do...
 

gicu0770

Intermediate OT User
Joined
Feb 26, 2011
Messages
108
Best answers
0
Reaction score
15
It miss functions that i mentioned.


Add this to you lib folder

Code:
getThingFromPos = getThingfromPos
getThingPosition = getThingPos
MESSAGE_LOOT = 20

table.find = function(table, value)
    for i, v in pairs(table) do
        if v == value then
            return i
        end
    end
    return nil
end

string.trim = function (str)
 return str:gsub("^%s*(.-)%s*$", "%1")
end

string.explode = function (str, sep, limit)
if(type(sep) ~= 'string' or isInArray({tostring(str):len(), sep:len()}, 0)) then
    return {}
end

 local i, pos, tmp, t = 0, 1, "", {}
 for s, e in function() return string.find(str, sep, pos) end do
  tmp = str:sub(pos, s - 1):trim()
  table.insert(t, tmp)
  pos = e + 1

  i = i + 1
  if(limit ~= nil and i == limit) then
   break
  end
 end

 tmp = str:sub(pos):trim()
 table.insert(t, tmp)
 return t
end

function isSummon(uid)
return Creature(uid):getMaster() ~= nil
end

exhaustion =
{
    check = function (cid, storage)
        if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end

        return getPlayerStorageValue(cid, storage) >= os.time()
    end,

    get = function (cid, storage)
        if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end

        local exhaust = getPlayerStorageValue(cid, storage)
        if(exhaust > 0) then
            local left = exhaust - os.time()
            if(left >= 0) then
                return left
            end
        end

        return false
    end,

    set = function (cid, storage, time)
        setPlayerStorageValue(cid, storage, os.time() + time)
    end,

    make = function (cid, storage, time)
        local exhaust = exhaustion.get(cid, storage)
        if(not exhaust) then
            exhaustion.set(cid, storage, time)
            return true
        end

        return false
    end
}


    function getItemAttack(uid) return ItemType(getThing(uid).itemid):getAttack() end
    function getItemDefense(uid) return ItemType(getThing(uid).itemid):getDefense() end
    function getItemArmor(uid) return ItemType(getThing(uid).itemid):getArmor() end
    function getItemWeaponType(uid) return ItemType(getThing(uid).itemid):getWeaponType() end
    function isArmor(uid) if (getItemArmor(uid) ~= 0 and getItemWeaponType(uid) == 0) then return true else return false end end
    function isWeapon(uid) return isInArray({1,2,3}, getItemWeaponType(uid)) end
    function isShield(uid) return getItemWeaponType(uid) == 4 end
    function isBow(uid) return (getItemWeaponType(uid) == 5 and (not ItemType(getThing(uid).itemid):isStackable())) end
 
OP
Lopaskurwa

Lopaskurwa

Banned User
Joined
Oct 6, 2017
Messages
694
Best answers
2
Reaction score
32
Add this to you lib folder

Code:
getThingFromPos = getThingfromPos
getThingPosition = getThingPos
MESSAGE_LOOT = 20

table.find = function(table, value)
    for i, v in pairs(table) do
        if v == value then
            return i
        end
    end
    return nil
end

string.trim = function (str)
return str:gsub("^%s*(.-)%s*$", "%1")
end

string.explode = function (str, sep, limit)
if(type(sep) ~= 'string' or isInArray({tostring(str):len(), sep:len()}, 0)) then
    return {}
end

local i, pos, tmp, t = 0, 1, "", {}
for s, e in function() return string.find(str, sep, pos) end do
  tmp = str:sub(pos, s - 1):trim()
  table.insert(t, tmp)
  pos = e + 1

  i = i + 1
  if(limit ~= nil and i == limit) then
   break
  end
end

tmp = str:sub(pos):trim()
table.insert(t, tmp)
return t
end

function isSummon(uid)
return Creature(uid):getMaster() ~= nil
end

exhaustion =
{
    check = function (cid, storage)
        if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end

        return getPlayerStorageValue(cid, storage) >= os.time()
    end,

    get = function (cid, storage)
        if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end

        local exhaust = getPlayerStorageValue(cid, storage)
        if(exhaust > 0) then
            local left = exhaust - os.time()
            if(left >= 0) then
                return left
            end
        end

        return false
    end,

    set = function (cid, storage, time)
        setPlayerStorageValue(cid, storage, os.time() + time)
    end,

    make = function (cid, storage, time)
        local exhaust = exhaustion.get(cid, storage)
        if(not exhaust) then
            exhaustion.set(cid, storage, time)
            return true
        end

        return false
    end
}


    function getItemAttack(uid) return ItemType(getThing(uid).itemid):getAttack() end
    function getItemDefense(uid) return ItemType(getThing(uid).itemid):getDefense() end
    function getItemArmor(uid) return ItemType(getThing(uid).itemid):getArmor() end
    function getItemWeaponType(uid) return ItemType(getThing(uid).itemid):getWeaponType() end
    function isArmor(uid) if (getItemArmor(uid) ~= 0 and getItemWeaponType(uid) == 0) then return true else return false end end
    function isWeapon(uid) return isInArray({1,2,3}, getItemWeaponType(uid)) end
    function isShield(uid) return getItemWeaponType(uid) == 4 end
    function isBow(uid) return (getItemWeaponType(uid) == 5 and (not ItemType(getThing(uid).itemid):isStackable())) end
Hmm i see its like small part of the system
 

gicu0770

Intermediate OT User
Joined
Feb 26, 2011
Messages
108
Best answers
0
Reaction score
15
Hmm i see its like small part of the system
add this line to you global.lua

Code:
dofile('data/lib/001_04_compat.lua')
and create 001_04_compat.lua in data/lib and past this first code.
 
OP
Lopaskurwa

Lopaskurwa

Banned User
Joined
Oct 6, 2017
Messages
694
Best answers
2
Reaction score
32
add this line to you global.lua

Code:
dofile('data/lib/001_04_compat.lua')
and create 001_04_compat.lua in data/lib and past this first code.
Yea but whats the point to use it there is no action lua?
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,049
Best answers
472
Reaction score
2,678
You're going to be bumping for a while.
Requests that take more than a few minutes to work on, nobody will do for you.
 
OP
Lopaskurwa

Lopaskurwa

Banned User
Joined
Oct 6, 2017
Messages
694
Best answers
2
Reaction score
32
You're going to be bumping for a while.
Requests that take more than a few minutes to work on, nobody will do for you.
Thats why i posted in request section this is where you ask for codes.
 
Top