SRL Archive - OSR Help

Scipt is able to detect colour accurately one desktop, fails on laptop


rtnrtn

2019-03-12 10:37:53

program new;
{$i SRL\osr.simba}

const
MSX1 = 400;
MSY1 = 200;
MSX2 = 675;
MSY2 = 500;

var
x, y:integer;

function rsps_getUpText(text: string): boolean;
var
yellowTPA: tpointarray;
yellowATPA: t2dpointarray;
upText: string;
begin
FindColorsTolerance(yellowTPA, 65535, 0, 0, 350, 200, 0);
if (length(yellowTPA) > 1) then
yellowATPA := splitTPAEx(yellowTPA, 1, 10);
sortATPAFromFirstPointX(yellowATPA, point(0, 0));
upText:= getTextATPA(yellowATPA, 5, 'UpChars07');

if (upText = text) then
begin
result := true;
end else
result := false;
end;

function IsWalking(): boolean;
var
BMPA, BMPB, w, h: Int32;
begin
try
BMPA := BitmapFromClient(MSX1, MSY1, MSX2, MSY2);
Wait(69);
BMPB := BitmapFromClient(MSX1, MSY1, MSX2, MSY2);
GetBitmapSize(BMPA, w, h);
Result := (CalculatePixelShift(BMPA, BMPB, [0, 0, w-1, h-1]) > 50000);
finally
if BitmapExists(BMPA) then FreeBitmap(BMPA);
if BitmapExists(BMPB) then FreeBitmap(BMPB);
end;
end;

function findPikachu: boolean;
var
TPAA: T2DPointArray;
TPA: TPointArray;
CTS, clicked, I: Integer;
begin
CTS := GetToleranceSpeed();
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.03, 1.11);
FindColorsSpiralTolerance(400, 200, TPA, 4701409, 0, 0, MSX2, 500, 12);
SetColorToleranceSpeed(CTS);
TPAA := TPAToATPAEx(TPA, 30, 30);
SortATPASize(TPAA, True);
WriteLn(TPAA);

For I := 0 To High(TPAA) do
If (GetArraylength(TPAA[i]) > 100) Then
begin
MiddleTPAEx(TPAA[i], x, y);
MoveMouse(X, Y);
writeln(TPAA[i]);
Wait(250);
If (rsps_getUpText('Pikachu')) Then
begin
while IsWalking() do Wait(500);
ClickMouse(x, y, mouse_left);
Wait(4800);
exit;
end;
end;


result := true;
end;

begin
repeat
findPikachu;
until(false);
end.

I have written the above script by plagiarising different scripts and putting them together.

I wrote this with my Laptop plugged into my PC Monitor and it works perfectly, it accurately selects the colour and identifies the NPCs. However, when I run it on my laptop it is consistently off by about 50-100 px. It can still see the colours etc but each coordinate returned by FindColorsSpiralTolerance is off by 50-100.

The resolution of my monitor and laptop is the same 1920x1080. Is there some configuration I need to do with the script to make it work on different screens?

Citrus

2019-03-12 21:53:19

Is your scale 100% on both computers?

rtnrtn

2019-03-17 08:55:14

Nope that was the issue, thanks.