Page 1 of 1

Dropping instance in a timer

Posted: Tue Apr 10, 2012 7:58 pm
by BillDoorNZ
Hiyas,

I have a KS script and I'm trying to do the following:

1) Run character to instance (honor party etc)
2) Run through instance till bags are full
3) Drop party to reset the instance and boot character to res point
4) Sell up at Pancer
5) Rince and Repeat

All of this is simple enough (with emphasis on simple). One of the issues I'm trying to solve is that the bot may fall off a wall, or get stuck target-switching (switching between 2 targets in an endless loop as it times out because of a random pixel in the way). It is simple enough from an individual waypoint to do a:

Code: Select all

	player:clearTarget();
	sendMacro("LeaveParty();");
	waitForLoadingScreen(10); 
	player:update();
	__WPL:setWaypointIndex(__WPL:findWaypointTag("rerun"));					
In this instance, however I want to drop the instance and reset etc as a result of a timer check. i.e I have a timer which checks my characters progress through the instance, and if the character is taking too long it should drop party etc. However, this often locks MM.

e.g.

Code: Select all

	--A list of waypoints, and maximum time before we reset. e.g. [6]=60 -> waypoint index 6 should be reached within 60 seconds.
	KS_TimingChecks = {[6]=60, [17]=300, [20]=400, [36]=480, [51]=660, [59]=780, [66]=1020, [80]=1220, [89]=1400, [97]=1560, [111]=1760};
	KS_StartTime = os.time(); --when we started the run (resets in waypoint rerun)
	KS_DEBUG = false; --turn of debug logging
	
	function PrintLine(_text)
		if (KS_DEBUG == true) then printf(tostring(os.date("%c"))..": ".._text.."\n"); end;
	end;
	
	function KS_checkTiming()
		PrintLine("Checking timing");
		local idx = __WPL.CurrentWaypoint;
		local t = (os.time() - KS_StartTime);
		PrintLine("KS_StartTime = "..os.date("%c", KS_StartTime));
		PrintLine("t="..tostring(t));
		
		for k,v in pairs(KS_TimingChecks) do
			PrintLine("checking t vs v => ("..tostring(t).."v"..tostring(v)..")");
			if (t > tonumber(v)) then
				PrintLine("  ->"..tostring(k).." > "..tostring(idx));
				if (tonumber(k) > idx) then
					printf("Exiting dungeon as time("..tostring(t)..") exceeds time("..tostring(v)..") - should be at waypoint #"..tostring(k).." by now\n");
					player:clearTarget();
					sendMacro("LeaveParty();");
					waitForLoadingScreen(10); 
					player:update();
					__WPL:setWaypointIndex(__WPL:findWaypointTag("rerun"));					
				end;
			end;
		end
	end;

	PrintLine("registering timer");
	PrintLine("KS_StartTime = "..os.date("%c", KS_StartTime));
	registerTimer("KS_Timer", 30000, KS_checkTiming);

Error I seem to get is:

Code: Select all

04/11/12 12:44:09: checking t vs v => (620v600)
04/11/12 12:44:09:   ->50 > 42
Clearing target.
Use MACRO: Executing RoMScript "LeaveParty();".
Stripping: You have left the party.

Stopping waypoint: Target acquired.
Did not find any crashed game clients.
12:44am - scripts\rom/start_character.lua:4: ...:/Installs/micromacro/scripts/rom
/classes/player.lua:3801: attempt to compare number with nil

Re: Dropping instance in a timer

Posted: Tue Apr 10, 2012 8:01 pm
by BillDoorNZ
hmmm...retesting this atm, that line in player.lua prolly errored due to a loading screen!! my bad :(

Re: Dropping instance in a timer

Posted: Wed Apr 11, 2012 12:54 am
by jasn
i might got this wrong but anyways.

Why not start the timer if the character gets stuck, and after a certain time it leaves party and "rince and repeat", and stop it if it reaches a waypoint before the timer runs out?
Not knowing if your time schedule are to tight for the bot to make a few unstuck tries and still manage to make it on time.

Re: Dropping instance in a timer

Posted: Wed Apr 11, 2012 4:41 am
by BillDoorNZ
that would work if getting stuck was the only problem, but starting a timer when the bot is target-cycling??? thus i just start one and check that the bot is progressing fast enough - and give it very loose times to allow for unsticking etc.