User Tools

Site Tools



taskmanager

Task manager

Quick start guide

Set the bot mode to “CustomTasks”.
Click the “Edit tasks” button on the bottom of the “Main Menu” panel.

Creating a profile

  1. Click the “New Task Profile” button
  2. Enter a task profile name (For example: “Shiverpeaks grind”)
  3. Set your profile options (Default is recommended).
  4. Start adding tasks

Adding a task

  1. Go to the position in the map you want to start your task
  2. Click the “Add task” button
  3. Click the new button that showed up in the “Task list”
  4. Enter a name of the task. (For example: “Wayfarer Foothills”)
  5. Select the task type (For example: “Grind”)
  6. Click the “Update position and map id” button
  7. Enter a duration (in seconds)
  8. Select the custom properties you want (if there are any)
  9. Click the “Save” button on the top of the “Task” panel.
  10. Close the “Task” panel.

Repeat until you have all the tasks you want.
Start the bot.

For more advanced options, keep reading.

Profile

A task profile is a collection of tasks you want to let the bot do.

Profile options

Task order:

  • Linear
    • Run the task profile from task 1 to task n.
  • Random
    • Select a random task to run.

Task failure:

  • Continue
    • Continue to the next task if the current task has failed.
  • Stop
    • Stop running tasks if the current task fails.

Repeat:

  • Yes
    • When all tasks have been completed start from the beginning.
  • No
    • Stop running the bot when all tasks are done.

Task list

Each button represents a task. Click the button to edit an existing task or click the “Add task” button to make a new one.

If the task profile is running:
Green - Current active task
Red - Task failure

Meaning of text appended to name:

(Completed):
The task has been completed.

(Running):
Current active task.

(Disabled):
The task has been disabled.

(Invalid):
No valid position or map id

(Unknown task type):
No task type set or task type missing.

(Cooldown):
The time since the task was last run is less then the cooldown value.

Task

Properties

These are the default task properties

Enabled:
Uncheck to disable the task.

Name:
The task name.

Task type:
Select the type of action you want this task to perform.

A task type is required.

Map id:
Enter the map id you want the bot to go to.

A map id is required.

Position:
This is the task start position. The bot will move here before starting the task.

A position is required.

Update position and map id:
Click this button to automatically set the map id and position to your current map id and position.

Min level:
The bot will not do this task unless the character is above this level.

Default value: 0 (Disabled)

Max level:
The bot will not do this task if the character is above this level.

Default value: 0 (Disabled)

Duration:
Set the duration (in seconds) for this task.
The countdown does not start until the bot has reached the task start position.
The duration is randomized a bit with when the task starts.

Default: 0 (Disabled)

Cooldown:
Set the cooldown (in seconds) for the task.
The task will not run again if the time since the task last started is less then the seconds specified.

Default: 0 (Disabled)

Reset cooldown:
Reset the currently active cooldown. Making the task available for running again.
This button only appears if the task is currently on cooldown.

Radius:
The max radius for the task. The bot will try to stay inside this radius.

Default: 0 (Disabled)
RADIUS IS ONLY AVAILABLE IN TASK TYPES THAT ALLOW IT.


Custom properties

Each property under custom properties depends on the task type.
Some task types have no properties, while others can have multiple.


Additional subtasks

The availability of these types of tasks depends on the task type.
Not all task types has any. Some task types only have a few.

Pre tasks

Pre tasks are tasks that must be completed before starting the primary task.
Pre tasks run serially. Each task must be completed before continuing to the next one.

Example:
One pre task to move to a specific location, then another one to talk to a character to gain entrance to another area.

Sub tasks

Sub tasks are tasks that run instead of a primarty task.
Sub tasks runs like a priority selector. The first sub task has first priority and if it fails it moves onto the second one.

Example:
Look for stuff to kill.
Look for stuff to interact with.
Look for characters to talk to.

Post tasks

Post tasks are tasks that must be completed to end the primary task.
Like pre tasks, it runs serially.

Example: Move to a certain location. Then interact to exit an area.

For developers

Creating a custom task type

The custom task manager supports both ml_task and the new behavior tree task type.

To add your task as a custom task:
ml_task_mgr.AddTaskType(name, task, controller, options)

Available options:

{
  allowpretasks = false; -- Allow this task type to use pre tasks
  allowposttasks = false; -- Allow this task type to use post tasks
  allowsubtasks = false; -- Allow this task type to use sub tasks
  allowradius = false; -- Allow this task type to have a radius
  path = false; -- Path to btree location
  displayname = nil; -- Name visible in dropdowns (name by default)
  requireduration = false; -- Task type requires a duration
  minduration = 0; -- Minimum duration for the task type. For tasks that need to have a certain duration.
}

Example with behavior tree:
ml_task_mgr.AddTaskType(“Grind”, “Grind.bt”, nil, {displayname = GetString(“grindMode”)})

Example with a already loaded behavior tree:
ml_task_mgr.AddTaskType(“my_btree”, my_behavior_tree, my_controller, {displayname = “My custom task type”})

Example with ml_task:
ml_task_mgr.AddTaskType(“My custom task type”, my_task)

Making a behavior tree available as a subtask:
ml_task_mgr.AddSubTaskType(“my_subtask”, “MoveTo.st”, nil, {displayname = “My custom subtask type”})


Controller functions:

:CanTaskStart_TM(taskProperties,customProperties)
Return false to prevent starting the task.

:CanTaskRun_TM(taskProperties,customProperties)
Return false to end the task.

:UIDraw_TM(customProperties)
Create your own custom options.

Example:

function my_controller:UIDraw_TM(customProperties)
  customProperties.maxgather = GUI:InputInt("My number", customProperties.maxgather or 1)
end

Events:
The controller supports custom events. You can call them from anywhere in your code.
You can create an event handler in your controller by naming your function OnYourCustomEvent_TM. Example:

function my_controller.OnAttack_TM(instance,my,properties)
 self.attack_counter = self.attack_counter + 1
end

Then call it in your script with:
activetask:CallEvent(“Attack”,target.id,target.name)

Default events:

.OnStart_TM(instance)
.OnStop_TM(instance)
.OnReset_TM(instance)

GW2 Events:
.OnDeath_TM(instance)
.OnDowned_TM(instance)


All tasks that are currently running has a “.runningintaskmanager” property set. (Note: Only the root node)
You can use this to check if your task/btree is running in the taskmanager.


Adding profiles

Load from file:
ml_task_mgr.AddTaskProfile(path, filename)

Load from table:
ml_task_mgr.AddTaskProfileTable(profile)


The currently selected profile is exposed in ml_task_mgr.GetCurrentProfile()


Functionlist

ml_task_mgr (TaskManager):

.ActiveTask()
.GetCurrentProfile()  
.AddTaskType(name, task, controller, options)
.AddSubTaskType(name, task, controller, options)
.Stop()
.Start()
.AddTaskProfile(path, filename)
.AddTaskProfileTable(profile)

TMTaskProfile:

:new(filename,path,data)
:LoadProfile(filename, path)
:LoadProfileData(data)
:Start()
:Stop()
:Started()
:IsValid()
:GetNextTask()
  Returns the next valid task or a blank TMTask
:FilterTasks()
  returns tasklist, completed, invalid
:ActiveTask()
:Failed()
:GetTasklist()
:GetTask(idx)
:AddTask()
:DeleteTask(idx)
:MoveTaskUp(idx)
:MoveTaskDown(idx)
:Save()
:SetActiveIndex()

TMTaskCore:

:IsValid()
:Enabled()
:Started()
:CanStart()
:CanRun()
:Name()
:Save()
:Run(alwaysrun)
:RunMainTask()
:RunSubTasks()
:Stop()
:Complete()
:Reset()
:AvailablePreTasks()
:AvailablePostTasks()
  

TMTask extends TMTaskCore:

.pretasks
.posttasks
.subtasks
:new(taskData,legacy)
:SettingsValid()
:CanStart()
:CanRun()
:AddSubTask()
:AddPreTask()
:AddPostTask()
:GetNextPreTask()
:GetNextPostTask()
:DeleteSubTask(tasklist,idx)
:MoveSubTaskUp(tasklist,idx)
:MoveSubTaskDown(tasklist,idx)

TMSubTask extends TMTaskCore

:new(taskData)

TMTaskType:

:Name()
:Started()
:CanStart(taskProperties,customPropertes)
:CanRun(taskProperties,customPropertes)
:Run(taskProperties,customPropertes)
:Start(taskProperties,customProperties)
:Stop()
:IsValid()
:Reset()

For bot developers

Setting up the task manager for use:

DO NOT DO THIS AS A REGULAR DEVELOPER

In main bot init:

ml_task_mgr.min_level = Min level to be allowed in task sliderint
ml_task_mgr.max_level = Max level to be allowed in task sliderint
ml_task_mgr.btreepath = path to default behaviour folder
ml_task_mgr.taskpath = path to default task folder
ml_task_mgr.GetPlayerPos = function to get the current player position
ml_task_mgr.GetMapID = function to get the current map id
ml_task_mgr.DrawBotProperties = function to draw bot specific task properties (optional)
ml_task_mgr.GetMapName = function to get map name (optional)
ml_task_mgr.ValidProfileName = function to check profile name validity (optional)
ml_task_mgr.Init()

Create a custom task btree. Example in GW2Minion.

taskmanager.txt · Last modified: 2017/05/18 06:06 by mmoalt