Boa noite, eu estive procurando no fórum um script que atribuísse slot e atributos a um item, eu ate encontrei o script no fórum, porem estou precisando de ajuda para ajusta-lo ou corrigir o bug.
Script:
Creaturescript:
Spoiler
---Script by mock the bear!local conditionMP,conditionHP,conditionML,conditionCLUB,conditionSHI,conditionDIST,conditionAMP ={},{},{},{},{},{},{}for i=1,100do---Carrega as conditions--- HP
conditionHP[i]= createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionHP[i], CONDITION_PARAM_TICKS,-1)
setConditionParam(conditionHP[i], CONDITION_PARAM_STAT_MAXHEALTHPERCENT,20+i)
setConditionParam(conditionHP[i], CONDITION_PARAM_BUFF,true)
setConditionParam(conditionHP[i], CONDITION_PARAM_SUBID,50)--MANA
conditionMP[i]= createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionMP[i], CONDITION_PARAM_TICKS,-1)
setConditionParam(conditionMP[i], CONDITION_PARAM_STAT_MAXMANAPERCENT,20+i)
setConditionParam(conditionMP[i], CONDITION_PARAM_BUFF,true)
setConditionParam(conditionMP[i], CONDITION_PARAM_SUBID,51)--Magic level
conditionML[i]= createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionML[i], CONDITION_PARAM_TICKS,-1)
setConditionParam(conditionML[i], CONDITION_PARAM_STAT_MAGICLEVELPERCENT,20+i)
setConditionParam(conditionML[i], CONDITION_PARAM_BUFF,true)
setConditionParam(conditionML[i], CONDITION_PARAM_SUBID,52)--club axe sword
conditionCLUB[i]= createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionCLUB[i], CONDITION_PARAM_TICKS,-1)
setConditionParam(conditionCLUB[i], CONDITION_PARAM_SKILL_CLUBPERCENT,50+i)
setConditionParam(conditionCLUB[i], CONDITION_PARAM_SKILL_SWORDPERCENT,50+i)
setConditionParam(conditionCLUB[i], CONDITION_PARAM_SKILL_AXEPERCENT,50+i)
setConditionParam(conditionCLUB[i], CONDITION_PARAM_BUFF,true)
setConditionParam(conditionCLUB[i], CONDITION_PARAM_SUBID,53)--- shield
conditionSHI[i]= createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionSHI[i], CONDITION_PARAM_TICKS,-1)
setConditionParam(conditionSHI[i], CONDITION_PARAM_SKILL_SHIELDPERCENT,30+i)
setConditionParam(conditionSHI[i], CONDITION_PARAM_BUFF,true)
setConditionParam(conditionSHI[i], CONDITION_PARAM_SUBID,54)--- dist
conditionDIST[i]= createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionDIST[i], CONDITION_PARAM_TICKS,-1)
setConditionParam(conditionDIST[i], CONDITION_PARAM_SKILL_DISTANCEPERCENT,50+i)
setConditionParam(conditionDIST[i], CONDITION_PARAM_BUFF,true)
setConditionParam(conditionDIST[i], CONDITION_PARAM_SUBID,55)endfunction getSlotType(n)--By mock the bearifnot n thenreturnfalseendif n:match('%[(.+)%]')then
n = n:match('%[(.+)%]')if n =='?'thenreturn0,n
elsereturn n:match('(.-)%.([+-])(%d+)%%')endelsereturnfalseendendlocalfunction loadSet(cid)local t ={}for slot=1,9do
t[slot]=''local s = getPlayerSlotItem(cid,slot).uid
if s ~=0then
t[slot]= getItemName(s)endendreturn t
endfunction isInArray2(arr,var)-- Because in some servers it return 1 and 0 and others true and falsefor i,b in pairs(arr)doif var == b thenreturntrueendendreturnfalseendfunction check2(cid,i)if i ==5or i ==6thenif isInArray({'head','necklace','backpack','body','legs','feet','ring'},getItemValue(getPlayerSlotItem(cid,i).itemid,'slotType')or'')thenreturnfalseendendreturntrueendfunction chk(cid,f)ifnot isPlayer(cid)thenreturnendlocal t = loadSet(cid)for i=1,#f doif f[i]~= t[i]then
equip(cid,nil,slot)breakendend
addEvent(chk,2000,cid,t)end
items ={---- Only to get attr: slotType because getItemName dont return it -.-'
_VERSION='1.0 By mock',
XML_DIR='data/items/items.xml',}dolocal ia = os.clock()
io.write('Loading items')local i = io.open(items.XML_DIR,'r')local u = i:read(-1)
i:close()local u = u:match('<items>(.+)</items>')for mi,id,mid,name,data,me in u:gmatch('<(%a-)%s*id%s*=%s*"(%d+)"%s*(.-)%s*name%s*=%s*"(.-)"%s*>(.-)</(%a*)>')doif mi =='item'and me =='item'thenlocal td ={name=name,id=id,type=1}for key,value in data:gmatch('<attribute key="(.-)" value="(.-)"/>')do
td[key]= value
endfor key,value in mid:gmatch('(.-)="(.-)"')do
td[key]= value
end
items[tonumber(id)]= td
items[name]= td
endendfor mi,id,mid,name,data in u:gmatch('<(%a-)%s*id%s*=%s*"(%d*)"%s*(.-)%s*name%s*=%s*"(%a+)"%s*/>')doif mi =='item'thenlocal td ={name=name,id=id,type=2}for key,value in mid:gmatch('(.-)="(.-)"')do
td[key]= value
end
items[tonumber(id)]= td
items[name]= td
endend
io.write('[done '..os.clock()-ia..']\n')endfunction getItemValue(item,value)return items[item]and items[item][value]endfunction equip(cid,item,slot)--By mock the bearlocal HP = getCreatureHealth(cid)local MP = getCreatureMana(cid)local t ={}if item thenlocal mm,sinal,qto = getSlotType(getItemName(item.uid))
t[mm]= tonumber(qto)endfor i=1,9do-- Not on slot 10 > arrowif i ~= slot thenif getPlayerSlotItem(cid,i).itemid ~=0thenlocal aab = getPlayerSlotItem(cid,i).uid
if aab and check2(cid,i)thenfor _ in getItemName(aab):gmatch('(%[.-%])')dolocal mm,sinal,qto2 = getSlotType(_)if mm thenifnot t[mm]then
t[mm]=0end
t[mm]= t[mm]+tonumber(qto2)
t[mm]= t[mm]>100and100or t[mm]endendendendendendlocal fu =0local ca ={}local s =''for sl,n in pairs(t)do
fu = fu+1
s = s..''..n..'% more of '..sl..'\n'if sl =='hp'then
doAddCondition(cid,conditionHP[tonumber(n)])
doCreatureAddHealth(cid,HP-getCreatureHealth(cid))
ca[50]=1
doPlayerSendTutorial(cid,19)elseif sl =='mp'then
doAddCondition(cid,conditionMP[tonumber(n)])
doCreatureAddMana(cid,HP-getCreatureMana(cid))
ca[51]=1
doPlayerSendTutorial(cid,19)elseif sl =='ml'then
doAddCondition(cid,conditionML[tonumber(n)])
ca[52]=1elseif sl =='cas'then
doAddCondition(cid,conditionCLUB[tonumber(n)])
ca[53]=1elseif sl =='shield'then
doAddCondition(cid,conditionSHI[tonumber(n)])
ca[54]=1elseif sl =='dist'then
doAddCondition(cid,conditionDIST[tonumber(n)])
ca[55]=1endendif fu >0then
addEvent(doPlayerSendTextMessage,100,cid,24,'You have:\n'..s)for i=50,55doifnot ca[i]then
doRemoveCondition(cid,CONDITION_ATTRIBUTES,i)endendelsefor i=50,55do
doRemoveCondition(cid,CONDITION_ATTRIBUTES,i)endendreturntrueendfunction onLogin(cid)---Script by mock the bear!
equip(cid,nil,slot)
addEvent(chk,2000,cid,loadSet(cid))-- Here we check!return TRUE
end
Action:
Spoiler
--[[
Slot system 100% by mock \o
]]---Configlocal conf ={
maxSlotCount=2,
ignoredIds={},
items ={--[itemid] = {attr = "hp"/"mp"/"ml"/"cas"/"shield"/"dist", percent = x%},[4918]={attr ="hp", percent =5},[13562]={attr ="mp", percent =5},[1231]={attr ="dist", percent =15},[4925]={attr ="ml", percent =5},--etc},}--Endfunction choose(...)--- Function by mock.local arg ={...}return arg[math.random(1,#arg)]endifnot getItemAttack thenfunction getItemAttack(uid)return getItemAttribute(uid,'attack')endfunction getItemDefense(uid)return getItemAttribute(uid,'defense')endendlocalfunction isArmor(uid)-- Function by Mock the bear.if(getItemInfo(uid.itemid).armor ~=0)and(getItemWeaponType(uid.uid)==0)thenreturntrueendreturnfalseendlocalfunction isWeapon(uid)-- Function by Mock the bear.
uid = uid or0local f = getItemWeaponType(uid)if f ==1or f ==2or f ==3thenreturntrueendreturnfalseendlocalfunction isShield(uid)-- Function by Mock the bear.
uid = uid or0if getItemWeaponType(uid)==4thenreturntrueendreturnfalseendlocalfunction isBow(uid)-- Function by Mock the bear.
uid = uid or0if getItemWeaponType(uid)==5andnot isItemStackable(uid)thenreturntrueendreturnfalseendfunction onUse(cid, item, fromPosition, itemEx, toPosition)-- Script by mock the bear (MTB)if item.uid ==0or item.itemid ==0thenreturnfalseendlocal itemTable = conf.items[item.itemid]ifnot itemTable thenreturn doPlayerSendCancel(cid,"You cannot use this item.")end
toPosition.stackpos =255if item.uid ==0or item.itemid ==0thenreturnfalseend
toPosition.stackpos =255if isInArray(conf.ignoredIds, itemEx.itemid)or(not getItemWeaponType(itemEx.uid)or getItemWeaponType(itemEx.uid)>5)or(getItemWeaponType(itemEx.uid)==0andnot isArmor(itemEx))or itemEx.itemid ==0or itemEx.type >1or isItemStackable(itemEx.uid)then
doPlayerSendTextMessage(cid,24,"You cant open a slot on this item.")returntrueendif isCreature(itemEx.uid)thenreturnfalseendlocal nam = getItemName(itemEx.uid)function getSlotCount(nam)local c =0for _ in nam:gmatch('%[(.-)%]')do
c = c+1endreturn c
endif getSlotCount(nam)< conf.maxSlotCount thenlocal l = itemTable.attr
local p = itemTable.percent
doSendMagicEffect(toPosition,30)
nam = nam..' ['..l..'.+'..p..'%]'
doSendAnimatedText(toPosition,l..' '..p..'%',120)
doItemSetAttribute(itemEx.uid,'name',nam)
doRemoveItem(item.uid,1)else
doPlayerSendTextMessage(cid,24,"You cant open a slot on this item.")endreturntrueend
Bom o script está funcionando, porem o bug que esta acontecendo é que ao utilizar o item no set ele esta atribuindo a % porem não esta somando com as skill e HP que o player já possui, eu queria ajuda nesta parte.
Caso não tiver solução eu queria trocar % por atributos brutos por ex: (+15 de ml sem ser em %)
Pergunta
Asasashu3 0
Boa noite, eu estive procurando no fórum um script que atribuísse slot e atributos a um item, eu ate encontrei o script no fórum, porem estou precisando de ajuda para ajusta-lo ou corrigir o bug.
Script:
Creaturescript:
Action:
Bom o script está funcionando, porem o bug que esta acontecendo é que ao utilizar o item no set ele esta atribuindo a % porem não esta somando com as skill e HP que o player já possui, eu queria ajuda nesta parte.
Caso não tiver solução eu queria trocar % por atributos brutos por ex: (+15 de ml sem ser em %)
TFS: 0.3.6
REP+
Agradeço a Atenção.
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados