SRL Archive - First Scripts

TankRoach - my first steps in TPA/ATPA :)


l6bustank

2013-01-29 14:58:28

Just went through the tutorials about TPA/ATPA and created a simple fighter script that camps at the lumbridge catacombs and kills warped cockroaches.

Running:
1. Go to the room where the cockaroaches are
2. Fill into the script how many roaches to kill (HowManyToKill)
3. Run script

NB! It does not eat or check hp so watch out mmkay :p (has anitban though)

Much lulz in the code for SRL veterans I bet, but hey, it something :)

Script:


program TankRoach;//simple roach killer to camp at the Lumbridge catacombs

{$DEFINE SMART}
{$I SRL/SRL.Simba}
{$I SRL/SRL/Misc/Smartgraphics.simba}

var
Count, x, y: Integer;

const
HowManyToKill = 100;//Change to how many roaches you need to be killed

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := ''; //Character Name
Pass := ''; //Character Pass
Pin := ''; //Pin for bank
Active := true;
end;
end;

Procedure AntiBan;
begin
x := Random(300) case x of
0..3:
GameTab(26);
12..15:
PickUpMouse;
16..20:
RandomMovement;
26..27:
RandomRClick;
28..32:
BoredHuman;
33:
ExamineInv;
34:
RandomAngle(SRL_ANGLE_HIGH);
35..40:
GameTab(25);
41..42:
Wait(RandomRange(3217, 4877));
end;
SetAngle(SRL_ANGLE_HIGH);
Wait(RandomRange(107, 223));
end;

//Credits to Flight+RISK+BenLand
procedure WindMouse2(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended);
var
veloX, veloY, windX, windY, veloMag, dist, randomDist, lastDist, step: extended;
lastX, lastY: integer;
sqrt2, sqrt3, sqrt5: extended;
begin
sqrt2:= sqrt(2);
sqrt3:= sqrt(3);
sqrt5:= sqrt(5);
while hypot(xs - xe, ys - ye) > 1 do
begin
dist:= hypot(xs - xe, ys - ye);
wind:= minE(wind, dist);
if dist >= targetArea then
begin
windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
end else
begin
windX:= windX / sqrt2;
windY:= windY / sqrt2;
if (maxStep < 3) then
begin
maxStep:= random(3) + 3.0;
end else
begin
maxStep:= maxStep / sqrt5;
end;
end;
veloX:= veloX + windX;
veloY:= veloY + windY;
veloX:= veloX + gravity * (xe - xs) / dist;
veloY:= veloY + gravity * (ye - ys) / dist;
if hypot(veloX, veloY) > maxStep then
begin
randomDist:= maxStep / 2.0 + random(round(maxStep) div 2);
veloMag:= sqrt(veloX * veloX + veloY * veloY);
veloX:= (veloX / veloMag) * randomDist;
veloY:= (veloY / veloMag) * randomDist;
end;
lastX:= Round(xs);
lastY:= Round(ys);
xs:= xs + veloX;
ys:= ys + veloY;
if (lastX <> Round(xs)) or (lastY <> Round(ys)) then
MoveMouse(Round(xs), Round(ys));
step:= hypot(xs - lastX, ys - lastY);
wait(round((maxWait - minWait) * (step / maxStep) + minWait));
lastdist:= dist;

{$IFDEF SMART}
//if (ENABLE_MOUSE_PAINT) then
//SMART_DrawDotsEx(False, [Point(lastX, lastY)], clWhite);
{$ENDIF}

end;
if (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) then
MoveMouse(Round(xe), Round(ye));

end;

//Credits to Flight
procedure HumanMMouse(eX, eY, ranX, ranY: Integer);
var
randSpeed: extended;
X,Y,X2,Y2,A,Dist,MP: integer;
begin
A := MouseSpeed;
GetMousePos(X, Y);
Dist := Distance(X, Y, eX, eY);
MP := Round(Dist/150);
if MP < 0 then
MP := 1;

randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
X2 := RandomRange(eX-(A*MP), eX+(A*MP));
Y2 := RandomRange(eY-(A*MP), eY+(A*MP));
WindMouse2(X, Y, X2, Y2, 11, 8, 10.0 / randSpeed, 12.0 / randSpeed, 10.0 * randSpeed, 10.0 * randSpeed);
GetMousePos(X, Y);
MMouse(eX, eY, ranX, ranY);
MouseSpeed := A;
end;

Procedure FindRoach;//Thats where all the magic happens :)
var
TmpCTS, i, Counter: Integer;
RoachTPA: TPointArray;
RoachTPAA: T2DPointArray;
begin
TmpCTS := GetToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.20, 0.80);
FindColorsTolerance(RoachTPA, 3295364, MSX1, MSY1, MSX2, MSY2, 9);
SetColorToleranceSpeed(TmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);
RoachTPAA := TPAToATPAEx(RoachTPA, 20, 20);
//Smart_DebugATPA(True, RoachTPAA);
SortATPASize(RoachTPAA, True);
MarkTime(counter);
for i := 0 to High(RoachTPAA) do
if GetArrayLength(RoachTPAA[i])>10 then
begin
MiddleTPAEx(RoachTPAA[i], x, y);
HumanMMouse(x, y, 1, 1);
ClickMouse2(mouse_right);
WaitOption('arp', 1000);
AntiBan;
While (SRL_InFight) do
begin
repeat
Wait(RandomRange(100, 200));
until TimeFromMark(Counter)>10000
end;
Exit;
if TimeFromMark(Counter) > 7000 then
begin
Writeln('We failed to find the roach!');
Exit;
end;
end;
end;

begin
{$IFDEF SMART}
{$IFDEF SIMBAMAJOR980}
Smart_Server := 72;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ELSE}
SRL_SixHourFix := True;
Smart_FixSpeed := True;
{$ENDIF}
{$ENDIF}
SetupSRL;
MouseSpeed := RandomRange(16, 20); //new mouse speed every time you run the script
ActivateClient;
Writeln('l6bustanks roach killer');
Wait(800);
SmartSetRefresh(70);
SetAngle(SRL_ANGLE_HIGH);
Wait(200);
repeat
FindRoach;
Inc(Count);
until (Count>(HowManyToKill))
end.


Recommendations and good advice are always welcome