SRL Archive - Research & Development Lounge

libSRL5


Markus

2014-09-19 07:19:29

Made this small include to aid me in porting some scripts over from SRL 5 to SRL 6. It is absolutely NOT recommended to use this for any other purpose except for saving you a lot of headaches crtl-r'ing lots of stuff. It also adds some overloaded methods for changed Simba functions.
Basically few steps left after importing this include:
  • CTS settings are gone, but you can supply them with the parameter colorSetting in FindColorsTolerance
  • TDTM -> TSDTM
  • Bankscreen/Pinscreen -> bankscreen/pinscreen.isOpen
  • Please fix the gametabs yourself etc.
  • Players.active -> isActive, .loc -> .location
  • And some more!


Enjoy.

- Markus


{ SRL 5 compatibility library for use with SRL 6. For updating legacy scripts }

var
{mmx1, mmx2, mmy1, mmy2, }msx1, msy1, msx2, msy2, mmcx, mmcy, mscx, mscy,
clickLeft, clickRight, __angle_i : integer;

var
SineArray, Cosearray: array[0..360] of Extended;
pi_const : extended;

function FindNormalRandoms : boolean; //Copied from The Mayor's miner ;)
begin //I have no idea what kind of randoms there are nowadays..
exitTreasure();
claimTicket();
result := false;
end;

procedure FFlag(dist : integer);
begin
minimap.waitFlag(dist); //cbf to rewrite 90% of the script
end;

procedure MMouse(x, y, randomx, randomy : integer);
begin
Mouse(x, y, randomx, randomy, mouse_move);
end;

Procedure FNRWait(ms: Integer);
Var
T: Integer;
Begin
T := GetSystemTime;
While GetSystemTime - T < ms Do
Begin
Wait(200);
FindNormalRandoms;
End;
End;

function IntToPoint(const px, py : integer) : tpoint;
begin
result.x := px;
result.y := py;
end;

procedure SortATPAFrom(var a: T2DPointArray; const fx, fy : integer); overload;
begin
SortATPAFrom(a, IntToPoint(fx, fy));
end;

function GetUpText : string; //I hope UpText is MouseOverText..
begin
result := getMouseOverText;
end;

function WaitUpTextMulti(text : TStringArray; waittime : integer) : boolean;
begin
result := isMouseOverText(text, waittime);
end;

procedure ClickMouse2(left : boolean);
begin
if left then
fastClick(mouse_left)
else
fastclick(mouse_right);
end;

function WaitOptionEx(action1, action2 : string; clickit, waittime : integer) : boolean;
begin
result := chooseOption.select([action1, action2], waittime);
end;

function IsUptext(str : string) : boolean;
begin
result := isMouseOverText([str]);
end;

function isFlagPresent : boolean;
begin
result := minimap.isFlagPresent;
end;

function MouseFlagEx(X, Y, rX, rY, Xmod, Ymod, FlagDist: Integer; //copied from srl 5.
CheckForFlag, CheckForRoadColor: Boolean): Boolean;
var
I: Integer;
P: TPoint;
begin
Result := False;
if (minimap.isFlagPresent) then
if (CheckForFlag) or (minimap.getFlagDistance <= FlagDist) then exit;

P := Point(X - Xmod, Y - Ymod);
Xmod := Max(Xmod, 3);
Ymod := Max(Ymod, 3);

for I := 0 to 4 do
begin
IncEx(P.X, Xmod + Random(rX));
IncEx(P.Y, Ymod + Random(rY));
if not pointInBox(P, minimap.GetBounds) then Continue;
Mouse(P.X, P.Y, 0, 0, mouse_left);
Result := WaitFunc(@isFlagPresent, 50, 3000);
if (Result) then break;
end;
if (FlagDist > -1) then
minimap.waitFlag(FlagDist);
end;

function MFF(X, Y, Xmod, Ymod: Integer): Boolean;
begin
Result := MouseFlagEx(X, Y, 3, 3, Xmod, Ymod, -1, True, False);
end;

function FindSymbol(var x, y : integer; symbolnumber : integer) : boolean; //Small change, not backwards compatible
var
p : tpoint;
begin
result := minimap.findSymbol(p, symbolnumber, minimap.getbounds());
x := p.x;
y := p.y;
end;

function InvCount : integer;
begin
result := tabBackpack.count;
end;

procedure LogOut;
begin
players[currentPlayer].logout();
end;

procedure Deposit(startslot, endslot : integer; depositall : boolean);
var
i : integer;
bleuh : tintegerarray;
begin
setlength(bleuh, endslot-startslot+1);
for i := startslot to endslot do
bleuh[i-startslot] := i;
bankscreen.deposit(bleuh, [], not depositall);
end;

procedure CloseBank;
begin
bankscreen.close();
end;

function InvFull : boolean;
begin
result := tabbackpack.isFull;
end;

procedure SetRun(run : boolean);
begin
minimap.toggleRun(run);
end;

function MFNF(X, Y, Xmod, Ymod: Integer): Boolean;
begin
Result := MouseFlagEx(X, Y, 3, 3, Xmod, Ymod, -1, False, False);
end;

procedure MakeCompass(direction : string);
begin
case lowercase(direction) of
'n': minimap.setAngle(MM_DIRECTION_NORTH);
'e': minimap.setAngle(MM_DIRECTION_EAST);
's': minimap.setAngle(MM_DIRECTION_SOUTH);
'w': minimap.setAngle(MM_DIRECTION_WEST);
end;
end;

procedure LoginPlayer;
begin
players[currentplayer].login;
end;

function loggedin : boolean;
begin
result := isLoggedIn;
end;

function IsUpTextMultiCustom(text : tstringarray) : boolean;
begin
result := isMouseOverText(text);
end;

function ChooseOptionMulti(text : tstringarray) : boolean;
begin
result := chooseoption.select(text);
end;

function Cose(Degrees: Integer): Extended;
begin
Result := cosearray[Trunc(FixD(Degrees))];
end;
function Sine(Degrees: Integer): Extended;
begin
Result := sinearray[Trunc(FixD(Degrees))];
end;

procedure SRLRandomsReport;
begin
writeln('Thank your for using the SRL-5 compatibility library!');
end;

function CreateTPAFromText(Txt: string; Chars: string) : TPointArray;
var
w,h : integer;
begin;
result := TPAFromText(Txt,Chars,w,h);
end;

procedure NextPlayer(active : boolean);
begin
players.next(active);
end;

function FindColorsTolerance(var pts: TPointArray; col, x1, y1, x2, y2, tol: Integer; setts : tcolorsettings): Boolean; overload;
begin
result := findcolorstolerance(pts, col, inttobox(x1, y1, x2, y2), tol, setts);
end;

procedure Mouse(x, y, rx, ry : integer; left : boolean); overload;
var
clickityclick : integer;
begin
if left then
clickityclick := MOUSE_LEFT
else
clickityclick := MOUSE_RIGHT;
Mouse(x, y, rx, ry, clickityclick);
end;

const //sorry but else my essminer doesnt work as it NEEDS these to be constants
mmx1 = 577;
mmy1 = 12;
mmx2 = 798;
mmy2 = 200;

begin
msx1 := mainscreen.getbounds.x1;
msy1 := mainscreen.getbounds.y1;
msx2 := mainscreen.getbounds.x2;
msy2 := mainscreen.getbounds.y2;

{mmx1 := minimap.getbounds.x1;
mmy1 := minimap.getbounds.y1;
mmx2 := minimap.getbounds.x2;
mmy2 := minimap.getbounds.y2;}

mmcx := minimap.getcenterpoint.x;
mmcy := minimap.getcenterpoint.y;

mscx := mainscreen.getcenterpoint.x;
mscy := mainscreen.getcenterpoint.y;

clickLeft := MOUSE_LEFT;
clickRight := MOUSE_RIGHT;

pi_const := Pi; // not necessary, but might as well.
for __angle_i := 0 to 360 do
begin
Sinearray[__angle_i] := Sin(__angle_i * pi_const / 180.0);
Cosearray[__angle_i] := Cos(__angle_i * pi_const / 180.0);
end;
end;

Fitta

2014-09-19 10:02:04

//sorry but else my essminer doesnt work as it NEEDS these to be constants

I like!

Incurable

2014-09-19 12:38:48

From: Markus

//Copied from The Mayor's miner ;)
//I have no idea what kind of randoms there are nowadays..


I'm not sure if you've been told yet, but RS3 has no randoms, and quite soon OSRS (Oldschool RuneScape, a 2007 copy of the game with minor updates). This has made botting a lot easier. The "randoms" dealt with in that function are just the micro-transaction related crap that Jagex has introduced into the game. That includes the "treasure" game thing which pops up in the top left when you log in (and is closed by exitTreasure) which replaced the previous spin thingy which used spin tickets (which claimTickets deals with if one exists in your inventory).

Hope that explained a few things. :)

As for your include, I have literally no use for it, but I'm glad to see an old timer returning and being active. :D

Markus

2014-09-19 16:08:11

Yea I've heard something about randoms being removed. I'm curious why they'd remove them in OSR though. They shouldn't pose a problem at all for SRL, as around 2008ish we literally had every random fully solved with colour, even the maze and prison pete! Candlelight was an exception though but that one was really really rare. Just grab an old version from the SVN :p

N1234

2014-11-17 15:49:29

they probably just want more money of course lol