SRL Archive - SRL Archives

Taking procedure requests


Rich

2009-08-27 12:38:33

I'm taking procedure and function requests. Just post here and I'll get back to you.

However:
- Must be realistic
- Must be useful in some way
- I can say no to doing it
- I get credits for making
- You get credits for the idea

Richard.

Laimonas171

2009-08-27 13:07:28

Draynor woodcutting, fishing and Willow Firemaking Procedures please.(No Reflection pls.. :)
first Post Btw. (Y)

Procedure cut;
begin
//woodcutting Willows..
end;

Procedure FmWillow;
Begin
//Fire the willow log.
End;

Procedure Fishing;
begin
//Fish Small Net. f2p
end;

Rich

2009-08-27 13:19:20

Hmm, I didn't have single-area functions in mind. However, since you're the first post, I'll see what I can do. Could you be a bit more specific on what you want to functions to do though please?

Richard.

Laimonas171

2009-08-27 13:23:58

1.I just need find willow tree chop it.

2.Also find fishing spot and fish Net kind.


I can make FM part myself i thought. just say how to find last msg. in chat.

Rich

2009-08-27 13:31:38

Can't do Number 1:
Please use common sense and don\'t post obscure useless functions/procedures. (ex. FindCabage)
Try making a TPA to find the tree.

___________________________________________________________________________-

{*******************************************************************************
Function FindFishingEquipmentColor(Equipment: String): Integer;
By: Dankness, rewritten by Wizzup? and edit by NaumanAkhlaQ
Description: Finds Net, Lobster Cage, Fishing Rod, Fly Fishing Rod or Harpoon color.
*******************************************************************************}

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
begin
if FindTransparentBitmapTolerance(srl_GetBitmap(iX + 42), iX, iY, clBlack, MIX1, MIY1, MIX2, MIY2, 25) then
begin
Result := GetColor(iX, iY);
srl_Warn('FindFishingEquipmentColor', 'Equipment found at ' + IntToStr(iX) +
', ' + IntToStr(iY) + '. Found color: ' + IntToStr(Result) + '.', warn_Debug);
end;
end else
srl_Warn('FindFishingEquipmentColor', '"' + Equipment + '" is an invalid equpment name!', warn_AllVersions);
end;

{*******************************************************************************
Function FindFishSpotsTPA(var VTPA:TPointArray):boolean;
By: Rasta Magician
Description: Finds all possible Fish Spots and stores them in the given TPA
Returns true if found at least one, false if none
*******************************************************************************}
Function FindFishSpotsTPA(var VTPA:TPointArray):boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
i, tmpCTS, VTPASize: Integer;
TP: TPoint;
begin
Result := False;
if (not LoggedIn) then exit;

tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.12, 0.27);

FindColorsSpiralTolerance(MSCX, MSCY, TPA, 11379611, MSX1, MSY1, MSX2, MSY2, 11);

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (Length(TPA) < 1) then exit;

VTPASize := 1;
SetLength(VTPA, 1);

ATPA := SplitTPA(TPA, 10);
SortATPAFrom(ATPA, Point(MSCX, MSCY));
for i := 0 to High(ATPA) do
begin
TP := MiddleTPA(ATPA[i]);

if FindWhirlPoolXY(TP.x, TP.y) then Continue;

VTPA[VTPASize - 1] := TP;
Inc(VTPASize);
SetLength(VTPA, VTPASize);
end;

Result := (VTPASize > 1);
end;

{*******************************************************************************
Function FindFishSpot(var xx, yy: integer; which: string): Boolean;
By: Rasta Magician
Description: Finds a fishing spot, according to your needs.
Stores (x, y) coordinates to the given variables.
which:
'harpoon' -> Harpoon fishing
'cage', 'lobster' -> Cage Fishing
'fly', 'flyfish' -> Fly Fishing
'rod', 'bait' -> Bait Fishing
'net' -> Net Fishing
*******************************************************************************}
Function FindFishSpot(var X, Y: Integer; Which: string): Boolean;
var
TPA: TPointArray;
s: string;
i: integer;
begin
if (not FindFishSpotsTPA(TPA)) then exit;

case lowercase(which) of
'harpoon': S := 'arpoon Fis';
'cage', 'lobster': S := 'age Fis';
'fly', 'flyfish': S := 'ure Fis';
'rod', 'bait': S := 'ait Fis';
'net': S := 'et Fis';
end;

for i := 0 to High(TPA) do
begin
MMouse(TPA[i].x, TPA[i].y, 5, 5);
if WaitUpText(S, 375) then
begin
GetMousePos(X, Y);
Wait(Random(100));
Result := True;
Exit;
end else
begin
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
if WaitOptionEx(S, 'all', Nothing, 375) then
begin
ChooseOption('ancel');
Result := True;
Exit;
end;
ChooseOption('ancel');
end;
end;
end;

Look through the includes. All the functions here are from them.

__________________________________________________________________

{*******************************************************************************
function FindBlackChatMessage(ChatMsg: String): Boolean;
By: Wizzup?
Description: Returns True if text with color 0 in last chat line is found.
*******************************************************************************}

function FindBlackChatMessage(ChatMsg: string): Boolean;
begin
Result := (Pos(ChatMsg, GetChatBoxText(8, clMessage)) > 0);
end;
You would use it like
if FindBlackChatMessage('logs on fire -or w/e it is-') then
BurnLogs;

Richard.

Laimonas171

2009-08-27 13:36:34

Ty. So i can find all that stuff on Core folder?

Rich

2009-08-27 13:38:54

The Fishing functions are in skill\fishing.scar, and GetBlackChatMessage is in core\chat.scar. Have a look around in the includes folder. You'll be surprised at what you can find.

Laimonas171

2009-08-27 13:46:30

From: R1ch
The Fishing functions are in skill\fishing.scar, and GetBlackChatMessage is in core\chat.scar. Have a look around in the includes folder. You'll be surprised at what you can find.


Ok ty again. i will try to study includes. Folder and sub folders source. Also I will rep++ you right now.

Rich

2009-09-09 22:37:38

From: R1ch on 27th August
No problem. Glad I could help.

Anyone else want any functions made for them?

Richard


—————————————————————-

I'm still doing this in case anyone wants anything made.

Main

2009-09-10 04:54:47

In random?

Lance

2009-09-10 05:46:56

Could you make a new ChooseOption function that is something like this..


function ChooseOptionEx(TextToClick : String) : Boolean;
begin
case Random(30) do
0: //Go to far and mouse over the option below the text, then recorect it
1: //Go not far enough and mouse over the option above it, then quickly recorecting it
2: //Go to far and choose 'examine' then, the function would return false
3..30: //Choose the option
end;
end;

then if the function returns false, the scripter can make it run the function again like..
repeat
Wait(500);
until(ChooseOptionEx('use'));

I think its a good idea :P considering realisticaly no one clicks purfectly every time they try to choose an option.

Edit: Btw, srl still fails randoms. If you really wanna be a hero you could help develope the reflection antirandoms. IMO the randoms can sucsessfuly do everything, they just seem to always get confused as to which step of the random they have to do (like thinking there not finished when they are)

what would be kinda cool is if you changed the antirandoms so that at every time it talks to the npc, it checks what it is saying. And each step of compleating the random, if the npc isnt saying the right thing it will go back to the propper step

Rich

2009-09-10 10:52:17

From: Main_Ftw
In random?


Isn't something like that in FindNormalRandoms?

From: Lance
Could you make a new ChooseOption function that is something like this..

Code:
[LEFT]function ChooseOptionEx(TextToClick : String) : Boolean;
begin
case Random(30) do
0: //Go to far and mouse over the option below the text, then recorect it
1: //Go not far enough and mouse over the option above it, then quickly recorecting it
2: //Go to far and choose 'examine' then, the function would return false
3..30: //Choose the option
end;
end;
[/LEFT]


then if the function returns false, the scripter can make it run the function again like..
Code:
[LEFT]repeat
Wait(500);
until(ChooseOptionEx('use'));
[/LEFT]


I think its a good idea :P considering realisticaly no one clicks purfectly every time they try to choose an option.

Edit: Btw, srl still fails randoms. If you really wanna be a hero you could help develope the reflection antirandoms. IMO the randoms can sucsessfuly do everything, they just seem to always get confused as to which step of the random they have to do (like thinking there not finished when they are)

what would be kinda cool is if you changed the antirandoms so that at every time it talks to the npc, it checks what it is saying. And each step of compleating the random, if the npc isnt saying the right thing it will go back to the propper step


I'll give that a go later on, when I get back from school. And I don't think I'll do the anti-randoms part; I only script in colour.

Richard.

senrath

2009-09-10 11:36:38

A function to tell if a spell is selected would be awesome.

Rich

2009-09-10 19:51:33

Going to do what Lance wanted now…Should be easy.

Senrath, I know it's not exactly what you want, but this may help. I'll check out exactly what you want later on.

Richard.

EDIT: Not as easy as I thought… :S

Pure1993

2009-09-10 20:39:57

From: R1ch
Going to do what Lance wanted now…Should be easy.

Senrath, I know it's not exactly what you want, but this may help. I'll check out exactly what you want later on.

Richard.

EDIT: Not as easy as I thought… :S


LOL? ^^
It is quite easy… simply modify ChooseOptionMultiEx to ouput the coords of the option and edit the clicking out, and then create a function which clicks…
I have already done it a while ago for a personal script… shall I post it and ruin the fun or should I wait? :p

Edit: of course you can combinde those two functions into one, but i like to keep them seperate :)

Rich

2009-09-10 22:45:19

From: Pure1993
LOL? ^^
It is quite easy… simply modify ChooseOptionMultiEx to ouput the coords of the option and edit the clicking out, and then create a function which clicks…
I have already done it a while ago for a personal script… shall I post it and ruin the fun or should I wait? :p

Edit: of course you can combinde those two functions into one, but i like to keep them seperate :)


My brain wasn't quite working when I posted that, but I just thought of what you said a minute ago - no lie. I'll do it now. You can post yours if you want.

Pure1993

2009-09-10 23:05:52


program MyMouse;
{.include srl/srl.scar}

function GetChooseOptionMultiExPosition(Texts: TStringArray; TextType: String): TBox;
var
B: TBox;
TPA, TextTPA: TPointArray;
aTPA: T2DPointArray;
I, C, H, HH, ii, L: Integer;
P: TPoint;
Occurances: array [0..4] of TPointArray;
Colors: TIntegerArray;
begin
GetClientDimensions(B.X2, B.Y2);
B.X1 := 0;
B.Y1 := 0;
SetLength(aTPA, 2);
FindColorsTolerance(aTPA[0], 4409686, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(aTPA[1], 4016722, B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := MergeATPA(aTPA);
SetLength(aTPA, 0);
If Length(TPA) < 10 Then
Exit;
B.X2 := 0;
B.Y2 := 0;

P := TPA[0];
H := High(TPA);
Dec(H);
For I := 0 To H Do
If TPA[i].X = TPA[I+1].X - 1 Then
Begin
If C > 5 Then
Begin
B.X1 := P.X;
B.Y1 := P.Y;
Break;
End Else
C := C + 1;
End
Else
Begin
P := TPA[I + 1];
C := 0;
End;
If I = Length(TPA) Then
Begin
WriteLn('Choose Option Menu Getting Failed');
Exit;
End;
InvertTPA(TPA);
C := 0;
P := TPA[0];
H := High(TPA);
Dec(H);
For I := 0 To H Do
If TPA[i].X = TPA[I+1].X + 1 Then
Begin
If C > 5 Then
Begin
B.X2 := P.X;
B.Y2 := P.Y;
Break;
End Else
C := C + 1;
End Else
Begin
P := TPA[I + 1];
C := 0;
End;
If I = Length(TPA) Then
Begin
WriteLn('Choose Option Menu Getting Failed');
Exit;
End;

TPA := [];
Colors := [13034990, 4231423, 2070783, 65535, 16776960, 9812166];
TextType := LowerCase(TextType);
case TextType of
'action', 'player': begin
FindColorsTolerance(Occurances[0], Colors[0], B.x1, B.y1, B.x2, B.y2, 3);
FindColorsTolerance(Occurances[1], Colors[5], B.x1, B.y1, B.x2, B.y2, 3);
end;
'item' : begin
FindColorsTolerance(Occurances[1], Colors[1], B.x1, B.y1, B.x2, B.y2, 3);
FindColorsTolerance(Occurances[2], Colors[2], B.x1, B.y1, B.x2, B.y2, 3);
end;
'npc' : FindColorsTolerance(Occurances[3], Colors[3], B.x1, B.y1, B.x2, B.y2, 3);
'object': FindColorsTolerance(Occurances[4], Colors[4], B.x1, B.y1, B.x2, B.y2, 3);
else
begin
FindColorsTolerance(Occurances[0], 1845035, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(Occurances[1], clBlack, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(Occurances[2], 6121839, B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := MergeATPA(Occurances);

ClearDoubleTPA(TPA);
TPA := ReturnPointsNotInTPA(TPA, B);
end;
end;
if High(TPA) < 1 then TPA := MergeATPA(Occurances);
aTPA := SplitTPAEx(TPA, 7, 1);
SortATPAFromFirstPoint(aTPA, Point(B.x1, B.y1));

H := High(Texts);
L := High(aTPA);

For I :=0 To H do
begin
TextTPA := LoadTextTPA(Texts[i], UpChars, HH);
for ii := 0 to L do
If FindTextTPAInTPA(HH, TextTPA, aTPA[ii], TPA) Then
Begin
Result := IntToBox(B.x1 + 5, TPA[0].Y, B.x2 - 5, TPA[0].Y + 5);
Writeln('B.x1 + 5 = '+inttostr(B.x1 + 5));
Writeln('B.x2 - 5 = '+inttostr(B.x2 - 5));
Writeln('TPA[0].Y = '+inttostr(TPA[0].Y));
Writeln('TPA[0].Y + 5 = '+inttostr(TPA[0].Y + 5));
Exit;
End;
end;

MMouse(B.X1 - 50, B.Y1 - 50, 40, B.Y2 - B.Y1);
Wait(200 + Random(100));
end;

function P_ChooseOption( option : string): Boolean;
var
theBox : TBox;
begin
TheBox := GetChooseOptionMultiExPosition([option],'all');
case random(20) of
0: begin
MouseBox( TheBox.x1, TheBox.y1 + 9, TheBox.x2, TheBox.y2 + 9, 1); // too far down
Result := False;
end;
1: begin
MouseBox( TheBox.x1, TheBox.y1 - 9, TheBox.x2, TheBox.y2 - 9, 1); // too far up
Result := False;
end;
2..19: begin
Result := True;
MouseBox( TheBox.x1, TheBox.y1, TheBox.x2, TheBox.y2, 1); // clicks properly
end;
end;
end;

begin
MouseSpeed := 15;
Mouse( msx1+200, msy1+150, 0, 0, false);
wait(500);
while not P_ChooseOption('alk') do
begin
Mouse( msx1+200, msy1+150, 0, 0, false);
Wait(500);
end;
end.

guess it can be combined into:

program MyMouse;
{.include srl/srl.scar}

function P_ChooseOptionMulti( texts : TstringArray; Debug : Boolean): Boolean;
var
theBox : TBox;
B: TBox;
TPA, TextTPA: TPointArray;
aTPA: T2DPointArray;
I, C, H, HH, ii, L: Integer;
P: TPoint;
Occurances: array [0..4] of TPointArray;
Colors: TIntegerArray;
begin
GetClientDimensions(B.X2, B.Y2);
B.X1 := 0;
B.Y1 := 0;
SetLength(aTPA, 2);
FindColorsTolerance(aTPA[0], 4409686, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(aTPA[1], 4016722, B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := MergeATPA(aTPA);
SetLength(aTPA, 0);
If Length(TPA) < 10 Then
Exit;
B.X2 := 0;
B.Y2 := 0;

P := TPA[0];
H := High(TPA);
Dec(H);
For I := 0 To H Do
If TPA[i].X = TPA[I+1].X - 1 Then
Begin
If C > 5 Then
Begin
B.X1 := P.X;
B.Y1 := P.Y;
Break;
End Else
C := C + 1;
End
Else
Begin
P := TPA[I + 1];
C := 0;
End;
If I = Length(TPA) Then
Begin
WriteLn('Choose Option Menu Getting Failed');
Exit;
End;
InvertTPA(TPA);
C := 0;
P := TPA[0];
H := High(TPA);
Dec(H);
For I := 0 To H Do
If TPA[i].X = TPA[I+1].X + 1 Then
Begin
If C > 5 Then
Begin
B.X2 := P.X;
B.Y2 := P.Y;
Break;
End Else
C := C + 1;
End Else
Begin
P := TPA[I + 1];
C := 0;
End;
If I = Length(TPA) Then
Begin
WriteLn('Choose Option Menu Getting Failed');
Exit;
End;

TPA := [];
Colors := [13034990, 4231423, 2070783, 65535, 16776960, 9812166];
FindColorsTolerance(Occurances[0], 1845035, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(Occurances[1], clBlack, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(Occurances[2], 6121839, B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := MergeATPA(Occurances);

ClearDoubleTPA(TPA);
TPA := ReturnPointsNotInTPA(TPA, B);
if High(TPA) < 1 then TPA := MergeATPA(Occurances);
aTPA := SplitTPAEx(TPA, 7, 1);
SortATPAFromFirstPoint(aTPA, Point(B.x1, B.y1));

H := High(Texts);
L := High(aTPA);

For I :=0 To H do
begin
TextTPA := LoadTextTPA(Texts[i], UpChars, HH);
for ii := 0 to L do
If FindTextTPAInTPA(HH, TextTPA, aTPA[ii], TPA) Then
Begin
TheBox := IntToBox(B.x1 + 5, TPA[0].Y, B.x2 - 5, TPA[0].Y + 5);
if Debug then
begin
Writeln('B.x1 + 5 = '+inttostr(B.x1 + 5));
Writeln('B.x2 - 5 = '+inttostr(B.x2 - 5));
Writeln('TPA[0].Y = '+inttostr(TPA[0].Y));
Writeln('TPA[0].Y + 5 = '+inttostr(TPA[0].Y + 5));
end;
Wait(200 + Random(100));
case random(20) of
0: begin
MouseBox( TheBox.x1, TheBox.y1 + 9, TheBox.x2, TheBox.y2 + 9, 1); // too far down
Result := False;
Exit;
end;
1: begin
MouseBox( TheBox.x1, TheBox.y1 - 9, TheBox.x2, TheBox.y2 - 9, 1); // too far up
Result := False;
Exit;
end;
2..19: begin
Result := True;
MouseBox( TheBox.x1, TheBox.y1, TheBox.x2, TheBox.y2, 1); // clicks properly
Exit;
end;
end;
end;
end;
MMouse(B.X1 - 50, B.Y1 - 50, 40, B.Y2 - B.Y1);
end;

function P_ChooseOption( Option : string): Boolean;
begin
Result := P_ChooseOptionMulti( [option], True );
end;

begin
MouseSpeed := 15;
Mouse( msx1+200, msy1+150, 0, 0, false);
wait(200);
while not P_ChooseOption('alk') do
begin
Mouse( msx1+200, msy1+150, 0, 0, false);
Wait(200);
end;
end.

I personally like the second one more for usage, but the first one is easier to play around with…

Credits, of course, go to Wizzup?, Nava2, and N1ke! for developing ChooseOptionMultiEx, which this function is based on. :D

Rich

2009-09-10 23:16:09

Well, I was working on it, but there you go Lance :p

Thanks Pure,
Richard.

Pure1993

2009-09-11 00:26:40

From: R1ch
Well, I was working on it, but there you go Lance :p

Thanks Pure,
Richard.


rofl, np, and thanks for giving me an opportunity to share this… xD :garfield:


Edit (don't want to make another spam post xD) :
From: R1ch
You could have posted them anyway, couldn't you? Rep +

Richard.


Nah, too little of that is made by myself… wouldn't have felt right to open up a new thread only to post some modified code which any mod/dev/user could have done just as well with a bit of thinking… but thanks for the repp anyway :D

Rich

2009-09-11 00:32:23

You could have posted them anyway, couldn't you? Rep +

Richard.