SRL Archive - OSR Help

making your own upchars [problem]


hete taart

2013-08-20 07:09:06

Hey guys!
I am kind of struggling for a while now on this script.
It just can't seem to find the upchars from a RSPS that i created myself from a guide from schuttleu.
so here's a picture of my script:
version 1:


Program New;
{$i SRL/SRL.simba}

procedure GetText;
begin
LoadFont(RSPS, True);
Wait(5000);
writeln(GetTextAtExWrap(3, 3, 200, 25, 0, 3, 0, 13948373, 50, RSPS));
end;

function steal:boolean;
var
x,y:Integer;
begin
if FindObjCustom (x, y, ['Ste','al'],[2490935,2490935,2490935], 5) then
begin
writeln('found');
GetMousePos(x,y);
case Random (1) of
0:Mouse (x,y,2,2,mouse_Left);
1:begin
mouse(x,y,2,2,false);
WaitOption('Steal',500);
end;
end;
end;
end;

Begin
SetupSRL;
steal;
GetText;
end.


^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
over here, all it does is hover over the stall where i want to steal from and write some random letters in the debug box.





version 2:



Program New;
{$i SRL/SRL.simba}

procedure GetText;
begin
LoadFont(RSPS, True);
Wait(5000);
writeln(GetTextAtExWrap(3, 3, 200, 25, 0, 3, 0, 13948373, 50, RSPS));
end;



function LetterColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
H, S, L: Extended;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(1);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 14408668, 4, 4, 500, 330, 11);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToHSL(arC[i], H, S, L);

if (H >= 0.00) and (H <= 8.35) and (S >= 0.00) and (S <= 3.35) and (L >= 83.51) and (L <= 88.26) then
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 63.22) and (X <= 71.76) and (Y >= 66.52) and (Y <= 75.42) and (Z >= 72.42) and (Z <= 81.30) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;
end;

ColorToleranceSpeed(tmpCTS);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;



function steal:boolean;
var
x,y:Integer;
begin
if FindObjCustom (x, y, ['r','m'],[LetterColor,LetterColor,LetterColor], 4) then
begin
writeln('found');
GetMousePos(x,y);
case Random (1) of
0:Mouse (x,y,2,2,mouse_Left);
1:begin
mouse(x,y,2,2,false);
WaitOption('Steal',500);
end;
end;
end;
end;

Begin
SetupSRL;
steal;
GetText;
LetterColor;
end.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
so i tried using autocolor.
over here it just hovers around the chatbox and does nothing.





what am i doing wrong guys?? any help is appreciated :D

riwu

2013-08-20 08:30:30

You have to create your own custom finding function or override rs_GetUpText() (if using lape), as FindObjCustom() calls rs_GetUpText() which directly uses a font only for the official RS.

hete taart

2013-08-20 09:13:06

thanks alot already! but couldd you tell me more about that own costum finding function? i don't really seem to get that part.

bump!
i am really willing to learn this. I promise i will use my knowledge to help others in the future :DD. Just like Yohojo, he's like my big example.

riwu

2013-08-21 08:28:59

From: hete taart
thanks alot already! but couldd you tell me more about that own costum finding function? i don't really seem to get that part.

After moving your mouse to the target through ATPA etc, get the uptext using GetTextAtEx()/GetTextATPA() etc where the argument for 'font' would be the new font you have created, then compare the result with the desired object's uptext using Pos() or ExecRegExpr().

hete taart

2013-08-21 09:16:13

ty i will try to figure that out! Will post result as soon as i got it. Ty alot for your help man! It's really appreciated! :D

masterBB

2013-08-21 09:27:33

When posting code place them inside simba tags:
code
<- without space after [

or use paste.villavu.com

hete taart

2013-08-21 09:59:53

sorry edited :D

hete taart

2013-08-21 10:48:17

ok so i changed my script alot. And i did what Riwu said; I guess… I don't really know what I did :p.

so now it looks like this:

version 3:
Program New;
{$i SRL/SRL.simba}

Function RSPS_GetUpText: String;
Var
WhiteT,BlueT,YellowT,OrangeT,FoundText: String;
Begin
WhiteT:=GetTextAtExWrap(8, 8, 80, 21, 0, 5, 1, 14541281, 55, 'RSPS');
BlueT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 13423640, 65, 'RSPS');
YellowT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 1235160, 40, 'RSPS');
OrangeT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 4687583, 53, 'RSPS');
FoundText:=WhiteT + ' ' + BlueT + YellowT + OrangeT;
FoundText:= ReplaceWrap(FoundText, '.', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '/', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '\', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, ',', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '*', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '^', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '"', '',[rfReplaceAll]);
Result:=FoundText;
End;

function StallColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.05, 0.09);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 10728640, MSX1, MSY1, MSX2, MSY2, 16);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 27.16) and (X <= 67.46) and (Y >= 27.98) and (Y <= 70.66) and (Z >= 20.78) and (Z <= 71.06) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;

procedure Steal;
var X, Y:Integer;

begin
if FindObjTPA(X, Y, StallColor, 5, 1, 41, 21, 23, ['em']) then
begin
MMouse(X, Y, 3, 3);
Mouse(X, Y, 0, 0, True);
end;
end;


Begin
SetupSRL;
RSPS_GetUpText;
Steal;
end.





^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It still does nothing. It doesn't even move the mouse anymore :(.
But ACA does recognise the color i guess.

here's my debug box :D

[ATTACH=CONFIG]22116[/ATTACH]

Now what guys? What am i doing wrong?

A big thanks to the people who already helped me so far! You guys are amazing!!!

Olly

2013-08-21 11:27:06

Try this, it should compile. The findObjTPA() in SRL has a login check (for the official rs) so it would always return false and exit, and regardless after that it would look for the uptext using the official rs uptext font.

Program New;
{$i SRL/SRL.simba}

Function RSPS_GetUpText: String;
Var
WhiteT,BlueT,YellowT,OrangeT,FoundText: String;
Begin
WhiteT:=GetTextAtExWrap(8, 8, 80, 21, 0, 5, 1, 14541281, 55, 'RSPS');
BlueT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 13423640, 65, 'RSPS');
YellowT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 1235160, 40, 'RSPS');
OrangeT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 4687583, 53, 'RSPS');
FoundText:=WhiteT + ' ' + BlueT + YellowT + OrangeT;
FoundText:= ReplaceWrap(FoundText, '.', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '/', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '\', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, ',', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '*', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '^', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '"', '',[rfReplaceAll]);
Result:=FoundText;
End;

function FindObjTPA2(var X, Y: Integer; Color, Tol, CTS, ObjWidth, ObjHeight, minCount: Integer; UpText: string): Boolean;
var
I, tCTS: Integer;
myPoint: TPoint;
Points: TPointArray;
aPoints: T2DPointArray;
begin
Result := False;

tCTS := GetColorToleranceSpeed;
CTS := Integer(CTS * 9 mod 3 <> 0);
ColorToleranceSpeed(CTS);
FindColorsSpiralTolerance(X, Y, Points, Color, MSX1, MSY1, MSX2, MSY2, Tol);
if Length(Points) = 0 then
begin
writeln('findObjTPA(): Found no colors.... exiting');
ColorToleranceSpeed(tCTS);
Exit;
end;
ColorToleranceSpeed(1);
aPoints := TPAtoATPAEx(Points, ObjWidth, ObjHeight);
SetLength(Points, 0);
for I := 0 to High(aPoints) do
begin
if Length(aPoints[i]) < minCount then
Continue;
myPoint := MiddleTPA(aPoints[i]);
MMouse(myPoint.X, myPoint.Y, 0, 0);
wait(100 + random(50));

if (pos(upText, RSPS_GetUptext) > 0) then
begin
writeln('findObjTPA(): We found the object!');
GetMousePos(X, Y);
Result := True;
ColorToleranceSpeed(tCTS);
Exit;
end else
writeln('findObjTPA(): Did not find the uptext... :<');
end;
ColorToleranceSpeed(tCTS);
end;

procedure Steal;
var
X, Y: Integer;
begin
if FindObjTPA2(X, Y, StallColor, 5, 1, 41, 21, 23, 'em') then
clickMouse2(MOUSE_LEFT);
end;


begin
SetupSRL();

Steal();
end.

hete taart

2013-08-21 11:55:58

ok, so i copied your script and it got me sooo much further thanks for that! but now it hovers over multiple stalls (i would like it to hover over just one, the one i want to steal from). But it still doesnn't click. this is what i get in my debug box. Any help? sorry if I am asking so much :S

[ATTACH=CONFIG]22117[/ATTACH]

i know my font is made right because i copied it from dannyrs who made one for the private server called P06.
My RSPS uses the same upchars font because it's also a 06 server.


here's my new script if you need it:

Program New;
{$i SRL/SRL.simba}

Function RSPS_GetUpText: String;
Var
WhiteT,BlueT,YellowT,OrangeT,FoundText: String;
Begin
WhiteT:=GetTextAtExWrap(8, 8, 80, 21, 0, 5, 1, 14541281, 55, 'RSPS');
BlueT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 13423640, 65, 'RSPS');
YellowT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 1235160, 40, 'RSPS');
OrangeT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 4687583, 53, 'RSPS');
FoundText:=WhiteT + ' ' + BlueT + YellowT + OrangeT;
FoundText:= ReplaceWrap(FoundText, '.', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '/', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '\', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, ',', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '*', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '^', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '"', '',[rfReplaceAll]);
Result:=FoundText;
End;

function StallColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.05, 0.09);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 10728640, MSX1, MSY1, MSX2, MSY2, 16);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 27.16) and (X <= 67.46) and (Y >= 27.98) and (Y <= 70.66) and (Z >= 20.78) and (Z <= 71.06) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;

function FindObjTPA2(var X, Y: Integer; Color, Tol, CTS, ObjWidth, ObjHeight, minCount: Integer; UpText: string): Boolean;
var
I, tCTS: Integer;
myPoint: TPoint;
Points: TPointArray;
aPoints: T2DPointArray;
begin
Result := False;

tCTS := GetColorToleranceSpeed;
CTS := Integer(CTS * 9 mod 3 <> 0);
ColorToleranceSpeed(CTS);
FindColorsSpiralTolerance(X, Y, Points, Color, MSX1, MSY1, MSX2, MSY2, Tol);
if Length(Points) = 0 then
begin
writeln('findObjTPA(): Found no colors.... exiting');
ColorToleranceSpeed(tCTS);
Exit;
end;
ColorToleranceSpeed(1);
aPoints := TPAtoATPAEx(Points, ObjWidth, ObjHeight);
SetLength(Points, 0);
for I := 0 to High(aPoints) do
begin
if Length(aPoints[i]) < minCount then
Continue;
myPoint := MiddleTPA(aPoints[i]);
MMouse(myPoint.X, myPoint.Y, 0, 0);
wait(100 + random(50));

if (pos(upText, RSPS_GetUptext) > 0) then
begin
writeln('findObjTPA(): We found the object!');
GetMousePos(X, Y);
Result := True;
ColorToleranceSpeed(tCTS);
Exit;
end else
writeln('findObjTPA(): Did not find the uptext... :<');
end;
ColorToleranceSpeed(tCTS);
end;

procedure Steal;
var
X, Y: Integer;
begin
if FindObjTPA2(X, Y, StallColor, 5, 1, 41, 21, 23, 'teal-from') then
clickMouse2(MOUSE_LEFT);
end;


begin
SetupSRL();

Steal();
end.

Olly

2013-08-21 12:05:31

Move your mouse over a object, then run the script with this

writeln(RSPS_GetUptext);

And then you will see if your uptext works or not.. :)

Also remove setupSRL() from your script, that will offset the whole client (because of the nav bar in official rs)

hete taart

2013-08-21 12:13:41

ok so i tested what you said and it sees the uptext perfectly.
But for some reason when i delete SetupSRL; the mouse will move reaaaal slow

hete taart

2013-08-21 12:42:01

but it does work it does click the stall. it just moves so slow.

hete taart

2013-08-21 12:44:54

fixed it myself i just did
MouseSpeed :=12;