zbizu
Legendary OT User
Credits for random lines goes to PhoOwned: http://otland.net/f83/walker-walks-ignore-players-spam-configured-msges-128186/
and StreamSide: http://otland.net/f83/npc-random-words-problem-182682/#post1771974
first, in libs add to modules.lua:
alice.xml:
alice.lua:
Tested on 0.3.7 for 9.6
Marks are accurate only on my custom evo datapack(check my signature) due to map offset and changes in town buildings.
Known bugs: allbless module doesn't handle blessings price and doesn't check if player has already any blessing, I'm too lazy to write it.
and StreamSide: http://otland.net/f83/npc-random-words-problem-182682/#post1771974
first, in libs add to modules.lua:
Lua:
function StdModule.allbless(cid, message, keywords, parameters, node)
local npcHandler = parameters.npcHandler
if(npcHandler == nil) then
print('[Warning - ' .. getCreatureName(getNpcId()) .. '] NpcSystem:', 'StdModule.bless - Call without any npcHandler instance.')
return false
end
if(not getBooleanFromString(getConfigValue('blessings'))) then
npcHandler:say("Sorry, but Gods moved back my permission to bless anyone.", cid)
return false
end
if(not npcHandler:isFocused(cid)) then
return false
end
if(isPremium(cid) or not getBooleanFromString(getConfigValue('blessingsOnlyPremium')) or not parameters.premium) then
local price = 150000
if(parameters.number == 1) then
if(not doPlayerRemoveMoney(cid, price)) then
npcHandler:say("You don't have enough money for blessing.", cid)
else
npcHandler:say("All blessings were given to you! Go and fulfil your destiny.", cid)
doPlayerAddBlessing(cid, 1)
doPlayerAddBlessing(cid, 2)
doPlayerAddBlessing(cid, 3)
doPlayerAddBlessing(cid, 4)
doPlayerAddBlessing(cid, 5)
doPlayerSetPVPBlessing(cid)
end
end
else
npcHandler:say('You need a premium account in order to be blessed.', cid)
end
npcHandler:resetNpc(cid)
return true
end
alice.xml:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Alice" script="alice.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="138" head="58" body="114" legs="87" addons="3"/>
<parameters>
<!-- <parameter key="message_greet" value="Be greeted. If you need {something} just ask me."/> -->
<parameter key="message_farewell" value="See you soon!"/>
<parameter key="message_walkaway" value="Bye." />
<parameter key="module_keywords" value="1" />
<parameter key="keywords" value="bless;help;temple;priest;job;something;food;guide;blessings;enigma" />
<parameter key="keyword_reply1" value="I can grant you blessings such as {Wisdom of Solitude}, {Spark of The Phoenix}, our {Fire of Two Suns}, {Spiritual Shielding}, {Embrace of Tibia} and {Twist of Fate}. I can also grant you {all} of these blessings, just ask me." />
<parameter key="keyword_reply2" value="I can give you {blessings}, {heal} you if you are wounded and help you finding yourself by {marking} your {map}" />
<parameter key="keyword_reply3" value="I am last {Priestess} left in Enigma City. I wrote my knowledge in books in hope it will be saved. I am also a {guide} of Enigma City." />
<parameter key="keyword_reply4" value="We are here to {guide} people in their lives." />
<parameter key="keyword_reply5" value="We are here to {guide} people in their lives." />
<parameter key="keyword_reply6" value="I can give you {bless}ings and help you finding yourself by {marking} your {map}." />
<parameter key="keyword_reply7" value="You can earn some by hunting animals or buy some in stores near Depot." />
<parameter key="keyword_reply8" value="I can show you way around and set some {marks} on your {map}" />
<parameter key="keyword_reply9" value="I can grant you blessings such as {Wisdom of Solitude}, {Spark of The Phoenix}, our {Fire of Two Suns}, {Spiritual Shielding}, {Embrace of Tibia} and {Twist of Fate}. I can also grant you {all} of these blessings, just ask me." />
<parameter key="keyword_reply10" value="Our home. Great city of great prosperity. Isn't it a magical place?" />
</parameters>
</npc>
alice.lua:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local random_texts = {'Welcome to our humble temple.', 'If you are hurt ask me, I\'ll heal you.', 'Feeling lost? Ask me for help.', 'Praise our God. He has power to revive andventurers whose adventure is not over yet!'}
local random_texts_chance = 40 -- percent
local random_texts_interval = 5 -- seconds
local talkState = {}
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()
if(getCreatureStorage(getNpcId(), 1) < os.time()) then
doCreatureSetStorage(getNpcId(), 1, os.time() + random_texts_interval)
if(math.random(1, 100) < random_texts_chance) then
selfSay(random_texts[math.random(1, #random_texts)])
end
end
npcHandler:onThink()
end
function onPlayerEndTrade(cid) npcHandler:onPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid) npcHandler:onPlayerCloseChannel(cid) end
function greetCallback(cid)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local msg = {
"Be greeted. If you need {something} just ask me.",
"Welcome to our humble temple," .. getPlayerName(cid) .. ".",
"Welcome, " .. getPlayerName(cid) .. "! Welcome to the temple of {Enigma City}. If you need {healing}, I can help you.",
"Hello. How may I help you " .. getPlayerName(cid) .. "?",
"Come in, " .. getPlayerName(cid) .. "."
}
npcHandler:setMessage(MESSAGE_GREET, msg[math.random(1, #msg)])
talkState[talkUser] = 0
return true
end
local node1 = keywordHandler:addKeyword({'wisdom'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want me to grant you Wisdom of Solitude blessing for 25000 gold?'})
node1:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 1, premium = true, baseCost = 25000, levelCost = 0, startLevel = 1, endLevel = 0})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Okay.'})
local node2 = keywordHandler:addKeyword({'spark'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want me to grant you Spark of The Phoenix blessing for 25000 gold?'})
node2:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 2, premium = true, baseCost = 25000, levelCost = 0, startLevel = 1, endLevel = 0})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Okay.'})
local node3 = keywordHandler:addKeyword({'fire'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want me to grant you double sun power of our local Fire of Two Suns blessing for 25000 gold?'})
node3:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 3, premium = true, baseCost = 25000, levelCost = 0, startLevel = 1, endLevel = 0})
node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Okay.'})
local node4 = keywordHandler:addKeyword({'spiritual'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to grant you ancient Spiritual Shielding blessing for 25000 gold?'})
node4:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 4, premium = true, baseCost = 25000, levelCost = 0, startLevel = 1, endLevel = 0})
node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Okay.'})
local node5 = keywordHandler:addKeyword({'embrace'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you wish to receive Embrace of Tibia blessing for 25000 gold?'})
node5:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 5, premium = true, baseCost = 25000, levelCost = 0, startLevel = 1, endLevel = 0})
node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Okay.'})
local node6 = keywordHandler:addKeyword({'twist'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Special one... Twist of Fate, it can reduce loss from unfair fights. Do you wish to receive it for 25000 gold?'})
node6:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 0, premium = true, baseCost = 25000, levelCost = 0, startLevel = 1, endLevel = 0})
node6:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Okay.'})
local node7 = keywordHandler:addKeyword({'all'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to receive all blessings for 150000 gold?'})
node7:addChildKeyword({'yes'}, StdModule.allbless, {npcHandler = npcHandler, number = 1, premium = true, baseCost = 150000, levelCost = 200, startLevel = 1, endLevel = 0})
node7:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Okay.'})
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'map') or msgcontains(msg, 'mark')) then
selfSay('Do you want me to mark your map with important locations in our town?', cid)
talkState[talkUser] = 1
end
if msgcontains(msg, "yes") and talkState[talkUser] == 1 then
local marks = {
{mark = 5, pos = {x = 256, y = 256, z = 7}, desc = "Enigma City Temple"},
{mark = 10, pos = {x = 287, y = 254, z = 7}, desc = "Depot with bank"},
{mark = 13, pos = {x = 303, y = 247, z = 7}, desc = "Food store"},
{mark = 8, pos = {x = 278, y = 236, z = 7}, desc = "Smithery"},
{mark = 8, pos = {x = 271, y = 226, z = 7}, desc = "Distance weapons shop"},
{mark = 13, pos = {x = 268, y = 241, z = 7}, desc = "Jewellery, magic shop and music instruments shop"},
{mark = 13, pos = {x = 303, y = 247, z = 7}, desc = "Food store and magic shop"},
{mark = 7, pos = {x = 252, y = 242, z = 7}, desc = "Tools and furniture"},
{mark = 13, pos = {x = 258, y = 237, z = 7}, desc = "Creature products and fashion"},
{mark = 9, pos = {x = 234, y = 215, z = 7}, desc = "Boat"},
}
local f_addMark = doPlayerAddMapMark
if(not f_addMark) then f_addMark = doAddMapMark end
for _, m in pairs(marks) do
f_addMark(cid, m.pos, m.mark, m.desc ~= nil and m.desc or "")
end
selfSay('Here you are.', cid)
talkState[talkUser] = 0
end
if msgcontains(msg, "no") and talkState[talkUser] == 1 then
selfSay('May God guide your path then.', cid)
talkState[talkUser] = 0
end
if msgcontains(msg, "heal") then
if getCreatureCondition(cid, CONDITION_FIRE) == TRUE then
npcHandler:say("You are burning. I will use water on you.", cid)
doRemoveCondition(cid, CONDITION_FIRE)
doSendMagicEffect(getCreaturePosition(cid), 14)
elseif getCreatureCondition(cid, CONDITION_POISON) == TRUE then
npcHandler:say("You are poisoned. I will cure you.", cid)
doRemoveCondition(cid, CONDITION_POISON)
doSendMagicEffect(getCreaturePosition(cid), 13)
elseif getCreatureCondition(cid, CONDITION_ENERGY) == TRUE then
npcHandler:say("You are electrificed. I will help you.", cid)
doRemoveCondition(cid, CONDITION_ENERGY)
doSendMagicEffect(getCreaturePosition(cid), 12)
elseif getCreatureCondition(cid, CONDITION_PARALYZE) == TRUE then
npcHandler:say("You are paralyzed. I will cure you.", cid)
doRemoveCondition(cid, CONDITION_PARALYZE)
doSendMagicEffect(getCreaturePosition(cid), 14)
elseif getCreatureCondition(cid, CONDITION_DROWN) == TRUE then
npcHandler:say("You are drowing. I will help you.", cid)
doRemoveCondition(cid, CONDITION_DROWN)
doSendMagicEffect(getCreaturePosition(cid), 12)
elseif getCreatureCondition(cid, CONDITION_FREEZING) == TRUE then
npcHandler:say("You are cold! I will burn you.", cid)
doRemoveCondition(cid, CONDITION_FREEZING)
doSendMagicEffect(getCreaturePosition(cid), 15)
elseif getCreatureCondition(cid, CONDITION_DAZZLED) == TRUE then
npcHandler:say("You are dazzled! Do not mess with holy creatures anymore!", cid)
doRemoveCondition(cid, CONDITION_DAZZLED)
doSendMagicEffect(getCreaturePosition(cid), 47)
elseif getCreatureCondition(cid, CONDITION_CURSED) == TRUE then
npcHandler:say("You are cursed! I will remove it.", cid)
doRemoveCondition(cid, CONDITION_CURSED)
doSendMagicEffect(getCreaturePosition(cid), 47)
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)
elseif getCreatureHealth(cid) < 2000 then
npcHandler:say("I did my best to fix your wounds.", cid)
doCreatureAddHealth(cid, 2000 - getCreatureHealth(cid))
doSendMagicEffect(getCreaturePosition(cid), 12)
else
local msgheal = {
"You aren't looking really bad, " .. getCreatureName(cid) .. ". I only help in cases of real emergencies. Raise your health simply by eating {food}.",
"Seriously? It's just a scratch",
"Don't be a child. You don't need any help with your health.",
"I'm not an expert. If you need help find a medic.",
"Don't even waste my time, I have bigger problems than your scratched armor."
}
npcHandler:say("" .. msgheal[math.random(1, #msgheal)] .. "", cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Tested on 0.3.7 for 9.6
Marks are accurate only on my custom evo datapack(check my signature) due to map offset and changes in town buildings.
Known bugs: allbless module doesn't handle blessings price and doesn't check if player has already any blessing, I'm too lazy to write it.