NJChronos
2012-01-11 11:59:32
:frusty: i attemped to replace the Text.simba file like harry said in another post, and im still getting same results? anyone have a fix? :frusty:
i changed the Text.Simba file in this folder C:\Simba\Includes\SRL\srl\core
was i right wrong?
(*
Text
====
The Text include contains all sorts of functions used for finding, analysing and
using text in RS. It also contains a few useful input routines
*)
{ var OldLine,TheLine, TheName: String;
Description: ChatLog vars. }
var
OldLine, TheLine, TheName: string;
{ const clMessage, clChat, clTrade, clFriend
Description: Text colour constants. }
const
clMessage = clBlack;
clAssist = 14822282;
clChat = clBlue;
clTrade = clPurple;
clFriend = 128;
{ type TOptions
Descripts: Choose option record. }
Type
TOptions = Record
Str: string;
Bounds: TBox;
end;
function CloseBank: Boolean; Forward;
(*
srl_Explode
~~~~~~~~~~~
.. code-block:: pascal
function srl_Explode(str, del: string): TStringArray;
Explodes a string into TStringArray, seperated by del.
.. note::
by mixster
Example:
.. code-block:: pascal
*)
function srl_Explode(str, del: string): TStringArray;
begin
Result := Explode(del, str);
end;
(*
srl_Implode
~~~~~~~~~~~
.. code-block:: pascal
function srl_Implode(Pieces: TStringArray; Glue: string): string;
Combines Pieces in a single string seperated by Seperator
.. note::
by ZephyrsFury & mixster
Example:
.. code-block:: pascal
*)
function srl_Implode(Pieces: TStringArray; Glue: string): string;
begin
Result := Implode(glue, pieces);
end;
(*
TypeByte
~~~~~~~~
.. code-block:: pascal
procedure TypeByte(k: Byte);
Types one character k.
.. note::
by Mutant Squirrle
Example:
.. code-block:: pascal
*)
procedure TypeByte(k: Byte);
begin
KeyDown(k);
Wait(10 + Random(50));
KeyUp(k);
end;
(*
TypeSendEx
~~~~~~~~~~
.. code-block:: pascal
procedure TypeSendEx(Text : string; PressEnter : Boolean);
Types text in a human-like way.
.. note::
by SKy Scripter
Example:
.. code-block:: pascal
*)
procedure TypeSendEx(Text: string; PressEnter: Boolean);
var
S: string;
I, L: Integer;
Shift: Boolean;
begin
S:= 'ABCDEFGHIJKLMNOPQRSTUVWXZ' + '~!@#$%^&*()_+{}|:"<>?';
L := Length(Text);
for I := 1 to L do
begin
Shift := (Pos(Text[i], S) > 0);
if (Shift) then
begin
KeyDown(VK_SHIFT);
Wait(40 + Random(40));
while (Pos(Text[i], S) > 0) and (I <= Length(Text)) do
begin
TypeByte(GetKeyCode(Text[I]));
Wait(40 + Random(40));
Inc(I);
if (I > Length(Text)) then Break;
end;
end;
if (Shift) then
KeyUp(VK_SHIFT);
Wait(40 + Random(40));
if (I <= Length(Text)) then
begin
TypeByte(GetKeyCode(Text[I]));
Wait(40 + Random(40));
end;
end;
if (PressEnter) then
TypeByte(GetKeyCode(Chr(13)));
end;
(*
TypeSend
~~~~~~~~
.. code-block:: pascal
procedure TypeSend(Text : string);
Types Text in a human-like way and presses enter. Wrapper function for TypeSendEx
for compatibility purposes.
.. note::
by N1ke!
Example:
.. code-block::pascal
*)
procedure TypeSend(Text: string);
begin
TypeSendEx(Text, True);
end;
(*
AddMistakes
~~~~~~~~~~~
.. code-block:: pascal
function AddMistakes(Orig: string; Chance: Integer): string;
Adds human mistakes to Orig such as mistypes, missing letters,
wrong cases. Probability that a character is typed wrong is 1 / Chance. ie.
Higher 'Chance' = less mistakes (I know thats stupid but oh well...).
Probability is the chance that an individual character is typed incorrectly.
That is if you have more characters in a string you will get more mistakes overall.
20 - 30 is usually good but it varies depending on your string so experiment!
.. note::
by Zephyrsfury
Example
.. code-block:: pascal
*)
function AddMistakes(Orig: string; Chance: Integer): string;
var
Line1, Line2, Line: array [0..3] of string;
i, j, TPos, Prob, Mist, L: Integer;
Norm, Caps, Excp, TLine, NewKey: string;
begin
Result := '';
Norm := '`1234567890-=qwertyuiop[]\asdfghjkl;''zxcvbnm,./';
Caps := '~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?';
Excp := '`1234567890-=[]\;'',./~!@#$%^&*()_+{}|:"<>?';
Line1[0] := '`1234567890-= '; Line2[0] := '~!@#$%^&*()_+ ';
Line1[1] := ' qwertyuiop[]\'; Line2[1] := ' QWERTYUIOP{}|';
Line1[2] := ' asdfghjkl;'' '; Line2[2] := ' ASDFGHJKL:" ';
Line1[3] := ' zxcvbnm,./ '; Line2[3] := ' ZXCVBNM<>? ';
L := Length(Orig);
for i := 1 to L do
begin
Prob := Chance;
Prob := Prob + Mist; //More mistakes = less chance of another mistake
if (Pos(Orig[i], Excp) <> 0) then Prob := Prob - 2; //If char is hard to type (numbers/symbols) - more chance
if (i = 1) then Prob := Prob + 5; //The first letter - less chance
if (Orig[i] <> ' ') and (Random(Max(Prob, 0)) = 0) then
begin
if (Pos(Orig[i], Norm) <> 0) then
Line := Line1
else
if (Pos(Orig[i], Caps) <> 0) then
Line := Line2;
for j := 0 to 3 do
begin
TPos := Pos(Orig[i], Line[j]);
if (TPos <> 0) then
case Random(19) of
0..5: //Same line
begin
TLine := Line[j];
try
NewKey := TLine[TPos - 1 + Random(3)];
except end;
if (NewKey = '') or (NewKey = ' ') then
NewKey := TLine[TPos];
end;
6..8: //Line above
begin
TLine := Line[Max(j - 1, 0)];
try
NewKey := Line[j - 1][TPos + Random(2)];
except end;
if (NewKey = '') or (NewKey = ' ') then
NewKey := TLine[TPos];
end;
9..11: //Line below
begin
TLine := Line[Min(j + 1, High(Line))];
try
NewKey := TLine[TPos - 1 + Random(2)]; //Wrong case
except end;
if (NewKey = '') or (NewKey = ' ') then
NewKey := TLine[TPos];
end;
12..16:
begin
if (i - 1 >= 1) then
begin
if (Pos(Orig[i - 1], Caps) <> 0) then
NewKey := Line2[j][TPos]
else
if (Pos(Orig[i - 1], Norm) <> 0) then
NewKey := Line1[j][TPos]
end else
if (i + 1 <= Length(Orig)) then
begin
if (Pos(Orig[i + 1], Caps) <> 0) then
NewKey := Line2[j][TPos]
else
if (Pos(Orig[i + 1], Norm) <> 0) then
NewKey := Line1[j][TPos];
end;
end;
17, 18: if (i <> 1) then NewKey := ''; //Missing letters
end;
end;
end else
NewKey := Orig[i];
if (NewKey <> Orig[i]) then Inc(Mist);
Result := Result + NewKey;
end;
end;
(*
GetUpText
~~~~~~~~~
.. code-block:: pascal
function GetUpText : string;
Returns the text in the upperleft corner (often referred to as UpText).
.. note::
by Simba Development Team.
Example:
.. code-block:: pascal
*)
function GetUpText: string;
begin
Result := rs_GetUpText
end;
(*
IsUpTextEx
~~~~~~~~~~
.. code-block:: pascal
function IsUpTextEx(Text: String): Boolean;
Checking uptext using wildcards
.. note::
by Frement
Example:
.. code-block:: pascal
*)
function IsUpTextEx(Text: String): Boolean;
begin
Text := Replace(Text, '?', '.');
Result := ExecRegExpr('.*'+Text+'.*', GetUpText);
end;
(*
IsUpTextRe
~~~~~~~~~~
.. code-block:: pascal
function IsUpTextRe(RegEx: String): Boolean;
Checking uptext using regex
.. note::
by Frement
Example:
.. code-block:: pascal
*)
function IsUpTextRe(RegEx: String): Boolean;
begin
Result := ExecRegExpr(RegEx, GetUpText);
end;
(*
IsUpText
~~~~~~~~
.. code-block:: pascal
function IsUpText(UpText : string) : Boolean;
Returns True if there is currently Uptext on the screen
.. note::
by Simba Development Team.
Example:
.. code-block:: pascal
*)
function IsUpText(UpText: string): Boolean;
begin
Result := (Pos(UpText, GetUpText) > 0);
end;
(*
IsUpTextMultiCustom
~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function IsUpTextMultiCustom(Text: TStringArray): Boolean;
Checks for the occurance of any of the strings in the array.
.. note::
by Starblaster100 & Nielsie95 & Freddy1990
Example:
.. code-block:: pascal
IsUpTextMultiCustom(['Att', 'ttac', 'ack', 'monst', 'ster'])
*)
function IsUpTextMultiCustom(Text: TStringArray): Boolean;
var
TheText: string;
i, n: Integer;
begin
TheText := GetUpText;
n := High(Text);
for i := 0 to n do
if (Pos(Text[i], TheText) > 0) then
begin
Result := True;
Exit;
end;
end;
(*
GetLevelAtPos
~~~~~~~~~~~~~
.. code-block:: pascal
function GetLevelAtPos(x, y : integer) : integer;
Returns the level of the characater found at (x, y), uses uptext. Returns -1 if
none are found.
.. note::
by marpis and Nava2
Example:
.. code-block:: pascal
*)
function GetLevelAtPos(x, y: Integer): integer;
begin
MMouse(x, y, 0, 0);
Wait(RandomRange(80, 150));
Result := StrToIntDef(Between('l: ', ')', GetUpText), -1);
end;
(*
FindText
~~~~~~~~
.. code-block:: pascal
function FindText(var cx, cy: Integer; txt,font: string; xs, ys, xe, ye: Integer): Boolean;
Searches for text in specified box with specified font.
.. note::
by Stupid3ooo
Example:
.. code-block:: pascal
*)
function FindText(var cx, cy: Integer; txt,font: string; xs, ys, xe, ye:
Integer): Boolean;
var
S: Integer;
begin
S := CreateBitmapMaskFromText(txt, font);
if (xs < 0) then xs := 0;
if (ys < 0) then ys := 0;
Result := FindBitmapMaskTolerance(S, cx, cy, xs, ys, xe, ye, 30, 30);
FreeBitmap(S);
end;
(*
ClickText
~~~~~~~~~
.. code-block:: pascal
function ClickText(Text, Chars: string;x1, y1, x2, y2: Integer; button: variant): Boolean;
Clicks Text if found in the specified box.
.. note::
by SKy Scripter
Example
.. code-block:: pascal
*)
function ClickText(Text, Chars: string;x1, y1, x2, y2: Integer; button: variant): Boolean;
var
Mask, w, h, tx, ty: Integer;
begin
try
Mask:= CreateBitmapMaskFromText(Text, Chars);
except
srl_Warn('ClickText', 'Invalid Character Names', warn_AllVersions);
Exit;
end;
Result:= FindBitmapMaskTolerance(Mask, tx, ty, x1, y1, x2, y2, 10, 10);
GetBitmapSize(Mask, W, H);
FreeBitmap(Mask);
if(Result)then
Mouse(TX + (W div 4), TY + (H div 4), (W div 2), (H div 2), button);
end;
(*
LoadTextTPA
~~~~~~~~~~~
.. code-block:: pascal
Function LoadTextTPA(Text : String; Chars : Integer;var height : integer) : TPointArray;
Loads a TPA of the text.. It also returns the real height of the Text. Used in FindTextTPAinTPA.
.. note::
by Raymond
Example
.. code-block:: pascal
*)
function LoadTextTPA(Text, Chars: string; var height: integer): TPointArray;
var
w: integer;
begin
result := TPAFromText(text,chars,w,height);
dec(height);
end;
(*
FindTextTpaEx
~~~~~~~~~~~~~
.. code-block:: pascal
function FindTextTpaEx(Color,Tol,xs,ys,xe,ye : integer;var x,y : integer; Txt : string; Chars : Integer; Action : (ClickLeft,ClickRight,Move,Nothing)) : Boolean;
Uses TPA's to find text..Returns the found pos in x and y (if not found both are 0)
In action you can put what you want to do after its found..
Nothing - Just return wether its found
Move - Just move the mouse to it
Clickleft - Movemouse & Clickmouse left
Clickright - MoveMouse & Clickmouse right
.. note::
by Raymond
Example:
.. code-block:: pascal
*)
function FindTextTPAEx(Color,Tol,xs,ys,xe,ye : integer;var x,y : integer; Txt, Chars : string; Action :fnct_ActionOptions ) : Boolean;
var
TextTPA,SearchTPA, Matches: TPointArray;
Box : TBox;
xx,yy : integer;
begin
FindColorsTolerance(SearchTPA,Color,xs,ys,xe,ye,tol);
if Length(SearchTPA) < 1 then
Exit;
TextTPA:= LoadTextTPA(Txt,Chars,yy);
Result := FindTextTPAinTPA(yy ,TextTPA,SearchTPA,Matches);
x := 0; y:=0;
if Result = False then
Exit;
Box := GetTPABounds(TextTPA);
SortTPAFrom(Matches, Point(Box.x1, Box.y1));
x := matches[0].x;
y := matches[0].y;
if Action = Nothing then
Exit;
GetMousePos(xx,yy);
if not IntInBox(xx,yy,IntToBox(matches[0].x,matches[0].y,matches[0].x + Box.x2,Matches[0].y + (Box.y2 shr 1))) then
MMouse(matches[0].x + Random(box.x2),Matches[0].y + Random(Box.y2 shr 1),0,0);
if Action = Move then
Exit;
GetMousePos(xx,yy);
MouseAction(xx, yy, 0, 0, Action);
end;
(*
FindTextTPA
~~~~~~~~~~~
.. code-block:: pascal
function FindTextTpa(Color,Tol,xs,ys,xe,ye : integer; Txt : string; Chars : Integer; Action : (ClickLeft,ClickRight,Move,Nothing)) : Boolean;
Just like FindTextTpaEx, but without the x and y pos returning.
.. note::
by Raymond
Example:
.. code-block:: pascal
*)
function FindTextTPA(Color, Tol, xs, ys, xe, ye: integer; Txt, Chars: string; Action: fnct_ActionOptions): Boolean;
var
x,y : integer;
begin
Result := FindTextTPAEx(Color,Tol,xs,ys,xe,ye,x,y,Txt,chars,action);
end;
(*
FindTextTPAMulti
~~~~~~~~~~~~~~~~
.. code-block:: pascal
function FindTextTPAMulti(Color, tol, xs, ys, xe, ye: integer; Texts: TStringArray; Chars: string;/integer; Action: fnct_ActionOptions): Boolean;
Just like FindTextTPA, only that it takes an array of strings as text to search for.
.. note::
by Cigue and EvilChicken!
Example:
.. code-block:: pascal
*)
function FindTextTPAMulti(Color, tol, xs, ys, xe, ye: integer;
Texts: TStringArray; Chars: string; Action: fnct_ActionOptions): Boolean;
var
I: Integer;
begin
for i := 0 to High(Texts) do
if FindTextTPA(Color, Tol, xs, ys, xe, ye, Texts[i], Chars, Action) then
begin
Result := True;
Exit;
end;
end;
(*
FindNPCChatText
~~~~~~~~~~~~~~~
.. code-block:: pascal
function FindNPCChatText(txt: string; Action: fnct_ActionOptions): Boolean;
Finds a text said by a NPC in chat. If found it'll perform action,
where action can be:
Nothing - Just return wether its found
Move - Just move the mouse to it
Clickleft - Movemouse & Clickmouse left
Clickright - MoveMouse & Clickmouse right
.. note::
by Kernel Klink, Nielsie95 & Narcle
Example:
.. code-block:: pascal
*)
Function FindNPCChatText(txt: string; Action: fnct_ActionOptions): Boolean;
var
BlackTPA, WhiteTPA, TPA, mTPA: TPointArray;
i, ii, cts, Height, c, H: integer;
TextATPA, ATPA: T2DPointArray;
B: TBox;
TSA: TStringArray;
begin
cts := GetColorToleranceSpeed;
SetColorToleranceSpeed(1);
FindColors(WhiteTPA, 13158600, MCX1, MCY1, MCX2, MCY2);
FindColors(BlackTPA, 0, MCX1, MCY1, MCX2, MCY2);
SetColorToleranceSpeed(cts);
TPA := CombineTPA(BlackTPA, WhiteTPA);
if (Length(TPA) < 1) then
Exit;
ATPA := SplitTPAEx(TPA, MCX2-MCX1, 1);
TSA := Explode(' ', txt);
SetArrayLength(TextATPA, Length(TSA));
for i := 0 to High(TSA) do
TextATPA[i] := LoadTextTPA(TSA[i], UpChars, Height);
H := High(TextATPA);
for i := 0 to High(ATPA) do
begin
c := 0;
for ii := 0 to H do
if FindTextTPAinTPA(Height, TextATPA[ii], ATPA[i], mTPA) then
Inc(c);
Result := (c = H+1);
if Result then
begin
B := GetTPABounds(ATPA[i]);
with B do
case Action of
Move: MMouse(X1, Y1 + 2, X2-X1, 4);
ClickLeft: Mouse(X1, Y1 + 2, X2-X1, 4, True);
ClickRight: Mouse(X1, Y1 + 2, X2-X1, 4, False);
end;
end;
end;
end;
(*
SortATPAFromFirstPointY
~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
procedure SortATPAFromFirstPointY(var a: T2DPointArray; const From: TPoint);
Sorts the Y coords of the ATPA.
.. note::
by Wizzup? & Narcle
Example:
.. code-block:: pascal
*)
procedure SortATPAFromFirstPointY(var a: T2DPointArray; const From: TPoint);
var
i, l: Integer;
DistArr: TIntegerArray;
begin
l := High(a);
if (l < 0) then Exit;
SetLength(DistArr, l + 1);
for i := 0 to l do
DistArr[i] := Round(Sqr(From.y - a[i][0].y));
QuickATPASort(DistArr, a, 0, l, True);
end;
(*
SortATPAFromFirstPointX
~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
procedure SortATPAFromFirstPointX(var a: T2DPointArray; const From: TPoint);
Sorts the X coords of the ATPA.
.. note::
by Wizzup? & Narcle
Example:
.. code-block:: pascal
*)
procedure SortATPAFromFirstPointX(var a: T2DPointArray; const From: TPoint);
var
i, l: Integer;
DistArr: TIntegerArray;
begin
l := High(a);
if (l < 0) then Exit;
SetLength(DistArr, l + 1);
for i := 0 to l do
DistArr[i] := Round(Sqr(From.x - a[i][0].x));
QuickATPASort(DistArr, a, 0, l, True);
end;
(*
GetChooseOptions
~~~~~~~~~~~~~~~~
.. code-block:: pascal
function GetChooseOptions(TextType: string): Array of TOptions;
Gets the texe from the options menu.
.. note::
by Wizzup? & Narcle
Example:
.. code-block:: pascal
*)
Function GetChooseOptions(TextType: string): Array of TOptions;
var
B,BB: TBox;
TPA, TPA1, TPA2: TPointArray;
aTPA, tempatpa: T2DPointArray;
I, L, target, bmp,w,h, cts: Integer;
Colors: TIntegerArray;
begin
target := GetImageTarget;
GetClientDimensions(B.X2, B.Y2);
B := IntToBox(0, 0, B.X2-1, B.Y2-1);
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsTolerance(TPA1, 4343893, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(TPA2, 3950929, B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := CombineTPA(TPA1, TPA2);
If Length(TPA) < 10 Then
Exit;
B := IntToBox(0, 0, 0, 0);
aTPA := SplitTPA(TPA, 10);
SortATPASize(aTPA, True);
B := GetTPABounds(aTPA[0]);
//Object Blue, Player White, Item Orange, Action Tan, NPC Yellow, Level Green
Colors := [14342147, 14079443, 3832268, 9677229, 840143{, 710915}];
SetLength(aTPA, Length(Colors));
for i := 0 to High(Colors) do
FindColorsTolerance(aTPA[i], Colors[i], B.X1, B.Y1, B.X2, B.Y2, 70);
TPA := MergeATPA(aTPA);
FindColorsTolerance(TPA1, 986117, B.X1, B.Y1, B.X2, B.Y2, 24);//shadow
bmp := CreateBitmap(B.X2-B.X1+2, B.Y2-B.Y1+2);
OffsetTPA(TPA, Point(-B.X1, -B.Y1));
OffsetTPA(TPA1, Point(-B.X1, -B.Y1));
FastDrawClear(bmp, 0);
DrawTPABitmap(bmp, TPA, clRed);
DrawTPABitmap(bmp, TPA1, clPurple);
ocr_FilterUpTextByCharacteristics(GetMufasaBitmap(bmp));
GetbitmapSize(bmp,w,h);
SetTargetBitmap(bmp); // new target for findcolorstolerance.
findcolorstolerance(TPA, clRed, 0, 0, w-1,h-1, 0);
ATPA := SplitTPAEx(TPA, 15, 2);
L := High(ATPA);
SortATPAFromFirstPointY(ATPA, Point(w/2,0));
SetArrayLength(Result, Length(ATPA));
for i := 0 to high(ATPA) do
begin
TPA := ATPA[i];
tempatpa := SplitTPAEx(TPA, 1, 10); // Split one into characters
SortATPAFromFirstPointX(tempatpa, Point(0, 0));
Result[i].Str := GetTextATPA(tempatpa, 4, 'UpCharsEx');
BB := GetTPABounds(ATPA[i]);
Result[i].Bounds := IntToBox(BB.X1+B.X1, BB.Y1+B.Y1, BB.X2+B.X1, BB.Y2+B.Y1);
setlength(tempatpa,0);
setlength(TPA,0);
end;
ColorToleranceSpeed(cts);
SetImageTarget(target);
FreeBitmap(bmp);
end;
(*
ChooseOptionMultiEx
~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function ChooseOptionMultiEx(Texts: TStringArray; TextType: String; Action: fnct_ActionOptions): Boolean;
Finds Popup menu, then clicks on it.
Will look for the first string first and so on.
It will search for the Text Type you input valid arguments are
'action', 'player': The white text
'npc': The yellow text
'object': The cyan text
'all': Searches for all colors of text.
Will default to 'all'.
.. note::
by Wizzup? & Nava2 & N1ke!
Example:
.. code-block:: pascal
*)
function ChooseOptionMultiEx(Texts: TStringArray; TextType: String; Action: fnct_ActionOptions): Boolean;
var
B: TBox;
i, H, ii, L: Integer;
T: TPoint;
Options: array of TOptions;
begin
Result := False;
Options := GetChooseOptions(TextType);
if (Length(Options) < 1) then
Exit;
H := High(Options);
L := High(Texts);
for i := 0 To L do
begin
for ii := 0 to H do
If Pos(Texts[i], Options[ii].Str) > 0 Then
begin
Result := True;
B := Options[ii].Bounds;
GetMousePos(T.x, T.y);
case Action of
ClickLeft: if PointInBox(T, B) then
ClickMouse2(true)
else
MouseBoxEx(B.x1 + 5, B.Y1, B.x2 - 5, B.Y1 + 5,5, 1);
Move: if not PointInBox(T, B) then
MouseBoxEx(B.x1 + 5, B.Y1, B.x2 - 5, B.Y1 + 5,5, 3);
Nothing: begin end;
else
srl_warn('ChooseOptionMultiEx', 'ClickRight not a valid click for RS menus!', warn_AllVersions);
end;
Exit;
end;
end;
B := IntToBox(Options[0].Bounds.X1, Options[0].Bounds.Y1,
Options[H].Bounds.X2, Options[H].Bounds.Y2);//to mmouse away
if Action <> Nothing then
begin
MMouse(Max(B.X1 - 50, 0), Max(B.Y1 - 50, 0), 40, B.Y2 - B.Y1);
Wait(200 + Random(100));
end;
if (not result) and (Action <> Nothing) then
ChooseOptionMultiEx(['Cancel', 'ancel', 'ncel'], 'All', clickLeft);
end;
(*
ChooseOptionMulti
~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function ChooseOptionMulti(Txt: TStringArray): Boolean;
Finds Popup menu, then clicks on it. Will look for the first string first and so on.
.. note::
by Wizzup? & N1ke!
Example:
.. code-block:: pascal
*)
function ChooseOptionMulti(Txt: TStringArray): Boolean;
begin
Result := ChooseOptionMultiEx(Txt, 'All', ClickLeft);
end;
(*
ChooseOptionEx
~~~~~~~~~~~~~~
.. code-block:: pascal
function ChooseOptionEx(Txt, TextType: string): Boolean;
Finds an option in a popup menu, then clicks on it. Searches for TextType.
See ChooseOptionMultiEx for valid options.
Default is 'all'.
.. note::
by Wizzup?
Example:
.. code-block:: pascal
*)
function ChooseOptionEx(Txt, TextType: string): Boolean;
begin
Result := ChooseOptionMultiEx([Txt], TextType, ClickLeft);
end;
(*
ChooseOption
~~~~~~~~~~~~
.. code-block:: pascal
function ChooseOption(txt: String): Boolean;
Finds an option in a popup menu, then clicks on it.
.. note::
by Wizzup?
Example:
.. code-block:: pascal
*)
function ChooseOption(Txt: String): Boolean;
begin
Result := ChooseOptionMultiEx([Txt], 'All', ClickLeft);
end;
(*
OptionsExist
~~~~~~~~~~~~
.. code-block:: pascal
function OptionsExist(txt: TStringArray; Move: boolean): boolean;
Returns true if an Option in txt is found in the RS Option Menu, will move or do
nothing according to the boolean Move.
.. note::
by Rasta Magician
Example
.. code-block:: pascal
*)
function OptionsExist(txt: TStringArray; MoveMouse: boolean): boolean;
begin
if MoveMouse then
Result := ChooseOptionMultiEx(Txt, 'All', Move)
else
Result := ChooseOptionMultiEx(Txt, 'All', Nothing);
end;
(*
CloseWindow
~~~~~~~~~~~
.. code-block:: pascal
function CloseWindow: Boolean;
Closes any open windows. (In RS not your pc roflmaololz, j/k)
.. note::
by NaumanAkhlaQ, Narcle, and Nava2
Updated: 12 December 2011 by Coh3n
Example:
.. code-block:: pascal
if (BankScreen) then
CloseWindow();
*)
function CloseWindow: Boolean;
var
Col: TIntegerArray;
b: array[0..1] of TPointArray;
a: T2DPointArray;
Pa: TBox;
i, ii, l: Integer;
begin
if (CloseBank) then
begin
Result := true;
exit;
end;
Col := [1118997, 1449250, {Main typ 1}
7976927, 4095140, {Skill}
6854059, 2902100, {Quest}
4282212, 2503226, {Main typ 2}
39423, 13567, {Red X}
1514271, 1580837, {Deposit Box}
1383457, 2107437];
for i := 0 to 6 do
begin
FindColorsTolerance(b[0], Col[i * 2], MSCX, MSY1, MSX2, MSCY, 5);
FindColorsTolerance(b[1], Col[i * 2 + 1], MSCX, MSY1, MSX2, MSCY, 5);
l := (High(b[0]) + High(b[1]));
if InRange(l, 6, 53) or InRange(l, 94, 250) then
begin
a := SplitTPA(CombineTPA(b[0], b[1]), 5);
SortATPAFromFirstPoint(a, Point(507, 14));
if (length(a) < 1) then
Continue;
for ii := 0 to high(a) do
begin
Pa := GetTPABounds(a[ii]);
if ((Pa.x2 - Pa.x1) > 50) or ((Pa.y2 - Pa.y1) > 50) then
Continue;
MouseBox(Pa.x1, Pa.y1, Pa.x2, Pa.y2, mouse_move);
if (WaitUptextMulti(['lose', 'ack'], 300)) then
begin
GetMousePos(Pa.x1, Pa.y1);
Mouse(Pa.x1, Pa.y1, 0, 0, mouse_left);
Result := True;
Exit;
end;
end;
end;
end;
end;
(*
InStrArrEx
~~~~~~~~~~
.. code-block:: pascal
function InStrArrEx(S: string; StrArr: TStringArray; var Where: Integer): Boolean;
Returns true if the string S was found in the StrArr, and if so stores the index into Where.
.. note::
by n3ss3s
Example:
.. code-block:: pascal
*)
function InStrArrEx(S: string; StrArr: TStringArray; var Where: Integer): Boolean;
var
I, H: Integer;
begin
H := High(StrArr);
for I := 0 to H do
if LowerCase(StrArr[i]) = LowerCase(S) then
begin
Where := i;
Result := True;
Break;
end;
end;
(*
StrInArr
~~~~~~~~
function StrInArr(str: string; arrS: TStringArray): Boolean;
Returns True if str is found in the Array. Case sensitive.
.. note::
by Narcle & Nava2
Example:
.. code-block:: pascal
*)
function StrInArr(str: string; arrS: TStringArray): Boolean;
var
I, L, H: Integer;
begin
Result := True;
L := Low(arrS); H := High(arrS);
for I := L to H do
if Pos(Str, arrS[I]) > 0 then
Exit;
Result := False;
end;
(*
ArrInStr
~~~~~~~~
.. code-block:: pascal
function ArrInStr(arrS: TStringArray; str: string): Boolean;
Returns True if the Array is found in the str. Case sensitive.
.. note::
by Narcle & Nava2
Example:
.. code-block::pascal
*)
function ArrInStr(arrS: TStringArray; str: string): Boolean;
var
I, L, H: Integer;
begin
Result := True;
L := Low(arrS); H := High(arrS);
for I := L to H do
if Pos(arrS[I], Str) > 0 then
Exit;
Result := False;
end;
{*******************************************************************************
procedure SetDebugColors(Text, Back: Integer);
By: Nava2
Description: Sets the next WriteLn's colours to Text and Back respectively.
*******************************************************************************}
{procedure SetDebugColors(txtCol, BackCol: Integer);
begin
end; }
{*******************************************************************************
procedure WriteArrayCols(Lines: TStringArray; Text, Back: Integer);
By: Nava2
Description: Writes a TStringArray with Text and Back colours. If not using
3.20, it will just writeln the array.
*******************************************************************************}
{procedure WriteArrayCols(Lines: TStringArray; Text, Back: Integer);
var
i, h: Integer;
begin
h := High(Lines);
for i := 0 to h do
begin
SetDebugColors(Text, Back);
Writeln(Lines[i]);
end;
end; }i changed the Text.Simba file in this folder C:\Simba\Includes\SRL\srl\core
was i right wrong?