[Npc] Healer

bastiago
em Scripts

bastiago

xtibia.com is the best ~*
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 20/02/09Posts: 13Char no Tibia: Sir Tiaguin

Boa noite xtibianos!



Estou com um problema em meu NPC Healer que quando fala hi não abre o chat do NPC, assim a pessoa tem que abrir, so que quando vai andando ele fala Bye e abre o chat.

 

Segue o Script:

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and not npcHandler:isFocused(cid) then
	if getCreatureHealth(cid) < 65 then
		npcHandler:say("Hello, "..getCreatureName(cid).."! You are looking really bad. Let me heal your wounds.", cid)
		doCreatureAddHealth(cid, 65 - getCreatureHealth(cid))
		doSendMagicEffect(getCreaturePosition(cid), 12)
	else
		selfSay("Hello, "..getCreatureName(cid).."! I'll {heal} you if you are badly injured or poisoned. Feel free to ask me for {help} or general {hints}.", cid, TRUE)
		npcHandler:addFocus(cid)
	end
	return true
end
if(not npcHandler:isFocused(cid)) then
	return false
elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
	selfSay("Farewell, " .. getCreatureName(cid) .. "!", cid, TRUE)
	npcHandler:releaseFocus(cid)
elseif msgcontains(msg, "heal") then
	if getCreatureCondition(cid, CONDITION_FIRE) == TRUE then
		npcHandler:say("You are burning. I will help you.", cid)
		doRemoveCondition(cid, CONDITION_FIRE)
		doSendMagicEffect(getCreaturePosition(cid), 14)
	elseif getCreatureCondition(cid, CONDITION_POISON) == TRUE then
		npcHandler:say("You are poisoned. I will help you.", cid)
		doRemoveCondition(cid, CONDITION_POISON)
		doSendMagicEffect(getCreaturePosition(cid), 13)
	elseif getCreatureHealth(cid) < 65 then
		npcHandler:say("You are looking really bad. Let me heal your wounds.", cid)
		doCreatureAddHealth(cid, 65 - getCreatureHealth(cid))
		doSendMagicEffect(getCreaturePosition(cid), 12)
	else
		npcHandler:say("You aren't looking really bad, " .. getCreatureName(cid) .. ". I only help in cases of real emergencies. Raise your health simply by eating {food}.", cid)
	end
end
return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_WALKAWAY, "Well, bye then.")

Te ajudei ?

 

dá um REP+

 

 

World of Killer Server - acesse agora mesmo!

SkyDangerous

Deus Kalec
avatar
Lorde
Lorde

INFOS

Grupo: LordeRegistrado: 17/01/09Posts: 2098Char no Tibia: Adra Sata

Olá ADM Dark

 

Claro , que quando fala hi ele não abre o chat , porque automaticamente você falar hi ele irá verificar sua vida , se ela estiver baixo então ele heala

Igual no npc do global , e só falar hi e pronto.

Me segui lá (:

 

b906.png

http://ageofwar.servegame.com/

IP: ageofwar.servegame.com

TIBIA: 10.78

GLOBAL PERFECT CUSTOM

bastiago

xtibia.com is the best ~*
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 20/02/09Posts: 13Char no Tibia: Sir Tiaguin

Okay, teria como abrir o chat após a verificação ?

Te ajudei ?

 

dá um REP+

 

 

World of Killer Server - acesse agora mesmo!

Ilidian

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 25/01/06Posts: 51

Seguinte, pelo que eu vi aqui, se o cara estiver com menos de 65 de HP o npc simplesmente irá curalo e não vai abrir chat algum... Se o cara estiver com + de 65 de HP o npc responde: "Hello, "..getCreatureName(cid).."! I'll {heal} you if you are badly injured or poisoned. Feel free to ask me for {help} or general {hints}." ????????????

 

Se for isso, só substituir o arquivo por esse aqui que o npc vai abrir o chat não importa a vida do cara.

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 creatureSayCallback(cid, type, msg)

   local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

       if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and not npcHandler:isFocused(cid) then
               if getCreatureHealth(cid) < 65 then
                       npcHandler:say("Hello, "..getCreatureName(cid).."! You are looking really bad. Let me heal your wounds.", cid)
                       doCreatureAddHealth(cid, 65 - getCreatureHealth(cid))
                       doSendMagicEffect(getCreaturePosition(cid), 12)
					npcHandler:addFocus(cid)
               else
                       selfSay("Hello, "..getCreatureName(cid).."! I'll {heal} you if you are badly injured or poisoned. Feel free to ask me for {help} or general {hints}.", cid, TRUE)
                       npcHandler:addFocus(cid)
               end
               return true
       end
       if(not npcHandler:isFocused(cid)) then
               return false
       elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
               selfSay("Farewell, " .. getCreatureName(cid) .. "!", cid, TRUE)
               npcHandler:releaseFocus(cid)
       elseif msgcontains(msg, "heal") then
               if getCreatureCondition(cid, CONDITION_FIRE) == TRUE then
                       npcHandler:say("You are burning. I will help you.", cid)
                       doRemoveCondition(cid, CONDITION_FIRE)
                       doSendMagicEffect(getCreaturePosition(cid), 14)
               elseif getCreatureCondition(cid, CONDITION_POISON) == TRUE then
                       npcHandler:say("You are poisoned. I will help you.", cid)
                       doRemoveCondition(cid, CONDITION_POISON)
                       doSendMagicEffect(getCreaturePosition(cid), 13)
               elseif getCreatureHealth(cid) < 65 then
                       npcHandler:say("You are looking really bad. Let me heal your wounds.", cid)
                       doCreatureAddHealth(cid, 65 - getCreatureHealth(cid))
                       doSendMagicEffect(getCreaturePosition(cid), 12)
               else
                       npcHandler:say("You aren't looking really bad, " .. getCreatureName(cid) .. ". I only help in cases of real emergencies. Raise your health simply by eating {food}.", cid)
               end
       end
       return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_WALKAWAY, "Well, bye then.")

 

Se não funcionar, posta denovo que dai eu testo no meu servidor antes de postar aqui...




Quando o ultimo peixe for pescado, o ultimo animal for caçado e a ultima arvore cair
o homem aprendera que dinheiro não se come.

bastiago

xtibia.com is the best ~*
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 20/02/09Posts: 13Char no Tibia: Sir Tiaguin

Ilidian, coloquei como você me passo mas continua a mesma coisa ;x

Te ajudei ?

 

dá um REP+

 

 

World of Killer Server - acesse agora mesmo!

Ilidian

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 25/01/06Posts: 51

Testei esse aqui em casa e deu certo, da uma olhada:

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 creatureSayCallback(cid, type, msg)
   local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

       if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and not npcHandler:isFocused(cid) then
               if getCreatureHealth(cid) < 65 then
                       npcHandler:say("Hello, "..getCreatureName(cid).."! You are looking really bad. Let me heal your wounds.", cid)
                       doCreatureAddHealth(cid, 65 - getCreatureHealth(cid))
                       doSendMagicEffect(getCreaturePosition(cid), 12)
                                               npcHandler:addFocus(cid)
               else
                       selfSay("Hello, "..getCreatureName(cid).."! I'll {heal} you if you are badly injured or poisoned. Feel free to ask me for {help} or general {hints}.", cid)
                       npcHandler:addFocus(cid)
               end
       end
	if(not npcHandler:isFocused(cid)) then
           return false
	end
       if msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
               selfSay("Farewell, " .. getCreatureName(cid) .. "!", cid)
               npcHandler:releaseFocus(cid)

       elseif msgcontains(msg, 'heal') then
               if getCreatureCondition(cid, CONDITION_FIRE) == TRUE then
                       npcHandler:say("You are burning. I will help you.", cid)
                       doRemoveCondition(cid, CONDITION_FIRE)
                       doSendMagicEffect(getCreaturePosition(cid), 14)
               elseif getCreatureCondition(cid, CONDITION_POISON) == TRUE then
                       npcHandler:say("You are poisoned. I will help you.", cid)
                       doRemoveCondition(cid, CONDITION_POISON)
                       doSendMagicEffect(getCreaturePosition(cid), 13)
               elseif getCreatureHealth(cid) < 65 then
                       npcHandler:say("You are looking really bad. Let me heal your wounds.", cid)
                       doCreatureAddHealth(cid, 65 - getCreatureHealth(cid))
                       doSendMagicEffect(getCreaturePosition(cid), 12)
               else
                       npcHandler:say("You aren't looking really bad, " .. getCreatureName(cid) .. ". I only help in cases of real emergencies. Raise your health simply by eating {food}.", cid)
               end
       end
       return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_WALKAWAY, "Well, bye then.")




Quando o ultimo peixe for pescado, o ultimo animal for caçado e a ultima arvore cair
o homem aprendera que dinheiro não se come.

bastiago

xtibia.com is the best ~*
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 20/02/09Posts: 13Char no Tibia: Sir Tiaguin

Obrigado Ilidian, deu certo.

REP +

 

Te ajudei ?

 

dá um REP+

 

 

World of Killer Server - acesse agora mesmo!

Secular

XTibia is back!
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 08/12/10Posts: 960Char no Tibia: Wayhell Soul

Dúvida Sanada,

 

tópico reportado para que movam.

 

Abraços.

Atenciosamente,
Gabriel Rodrigues.


oQ2udMR.png

 

 

Old but gold:

ADS 58: 3º Lugar
ADS 61: 3º Lugar
ADS 65: 2º Lugar
ADS 70: 1º Lugar
ADS 71: 3º Lugar

 
Membro: [08/12/2010]
Colaboração: [02/06/2011] 
Moderação: [11/09/2011]
Colaboração: [10/09/2013]