Hi, i want to create npc with repeatable mission. Plaese someone for help
I will pay 20$ for working script.
A. hi
B. hello! I have a mission for you, I need talons for my wife, could you bring me 50 talons? I saw few near Dragon Lords. Are you interested?
A. yes
B. Okay, so bring me 50 talons and ill give you 100 Tibia Coins.
- after looting 50 talons, talking again to NPC
A. hi
B. do you already have all the talons?
A. Yes
Then remove from player 50 Talons
Then add player 100 Tibia Coins
I will pay 20$ for working script.
A. hi
B. hello! I have a mission for you, I need talons for my wife, could you bring me 50 talons? I saw few near Dragon Lords. Are you interested?
A. yes
B. Okay, so bring me 50 talons and ill give you 100 Tibia Coins.
- after looting 50 talons, talking again to NPC
A. hi
B. do you already have all the talons?
A. Yes
Then remove from player 50 Talons
Then add player 100 Tibia Coins
Code:
local internalNpcName = "Missionary of Hellheim"
local npcType = Game.createNpcType(internalNpcName)
local npcConfig = {}
npcConfig.name = internalNpcName
npcConfig.description = internalNpcName
npcConfig.health = 100
npcConfig.maxHealth = npcConfig.health
npcConfig.walkInterval = 2000
npcConfig.walkRadius = 2
npcConfig.outfit = {
lookType = 129,
lookHead = 115,
lookBody = 39,
lookLegs = 96,
lookFeet = 118,
lookAddons = 3
}
npcConfig.flags = {
floorchange = false
}
npcConfig.voices = {
interval = 15000,
chance = 50,
{text = 'Hey, you! Help me collect loot from monsters'}
}
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
npcType.onThink = function(npc, interval)
npcHandler:onThink(npc, interval)
end
npcType.onAppear = function(npc, creature)
npcHandler:onAppear(npc, creature)
end
npcType.onDisappear = function(npc, creature)
npcHandler:onDisappear(npc, creature)
end
npcType.onMove = function(npc, creature, fromPosition, toPosition)
npcHandler:onMove(npc, creature, fromPosition, toPosition)
end
npcType.onSay = function(npc, creature, type, message)
npcHandler:onSay(npc, creature, type, message)
end
npcType.onCloseChannel = function(npc, creature)
npcHandler:onCloseChannel(npc, creature)
end
local function creatureSayCallback(npc, creature, type, message)
local player = Player(creature)
local playerId = player:getId()
if not npcHandler:checkInteraction(npc, creature) then
return false
end
end
-- Mission
if MsgContains(message, 'mission') or MsgContains(message, 'quest') then
npcHandler:say('I have a mission for you, I need talons for my wife, could you bring me 50 {talons}? I have heard its drops from Dragon Lords often', npc, creature)
end
if MsgContains(message, 'talons') or MsgContains(message, 'talons') or MsgContains(message, 'talony') then
npcHandler:say('Are you interested?', npc, creature)
npcHandler:setTopic(playerId, 2)
end
elseif npcHandler:getTopic(playerId) == 2 then
if MsgContains(message, 'yes') then
npcHandler:say('Alright then, if you bring me 50 pieces of Talons You probably have to kill really many dangerous monsters... so good luck! I will give you 10 Crystal Coins and 20 Dusts!', npc, creature)
npcHandler:removeInteraction(npc, creature)
else
npcHandler:say('Yeah..my talons...', npc, creature)
end
npcHandler:setTopic(playerId, 0)
elseif npcHandler:getTopic(playerId) == 3 then
if MsgContains(message, 'mission') then
if player:getItemCount(3034) < 50 then
npcHandler:say('Sorry, but that\'s not enough talons yet to give you special items. Would you rather like to buy a normal backpack for 10 gold?', npc, creature)
else
npcHandler:say('Great! Here is your reward!', npc, creature)
player:removeItem(3034, 50)
player:addItem(3043, 10)
player:addForgeDusts(20)
end
else
npcHandler:say('I know, it\'s quite some work... don\'t lose heart, just keep killing monsters and you\'ll eventually get lucky. Would you rather like to buy a normal backpack for 10 gold?', npc, creature)
end
npcHandler:setTopic(playerId, 0)
end
end
keywordHandler:addKeyword({'pet'}, StdModule.say, {npcHandler = npcHandler, text = 'There are some strange stories about a magicians pet names. Ask Hoggle about it.'})
npcHandler:setMessage(MESSAGE_GREET, 'Welcome, please help me with mission, |PLAYERNAME|! Ask me for {mission} and ill give you one!')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye, |PLAYERNAME|.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye.')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true)
-- On check npc shop message (look item)
npcType.onCheckItem = function(npc, player, clientId, subType)
end
npcType:register(npcConfig)
Last edited: