• 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!

Request Enchanting System 1.2

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
870
Solutions
2
Reaction score
49
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).
 
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
 
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
 
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.
 
Back
Top