Jump to content

Stop current quest profile and start another one


Recommended Posts

I've got a plugin, that checks if something specific have happened (in a complicated way, like different teleports, continent change, gm checks and so on)

The idea is, i do my quest profile, while plugin is working at background. When plugin got triggered i need to stop current quest profile and load new one, totally different, for another continent and so on.

The point i've stuck at. Stop quester and load anoter profile. Basicly when i stop quester product, bot brakes (stop / pouse buttons are inactive anymore, it only can be closed after that) and quest log looks like this:

18:27:30.883 - [Quester] Started
18:27:30.886 - 111111111111111111111111111111
18:27:31.886 - 222222222222222222222222222222
18:27:31.965 - [Quester] Stopped
18:27:32.489 - [Quester] Stopped
18:27:32.489 - [Quester] Closed
18:27:32.721 - Session statistics:
Elapsed time: 00h:00m:04s
XP/HR: 0 - 0 min
Kills: 0 (0/hr)
Deaths: 0 (0/hr)
Stucks: 0 (0/hr)
Farms: 0 (0/hr)
Loots: 0 (0/hr)
Money/HR: 0 G 00 S 00 C (0 G 00 S 00 C)

Code i use:

if (condition)
 ArgsParser.Product = "Quester";
 ArgsParser.Profile = "MyProfile.xml";

So my guess is, when i stop quester product, it also stop all plugins and, as a result, my plugin can't start quester with another profile.

There also may be some problems after "33333333" message, but i don't get there yet.

So the question is, how do i do "condition based quester profile change"? I don't need to change product (atleast yet) only the profile. It should be able triger with a condition and should do it multiple times per run if needed.
Maybe my code is wrong? Or maybe i should do it not with a plugin but how then?

This is probably the hardest one of my "stucks" with a wrobot so far, because i can't see workaround, even the bad ones, so any advics are much appreciated. Thank you in advance.


Link to comment
Share on other sites

I'm sorry, but how do i do that? Plugin itself decides when to kill process and what to do next. If it also got killed, no other thread will know what to do next. Do you mean that if i do it something like:

private BackgroundWorker backgroundThread;
public void Start()
   backgroundThread = new BackgroundWorker();
   backgroundThread.DoWork += Pulse;

And do all the stuff inside the Pulse method, then this thread will not be killed together with the plugin thread?

Link to comment
Share on other sites

Basically. Or you can just start a new thread like new Thread(() => { stuff here;}).Start();
Those threads won't be killed because they belong to the wRobot.exe process but aren't spawned like plugins/products inside the wRobot framework

Link to comment
Share on other sites

All that thing causes another problem.

When i create separate thread, it kills quester thread and. as a result, my plugin thread. Then it starts the quester again. Quester starts the plugin. Plugin starts new separate thread, that is killing quester again aaaaaaand down to the endles cycle we go.

So befor createon of a new thread within the plugin, i need to check isn't there already that thread running, left by a previous plugin. But i can't do it from within current  plugin thread, because it's a separate thread from the thread created by a previous plugin copy )))))

Is there any way to check for a status of a separate running thread? Maybe by it's name? Like wrobot.exe/MyThread?

Or maybe i can create a variable that will be stored not in my plugin but in wrobot.exe thread? Then i'll be able to set it false after the wrobot.exe start, and set it true after the first thread start.

Link to comment
Share on other sites

13 hours ago, Findeh said:

That's great, didn't know it exist. I don't even need a value, so Exist() will do just fine. Thank you.

Not sure which of the suggestions you're talking about but if it's mutex remember that its PC wide and if you have multiple wrobot instances its best to name your mutex (in wdiscord i use the charname as the unique identifier)


if (!Mutex.TryOpenExisting(myName, out mut))
    mut = new Mutex(true, myName);
    _ = DiscordBot.RunBotAsync();

edit: thinking about it i should probably change that to my plugin name + the char name in case other ppl use mutexs.. 

Edited by Marsbar
Link to comment
Share on other sites

On 7/18/2019 at 10:58 AM, Marsbar said:

Not sure which of the suggestions you're talking about but if it's mutex remember that its PC wide and if you have multiple wrobot instances its best to name your mutex (in wdiscord i use the charname as the unique identifier) 

I was actually need only a true/false trigger that will not die with my process but will die wit a wrobot process. Inbuild Var class did the trick (atleast for now, will need to coplete the code first to be sure). But thank you anyway.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...