SRL Archive - RS3 Script Requests

Unicorn Killer and banker - WIP


Zota

2012-03-22 18:47:38

Alright, first of let me say:
THIS SCRIPT IS NOT MINE! I used lots of different functions/procedures from other scripts and mashed them into this script(Pretty sure the shell is Laakers, Ghouling Ghouler: http://villavu.com/forum/showthread.php?t=73619&highlight=laaker)

Please, if you see your work in here and you dont want it to be published - send me a PM and I'll sort it out.


Ok now so far it can attack Unicorns very slowly.(That's the problem with not making your own attack procedure!)
It picks up unicorn horns fairly accurately.
jumps over wildy barrier(When SPS decides to work!)
Will bank for food(Top of bank 2nd slot)/Bank all horns(When SPS works)
etc

I tried using SPS but it kept failing. Half of the script needs SPS_Setup.Tolerance of 0.13 the other half needs 0.3. Madness.

I am putting it down for now - working on adding banking to Caotoms rock crab killer(Pretty much perfect now!)



If you want, try fix it up! REALLY good money. I got 180k just from testing it very slowly and buggy!

Remember - alot of the script is not relevant to killing unicorns. I never got around to tidying it all up!

program Unicorn;
{$DEFINE SMART}
{$i SRL/srl.simba}
{$i SRL/SRL/skill/fighting.simba}
{$i sps/sps.simba}
{$i SRL/SRL/misc/paintsmart.simba}

var
foodnumber,P,T,Z,Exp,Horns,XPH,DTM,Kills,MSpeed,RandAmount:Integer;
DCols: Array of Integer;
Drops: Array of String;

procedure DeclarePlayers;
Begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

With Players[0] Do
Begin
Name := ''; //Player username.
Pass := ''; //Player password.
Nick := ''; //Player nickname - 3-4 letters of Player username.
Active := True;
End;

End;

function FindObject(): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
wildy, DTM,tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.30, 0.44);

if not(FindColorsTolerance(arP, 3950413, MSX1, MSY1, MSX2, MSY2, 2)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

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

if (X >= 5.61) and (X <= 6.73) and (Y >= 5.87) and (Y <= 7.01) and (Z >= 4.69) and (Z <= 5.57) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 20, 20);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('ross')) then
begin;
mouse(p.x,p.y,5,5,true);
Result := True;
Break;
end;
end;

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

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

end;

Function UInFight: Boolean;
begin
Writeln('Checking for fight');
Wait(100);
Writeln('Pixel shift of '+IntToStr(averagePixelShift(IntToBox(235, 101, 290, 184), 120, 360)));
if (averagePixelShift(IntToBox(235, 101, 290, 184), 120, 360) < 150) then wait(500);
if (averagePixelShift(IntToBox(235, 101, 290, 184), 120, 360) > 400) then
Begin
Result := True;
Exit;
end else
if not InFight then
Result :=False;
Exit;
end;

Function Eat(What: String): Boolean;
var
I: Integer;
begin
Result := False;
If Not LoggedIn then Exit;
if (foodnumber=1) then Exit;
if (HPPercent < 60) then
If InvEmpty then Logout
else
for i := 1 to 28 do
begin
if ExistsItem(i) then
InvMouse(I, 3);
if IsUpText(What) then
begin
ClickMouse2(True);
Wait(RandomRange(350, 525));
Result := True;
Exit;
end else
end;
end;

Procedure LoadDTM;
begin
DTM := DTMFromString('mggAAAHicY2NgYKhghOBKJFwGxB1MDAzVQNwCxN1A3A/Fy+d5MsxfFc9w7Go5w9ErZQwLZriBMS7AiANDAAAtyBBz');
end;

function Walking(Color, Tolerance: Integer; SortFrom: tpoint): Boolean;
var
i, x, y, rx, ry: Integer;
TPA: TPointArray;
begin
if not LoggedIn then Exit;
FindNormalRandoms;
FindColorsSpiralTolerance(MMCX, MMCY, TPA, Color, MMX1, MMY1, MMX2, MMY2, Tolerance);
SortTPAFrom(TPA, SortFrom);

for i := 0 to High(TPA) do
begin
x := TPA[i].x;
y := TPA[i].y;

rx := RandomRange(-6, 6);
ry := RandomRange(-6, 6);
if (not rs_OnMinimap(x + rx, y + ry)) then
Continue;

Mouse(x + rx, y + ry, 0, 0, true);
FFlag(0);
Wait(200 + Random(500));
Result := True;
Break;
end;
end;

Procedure Bar2Unic;
Var
x,y:integer;
Bar2Uni: TPointArray;
begin
SPS_Setup(RUNESCAPE_SURFACE, ['10_6','10_5']);
Tolerance := 0.3;

Bar2Uni := [Point(4179, 2521), Point(4188, 2496), Point(4200, 2478), Point(4218, 2457), Point(4233, 2421), Point(4239, 2390), Point(4246, 2359), Point(4260, 2330), Point(4274, 2305), Point(4291, 2287), Point(4315, 2269), Point(4329, 2258), Point(4361, 2236), Point(4370, 2194)];

Walking(3100244 , 23, Point(661, 34));
fflag(3);

while isMoving do
wait(500);

if SPS_WalkPath(Bar2Uni) then
begin
while isMoving do
wait(500);
end;
end;

Procedure ToUnicorns;
Var
wildy,x,y:integer;
Ban2Bar: TPointArray;
begin
wildy := DTMFromString('mwQAAAHic42RgYOBgZGDgBGIzIDaH0veB4vcYIDRIbjUQTwDiiUC8CoiPQfEqqNhxIPawNwaqZoRjfn5+FD4EEwboOrBhOAAA4KUKbQ==');
SPS_Setup(RUNESCAPE_SURFACE, ['10_6','10_5']);
Ban2Bar := [Point(4209, 2659), Point(4195, 2630), Point(4181, 2590), Point(4165, 2582), Point(4152, 2563)];

if SPS_WalkPath(Ban2Bar) then
begin
while isMoving do
wait(500);
FindObject();
waitfinddtm(x,y,wildy,5000);
FindDTM(wildy,x,y,MSX1, MSY1, MSX2, MSY2);
mouse(x,y,5,5,true);
wait(3000);
end;
Bar2Unic;
{Walking(2645079 , 23, Point(668, 34));
fflag(3);
Walking(3100244 , 23, Point(661, 34));
fflag(3);
Walking(3099476 , 23, Point(638, 24));
fflag(3);
Walking(4477006 , 23, Point(659, 28));
fflag(3);
Walking(4412503 , 23, Point(660, 29));
fflag(3);
Walking(4607824 , 23, Point(617, 20));
fflag(3);
Walking(3622482, 23, Point(672, 56));
fflag(3);}
end;

Procedure Banking;
begin
repeat
SetAngle(SRL_ANGLE_HIGH);
MakeCompass('N');
Wait(RandomRange(400, 600));
OpenBankNPC;
until BankScreen;

if BankScreen then
begin
Wait(RandomRange(200, 300));
DepositAll;
Withdraw(1, 0, 8);
Wait(RandomRange(200, 300));
CloseBank;
Wait(RandomRange(200, 300));
end;

ToUnicorns;
end;

Procedure ToBank;
Var
wildy,x,y:integer;
myPath,Bar2Ban: TPointArray;
begin
SPS_Setup(RUNESCAPE_SURFACE, ['10_6','10_5']);
myPath := [Point(4162, 2544), Point(4176, 2523), Point(4188, 2506), Point(4203, 2491), Point(4211, 2474), Point(4219, 2449), Point(4224, 2409), Point(4244, 2360), Point(4272, 2325), Point(4301, 2290), Point(4331, 2256), Point(4364, 2228), Point(4361, 2185), Point(4355, 2163)];
Bar2Ban := [Point(4155, 2579), Point(4182, 2602), Point(4185, 2632), Point(4205, 2639), Point(4214, 2659)];
invertTPA(myPath);

if SPS_WalkPath(myPath) then
while isMoving do
wait(500);
FindObject();
waitfinddtm(x,y,wildy,5000);
FindDTM(wildy,x,y,MSX1, MSY1, MSX2, MSY2);
mouse(x,y,5,5,true);
wait(3000);

if SPS_WalkPath(Bar2Ban) then
wait(500);
Banking;
end;

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

FindColorsSpiralTolerance(MSCX, MSCY, arP, 2763308, MSX1, MSY1, MSX2, MSY2, 6);
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 >= 1.18) and (X <= 3.76) and (Y >= 1.22) and (Y <= 3.90) and (Z >= 1.32) and (Z <= 4.18) 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 LoadVars;
begin
Drops:=['nicorn horn']
end;

Function FindUnicorn: Boolean;

Var
TPAA: T2DPointArray; // The Variables of the Functions
TPA: TPointArray;
x,y,CTS, I, Retry: Integer;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, UnicornColour, MSX1, MSY1, MSX2, MSY2, 7); // Enter the Color and Tolerance Here at the Right place.
ColorToleranceSpeed(CTS);
TPAA := TPAToATPAEx(TPA, 15, 15); //Put the Width and Heigh here
SortATPASize(TPAA, True);
For I := 0 To High(TPAA) Do
If GetArraylength(TPAA[i]) > 150 Then // Set How Much Points you need for your function to take Action
Begin
repeat
inc(Retry);
MiddleTPAEx(TPAA[i], x, y);
MMouse(X, Y, 3, 3);
if (IsUpTextMultiCustom(['ck Blac'])) then // Enter The name of Your NPC or Monster
Begin
Result := True;
GetMousePos(X, Y);
mouse(x,y,3,3,false);
wait(100 + random(200));
ChooseOption('ttack');
wait(5000 + random(1000));
Break;
End;
until (Retry = 15);
Break;
end;
end;

Procedure KillUnicorn;
var
sX,sY,X,Y,J: Integer;
begin
Repeat
If FindUnicorn() then
wait(100);
Until UInFight or InFight;
If FindBlackChatMessage('omeone else is fighting') then begin
wait(500);
End;
If UInFight or Infight then
WriteLn('Attacking Unicorn.');
begin
repeat
FindNormalRandoms;
Eat('Eat');
until (not UInFight) or (not OthersInFight) or (not LoggedIn)
end;
wait(randomrange(200,300));
end;

function FindHorn: Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.19, 1.28);

If InvFull Then
begin
If not InvFull then
begin
FindHorn;
end;
for i := 1 to 28 do
begin
if ExistsItem(i) AND InvFull then
InvMouse(I, 3);
if IsUpText('at Lob') AND InvFull then
begin
ClickMouse2(True);
Wait(RandomRange(1050, 525));
end else
end;
FindHorn;
end;

if not(FindColorsTolerance(arP, 6142398, MSX1, MSY1, MSX2, MSY2, 12)) then
begin
//Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

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

if (X >= 21.01) and (X <= 56.63) and (Y >= 22.90) and (Y <= 66.78) and (Z >= 10.88) and (Z <= 28.66) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('ake Uni')) then
begin;
Result := True;
mouse(p.x,p.y,1,1,false);
While IsMoving do
wait(500 + random(100));
WaitOptionMulti(['ake', 'Unico'],50);
Break;
end;
end;

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

if (i = arL + 1) then
begin
// Writeln('FindObject could not find object.');
Result := False;
Exit;
end;
end;

Function FindObjOnScreen(Up,Option:Array of String;Color,Tolerance1,Tolerance2:Integer;MC2:Variant;Hmod,Smod:Extended): Boolean;
var
X,Y:Integer;
CTS,I,T,J: Integer;
Box:TBox;
TPA,T1,T2,Pbox: TPointArray;
ATPA:T2DPointArray;

begin
MarkTime(J);
repeat
Result := False;
CTS := GetColorToleranceSpeed;
PBox := TPAFromBox(IntToBox(245, 135, 280, 185));

ColorToleranceSpeed(2);

SetColorSpeed2Modifiers(Hmod,Smod);

FindColorsSpiralTolerance(MSCX, MSCY, T1,(Color), MSX1, MSY1, MSX2, MSY2, Tolerance1);
FindColorsSpiralTolerance(MSCX, MSCY, T2,(Color), MSX1, MSY1, MSX2, MSY2, Tolerance2);
ColorToleranceSpeed(CTS);
TPA := ClearTPAFromTPA(TPA, PBox);
TPA := CombineTPA(T1,T2);
ATPA := TPAtoATPAEx(TPA,20,20);
SortATPAFrom(ATPA,Point(257,157));

For i := 0 to High(ATPA) do
begin
if (Length(TPA) < 1) then
Exit;
Box := GetATPABounds(ATPA);
SMART_DrawBoxEx(False,IntToBox(Box.X1,Box.Y1,Box.X2,Box.Y2),65320);
SMART_DrawDotsEx(false, TPA, 65320);
MiddleTPAEx(ATPA[i],X,Y);
MMouse(X,Y,5,5);
if WaitUpTextMulti(Up, 400) then
begin
GetMousePos(X, Y);
ClickMouse2(MC2);
ChooseOptionMulti(Option);
SMART_ClearCanvasArea(Box);
Result := True;
Exit;
end;
end;
Until (TimeFromMark(J) > 3500);
End;

Function PickupHorn:Boolean;
Var
i,X, Y: Integer;
begin
FindNormalRandoms;
While IsMoving do
Wait(50);
FindNormalRandoms;
Wait(RandomRange(300,400));
End;




procedure Startup;
begin
Smart_Server := 69;
Smart_Members:= true;
Smart_Signed := true;
Smart_SuperDetail := false;
SetupSRL;
DeclarePlayers;
LogInPlayer;
SetAngle(0);
ClickNorth(0);
wait(100+random(100));
end;

begin
Startup;
LoadVars;
Bar2Unic;
repeat
MarkTime(Z);
repeat
wait(100+random(500));
// if InvFull then // if inv(nofoodleft)
// begin
// writeln('Inventory full, banking');
// ToBank;
// end;

if FindHorn = true then
begin
PickupHorn;
end;

if FindUnicorn = true then
begin
KillUnicorn;
end;

until (hppercent<50);
ToBank;
FindNormalRandoms;
until not LoggedIn
writeln('stopping script');
TerminateScript;
end.

Gucci

2012-03-23 00:57:59

If that's a fighting script it should probably be in the fighting section and not the script requests section

Zota

2012-03-23 04:45:50

It's not a finished script. Work in progress. I'm not good enough to finish it with good enough accuracy. passing it on.

Luke

Gucci

2012-03-23 11:28:10

Ahhh I see what are you having problems finishing?