using onLeaveCombat during an onLoad only waypoint?

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

using onLeaveCombat during an onLoad only waypoint?

#1 Post by noobbotter » Thu Jul 16, 2015 11:46 am

Hi guys. I have a waypoint file that I use to manually enable speed() with my spacebar... I typically use it aftermounting or after using a speed pot, or whenever I want to manually be able to enable faster speed.

So I thought I'd try to add some functionality to it to allow myself to auto-hide (as a rogue) when leaving combat, and to be able to turn that function on and off.

So I have the following code. The speed part still works properly. The part for enabling and disabling autohide, it recognizes the keypress but the onLeaveCombat section doesn't seem to run, even with no conditions put on it (you can see I commented out the condition check) it doesn't even do a print during the onLeaveCombat. Here's my code:

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad><![CDATA[
	
	autoHide = false
	
	for k,v in pairs(settings.profile.skills) do
		v.AutoUse = false
		yrest(50)
	end
	
	function settings.profile.events.onLeaveCombat()
		print("AutoHiding ")
		--if autoHide == true then
			yrest(500)
			sendMacro("/cast Hide")
			cprintf(cli.red, "Auto Hiding after Combat!!!\n")
		--end
	end
	
	
	--============= Function to show button controls ===================
	function SKM_ShowButtons()
		cprintf(cli.green, "SPACEBAR - - > Set Speed.\n")
		cprintf(cli.green, "VK_HOME - - > Disable Autohide.\n")
		cprintf(cli.green, "VK_INSERT - - > Enable Autohide.\n")
	end
   
	--============= main routine starting: =====================
	local delay = 1 -- time between key presses.
	local time = os.time()
	SKM_ShowButtons();
	while(true) do
		--================== Enable speed() ======================
		if keyPressed(key.VK_SPACE) and (os.time() - time > delay ) then
			speed()
			cprintf(cli.yellow, "HIGH SPEED ENABLEED!!!\n")
			SKM_ShowButtons();
			time = os.time()
		end
		--================== Enable Auto Hide after leaving combat =============
		if keyPressed(key.VK_INSERT) and (os.time() - time > delay ) then
			autoHide = true
			cprintf(cli.yellow, "Auto Hide ENABLEED!!!\n")
			SKM_ShowButtons();
			time = os.time()
		end
		--================== Disable Auto Hide after leaving combat =============
		if keyPressed(key.VK_HOME) and (os.time() - time > delay ) then
			autoHide = false
			cprintf(cli.yellow, "Auto Hide disabled!!!\n")
			SKM_ShowButtons();
			time = os.time()
		end
		yrest(10)
	end
]]></onLoad>
</waypoints>
If I had to guess, I'd say It never calls the onLeaveCombat function because the bot isn't doing the combat because it's too busy keeping track of whether there was a keypress? Any way I can make this work? I am stumped.

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

Re: using onLeaveCombat during an onLoad only waypoint?

#2 Post by rock5 » Thu Jul 16, 2015 12:15 pm

It's pretty simple really. The bot never takes control to attack because it's stuck in a loop in the onload. onLeaveCombat only goes into effect after a bot initiated combat sequence. If you want your code to do something after you manually kill something then you will have to test for combat yourself in your loop. Something like

Code: Select all

player:updateBattling()
if lastBattling == true and player.Battling == false then
    -- Put onLeaveCombat code here
end
lastBattling = player.Battling
  • 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: using onLeaveCombat during an onLoad only waypoint?

#3 Post by noobbotter » Thu Jul 16, 2015 12:22 pm

Awesome. I was thinking it had something to do with the loop it was in. Thanks. I'll try implementing that tonight and see what I come up with.

**Update:
Yep, that worked. I updated my code to have it detect battling within the loop and it worked. It's not always 100% accurate as far as detecting "leaving battle" and entering hide, but works most the time.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests