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

How to Pause Tree?

Smarter

Member
Joined
Jan 15, 2010
Messages
763
Reaction score
9
I would like to be able to Pause the current task, while keeping the CC response active. An example would be, while running GB2, after harvest, I'd like a plugin to complete an action without being interrupted. What (safe) methods do I have ... ?
 
If you want to do things in parallel, you have to use threads. My plugin uses them via delegates, take a look at it!
 
Cannot do them in Parallel, must be non-shapeshifted, and standing still for what I need to do.
 
I would like to be able to Pause the current task, while keeping the CC response active. An example would be, while running GB2, after harvest, I'd like a plugin to complete an action without being interrupted. What (safe) methods do I have ... ?

I believe you've got conflicting requirements. As I understand it, Honorbuddy (at a 10000 foot level), behaves similar to the following:
Code:
    while (true)
    {
        1. tick the behavior tree
        2. pulse each of the plugins
    }

If this is a correct understanding of Honorbuddy internals, then you've got a problem:
  • In order for the CC to remain responsive, you must return (quickly) from the plugin Pulse() to allow the behavior tree to 'tick'
  • To guarantee your action cannot be interrupted, you must not return from the plugin Pulse() until your desired action completes

This is one of the many reasons why 'sleep' inside plugins or CCs is simply evil. It prevents Honorbuddy from doing anything else until the sleep completes. The TreeSharp Wait action is an excellent alternative to sleep that does not have these limitations. Alas, the Wait action cannot be used in a plugin, unless you're willing to provide your own tree walking routine for the plugin. (I.e., your willing to implement and execute your plugin as a BT. But, this would be a distinct BT from that used by Honorbuddy.)

Your only real alternative is to build your plugin's Pulse as a state machine, and return as quick as you can. The state machine would have to 'recover' to the desired state if the BT or another plugin messed up the current state it was in.

You can also play games with threads as Jim87 suggested, but this is very dicey. As, Honorbuddy was not architected to facilitate this. Multi-threading plugins/CCs can be done, but it is a frequent source of errors, and a pain to debug--even for those that are very good at it.

If you provide more details about what you're trying to accomplish, perhaps the Community can supply you with a more solid answer as to your viable solution space.


cheers & good luck with it,
chinajade
 
Two options,
- Fuck with the very root composite
or
- Plugin which doesn't release the thread until the conditions are met, but calls the CC
 
Stupid question: may "return RunStatus.Running" affect this aspect? I mean, logically speaking (not "how the bot works"), "running" means "I'm not done yet, please hold on for me next tick"...
 
Stupid question: may "return RunStatus.Running" affect this aspect? I mean, logically speaking (not "how the bot works"), "running" means "I'm not done yet, please hold on for me next tick"...

Running means 'return directly to this BT node when its my parent node's turn to run again'. (The Running status is propagated up the tree as needed).

However, if your node returns Running, but there are 'higher level' nodes in the tree that now decide they need to run, they will be executed first, before returning to your Running node. (Recall, the reason that your node ran in the first place was because the 'higher level' nodes decided they had nothing to do).

'Higher level' nodes include things like harvesting, combat, and combat movement. So, you sub-tree's state can still be messed up if you return Running, and one of the higher level nodes intervened between consecutive ticks to your node.


cheers,
chinajade
 
Last edited:
Stupid question: may "return RunStatus.Running" affect this aspect? I mean, logically speaking (not "how the bot works"), "running" means "I'm not done yet, please hold on for me next tick"...

Yeah, I considered this, but as chinajade said, it would simply return to the top and run again, and after the harvest GB2 would take off removing my ability to do what is needed out of Shapeshift/Standing Still ....

Two options,
- Fuck with the very root composite
or
- Plugin which doesn't release the thread until the conditions are met, but calls the CC

Which root composite? & For the 2nd, that wouldn't work as GB2 would fly off after combat :-\.
 
If you have to ask, don't. Just make a plugin that follows this logic:

Code:
if(just looted herbs && safe conditions met) {
	while (my actions aren't complete) {
		if (in combat) {
			call cc routine
		} else {
			do my work here
		}
	}
}
 
Back
Top