SRL Archive - OSR Help

Need help with Targetting


vashanddou

2012-01-18 16:21:38

Alright so i've started too look more into scripting,
I saw home's rangeguild build your own,
and i looked at the previous working script by kyle.

I have got it mostly working accept for the targetting the targets, anyone able to help?


program RangeGuilder;
{$DEFINE SRL5}
{$DEFINE SMART}

{$i SRL/srl.simba}
{$i SRL/SRL/misc/paintsmart.simba}

const
SRLStatsUserName = '';
SRLStatsPassword = '';

var
maxGames, startupTickets, totTickets, totGames : Integer;

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

with Players[0] do
begin
Name := ''; // Your RuneScape Account Name
Pass := ''; // Your RuneScape Account Password
Active := True; // Use in the Script. True / False.
Integers[0] := 5; // How many times to compete
Strings[0] := 'Rune Arrows'; // What item to get with tickets
end;
end;

procedure AntiRandoms;
begin
if (not(LoggedIn)) then
Exit;
WriteLn('Checking for AntiRandoms');
FindNormalRandoms;
srl_InFight;
end;

function CalculateGameCount(): Integer;
var
coinAmt, x, y, i : Integer;
begin
if not Gametab(tab_Inv) then
Gametab(tab_Inv);

if FindCoins(x, y, 'inv') then
begin
i := CoordsToItem(x, y);
WriteLn('Found coins in Inventory Slot #' + IntToStr(i));

coinAmt := GetAmountBox(InvBox(i));
Result := (coinAmt / 200);
end else
begin
WriteLn('Couldn''t find coins in the inventory!');
WriteLn('Terminating the script!');
TerminateScript();
end;
end;

function CountTickets(): Integer;
var
x, y, i, ticketAmt : Integer;
begin
if FindColorTolerance(x, y, 5867118, MIX1, MIY1, MIX2, MIY2, 5) then
begin
i := CoordsToItem(x, y);
WriteLn('Found Archer Tickets in Inventory Slot #' + IntToStr(i));

ticketAmt := GetAmountBox(InvBox(i));
startupTickets := ticketAmt;

Result := ticketAmt;
end else
WriteLn('Did not find Archer Tickets in Inventory.');
end;

function FindJudge(var rx, ry : Integer) : Boolean;
var
TPA : TPointArray;
I, CTS : Integer;
ATPA : T2DPointArray;
o : TPoint;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.00, 0.03);
FindColorsTolerance(TPA, 7235945, MSX1, MSY1, MSX2, MSY2, 9);
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if(Length(TPA) = 0)then
begin
WriteLn('FindJudge could not find any points.');
Exit;
end;
SortTPAFrom(TPA, Point(MSCX, MSCY));
ATPA := TPAToATPA(TPA, 15);
for I := 0 to High(ATPA) do
begin
o := MiddleTPA(ATPA[i]);
MMouse(o.x, o.y, 3, 3);
if(WaitUptext('Judge', RandomRange(250, 750)))then
begin
Result := True;
GetMousePos(rx, ry);
Exit;
end;
end;
end;

procedure SetupScript();
begin
MakeCompass('N');
SetAngle(SRL_ANGLE_HIGH);
SetRun(True);
Wait(RandomRange(1000, 1750));
maxGames := CalculateGameCount();
WriteLn('You can play a total of ' + IntToStr(maxGames) + ' games!');
totTickets := CountTickets();
WriteLn('You have ' + IntToStr(totTickets) + ' tickets');
end;

function CompeteJudge() : Boolean;
var
x, y, BronzeArrowsBmp : Integer;
begin
Wait(RandomRange(500, 750));
WriteLn('Locating Judge...');

if FindJudge(x, y) then
begin
AntiRandoms();
WriteLn('Judge located, attempting to compete...');
Mouse(x, y, 3, 3, False);
Wait(RandomRange(500, 750));
ChooseOption('Compete');
WriteLn('Talked to Judge.');
Wait(RandomRange(1000, 1250));
MouseBox(247, 392, 274, 405, 1);
Wait(RandomRange(400, 750));
ClickToContinue();
Wait(RandomRange(500, 750));
AntiRandoms();

BronzeArrowsBmp := BitmapFromString(10, 33, 'meJytUssKwjAQDCsigg+qFbFQqF' +
'poEYWeLCheFC/ePHjx4B/5zy4duuRVwUcIZTKzM7slUerXRT5M9Td' +
'cbIRkDBCt90xO0iKIM6rKgKEuD1feo2Q1mM2pOgJDzU73pLxM8y1v' +
'qMBQW8Oom5/JnArL4hkUu6OobCSnGGVNgVBh1IuVYwRpdRcjyrwdG' +
'bj5/zJa6kdG+SOvUQbzGkG+N/bHD95NRpbandQ1YiTdiBxdDeMnjC' +
'JJLz0KpEjKjKI6Si7UilLmgxGVx3YfUi+4MemVlHYRX6wXd5Uwgw==');

WriteLn('Looking for arrows...');

if FindBitmapToleranceIn(BronzeArrowsBmp, x, y, MIX1, MIY1, MIX2, MIY2, 10) then
begin
Wait(RandomRange(500, 750));
WriteLn('We have the arrows! Equiping...');
Mouse(x, (y + 10), 2, 2, True);
WriteLn('Arrows equipped!');
Result := True;
end;

FreeBitmap(BronzeArrowsBmp);
AntiRandoms();
end;
end;

function FindTargets(var rx, ry : Integer) : Boolean;
var
TPA : TPointArray;
I, CTS : Integer;
ATPA : T2DPointArray;
o : TPoint;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.05, 0.54);
FindColorsTolerance(TPA, 11300959, MSX1, MSY1, MSX2, MSY2, 1);
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if(Length(TPA) = 0)then
begin
WriteLn('FindTargets could not find any points.');
Exit;
end;
SortTPAFrom(TPA, Point(MSCX, MSCY));
ATPA := TPAToATPA(TPA, 15);
for I := 0 to High(ATPA) do
begin
o := MiddleTPA(ATPA[i]);
MMouse(o.x, o.y, 3, 3);
if(WaitUptext('arget', RandomRange(250, 750)))then
begin
Result := True;
GetMousePos(rx, ry);
Exit;
end;
end;
end;

function RandomRangeEx(rFrom, rTo : Variant) : Variant;
var
r : Variant;
begin
r := RandomRange(Floor(rFrom), Ceil(rTo));
r := r + RandomE;

repeat
begin
if r <= rFrom then
r := r + RandomE
else if r >= rTo then
r := r - RandomE;
end;
until ((r >= rFrom) and (r <= rTo))

r := (Trunc(r * 100) / 100.00)

Result := r;
end;

function ShootTargets() : Boolean;
var
x, y, i : Integer;
bClicked : Boolean;
begin
AntiRandoms();
Wait(RandomRange(500, 750));
WriteLn('Locating Targets...');

SetAngle(SRL_ANGLE_HIGH);
MakeCompass(36.87 + RandomRangeEx(-1.75, 1.75));
Wait(RandomRange(1000, 1250));

if FindTargets(x, y) then
begin
AntiRandoms();
WriteLn('Targets found!');
Wait(RandomRange(500, 1000));
MMouse(x, y, 3, 3);
Wait(RandomRange(750, 1250));
WriteLn('Spam firing at targets');
repeat
ClickMouse2(True);
Inc(I);
bClicked := ClickToContinue();
if(bClicked)then
Break;
until((i >= 75));
Inc(totGames);
Result := bClicked;
AntiRandoms();
end;
end;

procedure GetTickets();
var
x, y, i : Integer;
begin
Wait(RandomRange(500, 750));
WriteLn('Locating Judge...');

if FindJudge(x, y) then
begin
WriteLn('Judge located, attempting to get tickets...');
Mouse(x, y, 3, 3, True);
Wait(RandomRange(500, 750));
ClickToContinue();
WriteLn('Got the tickets!');

if FindColor(x, y, 5867118, MIX1, MIY1, MIX2, MIY2) then
begin
i := CoordsToItem(x, y);
totTickets := GetAmountBox(InvBox(i));
WriteLn('You now have ' + IntToStr(totTickets) + ' tickets!');
end;
end;
end;
function WalkToTrader() : Boolean;
begin
AntiRandoms();
MakeCompass('N');
SetAngle(SRL_ANGLE_HIGH); ;
MouseBox(584, 35, 602, 52, 1);
Wait(RandomRange(7500, 8500));
Result := True;
AntiRandoms();
end;
function WalkToJudge() : Boolean;
begin
AntiRandoms();
MakeCompass('N');
SetAngle(SRL_ANGLE_HIGH);
MouseBox(671, 134, 680, 139, 1);
Wait(RandomRange(7500, 8500));
Result := True;
AntiRandoms();
end;
procedure EndScript(reason : string);
begin
WriteLn('Could not ' + reason + '. Please make a post on the thread about the issue.');
CompeteJudge();
end;

begin
VersionCheck();
SMART_Members := True;
SMART_Signed := True;
SetupSRL();
SetupSRLStats(222, SRLStatsUserName, SRLStatsPassword);
SRLRandomsReport;
ClearDebug();
ActivateClient();
DeclarePlayers();
LoginPlayer();
SetupScript();
Wait(RandomRange(750, 1250));
repeat
if (CompeteJudge()) then
begin
Wait(RandomRange(750, 1250));
if (ShootTargets()) then
begin
Wait(RandomRange(750, 1250));
end else
EndScript('fire at targets');
end else
EndScript('start competition');

until((totGames >= Players[CurrentPlayer].Integers[0]) or (totGames >= maxGames));
WriteLn('Thanks for running! Please post your progress reports! :)');
TerminateScript;
end.

Dynamite

2012-01-18 16:24:25

Wrong section.
+ why not just post in Home's thread? He said you could ask for help there..

-Boom

Kyle Undefined

2012-01-18 16:26:59

Lol, that's mostly my script with Home's functions added.

vashanddou

2012-01-18 16:28:37

From: Kyle Undefined
Lol, that's mostly my script with Home's functions added.


I'll attempt on home's more now then post in his thread lol ^^.