ond
Veteran OT User
Where to call functions?
Here is my script:
Here is my script:
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 addBlessOne()
local voc = getPlayerVocation(cid)
if voc == 5 or voc == 6 or voc == 7 or voc == 8 then
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 6)
doPlayerSetLossPercent(cid, PLAYERLOSS_MANA, 6)
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILL, 6)
else
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 9)
doPlayerSetLossPercent(cid, PLAYERLOSS_MANA, 9)
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILL, 9)
end
end
function addBlessTwo()
local voc = getPlayerVocation(cid)
if voc == 5 or voc == 6 or voc == 7 or voc == 8 then
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 5)
doPlayerSetLossPercent(cid, PLAYERLOSS_MANA, 5)
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILL, 5)
else
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 8)
doPlayerSetLossPercent(cid, PLAYERLOSS_MANA, 8)
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILL, 8)
end
end
function addBlessThree()
local voc = getPlayerVocation(cid)
if voc == 5 or voc == 6 or voc == 7 or voc == 8 then
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 4)
doPlayerSetLossPercent(cid, PLAYERLOSS_MANA, 4)
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILL, 4)
else
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 7)
doPlayerSetLossPercent(cid, PLAYERLOSS_MANA, 7)
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILL, 7)
end
end
function addBlessFour()
local voc = getPlayerVocation(cid)
if voc == 5 or voc == 6 or voc == 7 or voc == 8 then
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 3)
doPlayerSetLossPercent(cid, PLAYERLOSS_MANA, 3)
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILL, 3)
else
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 6)
doPlayerSetLossPercent(cid, PLAYERLOSS_MANA, 6)
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILL, 6)
end
end
function addBlessFive()
local voc = getPlayerVocation(cid)
if voc == 5 or voc == 6 or voc == 7 or voc == 8 then
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 2)
doPlayerSetLossPercent(cid, PLAYERLOSS_MANA, 2)
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILL, 2)
else
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 5)
doPlayerSetLossPercent(cid, PLAYERLOSS_MANA, 5)
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILL, 5)
end
end
npcHandler:addModule(FocusModule:new())
local node1 = keywordHandler:addKeyword({'first bless'}, addBlessOne, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first blessing for 10000 gold?'})
node1:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 1, premium = true, cost = 10000})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node2 = keywordHandler:addKeyword({'second bless'}, addBlessTwo.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the second blessing for 10000 gold?'})
node2:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 2, premium = true, cost = 10000})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node3 = keywordHandler:addKeyword({'third bless'}, addBlessThree, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the third blessing for 10000 gold?'})
node3:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 3, premium = true, cost = 10000})
node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node4 = keywordHandler:addKeyword({'fourth bless'}, addBlessFour, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fourth blessing for 10000 gold?'})
node4:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 4, premium = true, cost = 10000})
node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node5 = keywordHandler:addKeyword({'fifth bless'}, addBlessFive, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fifth blessing for 10000 gold?'})
node5:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 5, premium = true, cost = 10000})
node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})