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

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Execute code on town run start?

Infinite Monkeys

Community Developer
Joined
Jul 7, 2012
Messages
224
I'm working on a plugin at the moment, and I need to run some code when a town run is triggered but before any of the town run commands actually execute. I've had a good hunt through the VS object browser and other plugins, but the only similar thing I could find was code that runs when exploration is complete. However, ExplorationCompleteTask has an event (Completed) which functions can be added to in order to execute them when it triggers. TownRunTask doesn't have anything like this, is there some kind of workaround or other option? Thanks!
 
Hi

First thing first, look here:
https://www.thebuddyforum.com/exilebuddy-forum/exilebuddy-guides/178338-basicgrindbot-guide.html

There you find the Current Task Execution Order.

This is what is executed in Town:

MergeInventoryTask
IdTask
SellTask
StashTask
WithdrawTask
HandleInventoryItemsTask
SortInventoryTask
ReturnToGrindZoneTask

So add your task somewhere there (i add mine before IDTask)

You need to do this with a Task, and understand how Task work (basically you trow a Task in, it run in a loop and return true of false at various stages to indicate if your code should run other task or not. then you can chose to internally remove it or let it run based on your need.) take a look at a couple of example, and if i learnt it, you will too.

/hat
Alcor75
 
Thanks, I had a vague idea of the task system but that helped a lot. I have a bunch more questions now though:

If I need the task to execute before the actual portal to town is opened, should I stick it before TownRunTask?

Is BasicGrindBotSettings.NeedsTownRun set to 1 before TownRunTask is actually executed (i.e. as soon as the bot realises that the inventory is full)?
Why is that setting an int rather than a bool?

Should I avoid using AddAtFront() since presumably it adds the task before even ResurrectTask, ClearCursorTask etc? If so, what could cause TaskManager.AddBefore(new MyTask(), "ExplorationTask") to fail? When I tried that it didn't work and I had to replace it with AddAtFront().
 
If I need the task to execute before the actual portal to town is opened, should I stick it before TownRunTask?
Yes i do it too. It work great and ensure all the mob were killed and we are safe to do stupid things.

Is BasicGrindBotSettings.NeedsTownRun set to 1 before TownRunTask is actually executed (i.e. as soon as the bot realises that the inventory is full)?
Why is that setting an int rather than a bool?
Not sure about this, but probably a code decision that do not interests us, newer looked at it, sorry.

Should I avoid using AddAtFront() since presumably it adds the task before even ResurrectTask, ClearCursorTask etc? If so, what could cause TaskManager.AddBefore(new MyTask(), "ExplorationTask") to fail? When I tried that it didn't work and I had to replace it with AddAtFront().
Well, i do add a task at front, and i had to take care about ClearCursorTask(i do disable it when i pick items on the cursor, and Enable it back once done) the moment i decided to play and move with inventory stuffs, but if you do not, just be sure your task check for Me.IsDead or other condition at begin, and be sure it do not end in a infinite loop (i use timeout where needed).
Sorry not sure why your Fail, i do not add task there, for me is mostly a matter of try and fail :).

/Hat

Alcor75
 
Last edited:
Back
Top