Myself 0 Postado Dezembro 25, 2008 Share Postado Dezembro 25, 2008 (editado) Olá pessoal. Em primeiro lugar, já adianto que o tópico não é meu. Créditos totais a Tio Gordo, do outro fórum. Do que se trata Se trata de um NPC igual ao rei Tibianus, Orc King, Queen Eloise, etc. que quando se fala por exemplo, "fuck", o NPC te dá um golpe e lhe deixa com 1 HP. Vamos lá? 1° lugar: Em data/npc Copie um arquivo .XML de um NPC qualquer, e renomeie para King Tibianus.XML. Abra-o no bloco de notas e substitua o que tem dentro por isso: <?xml version="1.0"?> <npc name="King Tibianus" script="data/npc/scripts/removelife.lua" access="5" lookdir="1"> <health now="1000" max="1000"/> <look type="130" head="21" body="87" legs="106" feet="115" addons="0"/> </npc> E salve-o. Agora, parta para data/npc/scripts, copie um arquivo.lua qualquer e renomeie-o para removelife.lua. Após isso, abra-o, apague o que tem dentro e coloque isso: -- Walking -- max_x = 1 -- change the max x here. Means the NPC wont walk more to east or west as the number which is set here. max_y = 1 --change the max y here. Means the NPC wont walk more to north or south as the number which is set here. current_x = 0 --do nothing change here current_y = 0 --do nothing change here max_x = max_x - 1 --do nothing change here max_y = max_y - 1 --do nothing change here -- End Walking-- --NPC By Tio Gordo local focus = 0 local talk_start = 0 local target = 0 local following = false local attacking = false function onThingMove(creature, thing, oldpos, oldstackpos) end function onCreatureAppear(creature) end function onCreatureDisappear(cid, pos) if focus == cid then selfSay('Good bye then.') focus = 0 talk_start = 0 end end function onCreatureTurn(creature) end function msgcontains(txt, str) return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)')) end function onCreatureSay(cid, type, msg) msg = string.lower(msg) if (msgcontains(msg, 'hail') and (focus == 0)) and getDistanceToCreature(cid) < 4 then selfSay('I greet thee, my loyal subject ' .. creatureGetName(cid) .. '!') focus = cid talk_start = os.clock() elseif msgcontains(msg, 'hail') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.') elseif focus == cid then talk_start = os.clock() if msgcontains(msg, 'fuck') then hp = getPlayerHealth (cid) - 1 doPlayerAddHealth(cid,-hp) selfSay('Take this!') elseif msgcontains(msg, 'job') then selfSay('I am your sovereign, King Tibianus III, and it\'s my duty to provide justice and guidance for my subjects.') elseif msgcontains(msg, 'king') then selfSay('I am the king, so mind your words!') elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then selfSay('Good bye, ' .. creatureGetName(cid) .. '!') focus = 0 talk_start = 0 end end end function onCreatureChangeOutfit(creature) end function onThink() -- Walking -- if focus == 0 and max_x >= 0 and max_y >= 0 then cx, cy, cz = selfGetPosition() randmove = math.random(1,20) if randmove == 4 and current_x <= max_x then nx = cx + 1 current_x = current_x + 1 elseif randmove == 8 and current_x >= (max_x - (max_x * 2)) then nx = cx - 1 current_x = current_x - 1 elseif randmove == 12 and current_y <= max_y then ny = cy + 1 current_y = current_y + 1 elseif randmove == 16 and current_y >= (max_y - (max_y * 2)) then ny = cy - 1 current_y = current_y - 1 elseif randmove <= 20 then nx = cx ny = cy end moveToPosition(nx, ny, cz) end -- End Walking -- if (os.clock() - talk_start) > 30 then if focus > 0 then selfSay('Next Please...') end focus = 0 end if focus ~= 0 then if getDistanceToCreature(focus) > 5 then selfSay('Good bye then.') focus = 0 end end end Explicando: if msgcontains(msg, 'fuck')then - Significa que é ativado quando o player fala aquela mensagem (sublinhado). hp = getPlayerHealth (cid) - 1 - Pega a informação da vida do player, é a vida do player - 1. doPlayerAddHealth(cid,-hp) - Adiciona um valor negativo (Retira) o valor da vida - 1 (hp). OBS: Este código pode também ser utilizado em actions, para por exemplo criar itens que, ao movê-los, te deixem com 1 de HP. hp = getPlayerHealth (cid) - 1doPlayerAddHealth(cid,-hp) ~ Editado Dezembro 28, 2008 por Myself Link para o comentário https://xtibia.com/forum/topic/103542-npc-deixando-com-1-de-life/ Compartilhar em outros sites More sharing options...
Phgsoares 0 Postado Dezembro 28, 2008 Share Postado Dezembro 28, 2008 É meio inútil, mas fica mais parecido com Carlin hehe... Só preciso testá-lo! Link para o comentário https://xtibia.com/forum/topic/103542-npc-deixando-com-1-de-life/#findComment-664356 Compartilhar em outros sites More sharing options...
Marcelo321 0 Postado Dezembro 28, 2008 Share Postado Dezembro 28, 2008 Amigo NAo Funciono ;/ Link para o comentário https://xtibia.com/forum/topic/103542-npc-deixando-com-1-de-life/#findComment-664420 Compartilhar em outros sites More sharing options...
Myself 0 Postado Dezembro 28, 2008 Autor Share Postado Dezembro 28, 2008 (editado) Amigo NAo Funciono ;/ Acabei de testar aqui, e funcionou perfeitamente! O erro era no arquivo .XML, mas pouca coisa, dava pra ver no olho, hehe. Agora eu já arrumei, de qualquer jeito. EDIT: Adicionei algumas falas ao NPC, pra não ficar só com o "fuck". E agora ele está com a função de andar, pois ele ficava parado. Editado Dezembro 28, 2008 por Myself Link para o comentário https://xtibia.com/forum/topic/103542-npc-deixando-com-1-de-life/#findComment-664489 Compartilhar em outros sites More sharing options...
xXxhalloweenxXx 0 Postado Dezembro 28, 2008 Share Postado Dezembro 28, 2008 Funfa em 8.4? Link para o comentário https://xtibia.com/forum/topic/103542-npc-deixando-com-1-de-life/#findComment-664507 Compartilhar em outros sites More sharing options...
thaleees 2 Postado Dezembro 28, 2008 Share Postado Dezembro 28, 2008 foi bem feito. Mas também acho sem utilidade =\ Link para o comentário https://xtibia.com/forum/topic/103542-npc-deixando-com-1-de-life/#findComment-664513 Compartilhar em outros sites More sharing options...
6662597 1 Postado Janeiro 12, 2009 Share Postado Janeiro 12, 2009 Bom kra criativo.. Interesçante.. vo por aki dpois flo o que eu acho! Link para o comentário https://xtibia.com/forum/topic/103542-npc-deixando-com-1-de-life/#findComment-673970 Compartilhar em outros sites More sharing options...
Ththt 2 Postado Janeiro 12, 2009 Share Postado Janeiro 12, 2009 Nao vejo muita utilidade pra ele, mas eh bem lealzinho ateh x) Vou testar qdo der Link para o comentário https://xtibia.com/forum/topic/103542-npc-deixando-com-1-de-life/#findComment-673976 Compartilhar em outros sites More sharing options...
Posts Recomendados