Log in

View Full Version : How to check if gate is open .



I Am Legend
12-02-2011, 01:26 AM
Hi i have been having problems with this can someone tell me what method i should use to check if gate is open. Another problem is how i can place the character (walk to the gate ) if they are in certain parts of the map .

I attempted to do some of it , but its not workingproperly

program spsTest;
{$DEFINE SMART}
{$i srl/srl.scar}
{$i sps/sps.simba}

var
t: integer;
myPath, bank: TPointArray;
x, y : integer;
procedure HandleBank;
var
B: TBox;
I, x, y: Integer;
begin
if not LoggedIn then Exit;
FindNonInventoryRandoms;

if not OpenBankFast('db') then
begin

if (FindSymbol(x, y, 'bank')) then
begin
Mouse(x, y, 1, 1, True);
Flag;
OpenBankFast('db');
end else Exit;



end;
Wait(300 + Random(50));

DepositAll;

CloseBank;
Wait(300 + Random(50));
FindNonInventoryRandoms;
end;

function openGate:boolean;
var
MyTPA : TPointArray;
MyPoint : TPoint;
x, y, i, DTM ,closed: Integer;

begin

writeln('low angle');


SetAngle(false);
// DTM := DTMFromString('mlwAAAHicY2dgYHgIxJuBWICRgeEekP4KxK eh4vuBeB8Q7wLiuUB8DIrPAbGZgRaDjakeQ2qYC0N2tAdDZqQb GJvoaTDgAqxAzIgHQwEApfcQPA==');

DTM := DTMFromString('mwQAAAHicjcpBCkVgAEXha8g+TCj9ykOSko ENWADZCkZs4A2Yiz2+w+BNufUNbh1bUmdJPTLMaLFgQokYX7oB KzacGHFgx4Qqj9TUqfJPoNh4t+sXiVHouyoTXw7dE+uF/36x5A80');
if FindDTM(DTM,x, y,1, 1, 200, 200) then
begin
writeln('found');
MMouse (MyPoint.x, MyPoint.y, 3, 3);
if (IsUpTextMultiCustom(['pen', 'ate'])) then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
ChooseOption('pen');
Wait(500+random(250));
result := true;
Exit;
end else if (IsUpTextMultiCustom(['pen', 'ate'])) then
result := true;
end;

writeln('north and high angle');

MakeCompass('n');
SetAngle(true);

closed := DTMFromString('mQwAAAHicY2ZgYDgFxKeB+DgQTwXiIiDeAs RZkW4M4Z5WYMwF5MMwIxIGAgA+Owb5');
if FindDTM(closed,x, y,1, 1, 200, 200) then
begin
writeln('found');
MMouse (MyPoint.x, MyPoint.y, 3, 3);
if (IsUpTextMultiCustom(['lose', 'ate'])) then
begin
result := true;
Exit;
end;

writeln('not found');

{ x := MSCx;
y := MSCy;
FindColorsSpiralTolerance(x, y, MyTPA, 3159870 , MSx1, MSy1, MSx2, MSy2, 5);
if Length(MyTPA) = 0 then FindColorsSpiralTolerance(x, y, MyTPA, 4544359 , MSX1, MSY1, MSX2, MSY2, 5);
for i := 0 to High(MyTPA) do
begin
MyPoint := MyTPA[i]
MMouse (MyPoint.x, MyPoint.y, 3, 3);
if (IsUpTextMultiCustom(['pen', 'ate'])) then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
ChooseOption('pen');
Wait(500+random(250));
result := true;
Exit;
end else if (IsUpTextMultiCustom(['pen', 'ate'])) then
result := true;


Wait(350+random(350)); }
end;

end;



procedure walktoGate;

begin


x := MMCX;
y := MMCY;

if FindColorSpiralTolerance(x,y,262904,MMX1, MMY1, MMX2, MMY2, 10) then
begin
Mouse(x, y, 1, 1, True);
Wait(1000); //Waits 2 seconds for the flag to appear on screen
FFlag(10);


end else if FindColorTolerance(x,y,10260102,MMX1, MMY1, MMX2, MMY2, 5) then
RadialWalk(2897982 , 200,210,70,1,1)
else RadialWalk(2897982,180,190,70,1,1);






end;



procedure pickCabbage;
begin
x := MSCX;
y := MSCY;

if(not IsMoving) then
begin
if(FindColorSpiralTolerance(x, y, 6942403, MSX1, MSY1, MSX2, MSY2, 5)) then
begin
MMouse(x,y, 4,4);
Wait(200 + Random(100));
if IsUpText('abbage') then
begin
Mouse(x, y, 0, 0, True);
wait(1000 + random(250));
end else
Writeln('Couldn''t find the uptext of the cabbage.');

end;
end;

end;
begin
smart_server := 1;
smart_members := false;
smart_signed := true;
smart_superDetail := false;

clearDebug();
setupSRL();

SPS_Debug := true;


SPS_Setup(RUNESCAPE_SURFACE, ['11_8','10_8','10_9']);
myPath := [Point(4609, 3520), Point(4551, 3509), Point(4493, 3522), Point(4463, 3564), Point(4421, 3591), Point(4386, 3614), Point(4330, 3625), Point(4281, 3624), Point(4230, 3638), Point(4192, 3666)];;
bank := myPath;
invertTPA(bank);
repeat
inc(t);
HandleBank;

if not InvFull then
begin

if (SPS_WalkPath(myPath)) then
writeLn(format('Walked to Cabbage farm', [t]));
walktoGate;
end;

if InvFull then
begin
walktoGate;

end;

repeat
pickCabbage;
until InvFull;


until(t = 50);






SPS_GetMyPos();


end.






my code so far thanks


it picks cababge and banks in draynor

crap just realised i posted in wrong section .

RISK
12-02-2011, 01:28 AM
A very simple yet fail-prone way is to find the color/colours of the door using TPAs and using ACA to get the hue and saturation of it for more accuracy. Then mouse over it, see if the uptext says "Open" or something like that. If it does, open the door.
You can use SPS to click to the point you desire, can't you? Thru the minimap. But not the exact point as how would a human be able to click the exact point every time? But it's an idea.

E: You posted in the right section. But you shouldn't double post or else you might get in trouble with the staff members.

Narcle
12-02-2011, 01:31 AM
2 things you can do, one is bit more simple and 2nd is more advance.

1st, you can use a TPA (learn them they are amazing) and mouse over to see what UpText comes up, usually 'Open' or 'Closed' should be in.

The 2nd way is using TPA to evaluate the length if its longer North/South or East/West to see if its open or closed.

Edit:
RISK beat me on first one.

euphemism
12-02-2011, 01:31 AM
If you get on the IRC I'll help you a bit.

E: Yes, TPAs are magic.

I Am Legend
12-02-2011, 01:33 AM
lol yeah i remember getting into a heated debate over double posting last time i was here, but i still dont know why.

anyways i tried to use TPAs but the fence around it pretty much have the same colours and so doesnt work, im not sure how to use ACA i read the guides but still dont get it .

Yes i can use SPS but i dont want to ;P want to learn other methods so that when i make other scripts i can it.

RISK
12-02-2011, 01:35 AM
Coh3n has a segment on ACA in his guide, doesn't he? ACA is very simple. Grab the color/colours and then set the CTS to 2.

Coh3n's guide: http://villavu.com/forum/showthread.php?t=49089

Also for your other desire: Why not click to the door line on the minimap? There's a line, isn't there?

I Am Legend
12-02-2011, 01:38 AM
yes there ive already implemented that , but however as the guy is picking cabbage he might go a bit north and the door line will dissapear, i did a simple Radialwalk to walk south west but dont think its good enough

RISK
12-02-2011, 01:42 AM
Can you take a screenshot of the minimap to give us some ideas as to what could help your situation, please?

Narcle
12-02-2011, 01:43 AM
This will auto color the fence color on minimap. Its never failed in the year+ i've used it for my smelter.

function BuildingOutline: integer;
var
arC: TIntegerArray;
i, t: Integer;
H, S, L: Extended;
begin
t := GetSystemTime;
arC := GetColors(TPAFromBox(IntToBox(MMX1, MMY1, MMX2, MMY2)));
ClearSameIntegers(arC);
for i := 0 to High(arC) do
begin
ColorToHSL(arC[i], H, S, L);
if (L >= 91.00) and (L <= 98.0) then
begin
Result := arC[i];
Debugln('BuildingOutline = ' + IntToStr(arC[i])+ ' '+IntToStr(GetSystemTime-t)+'ms');
Exit;
end;
end;
end;

I Am Legend
12-02-2011, 01:48 AM
ok il post a pic after u i finish thie game on LoL

Swagger
12-02-2011, 01:49 AM
Wow, that's the name I tried first ;(.

KingKong
12-02-2011, 04:25 AM
Eh why not use the stile to get over the fence? its a lot easier to find the stile and click it and maybe faster too?

SubiN
12-02-2011, 09:20 AM
are u sure there is stile in every farm ? ^^

KingKong
12-02-2011, 09:35 AM
are u sure there is stile in every farm ? ^^

OP says the script picks cabbage and banks at draynor. Obviously there is a stile there.

I Am Legend
12-04-2011, 06:33 AM
ok i uplaoded the screenshots

http://img803.imageshack.us/img803/7347/cantseegat.jpg

http://img600.imageshack.us/img600/4959/locationt.jpg