SRL Archive - SRL Archives

function FallyRoadColor(RType, Tol, Limit : Integer) : Boolean;


WhiteShadow

2006-06-27 02:49:23

[PHP]{.include SRL/SRL.Scar}
{————————————————————————————+
Saves road color in global SRL variable RoadColor, and returns true if it
was successful. Rtype : 1 = brown road, 2 = river, 3 = grey road,
4 = Port sarim dock. Tol is starting tol, limit is max tol limit.
+————————————————————————————}
function FallyRoadColor(RType, Tol, Limit : Integer) : Boolean;
var
Rbmp : array [0..3] of Integer;
ad, Bmp : Integer;
c : TPoint;
begin
Rbmp[0]:= BitmapFromString(8, 8, 'z78DA333737733275351F2507880400' +
'27DE5801');
Rbmp[1]:= BitmapFromString(8, 7, 'z78DA3377B53474B2341F25A9440200' +
'D85E4D39');
Rbmp[2]:= BitmapFromString(3, 19, 'z78DA3377363706C25192AA2400DCD' +
'C4A5F');
Rbmp[3]:= BitmapFromString(12, 13, 'z78DA33313732343031192547C951' +
'721093005EF3BA79');
ad:= 0;
RoadColor:= 0;
case RType of
1: Bmp:= Rbmp[0];
2: Bmp:= Rbmp[1];
3: Bmp:= Rbmp[2];
4: Bmp:= Rbmp[3];
end;
repeat
if(FindBitmapToleranceIn(Bmp, c.x, c.y, 594, 34, 694, 124, Tol + ad))then
begin
RoadColor:= GetColor(c.x, c.y);
end;
ad:= ad + 5
if(RoadColor <> 0)then
Result:= True;
until(ad >= Limit) or (RoadColor <> 0)
FreeBitmap(Bmp);
end;[/PHP]

Post feedback, pl0x. ;P

- WhiteShadow

XxKanexX

2006-06-27 03:42:10

Simpler:


{------------------------------------------------------------------------------------+
Saves road color in global SRL variable RoadColor, and returns true if it
was successful. Rtype : 1 = brown road, 2 = river, 3 = grey road,
4 = Port sarim dock. Tol is starting tol, limit is max tol limit.
+------------------------------------------------------------------------------------}
function FallyRoadColor(RType, Tol, Limit : Integer) : Boolean;
var
Rbmp1, Rbmp2, Rbmp3, Rbmp4, ad, cx, cy, Ex : Integer;
m: Boolean;
begin
Rbmp1:= BitmapFromString(8, 8, 'z78DA333737733275351F2507880400' +
'27DE5801');
Rbmp2:= BitmapFromString(8, 7, 'z78DA3377B53474B2341F25A9440200' +
'D85E4D39');
Rbmp3:= BitmapFromString(3, 19, 'z78DA3377363706C25192AA2400DCD' +
'C4A5F');
Rbmp4:= BitmapFromString(12, 13, 'z78DA33313732343031192547C951' +
'721093005EF3BA79');
ad:= 0;
RoadColor:= 0;
case RType of
1: begin
Ex:= Rbmp1;
m:= True;
end;
2: Ex:= Rbmp2;
3: begin
Ex:= Rbmp3;
m:= True;
end;
4: Ex:= Rbmp4;
end;
repeat
if(FindBitmapToleranceIn(Ex, cx, cy, 594, 34, 694, 124, Tol + ad))then
begin
RoadColor:= GetColor(cx, cy);
if (m) then MMouse(cx, cy, 1, 1);
end;
ad:= ad + 5
if(RoadColor <> 0)then
Result:= True;
until(ad >= Limit) or (RoadColor <> 0)
FreeBitmap(Rbmp1);
FreeBitmap(Rbmp2);
FreeBitmap(Rbmp3);
FreeBitmap(Rbmp4);
end;

WhiteShadow

2006-06-27 03:53:40

I accidently left the MMouse's in there. Yea I felt like I could've done it much simpler but I did them one by one and it ended up like that. Stupid me. ;/ My original had a different variable saved for each type and box and tol adding speed.

XxKanexX

2006-06-27 04:00:00

Oh, i wondered why the mouses were in there :p..

Pyro

2006-06-27 05:45:16

Or better still you could just caseify the bitmaps using one variable name to cut down even more.

WhiteShadow

2006-06-27 06:26:44

;/, shortened. My specific coords box. x1, y1, x2, y2 removed tol raising rates now are the same. Awesome.

Krazy_Meerkat

2006-06-27 18:25:03

Wow, good stuff white :)

WhiteShadow

2006-06-27 18:30:16

w00t. This whole thread has been only about making my code fucking shorter, nice. Except Krazy_Meerkat. *appreciates.