What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Problem understanding TreeSharp

Gilderoy

New Member
Joined
May 10, 2010
Messages
761
Reaction score
16
Hi all, Developers :D
So, i'm tryng to rewrite UltimatePalaHealer using the TreeSharp couse actualy the CC is king on the edge of slowness and everyone told me "just rewrite it using TreeSharp!"
Well, i understanded something about TreeSharp i suppose, how decorator work, priority selector ecc ecc.
what i do _not_ understand is how to create the bone of the cc.
i'll try to explain better.
with the normal way if you want something to be done by the cc in combat you write something like
Code:
public overwrite void combat ()
{
  if(condizion1){do something}
  else if(condition2){do something else}
}
Now, problem is, CC that use TreeSharp do not even have a public overwtrite combat() function.. so how can i tell the CC what part of the code to execute when?
i get i must write something like
Code:
public composite CreateBehavior_palaheal()
{
  return (
    new PrioritySelector(
      new decorator(ret=>condition1, new Action(do something));
      new decorator(ret=>condition2, new Action(do something));
    )
  );
}
well, and now where do i put this code?
How do i call for this code to be executed?
cannot seem to understand..
must i declare something like a stranting node of the tree to be navigated? has to be called in some special way? or what?
 
Last edited:
Override the properties of CombatRoutine (you'll find matching properties for each legacy function, that take Composites)

I'd suggest caching the created composites, as some plugins/bots may constantly call said properties (and you don't want to recreate the tree every time its called!)
 
thank you! the first line of your post opened a world to me, realy opened my eyes :)
i'm instead uncertain about the second line, the one about caching the composite :) i do not want to recreate them but i want to navigate them right?
something like this is right or i misunderstud the suggestion about chaching?
Code:
private Composite _combatBehavior;
public override Composite CombatBehavior { get { return _combatBehavior; } }
public override void Initialize(){
  CreateBehaviors();
}
public bool CreateBehaviors()
{
  create the _combatBehaviour here (somehow :P)
}
and call again CreateBehaviors if something relevant change (we go PVP from PVE or something like that)
is that good? i feel like is not enought..
also now i'm working on understanding how CompositeBuilder.GetComposite work but i'll figure it out :P
Thanks again for your help and the realy quick response! :)
 
I assume you're talking about the composite builder from Singular? If so, thats probably over your head in terms of knowledge (it does a lot of reflection to retrieve the composites dynamically)

Also; what you pasted (code wise) will be fine.
 
Back
Top