Unstick needs a counter/timer / modification

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Unstick needs a counter/timer / modification

#1 Post by d003232 » Tue Jul 14, 2009 6:35 pm

The second time my bot tries to unstick for hours. Dmnd, my waypoint file is simply to bad. Nevertheless, it would be very helpfull to have a counter or timer within the unstick function.

I tried a little modification. It seems to work, even it looks not so elegant. I also want to use a logout call after reaching the limit. That would need a separate logout function. It would be nice to change the 'logoutcheck' function and separate the logout process within a separate function (btw: the time for the logout process should be greater then 12 sec, since one could use more ingame functions like use port or use housing runes, which will need a little more time).

Add a line after player.lua line 281:

Code: Select all

			if( success ) then
				hf_unstick_count = 0; 							-- STEPH13
				if( player.Returning ) then
and some new lines after player.lua line 312:

Code: Select all

					player:clearTarget();
					player:unstick();
					if( hf_unstick_count == nil ) then hf_unstick_count = 0; end;		-- STEPH13
					hf_unstick_count = hf_unstick_count + 1;				-- STEPH13
					if( hf_unstick_count > 12 ) then player:logout(); end;			-- STEPH13
				end
and a new logout function in player.lua

Code: Select all

function CPlayer:logout()		-- STEPH13

			if( settings.profile.hotkeys.LOGOUT_MACRO ) then
				keyboardPress(settings.profile.hotkeys.LOGOUT_MACRO.key);
				yrest(30000); -- Wait for the log out to process
			else
				local PID = findProcessByWindow(getWin()); -- Get process ID
				os.execute("TASKKILL /PID " .. PID .. " /F");
				while(true) do
					-- Wait for process to close...
					if( findProcessByWindow(__WIN) ~= PID ) then
						printf("Process successfully closed\n");
						break;
					end;
					yrest(100);
				end
			end

			if( settings.profile.options.LOGOUT_SHUTDOWN ) then
				cprintf(cli.yellow, language[51]);
				os.execute("\"%windir%\\system32\\shutdown.exe -s -t 30\" "); --Shutdown in 30 seconds.
			end

			error("Exiting: Auto-logout", 0); -- Not really an error, but it will drop us back to shell.

end

And at last I added a new thing to the unstick function itself. After 6 unstick tries I turn around, run a little and then just try to reach the next waypoint. I make that very rugged since I don't unterstand the functions to turn with angle.

Code: Select all

function CPlayer:unstick()

-- after 6x unstick try to run away a little and then go to the nearest waypoint
	if( hf_unstick_count == 6 ) then 				-- STEPH13
	 	-- Move back for x seconds				-- STEPH13
			keyboardHold(settings.hotkeys.ROTATE_RIGHT.key);-- STEPH13
			yrest(1900);					-- STEPH13
			keyboardRelease( settings.hotkeys.ROTATE_RIGHT.key );	-- STEPH13
		keyboardHold(settings.hotkeys.MOVE_FORWARD.key);	-- STEPH13
		yrest(12000);						-- STEPH13
		keyboardRelease(settings.hotkeys.MOVE_FORWARD.key);	-- STEPH13
		self:update();						-- STEPH13
		__WPL:setWaypointIndex(__WPL:getNearestWaypoint(player.X, player.Z));	-- STEPH13
		return
	end;								-- STEPH13

 	-- Move back for x seconds
	keyboardHold(settings.hotkeys.MOVE_BACKWARD.key);
	yrest(1000);
	keyboardRelease(settings.hotkeys.MOVE_BACKWARD.key);
I could also make sense to try to reach a waypoint before, or the next waypoint. But there I thought it is to complicated for me to do that in a modification.
The RoM Bot Online Wiki needs your help!

Post Reply

Who is online

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