User Tools

Site Tools



behaviortree

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
behaviortree [2017/01/07 10:36] mmoaltbehaviortree [2022/07/18 09:27] (current) fxfire
Line 1: Line 1:
 =====Behavior Tree Framwork===== =====Behavior Tree Framwork=====
-Behavior Trees are a wonderful thing when it comes to writing any kind of AI logic. It is currently in its "first working version" and there are still improvements coming in the future.  +Behavior Trees are a wonderful thing when it comes to writing any kind of AI logic. It is currently in its "first working version" and there are still improvements coming in the future. 
-GW2Minion is completely written with this framework. FFXIVMinion is not making use of this, but it *could* be used as well.+  
 +**FFXIVMinion** is not making use of this, but it *could* be used as well. Instead, it uses the 'older' Cause&Effect framework. Example Code how to build your own addon : {{ ::newaddon.zip |}}
  
 **BT Basics, How they work:** [[http://www.gamasutra.com/blogs/ChrisSimpson/20140717/221339/Behavior_trees_for_AI_How_they_work.php|Behavior trees for AI]] **BT Basics, How they work:** [[http://www.gamasutra.com/blogs/ChrisSimpson/20140717/221339/Behavior_trees_for_AI_How_they_work.php|Behavior trees for AI]]
Line 41: Line 42:
   
  -- Load all our local "bot/addon" BTree files  -- Load all our local "bot/addon" BTree files
- BehaviorManager:LoadBehaviorFromFolder(GetLuaModsPath()  .. "\\\GW2Minion\\\SillyJumper")+ BehaviorManager:LoadBehaviorFromFolder(GetLuaModsPath()  .. "\\\SillyJumper")
   
 end end
Line 69: Line 70:
 {{youtube>MMASYe_FEuU?medium}} {{youtube>MMASYe_FEuU?medium}}
  
 +EDIT: Above the lines where you add the Checkbox, you need to make sure the used variable is NOT nil, so put this above: 
 +<code lua> 
 +if (not Settings.sillyjumper.jump ) then Settings.sillyjumper.jump = false end 
 +</code>
 \\ \\
  
Line 112: Line 116:
  Reload = function() sillyjumper.LoadBehaviorFiles() end,   Reload = function() sillyjumper.LoadBehaviorFiles() end,
  -- if set, it will be treated as a private addon, loadable from the addon store  -- if set, it will be treated as a private addon, loadable from the addon store
- private = true,+ private = false,
   
  }  }
Line 201: Line 205:
  Reload = function() sillyjumper.LoadBehaviorFiles() end,   Reload = function() sillyjumper.LoadBehaviorFiles() end,
  -- if set, it will be treated as a private addon, loadable from the addon store  -- if set, it will be treated as a private addon, loadable from the addon store
- private = true,+ private = false,
                    
                         -- (optional) Callback function, is called by the BTree Framework when the BTree is started. Allows us to supply a custom "context" table to the BTree:                         -- (optional) Callback function, is called by the BTree Framework when the BTree is started. Allows us to supply a custom "context" table to the BTree:
  LoadContext = function() return sillyjumper.GetContext() end,  LoadContext = function() return sillyjumper.GetContext() end,
 +
 +                        -- (optional) Function to draw the menu elements that always appears on the "Main menu" interface.
 +                        DrawMenuCode = function(btree) end,
 +                                               
 +                        -- (optional) Function to draw the menu elements that appears on the "Main menu" interface when the btree is selected.
 +                        -- This locks the edit field inside the btree editor.
 +                        DrawMainMenuCode = function(btree) end,
                                                  
-                        -- (optional) Function to draw the menu elements that appears on the "Main menu" interface. This locks the edit field inside the btree editor. +                        -- (optional) Function to draw the menu elements that appears on the subtree node. This is also used for drawing custom properties in the taskmanager. 
-                        DrawMainMenuCode = function(btree) -- your draw code end, +                        -- This locks the edit field inside the btree editor. 
-                         +                        DrawSubMenuCode = function(btree) end
-                        -- (optional) Function to draw the menu elements that appears on the subtree node. This is also used for drawing custom properties in the taskmanager. This locks the edit field inside the btree editor. +
-                        DrawSubMenuCode = function(btree) -- your draw code end+
  }  }
 </code> </code>
Line 251: Line 260:
  Reload = function() sillyjumper.LoadBehaviorFiles() end,   Reload = function() sillyjumper.LoadBehaviorFiles() end,
  -- if set, it will be treated as a private addon, loadable from the addon store  -- if set, it will be treated as a private addon, loadable from the addon store
- private = true,+ private = false,
  -- (optional) Callback function, is called by the BTree Framework when the BTree is started. Allows us to supply a custom "context" table to the BTree:  -- (optional) Callback function, is called by the BTree Framework when the BTree is started. Allows us to supply a custom "context" table to the BTree:
  LoadContext = function() return sillyjumper.GetContext() end,  LoadContext = function() return sillyjumper.GetContext() end,
Line 306: Line 315:
   * There are additional BehaviorManager functions that might be helpful to you:   * There are additional BehaviorManager functions that might be helpful to you:
  
 +=== 11. BTreeinfo ===
 +<code lua>
 +local btreeinfo = {
 + -- Our Main Behaviortree filename:
 + filename = string,
 +
 + -- Our Foldername and a mandatory subfolder where our btree will be loaded from:
 + filepath = string,
 +
 + -- Callback function, when the BTree was changed and saved in the BT-Editor. Reload all addon bt files here, including private subtrees.
 + Reload = function() end,
 +
 + -- if set, it will be treated as a private addon, loadable from the addon store
 + private = false,
 +
 + -- if set, the btree will not appear in the botmode dropdown
 +        internal = false,
 +        
 +        -- Preloaded task data. Important when using a private addon.
 +        data = table,
 +        
 + -- (optional) Callback function, is called by the BTree Framework when the BTree is started. Allows us to supply a custom "context" table to the BTree:
 + LoadContext = function() end,
 +
 + -- (optional) Function to draw the menu elements that always appears on the "Main menu" interface. (Requires internal)
 + DrawMenuCode = function(btree) end,
 +    
 + -- (optional) Function to draw the menu elements that appears on the "Main menu" interface when the btree is selected.
 + -- This locks the edit field inside the btree editor.
 + DrawMainMenuCode = function(btree) end,
 +
 + -- (optional) Function to draw the menu elements that appears on the subtree node. This is also used for drawing custom properties in the taskmanager.
 + -- This locks the edit field inside the btree editor.
 + DrawSubMenuCode = function(btree) end,
 +
 + -- Required for private addons with additional private sub-behavior trees
 + LoadSubTree = function(filename) end,
 +
 +}
 +</code>
 +
 +=== 12. BehaviorManager functions ===
 <code lua> <code lua>
 BehaviorManager:ToggleMenu() BehaviorManager:ToggleMenu()
Line 312: Line 363:
 BehaviorManager:Start() BehaviorManager:Start()
 BehaviorManager:Stop() BehaviorManager:Stop()
-BehaviorManager:GetTicksThreshold()+BehaviorManager:GetTicksThreshold()  -- How often (in ms) the BTree is being called. 
 +BehaviorManager:SetTicksThreshold(milliseconds)
 BehaviorManager:GetLastTick() BehaviorManager:GetLastTick()
 BehaviorManager:SetLastTick(ticks) BehaviorManager:SetLastTick(ticks)
Line 320: Line 372:
 BehaviorManager:Paused(p) BehaviorManager:Paused(p)
 BehaviorManager:CurrentBTreeName() BehaviorManager:CurrentBTreeName()
 +BehaviorManager:SetBtreeFile(botmode_name)
 </code> </code>
- 
behaviortree.1483785385.txt.gz · Last modified: 2017/01/07 10:36 by mmoalt