• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

NPC: Oracle Custom Version

GhostX

Mapping Board Moderator
Staff member
Board Moderator
Joined
Nov 2, 2011
Messages
6,051
Reaction score
1,816
Location
UK
Twitch
ghostxpr0
Requesting my own Oracle: needed:


Name: Angel Of Life. Doesn't move (obviously)
LookType: angel statue
Health: 150?

Message:

XML:
Player: Hello
Angel: *checks if level 5+* 
Hello *playername*, are you interested in learning a vocation or are you here about the quest of life?

*if lower than level 5* 
Angel: Come back when you are experienced enough my child!

Player: Vocation
Angel: There are 4! Warrior, Sorcerer, Ranger and Monk, which do you choose?
[B]vocation id is, sorc=1, monk=2, ranger=3, warrior=4.[/B]

XML:
Player: Warrior
Angel: Ah! The vocation of the warrior! They are very strong and skilled melee warriors, reknowned across the land as fierce combatants, however they have limited and weak spells. Are you sure you wish to join their ranks?
Player: Yes
Angel: It is done, my child, congratulations! You are now among the greatest of warriors! Come back when you become familiar with your vocation to begin your quest of life!
End

Player: No
Angel: Ah! What vocation would you like to be then?

Player: Sorcerer
Angel: Ah! The followers of magic! These individuals boast great power in spells and magic combat! However, they lack ability in melee and close range combat! Are you sure you would like to join their ranks?
Player: Yes
Angel: It is done, my child, congratulations! You are now among the greatest of mages! Come back when you become familiar with your vocation to begin your quest of life!
end

player: No
Angel: Ah! What vocation would you like to be then?

player: Monk
Angel: Ah! The peaceful Monks! These peaceful individuals boast great healing and spirituality powers yet lack in strong combat abilities of both magic and melee, however they do possess a great power for support, are you sure you wish to join their ranks?
player: yes
Angel: It is done, my child, congratulations! You are now among the greatest of the spiritually gifted! Come back when you become familiar with your vocation to begin your quest of life!
end

Player: No
Angel: Ah! What vocation would you like to be then?

Player: Ranger
Angel: Ah! The great Rangers! They are strong in long range combat whilst still boasting a decent defence in close ranged combat! They also possess a variety of attack and support spells, yet they aren't regarded as tough combatants in close range, they like to fight from a distance and strike from the shadows! Are you sure you wish to join their ranks?
player: Yes
Angel: It is done, my child, congratulations! You are now among the greatest of rangers! Come back when you become familiar with your vocation to being your quest of life.
end

player: No
Angel: Ah! What vocation would you like to be then?

Once a vocation is picked, i wish certain equipment to be given to the player, just put in the standard items i can configure after, since i am respriting and wont know until i finished.
I also obviously want once the vocation is final, that this conversation doesn't happen and instead this:

XML:
*if lower than level 12 & has vocation*
Player: Hello
Angel: Hello young *vocation*, you are not quite ready to start the quest of life, come back once you reach level 12!
end

*If 12+ with vocation*
Player: Hello
Angel: Hello young *vocation*, you seem to have familiarised yourself with your chosen vocation! Are you ready to begin your quest of life?

Player: Yes
Angel: Note, that once you begin, there is no coming back, are you sure this is what you wish!
Player: Yes
Angel: Very well! *teleports player to location x: y: z: (just leave blank for now) and puts 'quest of life' into quest log*
end
Player: No
Angel: Very Well! I shall wait until you return!
end
Player: No
Angel: Ah! Come back when you are ready!
end

Player: Bye
Angel: Farewell Child!

Player walks away not saying bye
Angel: Farewell then!?

Player leaves it too long
Angel: Farewell Child!

Player already focused
Angel: I am here child, what do you want?

Need anything else then just ask :)

I think it is tfs 0.2

I WILL be extremely greatful if some nice otland scripter makes me a working version of this! I will love you forever! ;3 Heck i'll even post a statue on my server to be forever more remembered :P
 
Last edited:
in npc folder make Angeloflife.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Angel OF Life" script="angeloflife.lua" walkinterval="0" floorchange="0">
	<health now="100" max="100"/>
	<look typeex="1448" corpse="3128"/>
</npc>

in scripts folder make angeloflife.lua
LUA:
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 oracle(cid, message, keywords, parameters, node)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

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

	local destination = cityNode:getParameters().destination
	local town = cityNode:getParameters().town
	local vocation = vocNode:getParameters().vocation

	if(destination ~= nil and vocation ~= nil and town ~= nil) then
		if(getPlayerLevel(cid) < parameters.level) then
			npcHandler:say('You must first reach level ' .. parameters.level .. '!', cid)
			npcHandler:resetNpc()
		else
			if(getPlayerVocation(cid) > 0) then
				npcHandler:say('Sorry, You already have a vocation!')
				npcHandler:resetNpc()
			else
				doPlayerSetVocation(cid, vocation)
				doPlayerSetTown(cid, town)
				npcHandler:resetNpc()

				local tmp = getCreaturePosition(cid)
				doTeleportThing(cid, destination)
				doSendMagicEffect(tmp, CONST_ME_POFF)
				doSendMagicEffect(destination, CONST_ME_TELEPORT)
			end
		end
	end

	return true
end

function greetCallback(cid)
	if(getPlayerLevel(cid) < 5) then
		npcHandler:say('Come back when you are experienced enough my child!')
		return false
	else
		return true
	end
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|. are you interested in learning a vocation or are you here about the quest of life?')

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

local node1 = keywordHandler:addKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Hello young *vocation*, you seem to have familiarised yourself with your chosen vocation! Are you ready to begin your quest of life?'})
	local node2 = node1:addChildKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, town = 1, destination = {x=1002, y=903, z=7}, text = 'So what vocation do you wish to become? {Wizard}, {Magician}, {Ranger} or {Fighter}?'})
		local node3 = node2:addChildKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, vocation = 1, onlyFocus = true, text = 'Ah! The followers of magic! These individuals boast great power in spells and magic combat! However, they lack ability in melee and close range combat! Are you sure you would like to join their ranks?'})
			node3:addChildKeywordNode(yesNode)
			node3:addChildKeywordNode(noNode)
		node3 = node2:addChildKeyword({'monk'}, StdModule.say, {npcHandler = npcHandler, vocation = 2, onlyFocus = true, text = 'Ah! The peaceful Monks! These peaceful individuals boast great healing and spirituality powers yet lack in strong combat abilities of both magic and melee, however they do possess a great power for support, are you sure you wish to join their ranks?'})
			node3:addChildKeywordNode(yesNode)
			node3:addChildKeywordNode(noNode)
		node3 = node2:addChildKeyword({'ranger'}, StdModule.say, {npcHandler = npcHandler, vocation = 3, onlyFocus = true, text = 'Ah! The great Rangers! They are strong in long range combat whilst still boasting a decent defence in close ranged combat! They also possess a variety of attack and support spells, yet they aren\'t  regarded as tough combatants in close range, they like to fight from a distance and strike from the shadows! Are you sure you wish to join their ranks?'})
			node3:addChildKeywordNode(yesNode)
			node3:addChildKeywordNode(noNode)
		node3 = node2:addChildKeyword({'warrior'}, StdModule.say, {npcHandler = npcHandler, vocation = 4, onlyFocus = true, text = 'Ah! The vocation of the warrior! They are very strong and skilled melee warriors, reknowned across the land as fierce combatants, however they have limited and weak spells. Are you sure you wish to join their ranks?!'})
			node3:addChildKeywordNode(yesNode)
			node3:addChildKeywordNode(noNode)
	keywordHandler:addKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ah! What vocation would you like to be then?.'})

npcHandler:addModule(FocusModule:new())

Change
destination = {x=1002, y=903, z=7},
to ur x y z
 
Last edited:
Problem:

XML:
Lua Script Error: [Npc interface]
data/npc/scripts/angel.lua:onCreatureSay
data/npc/lib/npcsystem/npchandler.lua:596: table index is nil
stack traceback:
        [C]: in function '__newindex'
        data/npc/lib/npcsystem/npchandler.lua:596: in function 'say'
        data/npc/scripts/angel.lua:48: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:338: in function 'greet'
        data/npc/lib/npcsystem/npchandler.lua:492: in function 'onGreet'
        data/npc/lib/npcsystem/modules.lua:216: in function 'callback'
        data/npc/lib/npcsystem/keywordhandler.lua:27: in function 'processMessage'
        data/npc/lib/npcsystem/keywordhandler.lua:135: in function 'processNodeMes
        data/npc/lib/npcsystem/keywordhandler.lua:103: in function 'processMessage
        data/npc/lib/npcsystem/npchandler.lua:387: in function 'onCreatureSay'
        data/npc/scripts/angel.lua:7: in function <data/npc/scripts/angel.lua:7>
 
Last edited:
in 2016 work in tfs 0.4 rev 8...


PHP:
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 oracle(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
return false
end

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

local destination = cityNode:getParameters().destination
local town = cityNode:getParameters().town
local vocation = vocNode:getParameters().vocation

if(destination ~= nil and vocation ~= nil and town ~= nil) then
if(getPlayerLevel(cid) < parameters.level) then
npcHandler:say('You must first reach level ' .. parameters.level .. '!', cid)
npcHandler:resetNpc()
else
if(getPlayerVocation(cid) > 0) then
npcHandler:say('Sorry, You already have a vocation!')
npcHandler:resetNpc()
else
doPlayerSetVocation(cid, vocation)
doPlayerSetTown(cid, town)
npcHandler:resetNpc()

local tmp = getCreaturePosition(cid)
doTeleportThing(cid, destination)
doSendMagicEffect(tmp, CONST_ME_POFF)
doSendMagicEffect(destination, CONST_ME_TELEPORT)
end
end
end

return true
end

function greetCallback(cid)
if(getPlayerLevel(cid) < 5) then
npcHandler:say('Come back when you are experienced enough my child!')
return false
else
return true
end
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|. are you interested in learning a vocation or are you here about the quest of life?')

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

local node1 = keywordHandler:addKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Hello young *vocation*, you seem to have familiarised yourself with your chosen vocation! Are you ready to begin your quest of life?'})
local node2 = node1:addChildKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, town = 1, destination = {x=4134, y=2931, z=6}, text = 'So what vocation do you wish to become? {sorcerer}, {paladin}, {druid}, {mechanic} or {knight}?'})
local node3 = node2:addChildKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, vocation = 1, onlyFocus = true, text = 'Ah! The followers of magic! These individuals boast great power in spells and magic combat! However, they lack ability in melee and close range combat! Are you sure you would like to join their ranks?'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword({'druid'}, StdModule.say, {npcHandler = npcHandler, vocation = 2, onlyFocus = true, text = 'Ah! The peaceful Monks! These peaceful individuals boast great healing and spirituality powers yet lack in strong combat abilities of both magic and melee, however they do possess a great power for support, are you sure you wish to join their ranks?'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword({'paladin'}, StdModule.say, {npcHandler = npcHandler, vocation = 3, onlyFocus = true, text = 'Ah! The great Rangers! They are strong in long range combat whilst still boasting a decent defence in close ranged combat! They also possess a variety of attack and support spells, yet they aren\'t regarded as tough combatants in close range, they like to fight from a distance and strike from the shadows! Are you sure you wish to join their ranks?'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword({'knight'}, StdModule.say, {npcHandler = npcHandler, vocation = 4, onlyFocus = true, text = 'Ah! The vocation of the warrior! They are very strong and skilled melee warriors, reknowned across the land as fierce combatants, however they have limited and weak spells. Are you sure you wish to join their ranks?!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword({'mechanic'}, StdModule.say, {npcHandler = npcHandler, vocation = 9, onlyFocus = true, text = 'Ah! The vocation of the warrior! They are very strong and skilled melee warriors, reknowned across the land as fierce combatants, however they have limited and weak spells. Are you sure you wish to join their ranks?!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
keywordHandler:addKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ah! What vocation would you like to be then?.'})

npcHandler:addModule(FocusModule:new())
 
Back
Top