PDA

View Full Version : RSCUpText and RSCOption



cygo
12-02-2009, 03:00 AM
Alright, I figured someone might be able to use these :sasmokin:

In order to use these, save it in your includes folder and {.include} it along with {.include srl/srl.scar}


RSCUpText is called like:


If (RSCUpText('Goblin')) then AttackGoblin;

RSCOption is used like:


RSCOption('What wares')

These will search for the first 3 letters of the string you enter and either click it(RSCOption) or return True(RSCUpText).

I only tried it on a few NPC's and didnt have any problems. If anyone has any issues, comments, suggestions, feedback etc. I would love to hear it.

Enjoy! :stirthepot:


//---------------------------------------------------------------//
// Procedures and Functions (c) cygo 2009. //
// //
// BuildRSCChars : Creates Bitmaps for all letters, //
// comma, period, and apostrophe. //
// RSCUpText : Returns True if first 3 letters //
// of the string are found in UpText. //
// RSCOption : Will left click the specified //
// option if first 3 letters are found //
// in the UpText position. //
//---------------------------------------------------------------//


Procedure BuildRSCChars;
var RSCC : TIntegerArray;
Begin;
SetArrayLength(RSCC, 150);
RSCC[39] := BitmapFromString(3, 15, 'beNpjYMAD/uMADFQHANQjF+k=');
RSCC[44] := BitmapFromString(3, 15, 'beNpjYKAd+A8GyAwIG04iAAAaiRH' +
'v');
RSCC[46] := BitmapFromString(3, 15, 'beNpjYKAd+A8GyAycAACu5gv1');

RSCC[65] := BitmapFromString(8, 15, 'beNpjYKAu+A8DxIjDRdCkqCL+Hxs' +
'gw0zqAAAfWm6S');
RSCC[66] := BitmapFromString(8, 15, 'beNpjYKAW+I8BkMXRlJEtTn/zqQM' +
'Alqd9gw==');
RSCC[67] := BitmapFromString(8, 15, 'beNpjYKAu+I8E0ATR2GhqsCqmhTg' +
'u9+BxPxUAAD4wTbM=');
RSCC[68] := BitmapFromString(8, 15, 'beNpjYKAW+I8K0MTxs5G59BTHZGO' +
'6nzoAAFtycY8=');
RSCC[69] := BitmapFromString(7, 15, 'beNpjYKAQ/McAcEGsKokXpIOZFAE' +
'AA0xZpw==');
RSCC[70] := BitmapFromString(6, 15, 'beNpjYCAP/EcFcBFMNcSIUMscBgo' +
'BABc4R7k=');
RSCC[71] := BitmapFromString(8, 15, 'beNpjYKAu+I8E0ATR2GhqsCrGJY5' +
'sBS67iHEDLmW43EA+AAC2YGKe');
RSCC[72] := BitmapFromString(8, 15, 'beNpjYKAW+A8GmFzqiqMBOthLHQA' +
'A9+N0jA==');
RSCC[73] := BitmapFromString(3, 15, 'beNpjYMAD/oMBFRk4AQAwHDXL');
RSCC[74] := BitmapFromString(7, 15, 'beNpjYKAi+A8G9BRElsUvCGdjNZA' +
'cAADib0e5');
RSCC[75] := BitmapFromString(8, 15, 'beNpjYKAW+A8GmFxkcaxsrBrhAJc' +
'4fjOJZBN0BtVCBwDhCHSM');
RSCC[76] := BitmapFromString(7, 15, 'beNpjYKAQ/AeDoSKIDCj1OQCom0G' +
'/');
RSCC[77] := BitmapFromString(10, 15, 'beNpjYKAd+A8DWEWIlCWbC2Egk6' +
'TK4hIkKAs3Fk2QJgAAwJOwUA==');
RSCC[78] := BitmapFromString(8, 15, 'beNpjYKAW+A8GmNz/MECqODIXjYF' +
'LHKtGNLuIEcfkUgoAk/6Geg==');
RSCC[79] := BitmapFromString(9, 15, 'beNpjYKAR+I8EMMXxs9FE6ClFpKs' +
'wxakJAB8ia5U=');
RSCC[80] := BitmapFromString(8, 15, 'beNpjYKAW+I8BkMXRlFFdnKC9mBq' +
'JFKcOAADrxWWb');
RSCC[81] := BitmapFromString(9, 15, 'beNpjYKAR+I8EMMXxs9FEaCqFVYS' +
'gq7B6DTMEyAw7AITmdIw=');
RSCC[82] := BitmapFromString(8, 15, 'beNpjYKAW+I8BkMXRlJEtjt98Ktq' +
'LVYR8AACFnHeJ');
RSCC[83] := BitmapFromString(8, 15, 'beNpjYKAi+I8KkAXR1GCKYzWEGPO' +
'J0YjHXkyn4jGEfAAAj9tomA==');
RSCC[84] := BitmapFromString(7, 15, 'beNpjYKAQ/McAaFJY1Q8qQTIBAGJ' +
'EQb8=');
RSCC[85] := BitmapFromString(8, 15, 'beNpjYKAW+A8GmNyhIg5nwwEDFQE' +
'ApPBukg==');
RSCC[86] := BitmapFromString(8, 15, 'beNpjYKAW+P//P6YIHKAJIjOIFKd' +
'EL5o4sttwuZmBugAADzJing==');
RSCC[87] := BitmapFromString(12, 15, 'beNpjYKAn+P//PzIbAsgTgQj+Rw' +
'VwETozKPcOSSJ0AgC2YrxE');
RSCC[88] := BitmapFromString(8, 15, 'beNpjYKAW+A8GmFxc4gTVwAGmLbg' +
'EiXEDGe6kAgAAw99ukg==');
RSCC[89] := BitmapFromString(7, 15, 'beNpjYKAQ/P//H40LB8giyAysbGQ' +
'RTDU0FSQTAADHJUq2');
RSCC[90] := BitmapFromString(7, 15, 'beNpjYKAQ/McAWBWQKkJdjcS4k2Q' +
'AAPTbTbM=');
RSCC[97] := BitmapFromString(7, 15, 'beNpjYKAn+I8E4CJosvgVQ9iYDIK' +
'CaAYiW0QmAAANi1Ot');
RSCC[98] := BitmapFromString(7, 15, 'beNpjYKAQ/AcDkgSRZf/DAH4FZAj' +
'iMhOr28gBAA9qZZs=');
RSCC[99] := BitmapFromString(7, 15, 'beNpjYKAn+I8EkEXQ2MiCaHpJFcR' +
'kY9VCDgAAfKtBvw==');
RSCC[100] := BitmapFromString(7, 15, 'beNpjYKAi+A8GeAThbFwMNEGsKo' +
'kXRDYTly7yAQAmRWWb');
RSCC[101] := BitmapFromString(7, 15, 'beNpjYKAn+I8EkEXQ2HgE0UxAVo' +
'lmCy42Vi3kAABCclOt');
RSCC[102] := BitmapFromString(4, 15, 'beNpjYCAS/EcFaIJwNrI4eWzCAA' +
'D/2zvF');
RSCC[103] := BitmapFromString(7, 15, 'beNpjYKAn+A8GeBhoglhVEi+IbC' +
'YuBZhuQ9aIrAAdAADmFG6S');
RSCC[104] := BitmapFromString(7, 15, 'beNpjYKAQ/AcDkgSRZf/DAH4FNB' +
'KkCAAA3n5ing==');
RSCC[105] := BitmapFromString(3, 15, 'beNpjYMAD/oMBVhHyGDgBAPsmL9' +
'E=');
RSCC[106] := BitmapFromString(3, 15, 'beNpjYMAD/oMBVhHKGSg2AQCugT' +
'jI');
RSCC[107] := BitmapFromString(7, 15, 'beNpjYKAQ/AcDUgXhbEwGnI1myH' +
'9UgMscghbhch7JAACotGKe');
RSCC[108] := BitmapFromString(3, 15, 'beNpjYMAD/oMBFRk4AQAwHDXL');
RSCC[109] := BitmapFromString(11, 15, 'beNpjYBgS4D8YwBnIbGQFeNRgK' +
'sZq8sAqoDkAAI+xhno=');
RSCC[110] := BitmapFromString(7, 15, 'beNpjYKAb+A8GyAw4G00cUwGNBC' +
'kCAMz1Vqo=');
RSCC[111] := BitmapFromString(7, 15, 'beNpjYKAn+I8EkEXQ2LQQxGo7RQ' +
'AAoQVTrQ==');
RSCC[112] := BitmapFromString(7, 15, 'beNpjYKAb+A8GyAw4G00cUwEZgr' +
'jMxKoFqzsJAAA7v2Wb');
RSCC[113] := BitmapFromString(7, 15, 'beNpjYKAn+A8GeBhoglhVEi+IbC' +
'YuXZhuIygIBQBSmmWb');
RSCC[114] := BitmapFromString(5, 15, 'beNpjYKAi+I8E4Fw0WapwSQAAsD' +
'wv0Q==');
RSCC[115] := BitmapFromString(7, 15, 'beNpjYKAn+I8EkEXQ2Ghq8GjHlM' +
'JlJn7t5AAAcQtNsw==');
RSCC[116] := BitmapFromString(4, 15, 'beNpjYCAS/P//H85AY0O4mOLEsz' +
'G5+AAAz+E1yw==');
RSCC[117] := BitmapFromString(7, 15, 'beNpjYKAb+A8GaGyaCv6HATy6yA' +
'cApQ9Wqg==');
RSCC[118] := BitmapFromString(6, 15, 'beNpjYKAd+P//PzIbAjBFIIIkMf' +
'AbSL6LAZQ8R7k=');
RSCC[119] := BitmapFromString(10, 15, 'beNpjYBic4D8YwNlogmgMrILEy' +
'CKTaLZgmkC8LC4uTQAAdIZ6hg==');
RSCC[120] := BitmapFromString(7, 15, 'beNpjYKAb+A8GaGysgnA2sgimGl' +
'wqSbKIfAAAcQtNsw==');
RSCC[121] := BitmapFromString(6, 15, 'beNpjYKAd+P//PzIbAjBFIIIkMf' +
'AbiCaCi4sFAABmhlOt');
RSCC[122] := BitmapFromString(6, 15, 'beNpjYKAd+I8KMKWI5BKvAKtdJA' +
'AAXC47xQ==');
End;

Function RSCUpText(RSCText : String) : Boolean;
var
RSCTextArray : TStringarray;
i, j, k : Integer;
begin;
Result := False;
BuildRSCChars;
i := 0;
j := 0;
k := 0;
SetArrayLength(RSCTextArray, 50);
Repeat;
i:=i+1;
Begin
RSCTextArray[i] := StrGet(RSCText, i);
End;
Until(i = Length(RSCText));
MouseSpeed:=16;
i := 1;
While(i < 138) Do
Begin;
If (RSCTextArray[1] = Chr(i)) and (FindBitmapMaskTolerance(RSCC[i], x, y, 131, 0, 146, 41, 75, 75)) then
While(j < 138) Do
Begin;
If (RSCTextArray[2] = Chr(j)) and (FindBitmapMaskTolerance(RSCC[j], x, y, 134, 0, 153, 41, 75, 75)) then
While(k < 138) Do
Begin
If (RSCTextArray[3] = Chr(k)) and (FindBitmapMaskTolerance(RSCC[j], x, y, 137, 0, 160, 41, 75, 75)) then
Begin;
Result := True;
j := 137;
i := 137;
k := 137;
End;
k := k + 1;
End;
j := j + 1;
End;
i := i + 1;
End;
end;



Procedure RSCOption(RSCText : String);
var
RSCTextArray : TStringarray;
i, j, k : Integer;
begin;
BuildRSCChars;
i := 0;
j := 0;
k := 0;
SetArrayLength(RSCTextArray, 50);
Repeat;
i:=i+1;
Begin
RSCTextArray[i] := StrGet(RSCText, i);
End;
Until(i = Length(RSCText));
MouseSpeed:=16;
MMouse(622,28,10,10);
i := 48;
While(i < 138) Do
Begin;
If (RSCTextArray[1] = Chr(i)) and (FindBitmapMaskTolerance(RSCC[i], x, y, 131, 0, 146, 41, 75, 75)) then
While(j < 138) Do
Begin;
If (RSCTextArray[2] = Chr(j)) and (FindBitmapMaskTolerance(RSCC[j], x, y, 134, 0, 153, 41, 75, 75)) then
While(k < 138) Do
Begin
If (RSCTextArray[3] = Chr(k)) and (FindBitmapMaskTolerance(RSCC[j], x, y, 137, 0, 160, 41, 75, 75)) then
Begin;
Mouse(x + Random(15), y + 7, 3, 3, True);
j := 137;
i := 137;
k := 137;
End;
k := k + 1;
End;
j := j + 1;
End;
i := i + 1;
End;
end;

ZaSz
12-02-2009, 03:03 AM
Pretty nice ^^. I don't have the energy to put in the svn :p, maybe awkward saw will do it. Or someone else who has teh powers!

Awkwardsaw
12-02-2009, 03:16 AM
i will be GLAD to commit these :) but first you have to test it more, make sure 100% that the chars work on objects, npc's, items actions ect.

also it would be nice if you can find the entire uptext, intead of the first 3 letters

or to even just make a find text function, and use that for all the functions :)

cygo
12-02-2009, 03:40 AM
I wanted to search for the whole string, and It wouldnt be that hard to change at all but I cant get GetBitmapSize to work. Everytime I call it scar just goes in to an endless loop and I have to close it. I cant use the same type of searching for a lot of chars as I did for 3 because right now it just searches a box, the first letter area of each option and then searches a box to the right of it a little, and then a box to the right of that a little. Because not all the characters are the same size I cant just increment it the same each time and have it work correctly, and since GetBitmapSize isnt working, I cant give it a specific distance to move the searching area.

Nava2
12-02-2009, 04:17 AM
You could load the text like all the other texts are loaded..

weequ
12-02-2009, 11:09 AM
Very nice! Good job ;)
Everything could be written quite much shorter though. I think :P

Edit: Like:
procedure BuildRSCChars;
var
I: Integer;
S: TStringArray;
bmp: TIntegerArray;
begin
S := GetFiles(AppPath + 'Fonts\ClassicCharsOld\', 'bmp');
SetLength(bmp, Length(S));
for I := 0 to High(S) do
bmp[I] := LoadBitmap(AppPath + 'Fonts\ClassicCharsOld\' + S[I]);
end;
or
procedure BuildRSCChars;
var
I: Integer;
S: TStringArray;
bmp: TIntegerArray;
begin
S := GetFiles(AppPath + 'Fonts\ClassicCharsOld\', 'bmp');
SetLength(bmp, 130);
for I := 0 to High(S) do
bmp[StrToInt(GetNumbers(S[I]))] := LoadBitmap(AppPath + 'Fonts\ClassicCharsOld\' + S[I]);
end;Below does it your style.


You could load the text like all the other texts are loaded..
Didn't work. Atleast for me :(

Camaro'
12-02-2009, 11:57 AM
Wow just what was needed, im making an auto fighter now, muahaha :) i will definitly use these.

Awkwardsaw
12-02-2009, 01:14 PM
Wow just what was needed, im making an auto fighter now, muahaha :) i will definitly use these.

i thought we where making one :(

and nava, for some reason the current rsc chars dont work, and we failed when we loaded it our selves

one more thing, there has to be a way to make those other two functions shorter, and more effecient?

cygo
12-02-2009, 05:47 PM
You could use an array for the loop counter, for each nested loop, and also need to get FindBitmapSize working. Does it work for anyone else?

And I didnt even see the LoadBitmap function, thats freaking awesome and Ill definately change it.

Camaro'
12-02-2009, 07:45 PM
i thought we where making one :(

and nava, for some reason the current rsc chars dont work, and we failed when we loaded it our selves

one more thing, there has to be a way to make those other two functions shorter, and more effecient?

OF COURSE WE ARE :)

We can start tonight if were not busy.

weequ
12-02-2009, 10:00 PM
You could use an array for the loop counter, for each nested loop, and also need to get FindBitmapSize working. Does it work for anyone else?

And I didnt even see the LoadBitmap function, thats freaking awesome and Ill definately change it.Yup I tested and it worked...I dont have much time to this as my family will be moving on saturday..

Awkwardsaw
12-02-2009, 10:05 PM
OF COURSE WE ARE :)

We can start tonight if were not busy.

im not busy :)

weequ
12-02-2009, 10:32 PM
Going quite off topic but I have auto fighter too :P Ill finish and release it when ever I have the time...

Feroc1ty
12-11-2009, 03:37 AM
Does this work for anyone else, or am I the only person having issues.