local focus = 0
local talk_start = 0
local conv = 0
local target = 0
local following = false
local attacking = false
local talkState = {}
local finalname = ""
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay("Até logo Senhor!", cid, TALKTYPE_MONSTER)
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, msge)
local msg = string.lower(msge)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if focus == cid then
talk_start = os.clock()
end
local auras = {"red aura", "blue aura", "green aura", "yellow aura", "white aura", "gray aura", "cyan aura", "purple aura", "orange aura"}
if (msgcontains(msg, 'hi') and (focus == 0) and (getDistanceToCreature(cid) <= 4)) then
focus = cid
conv = 1
talk_start = os.clock()
selfSay("Olá, "..getCreatureName(cid).."! Eu posso trocar o nickname do seu Pokémon se ele tiver boost +5 ou colocar uma elemental aura no seu pokémon, se ele tiver boost +50...", cid, TALKTYPE_MONSTER)
elseif (msgcontains(msg, "no") or msgcontains(msg, "bye")) and focus == cid and conv ~= 3 then
selfSay("Não há problema então, senhor. Volte quando sentir vontade!", cid, TALKTYPE_MONSTER)
focus = 0
elseif (msgcontains(msg, "nick") or msgcontains(msg, "nickname")) and focus == cid and conv == 1 then
if getPlayerSlotItem(cid, 8).uid <= 0 then
selfSay("Desculpe, seu pokémon precisa estar no slot!", cid, TALKTYPE_MONSTER)
focus = 0
return true
end
selfSay("Coloque seu pokemon no slot principal e diga-me, que apelido você gostaria que eu desse ao seu pokemon?", cid, TALKTYPE_MONSTER)
conv = 3
elseif msgcontains(msg, "aura") and focus == cid and conv == 1 then
if getPlayerSlotItem(cid, 8).uid <= 0 then
selfSay("Desculpe, você não tem um pokemon no slot principal!", cid, TALKTYPE_MONSTER)
focus = 0
return true
end
local pb = getPlayerSlotItem(cid, 8).uid
if not getItemAttribute(pb, "boost") or getItemAttribute(pb, "boost") < 50 then
selfSay("Desculpe, seu pokemon não é +50!", cid, TALKTYPE_MONSTER)
focus = 0
return true
end
if getItemAttribute(pb, "aura") and getItemAttribute(pb, "aura") then
selfSay("Desculpe, seu pokemon já tem uma elemental aura!", cid, TALKTYPE_MONSTER)
focus = 0
return true
end
if #getCreatureSummons(cid) >= 1 then
selfSay("Volte seu pokémon para pokebola!", cid, TALKTYPE_MONSTER)
focus = 0
return true
end
selfSay("Você pode escolher uma dessas auras: red aura, blue aura, green aura, yellow aura, white aura, gray aura, cyan aura, purple aura, orange aura. Qual você prefere?", cid, TALKTYPE_MONSTER)
conv = 9
elseif isInArray(auras, msg) and focus == cid and conv == 9 then
selfSay("Você tem certeza que quer colocar "..msg.." no seu pokemon?", cid, TALKTYPE_MONSTER)
conv = 11
local d, e = msg:find('(.-) aura')
auraFinal = string.sub(msg, d -1, e - 5)
elseif msgcontains(msg, "yes") and focus == cid and conv == 11 then
if getPlayerSlotItem(cid, 8).uid <= 0 then
selfSay("Desculpe, você não tem um pokemon no slot principal!", cid, TALKTYPE_MONSTER)
focus = 0
return true
end
local pb = getPlayerSlotItem(cid, 8).uid
if not getItemAttribute(pb, "boost") or getItemAttribute(pb, "boost") < 50 then
selfSay("Desculpe, seu pokemon não é +50!", cid, TALKTYPE_MONSTER)
focus = 0
return true
end
if #getCreatureSummons(cid) >= 1 then
selfSay("Volte seu pokémon para pokebola!", cid, TALKTYPE_MONSTER)
focus = 0
return true
end
doItemSetAttribute(pb, "aura", auraFinal)
selfSay("Pronto! Agora seu pokémon está com elemental aura. Aproveite!", cid, TALKTYPE_MONSTER)
focus = 0
conv = 0
elseif conv == 3 and focus == cid then
local tablee = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "x", "w", "y", "z"}
local table = {"'", '"', "!", "ã", "õ", "ç", "´", "`", "á", "à", "ó", "ò", "é", "è", "í", "ì", "ú", "ù", "¹", "²", "³", "£", "¢", "¬", "§", "°", "º", "ª", "•", "|"}
for a = 1, #table do
if string.find(msg, table[a]) then
selfSay("Desculpe, o nick tem símbolos inválidos.", cid, TALKTYPE_MONSTER)
return true
end
end
if string.len(msg) <= 1 or string.len(msg) >= 15 then
selfSay("Desculpe, esse nick é muito longo ou muito curto!", cid, TALKTYPE_MONSTER)
return true
end
local pokename = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "poke")
selfSay("Tem a certeza que quer mudar o apelido do seu "..pokename.." nome para \""..msge.."\"?", cid, TALKTYPE_MONSTER)
conv = 5
finalname = msge
elseif msgcontains(msg, "yes") and focus == cid and conv == 5 then
if getPlayerSlotItem(cid, 8).uid <= 0 then
selfSay("Onde está seu pokemon ?! Você tem que mantê-lo no slot principal!", cid, TALKTYPE_MONSTER)
focus = 0
return true
end
--[[if doPlayerRemoveMoney(cid, 100000) == false then
selfSay("You don't have enough money to afford this service, come back later.")
focus = 0
conv = 0
return true
end]]--
local pb = getPlayerSlotItem(cid, 8).uid
if not getItemAttribute(pb, "boost") or getItemAttribute(pb, "boost") < 5 then
selfSay("Desculpe, seu pokemon não é +5!", cid, TALKTYPE_MONSTER)
focus = 0
return true
end
local nick = ""..finalname..""
local description = "Contém "..getItemAttribute(getPlayerSlotItem(cid, 8).uid, "poke").."."
selfSay("Feito! Seu pokemon agora tem um novo nome, aproveite!", cid, TALKTYPE_MONSTER)
doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "nick", nick)
doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "description", str)
local hp = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "hp")
doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "hp", hp + 25)
if #getCreatureSummons(cid) >= 1 then
adjustStatus(getCreatureSummons(cid)[1], getPlayerSlotItem(cid, 8).uid)
end
focus = 0
conv = 0
end
end
local intervalmin = 38
local intervalmax = 70
local delay = 25
local number = 1
local messages = {"Quer dar alguns apelidos para o seu pokemon? Fale comigo!",
"Você sabia que seu pokemon fica um pouco mais feliz quando você lhe dá um apelido?",
"Todo pokemon quer ter um apelido! Venha falar comigo!",
"Pokemons amam apelidos, você deve dar um ao seu.",
}
function onThink()
if focus == 0 then
selfTurn(0)
delay = delay - 0.5
if delay <= 0 then
selfSay(messages[number])
number = number + 1
if number > #messages then
number = 1
end
delay = math.random(intervalmin, intervalmax)
end
return true
else
if not isCreature(focus) then
focus = 0
return true
end
local npcpos = getThingPos(getThis())
local focpos = getThingPos(focus)
if npcpos.z ~= focpos.z then
focus = 0
return true
end
if (os.clock() - talk_start) > 45 then
focus = 0
selfSay("Volte outra hora!", cid, TALKTYPE_MONSTER)
end
if getDistanceToCreature(focus) > 2 then
selfSay("Aproveite!", cid, TALKTYPE_MONSTER)
focus = 0
return true
end
local dir = doDirectPos(npcpos, focpos)
selfTurn(dir)
end
return true
end
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Alison" script="nick.lua" walkinterval="350000" floorchange="0" speed="0" lookdir="2">
<health now="150" max="150"/>
<look type="510" head="10" body="15" legs="20" feet="25"/>
<parameters>
</parameters>
</npc>