How to watch for and get out of stuck loop

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

How to watch for and get out of stuck loop

#1 Post by noobbotter » Mon Jul 20, 2015 12:08 pm

I'm starting this thread to discuss an idea that was generated from within a different topic. I didn't want to hijack that thread so I'm starting this new thread.

Every once in a while, one of my characters gets stuck inside the Ancient Treasures minigame at the point where it is supposed to click the candlestick to transport out. When this happens, it seems the MM code is stuck in a loop where it thinks it clicked the candlestick and selected the option to transport out but did not and it sits there waiting (sometimes for hours until I notice it). If I manually click and exit the minigame, MM then resumes the waypoint where it should. So the question is... how can you watch for it getting stuck and force it's way out? Because the code being executed is stuck in a loop, no code you add to that waypoint can watch for the player being stuck. It would have to be in a separate MM window. So this got me to thinking... maybe I could create the following as a solution:

in my AT waypoint file, I add code that will launch a new, separate MM window, attach it to the same character, and all it will do is it's own loop of watching for player.X and player.Z. If those aren't constantly changing (for example, 30 seconds goes by and those values haven't changed) then the bot must be stuck. If those conditions are met, then I could either have it attempt to click the candlestick and get out, or I could have it do a recall and go to where it needs to go. Regardless of which route I choose to make it go, I would then have to make it detect whether it is now working or not, and decide also if I need to kill the other waypoint file/MM that is running and start a fresh one, or whether to take it over from the new one that was watching to unstick.

On top of that, If I wanted to be able to use this functionality from more than 1 waypoint, I would have to either build conditions within the "unsticking" waypoint, or make it where the recovery option is the exact same regardless of which waypoint it was running.

I'd like to hear anyone's input on this as I begin attempting to build such a function. There are a lot of you on these forums that are much better than me at coding so as I work on this I'll post some code and surely, I'll be asking for assistance.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: How to watch for and get out of stuck loop

#2 Post by beanybabe » Mon Jul 20, 2015 2:34 pm

i have been having a small problem when a char goes to leave castle it thinks it clicked the portal and then stands there waiting to exit. I think I may know a way to fix it just make it wait so long back up and try again.

I have never used the exit from AT so not sure about the getting stuck at candlestick I usually run that one manually since I just do a few chars. I was thinking of setting up a path to do those minis.

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: How to watch for and get out of stuck loop

#3 Post by BlubBlab » Mon Jul 20, 2015 2:52 pm

I had also here and there problems with the mini-game wps I simple added more checks and repeat it when it fails.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Re: How to watch for and get out of stuck loop

#4 Post by noobbotter » Mon Jul 20, 2015 3:04 pm

I had added checks and repeats as well, but they didn't help because as Rock5 mentioned, it gets stuck in a loop so it's not going to time out or check anything else. Unless something external makes it stop, hence a second MM window to monitor for lack of movement. If I can get something built and test it with AT and it works, then I can think about other ways to implement it.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: How to watch for and get out of stuck loop

#5 Post by rock5 » Tue Jul 21, 2015 8:28 am

I think he meant extra checks inside the loop. In the end stopping it getting stuck in the loop in the first place is probably the best solution.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Re: How to watch for and get out of stuck loop

#6 Post by noobbotter » Tue Jul 21, 2015 9:47 am

Oh, I see. Well, I had tried to figure out how to put an extra check in there to keep it from getting stuck and it doesn't seem to work. So here's the part of code where it gets stuck:

Code: Select all

			if ExitBeforeNextFile == true then
				if player:target_Object(tran) then
					RoMScript("StaticPopup_OnClick(StaticPopup1, 1);")
					waitForLoadingScreen();
					yrest(3000)
					buyitems()
				end
			end
I think it gets stuck on the waitForLoadingScreen because the bot will sit there forever until I manually click the candlestick and exit the minigame. Then the bot will resume. For some reason it thinks it clicked the candlestick and the message popup but the click didn't actually take. And like I said, it only does this maybe once every 5th or 6th time so it's not every time. How could I change this code to make absolutely sure those items get clicked? Also, I don't know why the waitForLoadingScreen doesn't timeout. I thought it had a built-in timeout function?

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: How to watch for and get out of stuck loop

#7 Post by rock5 » Tue Jul 21, 2015 10:42 am

You have to put a maximum time in it for it to time out, eg.

Code: Select all

waitForLoadingScreen(30)
The problem you are having might be because there is no time between clicking the candlestick and checking the popup. Try putting a yrest between them.

To make sure it works you could repeat it like so.

Code: Select all

            repeat
               if player:target_Object(tran) then
                  yrest(500)
                  RoMScript("StaticPopup_OnClick(StaticPopup1, 1);")
                  waitForLoadingScreen(30);
               end
            until getZoneId() == 10 -- Sascilia Steppes
            yrest(3000)
            buyitems()
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Re: How to watch for and get out of stuck loop

#8 Post by noobbotter » Tue Jul 21, 2015 11:08 am

Thanks Rock5. I'll give that solution a try. Hopefully it will take care of it.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: How to watch for and get out of stuck loop

#9 Post by lisa » Thu Jul 23, 2015 5:43 am

I check the popup has actually popped up and you can check which type it is too, I use this to watch for an invite to ride a mount invitation.

Code: Select all

	if sendMacro('StaticPopup_Visible("RIDE_INVITE")') then 
		sendMacro('StaticPopup_OnClick(StaticPopup1, 1);') 
	end
The thing to also keep in mind that the StaticPopup1 will only accept the top popup, if you have another popup already there for what every reason then it will accept the top one. An example is when you join a party and are in different channel to the party leader, a popup will appear asking if you want to change channels.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: How to watch for and get out of stuck loop

#10 Post by rock5 » Thu Jul 23, 2015 6:27 am

I think I had a function to simplify this once. Here it is. It searches for the popup with the matching name then accepts it even if there are other popups open at the time. Requires you to know the name of the popup but if you don't supply the name then it accept the first popup it finds.

To get the popup name you can just initially use

Code: Select all

AcceptPopup()
Then when it prints the message

Code: Select all

Accepting popup POPUPNAME
You can insert that into the AcceptPopup command to make sure it always accepts the right popup.

Code: Select all

AcceptPopup("POPUPNAME")
userfunction_AcceptPopup.lua
Version 1.0
(736 Bytes) Downloaded 131 times
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Re: How to watch for and get out of stuck loop

#11 Post by noobbotter » Thu Jul 23, 2015 9:59 am

So, I wonder if the problem could be (because I've never witnessed it, it always happends when I'm not watching) if the low on memory error pops up and maybe that's causing the bot to click the wrong popup or something weird? Anyway, I've ben using my new code on this part and haven't seen the problem yet. Still monitoring to see how it works though because I haven't had much time to run my stuff lately, and I think I introduced a problem somewhere else in code (the code that controls my many dailies and minigames amongst my characters) so I've got to work on fixing that.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: How to watch for and get out of stuck loop

#12 Post by lisa » Thu Jul 23, 2015 8:20 pm

with the code posted it will just keep on doing the click staticpopup1 so in that case it wouldn't matter if there was other popups because it will eventually click on them all.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: How to watch for and get out of stuck loop

#13 Post by rock5 » Fri Jul 24, 2015 2:29 am

The reason I created my userfunction was because I used to worry about player hanging around teleporter npcs, watching for botters. Then if they challenge you to a duel just before your bot reaches the npc it could end up accepting the duel.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 12 guests