Add timeout

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
ichmagbotsyay
Posts: 70
Joined: Tue Aug 09, 2011 7:43 am

Add timeout

#1 Post by ichmagbotsyay » Mon Oct 17, 2011 1:41 pm

Hi,
my cyclops bot doesn't actually target enemies, it attacks them using the following command:

Code: Select all

	player:cast("MAGE_PURGATORY_FIRE");
	repeat
		if 12000 > player.HP and not player:hasBuff("500469") then
			player:cast("PRIEST_REGENERATE");
		end;
		if 6000 > player.HP then
			player:cast("PRIEST_URGENT_HEAL");
		end;
		player:cast("MAGE_PURGATORY_FIRE");
	until not player.Battling;
	yrest(50);
	player:lootAll();
	if inventory:itemTotalCount(0) == 0 then	
		yrest(1000);
		sendMacro("ViewDistanceSlider_SetValue(400)");
		sendMacro("LeaveParty()");
		waitForLoadingScreen();
		yrest(3000);
		__WPL:setWaypointIndex(__WPL:findWaypointTag("Zumhaendler"));
	end
Obviously that code is packed into an userfunction so it doesn't cram the waypoint file. Now what sometimes happens is that the bot lags for a second (because I'm running several clients) and accidentally walks too far. Then the enemies go into the wall and are invincible. Then the bot just stucks there, continuously casting purgatory fire and sometimes healing himself. Sometimes, when I'm lucky, it runs out of mana and can't heal itself and dies, but sometimes it stucks there for hours.

So here's my question:
How do I add a timeout into that function? I want the bot to try for a while, but stop and go to the next waypoint after a couple of minutes.
Any ideas?

Tooney
Posts: 26
Joined: Fri Oct 07, 2011 12:48 am

Re: Add timeout

#2 Post by Tooney » Mon Oct 17, 2011 4:41 pm

No idea what you are doing with your script but os.date() will give you a time value which by getting a difference would effectively give you a way of monitoring how long you did something.
If os.date() doesn't work then install the d303Fix from Curse.com

Or GetTime() will give you how many mSec it's been since the PC was switched on. Again a difference calc will tell you if you've waited too long.

Thx to Lisa for the d303Fix heads up.

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

Re: Add timeout

#3 Post by rock5 » Mon Oct 17, 2011 7:16 pm

os.date() gives a formated time that is hard to work with. You can use "getTime()" but because it's saved as a table, you would have to use the deltaTime function to get the difference eg. deltaTime(getTime(), starttime). I find it easieast to just use os.clock() which just gives you an easy to use number in seconds so.

Code: Select all

local starttime = os.clock()
before the 'repeat' loop then

Code: Select all

   until not player.Battling or (os.clock()- starttime > 15) -- No more than 15s
You could try and do what the bot would do if it was controling the fight and have it back step or something.
  • 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

ichmagbotsyay
Posts: 70
Joined: Tue Aug 09, 2011 7:43 am

Re: Add timeout

#4 Post by ichmagbotsyay » Tue Oct 18, 2011 9:56 am

rock5 wrote:os.date() gives a formated time that is hard to work with. You can use "getTime()" but because it's saved as a table, you would have to use the deltaTime function to get the difference eg. deltaTime(getTime(), starttime). I find it easieast to just use os.clock() which just gives you an easy to use number in seconds so.

Code: Select all

local starttime = os.clock()
before the 'repeat' loop then

Code: Select all

   until not player.Battling or (os.clock()- starttime > 15) -- No more than 15s
You could try and do what the bot would do if it was controling the fight and have it back step or something.
ok thank you
i will try this when the bot is up and running again

edit: works great, thank you

Post Reply

Who is online

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