Page 1 of 1
Drop party and switch waypoints after unstick tries
Posted: Thu Feb 03, 2011 12:00 pm
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.
Re: Drop party and switch profiles after unstick tries
Posted: Thu Feb 03, 2011 12:15 pm
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.
Re: Drop party and switch profiles after unstick tries
Posted: Thu Feb 03, 2011 12:21 pm
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");
Re: Drop party and switch profiles after unstick tries
Posted: Thu Feb 03, 2011 12:54 pm
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.
Re: Drop party and switch profiles after unstick tries
Posted: Thu Feb 03, 2011 1:05 pm
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.
Re: Drop party and switch profiles after unstick tries
Posted: Thu Feb 03, 2011 3:54 pm
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.
Re: Drop party and switch profiles after unstick tries
Posted: Thu Feb 03, 2011 11:37 pm
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)
Re: Drop party and switch waypoints after unstick tries
Posted: Fri Feb 04, 2011 3:55 am
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
Re: Drop party and switch waypoints after unstick tries
Posted: Fri Feb 04, 2011 4:03 am
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?
Re: Drop party and switch waypoints after unstick tries
Posted: Fri Feb 04, 2011 5:35 am
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.
Re: Drop party and switch waypoints after unstick tries
Posted: Fri Feb 04, 2011 12:59 pm
by del3e7
thank you very much Lisa! you saved the rest of the hair left on my head
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

Re: Drop party and switch waypoints after unstick tries
Posted: Mon Feb 07, 2011 4:08 am
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.