vichoko
Member
I have this script for my blessing NPC:
The thing is that i want to add the last blessing, the Twist of Fate blessing but i don't know how to do it.
Can someone help me with this?
Code:
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
-- local blessings, t = {
-- ['first'] = 1,
-- ['second'] = 2,
-- ['third'] = 3,
-- ['fourth'] = 4,
-- ['fifth'] = 5
-- }, {}
local function creatureSayCallback(cid, type, msg)
local function getBlessingsCost(level)
if level <= 30 then
return 2000
elseif level >= 120 then
return 20000
else
return (level - 20) * 200
end
end
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
if msgcontains(msg, "first") then
npcHandler:say('Would you like to receive my first blessing for a sacrifice of ' .. getBlessingsCost(player:getLevel()) .. ' gold, child?', cid)
npcHandler.topic[cid] = 1
t = 1
elseif msgcontains(msg, "second") then
npcHandler:say('Would you like to receive my second blessing for a sacrifice of ' .. getBlessingsCost(player:getLevel()) .. ' gold, child?', cid)
npcHandler.topic[cid] = 2
t = 2
elseif msgcontains(msg, "third") then
npcHandler:say('Would you like to receive my third blessing for a sacrifice of ' .. getBlessingsCost(player:getLevel()) .. ' gold, child?', cid)
npcHandler.topic[cid] = 3
t = 3
elseif msgcontains(msg, "fourth") then
npcHandler:say('Would you like to receive my fourth blessing for a sacrifice of ' .. getBlessingsCost(player:getLevel()) .. ' gold, child?', cid)
npcHandler.topic[cid] = 4
t = 4
elseif msgcontains(msg, "fifth") then
npcHandler:say('Would you like to receive my fifth blessing for a sacrifice of ' .. getBlessingsCost(player:getLevel()) .. ' gold, child?', cid)
npcHandler.topic[cid] = 5
t = 5
elseif msgcontains(msg, "yes") then
if npcHandler.topic[cid] == t then
if not player:hasBlessing(t) then
if player:removeMoney(getBlessingsCost(player:getLevel())) then
player:addBlessing(t)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
npcHandler:say("So receive the new blessing.", cid)
else
npcHandler:say('Oh, you do not have enough money.', cid)
end
else
npcHandler:say('You already possess this blessing.', cid)
end
end
npcHandler.topic[cid] = 0
t = 0
elseif msgcontains(msg, 'no') and npcHandler.topic[cid] == t then
npcHandler:say('Fine. You are free to decline my offer.', cid)
npcHandler.topic[cid] = 0
t = 0
end
return true
end
keywordHandler:addKeyword({'blessings'}, StdModule.say, {npcHandler = npcHandler, text = 'There are five blessings available in five sacred places: The {first} blessing, the {second} blessing, the {third} blessing, the {fourth} blessing and the {fifth} blessing.'})
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_GREET, 'Welcome to my little garden, adventurer |PLAYERNAME|!')
npcHandler:setMessage(MESSAGE_FAREWELL, 'It was a pleasure to help you, |PLAYERNAME|.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'It was a pleasure to help you, |PLAYERNAME|.')
npcHandler:addModule(FocusModule:new())
The thing is that i want to add the last blessing, the Twist of Fate blessing but i don't know how to do it.
Can someone help me with this?