SRL Archive - SRL Archives

A bit of St00f III ;)


Naum

2009-08-18 15:36:39

Hey, I kinda got distracted from writing my tutorial, so I decided to take a break. My breaks don't consist of a walk in the park, or 15 minutes playing runescape. More likely they consist of checking the SRL Include for stuff. So yeah, the trilogy.


1) World Screen - world.scar = No x and y vars

function WorldScreen: Boolean;
var
x, y: integer;
begin
Result := FindTextTpaEx(16777215, 0, 57, 130, 162, 458, x, y, 'orld ', SmallChars, Nothing);
end;

to

function WorldScreen: Boolean;
begin
Result := FindTextTpa(16777215, 0, 57, 130, 162, 458, 'orld ', SmallChars, Nothing);
end;



2) SkillCoords Shorten:

Function SkillCoords(Row, Column : ShortInt): TPoint;
Begin
Result := Point(577 + (55 * (Column-1)), 228 + (32 * (Row-1)));
If Row = 8 Then Result.y := 419;
End;



3) GetTolerance, in Color.scar usefull for finding tolerance against two colors. Taken from Abyssal, all credits to him and noidea ;)

Function GetTol(Col1, Col2 : TColor) : Integer;
Begin
While Not SimilarColors(Col1, Col2, Result) Do Inc(Result);
End;



4) DepositScreen. No x and y variables needed. Used FindTextTPA:

Function DepositScreen : Boolean;
Begin
Result := FindTextTPA(2070783, 0, 92, 29, 396, 54, 'eposit', UpChars, Nothing);
End;



5) A FindWallColor function could be added.



6) RandomRClick, could be made much shorter:

procedure RandomRClick;
var
M: Integer;

begin
if not LoggedIn then exit;
M := MouseSpeed;
MouseSpeed := 7 + Random(5);
ActivateClient;
case Random(7) of
0: MouseBox(533, 7, 757, 200, 2);
1: MouseBox(521, 3, 553, 496, 2);
2: MouseBox(743, 3, 764, 497, 2);
3: MouseBox(4, 467, 763, 498, 2);
4: MouseBox(499, 343, 552, 496, 2);
5: MouseBox(3, 343, 521, 355, 2);
6: MouseBox(2, 346, 14, 499, 2);
end;
MouseSpeed := M;
end;

to

Procedure RandomRClick;
Var M : Byte;
Begin
If not LoggedIn then exit;
M := MouseSpeed;
MouseSpeed := 7 + Random(5);
MouseBox(MSX1, MSY1, MIX2, MIY2, 2);
Wait(RandomRange(200, 600));
MouseSpeed := M;
If Random(2) = 0 Then
ChooseOption('ancel') Else
MMouse(MSX1, MSY1, 200, 200);
End;

Changed 'M' from an integer to a Byte. There was a huge wastage of lines.



7) A BarToPoint shorten:

Function BarToPoint(Bar: String): TPoint;
Begin
Result.y := 410;
Case LowerCase(Bar) of
'bronze': Result.x := 0;
'blurite': Result.x := 1;
'iron': Result.x := 2;
'silver': Result.x := 3;
'steel': Result.x := 4;
'gold': Result.x := 5;
'mithril': Result.x := 6;
'adamant': Result.x := 7;
'runite': Result.x := 8;
Else
Begin
srl_Warn('BarToPoint', 'Invalid bar name', warn_Warning);
Result.x := -1;
End;
End;
If Result.x = -1 Then
Result := Point(0, 0)
Else
Result.x := Result.x * 50 + 53;
End;

to

Function BarToPoint(Bar: String): TPoint;
Var TSA : TStringArray;
I : Integer;
Begin
Result.y := 410;
TSA := ['bronze', 'blurite', 'iron', 'silver', 'steel', 'gold', 'mithril', 'adamant', 'runite'];
If InStrArrEx(LowerCase(Bar), TSA, I) Then
Begin
Result.x := I * 50 + 53
Exit;
End;
srl_Warn('BarToPoint', 'Invalid bar name', warn_Warning);
Result := Point(0, 0);
End;



8) Woodcutting.scar, FindBirdsNest needs MAJOR re-decoration.



9) GetCourseXP Arrayized:

function GetCourseXP(Course: string): Extended;
var
CourseXP: Extended;
begin
case LowerCase(Course) of
'agiliy dungeon ledge': CourseXP := 22.5;
'gnome course': CourseXP := 86.5;
'gnome course extra': CourseXP := 725;
'barbarian course': CourseXP := 153.2;
'barbarian course extra': CourseXP := 740.67;
'werewolves course': CourseXP := 540;
'penguin course': CourseXP := 540;
'wilderness course': CourseXP := 571.4;
'ape atoll course': CourseXP := 580;
'agility pyramid': CourseXP := 1014;
'dorgesh-kaan long(2)': CourseXP := 2750;
'dorgesh-kaan long+grapple': CourseXP := 1429;
'dorgesh-kaan grapple(2)': CourseXP := 108;
end;
Result := CourseXP;
end;

to:

Function GetCourseXP(Course: String) : Extended;
Var InfoArr : TVariantArray;
I : Integer;
Begin
InfoArr := ['agility dungeon ledge', 22.5, 'gnome course', 86.5, 'gnome course extra', 725, 'barbarian course', 153.2,
'barbarian course extra', 740.67, 'werewolves course', 540, 'penguin course', 540, 'wilderness course', 571.4,
'ape atoll course', 580, 'agility pyramid', 1014, 'dorgesh-kaan long(2)', 2750, 'dorgesh-kaan long+grapple', 1429,
'dorgesh-kaan grapple(2)', 108];
If InStrArrEx(LowerCase(Course), InfoArr, I) Then
Result := InfoArr[I+1];
end;


Fixed the spelling on one course as well.


10) FindFishingEquipment Array'ization', Fishing.scar:

function FindFishingEquipmentColor(Equipment: string): Integer;
var
TheBitmap, iX, iY: Integer;
begin
case LowerCase(Equipment) of
'smallnet': TheBitmap := srl_GetBitmap(42);
'fishingrod': TheBitmap := srl_GetBitmap(43);
'flyfishingrod': TheBitmap := srl_GetBitmap(44);
'cage': TheBitmap := srl_GetBitmap(45);
'harpoon': TheBitmap := srl_GetBitmap(46);
end;
if FindTransparentBitmapTolerance(TheBitmap, iX, iY, clBlack, MIX1, MIY1, MIX2, MIY2, 25) then
begin
WriteLn(Equipment + ' Found at (' + IntToStr(iX) + ', ' + IntToStr(iY) + ')');
Result := GetColor(iX, iY);
WriteLn('Fishing Equipment Color is ' + IntToStr(Result));
end
else Result := -1;
end;

to:

Function FindFishingEquipmentColor(Equipment : String) : Integer;
Var iX, iY: Integer;
Arr : TStringArray;
Begin
Result := -1;
Arr := ['smallnet', 'fishingrod', 'flyfishingrod', 'cage', 'harpoon'];
If InStrArrEx(LowerCase(Equipment), Arr, iX) Then
If FindTransparentBitmapTolerance(srl_GetBitmap(iX+42), iX, iY, clBlack, MIX1, MIY1, MIX2, MIY2, 25) Then
Begin
WriteLn(Equipment + ' Found at (' + IntToStr(iX) + ', ' + IntToStr(iY) + ')');
Result := GetColor(iX, iY);
WriteLn('Fishing Equipment Color is ' + IntToStr(Result));
End;
End;



11) A suggestion for Symbol bitmaps to be put in Bitmaps.scar, if anyone else wants to use it :).


Thanks for reading :)

noidea

2009-08-18 16:01:36

Nice :)

why not

Function GetTol(Col1, Col2 : TColor) : Integer;
Begin
While Not SimilarColors(Col1, Col2, Result) Do
Inc(Result);
End;

?

Naum

2009-08-18 16:08:08

From: noidea
Nice :)

why not

Function GetTol(Col1, Col2 : TColor) : Integer;
Begin
While Not SimilarColors(Col1, Col2, Result) Do
Inc(Result);
End;

?


Yeah, why not? Thanks for the comment, the function was ripped directly from Abyssals script btw.

EDIT: <3 EC, used InStrArrEx instead of looping through, saves time :). However, all of the byte's needed to be changed back to integer's so there weren't any type mismatches.

Nava2

2009-08-18 19:33:03

function GetTol(Col1, Col2 : TColor; CTS: Integer) : Integer;
var
c: Integer;
begin
c := GetColorToleranceSpeed;
ColorToleranceSpeed(CTS);
while not SimilarColors(Col1, Col2, Result) do
Inc(Result);
ColorToleranceSpeed(c);
end;

marpis

2009-08-18 20:39:06

Nielsie made an incredibly accurate GetWallColors: TIntegerArray, but i couldn't find the thread anymore…

Naum

2009-08-18 21:40:42

From: marpis
Nielsie made an incredibly accurate GetWallColors: TIntegerArray, but i couldn't find the thread anymore…


If the section goes over 20 pages of threads, then you can't find it anymore.

Thanks for the comments though :)

Sabzi

2009-08-18 22:28:13

From: marpis
Nielsie made an incredibly accurate GetWallColors: TIntegerArray, but i couldn't find the thread anymore…


This one?
http://www.villavu.com/forum/showpost.php?p=567641&postcount=17
I gave it a shoot because I like searching through the forum :D

marpis

2009-08-19 00:41:05

From: Sabzi
This one?
http://www.villavu.com/forum/showpost.php?p=567641&postcount=17
I gave it a shoot because I like searching through the forum :D


Yes that's it! :) Should totally be committed!

EDIT: rep++ to Sabzi, I badly need that function to my RC script :p

Abyssal

2009-08-19 05:46:56

From: NaumanAkhlaQ
3) GetTolerance, in Color.scar usefull for finding tolerance against two colors. Taken from Abyssal, all credits to him and noidea ;)


Much appreciated, ;)

noidea

2009-08-19 06:01:41

wat

Thats Awesome thanks :)

Naum

2009-08-19 19:03:46

From: Abyssal
Much appreciated, ;)


Yeah thanks for that :).

@ Nava2 I made that for direct comparison in something like a fighting script:

Begin
If GetTol(UpdateCol[I], GlobalCol) < 16 Then
AddToArray
Else
Inc(I);

EvilChicken!

2009-08-23 11:58:02

I did as I promised! ^__^

Fixed:
1, 2, 6, 7, 10.

#2: It's looking great – but I haven't tested it, so I REALLY hope it works.
#3: There already IS a GetTolerance in SCAR, it's called GetTol.
#5: I'll test Nielsie's function to see if it still works.
#6: Spiced up. Always annoyed me, thanks for reminding.
#7: Nice. :) Though, haven't tested it, soo. Don't disappoint me?
#8 and #5; I'll look into it. Remind me of it if I forget.
#10: Same as #7.

ZephyrsFury

2009-08-23 12:33:04

In the modified RandomRClick you need to make sure the menu actually gets closed. Random point on the minimap might be on the menu itself and moving the mouse there wouldn't close the menu then then things start failing.

Naum

2009-08-23 14:40:19

From: EvilChicken!
I did as I promised! ^__^

Fixed:
1, 2, 6, 7, 10.

#2: It's looking great – but I haven't tested it, so I REALLY hope it works.
#3: There already IS a GetTolerance in SCAR, it's called GetTol.
#5: I'll test Nielsie's function to see if it still works.
#6: Spiced up. Always annoyed me, thanks for reminding.
#7: Nice. :) Though, haven't tested it, soo. Don't disappoint me?
#8 and #5; I'll look into it. Remind me of it if I forget.
#10: Same as #7.


Thanks :).

10 mainly works, theoretically speaking. I think that mainly because FindFishingEquipment was only tried with a: cage, fishing rod and fly fishing rod. It found all three nicely :).

Debugging shows, comparing it with the last function, 7 would work as it outputs the same co-ordinates as the previous prototype. However, saying that, it has not been tested during runtime.

Believe me number 2 does work :D.

What about number 4 and 9. I'd appreciate some feedback on that as well, if you don't decide to commit it; please fix the
'agiliy dungeon ledge': CourseXP := 22.5;

to:

'agility dungeon ledge': CourseXP := 22.5;

As wizzup? pointed before, on another thread I think.


@Zeph, Yeah, that's gone though in the new beef'd up version (that sound wrong, lol :p).

Sabzi

2009-08-24 02:19:27

If you were doing something with FindXp.scar why didn't you fixed ConvertXpToLvl ?
To this:

function ConvertXpToLvl(xp: Integer): Integer;
var
level, exp: Integer;
begin
for level := 1 to 99 do
begin
exp := exp + Trunc(level + 300 * Pow(2, level / 7));
if ((exp / 4) > xp) then
begin
Result := level;
Exit;
end;
end;
Result := 99;
end
just added exp +. Look into ConvertLvlToXP that's the same.(I mean it's right so ConvertXpToLvl should follow that)
And it's not just theory. I have used it because GetSkillLevel sometimes returns inaccurate result if our level is 1x. Also I think that could be fixed with decreasing the maxspacing to 3 in the correct place(GetTextAtEx). I have tested that but not enough. So it's weak, just an idea. And I don't know why it's working better with less maxspacing. I mean it's not just simple "spacing". It should be between min and max spacing to return the correct values, no? If someone could make me understand this would be great.

Sir R. M8gic1an

2009-09-08 15:33:32

the ones that used case and you changed to using InStrArrEx, i suspect they will be slower your way.

~RM

nielsie95

2009-09-08 16:12:22

Plus it uses more (unnecessary) memory and it's harder to read.