Ir para conteúdo

[duvida]npc~que Adiciona Classe~8.4


leandrosantucci2

Posts Recomendados

Como fasso um npc que

Adicione uma classe em um character por exemplo

Player: Hi

Npc: Hello |PLAYERNAME|. Você deseja virar sorcerer?

Player: Sim

Npc: Tem Certeza?

Player: Sim

Mensagem em verde: Parabéns você acaba de virar sorcerer!

 

Ajuda eu se puderem :D

vlw! :)

Link para o comentário
Compartilhar em outros sites

Vai ai um exemplo do script Oracle.lua:

 

local LEVEL = 8

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



-- OTServ event handling functions start
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
-- OTServ event handling functions end


function oracle(cid, message, keywords, parameters, node)
if(cid ~= npcHandler.focus) then
	return false
end

local cityNode = node:getParent():getParent()
local vocNode = node:getParent()

local destination = cityNode:getParameters().destination
local townid = cityNode:getParameters().townid
local voc = vocNode:getParameters().voc

if(destination ~= nil and voc ~= nil and townid ~= nil) then
	if(getPlayerLevel(cid) < parameters.level) then
		npcHandler:say('You must first reach level ' .. parameters.level .. '!')
	else
		if voc == 1 then
												 doPlayerAddItem(cid,2190,1)
												 doPlayerSendTextMessage(cid,22,"You are now a Sorcerer. May your new wand give you might!")
												 end
												 if voc == 2 then
												 doPlayerAddItem(cid,2182,1)
												 doPlayerSendTextMessage(cid,22,"You are now a Druid. May your new rod give you intellect!")
												 end
												 if voc == 3 then
												 doPlayerAddItem(cid,2456,1)
												 doPlayerAddItem(cid,2544,50)
												 doPlayerSendTextMessage(cid,22,"You are now a Paladin. May your new Bow and Arrows protect you in dangerous cases!")
												 end
												 if voc == 4 then
												 doPlayerAddItem(cid,2428,1)
												 doPlayerAddItem(cid,2531,1)
												 doPlayerSendTextMessage(cid,22,"You are now a Knight. May your new shield and axe give you strength!")
												 end
												 doPlayerSetVocation(cid,voc)
		doPlayerSetTown(cid,townid)
										   doTeleportThing(cid,destination)
										   doSendMagicEffect(destination,12)

	end
else
	error('Destination:', destination, 'Vocation:', vocation, 'Townid:', townid)
end
npcHandler:resetNpc()
return true
end


function greetCallback(cid)
if(getPlayerLevel(cid) < LEVEL) then
	npcHandler:say('CHILD! COME BACK WHEN YOU HAVE GROWN UP!')
	return false
else
	return true
end
end

-- Set the greeting callback function
npcHandler:setCallback(CALLBACK_GREET, greetCallback)

-- Set the greeting message.
npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|. Are you prepared to face your destiny?')

-- Pre-create the yes/no nodes.
local yesNode = KeywordNode:new({'yes'}, oracle, {level = LEVEL})
local noNode = KeywordNode:new({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Then what vocation do you want to become?'})

-- Create the actual keyword structure...
local node1 = keywordHandler:addKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'What city do you wish to live in? Carlin, Thais or Venore?'})
local node2 = node1:addChildKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, townid = 2, destination = {x=32360, y=31782, z=7}, text = 'Carlin will be your home-town! So what vocation do you wish to become? Sorcerer, druid, paladin or knight?'})
	local node3 = node2:addChildKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, voc = 1, onlyFocus = true, text = 'So, you wish to be a powerful magician? Are you sure about that? This decision is irreversible!'})
		node3:addChildKeywordNode(yesNode)
		node3:addChildKeywordNode(noNode)
	local node3 = node2:addChildKeyword({'druid'}, StdModule.say, {npcHandler = npcHandler, voc = 2, onlyFocus = true, text = 'A druid! Are you sure? This decision is irreversible!'})
		node3:addChildKeywordNode(yesNode)
		node3:addChildKeywordNode(noNode)
	local node3 = node2:addChildKeyword({'paladin'}, StdModule.say, {npcHandler = npcHandler, voc = 3, onlyFocus = true, text = 'A nimble paladin! Are you sure? This decision is irreversible!'})
		node3:addChildKeywordNode(yesNode)
		node3:addChildKeywordNode(noNode)
	local node3 = node2:addChildKeyword({'knight'}, StdModule.say, {npcHandler = npcHandler, voc = 4, onlyFocus = true, text = 'A valorous knight! Are you sure? This decision is irreversible!'})
		node3:addChildKeywordNode(yesNode)
		node3:addChildKeywordNode(noNode)

	local node2 = node1:addChildKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, townid = 5, destination = {x=32369, y=32241, z=7}, text = 'Thais will be your home-town! So what vocation do you wish to become? Sorcerer, druid, paladin or knight?'})
	local node3 = node2:addChildKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, voc = 1, onlyFocus = true, text = 'So, you wish to be a powerful magician? Are you sure about that? This decision is irreversible!'})
		node3:addChildKeywordNode(yesNode)
		node3:addChildKeywordNode(noNode)
	local node3 = node2:addChildKeyword({'druid'}, StdModule.say, {npcHandler = npcHandler, voc = 2, onlyFocus = true, text = 'A mighty druid! Are you sure? This decision is irreversible!'})
		node3:addChildKeywordNode(yesNode)
		node3:addChildKeywordNode(noNode)
	local node3 = node2:addChildKeyword({'paladin'}, StdModule.say, {npcHandler = npcHandler, voc = 3, onlyFocus = true, text = 'A nimble paladin! Are you sure? This decision is irreversible!'})
		node3:addChildKeywordNode(yesNode)
		node3:addChildKeywordNode(noNode)
	local node3 = node2:addChildKeyword({'knight'}, StdModule.say, {npcHandler = npcHandler, voc = 4, onlyFocus = true, text = 'A valorous knight! Are you sure? This decision is irreversible!'})
		node3:addChildKeywordNode(yesNode)
		node3:addChildKeywordNode(noNode)

local node2 = node1:addChildKeyword({'venore'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, townid = 6, destination = {x=32957, y=32076, z=7}, text = 'Venore will be your home-town! So what vocation do you wish to become? Sorcerer, druid, paladin or knight?'})
	local node3 = node2:addChildKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, voc = 1, onlyFocus = true, text = 'So, you wish to be a powerful magician? Are you sure about that? This decision is irreversible!'})
		node3:addChildKeywordNode(yesNode)
		node3:addChildKeywordNode(noNode)
	local node3 = node2:addChildKeyword({'druid'}, StdModule.say, {npcHandler = npcHandler, voc = 2, onlyFocus = true, text = 'A mighty druid! Are you sure? This decision is irreversible!'})
		node3:addChildKeywordNode(yesNode)
		node3:addChildKeywordNode(noNode)
	local node3 = node2:addChildKeyword({'paladin'}, StdModule.say, {npcHandler = npcHandler, voc = 3, onlyFocus = true, text = 'A nimble paladin! Are you sure? This decision is irreversible!'})
		node3:addChildKeywordNode(yesNode)
		node3:addChildKeywordNode(noNode)
	local node3 = node2:addChildKeyword({'knight'}, StdModule.say, {npcHandler = npcHandler, voc = 4, onlyFocus = true, text = 'A valorous knight! Are you sure? This decision is irreversible!'})
		node3:addChildKeywordNode(yesNode)
		node3:addChildKeywordNode(noNode)

keywordHandler:addKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Then come back when you are ready.'})

-- Make it react to hi/bye etc.
npcHandler:addModule(FocusModule:new())

 

Eu sabia os comandos nas versões anteriores:

 

getPlayerVocation(cid) -- Retorna a vocação.

doPlayerSetVocation(cid,voc) -- Coloka uma vocação em determinado player (doPlayerSetVocation("Lucasjockey",4))

 

Mas o sistema mudou muito do 8.11 para agora...

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...