View Single Post
  #16  
Old 03-19-2010, 07:19 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
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!
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote