Eai galera, como vão?
Um pedido que eu atendi hoje no fórum, era um NPC igualzinho ao "meu", então vou postar pra vocês.
Nome: Brock
Função: Batalha
Primeiramente, os créditos son para Nacho Rico.
Espanhois ownando
Battle.lua
local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function getUidsInContainer(containeruid) -- By MatheusMkalo
local dat = {}
for i = 0, (getContainerSize(containeruid)-1) do
local item = getContainerItem(containeruid, i)
if isContainer(item.uid) then
local items = getUidsInContainer(item.uid)
for i = 0, #items do
table.insert(dat, items)
end
else
table.insert(dat, item.uid)
end
end
return dat
end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if getPlayerStorageValue(cid, 64999) == 1 then
selfSay('Eu vou vencê-lo mais tarde, {!exit}.', cid)
npcHandler:ResetNpc()
end
if msgcontains(msg:lower(), "duel") then
selfSay('Olá, eu sou o Líder do Ginásio de Pewter, meu nome é Brock e eu uso Pokémons do tipo Pedra, você quer batalhar comigo?', cid)
talk_state = 1
elseif msgcontains(msg:lower(), "yes") and talk_state == 1 then
if getPlayerStorageValue(cid,987876) ~= 1 then
if getPlayerStorageValue(cid,574225) ~= 1 then
selfSay('Go, Golem', cid)
doCreateMonster("Golem", getCreaturePosition(getNpcId()))
doSendMagicEffect(getCreaturePosition(getNpcId()) , 10)
setPlayerStorageValue(cid, 574225, 1)
else
selfSay('...', cid)
end
else
if getPlayerStorageValue(cid, 987877) ~= 1 and getPlayerStorageValue(cid,574225) == 1 then
if getPlayerStorageValue(cid,574226) ~= 1 then
selfSay('Go, Onix', cid)
doCreateMonster("Onix", getCreaturePosition(getNpcId()))
doSendMagicEffect(getCreaturePosition(getNpcId()) , 10)
talk_state = 2
setPlayerStorageValue(cid, 574226, 1)
else
selfSay('...', cid)
end
else
if getPlayerStorageValue(cid, 63768) ~= 1 and getPlayerStorageValue(cid,574226) == 1 and getPlayerStorageValue(cid,987877) == 1 then
selfSay('Parabéns, você me venceu com seu carisma e estilo. Aqui está sua recompensa...', cid)
doTransformItem(getUidsInContainer(getPlayerSlotItem(cid, CONST_SLOT_AMMO).uid)[7], 2555)
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, "Você ganhou do Líder de Ginásio de Pewter (Brock), você ganhou a Boulder Badge!")
setPlayerStorageValue(cid, 63768, 1)
else
selfSay('Você conseguiu... me venceu.', cid)
end
end
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Vermelho - Pokémons que o Brock irá sumonar.
Brock.xml
<?xml version="1.0" encoding="UTF-8"?><npc name="Brock" script="brock.lua" walkinterval="0" floorchange="0">
<health now="100" max="100"/>
<look type="178" head="17" body="54" legs="114" feet="0" addons="0"/>
</npc>
Vermelho - Nome do NPC
É só isso mesmo povo, espero que tenha ajudado em alguma coisa.
Abraços.
#Edit
Só está funcionando o primeiro pokémon, até semana que vem eu atualizo.