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

Whi World NPC "Task Master" [TFS 1.0]

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,452
Solutions
1
Reaction score
625
Location
Estonia
Making this into Tutorial requires too much trouble, id rather do in video format if ever.

So i just leave it as it is:
By the time you use these scripts, they might not be exactly the same as in my Whi World server, but have a close resemblance.

Task Master Features:
1.
Gives skill points when task completed
2. Tasks can be redone
3. Tasks can be done in party
4. Easy config
5. There can be more than 1 task master NPC
6. Player Friendly hints
-------------------------------------
Task Master.xml NPC>...

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Task Master" script="tasks.lua" walkinterval="2000" speed="200" walkradius="7" floorchange="0" speechbubble="3">
    <health max="100" now="100"/>
    <look type="264" head="78" body="116" legs="95" feet="121" corpse="20339"/>
</npc>

task.lua in NPC>SCRIPTS>...
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
npcHandler.talkRadius = 1

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()
-- not polished yet to release NPC System, where NPC talk to each-other and players who are
--not even trying to talk to them.
end

function creatureSayCallback(cid, type, msg)
local L = getPlayerLevel(cid)
local noTask = true
local noTaskReport = true
-------- CHAT
  local walkawayMessage = taskLocationHinter(cid)
  npcHandler:setMessage(MESSAGE_WALKAWAY, walkawayMessage)

  if not npcHandler:isFocused(cid) then
     if msg == "hi" or msg == "hello" then
       npcHandler:addFocus(cid)
       for k, v in pairs(tasks) do
         if L >= tasks[k].minL and L <= tasks[k].maxL and getPlayerStorageValue(cid, tasks[k].storageID) == -1 then
           selfSay("i have {task} for you!", cid)
           return true
  elseif getPlayerStorageValue(cid, tasks[k].storageID) >= tasks[k].killsRequired then
  selfSay("Give me full {report} about your hunt", cid)
  return true
  end
  end

  selfSay ("This is a fine day for hunting", cid)
     else
       return false
     end
   end

  if msg == "bye" or msg == "bb" or msg == "cya" then
  selfSay("bye", cid)
  npcHandler:releaseFocus(cid)
  return true
  end
  if msgcontains(msg, "help") then
  selfSay("This NPC accpets words: {task}, {report}}", cid)
  return true
  end
-------- SYSTEMS
   if msgcontains(msg:lower(), 'task') then
     noTask = taskSystem(cid, tasks, noTask)
  taskBoolean(cid, noTask)
   end

  if msgcontains(msg, "report") then
  noTaskReport = reportTaskSystem(cid, tasks, noTaskReport)
  taskReportBoolean(cid, noTaskReport)
   end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
creaturescrpits.xml
Code:
<event type="modalwindow"     name="taskRewards"      script="ModalWindow/taskRewards.lua"/>
<event type="kill"         name="tasks"         script="tasks.lua"/>
 
Last edited:
tasks.lua in creaturescripts>scripts>...
Code:
function onKill(cid, target)
  local monster = tasks[getCreatureName(target):lower()]
  if isPlayer(target) or not monster or isSummon(target) then
  return true
  end

  local partyMembers = {cid}
  local party = Player(cid):getParty()
  if party then
  for _, member in ipairs(party:getMembers()) do
  if getDistanceBetween(Player(cid):getPosition(), Player(member):getPosition()) == 10 then
  table.insert(partyMembers, member:getId())
  end
  end
  end

  for x=1, #partyMembers do
  local player = Player(partyMembers[x])
  if player:getStorageValue(monster.storageID) < monster.killsRequired and player:getStorageValue(monster.storageID) >= 0 then
  player:setStorageValue(monster.storageID, player:getStorageValue(monster.storageID) + 1)
  player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..player:getStorageValue(monster.storageID)..' of '..monster.killsRequired..' '..getCreatureName(target)..'s killed.')
  end
  if player:getStorageValue(monster.storageID) == monster.killsRequired then
  player:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(player:getStorageValue(monster.storageID))..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
  end
  end
return true
end

taskRewards.lua in creaturescripts>scripts>ModalWindows>...
Code:
function onModalWindow(cid, modalWindowId, buttonId, choiceId)
    local player = Player(cid)
    player:unregisterEvent("taskRewards")

    if modalWindowId == 1000 then
        if buttonId == 100 then
            if choiceId == 1 then
                player:addManaSpent    (                160*1)
                player:sendTextMessage(TALKTYPE_MONSTER_SAY,"you gained 160 experience to magic skill")
            elseif choiceId == 2 then
                player:addSkillTries(SKILL_AXE,     20*1)
                player:addSkillTries(SKILL_SWORD,     20*1)
                player:addSkillTries(SKILL_CLUB,     20*1)
                player:sendTextMessage(TALKTYPE_MONSTER_SAY,"you gained 20 experience to weapon skills")
            elseif choiceId == 3 then
                player:addSkillTries(SKILL_DISTANCE,15*1)
                player:sendTextMessage(TALKTYPE_MONSTER_SAY,"you gained 15 experience to distance skill")
            elseif choiceId == 4 then
                player:addSkillTries(SKILL_SHIELD,    40*1)
                player:sendTextMessage(TALKTYPE_MONSTER_SAY,"you gained 40 experience to shielding skill")
            elseif choiceId == 5 then
                player:addSkillTries(SKILL_FIST,     20*1)
                player:sendTextMessage(TALKTYPE_MONSTER_SAY,"you gained 20 experience to fist fighting skill")
           
            end       
        end
    end
    if modalWindowId == 1001 then
        if buttonId == 100 then
            if choiceId == 1 then
                player:addManaSpent    (                160*2)
            elseif choiceId == 2 then
                player:addSkillTries(SKILL_AXE,     20*2)
                player:addSkillTries(SKILL_SWORD,     20*2)
                player:addSkillTries(SKILL_CLUB,     20*2)
            elseif choiceId == 3 then
                player:addSkillTries(SKILL_DISTANCE,15*2)
            elseif choiceId == 4 then
                player:addSkillTries(SKILL_SHIELD,    40*2)
            elseif choiceId == 5 then
                player:addSkillTries(SKILL_FIST,     20*2)
           
            end       
        end
    end
end

global.lua
Code:
-- TASK CHECKER
function taskBoolean(cid, b)
    if b == true then
        selfSay("There is no new tasks for you, yet.", cid)
    end
return true
end
-- TASK REPORT CHECKER
function taskReportBoolean(cid, b)
    if b == true then
        selfSay("You don't have any ongoing tasks here.", cid)
    end
return true
end
Code:
-- GLOBAL TASK MASTER TABLE
tasks = {
["deer"] = {
    minL = 1,
    maxL = 2,
    killsRequired = 10,
    storageID = 10100,
    plural = "deers",
    modId = 1000,
    hours = 12,
    location = "north forest"
  },
["wolf"] = {
    minL = 1,
    maxL = 2,
    killsRequired = 10,
    storageID = 10101,
    plural = "wolves",
    modId = 1000,
    hours = 12,
    location = "north forest"
  },
["boar"] = {
    minL = 1,
    maxL = 2,
    killsRequired = 10,
    storageID = 10102,
    timeId = 20102,
    plural = "boars",
    modId = 1000,
    hours = 12,
    location = "north forest"
  },
["bear"] = {
    minL = 1,
    maxL = 2,
    killsRequired = 10,
    storageID = 10103,
    plural = "bears",
    modId = 1000,
    hours = 12,
    location = "north forest"
  },
["bandit druid"] = {
    minL = 3,
    maxL = 4,
    killsRequired = 12,
    storageID = 10104,
    plural = "bandit druids",
    modId = 1001,
    hours = 14,
    location = "west Bandit mountain"
  },
["bandit mage"] = {
    minL = 3,
    maxL = 4,
    killsRequired = 12,
    storageID = 10105,
    plural = "bandit mages",
    modId = 1001,
    hours = 14,
    location = "west Bandit mountain"
  },
["bandit knight"] = {
    minL = 3,
    maxL = 4,
    killsRequired = 12,
    storageID = 10106,
    plural = "bandit knights",
    modId = 1001,
    hours = 14,
    location = "west Bandit mountain"
  },
["bandit hunter"] = {
    minL = 3,
    maxL = 4,
    killsRequired = 12,
    storageID = 10107,
    plural = "bandit hunters",
    modId = 1001,
    hours = 14,
    location = "west Bandit mountain"
  },
["archanos"] = {
    minL = 4,
    maxL = 5,
    killsRequired = 1,
    storageID = 10108,
    plural = "archanos",
    modId = 1001,
    hours = 24,
    location = "west Bandit mountain"
  }
}
Code:
function taskMW(cid, modId, title)
    local player = Player(cid)

    window = ModalWindow(modId, title, "Choose Skill to train")
    player:registerEvent("taskRewards")
    window:addButton(100, "Confirm")
    window:addChoice(1, "Magic")
    window:addChoice(2, "Weapon")
    --window:addChoice(3, "Distance")
    --window:addChoice(4, "shielding")
    --window:addChoice(5, "fistfighting")
    window:setDefaultEnterButton(100)
    window:setDefaultEscapeButton(101)
    window:sendToPlayer(player)
   return window;
end
Code:
-- TAKE TASK
function taskSystem(cid, table, noTask)
local L = getPlayerLevel(cid)
    for k, v in pairs(table) do
        if L >= table[k].minL and L <= table[k].maxL then
            if getPlayerStorageValue(cid, table[k].storageID+10000) < 0 then
                if getPlayerStorageValue(cid, table[k].storageID) <= -1 then
                    if Player(cid):getStorageValue(TASKS_STORAGE_VALUE) == -1 then
                        Player(cid):setStorageValue(TASKS_STORAGE_VALUE, 0)
                    end
                    noTask = false
                    setPlayerStorageValue(cid, table[k].storageID, 0)
                    questAccepted = selfSay ("You accepted task to kill " .. table[k].killsRequired .. " " .. table[k].plural, cid)
                end
            else
                selfSay ("You need to wait " ..math.floor(Player(cid):getExhaustion(table[k].storageID+10000)/60)+1 .. " minutes, before you can do " .. k .." task again", cid)
            end
        end
    end
return noTask
end
Code:
-- REPORT TASK
function reportTaskSystem(cid, table, noTaskReport)
    for k, v in pairs(table) do
        if getPlayerStorageValue(cid, table[k].storageID) >= table[k].killsRequired then
            local title = k .. " task completed"
            noTaskReport = false
            setPlayerStorageValue(cid, table[k].storageID, -2)
            Player(cid):setExhaustion(table[k].storageID+10000, table[k].hours*60*60)
            selfSay("you completed "  .. k .." task", cid)
            taskMW(cid, table[k].modId, title)
            return true and noTaskReport
        elseif getPlayerStorageValue(cid, table[k].storageID) >= 0 then
            noTaskReport = false
            selfSay("You have killed " .. getPlayerStorageValue(cid, table[k].storageID) .. " out of " .. table[k].killsRequired .. " " .. table[k].plural, cid)
        end
    end
return noTaskReport
end
Code:
function taskLocationHinter(cid)
local player = Player(cid)
local taskOnProgress = {}

    for k,v in pairs(tasks) do
        if player:getStorageValue(tasks[k].storageID) >= 0 then
            table.insert(taskOnProgress, k)
        end
    end
    if #taskOnProgress > 0 then
        local task = taskOnProgress[math.random(1, #taskOnProgress)]
        local answer = tostring(task.." can be found in "..tasks[task].location)
        return answer
    end
return "good bye"
end

BUGLIST:
1. change onKill function into onDeath function and register the creaturescript to every monster. @Peonso example on page post #37
(this will fix multiple kill counting)
2. change the party table creator, fix can be found on post #40 (this will fix double killcount to party leader)
 
Last edited:
I don't think you have a clear understanding of what a "tutorial" is.
yeah should of put in resources, but was in haste..
i could make it a tutorial though. After a find time.
But right now scripting hours going for preparing for beta launch.
 
I do know what a tutorial is and this clearly isn't one.
Clearly is, he has provided the necessary steps in order to step by step from beginning to end, add a skill point system.
 
Clearly is, he has provided the necessary steps in order to step by step from beginning to end, add a skill point system.
Um yeah sure whatever.. go work on your server you will never launch or bump that hype thread of yours..
 
Um yeah sure whatever.. go work on your server you will never launch or bump that hype thread of yours..
Will do, keep wasting all day everyday on OTLand doing nothing with your life except trying to boost your post count.
 
This is clearly not a tutorial, but rather a resource release.
No one without coding knowledge will have a single clue what this is supposed to do.

Let me simplify. Maybe if I do this for you, you'll see the tutorial in it because it is indeed a tutorial but you guys think too hard to try proving someone wrong.

STEP ONE- make Task Master.xml NPC>..

STEP TWO- add
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Task Master" script="tasks.lua" walkinterval="2000" speed="200" walkradius="7" floorchange="0" speechbubble="3">
    <health max="100" now="100"/>
    <look type="264" head="78" body="116" legs="95" feet="121" corpse="20339"/>
</npc>

STEP THREE- make script task.lua in NPC>SCRIPTS>...

I'll leave it at that, whether or not someone without coding knowledge knows what the hell to do, it is laid out step by step, They need no knowledge to add this. IT IS A TUTORIAL.
 
this is not a tutorial, but i will make it a tutorial in due time.
 
Let me simplify. Maybe if I do this for you, you'll see the tutorial in it because it is indeed a tutorial but you guys think too hard to try proving someone wrong.

STEP ONE- make Task Master.xml NPC>..

STEP TWO- add
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Task Master" script="tasks.lua" walkinterval="2000" speed="200" walkradius="7" floorchange="0" speechbubble="3">
    <health max="100" now="100"/>
    <look type="264" head="78" body="116" legs="95" feet="121" corpse="20339"/>
</npc>

STEP THREE- make script task.lua in NPC>SCRIPTS>...

I'll leave it at that, whether or not someone without coding knowledge knows what the hell to do, it is laid out step by step, They need no knowledge to add this. IT IS A TUTORIAL.

Hahahaha, just because you define steps on how to implement it, it doesn't mean its a tutorial.
There is no educational process included in this post.
I also said you need coding knowledge to understand what the script does, never mentioned anything about needing coding knowledge to be able to implement this.
If by anything, this explains how to add a new NPC with a script associated with it, but as this was never the intention, its not a tutorial for "How to add your own NPC with scripts!", leading it to be just a resource release.

So hilarious how some people can't even tell the difference about the most basic stuff.
 
Hahahaha, just because you define steps on how to implement it, it doesn't mean its a tutorial.
There is no educational process included in this post.
I also said you need coding knowledge to understand what the script does, never mentioned anything about needing coding knowledge to be able to implement this.
If by anything, this explains how to add a new NPC with a script associated with it, but as this was never the intention, its not a tutorial for "How to add your own NPC with scripts!", leading it to be just a resource release.

So hilarious how some people can't even tell the difference about the most basic stuff.
How the fuck retarded are you? In any scenario in which there's a how to there's an educational process you moron. You sound stupid as fuck.

Also I'm pretty sure in regards to knowing what this specific code does, you don't need coding knowledge. See the big bold letters at the top that they sometimes call a title? Usually describes what the post is about? I'm gathering anyone that can read, can obtain the knowledge of what this code does.
 
Last edited:
How the fuck retarded are you? In any scenario in which there's a how to there's an educational process you moron. You sound stupid as fuck.

Also I'm pretty sure in regards to knowing what this specific code does, you don't need coding knowledge. See the big bold letters at the top that they sometimes call a title? Usually describes what the post is about? I'm gathering anyone that can read, can obtain the knowledge of what this code does.
Madness overload.
 
Chill guys, give me 2 weeks and then i make a real tutorial, by that time i prolly have receiver npc too. The guy who knows what to do with skillpoints, talking about skillreset
 
Classic... Get proven wrong and your go to line is me being mad. Kids these days.
You are hilarious.

How the fuck retarded are you?
So mad. Your can't even insult people properly with your poor English.

In any scenario in which there's a how to there's an educational process you moron.
Not every scenario, like in this post. But as we all can tell by your madness-level, you don't seem to comprehend a lot.
You sound stupid as fuck.
No, you do, as I'm not the only one pointing out that this is not a tutorial. Even the OP said it several times.
Also I'm pretty sure in regards to knowing what this specific code does, you don't need coding knowledge. See the big bold letters at the top that they sometimes call a title?
Skillpoints does not refer to anything in Tibia. First time I read this, I thought it had to do with these custom "skillpoint-system" some peoples have been making.
Skill level or skill tries would sound more reasonable regarding this topic.
I'm gathering anyone that can read, can obtain the knowledge of what this code does.
I guess you meant to say; "I believe that anyone that can read, can obtain the knowledge of what this code does.", but sure go get your gangsquad if that's what you really intended.
And there is so many people who doesn't know even what the most basic words mean, you are one of them, so if you want to base a tutorial off of reading code, then you have certainly failed with your tutorial.
 
You are hilarious.


So mad. Your can't even insult people properly with your poor English.


Not every scenario, like in this post. But as we all can tell by your madness-level, you don't seem to comprehend a lot.

No, you do, as I'm not the only one pointing out that this is not a tutorial. Even the OP said it several times.

Skillpoints does not refer to anything in Tibia. First time I read this, I thought it had to do with these custom "skillpoint-system" some peoples have been making.
Skill level or skill tries would sound more reasonable regarding this topic.

I guess you meant to say; "I believe that anyone that can read, can obtain the knowledge of what this code does.", but sure go get your gangsquad if that's what you really intended.
And there is so many people who doesn't know even what the most basic words mean, you are one of them, so if you want to base a tutorial off of reading code, then you have certainly failed with your tutorial.

That's a hell of a nice story you wrote, would love to read it sometime.
 
Back
Top