View Full Version : Calculating PixelShift in a circle
Footy
08-09-2012, 01:27 PM
Is there a function in SRL to calculate average pixelshift in a cirle, in this case the minimap? AveragePixelShift uses a Tbox, so I dont think that work work. Worst case scenario, I just make a box around the minimap, it just wont be as precise.
~Footy
May i ask why you want to calc pixel shift of the minimap?
Footy
08-09-2012, 01:46 PM
Im using radialwalk to walk to a specific point, +/- 1 square, and if I click the next point while im still moving, it will be way off. Thought this would be a better way then using wait times.
Can just use FFlag() and while the Flag is present, wait.
There is already a function IsMoving in SRL and it is actually based on the pixelshift of the minimap. If you want to make your own, take a look at how that goes about it, or alternatively just use IsMoving :)
Footy
08-09-2012, 01:53 PM
@JJ, flag goes away ~ 800 ms before your character actually stops moving
@P1ng Ill look into that, Thanks!
Nebula
08-09-2012, 03:48 PM
All IsMoving is is a box ~50x50 around the center of the MM.
You could make a box around entire the mm and it would be just as accurate as only have the circular part- think about it. Pixelshift returns the amount of pixels that have changed. So any pixels that don't change have no impact on the result. Which is good in this case, because the pixels around the mm don't change color. So let's say there was a function to determine pixelshift within a circle, It would return the same result as the box function.
Flight
08-09-2012, 06:08 PM
All IsMoving is is a box ~50x50 around the center of the MM.
You could make a box around entire the mm and it would be just as accurate as only have the circular part- think about it. Pixelshift returns the amount of pixels that have changed. So any pixels that don't change have no impact on the result. Which is good in this case, because the pixels around the mm don't change color. So let's say there was a function to determine pixelshift within a circle, It would return the same result as the box function.
That's right, but I believe there's a good reason why IsMoving doesn't read the full minimap. Should your player be walking in a dungeon or second/third story room them only a small part of the MM will change pixels, right? The majority of the MM will be black and will never change, so the pixelshift count would be much lower than normal, that's why the current IsMoving only searches a small area surrounding the center.
If I may, I recommend using my own IsMoving function; it seems to be much faster for detecting player walking/running:
Function IsMoving_F: Boolean;
begin
Result := PixelShift(IntToBox(MMCX-30, MMCY-30, MMCX+30, MMCY+30), 200) > 200;
end;
Element17
08-09-2012, 06:09 PM
@JJ, flag goes away ~ 800 ms before your character actually stops moving
@P1ng Ill look into that, Thanks!
You can change that mate
Footy
08-09-2012, 07:15 PM
Thanks for all the help guys! Im using ismoving, and it appears to work perfectly. Should I ever run into any problems, ill give Flights function a go.
I'm late, but here's your function.
function PixelShiftCircle(CenterX, CenterY, Radius, T: Integer): Integer;
var
BMP, BMP2: Integer;
CIRCLETPA: TPointArray;
B: TBox;
begin
CIRCLETPA := TPAFromCircle(CenterX, CenterY, Radius);
FillEllipse(CIRCLETPA);
B := GetTPABounds(CIRCLETPA);
OffsetTPA(CIRCLETPA, Point(-CenterX + Radius, -CenterY + Radius));
BMP := BitmapFromClient(B.x1,B.y1,B.x2,B.y2);
Wait(T);
BMP2 := BitmapFromClient(B.x1,B.y1,B.x2,B.y2);
Result := CalculatePixelShiftTPA(BMP, BMP2, CIRCLETPA);
FreeBitmap(BMP);
FreeBitmap(BMP2);
end;
Footy
08-09-2012, 08:06 PM
Thanks! It looks really good! Everyone above just said there's no point in it, but I might find a use for this!
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.