SRL Archive - SRL Archives

Some Suggestions


Daniel

2008-04-27 04:13:39

I just made these when i was bored and thought, what the heck, they'll be good use in SRL, so i posted them here.

//Place in: SRL/Core/Inventory.scar
procedure DropToPosition(StartPosition, EndPosition: Integer; WaitPeriod: Integer);
var
i: Integer;
begin
for i:=StartPosition to EndPosition do
begin
if(not(ExistsItem(i))) then
DropItem(i);
Wait(WaitPeriod+Random(WaitPeriod/2));
end;
end;

procedure DropExcept(tsa: TStringArray; WaitPeriod: Integer);
var
i: Integer;
begin
for i:=1 to 28 do
begin
if(not(ExistsItem(i))) or (not(IsUpTextMultiCustom(tsa))) then
DropItem(i);
Wait(WaitPeriod+Random(WaitPeriod/2));
end;
end;

procedure DropToPositionExcept(StartPosition, EndPosition: Integer; tsa: TStringArray; WaitPeriod: Integer);
var
i: Integer;
begin
for i:=StartPosition to EndPosition do
begin
if(not(ExistsItem(i))) or (not(IsUpTextMultiCustom(tsa))) then
DropItem(i);
Wait(WaitPeriod+Random(WaitPeriod/2));
end;
end;

procedure DropExceptColor(tsa: TStringArray; Color: TIntegerArray; WaitPeriod: Integer);
var
i: Integer;
Box: TBox;
x, y: Integer;
begin
for i:=1 to 28 dp
begin
Box:=InvBox(i);
if(not(ExistsItem)) or (not(IsUpTextMulti(tsa))) or (not(FindMultiColor(x, y, MSX1, MSY1, MSX2, MSY2, Color))) then
DropItem(i);
Wait(WaitPeriod+Random(WaitPeriod div 2));
end;
end;

//Place in: SRL/skill/Mining.scar
function DetectPickaxeEx(tx, ty, Tol: Integer; SpiralDist: Extended): String;
var
b: Boolean;
begin
b:=FindPickHeadColor;
if(not(b)) then
Exit;
if(FindObjEx(tx, ty, ['une', 'icka'], [0, hc1, hc2, hc3, hc4, hc5], Tol, 586, 304, SpiralDist, MIX1, MIY1, MIX2, MIY2)) then
Result:='runite' else
if(FindObjEx(tx, ty, ['daman', 'mant', 'icka'], [0, hc1, hc2, hc3, hc4, hc5], Tol, 586, 304, SpiralDist, MIX1, MIY1, MIX2, MIY2)) then
Result:='adamant' else
if(FindObjEx(tx, ty, ['ith', 'hri', 'ril', 'icka'], [0, hc1, hc2, hc3, hc4, hc5], Tol, 586, 304, SpiralDist, MIX1, MIY1, MIX2, MIY2)) then
Result:='mithril' else
if(FindObjEx(tx, ty, ['tee', 'eel', 'icka'], [0, hc1, hc2, hc3, hc4, hc5], Tol, 586, 304, SpiralDist, MIX1, MIY1, MIX2, MIY2)) then
Result:='steel' else
if(FindObjEx(tx, ty, ['Iron', 'icka'], [0, hc1, hc2, hc3, hc4, hc5], Tol, 586, 304, SpiralDist, MIX1, MIY1, MIX2, MIY2)) then
Result:='iron' else
if(FindObjEx(tx, ty, ['ronz', 'ze', 'icka'], [0, hc1, hc2, hc3, hc4, hc5], Tol, 586, 304, SpiralDist, MIX1, MIY1, MIX2, MIY2)) then
Result:='bronze';
end;

function DetectPickaxe(vx, vy: Integer): String;
begin
GameTab(5);
Wait(867+Random(541));
Result:=DetectPickaxeEx(vx, vy, 5, 2.0);
if(Result='') then
begin
GameTab(4);
Wait(869+Random(763));
Result:=DetectPickaxeEx(vx, vy, 5, 3.0);
if(Result='') then
Writeln('WARNING: No Pickaxe Found');
end;
end;

//Place in: SRL/Core/AntiBan.scar
procedure RandomCompass;
var
i: Integer;
begin
i := 1 + Random(359);
case random(7) of
0: MakeCompass('N');
1: MakeCompass('S');
2: MakeCompass('E');
3: MakeCompass('W');
4: MakeCompass(IntToStr(i));
5: SetAngle(True);
6: SetAngle(False);
end;
end;

and here is the FindColorMulti function out of the IP-Includes:
{*******************************************************************************
function FindMultiColor(x, y, xs, ys, xe, ye: Integer; Colors: TIntegerArray): Boolean;
By: IP-Drowner
Type: Simple.
Description: Will return true if found one of the colors specified.
Usage: FindMultiColor(x, y, 0, 0, 500, 400, [0, 255', 16777215]);
Result: Will search for the colours Black, Red and White within a boxed area
of 0, 0 and 500, 400.
*******************************************************************************}
function FindMultiColor(x, y, xs, ys, xe, ye: Integer; Colors: TIntegerArray): Boolean;
var
i: Integer;
begin
for i:=1 to Length(Colors) do
begin
Result:=FindColor(x, y, Colors[i], xs, ys, xe, ye);
if(Result) then Break;
end;
end;

{*******************************************************************************
function FindMultiColorTolerance(x, y, xs, ys, xe, ye, Tol: Integer; Colors: TIntegerArray): Boolean;
By: IP-Drowner
Type: Simple.
Description: Will return true if found one of the colors specified.
Usage: FindMultiColor(x, y, 0, 0, 500, 400, [0, 255', 16777215], 5);
Result: Will search for the colours Black, Red and White within a boxed area
of 0, 0 and 500, 400 with a Tolerance level of 5.
*******************************************************************************}
function FindMultiColorTolerance(x, y, xs, ys, xe, ye, Tol: Integer; Colors: TIntegerArray): Boolean;
var
i: Integer;
begin
for i:=1 to Length(Colors) do
begin
Result:=FindColorTolerance(x, y, Colors[i], xs, ys, xe, ye, Tol);
if(Result) then Break;
end;
end;

Enjoy!

n3ss3s

2008-04-27 05:36:09

Why do you do "if(not(ExistsItem(..))) Then DropItem(..)"? You should do If ExistsItem…

Richard

2008-04-27 15:01:59

Good load of things to add. Also I you gave me an idea with the compass, so if you want it to be east you would have it 85-95 deg, instead of exactly 90.

So what I was thinging of was this:


{*******************************************************************************
function MakeCompass(Direction: string): Boolean;
By: Nielsie95
Description: Aligns RS to specified direction
direction: Enter a specific side ('n', 'e', 's', 'w')
or enter a degree(for example: '153' or '23')
*******************************************************************************}

function MakeCompass(Direction: string): Boolean;
var
StartAngle, Angle, DirectionDeg, i: Extended;
Left: Boolean;
Mark: Integer;
begin
Result := False;
StartAngle := (rs_GetCompassAngleDegrees);
if (StartAngle < 0) or (not LoggedIn) then Exit;
try
DirectionDeg := FixD(StrToFloat(Direction));
except
case LowerCase(Direction) of
'n': DirectionDeg := 355+random(10);
'w': DirectionDeg := 85+random(10);
's': DirectionDeg := 175+random(10);
'e': DirectionDeg := 265+random(10);;
end;
end;
if (MinE(Abs(StartAngle - DirectionDeg), MinE(Abs(StartAngle - (DirectionDeg + 360)), Abs((StartAngle + 360) - DirectionDeg)))) <= 8.0 then
begin
Result := True;
Exit;
end;
Left := (Round((360 - StartAngle) + DirectionDeg) mod 360 > Round((StartAngle + 360) - DirectionDeg) mod 360);
if Left then
KeyDown(VK_LEFT)
else
KeyDown(VK_RIGHT);
Wait(10);
MarkTime(Mark);
repeat
Wait(1);
Angle:= rs_GetCompassAngleDegrees;
if ((TimeFromMark(Mark) > 6000) and (i < 1.0)) or
((TimeFromMark(Mark) > 10000) and (i < 2.0)) or
((TimeFromMark(Mark) > 14000) and (i < 3.0)) then
begin
i := i + 1.0;
end;
until ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i))
or (TimeFromMark(Mark) > 14000)
or (Angle < 0);
if Left then
KeyUp(VK_Left)
else
KeyUp(VK_Right);
Wait(10);
Result := ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i));
end;

That way moving the compass is less detectable, so you wont always point in the exact direction. But I guess its easy enough to put that into your script.

Daniel

2008-04-27 19:53:26

From: n3ss3s
Why do you do "if(not(ExistsItem(..))) Then DropItem(..)"? You should do If ExistsItem…

I wasn't really concentrating at the time when i made this.

Sir R. M8gic1an

2008-05-03 05:19:14


procedure DropExcept(tsa: TStringArray; WaitPeriod: Integer);
var
i: Integer;
begin
for i:=1 to 28 do
begin
if(not(ExistsItem(i))) or (not(IsUpTextMultiCustom(tsa))) then
DropItem(i);
Wait(WaitPeriod+Random(WaitPeriod/2));
end;
end;


you never move the mouse to the object, the uptext will never be there before you drop it.

n3ss3s

2008-05-06 12:07:43

Dude Richard, MakeCompass accepts raw degrees too.