[Npc] Nurse Joy

MaGoDaNeT
em NPCs, monsters e raids

MaGoDaNeT

---------------
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 04/10/10Posts: 45

Funciona em 8.54 ou maior

 

 

Ola nesse npc foi usado o script go/back do MatheusMkalo.

 

O npc esta quase identico ao do PO é só fala hi e pronto heala vc e todos os seus pokemons...

E as falas tbm estão iguais.

 

E como podem ver eu fis com a poke ball e ultra ball.

 

 

Bom vamos ao script

 

Va na pasta data/npc copie qualquer npc e renomeie para Nurse Joy

feito isso abra o arquivo XML qui vc pois o nome de Nurse Joy apague tudo de dentro e ponha isso.

 

<?xml version="1.0" encoding="UTF-8"?> 
<npc name="Nurse Joy" script="Nurse Joy.lua" walkinterval="0" speed="0" floorchange="0"> 
   <health now="100" max="100"/> 
   <look type="318" head="0" body="0" legs="0" feet="0" addons="0"/> 
   <parameters> 
   </parameters> 
</npc>

 

Agora salve e fexe

 

Depois disso abra a pasta Scripts copie qualque arquivo LUA e renomeie para Nurse Joy agora abra ele apague tudo e ponha isso

 

local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos, item, itemEx)

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, 'hi')) and getDistanceToCreature(cid) < 4 then
if getPlayerStorageValue(cid, 59987) == 1 then       
return selfSay('You Are riding.')
end
if getPlayerStorageValue(cid, 62314) == 1 then
return selfSay('You are flying.')
end
if #getCreatureSummons(cid) >= 1 then
selfSay('Please back your Pokemon to the pokeball...')
focus = 0
talk_start = 0
return TRUE
end

if not getTilePzInfo(getCreaturePosition(cid)) then 
return selfSay('Please enter in the Pokemon Center...')

end

-- Poke Ball

for slo = CONST_SLOT_FIRST, CONST_SLOT_LAST do 
local item = getPlayerSlotItem(cid, slo) 
if isContainer(item.uid) then 
local items = getItemsInContainerById(item.uid, pokeout) 
for i,x in pairs(items) do 
local maxh = tonumber(getItemAttribute(x, "poke"):match("/(.+)]")) 
doItemSetAttribute(x, "poke", getItemAttribute(x, "poke"):sub(1, findLetter(getItemAttribute(x, "poke"), ".")) .. " HP = ["..maxh.."/"..maxh.."]") 
doTransformItem(x, pokein) 

end 

local items2 = getItemsInContainerById(item.uid, pokein) 
for i,x in pairs(items2) do 
local maxh = tonumber(getItemAttribute(x, "poke"):match("/(.+)]")) 
doItemSetAttribute(x, "poke", getItemAttribute(x, "poke"):sub(1, findLetter(getItemAttribute(x, "poke"), ".")) .. " HP = ["..maxh.."/"..maxh.."]") 

end 

if item.itemid == pokeout or item.itemid == pokein then 
local maxh = tonumber(getItemAttribute(item.uid, "poke"):match("/(.+)]")) 
doItemSetAttribute(item.uid, "poke", getItemAttribute(item.uid, "poke"):sub(1, findLetter(getItemAttribute(item.uid, "poke"), ".")) .. " HP = ["..maxh.."/"..maxh.."]") 
doTransformItem(item.uid, pokein)

end
end

local items = getItemsInContainerById(item.uid, pokeout) 
for i,x in pairs(items) do 
local maxh = tonumber(getItemAttribute(x, "poke"):match("/(.+)]")) 
doItemSetAttribute(x, "poke", getItemAttribute(x, "poke"):sub(1, findLetter(getItemAttribute(x, "poke"), ".")) .. " HP = ["..maxh.."/"..maxh.."]") 
doTransformItem(x, pokein) 

end 

local items2 = getItemsInContainerById(item.uid, pokein) 
for i,x in pairs(items2) do 
local maxh = tonumber(getItemAttribute(x, "poke"):match("/(.+)]")) 
doItemSetAttribute(x, "poke", getItemAttribute(x, "poke"):sub(1, findLetter(getItemAttribute(x, "poke"), ".")) .. " HP = ["..maxh.."/"..maxh.."]") 

end 

if item.itemid == pokeout or item.itemid == pokein then 
local maxh = tonumber(getItemAttribute(item.uid, "poke"):match("/(.+)]")) 
doItemSetAttribute(item.uid, "poke", getItemAttribute(item.uid, "poke"):sub(1, findLetter(getItemAttribute(item.uid, "poke"), ".")) .. " HP = ["..maxh.."/"..maxh.."]") 
doTransformItem(item.uid, pokein)

end

-- Ultra Ball

local items = getItemsInContainerById(item.uid, pokeoutultra) 
for i,x in pairs(items) do 
local maxh = tonumber(getItemAttribute(x, "poke"):match("/(.+)]")) 
doItemSetAttribute(x, "poke", getItemAttribute(x, "poke"):sub(1, findLetter(getItemAttribute(x, "poke"), ".")) .. " HP = ["..maxh.."/"..maxh.."]") 
doTransformItem(x, pokeinultra) 

end 

local items2 = getItemsInContainerById(item.uid, pokeinultra) 
for i,x in pairs(items2) do 
local maxh = tonumber(getItemAttribute(x, "poke"):match("/(.+)]")) 
doItemSetAttribute(x, "poke", getItemAttribute(x, "poke"):sub(1, findLetter(getItemAttribute(x, "poke"), ".")) .. " HP = ["..maxh.."/"..maxh.."]") 

end 

if item.itemid == pokeoutultra or item.itemid == pokeinultra then 
local maxh = tonumber(getItemAttribute(item.uid, "poke"):match("/(.+)]")) 
doItemSetAttribute(item.uid, "poke", getItemAttribute(item.uid, "poke"):sub(1, findLetter(getItemAttribute(item.uid, "poke"), ".")) .. " HP = ["..maxh.."/"..maxh.."]") 
doTransformItem(item.uid, pokeinultra)

end
end

selfSay("Hello! We've restored your Pokemon to full health. We hope to see you again!")
local hp = getCreatureMaxHealth(cid)
doCreatureAddHealth(cid, hp)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)

focus = 0
talk_start = 0
end
end

function onCreatureChangeOutfit(creature)

end

 

Salve e fexe

 

 

Agora As Functions

 

va na pasta LIB e crie um arquivo lua chamado PokeLib e coloque isso dentro

 

 

pokein, pokeout = 2646,2457
pokeinultra, pokeoutultra = 2654,2537



function doRemoveTile(pos)-- Script by mock 
   pos.stackpos = 0 
   local sqm = getTileThingByPos(pos) 
   doRemoveItem(sqm.uid,1) 
end 


function doCreateTile(id,pos) -- By mock 
   doAreaCombatHealth(0,0,pos,0,0,0,CONST_ME_NONE) 
   doCreateItem(id,1,pos) 
end 

function getPosDirs(p, dir) -- By MatheusMkalo 
   return dir == 1 and {x=p.x-1, y=p.y, z=p.z} or dir == 2 and {x=p.x-1, y=p.y+1, z=p.z} or dir == 3 and {x=p.x, y=p.y+1, z=p.z} or dir == 4 and {x=p.x+1, y=p.y+1, z=p.z} or dir == 5 and {x=p.x+1, y=p.y, z=p.z} or dir == 6 and {x=p.x+1, y=p.y-1, z=p.z} or dir == 7 and {x=p.x, y=p.y-1, z=p.z} or dir == 8 and {x=p.x-1, y=p.y-1, z=p.z} 
end 

function doItem(pos,a,d)-- Script by mock 
       doCreateTile(460,pos) 
       pos.stackpos = 0 
       local c = getTileThingByPos(pos) 
       doItemSetAttribute(c.uid, "aid", a) 
end 

function getDescription(uid) 
   for i,x in pairs(getItemDescriptions(uid)) do 
       if i == "special" then 
           return x 
       end 
   end 
end 

function findLetter(string, letter) 
   for i = 1, #string do 
       if string:sub(i, i) == letter then 
           return i 
       end 
   end 
end 

function isWalkable(pos, creature, proj, pz)-- by Nord 
   if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end 
   if getTopCreature(pos).uid > 0 and creature then return false end 
   if getTileInfo(pos).protection and pz then return false, true end 
   local n = not proj and 3 or 2 
   for i = 0, 255 do 
       pos.stackpos = i 
       local tile = getTileThingByPos(pos) 
       if tile.itemid ~= 0 and not isCreature(tile.uid) then 
           if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then 
               return false 
           end 
       end 
   end 
   return true 
end 

function getPosDirs(p, dir) 
   return dir == 1 and {x=p.x-1, y=p.y, z=p.z} or dir == 2 and {x=p.x-1, y=p.y+1, z=p.z} or dir == 3 and {x=p.x, y=p.y+1, z=p.z} or dir == 4 and {x=p.x+1, y=p.y+1, z=p.z} or dir == 5 and {x=p.x+1, y=p.y, z=p.z} or dir == 6 and {x=p.x+1, y=p.y-1, z=p.z} or dir == 7 and {x=p.x, y=p.y-1, z=p.z} or dir == 8 and {x=p.x-1, y=p.y-1, z=p.z} 
end 

function canSummon(cid) 
   local pos = getCreaturePosition(cid) 
   local state = false 
   for i = 1, 8 do 
       if isWalkable(getPosDirs(getCreaturePosition(cid), i)) then 
           state = true 
       end 
   end 
return state 
end 

function isPlayerSummon(cid, uid) 
   if getCreatureMaster(uid) == cid then 
       return TRUE 
   end 
return FALSE 
end 

function getSummonLifes(cid) 
   for _,x in pairs(getCreatureSummons(cid)) do 
       return getCreatureHealth(x), getCreatureMaxHealth(x) 
   end 
end 

function getItemsInContainerById(container, itemid) -- Function By Kydrai 
   local items = {} 
   if isContainer(container) and getContainerSize(container) > 0 then 
       for slot=0, (getContainerSize(container)-1) do 
           local item = getContainerItem(container, slot) 
           if isContainer(item.uid) then 
               local itemsbag = getItemsInContainerById(item.uid, itemid) 
               for i=0, #itemsbag do 
                   table.insert(items, itemsbag[i]) 
               end 
           else 
               if itemid == item.itemid then 
                   table.insert(items, item.uid) 
               end 
           end 
       end 
   end 
   return items 
end 

function addPokeball(cid, pokename, maxh) 
   local s = doPlayerAddItem(cid, pokein)
   local s = doPlayerAddItem(cid, pokeinultra)
   doItemSetAttribute(s, "poke", "This is "..pokename.."'s pokeball. HP = ["..maxh.."/"..maxh.."]") 
   doItemSetAttribute(s, "name", "" .. pokename .. " Poke Ball") 
end 

function getPokeOutLive(cid) 
   dat = {} 
   for slot = CONST_SLOT_FIRST, CONST_SLOT_LAST do 
       local item = getPlayerSlotItem(cid, slot) 
       if isContainer(item.uid) then 
           local items = getItemsInContainerById(item.uid, pokeout)

           local items = getItemsInContainerById(item.uid, pokeoutultra)
           for _, ui in pairs(items) do 
               if getItemAttribute(ui, "poke"):sub(#getItemAttribute(ui, "poke")) == "." then 
                   table.insert(dat, ui) 
               end   
           end 
      end 

      if item.itemid == pokeout then
           if getItemAttribute(item.uid, "poke"):sub(#getItemAttribute(item.uid, "poke")) == "." then 
           table.insert(dat, item.uid)

      end
      end

      if item.itemid == pokeoutultra then
           if getItemAttribute(item.uid, "poke"):sub(#getItemAttribute(item.uid, "poke")) == "." then 
           table.insert(dat, item.uid)    
      end
      end
      end
   return dat 
end

Trabalhos:

[Npc] Nurse Joy

 

7122493.png

AlphaLove

Força de vontade :)
avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 12/06/10Posts: 408Char no Tibia: Nakamura

Muito boom :D

É oque a Galera tava pedindo,

pq na maioria dos servers o NPC healava um poke de cada vez ;D

Agora vai fica bom (:

Vllw

Att


Fan Bar:

nakamurafans.gif

"A guerra inflige morte, ferimentos e dor para ambos os lados.
A morte de alguém querido é difícil de se aceitar.
Nos convencemos de que não há como eles morrerem.
É apenas natural, particularmente, da nossa geração...
Nós não conhecemos a guerra.
Tentam encontrar significado na morte, mas há apenas dor.
Um ódio insuportável... Mortes sem sentido... Ódio eterno... E a dor que não cura.
É isso que a guerra é."


.

MaGoDaNeT

---------------
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 04/10/10Posts: 45

Sim até agora esse foi o segundo npc qui eu fis

 

e eu estou sem ideia doque postar se alguem tive alguma ideia qui eu conssiga fazer fale

Trabalhos:

[Npc] Nurse Joy

 

7122493.png

FD CODE

Nostalgic
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 17/08/09Posts: 57Gênero: Masculino

hum testei aki com os scripts do matheus n funfo direito so healo o player n healo o summon...

mais ta daora em...achei legal fiko bem parecido mesmo pra heala tem q ta em pz bom mesmo...

 

mais nao sei se e so aki mais n healo o summon (pokemon)

 

 

---edited----------

 

Arrumei e q os scripts q eu testei as pokeball sao pokeout pokein

 

ai voce boto assim:

 

if item.itemid == pokeout or item.itemid == pokeina then

 

ai so tive q muda pokeina pra pokein se isso foi um erro seu ja arruma xd

MaGoDaNeT

---------------
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 04/10/10Posts: 45

Ja arrumei

Trabalhos:

[Npc] Nurse Joy

 

7122493.png

MaXwEllDeN

string.reverse("adiV a arohaD")
avatar
Barão
Barão

INFOS

Grupo: BarãoRegistrado: 18/10/10Posts: 246Char no Tibia: Elite Pamcadaum

Vallew Manolo, very thanks, tava dando pau aki o script quando eu tava tentando modificar, askoak, mais agora tudo oks

REP++

eq9qh0.png

papamix

Hnns..
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 24/09/10Posts: 30

Rep+ ficou mt bom.

gohansign.png

Msn: dewes-ruy@hotmail.com

junior2b

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 15/06/10Posts: 46Gênero: MasculinoChar no Tibia: Lancellott~*

Mano, faz o NPC de battle ;D

flws, (obricado por compartilhar aqui no ékstibia ;D)

LaisDosOts

asfassda
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 23/09/10Posts: 84Gênero: Feminino

Era isso que todo mundo tava querendo.



Já havia tentado fazer isso mas não consegui =/

Gratz ^^

LaísNãoéMaisDosOts

juanbrando

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 28/06/09Posts: 60

Opa Valeu AI ELA PEGOU CERTIM!!!vc pode fazer um npc lider de gym que luta com os players?

valeuu

REP+

greenpro.jpg

 

 

Sou Fan Desse leke:

fanq.gif

Royalek

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 30/11/10Posts: 8

uma dúvida, essa nurse funciona com o server do thalia ? grato.



MaGoDaNeT

---------------
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 04/10/10Posts: 45

-SuperTnT

 

o npc lider de gym eu ja estou fazendo mais ainda estou em duvida se vou postar quando estiver pronto.

 

 

-RoyalFlash

 

Esse npc nurse joy funciona sim com o server da thalia

 

só qui teria qui editar o catch e o go/back...

Trabalhos:

[Npc] Nurse Joy

 

7122493.png

Royalek

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 30/11/10Posts: 8

-SuperTnT

 

o npc lider de gym eu ja estou fazendo mais ainda estou em duvida se vou postar quando estiver pronto.

 

 

-RoyalFlash

 

esse npc nurse joy funciona sim com o server da thalia é só trocar essas coisa pokein e pokeout pelo id das poke balls

 

por exemplo pokein é o id da pokeball normal ai quando vc da use ela vira a pokeout qui é a poke ball em uso ou com o pokemon morto

 

 

Então ok , ganhou meu rep+ pela ajuda :smile_positivo:

 

~~~edit

 

Bem, Configurei tudo certinho, do jeito que vc falou, mais na hora de falar hi para o npc, olha o que acontece :

 

[09/12/2010 13:25:59] [Error - Npc interface]

[09/12/2010 13:25:59] data/npc/scripts/Nurse Joy.lua:onCreatureSay

[09/12/2010 13:25:59] Description:

[09/12/2010 13:25:59] data/npc/scripts/Nurse Joy.lua:78: attempt to call global 'getItemsInContainerById' (a nil value)

[09/12/2010 13:25:59] stack traceback:

[09/12/2010 13:25:59] data/npc/scripts/Nurse Joy.lua:78: in function <data/npc/scripts/Nurse Joy.lua:34>

 

o que faço para arrumar isso ? :sosad:



MaGoDaNeT

---------------
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 04/10/10Posts: 45

vc precisa ter as funçoes qui o MatheusMkalo postou junto com os scripts dele

Trabalhos:

[Npc] Nurse Joy

 

7122493.png

OverCross

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 29/10/10Posts: 23Char no Tibia: OverCross

Man testei o da Thalia aki nao pegou eu healo mais os poke fica morto ainda .

Ajudei? Rep + =D