Page 1 of 1
Getting stuck while fighting
Posted: Fri Apr 09, 2010 12:20 am
by rock5
I've noticed a situation where the bot can get stuck and not be able to continue.
It's when you start a fight with a mob and it moves into a position where you are unable to attack it.
In this situation the mob will continuously attack you. After awhile the bot notices that it has stopped damaging the mob so it clears the target but immediately notices that it is in combat so waits for aggro. It then tries to attack the mob again starting the loop all over again.
At no point does the character move.
I think a simple fix for this is when the bot stops damaging the mob and clears the target, the first thing it should do is take a step or 2 forward before waiting for aggro again.
Or maybe, before clearing the target, it could try moving a bit to see if it is now able to damage the mob.
This has happened with at least 2 of my waypoint files so I hope it can be fixed.
Re: Getting stuck while fighting
Posted: Fri Apr 09, 2010 4:12 am
by Administrator
Open rom/classes/player.lua, go to (CTRL+G) line 404.
Directly under this line:
Add this:
Save and let me know if this fixes the problem or if it causes any other issues.
Re: Getting stuck while fighting
Posted: Fri Apr 09, 2010 5:31 am
by rock5
Of the 4 times I tried it, it only worked 2 times. The 2 times it didn't work it still just stood there.
Re: Getting stuck while fighting
Posted: Fri Apr 09, 2010 12:36 pm
by rock5
Also, it should only do the unstick if in combat. But I've noticed that if you target a mob and can't attack it, but haven't attracted aggro yet, you still do the unstick move before continuing to the next waypoint.
Re: Getting stuck while fighting
Posted: Fri Apr 09, 2010 5:12 pm
by Garrison
Is there a way to make bot use games own stuck report feature? It would be nice.
Re: Getting stuck while fighting
Posted: Fri Apr 09, 2010 7:38 pm
by Administrator
You could change it to:
Code: Select all
if( self.Battling ) then
yrest(1000);
self:unstick();
self:update();
yrest(500);
end
That should help some. I'm not sure what would cause it to 'not work'. You'll have to describe what you mean. Does it not move (ie. the unsticking isn't doing anything at all)? Is the player actually stuck and unable to move? Did it not move far enough to draw the monster out where it can be attacked? The more detail you give, the better.
Re: Getting stuck while fighting
Posted: Fri Apr 09, 2010 9:13 pm
by rock5
Administrator wrote:You could change it to:
Code: Select all
if( self.Battling ) then
yrest(1000);
self:unstick();
self:update();
yrest(500);
end
That should help some. I'm not sure what would cause it to 'not work'. You'll have to describe what you mean. Does it not move (ie. the unsticking isn't doing anything at all)? Is the player actually stuck and unable to move? Did it not move far enough to draw the monster out where it can be attacked? The more detail you give, the better.
What I meant by 'not work' is it doesn't do the unstick. It clears the target, then waits for aggro without moving. I tried putting a print statement before it to see if it actually gets to that code. I didn't see the print statement so it never got to that code. Maybe there are certain circumstances where that code doesn't execute?
I noticed there is another "Taking too long to damage target" loop around line 630. Maybe that's the one getting executed. What's the difference between the 2 loops?
As to whether the above code fixes unsticking when not in combat, I can't test that right now. Maybe tonight.
Re: Getting stuck while fighting
Posted: Mon Apr 12, 2010 5:20 am
by rock5
Administrator wrote:You could change it to:
Code: Select all
if( self.Battling ) then
yrest(1000);
self:unstick();
self:update();
yrest(500);
end
That should help some. I'm not sure what would cause it to 'not work'. You'll have to describe what you mean. Does it not move (ie. the unsticking isn't doing anything at all)? Is the player actually stuck and unable to move? Did it not move far enough to draw the monster out where it can be attacked? The more detail you give, the better.
I'm not sure what the difference is between the "Taking too long to damage target" loop in checkSkills and fight functions but I copied this code to both line 404 and around 630. Now it unsticks every time.
I also tested to see if the "if self.battling" condition has stopped it from unsticking when not in battle. It has.
So it looks like that is all working. The only comment I would make is it moves too much.
When you are too close to the target it takes a couple of steps back. Is it possible to use that function instead?
I believe it is something along the lines of;
Code: Select all
keyboardHold( settings.hotkeys.MOVE_BACKWARD.key);
yrest(200);
keyboardRelease( settings.hotkeys.MOVE_BACKWARD.key);
I just tried this but when he steps back he steps forward again to stand in exactly the same spot. Is there any way to avoid it moving forward again?
Re: Getting stuck while fighting
Posted: Mon Apr 12, 2010 5:56 am
by Administrator
I think that your character is moving forward again because it is attempting to use a melee skill (which causes your character to run towards the target with click-to-move turned on) or because the bot notices it is too far away from the target. Try resting for 1 second ( yrest(1000) should do the trick) after moving backwards. Let me know if you can get this to work sufficiently and I'll include it.
Re: Getting stuck while fighting
Posted: Mon Apr 12, 2010 7:52 am
by rock5
Administrator wrote:I think that your character is moving forward again because it is attempting to use a melee skill (which causes your character to run towards the target with click-to-move turned on) or because the bot notices it is too far away from the target. Try resting for 1 second ( yrest(1000) should do the trick) after moving backwards. Let me know if you can get this to work sufficiently and I'll include it.
I added a 1 second pause after moving back and before the player:update(). It paused for 1 second after moving back but still moved forward. I even used a longer pause but it seems that before my priest castes any spells he moves forward first.
I think I figured it out. On closer inspection of the MM window I notice it's trying to loot after clearing the target. Looting uses the attack action correct?
That should give you something to follow up.
Re: Getting stuck while fighting
Posted: Mon Apr 12, 2010 5:22 pm
by Administrator
Try this. On line 840 of rom/classes/player.lua, you'll see this:
Code: Select all
if( settings.profile.options.LOOT == true and
Change to:
Code: Select all
if( not break_fight and settings.profile.options.LOOT == true and
Let me know how that works for you.
Re: Getting stuck while fighting
Posted: Mon Apr 12, 2010 11:57 pm
by rock5
No change. Still looted.
I noticed, though, the only thing in that if statement was inventory:updateSlotsByTime(800);. How is not running this supposed to stop me looting?
Re: Getting stuck while fighting
Posted: Tue Apr 13, 2010 5:59 am
by Administrator
My mistake. I posted that quite hastily. Look a few lines down and you'll have to wrap the loot call in an if statement.
Code: Select all
self:update();
if( not break_fight ) then
self:loot();
end
Re: Getting stuck while fighting
Posted: Tue Apr 13, 2010 9:46 am
by rock5
Administrator wrote:My mistake. I posted that quite hastily. Look a few lines down and you'll have to wrap the loot call in an if statement.
Code: Select all
self:update();
if( not break_fight ) then
self:loot();
end
Ok, that works. So everything works now.
So to summarize, I've added this code to around line 405 and 634;
Code: Select all
if( self.Battling ) then
yrest(1000);
keyboardHold( settings.hotkeys.MOVE_BACKWARD.key);
yrest(1000);
keyboardRelease( settings.hotkeys.MOVE_BACKWARD.key);
self:update();
end
Although I suspect that it is not needed at line 405 as every time I got stuck while in combat, it has executed the code at line 634. The only time it executed the code at line 405 was when I got stuck but didn't get aggro.
And I've changed self:loot(); around line 863 to;
Code: Select all
if( not break_fight ) then
self:loot();
end
I guess now you can implement it.
Re: Getting stuck while fighting
Posted: Tue Apr 13, 2010 5:15 pm
by Administrator
Ok, just committed this with r432. It should also resolve some more waypoint issues.
Re: Getting stuck while fighting
Posted: Tue Apr 13, 2010 9:05 pm
by rock5
Administrator wrote:OK, just committed this with r432. It should also resolve some more waypoint issues.
There were a couple of errors;
Line 858 of player.lua has an extra 'and';
Code: Select all
if( and settings.profile.options.LOOT == true and
And line 797 of bot.lua is missing a bracket;
Code: Select all
__RPL:setCurrentWaypoint __RPL:getNearestWaypoint(player.X, player.Z ) );
Also this revision still takes you to the point before the closest waypoint when first starting the bot.
Obviously when starting the bot and loading the first waypoint file it's doing something different than when just using the loadPaths function. Hope you can resolve this because to start a waypoint file from the right place(l1t_start.xml for example) I have to move to waypoint 2 before starting it. It then goes to waypoint 1 then back to 2. If I don't do this it tries to take me to the last point first. LOL
Re: Getting stuck while fighting
Posted: Wed Apr 14, 2010 7:28 am
by Administrator
Ok, I think I've finally got it all figured out. It should be working properly now. I've also removed setCurrentWaypoint (use setWaypointIndex() again).
Re: Getting stuck while fighting
Posted: Wed Apr 14, 2010 9:00 am
by rock5
Administrator wrote:Ok, I think I've finally got it all figured out. It should be working properly now. I've also removed setCurrentWaypoint (use setWaypointIndex() again).
Yep, tested all 3 and they seem to work.
- Starting a new file goes to the nearest waypoint first.
- Loadpaths() takes you to the nearest waypoint.
- setWaypointIndex takes you to the correct waypoint.
All I have to do now is find and change all the places I've already used seCurrentWaypoint.
Thanks for all your efforts.