Log in

View Full Version : Help with picking up ashes



madoff
12-06-2012, 01:17 AM
I'm trying to write my first script but i've run into a problem. I can't seem to actually click on the ashes. I'd really like some guidance on a way to restart with a better overall approach, but if someone wants to offer some guidance about just fixing the code i've got, i'd appreciate that too.


program SRLSuperHeater;
{$DEFINE SMART}
{$I SRL/SRL.Simba}
{$i sps/sps.simba}

Const
DoDebug = True; { Create Debug Info? }

var
x, y, T, B, loads: Integer;

Procedure DeclarePlayers;
begin

HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

with Players[0] do
begin

Name := '';
Pass := '';
Nick := 'ick'; // three lowercase letters in the middle of your name
BoxRewards := ['amp'];
LampSkill := SKILL_SMITHING;
Pin := '';
Active := True;
end;
end;

Procedure Debug(s:string);
Begin
if DoDebug then
Writeln(s);
end;

Procedure Antiban;
begin
case (Random(1000)) of
1: begin BoredHuman; PickupMouse; HoverSkill('Magic', False); end;
2: HoverSkill('Smithing', False);
3: ExamineInv;
4: begin PickupMouse; RandomRClick; end;
5: HoverSkill('Magic', False);
end;
if GetCurrentTab = tab_Inv then
Exit
else
GameTab(tab_Inv);
end;

Procedure LogIn;
begin
LoginPlayerToLob;
OpenWorldScreen;
SelectWorld(98);
LoginPlayer;
end;

Procedure WalkTo(p: Integer);
Var
To0:TPointArray;
To1:TPointArray;
To2:TPointArray;
To3:TPointArray;
To4:TPointArray;
To5:TPointArray;
begin
writeln('Walking to ');
writeln(p);
To0 := [Point(126, 147)];
To1 := [Point(124, 165)];
To2 := [Point(172, 165)];
To3 := [Point(206, 167)];
To4 := [Point(93, 168)];
To5 := [Point(60, 171)];
case p of
0:
begin
SPS_WalkPath(To0);
end ;
1:
begin
SPS_WalkPath(To1);
end;
2:
begin
SPS_WalkPath(To2);
end;
3:
begin
SPS_WalkPath(To3);
end;
4:
begin
SPS_WalkPath(To4);
end;
5:
begin
SPS_WalkPath(To5);
end;
end;
wait(1 + RandomRange(1000,1500));
AntiBan;

end;

Function AtBank:Boolean;
Begin
Wait(250+random(50));
if FindBank('vwb') then
begin
writeln('At the bank');
Result:=True;
end
else
begin
writeln('We are not at the bank Teleporting to varrock and walking there');
Result:=False;
end;
end;

Function FindBanker:Boolean;
var
tmpCTS, i, l, r, counter: integer;
BankerTPA:TPointArray;
begin tmpCTS := GetToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.85, 1.15);
FindColorsTolerance(BankerTPA, 4140331, MSX1, MSY1, MSX2, MSY2, 10);
SetColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);
L := High(BankerTPA)
marktime(counter);
for i := 0 to L do
begin
r := random(L);
wait(randomrange(60, 200));
mmouse(BankerTPA[r].x, BankerTPA[r].y, 2, 2);
if waituptext('Talk-to', 300) then
Break;
if timefrommark(counter) > 20000 then
begin
writeln('Failed to find the banker');
end;
end;
writeln('Found the banker');
clickmouse2(mouse_right);
wait(RandomRange(250,300));
ChooseOption('Bank Banker');
MarkTime(b);
repeat
wait(50+random(5));
until(BankScreen or (TimeFromMark(t)>20000)or PinScreen);
Result:=True
end;

Procedure OpenBanker;
Begin
MarkTime(t);
repeat
wait(randomrange(100,200));
if FindBanker then
Begin
MarkTime(b)
repeat
wait(100+random(5));
until(BankScreen or (TimeFromMark(t)>20000)or PinScreen);
end;
until(BankScreen or (TimeFromMark(t)>20000)or PinScreen );
end;

Function DepositAsh:Boolean;
begin
MarkTime(T);
OpenBanker;
if PinScreen then InPin(players[0].Pin);
if BankScreen then
begin
DepositAll;
wait(250+random(50));
CloseBank;
wait(500+random(50));
Result:= True;
writeln('Deposited ashes');
end else
Begin
Result:=False;
writeln('Failed to Deposit');
end
end;

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

FindColorsSpiralTolerance(MSCX, MSCY, arP, 13817311, MSX1, MSY1, MSX2, MSY2, 8);
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 >= 53.93) and (X <= 79.15) and (Y >= 56.32) and (Y <= 81.59) and (Z >= 58.45) and (Z <= 86.44) 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 FindAshes;
var
Nx, Ny, C: Integer;
begin
Nx := MSCX
Ny := MSCY
while (True) do
begin
C := AshColor
if FindObjTPA(Nx,Ny, C, 10, -1, 60, 60, 100, ['Tak']) then
begin
Writeln('found a tree');
GetMousePos(Nx,Ny);
Wait(RandomRange(10,30));
Mouse(Nx,Ny,0,0,True);
Wait(RandomRange(400,600))
end else;
begin
Break;
end;
end;
end;



begin
ClearDebug;
ClearReport;
SetupSRL;
ActivateClient;
DeclarePlayers;
Wait(500 + Random(500));
if (not LoggedIn) then
LogIn;
SetAngle(SRL_ANGLE_HIGH);
MakeCompass('N');
Debug('Just Set Up Player :)');
Wait(2000);
SPS_Setup(Runescape_Surface,['Beer_Map']);
Repeat
if not LoggedIn then LogIn;
if InvFull then
begin
WalkTo(1);
WalkTo(0);
DepositAsh;
AntiBan;
end;
while(not InvFull) do
begin
WalkTo(1);
FindAshes;
AntiBan;
WalkTo(2);
FindAshes;
WalkTo(3);
FindAshes;
AntiBan;
WalkTo(2);
FindAshes
WalkTo(1);
FindAshes;
WalkTo(4);
FindAshes;
AntiBan;
WalkTo(5);
FindAshes;
WalkTo(4);
FindAshes;
AntiBan;
WalkTo(1);
FindAshes;
end;
Until(false);
end.

DannyRS
12-06-2012, 01:19 AM
Remove your username and password from script!

And change your password asap incase someone besides me and Rez saw it, thats also a really crap pw btw lol,

As for collecting ashes, look in the beginner tutorial section for DTM's, thats the easiest way to pick stuff up without a whole lot of effort :)

Rezozo
12-06-2012, 01:20 AM
Take this off now, remove the email and password, then repost. Hurry.
~Rez

madoff
12-06-2012, 01:37 AM
its a throwaway account. not a big deal. thanks for the heads up though.

Rezozo
12-06-2012, 03:18 AM
You are welcome. So as for your problem, does it do everything but pick up ashes? Or does it give an error? If so, what error?
~Rez

Edit: Try changing your findAshes procedure to:

Procedure FindAshes;
var
Nx, Ny, C: Integer;
begin
Nx := MSCX
Ny := MSCY
while (True) do
begin
C := AshColor
if FindObjTPA(Nx,Ny, C, 10, -1, 60, 60, 100, ['Tak']) then
begin
Writeln('Found some ashes!');
Wait(Random(50));
Mouse(Nx,Ny,0,0,True);
Wait(RandomRange(400,600))
end else;
begin
Break;
end;
end;
end;

Lastly, check your AshColor function, put a writeln function to output the color you get. Just to make sure you are getting what you expect. (Why not just use regular findObjCustom? It would be more efficient)

madoff
12-07-2012, 07:50 AM
thanks for the suggestion. my code is doing a pretty good job of locating ashes now, but it eventually (usually within half an hour or so) gets off of my movement track and gets lost to the west of my movement locations. here's my updated code, could anyone give some general advice on how i should approach the movement portion of this script? the current method i'm using doesn't seem to be a very effective overall idea, so i'm sure there's a better approach.


program pickupAsh;
{$DEFINE SMART}
{$I SRL/SRL.Simba}
{$i sps/sps.simba}

Const
DoDebug = True; { Create Debug Info? }
WORLD = 33;
var
x, y, T, B, loads, Ash: Integer;

Procedure DeclarePlayers;
begin

HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

with Players[0] do
begin

Name := '';
Pass := '';
Nick := ''; // three lowercase letters in the middle of your name
BoxRewards := ['amp'];
LampSkill := SKILL_SMITHING;
Pin := '';
Active := True;
end;
end;

Procedure Debug(s:string);
Begin
if DoDebug then
Writeln(s);
end;

Procedure Antiban;
begin
case (Random(100)) of
2: HoverSkill('Smithing', False);
3: ExamineInv;
5: HoverSkill('Magic', False);
end;
if GetCurrentTab = tab_Inv then
Exit
else
GameTab(tab_Inv);
end;

Procedure LogIn;
begin
LoginPlayerToLob;
OpenWorldScreen;
SelectWorld(WORLD);
LoginPlayer;
end;

Procedure WalkTo(p: Integer);
Var
To0:TPointArray;
To1:TPointArray;
To2:TPointArray;
To3:TPointArray;
To4:TPointArray;
To5:TPointArray;
begin
Writeln('Walking to ');
Writeln(p);
To0 := [Point(135, 140)];
To1 := [Point(130, 165)];
To2 := [Point(162, 165)];
To3 := [Point(192, 167)];
To4 := [Point(85, 169)];
To5 := [Point(75, 171)];
case p of
0:
begin
SPS_WalkPath(To0);
end ;
1:
begin
SPS_WalkPath(To1);
end;
2:
begin
SPS_WalkPath(To2);
end;
3:
begin
SPS_WalkPath(To3);
end;
4:
begin
SPS_WalkPath(To4);
end;
5:
begin
SPS_WalkPath(To5);
end;
end;
wait(1 + RandomRange(3000,4000));
AntiBan;

end;

Function AtBank:Boolean;
Begin
Wait(250+random(50));
if FindBank('vwb') then
begin
writeln('At the bank');
Result:=True;
end
else
begin
writeln('We are not at the bank Teleporting to varrock and walking there');
Result:=False;
end;
end;

Function FindBanker:Boolean;
var
tmpCTS, i, l, r, counter: integer;
BankerTPA:TPointArray;
begin tmpCTS := GetToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.85, 1.15);
FindColorsTolerance(BankerTPA, 4140331, MSX1, MSY1, MSX2, MSY2, 10);
SetColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);
L := High(BankerTPA)
marktime(counter);
for i := 0 to L do
begin
r := random(L);
wait(randomrange(60, 200));
mmouse(BankerTPA[r].x, BankerTPA[r].y, 2, 2);
if waituptext('Talk-to', 300) then
Break;
if timefrommark(counter) > 20000 then
begin
writeln('Failed to find the banker');
end;
end;
writeln('Found the banker');
clickmouse2(mouse_right);
wait(RandomRange(250,300));
ChooseOption('Bank Banker');
MarkTime(b);
repeat
wait(50+random(5));
until(BankScreen or (TimeFromMark(t)>20000)or PinScreen);
Result:=True
end;

Procedure OpenBanker;
Begin
MarkTime(t);
repeat
wait(randomrange(100,200));
if FindBanker then
Begin
MarkTime(b)
repeat
wait(100+random(5));
until(BankScreen or (TimeFromMark(t)>20000)or PinScreen);
end;
until(BankScreen or (TimeFromMark(t)>20000)or PinScreen );
end;

Function DepositAsh:Boolean;
begin
MarkTime(T);
OpenBanker;
if PinScreen then InPin(players[0].Pin);
if BankScreen then
begin
DepositAll;
wait(250+random(50));
CloseBank;
wait(500+random(50));
Result:= True;
writeln('Deposited ashes');
end else
Begin
Result:=False;
writeln('Failed to Deposit');
end
end;

Procedure Bank;
begin
Writeln('banking')
WalkTo(1);
WalkTo(0);
DepositAsh;
AntiBan;
end;

Procedure FindAshes;
var
count,nX,nY,state: Integer;
begin
count := 0
nX := MSCX
nY := MSCY
state := 0
Writeln('trying to find')
while (True) do
begin
if InvFull then
begin
Bank;
Break;
end;
if count > 4 then
begin
if state = 1 then
begin
WalkTo(4);
FindAshes;
end;
Break;
end;
if FindObjCustom(nX, nY, ['Take Ashes'], [13751259], 5) then
begin
Writeln('found ash');
Wait(RandomRange(20,40))
if InvFull then
begin
WalkTo(1);
WalkTo(0);
DepositAsh;
AntiBan;
Break;
end;
Mouse(nX, nY, 0, 0, True);//FindDTM gives (x, y) as the coordinates of the DTM we made it look for.
Wait(RandomRange(2100,2200))
state := 1
end else
begin
count := count + 1
Writeln('didnt find')
end;
end;
end;

begin
ClearDebug;
ClearReport;
SetupSRL;
ActivateClient;
DeclarePlayers;
Wait(500 + Random(500));
if (not LoggedIn) then
LogIn;
SetAngle(SRL_ANGLE_HIGH);
MakeCompass('N');
Debug('Just Set Up Player :)');
Wait(2000);
SPS_Setup(Runescape_Surface,['Beer_Map']);
Repeat
if not LoggedIn then LogIn;
if InvFull then
begin
WalkTo(1);
WalkTo(0);
DepositAsh;
AntiBan;
end;
while(not InvFull) do
begin
Writeln('step1')
FindAshes;
WalkTo(1);
FindAshes;
// AntiBan;
Writeln('step2')
WalkTo(2);
FindAshes;
Writeln('step3')
WalkTo(3);
FindAshes;
// AntiBan;
Writeln('step4')
WalkTo(2);
FindAshes
Writeln('step5')
WalkTo(1);
FindAshes;
Writeln('step6')
WalkTo(4);
end;
Until(false);
end.

xtrapsp
12-07-2012, 09:25 AM
I'm pretty sure with SPS you can make a rough area around where your walking and set it back on the straight and narrow... lol