Postado Junho 30, 2014 10 anos Este é um post popular. Fala galera do TK, hoje vim trazer pra vocês à pedidos do grande @azzouks uma versão do meu Dodge System por equips. Explicação: É um sistema onde vc pode colocar uma % de esquiva nos itens e ao usá-los você ganha a chance de desviar dos ataques e levar somente metade do dano. Qualquer semelhança com esse > http://www.tibiaking.com/forum/topic/8223-mod-reflect-system-01/ < mod do @Aluccard não é mera coincidência, eu usei o mod dele como base pra fazer o meu *-* Sem mais delongas vamos ao script: Vá na pasta do seu server e abra uma pasta chamada "mods".. lá dentro crie um arquivo com o nome que vc quiser (sério) de extensão.xml e adicione o seguinte nele: <?xml version="1.0" encoding="UTF-8"?> <mod name="Dodge System" version="0.1" author="Night Wolf" contact="" enabled="yes"> <event type="login" name="registerDodge" event="script"><![CDATA[ function onLogin(cid) registerCreatureEvent(cid,"dodge") return true end ]]></event> <event type="statschange" name="dodge" event="script"><![CDATA[ function onStatsChange(cid, attacker, type, combat, value) if (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) and isCreature(attacker) then local max = 50 local slotPos = {1,2,3,4,5,6,7,8,9} local percent = 0.5 local dodgePercent = 0 for i = 1, #slotPos do if getPlayerSlotItem(cid, slotPos[i]).uid > 1 then if getItemDodgePercent(getPlayerSlotItem(cid, slotPos[i]).uid) then dodgePercent = dodgePercent + getItemDodgePercent(getPlayerSlotItem(cid, slotPos[i]).uid) end end end if dodgePercent >= max then dodgePercent = max end if dodgePercent >= math.random (0,100) then value = math.ceil(value*(percent)) doTargetCombatHealth(attacker, cid, combat, -value, -value, 255) doSendAnimatedText(getCreaturePos(cid), "DODGE", 6) return false end end return true end]]></event> </mod> Configurando: Se você não manja de script então eu sugiro que vcs só alterem essa parte aqui: local max = 50local percent = 0.5local dodgePercent = 0 em vermelho é o máximo que uma pessoa pode ter de dodge: se ela tiver usando um full set que deixe ela com um total de 99% de dodge ela só vai poder aproveitar 50%. Isso foi feito pra evitar um bug.. vocês podem se sentir livres pra alterar esse numero mas não coloquem nada muito grande pra evitar que seus servers explodam.em verde é a porcentagem do dano que vocês vao tomar ao desviar.. nesse caso os ataques que eu der dodge darão 50% do dano (0.5)em azul é a porcentagem inicial que todos os players vão ter. Por padrão está 0 mas se vc quiser que todos os players do seu server tenham 20% e que cada item dê 5% também é possível editando esse 0 pra 20. Feito isso vá em data\lib\function.lua e adicione essas linhas function getItemDodgePercent(itemuid) return getItemAttribute(itemuid, "dodgePercent") end function doPlayerAddDodgeItem(cid, itemid, percent) local item = doPlayerAddItem(cid, itemid) doItemSetAttribute(item, "description", "[Dodge: "..percent.."%]") doItemSetAttribute(item, "dodgePercent", percent) end Agora é só aproveitar no seu server.. toda vez que vc for usar num script vc poderá utilizar as funções getItemDodgePercent(item) e a doPlayerAddDodgeItem(cid, itemid, percent). Pra finalizar aqui tem um exemplo de uma quest que dá uma plate armor com 0.8% de dodge: function onUse(cid, item, frompos, item2, topos) queststatus = getPlayerStorageValue(cid,50100) if queststatus == -1 then doPlayerSendTextMessage(cid,22,"You have found a plate armor with dodge.") doPlayerAddDodgeItem(cid, 2463, 0.8) setPlayerStorageValue(cid,50100,1) else doPlayerSendTextMessage(cid,22,"It is empty.") end return true end e uma fotinha pra vcs: Espero que gostem! EDITADO: Fiz um script de action pra ser uma pedra que vai dar dodge nos items. Ele tem muito que melhorar mas por ora ele tá 99% pronto pra ser colocado em algum server que utilize esse dodge system. function isHandItem(uid) -- NW based on Mock uid = uid or 0 if isInArray({1,2,3,4,5,6}, getItemWeaponType(uid)) then return true end return false end function getItemDodgePercent(itemuid) return getItemAttribute(itemuid, "dodgePercent") or 0 end function setItemDodgePercent(uid, percent) doItemSetAttribute(uid, "description", "[Dodge: "..percent.."%]") doItemSetAttribute(uid, "dodgePercent", percent) end function onUse(cid, item, fromPosition, itemEx, toPosition) level = 0 local upgrade = { [1] = {min = 1, max = 5, chance = 100}, [2] = {min = 5, max = 10, chance = 80}, [3] = {min = 10, max = 20, chance = 60}, [4] = {min = 20, max = 40, chance = 40}, [5] = {min = 40, max = 50, chance = 20} } function isWearing(uid) -- NW based on Mock uid = uid or 0 if isInArray({uid}, getPlayerSlotItem(cid, 1).uid) or isInArray({uid}, getPlayerSlotItem(cid, 4).uid) or isInArray({uid}, getPlayerSlotItem(cid, 7).uid) or isInArray({uid}, getPlayerSlotItem(cid, 8).uid) then return true end return false end if isHandItem(itemEx.uid) or isWearing(itemEx.uid) then local name = getItemName(itemEx.uid) local atual = math.floor(getItemDodgePercent(itemEx.uid)*10)/10 for i = 1, #upgrade do if string.find(tostring(name),"+".. i .."") then level = i end end if level >= #upgrade then doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"Your item is already on max level, you can't upgrade it any further.") return true end if math.random(0,100) <= upgrade[level + 1].chance then doRemoveItem(item.uid, 1) doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"You leveled your "..getItemNameById(itemEx.itemid).." to ".. level+1 ..".") setItemDodgePercent(itemEx.uid, atual + (math.random(upgrade[level+1].min,upgrade[level+1].max))/10) doItemSetAttribute(itemEx.uid,'name', getItemNameById(itemEx.itemid)..' +'..(level+1)) doSendMagicEffect(toPosition, math.random(28,30)) else doRemoveItem(itemEx.uid, 1) doRemoveItem(item.uid, 1) doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"Your "..getItemNameById(item.itemid).." has failed and destroyed your "..getItemNameById(itemEx.itemid).." in the process") doSendMagicEffect(toPosition, 4) end else doPlayerSendTextMessage(cid, 24,"You cant refine this item.") end return true end Note que pra colocar dodge num item ele tem que: Estar equipado se for qualquer tipo de armadura (legs, boots, helmet, armor) ou livremente (se for weapon/shield).. Necklaces, rings e pendants não são possíveis de colocar dodge.. se vc quiser que seja edita essa função dentro do script pros slots de ring e necklace mas eu não aconselharia a fazer isso. function isWearing(uid) -- NW based on Mock uid = uid or 0 if isInArray({uid}, getPlayerSlotItem(cid, 1).uid) or isInArray({uid}, getPlayerSlotItem(cid, 4).uid) or isInArray({uid}, getPlayerSlotItem(cid, 7).uid) or isInArray({uid}, getPlayerSlotItem(cid, 8).uid) then return true end return false end e no xml coloque: <action itemid="8306" script=upgraderock.lua"/> Editado Agosto 21, 2014 10 anos por xWhiteWolf (veja o histórico de edições)
Postado Junho 30, 2014 10 anos Mais bonito que isso só o VittinG! Excelente lindão, continue sempre assim, reputado.
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.