Ir para conteúdo
  • 1

Refine System


mariatti

Pergunta

eu peguei esse script do @Oneshot:

 

-- PERFECT REFINE SYSTEM BY LPZ

-- VERSION 2.0

 

Refine = {

config = {

max = 13, -- NíVEL MáXIMO DE REFINO

interface = 2, -- 1 PARA INGLêS, 2 PARA PORTUGUêS

message = {

type = MESSAGE_EVENT_DEFAULT,

delay = 0.5,

success = {"You have succeeded in upgrade of %s to level +%s", "Você refinou %s para o nível +%s com sucesso."},

fail = {"You have failed in upgrade of %s to level +%s", "Você falhou em refinar %s para o nível +%s."},

recede = {"You have failed in upgrade of %s to level +%s. The refine level has downgraded to +%s.", "Você falhou em refinar %s para o nível +%s e o nível regrediu para +%s."},

critical = {"You have critical failed in upgrade of %s to level +%s. The refine level has vanished.", "Você falhou criticamente em refinar %s para o nível +%s. O nível resetou."},

maxlevel = {"This %s is already on max upgrade level.", "Este(a) %s já está no nível máximo de refino."},

broadcast = {"%s has succeeded in the upgrade of a %s to level +%s.\nCongratulations.", "%s teve sucesso em refinar %s para o nível +%s."},

tool_error = {"This isn't a valid refine item.", "Esse não é um item de refino válido"},

tool_maxlevel = {"This %s can only upgrade items to level +%s", "Este(a) %s só pode refinar itens abaixo de +%s."},

notupgradeable = {"This item isn't upgradeable.", "Este item não é refinável"},

prompt = {"Trying to refine %s to level +%s with %s%% success rate.", "Tentando refinar %s ao level +%s com %s%% de chance de sucesso."},

notenoughitems = {"You don't have %s %s to refine this item.", "Você não tem %s %s para refinar este item."}

},

attributes = {{"attack", true}, {"defense", true}, {"armor", false}}, -- MEXA APENAS SE ENTENDER O CóDIGO

downgrade = 5, -- NíVEL QUE EQUIPAMENTOS COMEçAM A REGREDIR

critical = 7, -- NíVEL QUE EQUIPAMENTOS COMEçAM A RESETAR

broadcast = {level = 7, key = true}, -- CONFIGURAçãO DO BROADCAST: 'level' define quais níveis podem mandar broadcast e 'key' liga e desliga broadcasts.

},

tools = {

--[[

Configure aqui as diferentes ferramentas de refino.

 

[itemid] = {max = x, chancemax = y, removeable = z}

 

'itemid' será o itemid da ferramenta

'x' é até qual nível a ferramenta pode refinar

'chancemax' é um bônus que a ferramenta adiciona a chance de refino

'z' define se a ferramenta some depois de refinar [true ou false]

]]--

[8303] = {max = 6, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},

[8301] = {max = 10, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},

[4846] = {max = 10, chancemax = 0, removeable = false, reagent = 5880, amountbylevel = true}

},

isEquipment = function(self)

local weapontype = self:getItemWeaponType()

if (weapontype > 0 and weapontype < 7) or self.item.info.armor ~= 0 then

return true

end

return false

end,

setItemName = function(self, name)

return doItemSetAttribute(self.item.uid, "name", name)

end,

chance = function(self)

local formula = math.ceil((100/math.sqrt((((self.config.max/4)+(self.item.level*2.3))/self.config.max)*self.item.level)))

local ret = {base = (formula > 100 and 100 or formula), downgrade = 7 * self.item.level, critical = 2.5 * self.item.level}

return ret

end,

amount = function(self)

return math.ceil(self.item.level * 0.33)

end

}

 

function Refine:load(item)

local obj = setmetatable({item = {uid = item.uid, info = getItemInfo(item.itemid)}}, {__index = function(self, index)

if(_G[index]) then

return setmetatable({callback = _G[index]}, {__call = function(self, ...)

return self.callback(item.uid, ...)

end})

else

return Refine[index]

end

end})

 

if not obj:isEquipment() then

return false

end

obj:updateLevel()

return obj

end

 

function Refine:updateLevel()

local info = self:getItemName():match("%+(%d+)")

self.item.level = (tonumber(info) or 0)

end

 

function Refine:getLevel()

local info = self:getItemName():match("%+(%d+)")

return tonumber(info) or 0

end

 

function Refine:upgrade(cid, item)

if self.config.message.delay > 0 then doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.prompt[self.config.interface]:format(self.item.info.name, self.item.level + 1, (self:chance().base > 100 and 100 or self:chance().base))) end

local tool = self.tools[item.itemid]

if not tool then

return doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.tool_error[self.config.interface])

end

 

if self.item.level == self.config.max then

return doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.maxlevel[self.config.interface]:format(self.item.info.name))

end

 

if self.item.level >= tool.max then

return doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.tool_maxlevel[self.config.interface]:format(getItemNameById(item.itemid), tool.max))

end

 

if tool.reagent ~= 0 then

local count = (tool.amountbylevel == true and self:amount() or 1)

if not doPlayerRemoveItem(cid, tool.reagent, count) then

return addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.notenoughitems[self.config.interface]:format(count, (count > 1 and getItemInfo(tool.reagent).plural or getItemNameById(tool.reagent))))

end

end

 

if tool.removeable == true then doRemoveItem(item.uid, 1) end

if (self:chance().base + tool.chancemax) * 100 >= math.random(1, 10000) then

addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.success[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))

if self.config.broadcast.key == true and (self.item.level + 1) >= self.config.broadcast.level then

doBroadcastMessage(self.config.message.broadcast[self.config.interface]:format(getCreatureName(cid), self.item.info.name, (self.item.level + 1)))

end

local r = self.config.attributes

if self.item.level > 0 then

self:setItemName(self:getItemName():gsub("%+(%d+)", "+".. (self.item.level + 1)))

for i = 1, #r do

if getItemAttribute(self.item.uid, r[1]) ~= nil then

doItemSetAttribute(self.item.uid, r[1], getItemAttribute(self.item.uid, r[1]) + (r[2] == true and (self.item.level + 1) or 1))

end

end

else

self:setItemName(self:getItemName() .." +1")

for i = 1, #r do

if self.item.info[r[1]] ~= 0 or self:getItemWeaponType() ~= 5 then

doItemSetAttribute(self.item.uid, r[1], self.item.info[r[1]] + 1)

end

end

end

else

local r = self.config.attributes

if self.item.level >= self.config.critical then

if self:chance().critical * 100 >= math.random(1, 10000) then

addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.critical[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))

self:setItemName(self.item.info.name)

for i = 1, #r do

if self.item.info[r[1]] ~= 0 then

doItemSetAttribute(self.item.uid, r[1], self.item.info[r[1]])

end

end

elseif self:chance().downgrade * 100 >= math.random(1, 10000) then

addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.recede[self.config.interface]:format(self.item.info.name, (self.item.level + 1), (self.item.level - 1)))

if self.item.level > 0 then

self:setItemName(self:getItemName():gsub("%+(%d+)", "+".. (self.item.level - 1)))

for i = 1, #r do

if getItemAttribute(self.item.uid, r[1]) ~= nil then

doItemSetAttribute(self.item.uid, r[1], getItemAttribute(self.item.uid, r[1]) - (r[2] == true and self.item.level or 1))

end

end

else

self:setItemName(self.item.info.name)

for i = 1, #r do

if self.item.info[r[1]] ~= 0 then

doItemSetAttribute(self.item.uid, r[1], self.item.info[r[1]])

end

end

end

else

addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.fail[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))

end

elseif self.item.level >= self.config.downgrade then

if self:chance().downgrade * 100 >= math.random(1, 10000) then

addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.recede[self.config.interface]:format(self.item.info.name, (self.item.level + 1), (self.item.level - 1)))

if self.item.level > 0 then

self:setItemName(self:getItemName():gsub("%+(%d+)", "+".. (self.item.level - 1)))

for i = 1, #r do

if getItemAttribute(self.item.uid, r[1]) ~= nil then

doItemSetAttribute(self.item.uid, r[1], getItemAttribute(self.item.uid, r[1]) - (r[2] == true and self.item.level or 1))

end

end

else

self:setItemName(self.item.info.name)

for i = 1, #r do

if self.item.info[r[1]] ~= 0 then

doItemSetAttribute(self.item.uid, r[1], self.item.info[r[1]])

end

end

end

else

addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.fail[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))

end

else

addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.fail[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))

end

end

return true

end

 

soh que ai eu mudei essa linha:

 

[8303] = {max = 6, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},

[8301] = {max = 10, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},

[4846] = {max = 10, chancemax = 0, removeable = false, reagent = 5880, amountbylevel = true}

 

 

para essa:

 

[8302] = {max = 6, chancemax = 0, removeable = true}

[8302] = {max = 6, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},

[8299] = {max = 10, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},

[4846] = {max = 12, chancemax = 0, removeable = false, reagent = 5880, amountbylevel = true}

[8300] = {max = 12, chancemax = 3, removeable = false, reagent = 8306, amountbylevel = true}

 

e agora soh ta funcionando o 4846 que ja estava no script... ja mudei os ids dos item tbm no actions.xml..

Link para o comentário
Compartilhar em outros sites

7 respostass a esta questão

Posts Recomendados

  • 0

troque por isso.


[8302] = {max = 6, chancemax = 0, removeable = true}
[8302] = {max = 6, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},
[8299] = {max = 10, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},
[4846] = {max = 12, chancemax = 0, removeable = false, reagent = 5880, amountbylevel = true},
[8300] = {max = 12, chancemax = 3, removeable = false, reagent = 8306, amountbylevel = true}

 

 

rep+?

 

ou


[8302] = {max = 6, chancemax = 0, removeable = true}
[8302] = {max = 6, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},
[8299] = {max = 10, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},
[4846] = {max = 12, chancemax = 0, removeable = false, reagent = 5880, amountbylevel = true},
[8300] = {max = 12, chancemax = 3, removeable = true, reagent = 8306, amountbylevel = truefalse}

Link para o comentário
Compartilhar em outros sites

  • 0

tente assim

 

 

-- PERFECT REFINE SYSTEM BY LPZ
-- VERSION 2.0
Refine = {
config = {
max = 13, -- NíVEL MáXIMO DE REFINO
interface = 2, -- 1 PARA INGLêS, 2 PARA PORTUGUêS
message = {
type = MESSAGE_EVENT_DEFAULT,
delay = 0.5,
success = {"You have succeeded in upgrade of %s to level +%s", "Você refinou %s para o nível +%s com sucesso."},
fail = {"You have failed in upgrade of %s to level +%s", "Você falhou em refinar %s para o nível +%s."},
recede = {"You have failed in upgrade of %s to level +%s. The refine level has downgraded to +%s.", "Você falhou em refinar %s para o nível +%s e o nível regrediu para +%s."},
critical = {"You have critical failed in upgrade of %s to level +%s. The refine level has vanished.", "Você falhou criticamente em refinar %s para o nível +%s. O nível resetou."},
maxlevel = {"This %s is already on max upgrade level.", "Este(a) %s já está no nível máximo de refino."},
broadcast = {"%s has succeeded in the upgrade of a %s to level +%s.\nCongratulations.", "%s teve sucesso em refinar %s para o nível +%s."},
tool_error = {"This isn't a valid refine item.", "Esse não é um item de refino válido"},
tool_maxlevel = {"This %s can only upgrade items to level +%s", "Este(a) %s só pode refinar itens abaixo de +%s."},
notupgradeable = {"This item isn't upgradeable.", "Este item não é refinável"},
prompt = {"Trying to refine %s to level +%s with %s%% success rate.", "Tentando refinar %s ao level +%s com %s%% de chance de sucesso."},
notenoughitems = {"You don't have %s %s to refine this item.", "Você não tem %s %s para refinar este item."}
},
attributes = {{"attack", true}, {"defense", true}, {"armor", false}}, -- MEXA APENAS SE ENTENDER O CóDIGO
downgrade = 5, -- NíVEL QUE EQUIPAMENTOS COMEçAM A REGREDIR
critical = 7, -- NíVEL QUE EQUIPAMENTOS COMEçAM A RESETAR
broadcast = {level = 7, key = true}, -- CONFIGURAçãO DO BROADCAST: 'level' define quais níveis podem mandar broadcast e 'key' liga e desliga broadcasts.
},
tools = {
--[[
Configure aqui as diferentes ferramentas de refino.
[itemid] = {max = x, chancemax = y, removeable = z}
'itemid' será o itemid da ferramenta
'x' é até qual nível a ferramenta pode refinar
'chancemax' é um bônus que a ferramenta adiciona a chance de refino
'z' define se a ferramenta some depois de refinar [true ou false]
]]--
[8302] = {max = 6, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},
[8300] = {max = 12, chancemax = 3, removeable = false, reagent = 8306, amountbylevel = true},
[8299] = {max = 10, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},
[4846] = {max = 10, chancemax = 0, removeable = false, reagent = 5880, amountbylevel = true}
},
isEquipment = function(self)
local weapontype = self:getItemWeaponType()
if (weapontype > 0 and weapontype < 7) or self.item.info.armor ~= 0 then
return true
end
return false
end,
setItemName = function(self, name)
return doItemSetAttribute(self.item.uid, "name", name)
end,
chance = function(self)
local formula = math.ceil((100/math.sqrt((((self.config.max/4)+(self.item.level*2.3))/self.config.max)*self.item.level)))
local ret = {base = (formula > 100 and 100 or formula), downgrade = 7 * self.item.level, critical = 2.5 * self.item.level}
return ret
end,
amount = function(self)
return math.ceil(self.item.level * 0.33)
end
}
function Refine:load(item)
local obj = setmetatable({item = {uid = item.uid, info = getItemInfo(item.itemid)}}, {__index = function(self, index)
if(_G[index]) then
return setmetatable({callback = _G[index]}, {__call = function(self, ...)
return self.callback(item.uid, ...)
end})
else
return Refine[index]
end
end})
if not obj:isEquipment() then
return false
end
obj:updateLevel()
return obj
end
function Refine:updateLevel()
local info = self:getItemName():match("%+(%d+)")
self.item.level = (tonumber(info) or 0)
end
function Refine:getLevel()
local info = self:getItemName():match("%+(%d+)")
return tonumber(info) or 0
end
function Refine:upgrade(cid, item)
if self.config.message.delay > 0 then doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.prompt[self.config.interface]:format(self.item.info.name, self.item.level + 1, (self:chance().base > 100 and 100 or self:chance().base))) end
local tool = self.tools[item.itemid]
if not tool then
return doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.tool_error[self.config.interface])
end
if self.item.level == self.config.max then
return doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.maxlevel[self.config.interface]:format(self.item.info.name))
end
if self.item.level >= tool.max then
return doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.tool_maxlevel[self.config.interface]:format(getItemNameById(item.itemid), tool.max))
end
if tool.reagent ~= 0 then
local count = (tool.amountbylevel == true and self:amount() or 1)
if not doPlayerRemoveItem(cid, tool.reagent, count) then
return addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.notenoughitems[self.config.interface]:format(count, (count > 1 and getItemInfo(tool.reagent).plural or getItemNameById(tool.reagent))))
end
end
if tool.removeable == true then doRemoveItem(item.uid, 1) end
if (self:chance().base + tool.chancemax) * 100 >= math.random(1, 10000) then
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.success[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))
if self.config.broadcast.key == true and (self.item.level + 1) >= self.config.broadcast.level then
doBroadcastMessage(self.config.message.broadcast[self.config.interface]:format(getCreatureName(cid), self.item.info.name, (self.item.level + 1)))
end
local r = self.config.attributes
if self.item.level > 0 then
self:setItemName(self:getItemName():gsub("%+(%d+)", "+".. (self.item.level + 1)))
for i = 1, #r do
if getItemAttribute(self.item.uid, r[i][1]) ~= nil then
doItemSetAttribute(self.item.uid, r[i][1], getItemAttribute(self.item.uid, r[i][1]) + (r[i][2] == true and (self.item.level + 1) or 1))
end
end
else
self:setItemName(self:getItemName() .." +1")
for i = 1, #r do
if self.item.info[r[i][1]] ~= 0 or self:getItemWeaponType() ~= 5 then
doItemSetAttribute(self.item.uid, r[i][1], self.item.info[r[i][1]] + 1)
end
end
end
else
local r = self.config.attributes
if self.item.level >= self.config.critical then
if self:chance().critical * 100 >= math.random(1, 10000) then
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.critical[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))
self:setItemName(self.item.info.name)
for i = 1, #r do
if self.item.info[r[i][1]] ~= 0 then
doItemSetAttribute(self.item.uid, r[i][1], self.item.info[r[i][1]])
end
end
elseif self:chance().downgrade * 100 >= math.random(1, 10000) then
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.recede[self.config.interface]:format(self.item.info.name, (self.item.level + 1), (self.item.level - 1)))
if self.item.level > 0 then
self:setItemName(self:getItemName():gsub("%+(%d+)", "+".. (self.item.level - 1)))
for i = 1, #r do
if getItemAttribute(self.item.uid, r[i][1]) ~= nil then
doItemSetAttribute(self.item.uid, r[i][1], getItemAttribute(self.item.uid, r[i][1]) - (r[i][2] == true and self.item.level or 1))
end
end
else
self:setItemName(self.item.info.name)
for i = 1, #r do
if self.item.info[r[i][1]] ~= 0 then
doItemSetAttribute(self.item.uid, r[i][1], self.item.info[r[i][1]])
end
end
end
else
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.fail[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))
end
elseif self.item.level >= self.config.downgrade then
if self:chance().downgrade * 100 >= math.random(1, 10000) then
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.recede[self.config.interface]:format(self.item.info.name, (self.item.level + 1), (self.item.level - 1)))
if self.item.level > 0 then
self:setItemName(self:getItemName():gsub("%+(%d+)", "+".. (self.item.level - 1)))
for i = 1, #r do
if getItemAttribute(self.item.uid, r[i][1]) ~= nil then
doItemSetAttribute(self.item.uid, r[i][1], getItemAttribute(self.item.uid, r[i][1]) - (r[i][2] == true and self.item.level or 1))
end
end
else
self:setItemName(self.item.info.name)
for i = 1, #r do
if self.item.info[r[i][1]] ~= 0 then
doItemSetAttribute(self.item.uid, r[i][1], self.item.info[r[i][1]])
end
end
end
else
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.fail[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))
end
else
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.fail[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))
end
end
return true
end

 

Editado por notle2012
Link para o comentário
Compartilhar em outros sites

  • 0


-- PERFECT REFINE SYSTEM BY LPZ
-- VERSION 2.0

Refine = {
config = {
max = 13, -- NíVEL MáXIMO DE REFINO
interface = 2, -- 1 PARA INGLêS, 2 PARA PORTUGUêS
message = {
type = MESSAGE_EVENT_DEFAULT,
delay = 0.5,
success = {"You have succeeded in upgrade of %s to level +%s", "Você refinou %s para o nível +%s com sucesso."},
fail = {"You have failed in upgrade of %s to level +%s", "Você falhou em refinar %s para o nível +%s."},
recede = {"You have failed in upgrade of %s to level +%s. The refine level has downgraded to +%s.", "Você falhou em refinar %s para o nível +%s e o nível regrediu para +%s."},
critical = {"You have critical failed in upgrade of %s to level +%s. The refine level has vanished.", "Você falhou criticamente em refinar %s para o nível +%s. O nível resetou."},
maxlevel = {"This %s is already on max upgrade level.", "Este(a) %s já está no nível máximo de refino."},
broadcast = {"%s has succeeded in the upgrade of a %s to level +%s.\nCongratulations.", "%s teve sucesso em refinar %s para o nível +%s."},
tool_error = {"This isn't a valid refine item.", "Esse não é um item de refino válido"},
tool_maxlevel = {"This %s can only upgrade items to level +%s", "Este(a) %s só pode refinar itens abaixo de +%s."},
notupgradeable = {"This item isn't upgradeable.", "Este item não é refinável"},
prompt = {"Trying to refine %s to level +%s with %s%% success rate.", "Tentando refinar %s ao level +%s com %s%% de chance de sucesso."},
notenoughitems = {"You don't have %s %s to refine this item.", "Você não tem %s %s para refinar este item."}
},
attributes = {{"attack", true}, {"defense", true}, {"armor", false}}, -- MEXA APENAS SE ENTENDER O CóDIGO
downgrade = 5, -- NíVEL QUE EQUIPAMENTOS COMEçAM A REGREDIR
critical = 7, -- NíVEL QUE EQUIPAMENTOS COMEçAM A RESETAR
broadcast = {level = 7, key = true}, -- CONFIGURAçãO DO BROADCAST: 'level' define quais níveis podem mandar broadcast e 'key' liga e desliga broadcasts.
},
tools = {
--[[
Configure aqui as diferentes ferramentas de refino.

[itemid] = {max = x, chancemax = y, removeable = z}

'itemid' será o itemid da ferramenta
'x' é até qual nível a ferramenta pode refinar
'chancemax' é um bônus que a ferramenta adiciona a chance de refino
'z' define se a ferramenta some depois de refinar [true ou false]
]]-- 
[8302] = {max = 6, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},
[8299] = {max = 10, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},
[4846] = {max = 12, chancemax = 0, removeable = false, reagent = 5880, amountbylevel = true},
[8300] = {max = 12, chancemax = 3, removeable = false, reagent = 8306, amountbylevel = true}
},
isEquipment = function(self)
local weapontype = self:getItemWeaponType()
if (weapontype > 0 and weapontype < 7) or self.item.info.armor ~= 0 then
return true
end
return false
end,
setItemName = function(self, name)
return doItemSetAttribute(self.item.uid, "name", name)
end,
chance = function(self)
local formula = math.ceil((100/math.sqrt((((self.config.max/4)+(self.item.level*2.3))/self.config.max)*self.item.level)))
local ret = {base = (formula > 100 and 100 or formula), downgrade = 7 * self.item.level, critical = 2.5 * self.item.level}
return ret
end,
amount = function(self)
return math.ceil(self.item.level * 0.33)
end
}

function Refine:load(item)
local obj = setmetatable({item = {uid = item.uid, info = getItemInfo(item.itemid)}}, {__index = function(self, index)
if(_G[index]) then
return setmetatable({callback = _G[index]}, {__call = function(self, ...)
return self.callback(item.uid, ...)
end})
else
return Refine[index]
end
end})

if not obj:isEquipment() then
return false
end
obj:updateLevel()
return obj
end

function Refine:updateLevel()
local info = self:getItemName():match("%+(%d+)")
self.item.level = (tonumber(info) or 0)
end

function Refine:getLevel()
local info = self:getItemName():match("%+(%d+)")
return tonumber(info) or 0
end

function Refine:upgrade(cid, item)
if self.config.message.delay > 0 then doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.prompt[self.config.interface]:format(self.item.info.name, self.item.level + 1, (self:chance().base > 100 and 100 or self:chance().base))) end
local tool = self.tools[item.itemid]
if not tool then
return doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.tool_error[self.config.interface])
end

if self.item.level == self.config.max then
return doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.maxlevel[self.config.interface]:format(self.item.info.name))
end

if self.item.level >= tool.max then
return doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.tool_maxlevel[self.config.interface]:format(getItemNameById(item.itemid), tool.max))
end

if tool.reagent ~= 0 then
local count = (tool.amountbylevel == true and self:amount() or 1)
if not doPlayerRemoveItem(cid, tool.reagent, count) then
return addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.notenoughitems[self.config.interface]:format(count, (count > 1 and getItemInfo(tool.reagent).plural or getItemNameById(tool.reagent))))
end
end

if tool.removeable == true then doRemoveItem(item.uid, 1) end
if (self:chance().base + tool.chancemax) * 100 >= math.random(1, 10000) then
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.success[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))
if self.config.broadcast.key == true and (self.item.level + 1) >= self.config.broadcast.level then
doBroadcastMessage(self.config.message.broadcast[self.config.interface]:format(getCreatureName(cid), self.item.info.name, (self.item.level + 1)))
end
local r = self.config.attributes
if self.item.level > 0 then
self:setItemName(self:getItemName():gsub("%+(%d+)", "+".. (self.item.level + 1)))
for i = 1, #r do
if getItemAttribute(self.item.uid, r[i][1]) ~= nil then
doItemSetAttribute(self.item.uid, r[i][1], getItemAttribute(self.item.uid, r[i][1]) + (r[i][2] == true and (self.item.level + 1) or 1))
end
end
else
self:setItemName(self:getItemName() .." +1")
for i = 1, #r do
if self.item.info[r[i][1]] ~= 0 or self:getItemWeaponType() ~= 5 then
doItemSetAttribute(self.item.uid, r[i][1], self.item.info[r[i][1]] + 1)
end
end
end
else
local r = self.config.attributes
if self.item.level >= self.config.critical then
if self:chance().critical * 100 >= math.random(1, 10000) then
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.critical[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))
self:setItemName(self.item.info.name)
for i = 1, #r do
if self.item.info[r[i][1]] ~= 0 then
doItemSetAttribute(self.item.uid, r[i][1], self.item.info[r[i][1]])
end
end
elseif self:chance().downgrade * 100 >= math.random(1, 10000) then
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.recede[self.config.interface]:format(self.item.info.name, (self.item.level + 1), (self.item.level - 1)))
if self.item.level > 0 then
self:setItemName(self:getItemName():gsub("%+(%d+)", "+".. (self.item.level - 1)))
for i = 1, #r do
if getItemAttribute(self.item.uid, r[i][1]) ~= nil then
doItemSetAttribute(self.item.uid, r[i][1], getItemAttribute(self.item.uid, r[i][1]) - (r[i][2] == true and self.item.level or 1))
end
end
else
self:setItemName(self.item.info.name)
for i = 1, #r do
if self.item.info[r[i][1]] ~= 0 then
doItemSetAttribute(self.item.uid, r[i][1], self.item.info[r[i][1]])
end
end
end
else
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.fail[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))
end
elseif self.item.level >= self.config.downgrade then
if self:chance().downgrade * 100 >= math.random(1, 10000) then
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.recede[self.config.interface]:format(self.item.info.name, (self.item.level + 1), (self.item.level - 1)))
if self.item.level > 0 then
self:setItemName(self:getItemName():gsub("%+(%d+)", "+".. (self.item.level - 1)))
for i = 1, #r do
if getItemAttribute(self.item.uid, r[i][1]) ~= nil then
doItemSetAttribute(self.item.uid, r[i][1], getItemAttribute(self.item.uid, r[i][1]) - (r[i][2] == true and self.item.level or 1))
end
end
else
self:setItemName(self.item.info.name)
for i = 1, #r do
if self.item.info[r[i][1]] ~= 0 then
doItemSetAttribute(self.item.uid, r[i][1], self.item.info[r[i][1]])
end
end
end
else
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.fail[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))
end
else
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.fail[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))
end
end 
return true
end

 

Testa aí parceiro. Está sem erros. Mas se der algo poste aqui mesmo que tentarei ajuda-lo.

Abraços.

Link para o comentário
Compartilhar em outros sites

  • 0

config = {
max = 13, -- NíVEL MáXIMO DE REFINO
interface = 2, -- 1 PARA INGLêS, 2 PARA PORTUGUêS
message = {
type = MESSAGE_EVENT_DEFAULT,
delay = 0.5,
success = {"You have succeeded in upgrade of %s to level +%s", "Você refinou %s para o nível +%s com sucesso."},
fail = {"You have failed in upgrade of %s to level +%s", "Você falhou em refinar %s para o nível +%s."},
recede = {"You have failed in upgrade of %s to level +%s. The refine level has downgraded to +%s.", "Você falhou em refinar %s para o nível +%s e o nível regrediu para +%s."},
critical = {"You have critical failed in upgrade of %s to level +%s. The refine level has vanished.", "Você falhou criticamente em refinar %s para o nível +%s. O nível resetou."},
maxlevel = {"This %s is already on max upgrade level.", "Este(a) %s já está no nível máximo de refino."},
broadcast = {"%s has succeeded in the upgrade of a %s to level +%s.\nCongratulations.", "%s teve sucesso em refinar %s para o nível +%s."},
tool_error = {"This isn't a valid refine item.", "Esse não é um item de refino válido"},
tool_maxlevel = {"This %s can only upgrade items to level +%s", "Este(a) %s só pode refinar itens abaixo de +%s."},
notupgradeable = {"This item isn't upgradeable.", "Este item não é refinável"},
prompt = {"Trying to refine %s to level +%s with %s%% success rate.", "Tentando refinar %s ao level +%s com %s%% de chance de sucesso."},
notenoughitems = {"You don't have %s %s to refine this item.", "Você não tem %s %s para refinar este item."}
},
attributes = {{"attack", true}, {"defense", true}, {"armor", false}}, -- MEXA APENAS SE ENTENDER O CóDIGO
downgrade = 5, -- NíVEL QUE EQUIPAMENTOS COMEçAM A REGREDIR
critical = 7, -- NíVEL QUE EQUIPAMENTOS COMEçAM A RESETAR
broadcast = {level = 7, key = true}, -- CONFIGURAçãO DO BROADCAST: 'level' define quais níveis podem mandar broadcast e 'key' liga e desliga broadcasts.
},
tools = {
--[[
Configure aqui as diferentes ferramentas de refino.

[itemid] = {max = x, chancemax = y, removeable = z}

'itemid' será o itemid da ferramenta
'x' é até qual nível a ferramenta pode refinar
'chancemax' é um bônus que a ferramenta adiciona a chance de refino
'z' define se a ferramenta some depois de refinar [true ou false]
]]-- 
[8302] = {max = 6, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},
[8299] = {max = 10, chancemax = 0, removeable = true, reagent = 0, amountbylevel = false},
[4846] = {max = 12, chancemax = 0, removeable = false, reagent = 5880, amountbylevel = true},
[8300] = {max = 12, chancemax = 3, removeable = false, reagent = 8306, amountbylevel = true}
},
isEquipment = function(self)
local weapontype = self:getItemWeaponType()
if (weapontype > 0 and weapontype < 7) or self.item.info.armor ~= 0 then
return true
end
return false
end,
setItemName = function(self, name)
return doItemSetAttribute(self.item.uid, "name", name)
end,
chance = function(self)
local formula = math.ceil((100/math.sqrt((((self.config.max/4)+(self.item.level*2.3))/self.config.max)*self.item.level)))
local ret = {base = (formula > 100 and 100 or formula), downgrade = 7 * self.item.level, critical = 2.5 * self.item.level}
return ret
end,
amount = function(self)
return math.ceil(self.item.level * 0.33)
end
}

function Refine:load(item)
local obj = setmetatable({item = {uid = item.uid, info = getItemInfo(item.itemid)}}, {__index = function(self, index)
if(_G[index]) then
return setmetatable({callback = _G[index]}, {__call = function(self, ...)
return self.callback(item.uid, ...)
end})
else
return Refine[index]
end
end})

if not obj:isEquipment() then
return false
end
obj:updateLevel()
return obj
end

function Refine:updateLevel()
local info = self:getItemName():match("%+(%d+)")
self.item.level = (tonumber(info) or 0)
end

function Refine:getLevel()
local info = self:getItemName():match("%+(%d+)")
return tonumber(info) or 0
end

function Refine:upgrade(cid, item)
if self.config.message.delay > 0 then doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.prompt[self.config.interface]:format(self.item.info.name, self.item.level + 1, (self:chance().base > 100 and 100 or self:chance().base))) end
local tool = self.tools[item.itemid]
if not tool then
return doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.tool_error[self.config.interface])
end

if self.item.level == self.config.max then
return doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.maxlevel[self.config.interface]:format(self.item.info.name))
end

if self.item.level >= tool.max then
return doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.tool_maxlevel[self.config.interface]:format(getItemNameById(item.itemid), tool.max))
end

if tool.reagent ~= 0 then
local count = (tool.amountbylevel == true and self:amount() or 1)
if not doPlayerRemoveItem(cid, tool.reagent, count) then
return addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.notenoughitems[self.config.interface]:format(count, (count > 1 and getItemInfo(tool.reagent).plural or getItemNameById(tool.reagent))))
end
end

if tool.removeable == true then doRemoveItem(item.uid, 1) end
if (self:chance().base + tool.chancemax) * 100 >= math.random(1, 10000) then
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.success[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))
if self.config.broadcast.key == true and (self.item.level + 1) >= self.config.broadcast.level then
doBroadcastMessage(self.config.message.broadcast[self.config.interface]:format(getCreatureName(cid), self.item.info.name, (self.item.level + 1)))
end
local r = self.config.attributes
if self.item.level > 0 then
self:setItemName(self:getItemName():gsub("%+(%d+)", "+".. (self.item.level + 1)))
for i = 1, #r do
if getItemAttribute(self.item.uid, r[i][1]) ~= nil then
doItemSetAttribute(self.item.uid, r[i][1], getItemAttribute(self.item.uid, r[i][1]) + (r[i][2] == true and (self.item.level + 1) or 1))
end
end
else
self:setItemName(self:getItemName() .." +1")
for i = 1, #r do
if self.item.info[r[i][1]] ~= 0 or self:getItemWeaponType() ~= 5 then
doItemSetAttribute(self.item.uid, r[i][1], self.item.info[r[i][1]] + 1)
end
end
end
else
local r = self.config.attributes
if self.item.level >= self.config.critical then
if self:chance().critical * 100 >= math.random(1, 10000) then
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.critical[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))
self:setItemName(self.item.info.name)
for i = 1, #r do
if self.item.info[r[i][1]] ~= 0 then
doItemSetAttribute(self.item.uid, r[i][1], self.item.info[r[i][1]])
end
end
elseif self:chance().downgrade * 100 >= math.random(1, 10000) then
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.recede[self.config.interface]:format(self.item.info.name, (self.item.level + 1), (self.item.level - 1)))
if self.item.level > 0 then
self:setItemName(self:getItemName():gsub("%+(%d+)", "+".. (self.item.level - 1)))
for i = 1, #r do
if getItemAttribute(self.item.uid, r[i][1]) ~= nil then
doItemSetAttribute(self.item.uid, r[i][1], getItemAttribute(self.item.uid, r[i][1]) - (r[i][2] == true and self.item.level or 1))
end
end
else
self:setItemName(self.item.info.name)
for i = 1, #r do
if self.item.info[r[i][1]] ~= 0 then
doItemSetAttribute(self.item.uid, r[i][1], self.item.info[r[i][1]])
end
end
end
else
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.fail[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))
end
elseif self.item.level >= self.config.downgrade then
if self:chance().downgrade * 100 >= math.random(1, 10000) then
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.recede[self.config.interface]:format(self.item.info.name, (self.item.level + 1), (self.item.level - 1)))
if self.item.level > 0 then
self:setItemName(self:getItemName():gsub("%+(%d+)", "+".. (self.item.level - 1)))
for i = 1, #r do
if getItemAttribute(self.item.uid, r[i][1]) ~= nil then
doItemSetAttribute(self.item.uid, r[i][1], getItemAttribute(self.item.uid, r[i][1]) - (r[i][2] == true and self.item.level or 1))
end
end
else
self:setItemName(self.item.info.name)
for i = 1, #r do
if self.item.info[r[i][1]] ~= 0 then
doItemSetAttribute(self.item.uid, r[i][1], self.item.info[r[i][1]])
end
end
end
else
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.fail[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))
end
else
addEvent(doPlayerSendTextMessage, self.config.message.delay * 1000, cid, self.config.message.type, self.config.message.fail[self.config.interface]:format(self.item.info.name, (self.item.level + 1)))
end
end 
return true
end

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...