PDA

View Full Version : making a script



Feroc1ty
12-10-2009, 01:45 AM
yeah im making a script and im basically gonna keep updating this, you can take any functions i make and put em in repository if you want, so far nothing worthy of it tho, except my keyboard and mouse includes which ill post if you want.


program all_my_rsc_crap;

{.include Feroc1ty Keyboard.scar}
{.include Feroc1ty Mouse.scar}

const
rscclient_x = 511;
rscclient_y = 344;

rscchar_x = 255;
rscchar_y = 160;


hoveropt_y = 18;
hoveropt_1 = 328;
hoveropt_2 = 361;
hoveropt_3 = 394;
hoveropt_4 = 426;
hoveropt_5 = 459;
hoveropt_6 = 493;

var
rsclient: integer;
clientpos_x,clientpos_y:integer;
buttons_login: TPoint;

function cx():integer;
begin
result := clientpos_x;
end;

function cy():integer;
begin
result := clientpos_y;
end;

procedure LoadBitmap;
begin
rsclient := BitmapFromString(5, 10, 'beNrTMmHACjhhCAJEpaAIA' +
'rRMoAgC7PygCAKCM6AIAtIaoAirLJpeiLEA0/MNOQ==');
end;

procedure SetupClientPosition;
begin
if FindBitmap(rsclient, clientpos_x,clientpos_y) then
begin
clientpos_x := clientpos_x + 2;
clientpos_y := clientpos_y - 333;
writeln('Successfully found client!');
writeln(inttostr(clientpos_x) + ',' + inttostr(clientpos_y));
end else
begin
writeln('Failed to find client.');
FindWindow('SCAR Divi CDE');
ActivateClient;
TerminateScript;
end;
end;

function LocateFish(name:string):TPoint;
var x,y:integer;
begin
FindColorSpiral(x,y,10047536,cx,cy,cx+rscclient_x, cy+rscclient_y);
end;

procedure Initializer();
begin
FindWindowTitlePart('Runescape Classic', false);
ActivateClient;
LoadBitmap;
MouseInit;
Wait(1000);
SetupClientPosition;
KeyboardVars;
end;

procedure RMouse(x,y,rx,ry:integer;left:boolean);
begin
Mouse(x+cx,y+cy,rx,ry,left);
end;

procedure RMMouse(x,y,rx,ry:integer);
begin
MMouse(x+cx,y+cy,rx,ry);
end;

procedure WaitForColor(x,y,color,timeout:integer);
var i:integer;
begin
i := 0;
while i < timeout do
begin
if GetColor(x,y) = color then
exit;
timeout := timeout + 100;
wait(100);
end;
end;

function RWaitForColor(x,y,color,timeout:integer):boolean;
var i:integer;
begin
result := true;
i := 0;
while i < timeout do
begin
if GetColor(x+cx,y+cy) = color then
begin
result := false;
exit;
end;
i := i + 100;
wait(100);
end;
end;

function LogIn(name,pass:string):boolean;
begin
result := false;
RMouse(260,295,40,5,true);
TypeText(name,true,true);
PressEnter;
TypeText(pass,true,true);
PressEnter;
if RWaitForColor(60,100,0,10000) then
begin
Writeln('Timed out at login.');
exit;
end;
if (GetColor(cx+440,cy+100) <> 0) and (GetColor(cx+440,cy+230) <> 0) then
begin
Writeln('Login failed.');
exit;
end;
RMouse(260,218,40,3,true);
result := true;
writeln('Login succesful!');
end;

procedure HoverOpt(num:integer);
var x:integer;
begin
case num of
1:x := hoveropt_1;
2:x := hoveropt_2;
3:x := hoveropt_3;
4:x := hoveropt_4;
5:x := hoveropt_5;
6:x := hoveropt_6;
end;
RMMouse(x,hoveropt_y,8,8);
end;

begin
Initializer;
LogIn('*','*');
HoverOpt(1);
LocateFish('heh');
end.


oh btw dont take that find fish function its not complete yet :P

YoHoJo
12-10-2009, 01:54 AM
Lawl, nice start, could use some work though, but that's why we're here!

Whats point of the string parameter in this? Its never used?
function LocateFish(name:string):TPoint;
var x,y:integer;
begin
FindColorSpiral(x,y,10047536,cx,cy,cx+rscclient_x, cy+rscclient_y);
end;

Also why are these needed, why not just use Mouse, and MMouse?
procedure RMouse(x,y,rx,ry:integer;left:boolean);
begin
Mouse(x+cx,y+cy,rx,ry,left);
end;

procedure RMMouse(x,y,rx,ry:integer);
begin
MMouse(x+cx,y+cy,rx,ry);
end;

And cx,cy are never used in them?

Feroc1ty
12-10-2009, 01:57 AM
My script doesn't need client targeting, all you do is click play, it will find runescape for you, than it will find a bitmap of the login screen, and offset it to 0,0 coordinates of the runescape classic client begining, so no matter what screen size you have or any other random issues it will find the location of the runescape, and RMouse uses client locations rather than screen locations.

The find fish isn't completed as I've really do absolutely nothing with it haha, got sidetracked with other random crap.

EDIT: BTW, these are all client tested and work, I don't use SRL include simply because I don't want to load 2,000 different functions that I will never use, if they were pre-compiled sure, but SCAR compiles stuff every single time you run it.

Awkwardsaw
12-10-2009, 01:59 AM
may i change/ fix some stuff around? :)

first off, you might as well just use the srl-rsc includes, and if you think things should be done differently with the includes then tell me :)

seconds, you can just get rid of the cy, and cx functions(unless your planning on doing any thing further with them), and just rename the consts to cx, and cy.

also, i beileve you need to make


procedure RMouse(x,y,rx,ry:integer;left:boolean);
begin
Mouse(x+cx,y+cy,rx,ry,left);
end;


to


procedure RMouse(x,y,rx,ry:integer;left:boolean);
begin
Mouse(x-cx, y, rx, ry, left);
end;


since the y coord doesnt change like the x one does, and you need to subtract cx from x, instead of adding it, so it doesnt get some far off x coord :p

also, setuprsc in the includes finds the rs client, and loads the correct client coords ;)