Drop party and switch waypoints after unstick tries

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
del3e7
Posts: 6
Joined: Wed Feb 02, 2011 8:01 pm

Drop party and switch waypoints after unstick tries

#1 Post by del3e7 »

I've searched the forums and wasn't able to find any posts like this, but can someone give me a hand in how to get micromacro to drop party and load a new profile after max unstick tries? Thank you in advance.
Last edited by del3e7 on Thu Feb 03, 2011 11:48 pm, edited 1 time in total.
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Drop party and switch profiles after unstick tries

#2 Post by lisa »

a new profile or new WP file?
loading a new waypoint wouldn't be to difficult but would involve adding some code to player.lua
Changing to a different profile is a bit more difficult.

Maybe if you say more about what you want to do there might be an easier way.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
del3e7
Posts: 6
Joined: Wed Feb 02, 2011 8:01 pm

Re: Drop party and switch profiles after unstick tries

#3 Post by del3e7 »

I'm running a KS gold farm profile, which consists of 3 waypoint profiles (ks, rez to npc, npc to ks). It does well, however about every 5-6th run, somehow it will manage to get stuck. Instead of logging out or going to sleep, I would like it to drop party to reset instance and load a new waypoint profile, basically reloading the rez to npc profile.

What I really need is the code to get the program to drop party after max unstick tries, and load new profile.

Currently, at the end of my KS run, my code is

Code: Select all

RoMScript("LeaveParty()"); yrest(10000); loadPaths("ks-res-to-pancer");
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Drop party and switch profiles after unstick tries

#4 Post by lisa »

I thought so, a slight terminology error.
Profile is the file that has all your character information, the file that tells your character what to do and where to go is the WP.

Loading a WP is easy enough.
Would mean adding some code to class/player.lua around line 2000. Changing this would mean anytime the bot is updated that you would need to also change the file every time.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
del3e7
Posts: 6
Joined: Wed Feb 02, 2011 8:01 pm

Re: Drop party and switch profiles after unstick tries

#5 Post by del3e7 »

do you know what code I need to insert to drop party to reset instance at max unstick tries, or do I need to wait for someone else to help with that? I've tried a few things with no positive results so far.
Alkaiser
Posts: 222
Joined: Sat Sep 25, 2010 2:03 pm

Re: Drop party and switch profiles after unstick tries

#6 Post by Alkaiser »

I'm just guessing but try this. player.lua line 2000

Code: Select all

-- Attempt to unstick the player
function CPlayer:unstick()
-- after 2x unsuccesfull unsticks try to reach last waypoint
	if( self.Unstick_counter == 3 ) then
		if( self.Returning ) then
			__RPL:backward();
		else
			__WPL:backward();
		end;
		return;
	end;

-- after 5x unsuccesfull unsticks try to reach next waypoint after sticky one
	if( self.Unstick_counter == 6 ) then
		if( self.Returning ) then
			__RPL:advance();	-- forward to sticky wp
			__RPL:advance();	-- and one more
		else
			__WPL:advance();	-- forward to sticky wp
			__WPL:advance();	-- and one more
		end;
		return;
	end;

-- after 8x unstick try to run away a little and then go to the nearest waypoint
	if( self.Unstick_counter == 9 ) then
	 	-- turn and move back for 10 seconds
		keyboardHold(settings.hotkeys.ROTATE_RIGHT.key);
		yrest(1900);
		keyboardRelease( settings.hotkeys.ROTATE_RIGHT.key );
		keyboardHold(settings.hotkeys.MOVE_FORWARD.key);
		yrest(10000);
		keyboardRelease(settings.hotkeys.MOVE_FORWARD.key);
		self:update();
		if( player.Returning ) then
			__RPL:setWaypointIndex(__RPL:getNearestWaypoint(self.X, self.Z));
		else
			__WPL:setWaypointIndex(__WPL:getNearestWaypoint(self.X, self.Z));
		end;
		return;
	end;

 	-- Move back for x seconds
	keyboardHold(settings.hotkeys.MOVE_BACKWARD.key);
	yrest(1000);
	keyboardRelease(settings.hotkeys.MOVE_BACKWARD.key);

	-- Straff either left or right now
	local straffkey = 0;
	if( math.random(100) < 50 ) then
		straffkey = settings.hotkeys.STRAFF_LEFT.key;
	else
		straffkey = settings.hotkeys.STRAFF_RIGHT.key;
	end

	local straff_bonus = self.Unstick_counter * 120;
	keyboardHold(straffkey);
	yrest(500 + math.random(500) + straff_bonus);
	keyboardRelease(straffkey);

	-- try to jump over a obstacle
	if( self.Unstick_counter > 1 ) then
		if( self.Unstick_counter == 2 ) then
			keyboardHold(settings.hotkeys.MOVE_FORWARD.key);
			yrest(550);
			keyboardPress(settings.hotkeys.JUMP.key);
			yrest(400);
			keyboardRelease(settings.hotkeys.MOVE_FORWARD.key);
		elseif( math.random(100) < 80 ) then
			keyboardHold(settings.hotkeys.MOVE_FORWARD.key);
			yrest(600);
			keyboardPress(settings.hotkeys.JUMP.key);
			yrest(400);
			keyboardRelease(settings.hotkeys.MOVE_FORWARD.key);
		end;
	end;

end
You could put in something like this

Code: Select all

		RoMScript("LeaveParty()")
		RoMScript("Logout()")
		waitForLoadingScreen()
		yrest(5000)
		-- Re-initialize player
		player = CPlayer.new()
		settings.load()		
		loadPaths("KS")
somewhere under

Code: Select all

if( self.Unstick_counter == 9 ) then
You will need to have the Autologin addon.
del3e7
Posts: 6
Joined: Wed Feb 02, 2011 8:01 pm

Re: Drop party and switch profiles after unstick tries

#7 Post by del3e7 »

Would it be easier to simpy edit my bot.lua at this point:

Code: Select all

-- Too many tries, logout
					if( settings.profile.options.MAX_UNSTICK_TRIALS > 0 and
						player.Unstick_counter > settings.profile.options.MAX_UNSTICK_TRIALS ) then
						cprintf(cli.yellow, language[55],
						  player.Unstick_counter,
						  settings.profile.options.MAX_UNSTICK_TRIALS );	-- max unstick reached
						if( settings.profile.options.LOGOUT_WHEN_STUCK ) then
							if settings.profile.options.CLOSE_WHEN_STUCK == false then
								player:logout() -- doesn't close client
							else
								player:logout(nil,true); -- closes client
							end
						else
						-- pause or stop ?
							player.Sleeping = true;		-- go to sleep
							--stopPE();	-- pause the bot
							-- we should play a sound !
							player.Unstick_counter = 0;
						end
					end;
So that instead of logging out, he/she simply leaves party (so i get kicked from instance and it resets) and loads new wp file? (my other profile will invite another after autoselling equipment)
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Drop party and switch waypoints after unstick tries

#8 Post by lisa »

Either would work, it's up to you. Just remember each time that file is updated you will need to edit it again.
Personally I'd go with the player.lua as you are more likely to make changes to that file then to bot.lua
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
User avatar
Giram
Posts: 191
Joined: Thu Aug 26, 2010 3:34 pm
Location: Finland

Re: Drop party and switch waypoints after unstick tries

#9 Post by Giram »

If there are some changes on that file what svn is trying to update then aren't those files just merged together leaving changes made to file previously?
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Drop party and switch waypoints after unstick tries

#10 Post by lisa »

Add this to your profiles that would need to load a new WP after leaving party

Code: Select all

		<option name="STUCK_WAYPOINT"		value="WAYPOINTNAME" />
obviously replace WAYPOINTNAME with the actual WP file name (don't include .xml)

If you don't have this option in your profile then it won't do anything different to normal.

I added this to the player.lua that is attached.

Code: Select all

-- after 7x unsuccesfull unsticks leave party and load WP.

	if ( self.Unstick_counter == 8 ) and 
	(settings.profile.options.STUCK_WAYPOINT ~= nil) then
	RoMScript('LeaveParty();');
	printf("Stuck and leaving party")
	waitForLoadingScreen()
	loadPaths(settings.profile.options.STUCK_WAYPOINT)
	end;
Tested the code except the loading screen after leaving party, should hopefully wait until you are kicked from instance and then continue.
Attachments
player.lua
Adding in some specific coding for del3e7
(104.24 KiB) Downloaded 182 times
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
del3e7
Posts: 6
Joined: Wed Feb 02, 2011 8:01 pm

Re: Drop party and switch waypoints after unstick tries

#11 Post by del3e7 »

thank you very much Lisa! you saved the rest of the hair left on my head :P

your code works great (was receiving an error using the player.lua), thank you very much for spending the time to help me, it's appreciated.

And thanks to Alkaiser for the assist as well, appreciate your effort and time too :)
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Drop party and switch waypoints after unstick tries

#12 Post by lisa »

Ok something that may interest you. in revision 572 (current at posting) we introduced a new event section in profile.

Code: Select all

	<onUnstickFailure><![CDATA[
		-- Lua code to execute when MAX_UNSTICK_TRIALS is reached.
	]]></onUnstickFailure>
If you update rombot and revert it to current version then you can just add those tags to your profile and add the code for leaving party and such in there.
That way your player.lua will be the default and won't be affected by updates.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Post Reply