Page 1 of 1

Stop the bot after last waypoint (stop running)

Posted: Wed Sep 18, 2013 2:33 am
by Marcora
Hi all

How to stop running the bot after the last waypoint here

Code: Select all

<!-- # 12 --><waypoint x="2596" z="3198" y="143">
to wait until the timer.

my file for Drill Ground (I want to survive).

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL" >
<onLoad>
	--== User Option ==--
	RunningSpeed = 60       -- The speed the character runs, 50 is normal. Recommended 59.

	--=================--

	--== Apply speed hack ==--
	local playerAddress = memoryReadIntPtr(getProc(), addresses.staticbase_char, addresses.charPtr_offset);
	if playerAddress ~= 0 then
		memoryWriteFloat(getProc(), playerAddress + 0x40, RunningSpeed);
	end

	--=================--
</onLoad>


	<!-- #  1 --><waypoint x="2483" z="-1385" y="53">
		player:target_NPC("Guild Castle Manager");
		sendMacro("ChoiceOption(2);");	   player:rest(2);   waitForLoadingScreen();   player:rest(2);</waypoint>
	<!-- #  1 --><waypoint x="0" z="-485" y="5">	</waypoint>
	<!-- #  2 --><waypoint x="-125" z="-270" y="6">	</waypoint>
	<!-- #  3 --><waypoint x="-303" z="-105" y="5">	</waypoint>
	<!-- #  4 --><waypoint x="-389" z="-80" y="5">	</waypoint>
	<!-- #  5 --><waypoint x="-403" z="183" y="9">	   player:rest(2); 
		player:target_Object("Drill Ground III");
		sendMacro("ChoiceOption(1);");	   player:rest(2);   waitForLoadingScreen();   player:rest(2);
		player:target_NPC("Special Training Manager");

                sendMacro("ChoiceOption(2);"); yrest(200); 
		sendMacro("ChoiceOption(2);");	   player:rest(2);   waitForLoadingScreen();   </waypoint>


	<!-- #  1 --><waypoint x="2074" z="4519" y="31">	fly(); 	</waypoint>
	<!-- #  2 --><waypoint x="2128" z="4465" y="31">	</waypoint>
	<!-- #  3 --><waypoint x="2209" z="4384" y="71">	</waypoint>
	<!-- #  4 --><waypoint x="2277" z="4268" y="112">	</waypoint>
	<!-- #  5 --><waypoint x="2355" z="4188" y="143">	</waypoint>
	<!-- #  6 --><waypoint x="2426" z="4109" y="143">	</waypoint>
	<!-- #  7 --><waypoint x="2558" z="3962" y="143">	</waypoint>
	<!-- #  8 --><waypoint x="2591" z="3791" y="143">	</waypoint>
	<!-- #  9 --><waypoint x="2593" z="3696" y="143">	flyoff();	</waypoint>
	<!-- # 10 --><waypoint x="2595" z="3534" y="143">	</waypoint>
	<!-- # 11 --><waypoint x="2594" z="3319" y="143">	</waypoint>
	<!-- # 12 --><waypoint x="2596" z="3198" y="143">
	</waypoint>
</waypoints>
sorry i am use google translate tx for you help :D

Re: Stop the bot after last waypoint (stop running)

Posted: Wed Sep 18, 2013 2:41 am
by lisa
If you want Micromacro to exit the script you can do

Code: Select all

error("finished")
If you want it to just stop in place and continue if it gets attacked you can use

Code: Select all

player:sleep()
You can also make it load other characters or other WP, you can make it do pretty much anything you want.

Re: Stop the bot after last waypoint (stop running)

Posted: Wed Sep 18, 2013 4:16 am
by Marcora
allo

i am test player:sleep() the problem is enter combat on the screen, its possible no move after last waypoint exemple (2 minute) after relog next character.

tx :D

Re: Stop the bot after last waypoint (stop running)

Posted: Thu Sep 19, 2013 1:50 am
by lisa
You can just create a loop, it really comes down to what you want it to specifically do.

Re: Stop the bot after last waypoint (stop running)

Posted: Sat Jan 25, 2014 9:15 am
by ZZZZZ
Just wondering, how would I go about making player:sleep() or something similar work without combat waking it up? I have been using a function that buffs a friendly target but I have it set so if player dies it goes to sleep, so I can manually resume it after I have res-ed it and fixed up buffs/pet. The issue is that even while its dead combat keeps pulling it out of sleep...
I guess I could try

Code: Select all

repeat
yrest(200)
player:update
until player.Alive
but I would rather it stay 'asleep' until I manually resume it.

Re: Stop the bot after last waypoint (stop running)

Posted: Sat Jan 25, 2014 9:48 am
by rock5
How do you get attacked if you are dead? Or are you talking about after you rez while you are buffing? You could just press the End key to pause the script while you are buffing. Then press the continue button twice to resume the script.

Re: Stop the bot after last waypoint (stop running)

Posted: Sat Jan 25, 2014 11:24 am
by ZZZZZ
I am using a character to 'buff' my main character while running an instance. If that character dies mid fight for example, you still get the 'in combat' until either the rest of your party or the boss dies. Meaning it just endlessly spams the MM window until either of those conditions are done. It's not that easy tabing out to hit end on a different client while trying to survive/kill Bela/Beth hm bosses, so just looking for a way around it.


*I know this is offtopic, but its to do with the same file, im trying to get my alt to change 'target' without me actually stoping and starting it over again. To do so I figured I would make it so it monitors whisper for my main character and if it says something to it, check if its a players name in range, and if so make that its new target. Tried using:

Code: Select all

		EventMonitorStart("Changetank", "CHAT_MSG_WHISPER");
			local ChangeTankname
			repeat
			local time, moreToCome, name, msg = EventMonitorCheck("Changetank", "4,1")
			if name == "--maintoon--" and msg ~= nil then
				ChangeTankname = player:findNearestNameOrId(msg)
				if ChangeTankname and 200 > distance(ChangeTankname.X, ChangeTankname.Z, player.X, player.Z) then
				Tobuff = Changetankname
				Tankname = Changetankname
				end
			end
--- do the rest
until ( keyPressed( key.VK_F8 ) )
EventMonitorStop("Changetank", "CHAT_MSG_WHISPER");
but i just get this error

Code: Select all

onLoad error: E:/micromacro/scripts/rom/classes/player.lua:3691: bad argument #1
 to 'pairs' (table expected, got nil)

Re: Stop the bot after last waypoint (stop running)

Posted: Sat Jan 25, 2014 11:04 pm
by rock5
player line 3691

Code: Select all

						if( closestObject == nil ) then
I don't see any 'pairs' there. What version of the bot are you using? Has player.lua been modified?

Re: Stop the bot after last waypoint (stop running)

Posted: Sat Jan 25, 2014 11:14 pm
by lisa
ZZZZZ wrote:I am using a character to 'buff' my main character while running an instance.
Any reason you don't use party bot for this?

Re: Stop the bot after last waypoint (stop running)

Posted: Sun Jan 26, 2014 12:08 am
by ZZZZZ
lisa wrote:Any reason you don't use party bot for this?
I made a function for ch/m. Its only a simple 'spam skill depending on declared options'. I have it so I enter the player I want the ch/m to spam high energy barrier on, and if they are in range it will do so. Currently I have made it so i can hit F8 to reload the funtion and allow me to enter a different player to buff, but im looking to make it change just by whispering the character. (easier mid boss fight etc).
rock5 wrote:player line 3691

Code: Select all

						if( closestObject == nil ) then
I don't see any 'pairs' there. What version of the bot are you using? Has player.lua been modified?
Sorry, i had edited the target_NPC function. **wrong line, edited out**


** I tried using this to check if the EventMonitor was working:

Code: Select all

			local time, moreToCome, _name, _msg = EventMonitorCheck("Changetank","4,1")
			if _msg == "test" then
				cprintf(cli.yellow,"\nWorked\n")
			end
and it wouldn't return 'Worked' :/

Re: Stop the bot after last waypoint (stop running)

Posted: Sun Jan 26, 2014 12:31 am
by rock5
So what was the extent of your edits? What's on line 3691?

Re: Stop the bot after last waypoint (stop running)

Posted: Sun Jan 26, 2014 12:42 am
by ZZZZZ
From line 3651 i changed the target_NPC function to:

Code: Select all

	local npc = self:findNearestNameOrId(_npcname)
	if npc then	-- we successfully found NPC
		cprintf(cli.green, language[136], npc.Name);	-- we successfully target NPC
		if( distance(self.X, self.Z, npc.X, npc.Z) > 39 ) then
			self:moveInRange(CWaypoint(npc.X, npc.Z), 39, true);
		end
		-- target NPC
		repeat
		RoMScript("CloseWindows()");
		self:target(npc.Address)
		Attack(); yrest(50); Attack(); -- 'click' again to be sure
		yrest(500);
		until RoMScript("SpeakFrame:IsVisible()") or RoMScript("MailFrame:IsVisible()");
		return true
	else
		cprintf(cli.green, language[137], _npcname);	-- we can't find NPC
		return false
	end
end
Has worked perfectly for me, no longer 'miss' targeting an NPC and causing ChoiceOption to fail.

Code: Select all

			for __, _objnameorid in pairs(_objtable) do

is line 3691 for me.

Re: Stop the bot after last waypoint (stop running)

Posted: Sun Jan 26, 2014 2:30 am
by lisa
well if the bot is still running you can use the default functions for party chat.

Code: Select all

eventParty(_startstop)

sendPartyChat(_msg)

checkEventParty()

So you would do

Code: Select all

eventParty()
which will start the event monitoring for party chat.

Then you can do

Code: Select all

local msg,name = checkEventParty()
As for your code you probably just didn't start the event monitoring

Code: Select all

EventMonitorStart("Changetank", "CHAT_MSG_PARTY")

Re: Stop the bot after last waypoint (stop running)

Posted: Sun Jan 26, 2014 9:25 am
by ZZZZZ
Got it working spot on now, funnily enough you were right about the eventmonitoring lisa, even though I had it set to start i had:

Code: Select all

EventMonitorStop("Changetank", "CHAT_MSG_PARTY")
EventMonitorStart("Changetank", "CHAT_MSG_PARTY")
Which for some reason would only stop it and ignore the start. Then I had an issue with the findNearestNameorId function and trying to save a variable as a boolean instead of a string, but fixed that, so works great now.