SRL Archive - SRL Archives

A list of fixes


Cazax

2009-02-04 12:05:46

Firemaking.scar:

WeHaveLogs is outdated. here is the fix:
Function FindLogs(Var X, Y : Integer): Boolean;
Var
Logs : Integer;
Begin
Logs := DTMFromString('78DA63DCC8C4C0F08A010D30229140FA2450C' +
'D4D026AB601D5DC25A0E61450CD23026ACE01D5BC26A0663750CD' +
'47FC6A00BF630A00');
GameTab(4);
Wait(250 + Random(250));
Result := FindDTM(Logs, X, Y, MIX1, MIY1, MIX2, MIY2);
FreeDTM(Logs);
End;
Also it should have a findtinderbox:
Function FindTinderbox(Var X, Y : Integer): Boolean;
Var
TinderBox : Integer;
Begin
TinderBox := DTMFromString('78DA638C67626078C18006189148205D0A547' +
'39D809A04A09A7B04D49400D5DC27A0A61CA8E60D0135E940351F' +
'F1AB0100C4B607FE');
GameTab(4);
Wait(250 + Random(250));
Result := FindDTM(TinderBox, X, Y, MIX1, MIY1, MIX2, MIY2);
FreeDTM(TinderBox);
End;

Cooking.scar:
FindRange still works but it laggs a lot and sometimes it doesn't work. It uses DTM to find the range in the mainscreen, which makes it very slow. Here is the TPA version:
Function FindRange(Var X, Y : Integer): Boolean;
Var
TPA : TPointArray;
ATPA : T2DPointArray;
I, H : Integer;
Begin
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 1385376, MSX1, MSY1, MSX2, MSY2, 15);
If Length(TPA) = 0 Then
Exit;
ATPA := TPAtoATPAEx(TPA, 50, 50);
H := High(ATPA);
For I := 0 To H Do
Begin
If Length(ATPA[I]) > 50 Then
Begin
Result := True;
MiddleTPAex(ATPA[I], X, Y);
Exit;
End;
End;
End;

Fighting.scar:
IsFightAt searches in a 20*20 square for the bar so if it is a big moster(lesser demon for example) it won't find it. Fix:
Function IsFightAt(CX, CY : Integer): Boolean;
Var
ATPA : T2DPointArray;
X, Y : Integer;
Begin
ATPA := FindAllHPBars(CX,CY, MSCY, MSX1, MSY1, MSX2, MSY2);
If (Length(ATPA) = 0) Then
Exit;
MiddleTPAEx(ATPA[0], X, Y);
Result := (Distance(X, Y, CX, CY) <= 45);
End;

Damage will always call getskillinfo making it to change the tab every time. It can be replaced with GetMMLevels:
Function Damage: Integer;
Var
S : String;
Begin
If Players[CurrentPlayer].Level[8] = 0 Then
Players[CurrentPlayer].Level[8] := GetSkillInfo('hp', False);
S := GetMMLevels('hp', S) - Players[CurrentPlayer].Level[8];
End;

NCDS

2009-02-04 12:09:38

Nice Cazax!

You seem to be on top of your game lately, Keep it up.

rep+

lordsaturn

2009-02-04 23:34:02

This works fine for me:

function FindFire(var x, y: integer): Boolean;
var
P: TPointArray;
Fire, Tol, j, fx, fy: integer;
B: TBox;
a: extended;
begin
if not LoggedIn then Exit;
Debug('FindFire');
FindColorsSpiralTolerance(MSCX, MSCY, P, 3385314, MSX1, MSY1, MSX2, MSY2, 40);
RemovePointsInBox(P, PointToBox(Point(31, 4), Point(129, 24)));
if Length(P) < 10 then Exit;
Fire := BitmapFromString(1, 11, '3B3000F4C63FF8C83FF4C73EE6' +
'BC39E6BC39BC922CE6BE45BC9E38BC9E3B352A00');
Tol := 40;
B := GetTPABounds(P);
try
for j := 1 to 3 do
begin
FindDeformedBitmapToleranceIn(Fire, fx, fy, B.x1-10, B.y1-10, B.x2+10, B.y2+10, Tol, 2, True, a);
if a >= 1-j*0.2 then
begin
x := fx;
y := fy+4;
Result := True;
Exit;
end;
DecEx(Tol, 5);
end;
except
writeln('Exception');
finally
FreeBitmap(Fire);
end;
end;
;

Nava2

2009-02-14 15:09:42

From: lordsaturn
This works fine for me:

function FindFire(var x, y: integer): Boolean;
var
P: TPointArray;
Fire, Tol, j, fx, fy: integer;
B: TBox;
a: extended;
begin
if not LoggedIn then Exit;
Debug('FindFire');
FindColorsSpiralTolerance(MSCX, MSCY, P, 3385314, MSX1, MSY1, MSX2, MSY2, 40);
RemovePointsInBox(P, PointToBox(Point(31, 4), Point(129, 24)));
if Length(P) < 10 then Exit;
Fire := BitmapFromString(1, 11, '3B3000F4C63FF8C83FF4C73EE6' +
'BC39E6BC39BC922CE6BE45BC9E38BC9E3B352A00');
Tol := 40;
B := GetTPABounds(P);
try
for j := 1 to 3 do
begin
FindDeformedBitmapToleranceIn(Fire, fx, fy, B.x1-10, B.y1-10, B.x2+10, B.y2+10, Tol, 2, True, a);
if a >= 1-j*0.2 then
begin
x := fx;
y := fy+4;
Result := True;
Exit;
end;
DecEx(Tol, 5);
end;
except
writeln('Exception');
finally
FreeBitmap(Fire);
end;
end;
;


FindBitmapDeformed is really really slow AFAIK. TPA is much quicker ;)

Narcle

2009-02-14 15:44:42

Problem with IsFightAt is that it'll look horizontally to far imo. Have to have it look in a vertical way only which with a FindColor you can do ezily.

lordsaturn

2009-02-22 14:20:40

Your FindFire function doesn't find the fire very well, sorry to say.

Cazax

2009-02-22 14:37:47

I was testing with willows in draynor… Maybe the fire changes? I will test.
@Narcle: Are you talking about Distance? because it searches in a circle around the point, not any specific direction.

n3ss3s

2009-02-22 14:53:48

Well the hp functions of mine worked excellent at goblins, all I know :p

 C Y 

Happy colon expected error!

Naughty boy making fixes without even checking if they compile, eh? ;)

Cazax

2009-02-22 15:14:28

Ok, updated the findfire(hopefully). To test it:
program New;
{.include SRL/SRL.scar}

Function DebugATPA(aPoints: Array Of TPointArray; BmpName: String): Boolean; //Wizzup

Var
Width, Height, ClientBMP, I, L, C, Col: Integer;
xs, ys, xe, ye: Integer;
OuterPoints: TPointArray;

Begin
For I := 0 To High(aPoints) Do
L := L + Length(aPoints[i]);
SetLength(OuterPoints, L + 1);
C := 0;
For I := 0 To High(aPoints) Do
For L := 0 To High(aPoints[i]) Do
Begin
C := C + 1;
OuterPoints[C] := aPoints[i][L];
End;

Try
Begin
xe := xs xor xs;
ye := ys xor ys;
xs := 1 shl 20;
ys := 1 shl 20;

For I := 0 To High(OuterPoints) Do
Begin
xs := Min(xs, OuterPoints[i].X);
ys := Min(ys, OuterPoints[i].Y);

xe := Max(xe, OuterPoints[i].X);
ye := Max(ye, OuterPoints[i].Y);
End;

Width := xe - xs;
Height := ye - ys;

DisplayDebugImgWindow(0, 0);
DisplayDebugImgWindow(Width, Height);
ClientBMP := BitmapFromString(Width, Height, '');

CopyClientToBitmap(ClientBMP, xs, ys, xe, ye)
For I := 0 To High(aPoints) Do
Begin
Col := Random(16777215);
For L := 0 To High(aPoints[i]) Do
FastSetPixel(ClientBMP, aPoints[i][L].X - xs, aPoints[i][L].Y - ys, Col);
End;

SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
DisplayDebugImgWindow(Width, Height);
If BmpName <> '' Then
SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');

FreeBitmap(ClientBMP);
End
Except
FreeBitmap(ClientBMP);
End;
Result := True;
End;

Function FindFire(Var X, Y : Integer): Boolean;
Var
TPA, FP : TPointArray;
ATPA : T2DPointArray;
I, Hi : Integer;
H, S, L : Extended;
Begin
ColorToleranceSpeed(3);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 5158121, MSX1, MSY1, MSX2, MSY2, 50);
ColorToleranceSpeed(1);
If Length(TPA) = 0 Then
Exit;
Hi := High(TPA);
For I := 0 To Hi Do
Begin
ColorToHSL(GetColor(TPA[i].X, TPA[i].Y), H, S, L);
If (H > 8.0) And (H < 12.0) Then
Begin
SetLength(FP, Length(FP) + 1);
FP[High(FP)] := TPA[i];
End;
End;
If Length(FP) = 0 Then
Exit;
ATPA := TPAtoATPA(FP, 25);
DebugATPA(ATPA, '');
Hi := High(ATPA);
For I := 0 To Hi Do
Begin
If Length(ATPA[i]) >= 250 Then
Begin
MiddleTPAex(ATPA[i], X, Y);
Result := True;
Exit;
End;
End;
End;
var
x, y : integer;
begin
ActivateClient;
SetupSRL;
Wait(500);
FindFire(X, y);
Mouse(x, y, 2, 2, true);
end.

@n3s: Happy now :p?

Bebe

2009-02-22 15:30:04

If anybody can test an confirm these work at least near perfectly I'll be more than happy to add them.

lordsaturn

2009-02-23 20:18:31

With the length check included..
For I := 0 To Hi Do
Begin
If Length(ATPA[i]) < 250 Then
atpa[i] := [];
End;
debugatpa(atpa,'');

Cazax

2009-02-24 09:15:40

From: lordsaturn
With the length check included..
For I := 0 To Hi Do
Begin
If Length(ATPA[i]) < 250 Then
atpa[i] := [];
End;
debugatpa(atpa,'');

Then SRL should keep the bitmap finding… I'm removing it.

Naum

2009-02-24 11:29:50

Also DoEmote isn't compatable, Fixed it :).

procedure DoEmote(Number: Integer);
var
row, X1, Y1, X2, Y2, Others, EmoteNumber: Integer;
begin
EmoteNumber := Number;
if (not(InRange(EmoteNumber, 1, 45))) then
begin
srl_Warn('DoEmote', 'Invalid EmoteNumber: ' + IntToStr(EmoteNumber) + ', Valid Emotes: 1..45', warn_AllVersions);
Exit;
end;
GameTab(12);

if (InRange(EmoteNumber, 21, 39)) then
begin
if (GetColor(734, 442) = 3029569) then
Mouse(731, 362, 5, 5, True);
EmoteNumber := EmoteNumber - 20;
Others := 10;
end else if (GetColor(733, 224) = 3029569) then
Mouse(727, 224, 5, 5, True);

if (EmoteNumber > 40) then
Begin
Mouse(728, 444, 5, 5, True);
EmoteNumber := EmoteNumber - 28;
end;

if (EmoteNumber > 4) then
begin
repeat;
row := row + 1;
EmoteNumber := EmoteNumber - 4;
until (EmoteNumber <= 4) or (row = 12)
end;

if (row >= 5) then
row := row - 5;
EmoteNumber := EmoteNumber - 1;
X1 := 554 + (43 * EmoteNumber);
Y1 := 211 + (49 * row) + Others;
X2 := 592 + (43 * EmoteNumber);
Y2 := 257 + (49 * row) + Others;
MouseBox(X1 + 10, Y1 + 10, X2 - 10, Y2 - 10, 1);
end;