SRL Archive - First Scripts

Bird Hunter (Tropical Wagtail)


johnbrown8976

2012-04-26 13:01:17

Tropical WagTail Bird Hunter

Requirements:
- Level 19 Hunter
- Bird Traps in Inventory

How to Setup Script
- Start the script anywhere around Tropical Wagtail Birds.
- Tropical Wagtails are found in Feldip Hunter Area.

Features
- Detects other players, and changes world.
- Detects maximum traps you can use.
- Walks by clicking MAINSCREEN, unlike SPS which walks clicking MINIMAP.


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

Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name :='sanjeev_kafley@yahoo.com';
Players[0].Pass :='sudeep';
Players[0].Nick :='';
Players[0].Active:=True;
Players[0].Pin := '';
end;

procedure AntiBan;
begin
if(not(LoggedIn))then Exit;
FindNormalRandoms;
case Random(10000) of
0: begin
HoverSkill('Hunter', false);
wait(1963+Random(432));
end;
1: PickUpMouse;
2: begin
MakeCompass('N');
wait(100+random(133));
MakeCompass('S');
wait(50+random(133));
MakeCompass('N');
end;
3: RandomMovement;
4: BoredHuman;
5: ExamineInv;
6: RandomRClick;
end;
end;

var
x, y, startTime, lastActiveTime, maxTraps, nextTrap, totalBirds, totalTime,
trapNormal, trapSuccess, trapFall, TrapFailure, invBone, invMeat, invTrap, closeButton: Integer;
extend: Extended;

Procedure loadDTM;
begin
trapSuccess := DTMFromString('mWAAAAHicY2FgYHBlZGCwg2J3IL4HFLsCxBeg9IICd4bd8zIZtAy1GZbWeDJIAsWQMSMaBgEAFBcJ2A==');
trapFailure := DTMFromString('mWAAAAHicY2FgYLBnZGBwBmJbIDYC4s9AsV9A/BuI/wDxpDQHhhULFzJMyXdk2DI9hUESKIaMGdEwCAAAWvELWw==');
trapFall := DTMFromString('mWAAAAHicY2FgYOBjgABWIGaDsjmgfBBoS7VhyPI2YGiIsmTobm1lkAOKIWNGNAwCAOx1BVs=');
invMeat := DTMFromString('mggAAAHicY2NgYJjByMAwC4gXA/FsIO4F4n4grgXiYiCuBOIWIG4C4nIQXVgA1MWEgeWApAgWzIgDQwAAM7gIeg==');
invTrap := DTMFromString('mbQAAAHicY2VgYPBkZGBwAeJAIPYHYhsgFgBiJiCWA2I+IOYA4ih7daBqJjDm5eEB03JAEh0zYsFgAADzCgNF');
invBone := DTMFromString('mbQAAAHicY2VgYGBngAAmIBYCYh4gZoNiPiDmgMpvXbsWqgqB5YCkCBpmxILBAACxQgLZ');
closeButton := DTMFromString('mbQAAAHicY2VgYMhlZGDIBOJCIC4A4iwgjgKKh0NxLBT/2aDDMCdbm6E3UhLMBmE5oDg6ZsSCwQAAIXoMQg==');
end;

Procedure unloadDTM;
begin
FreeDTMs([trapSuccess, TrapFailure, trapFall]);
FreeDTMs([invBone, invMeat, invTrap, closeButton]);
end;

function AutoColorPlayers: Array of Integer;
// Thanks to the AutoColor Aid for this function
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL, counter: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(7.33, 7.96);

FindColorsSpiralTolerance(MMCX, MMCY, arP, 16119522, MMX1, MMY1, MMX2, MMY2, 6);
if (Length(arP) = 0) then
begin
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

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

if (X >= 71.32) and (X <= 90.11) and (Y >= 73.58) and (Y <= 96.95) and (Z >= 75.16) and (Z <= 106.92) then
begin
Result[counter] := arC[i];
counter := counter + 1;
Writeln('AutoColor = ' + IntToStr(arC[i]));
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the PLAYERS color.');
end;

function checkPlayers:Boolean;
var
x, y, i, j:Integer;
colors : Array of Integer;
tpa: TPointArray;
atpa: T2DPointArray;
box: TBox;
begin
colors := AutoColorPlayers;
for j:=0 to High(colors) do
begin
if not FindColors(tpa, colors[j], MMX1, MMY1, MMX2, MMY2) then
exit;
atpa := SplitTPA(tpa, 1);
for i:=0 to High(atpa) do
begin
box := GetTPABounds(atpa[i]);
if MiddleTPAEx(atpa[i], x, y) then
if (Abs(box.x2-box.x1)=2) and (Abs(box.y2-box.y1)=2) then
if Distance(MMCX, MMCY, x, y)<30 then
begin
MMouse(x, y, 0, 0);
writeln('Other Player found');
wait(1000);
Result := True;
exit;
end;
end;
end;
end;


Function isInvChanged(prevInvCount, howLong:Integer):Boolean;
begin
MarkTime(startTime);
while prevInvCount=InvCount do
begin
if TimeFromMark(startTime)<howLong then
wait(200+random(200))
else
exit;
end;
Result := True;
end;


Function isPosChanged(prevPos:TPoint; howLong:Integer):Boolean;
var
newPos : TPoint;
begin
MarkTime(startTime);
newPos := SPS_GetMyPos;
while (newPos.x=prevPos.x) and (newPos.y=prevPos.y) do
if TimeFromMark(startTime)<howLong then
begin
newPos := SPS_GetMyPos;
wait(200+random(200));
end else
exit;
Result := True;
end;

Function layTrap:Boolean;
var
i, prevInvCount : Integer;
prevPos, newPos: TPoint;
begin
if ExistsItemDTM(invTrap, x, y) then
begin
MarkTime(lastActiveTime);
prevInvCount := InvCount;
prevPos := SPS_GetMyPos;
Mouse(x, y, 5, 5, mouse_Left);
if isInvChanged(prevInvCount, 5000) then
begin
if isPosChanged(prevPos, 5000) then
begin
while IsMoving do
wait(100+random(200));
wait(800+random(200));
Result := True;
end else
writeln('SPS did not change');
end else
writeln('Inventory did not change');
end else
begin
writeln('No Trap found-Inventory.');
Logout;
TerminateScript;
end;
end;

Function walkDir(dir:String):Boolean;
var
dx, dy : Integer;
prevPos : TPoint;
begin
prevPos := SPS_GetMyPos;
dir := Lowercase(dir);
dx := RandomRange(-5, 5);
dy := RandomRange(-3, 3);
case dir of
'n': dy:=RandomRange(-20,-30);
's': dy:=RandomRange(30,40);
'e': dx:=RandomRange(40,50);
'w': dx:=RandomRange(-40,-50);
end;
if WaitUpTextMulti(['alk here', 'here', 'ere', 'lk', 'alk'], 500+random(200)) then
begin
Mouse(MSCX+dx, MSCY+dy, 0, 0, mouse_Left);
if isPosChanged(prevPos, 5000) then
begin
while IsMoving do
wait(100+random(100));
wait(700+random(200));
Result := True;
exit;
end;
wait(1500+random(200));
Result := True;
end else
begin
Mouse(MSCX+dx, MSCY+dy, 0, 0, mouse_Right);
WaitOptionMulti(['alk here', 'here', 'ere', 'lk', 'alk'], 500+random(200));
if isPosChanged(prevPos, 5000) then
begin
while IsMoving do
wait(100+random(100));
wait(700+random(200));
Result := True;
exit;
end;
wait(1500+random(200));
Result := True;
end;
end;


Procedure SetupPlayer;
var
i: Integer;
begin
//if not SmartEnabled then exit;
MakeCompass('N');
SetAngle(SRL_ANGLE_HIGH);

loadDTM;
AddOnTerminate('unloadDTM');

//Close Advertisement Window
if FindDTMRotatedAlternating(closeButton, x, y, MSX1, MSY1, MSX2, MSY2, -1, 1, 1, extend) then
begin
MMouse(x, y, 2,2);
if WaitUptext('los',500+random(200)) then
Mouse(x, y, 0, 0, mouse_Left);
end;

//Check other players
MarkTime(startTime);
writeln('Check other players');
while TimeFromMark(startTime)<10000 do
begin
if checkPlayers then
begin
ChangeWorld(RandomWorld(true, false));
SetupPlayer;
exit;
end;
wait(700+random(300));
end;

maxTraps := (GetSkillLevel(SKILL_HUNTER) div 20)+1;
if maxTraps<1 then
maxTraps := 1;
writeln('Max traps: '+IntToStr(maxTraps));

//Lay all traps
for i:=1 to maxTraps do
begin
if layTrap then
begin
if i<>maxTraps then
if not walkDir('NSNSNS'[i]) then
writeln('Move Failed.');
end else
writeln('Lay Trap Fail')
end;
end;

Function walkToTrap(x, y: Integer):Boolean;
begin

if (x>(MSCX-60)) and (x<(MSCX+60)) then
begin
if y<160 then
begin
walkDir('N');
exit;
end else
if y>190 then
begin
walkDir('S');
exit;
end;
end;

if (x<MSCX) then
walkDir('W')
else if (x>MSCX) then
walkDir('E');
end;

Function findTrapNormal(dtm:Integer; pickup:Boolean): Boolean;
var
prevInvCount: Integer;
prevPos, newPos: TPoint;
begin
if not FindDTMRotatedAlternating(dtm, x, y, MSX1, MSY1, MSX2, MSY2, -1, 1, 1, extend) then
exit;
MMouse(x, y, 2, 2);
if WaitUpTextMulti(['ird snare','ird','nare','are','ck','eck','heck'], 500 + random(200)) then
begin
MarkTime(lastActiveTime);
prevInvCount := InvCount;

ClickMouse2(true);
if not DidRedClick then exit;
if Pickup then exit; //picks up and exit
FFlag(0);
if isInvChanged(prevInvCount,5000) then
begin
wait(500+random(200));
prevPos := SPS_GetMyPos;
wait(2000+random(500)); //pickup trap animation
walkToTrap(x, y);
if isPosChanged(prevPos, 5000) then
begin
while IsMoving do
wait(50+random(50));
wait(700+random(300));
layTrap;
Result := True;
end;
end;
end;
end;

Function findTrapFall(pickup:Boolean):Boolean;
var
prevInvCount: Integer;
begin
if not FindDTMRotatedAlternating(trapFall, x, y, MSX1, MSY1, MSX2, MSY2, -1, 1, 1, extend) then
exit;
MMouse(x, y, 2, 2);
if WaitUptext('ird', 500 + random(200)) then
begin
MarkTime(lastActiveTime);
prevInvCount := InvCount;
ClickMouse2(false);
WaitOption('ake Bird', 500+random(200));
if Pickup then exit; //Pick up and exit

if isInvChanged(prevInvCount, 5000) then
begin
wait(700+random(300));
while IsMoving do
wait(100+random(100));
wait(700+random(300));
layTrap;
Result := True;
end;
end;
end;

Procedure pickUpAllTraps;
begin
for x:=0 to 3*maxTraps do
begin
writeln('Checking remaining traps');
findTrapNormal(trapSuccess, true);
findTrapNormal(TrapFailure, true);
findTrapFall(true);
wait(500+random(200));
end;
end;

Procedure mainLoop;
begin
while true do
begin
//if (not SmartEnabled) or (TimeFromMark(lastActiveTime)>300000) then exit;
DropItemsByIdentifier('dtm', invBone, []);
DropItemsByIdentifier('dtm', invMeat, []);
if findTrapNormal(trapSuccess, false) then
begin
totalBirds := totalBirds+1;
writeln('Birds catched: '+IntToStr(totalBirds)+' ('+IntToStr(TimeFromMark(totalTime)/60000)+' min)');
end;
findTrapNormal(TrapFailure, false);
findTrapFall(false);
Antiban;
if checkPlayers then
begin
pickUpAllTraps;
ChangeWorld(RandomWorld(true, false));
SetupPlayer;
exit;
end;
wait(500);
end;
end;


begin
Smart_Server := 25;
Smart_Members := False;
Smart_Signed := True;
Smart_SuperDetail := False;
ClearDebug;
SetupSRL;
DeclarePlayers;
LoginPlayer;

SPS_Setup(RUNESCAPE_SURFACE, ['4_12']);
SetupPlayer;
mainLoop;

end.

NKN

2012-04-26 16:10:15

Nice. You could make a custom White color finder.


Procedure FindPlayers;
begin
if(FindColorTolerance(x,y,WhiteColorHere,MMX1,MMY1,MMX2,MMY2,2);
begin
//Do code here
end;
end;

Striken

2012-04-26 19:30:08

From: NKN
Nice. You could make a custom White color finder.


Procedure FindPlayers;
begin
if(FindColorTolerance(x,y,WhiteColorHere,MMX1,MMY1,MMX2,MMY2,2);
begin
//Do code here
end;
end;


I'd go with this. Best to try something new.

johnbrown8976

2012-04-26 22:28:13

From: Phyaskou
I'd go with this. Best to try something new.


From: NKN
Nice. You could make a custom White color finder.


Procedure FindPlayers;
begin
if(FindColorTolerance(x,y,WhiteColorHere,MMX1,MMY1,MMX2,MMY2,2);
begin
//Do code here
end;
end;


Thanks guys for the help. But there is a problem. A big problem. Everytime I logoff Runescape changes a color drastically. Solution would be to use a high tolerance, however it causes another problem. It finds too many unnecessary objects due to high tolerance. This is my script that WORKS, any improvements would be appreciated.

Procedure checkPlayers;
var
i, x, y: Integer;
box1: TBox;
tpa, tpa1 : TPointArray;
atpa : T2DPointArray;
begin
if not FindColorsTolerance(tpa, 14875118, MMX1, MMY1, MMX2, MMY2, 30) then
exit;
atpa := SplitTPAEx(tpa, 5, 5);
for i:=0 to High(atpa) do
begin
tpa1 := atpa[i];
box1 := GetTPABounds(tpa1);
if (Abs(box1.x2-box1.x1)<5) and (Abs(box1.y2-box1.y1)<5) then
if MiddleTPAEx(atpa[i], x , y) then
begin
writeln('Found another player');
TerminateScript;
end;
end;
end;

Total

2012-04-26 22:46:34

Use ACA to get colors. Log in and out a couple times and it will give you the best color.

demoniste

2012-04-27 03:11:36

yes you can have a look at "auto coloring" in this nice tut : http://villavu.com/forum/showpost.php?p=673399&postcount=6

johnbrown8976

2012-04-27 21:55:26

From: TotalKillz
Use ACA to get colors. Log in and out a couple times and it will give you the best color.


From: demoniste
yes you can have a look at "auto coloring" in this nice tut : http://villavu.com/forum/showpost.php?p=673399&postcount=6


Thanks a lot guys, I am currently learning some advanced autocolor functions. Hopefully, get the hunter script working.

johnbrown8976

2012-04-27 23:30:06

~ Solved ~