Jump to content

How to intercept corpse-run?


Findeh

Recommended Posts

Might be very stupid question, i'm kind of ill today, so it's hard to think right, sorry for that.

Anyway, simple code like this is not working for me: 

robotManager.Events.FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState += (engine, state, cancelable) =>
{
	if (condition)
	{
		cancelable.Cancel = true;
		Logging.Write("Message1");
				
		// Do something here
			
		Logging.Write("Message2");
		cancelable.Cancel = false;			
	}
};

The goal is to release spirit but then intercept the act of the corpse-run with a plugin. Problem is: I do get "Message1", so state is canceled, then bot tryes to do the job (// section), but then, for some reason, bot decides to run for a corpse.

If i test it like this: 

cancelable.Cancel = true;
                
Logging.Write("Waiting");
Thread.Sleep(1000*500);
                
Logging.Write("Message2");
cancelable.Cancel = true;

Then i'll get "Waiting" message. Bot will stay for 2-3 seconds but then will run for a corpse anyway. So it's not my code starting the thread again, the thread is starting by itself or (more likely) its a separate thread wich i can't cancel, for some reasone.

Also it doesn't matter wich way i do this, with OnBeforeCheckIfNeedToRunState or OnRunState, result is the same.

I've tryed to cnahge "condition" of my if, to be always true. It spams "Message1", constantly canceling the state, but does not stop the corpse run.

I can pause the bot instead of canceling the state, It will stop the corpse run for sure, but then i will not be able to move it with methods like MovementManager (if i'm not mistaken).

To sum up, is it some sort of state that i can't cancel, or am i just stupid and do it wrong? Maybe the Products.InPause is the way to do it instead, but how do i move then?

Thank you in advance for any tips. 

Link to comment
Share on other sites

 

5 июн 2019 17H01.log.html

 

Here is a video and a log. I'm trying to make bot to go opposite derection from the corpse. But he does not ever reach first waypoint.

Code that i was testing it with:
 

public void Initialize()
    {
		Logging.Write("Corpse Runner is ON");
        isRunning = true;
	
		
		
        robotManager.Events.FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState += (engine, state, cancelable) =>
        {
            if ((Me.HaveBuff("Ghost")))
            {
				Logging.Write("Resurrect state is cancelled");
				cancelable.Cancel = true;
				MovementManager.StopMove();
				
				
				
				MovementManager.Go(OppositeDirectionSpiritPath);
				while (MovementManager.InMovement && Conditions.InGameAndConnected && !Conditions.IsAttackedAndCannotIgnore) { Thread.Sleep(300); };
				MovementManager.StopMove();  
				
				
				Logging.Write("WAIT 5000ms");
				Thread.Sleep(5000);
            }
        };
		
		
       
    }

 

Link to comment
Share on other sites

@Droidz, can you tell me please, is there no such event as "running to retrieve the corpse" and that's why i just can't intercept it, or am i do something wrong?

If there is no such event, then how to retrive corpse with my own code? There is like 20 places atleast, where bot can't get his corpse back, rumming in to the wall or ignores elevator.

can you tell me please, is there no such event such "running to retrive the corpse" and that's why i just can't intercept it, or am i do something wrong?

Link to comment
Share on other sites

  • 3 weeks later...

So nothing?
I will try to explain. Wrobot does not resurect at some points. Bug on wrobots side that have been reported but have not been solved. Bot also don't know how to pass some elevators, caves, mountains and such. It is also a bug on wrobots side. Also have been reported, also have not been solved.  I am trying to make fix both bugs with a plugin, but i can't intercept a resurect part, wich is also seems like a bug on wrobot side. What should i do?

Link to comment
Share on other sites

That's what i do. But i can't stop inbuilt corpse run event. Only by pausing the bot, but if i pause it, half of functionality will not work as intended.

Link to comment
Share on other sites

The problem is. Resurrect state seems to be from "Player is dead" and till you push "Release spirit". So when bot arrives at the graveyard, it is not Ressurect state anymore, and he just runs. But i will recheck that today to confirm.

Link to comment
Share on other sites

Okay, seems like i have found one more problem. I can stop movement now, but if after i've stoped it, i'll do any Thread.Sleep then it automatically set cancelable.Cancel to false.

Another words, i need to stop current even to preven bot from running. I do stop it. Then i do my own work, but if in a process i will use any Thread.Sleep (wich i will use for elevators or to check something, for example). Then it just unsubscribes from event and bot once again start to run wherever he wants.

I't almost imposible to do not use thread.sleep. Or i will run in circles like a mad, instead of standing still, or i'll burn my cpu.

Any ideas how to avoid that behavior?

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...