• 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!

NPC [TFS1.2] A monk who will mark your map and set your home town.

erinsx

Princess of the Internet
Joined
Nov 3, 2015
Messages
7
Reaction score
10
In my temples I have monks, who will mark shops and depots and things on the minimap, and if you ask them they will set your home town to the town you are in.

Here is an example, Monk Brevan, who lives in Jorvik

First, Brevan's XML file, goes in /data/npc/
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Brevan" script="jorvikmark.lua" walkinterval="0" floorchange="0" speechbubble="1">
    <health now="100" max="100"/>
    <look type="206" head="17" body="54" legs="114" feet="0" addons="0" />
    <parameters>
        <parameter key="message_greet" value="Greetings |PLAYERNAME|! I can mark your {map} to help you find you way around! If you want this, just say {map}! I can also make Jorvik your {home} town. If you want this, say {home}."/>
    </parameters>
</npc>

Next, Brevans's LUA, called jorvikmark.lua, goes in /data/npc/scripts/
Code:
local marks = {
    [1]={{x=0496,y=0172,z=7},"Temple",MAPMARK_TEMPLE},
    [2]={{x=0408,y=0203,z=7},"Depot",MAPMARK_LOCK},
    [3]={{x=0478,y=0148,z=7},"Weapons and Armor shops",MAPMARK_SWORD},
    [4]={{x=0464,y=0208,z=7},"Magic shop",MAPMARK_STAR},
    [5]={{x=0476,y=0201,z=7},"Potions shop",MAPMARK_STAR},
    [6]={{x=0390,y=0202,z=7},"Bank",MAPMARK_DOLLAR},
    [7]={{x=0433,y=0235,z=7},"Adventurer Supplies",MAPMARK_BAG},
    [8]={{x=0480,y=0163,z=7},"Mount Seller",MAPMARK_EXCLAMATION},
    [9]={{x=0430,y=0210,z=7},"Loot Buyer",MAPMARK_TICK},
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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()        npcHandler:onThink()        end

function  creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
    return false
end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
     local player = Player(cid)
     if msg == "map" then
      for i = 1, #marks do
       player:addMapMark(marks[i][1],marks[i][3],marks[i][2])
      end
      selfSay('I have marked your map for you, good luck!', cid)
      talkState[talkUser] = 0
      elseif msg == "home" then
      player:setTown(Town(4))
      selfSay('It is done! Goodbye.', cid)
      talkState[talkUser] = 0
     else
    selfSay('Okay, goodbye.', cid)
    talkState[talkUser] = 0
   end
   return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


So obviously to adapt this, you would just change mark coordinates and town IDs and names and things.

And that's it!
 
Should add some yes/no checks to the npc.. instead of simply adding map marks and changing hometown instantly. :p
 
Should add some yes/no checks to the npc.. instead of simply adding map marks and changing hometown instantly. :p
Good idea, the community i originally opened my server for were new to tibia, i added these monks to help them out, maybe a little "are you really sure?" would be good for new players ^^
 
Sorry for reviving this post, but works great on 1.X.
I don't know how to make this simplier:
Code:
player:addMapMark(marks[i][1],marks[i][3],marks[i][2],marks[i][4],marks[i][5],marks[i][6],marks[i][7],marks[i][8],marks[i][9],marks[i][10],marks[i][11],marks[i][12],marks[i][13],marks[i][14],marks[i][15],marks[i][16],marks[i][17],marks[i][18],marks[i][19],marks[i][20]

Let's say I need to add 70 marks, how do I add mark from 1 to 75 at once?
Ex. player:addMapMark(marks[1 to 75]
 
Sorry for reviving this post, but works great on 1.X.
I don't know how to make this simplier:
Code:
player:addMapMark(marks[i][1],marks[i][3],marks[i][2],marks[i][4],marks[i][5],marks[i][6],marks[i][7],marks[i][8],marks[i][9],marks[i][10],marks[i][11],marks[i][12],marks[i][13],marks[i][14],marks[i][15],marks[i][16],marks[i][17],marks[i][18],marks[i][19],marks[i][20]

Let's say I need to add 70 marks, how do I add mark from 1 to 75 at once?
Ex. player:addMapMark(marks[1 to 75]
for key, value in pairs(marks)
player:addMark(value[1], value[3], value[2])
end
 
Check this example I had created for my server
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}
local mapMarks = {
    [{x = 2022, y = 2706, z = 7}] = {MAPMARK_LOCK, 'Depot'},
    [{x = 1992, y = 2711, z = 7}] = {MAPMARK_TEMPLE, 'Temple'},
    [{x = 1990, y = 2711, z = 8}] = {MAPMARK_TEMPLE, 'Bless'},
    [{x = 1972, y = 2699, z = 7}] = {MAPMARK_BAG, 'Food Shop'},

    [{x = 1988, y = 2722, z = 7}] = {MAPMARK_TICK, 'Trainer Mage'},
    [{x = 1972, y = 2704, z = 7}] = {MAPMARK_TICK, 'Trainer Knight'},
    [{x = 1973, y = 2729, z = 7}] = {MAPMARK_TICK, 'Trainer Paladin'},

    [{x = 1982, y = 2725, z = 7}] = {MAPMARK_SHOVEL, 'Tools'},
    [{x = 2014, y = 2669, z = 7}] = {MAPMARK_REDNORTH, 'Amazonia North Exit'},
    [{x = 1964, y = 2718, z = 7}] = {MAPMARK_REDWEST, 'Amazonia West Exit'},
    [{x = 2001, y = 2715, z = 7}] = {MAPMARK_SKULL, 'Runes Shop'},
    [{x = 1932, y = 2714, z = 7}] = {MAPMARK_FLAG, 'Harbour'},
    [{x = 2049, y = 2666, z = 6}] = {MAPMARK_DOLLAR, 'Bank'}, -- falta bank amazonia.
    [{x = 1988, y = 2698, z = 8}] = {MAPMARK_STAR, 'Task Manager'}, -- botar o npc
    [{x = 2008, y = 2707, z = 6}] = {MAPMARK_SWORD, 'Equipment'},
    [{x = 1979, y = 2710, z = 7}] = {MAPMARK_EXCLAMATION, 'Bug hideout'},
    [{x = 2051, y = 2659, z = 7}] = {MAPMARK_EXCLAMATION, 'Leaf Golem'},
    [{x = 2027, y = 2707, z = 8}] = {MAPMARK_EXCLAMATION, 'Rotworm hideout'},
}

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 onPlayerCloseChannel(cid) npcHandler:onPlayerCloseChannel(cid) end

function greetCallback(cid)
    Topic[cid] = 1
    return true
end

function creatureSayCallback(cid, type, msg)
    local p = Player(cid)
    if not npcHandler:isFocused(cid) then
        return false
    elseif getPlayerLevel(cid) < 10 and msgcontains(msg, 'escort') then
        npcHandler:say('Yes, I escort newcomers to the depot. Do you want me to bring you there?', cid)
        Topic[cid] = 3
    elseif Topic[cid] == 1 and msgcontains(msg, 'yes') then
        npcHandler:say('Well, I can {mark} all important locations in this town on your map. Including an initial hunting spot. I can also give you {information} about Amazon in general.', cid)
        Topic[cid] = 0
    elseif Topic[cid] == 2 and msgcontains(msg, 'yes') then
        npcHandler:say('Here you go.', cid)
        for pos, v in pairs(mapMarks) do
            p:addMapMark(pos, v[1], v[2] or '')
        end
        Topic[cid] = 0
    elseif msgcontains(msg, 'escort') then
        npcHandler:say('This service is only for newcomers below level 10. I think you can manage the way on your own! If you need {marks} on your map, let me know.', cid)
        Topic[cid] = 0
    elseif Topic[cid] == 2 then
        npcHandler:say('Well, nothing wrong about exploring the town on your own. Let me know if you need something!', cid)
        Topic[cid] = 0
    elseif Topic[cid] == 3 and msgcontains(msg, 'yes') then
        npcHandler:say('And here we go!', cid)
        npcHandler:releaseFocus(cid)
        doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
        local pos = {x = 1992, y = 2712, z = 8}
        doTeleportThing(cid, pos)
        doSendMagicEffect(pos, CONST_ME_TELEPORT)
        Topic[cid] = 0
    elseif msgcontains(msg, 'name') then
        npcHandler:say('I\'m Simon, one of the guards of Amazonia!', cid)
        Topic[cid] = 0
    elseif msgcontains(msg, 'job') then
        npcHandler:say('I\'m a guard, overworked and underpaid. I can {mark} important locations on your {map} and give you some {information} about the town.', cid)
        Topic[cid] = 0
    elseif Topic[cid] == 3 then
        npcHandler:say('Well, you seem to know your way around. Take care!', cid)
        Topic[cid] = 0
    elseif msgcontains(msg, 'information') then
        npcHandler:say('Currently, I can tell you all about the town, its {temple}, the {bank}, {shops}, the {bridge} and the {depot}. And if you wish a {hunting} place for begginers.', cid)
        Topic[cid] = 0
    elseif msgcontains(msg, 'map') or msgcontains(msg, 'mark') then
        npcHandler:say('Would you like me to mark locations like - for example - the depot, bank, shops and hunting places on your map?', cid)
        Topic[cid] = 2
    elseif Topic[cid] == 1 then
        npcHandler:say('Well, you seem to know your way around. Take care!', cid)
        Topic[cid] = 0
    elseif msgcontains(msg, 'hunting') or msgcontains(msg, 'hunt') then
        npcHandler:say('Up in the north you can find some freaky creatures. It\'s safer near the city or even under it.', cid)
        Topic[cid] = 0
    elseif msgcontains(msg, 'temple') then
        npcHandler:say('The temple is a magic and spiritual place. You should go there if you need some assistance.', cid)
        Topic[cid] = 0
    elseif msgcontains(msg, 'bridge') then
        npcHandler:say('The bridge is moved by this lever, you can only up or down when it\'s activated.', cid)
        Topic[cid] = 0
    elseif msgcontains(msg, 'bank') then
        npcHandler:say('The banker is in the north area of the city. Go north and then turn right. Don\'t forget that I can {mark} important locations on your map.', cid)
        Topic[cid] = 0
    elseif msgcontains(msg, 'shops') then
        npcHandler:say('You can buy weapons, armor, tools, magical equipment and food here.', cid)
        Topic[cid] = 0
    elseif msgcontains(msg, 'depot') then
        npcHandler:say('The depot is a place where you can safely store your belongings. You are also protected against attacks there. I {escort} newcomers there.', cid)
        Topic[cid] = 0
    else
        npcHandler:say('Sorry, I don\'t have anything to tell you about this topic.', cid)
        Topic[cid] = 0
    end
    return true
end

npcHandler:setMessage(MESSAGE_WALKAWAY, 'How rude.')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye and enjoy your stay in Amazonia, |PLAYERNAME|.')
npcHandler:setMessage(MESSAGE_GREET, 'Hello there, |PLAYERNAME| and welcome to Amazonia! Would you like some {information} and a {map} guide?')
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top