Postado Julho 19, 2015 9 anos boa tarde,estou precisando de ajuda em um script, a minha ideia é fazer com que equipamentos com determinada habilidade passe a healar vida ao inves de tomar dano por determinado elemento, por exemplo armadura com "eatfire" me hela ao receber hit de fogo,mas nao sei a tag exata para usar ja q fiquei muito tempo sem editar otservers, estou fazendo script baseado nesse script de dodge do night wolf <?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) then local max = 100 local slotPos = {1,2,3,4,5,6,7,8,9} local percent = 1 local dodgePercent = 0 for i = 1, #slotPos do if getPlayerSlotItem(cid, slotPos).uid > 1 then if getItemDodgePercent(getPlayerSlotItem(cid, slotPos).uid) then dodgePercent = dodgePercent + getItemDodgePercent(getPlayerSlotItem(cid, slotPos).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> ja consegui fazer com q heale ao inves de dar dano,mas de todos eles,mas se alguem poder me ajudar a introduzir uma tag que limite a dano de fogo, agradeço,depois farei scripts separados para cada elemento,e tb mudarei os nomes , nao vou colocar dodge com esta ali, esse é só uma base tb tenho outra duvida no server, q uso nao mostra healing damage mesmo com showhealingdamage em true, alguem sabe resolver,uso Styller 8.60,mais antigo ,pq é da epoca q parei e tb pq usa sqlite, q prefiro e se por acaso alguem tiver algum script base onde eu posso adaptar para monstros fazerem o mesmo com elementos,pode colocar ai, se nao for pedir muito, dsde ja agradeço pela ajuda Editado Julho 19, 2015 9 anos por TNTDZ (veja o histórico de edições)
Postado Julho 19, 2015 9 anos Solução Olá amigo, primeiramente queria dizer que fico feliz de saber que meus scripts estão sendo úteis. Pro seu problema de healar apenas para danos de fogo: no callback onStatsChange nós temos alguns parametros que nos permite manipular que tipo de dano estamos recebendo: function onStatsChange(cid, attacker, type, combat, value) cid - uid do player que tem os stats alterados attacker - uid do player que implica essa mudança de stats type - tipo de mudança de stats que está ocorrendo combat - o tipo de combat que está sendo utilizado para fazer a alteração de stats value - valor da mudança de stats vide> http://www.tibiaking.com/forum/topic/34420-callbacks-de-creaturescripts/ Como você quer dar heal somente em danos de fogo, estamos procurando um combat do tipo COMBAT_FIREDAMAGE Apenas faça um if combat == COMBAT_FIREDAMAGE ou if combat == 8 (no lugar desse 8 você bota no numero que aparece lá em data/lib/constant.lua O meu está COMBAT_FIREDAMAGE = 8 então eu posso usar tanto 8 quanto COMBAT_FIREDAMAGE e aí você aplica o heal dentro dessa condição. Espero ter ajudado em algo Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá! "Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda (obg ao @Beeny por fazer essa linda sign <3)
Postado Julho 19, 2015 9 anos Autor muito obrigado, funcionou perfeito, ja tinha tentado algo parecido, mas tava usando combat == FIREDAMAGE e nao combat == COMBAT_FIREDAMAGE, como vc me disse , (uma palavrinha muda tudo)e obrigado por me lembrar da lista constant.lua ,me basearei nela daqui em diante, vou tb colocar o arquivo aki caso alguem precise <?xml version="1.0" encoding="UTF-8"?> function onLogin(cid) registerCreatureEvent(cid,"dodge") return true end function onStatsChange(cid, attacker, type, combat, value) if (type == STATSCHANGE_HEALTHLOSS and combat == COMBAT_FIREDAMAGE) then local max = 100 local slotPos = {1,2,3,4,5,6,7,8,9} local percent = 1 local dodgePercent = 0 for i = 1, #slotPos do if getPlayerSlotItem(cid, slotPos).uid > 1 then if getItemDodgePercent(getPlayerSlotItem(cid, slotPos).uid) then dodgePercent = dodgePercent + getItemDodgePercent(getPlayerSlotItem(cid, slotPos).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), ""..value.."", 12) return false end end return true end nessa linha doSendAnimatedText(getCreaturePos(cid), ""..value.."", 12) coloquei assim pq meu server nao esta mostrando healing damage e tens algo ai que eu posso me basear para fazer tipo fire elemental healar ao ser atingido por fogo por exemplo? estou com outra duvida agora 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 getItemthundereaterPercent(itemuid) return getItemAttribute(itemuid, "thundereaterPercent") or 0 end function setItemthundereaterPercent(uid, percent) doItemSetAttribute(uid, "description", "[thundereater: "..percent.."%]") doItemSetAttribute(uid, "thundereaterPercent", 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 = 100}, [3] = {min = 10, max = 20, chance = 100}, [4] = {min = 20, max = 40, chance = 100}, [5] = {min = 40, max = 50, chance = 100} } 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(getItemthundereaterPercent(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 ..".") setItemthundereaterPercent(itemEx.uid,100) doItemSetAttribute(itemEx.uid,'name', getItemNameById(itemEx.itemid)..' +'..(level+1)) doSendMagicEffect(toPosition, math.random(28,30)) else doRemoveItem(item.uid, 1) doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"Your "..getItemNameById(item.itemid).." has failed ") doSendMagicEffect(toPosition, 4) end else doPlayerSendTextMessage(cid, 24,"You cant refine this item.") end return true end nesse script tenho outro desse que adiciona fire eater, e nesse que esta ali adiciona thunder, so q no caso ele so addiciona 1, quando eu coloco outro atribute ele substitui, como faço para acumular 2 ou mais atributos? reparei agora q addicona os 2 sim, é so na descricao q so mostra 1, vo da uma olhada e ve se arrumo Editado Julho 19, 2015 9 anos por TNTDZ (veja o histórico de edições)
Postado Julho 20, 2015 9 anos vc tem que fazer o creatureevent pro monstro em vez de fazer pro player.. e aí colocar a tag no xml do monstro. Não pode ser por mod isso, teria que ser um creaturescript só com function onStatsChange(cid, attacker, type, combat, value) if (type == STATSCHANGE_HEALTHLOSS and combat == COMBAT_FIREDAMAGE) then local max = 100 local slotPos = {1,2,3,4,5,6,7,8,9} local percent = 1 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), ""..value.."", 12) return false end end return true end Sobre o segundo problema: ele só aceita 5 leveis por item, vc tá adicionando level 1 de fire e dps level 2 thunder, ele vai contar os 2 mas fica 1 nv de fire e 1 nv de thunder no item. Pra mostrar os dois teria que fazer uma gambiara na hr de modificar o nome do item pra colocar o +X e +Y referente a cada elemento, só q isso vai ficar bem zoado se vc fizer pra todos os elementos. Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá! "Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda (obg ao @Beeny por fazer essa linda sign <3)
Postado Julho 20, 2015 9 anos Autor existe algo como ADDitematribute description ou so tem itemSETattribute?
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.