I have to agree with WD here 100%. (Also, I prefer JSON but still haven't gotten around to finishing a JSON parser for GS2...)
Anyways, new release!
Behavior Tree Version 1.1
I have added the ability to load behavior trees from a simple file format.
PHP Code:
this.behavior = new TStaticVar();
this.behavior.join("ai-behaviortree");
this.behavior.loadFromFile("behavior_tree_name", this);
This will load a behavior tree from a "behaviors/behavior_tree_name.txt" dynamically. Make sure that your npc-server has rights to this. The comments in the script should explain the further details.
Here's what the example script in the first post looks like in file format:
PHP Code:
rootSelector
leaf search %this
decorator filter %this,state,idle
getParent
sequence
decorator filter %this,state,chase
leaf findPath %target
getParent
leaf move %this
decorator loop %path_size
getParent
getParent
sequence
decorator filter %this,state,attack
leaf attack %this
getParent
macro pause 0.5
getParent
sequence
decorator filter %this,state,dead
macro setCharAni, dead
getParent
You may note that what was once this.path.size() is now %path_size. Unfortunately, I don't have any real way to allow calling a function of an object like that, so for situations like that you'll have to save info like that elsewhere, in this case a variable called path_size.
The next step is a Behavior Tree editor, so you won't have to mess with any of this!