User Tools

Site Tools



taskmanager

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
taskmanager [2016/12/16 13:28] – [Creating a custom task type] mmoalttaskmanager [2017/05/18 06:06] (current) mmoalt
Line 123: Line 123:
 The countdown does not start until the bot has reached the task start position.\\ 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.\\ The duration is randomized a bit with when the task starts.\\
- 
-Default: 0 (Disabled) 
- 
-**Radius:**\\ 
-The max radius for the task. The bot will try to stay inside this radius. 
  
 Default: 0 (Disabled) Default: 0 (Disabled)
Line 136: Line 131:
  
 Default: 0 (Disabled) 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.
  
 ---- ----
Line 183: Line 188:
 Available options: Available options:
   {   {
-    allowpretasksfalse; -- Allow this task type to use pre tasks +    allowpretasks false; -- Allow this task type to use pre tasks 
-    allowposttasksfalse; -- Allow this task type to use post tasks +    allowposttasks false; -- Allow this task type to use post tasks 
-    allowsubtasksfalse; -- Allow this task type to use sub tasks +    allowsubtasks false; -- Allow this task type to use sub tasks 
-    pathfalse; -- Path to btree location +    allowradius = false; -- Allow this task type to have a radius 
-    displaynamenil; -- Name visible in dropdowns (name by default)+    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:**\\ **Example with behavior tree:**\\
-ml_task_mgr.AddTaskType("Grind", "Grind.bt", nil, {displaynameGetString("grindMode")})+ml_task_mgr.AddTaskType("Grind", "Grind.bt", nil, {displayname GetString("grindMode")})
  
 **Example with a already loaded behavior tree:**\\ **Example with a already loaded behavior tree:**\\
-ml_task_mgr.AddTaskType("my_btree", my_behavior_tree, my_controller, {displayname"My custom task type"})+ml_task_mgr.AddTaskType("my_btree", my_behavior_tree, my_controller, {displayname "My custom task type"})
  
 **Example with ml_task:**\\ **Example with ml_task:**\\
Line 200: Line 208:
  
 ** Making a behavior tree available as a subtask:**\\ ** Making a behavior tree available as a subtask:**\\
-ml_task_mgr.AddSubTaskType("my_subtask", "MoveTo.st", nil, {displayname"My custom subtask type"})+ml_task_mgr.AddSubTaskType("my_subtask", "MoveTo.st", nil, {displayname "My custom subtask type"})
  
  
Line 207: Line 215:
 **Controller functions:** **Controller functions:**
  
-**:CanStart_TM(taskProperties,customProperties)**\\+**:CanTaskStart_TM(taskProperties,customProperties)**\\
 Return false to prevent starting the task. Return false to prevent starting the task.
  
-**:CanRun_TM(taskProperties,customProperties)**\\+**:CanTaskRun_TM(taskProperties,customProperties)**\\
 Return false to end the task. Return false to end the task.
  
Line 220: Line 228:
     customProperties.maxgather = GUI:InputInt("My number", customProperties.maxgather or 1)     customProperties.maxgather = GUI:InputInt("My number", customProperties.maxgather or 1)
   end   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 ==== ==== Adding profiles ====
 Load from file:\\ Load from file:\\
Line 330: Line 364:
   ml_task_mgr.GetPlayerPos = function to get the current player position   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.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.GetMapName = function to get map name (optional)
   ml_task_mgr.ValidProfileName = function to check profile name validity (optional)   ml_task_mgr.ValidProfileName = function to check profile name validity (optional)
taskmanager.1481894920.txt.gz · Last modified: 2016/12/16 13:28 by mmoalt