Page 1 of 1
[Fixed] mounted movement
Posted: Tue Jun 22, 2010 1:53 am
by rock5
I've been trying to figure out why the bot can't move properly when mounted. At first I thought it might be a timing issue because it moves faster but it looks like it has something to do with the players x,z values.
The players x,z values seem to be stable when not mounted but fluctuate wildly when mounted.
So obviously that means the values in the memory addresses are fluctuating when mounted.
So I thought "Maybe there are other memory addresses that don't fluctuate when mounted" so I had a look for them.
I found 4 addresses (for the x value) that are stable when mounted and not mounted.
Is it possible to use these instead?
0187E4B8
0187E780
018DF994
0350E510
I couldn't find offsets as there were no "copy memory" values. Does that mean they're static?
Please correct me if you are already aware of all this.
Edit: I've since checked this again. Looks like they aren't static. I've come up with another 4 values whose endings are the same as above but the starts are different. I just checked the value of staticbase_char and it matches the first 2 values ie. 0187E000. Can we use staticbase_char and an offset of 4B8 or 780 to find these values? I'm not sure I understand offsets as I don't see the pawnX_offset value. Is it supposed to be 0187E028 as the above example 'cos that's not there?
Re: Fixing mounted movement
Posted: Tue Jun 22, 2010 2:48 pm
by Administrator
I think you could be right. This might cause it to unstick even when it's not necessary. It looks like it only varies a small amount, so it shouldn't be too much of a problem to use those numbers anyways.
Find this in player.lua:
Code: Select all
if( os.difftime(os.time(), self.LastDistImprove) > 3 ) then
-- We haven't improved for 3 seconds, assume stuck
success = false;
failreason = WF_STUCK;
break;
end
Try wrapping that in an if-statement so that it only triggers when not mounted( if( not self.Mounted) ). That might fix it.
Re: Fixing mounted movement
Posted: Tue Jun 22, 2010 3:22 pm
by rock5
Administrator wrote:I think you could be right. This might cause it to unstick even when it's not necessary. It looks like it only varies a small amount, so it shouldn't be too much of a problem to use those numbers anyways.
Find this in player.lua:
Code: Select all
if( os.difftime(os.time(), self.LastDistImprove) > 3 ) then
-- We haven't improved for 3 seconds, assume stuck
success = false;
failreason = WF_STUCK;
break;
end
Try wrapping that in an if-statement so that it only triggers when not mounted( if( not self.Mounted) ). That might fix it.
The unsticking doesn't happen often so it doesn't bother me. The thing I'm trying to fix is the way it wobbles left and right. It's as if it's unable to point the player in the right direction. Another idea was maybe the addresses for direction might also have a problem. But player.Direction seems steady, mounted or not. Note, I use quick turn.
Is there no way to try the stable addresses to see if it stabilizes the mounted movement?
Re: Fixing mounted movement
Posted: Tue Jun 22, 2010 6:31 pm
by Administrator
You could try it by swapping out the addresses in CPlayer:update().
Code: Select all
self.X = memoryReadInt(getProc(), use_the_address_here);
Just use the address you've found with Cheat Engine and don't bother with pointers unless it actually fixes the problem.
I doubt that's the cause, though. Really, I think the simplest solution would be to just ignore the QUICK_TURN option while mounted.
Re: Fixing mounted movement
Posted: Wed Jun 23, 2010 2:22 am
by rock5
Administrator wrote:You could try it by swapping out the addresses in CPlayer:update().
Code: Select all
self.X = memoryReadInt(getProc(), use_the_address_here);
Just use the address you've found with Cheat Engine and don't bother with pointers unless it actually fixes the problem.
I doubt that's the cause, though. Really, I think the simplest solution would be to just ignore the QUICK_TURN option while mounted.
You were right it wasn't the x, z values. I really didn't expect it to be as they are so close, if they were causing wrong angles to be calculated, it would only be by a small amount not the 45 degree waggle that it does. Turning QUICK_TURN of doesn't really help as it still waggles but more slowly.
I had another look at the calculated angles and made a discovery. faceDirection doesn't work at all when mounted. I'd say this must be the cause of the problem. Maybe you need to find other addresses to write the vectors to, when mounted, to turn?
Re: Fixing mounted movement
Posted: Sat Jun 26, 2010 9:43 am
by rock5
You didn't have a comment to make about QUICK_TURN not working when mounted?
Re: Fixing mounted movement
Posted: Sat Jun 26, 2010 3:59 pm
by rock5
I found the addresses and pointers to apply the vectors to when mounted. I've done a bit of testing and they seem to work perfectly.
To get to the addresses you start with;
addr1 = staticbase_char
addr2 = addr1 offset by charPtr_offset
addr3 = addr2 offset by 7c or 278 (they give the same address)
X vector address = addr3 offset by pawnDirXUVec_offset
Y vector address = addr3 offset by pawnDirYUVec_offset
Although I've found these addresses I think implementing it would be beyond me. Can you implement these please?
Re: Fixing mounted movement
Posted: Sun Jun 27, 2010 1:16 am
by rock5
I tried doing it myself:
I added
to addresses.lua
and changed faceDirection in player.lua like this.
Code: Select all
function CPlayer:faceDirection(dir)
local Vec1 = math.cos(dir);
local Vec2 = math.sin(dir);
if self.Mounted then
local tmpAddress = memoryReadIntPtr(getProc(), self.Address , addresses.charPtrMounted_offset);
memoryWriteFloat(getProc(), tmpAddress + addresses.pawnDirXUVec_offset, Vec1);
memoryWriteFloat(getProc(), tmpAddress + addresses.pawnDirYUVec_offset, Vec2);
else
memoryWriteFloat(getProc(), self.Address + addresses.pawnDirXUVec_offset, Vec1);
memoryWriteFloat(getProc(), self.Address + addresses.pawnDirYUVec_offset, Vec2);
end
end
but it crashes the client when mounted.
I suspect I just don't understand the memory functions and have used them incorrectly.
Can anyone see what is wrong with this?
Re: Fixing mounted movement
Posted: Sun Jun 27, 2010 3:25 am
by rock5
By trial and error I figured it out. It was supposed to be
Code: Select all
local tmpAddress = memoryReadInt(getProc(), self.Address + addresses.charPtrMounted_offset);
There's just 1 small thing that I'd like to fix before committing this. At about half the waypoints it will face backwards then forwards again before continuing. I suspect it has something to do with the character getting to the waypoint faster than the script expected. I still haven't found how to fix it yet.
Re: Fixing mounted movement
Posted: Sun Jun 27, 2010 4:08 am
by rock5
All sorted.
Committed to rev 464.
Re: [Fixed] mounted movement
Posted: Thu Jul 08, 2010 7:02 am
by miximixi007
very useful,thank you
Re: [Fixed] mounted movement
Posted: Thu Jul 08, 2010 7:34 am
by rock5
miximixi007 wrote:very useful,thank you
Nice to have someone finally notice.
Re: [Fixed] mounted movement
Posted: Thu Jul 08, 2010 7:44 am
by Administrator
rock5 wrote:Nice to have someone finally notice.
I don't mean to overlook what you're doing. I, and I'm sure everyone here, appreciates the work you are doing. A few of my accounts were disabled, which makes testing some stuff pretty difficult.
Re: [Fixed] mounted movement
Posted: Thu Jul 08, 2010 7:53 am
by rock5
Administrator wrote:rock5 wrote:Nice to have someone finally notice.
I don't mean to overlook what you're doing. I, and I'm sure everyone here, appreciates the work you are doing. A few of my accounts were disabled, which makes testing some stuff pretty difficult.
Actually I said it in jest. I wrote it with a smile on my face. Anyway, I wasn't talking about you. I guess I just expected a few more positive comments to bolster my ego. In the end I do it because I enjoy it and that's the important thing.