SRL Archive - OSR Help

Anything I can do to replace this?


Roflme

2012-09-02 22:09:24

NEED HELP WITH THIS AT THE MOMENT:


I've been trying to get inside the black circle. I've only successfully walked to there once. The SPS walking is inaccurate and will walk a few tiles away from the door, getting it out of range. This is throwing off my loop. What can I do to allow it to get CLOSE to the door so that my script can FindDoor and continue the loop?


EDIT: Thank you everyone for your help. The script is working OK. There are some problems.


1) Item detection - Will go through the find apple/grape functions twice before successfully picking up the item. Will only occur every so often.

2) Stair detection - I still need to play around with it. While browsing the forums I found a ObjFinder function and just leeched that :(. It works though, for the most part. One of three things happens:
a. Works properly, finds stairs on first try
b. Finds stairs eventually
c. Misclicks stairs (VERY RARE THOUGH)

3) Better wait times - I will probably make this into it's own function. The wait timer of the script currently is…bad. It's going down the stairs to the second floor as the third floor has replenished itself. etc. etc. Only a few seconds off but that could mean a few tens of thousands of gold off per hour. Also the wait timers for not only changing floors but for looting items are bad. Looks very bot like.


4) The script in general - It's very sloppy, has lots of unnecessary code. I tried writing some of it as an array but I messed up somewhere so I would make two separate functions (Example: Finding the grape and finding the apple. Both use the SAME function, the only difference is that one uses the GrapeColor result and other uses AppleColor result.)

Oh.. and it also looks very bot-like I suppose…

I've taken the time to go through the script and comment in some Writeln for debugging.

Besides that I'll probably be releasing a version soon with just a little bit of Anti Leech put into it. Would hate to see these prices die. If I notice profits drop substantially then I'll probably take it down or add more Anti Leech.


I'd post the complete code but I don't want to release the script yet :p.

Thanks everyone for helping! Hopefully I can fix some of the smaller bugs once I do release the script!

Footy

2012-09-02 22:15:35

That would work, but it would be pretty slow, or slow compared to other methods you could use. I'd help, but walking isn't my forté.

NKN

2012-09-02 22:18:06

is this for the competition?

Footy

2012-09-02 22:20:36

Also, is a tolerance of 4 enough for the apple? If there aren't any other red colors on the screen, I'd use a higher tolerance, like 10-15. If you could explain exactly what you are trying to do, I might be able to suggest a method.

E: NKN, I'd assume so.

NKN

2012-09-02 22:30:21

Should we be helping for it?
It seems he's going for the advanced part, wouldn't be fair if he got actual help like this, just my opinion.

Footy

2012-09-02 22:36:40

Ask R4nd0m, you are probably correct, I'm not familiar with competition rules.

Roflme

2012-09-02 22:58:18

From: NKN
is this for the competition?


No no no! Wasn't even aware there was a competition! Haha this is just for personal use! :p

Didn't even know villavu had competitions! Going to have to enter in the next one :)

EDIT: And after reading it, it looks like the Guild AIO is for SRL members only so I'd be ineligible to enter anyways :p

From: Footy
Also, is a tolerance of 4 enough for the apple? If there aren't any other red colors on the screen, I'd use a higher tolerance, like 10-15. If you could explain exactly what you are trying to do, I might be able to suggest a method.

E: NKN, I'd assume so.

A tolerance of 4, as I've found, was TOO much :p just lowered it to 2.

The apple is a cooking apple. It's green. It's having problems with the grass if the tolerance is too high :p

What I'm trying to do is, after the script clicks on the apple, while it's moving to pick it up, it's going to be, well, doing nothing until the apple is added into the inventory. What I had originally was it waiting a set time with some randomness. But that doesn't account for lag, so if lag spikes it would click again before grabbing the apple. It could miss click, but I'm more worried that it'd look bot-like clicking on the apple twice. So was just looking for something that accounted for the lag, and was hoping IsMoving would be a good replacement for the wait I've got in there.

Footy

2012-09-02 23:09:54

I'm on my phone, so I can't really write this out in pascal, but I'll describe what you should do.

Locate the apple with color, confirm with up text. Click the mouse, and if didredclick returns true, repeat wait(randomrange(200, 500)) until the invcount before we started the loop is lower then the new invcount. Use a timefrommark failsafe to remove possibility of infinite loop. If red didn't click, maybe try to find the apple one more time.

riwu

2012-09-02 23:12:05

From: Roflme

EDIT: And after reading it, it looks like the Guild AIO is for SRL members only so I'd be ineligible to enter anyways :p

Anyone can join the members category. Anyway if you don't plan to join and dont mind waiting 4 weeks, there will be tons of cooking guild scripts that you can use soon ;)

Roflme

2012-09-02 23:16:13

From: riwu
Anyone can join the members category. Anyway if you don't plan to join and dont mind waiting 4 weeks, there will be tons of cooking guild scripts that you can use soon ;)


Oh really???

Well it seems that the script needs to cook according to the competition rules? I'm making a script to collect apples, grapes, and will add other items soon for easy low requirement F2P profit :D


From: Footy
I'm on my phone, so I can't really write this out in pascal, but I'll describe what you should do.

Locate the apple with color, confirm with up text. Click the mouse, and if didredclick returns true, repeat wait(randomrange(200, 500)) until the invcount before we started the loop is lower then the new invcount. Use a timefrommark failsafe to remove possibility of infinite loop. If red didn't click, maybe try to find the apple one more time.


Didredclick… Thank you for that function.

I am a little worried though because I'm not using uptext. I'll have to attack that tomorrow. I was having problems with it. The script wasn't continuing even though the uptext was correct. The script was accurate enough that I wasn't worrying about that though.

My current failsafe is to stop when it cannot find the color, but I've added a timefrommark for another failsafe, since my others could lead to some issues (second floor, if clicking on an apple and someone else takes it and leaves the other, could cause an infinite loop, though I'm not sure. InvCount would not = PlusOne, and it would still find the apple color of the other apple. But perhaps when it would repeat the MMouse to x, y it could move to the other apple? who knows. I'd need someone else in the room to try it with me.

riwu

2012-09-02 23:18:49

From: Roflme
Oh really???

Well it seems that the script needs to cook according to the competition rules? I'm making a script to collect apples, grapes, and will add other items soon for easy low requirement F2P profit :D

The script should do everything with options to do selected parts. Since it's a competition you can expect scripts of pretty high standards :)

Roflme

2012-09-02 23:30:23

From: riwu
The script should do everything with options to do selected parts. Since it's a competition you can expect scripts of pretty high standards :)


From: R4nd0m

What you are to build:
I would like to see the Cooking Guild AIO
Start with 50gp in bank or pouch/inventory
Buy a chef's hat (Beefy bills, yes it is kind of far :p)
Enter the cooking guild
Cook everything (f2p) in the guild, including pie by collecting wheat outside.
Banking items
Repeating



I'm really hoping none of them have an option for just picking up items and then banking. It's a good source of F2P money that I'd hate see get ruined. Hope the scripts released only have the option for cooking. :(



Oh, and a few random questions:

1) What can I use to make a script not continue unless it counts a certain amount of pixels of a color in a group? Trying to make a function for detecting the stairs, and the top of the stair is a greyish color, but the outside of the roof that can be seen in the building is also greyish. When I was using ACA the top of the stairs was found perfectly but the roof had scattered pixels found. Does a function exist that will come back true when a certain number of pixels are found in an area?

2) Would TPAs be the best choice for checking multiple areas of colors found? Until I get a permanent fix on it, the script will sometimes click on a tree leaf for some odd reason. Until I can fix that I wanted to have the script check every color that it possibly found and if it doesn't have the correct uptext it'll go to the next. I heard TPAs could do that. And even though I suck with them I would be willing to learn them if it would really help

riwu

2012-09-02 23:34:30

From: Roflme
I'm really hoping none of them have an option for just picking up items and then banking. It's a good source of F2P money that I'd hate see get ruined. Hope the scripts released only have the option for cooking. :(


SRL members+ Section:
Must include Banking

Not to worry though, the scripters may keep it in members section and maybe only a lite version w/o banking to the public.
What's the max profit/hr in cook's guild for f2p btw?

Roflme

2012-09-03 09:37:03

From: riwu
Not to worry though, the scripters may keep it in members section and maybe only a lite version w/o banking to the public.
What's the max profit/hr in cook's guild for f2p btw?


But the banking is only for banking cooked food? Not for looting grapes/apples/etc. and banking those?

Well depends how many items you have it collecting. I think there was a script released in First Script section that only did grapes, and it's looking like it's getting about 70k p/h market price (don't know how the market of grapes does). If you are looting EVERYTHING that's decent profit (chocolate bar, apple, pie dish, jug, grape; hoping to have everything but chocolate bar functional when I release the script :p) you are looking at 140k-150k per hour.

And that's with a very low requirement of 32 cooking, AND you could run the script 24/7.

I'd release it with an anti-leech just so no leechers abused it (I'm going to need to make another post about that when the time comes asking people to judge/suggest some anti-leech. I have a few ideas but don't really know what else I should be err, breaking, in the script for people to fix :p).


EDIT: And there's an injection bot (maybe multiple IDK) with full collectors… One in every two worlds though nothing to worry about. Was just having problems finding a world to continue testing in :p

Roflme

2012-09-03 17:22:41

To save me from posting another thread, I'll just ask this here and hope to get a response…

What's the best method of using stairs?

Here is the top floor. The top of the stairs has a distinct color from the rest of the building. Unfortunately as you can see the roof is close to being the same color. If standing on the other side of the table due north of the stairs, a FindObj function (obtained from ACA) will be searching all over the roof. If standing where I currently am, the ACA function will find it properly. I need a method for ALWAYS finding it ACCURATELY.

Plus, the second floor has a problem.


The same color used for the top floor is, well, not so visible anymore. I still believe that, according to ACA, it's coming back as having the largest group of same colored pixels connected.

Been searching around and looking at other's scripts, have a few ideas but I was looking for something that I could make myself. I'd like to prevent myself from using as many functions as possible from other sources, and ACA has already helped me with finding grape and apple color so I'd like to limit any further copying and pasting. But if I must, I will. If there's no real "best" way of detecting the stairs in this case I'll just come up with some makeshift function that'll just get it done, regardless of quality :p

Footy

2012-09-03 17:44:28

Wow, that looks pretty tough to do, you could try to detect that pole going through the stairs if it has no nearby color matches, and you can use TPA's and uptext checking to ensure even if it finds the wrong color first, it will find the stairs eventually.

Solar

2012-09-03 18:02:51

I'm not sure how you'd go about doing it, but maybe you could try finding the grey and brown colour of the stairs together using TPAs (if this is possible, I assume so).
An easier route, if the compass angle is always the same, might be to try and use a bitmap.
These are just my ideas though, I'm not experienced with either method.

Roflme

2012-09-03 18:39:09

@Footy I tried using the poles and TPAs, maybe I'll have to approach it differently. Got to try everything multiple times :(



@Solar Never used bitmaps, will have to look into those.

I would just have it set the angle high and compass north (that's what I have it doing throughout the picking up part of the script).

Can TPAs find the colors together? I'm still learning TPAs and haven't a clue how to use them to their full potential :p

CephaXz

2012-09-03 20:05:18

Does it have a ladder icon on the minimap? You can try MMtoMS.

Footy

2012-09-03 20:10:52

I wouldnt suggest using symbols finding as your main failsafe/location detecter. It only takes one NPC/Player to wander over the symbol, and it will return false.

CephaXz

2012-09-03 20:13:48

I would use color of the ladder on minimap instead of the full symbol.

[XoL]

2012-09-03 20:18:55

Seeing as this is not for the competition it is all good!

Roflme

2012-09-03 20:28:44

From: R4nd0m
Seeing as this is not for the competition it is all good!

Reading the competition requirements, I didn't see that any of the scripts were going to be based on collecting the items. Is this true? I don't want those scripts being released and killing this method :(

From: CephaXz
I would use color of the ladder on minimap instead of the full symbol.

Would you suggest MMtoMS over MMtoMSEx? I never knew about this function and after reading them both I can't see a difference besides MMtoMSEx has an X and Y mod and MMtoMS doesn't.

CephaXz

2012-09-03 20:48:26

From: Roflme
Reading the competition requirements, I didn't see that any of the scripts were going to be based on collecting the items. Is this true? I don't want those scripts being released and killing this method :(


Would you suggest MMtoMS over MMtoMSEx? I never knew about this function and after reading them both I can't see a difference besides MMtoMSEx has an X and Y mod and MMtoMS doesn't.


I believe in MMtoMSEx, you can adjust the X and Y axis, whether you want to + or - from the point it gets you. In case the point MMtoMS gives you isn't what you want, you could use it. FYI, MMtoMS is made from MMtoMSEx.


Function MMtoMS(MM: TPoint): TPoint;
begin
Result := MMtoMSEx(0, -20, MM);
end;

This is a function I used quite long ago, colors might be outdated, but you can try it. Its only the half part of the whole function, the other half is a failsafe in case MMtoMS didn't work.


Function ClickLadder: Boolean;
var
Lad, MP: TPoint;
TPA: TPointArray;
ATPA: T2DPointArray;
find: Integer;
begin
FindMMColorsSpiralTolerance(TPA, 799581, 10);
ATPA := TPAtoATPAEx(TPA, 10, 10);
if Length(ATPA) < 1 then
writeln('Fail MMtoMS ladder')
else
begin
MP := MiddleTPA(ATPA[0]);
SMART_DrawCircle(true, MP, 10, false, clRed);
Lad := MMtoMS(Point(MP.x, MP.y));
Mouse(Lad.x, Lad.y, 2, 2, mouse_Right);
if WaitOption('lim', 2000) then
begin
Result := True;
writeln('Climbing');
end;
end;
end;

Roflme

2012-09-03 21:15:07

From: CephaXz
I believe in MMtoMSEx, you can adjust the X and Y axis, whether you want to + or - from the point it gets you. In case the point MMtoMS gives you isn't what you want, you could use it. FYI, MMtoMS is made from MMtoMSEx.


Function MMtoMS(MM: TPoint): TPoint;
begin
Result := MMtoMSEx(0, -20, MM);
end;

This is a function I used quite long ago, colors might be outdated, but you can try it. Its only the half part of the whole function, the other half is a failsafe in case MMtoMS didn't work.


Function ClickLadder: Boolean;
var
Lad, MP: TPoint;
TPA: TPointArray;
ATPA: T2DPointArray;
find: Integer;
begin
FindMMColorsSpiralTolerance(TPA, 799581, 10);
ATPA := TPAtoATPAEx(TPA, 10, 10);
if Length(ATPA) < 1 then
writeln('Fail MMtoMS ladder')
else
begin
MP := MiddleTPA(ATPA[0]);
SMART_DrawCircle(true, MP, 10, false, clRed);
Lad := MMtoMS(Point(MP.x, MP.y));
Mouse(Lad.x, Lad.y, 2, 2, mouse_Right);
if WaitOption('lim', 2000) then
begin
Result := True;
writeln('Climbing');
end;
end;
end;

Alright I'm actually going to try that :p

If I may ask, what is the 0 in ATPA[0] representing exactly? I understand everything but that part :(

CephaXz

2012-09-03 21:18:30

From: Roflme
Alright I'm actually going to try that :p

If I may ask, what is the 0 in ATPA[0] representing exactly? I understand everything but that part :(


The first TPA in the Array of TPA.

[XoL]

2012-09-03 21:25:16

From: Roflme
Reading the competition requirements, I didn't see that any of the scripts were going to be based on collecting the items. Is this true? I don't want those scripts being released and killing this method :(


Would you suggest MMtoMS over MMtoMSEx? I never knew about this function and after reading them both I can't see a difference besides MMtoMSEx has an X and Y mod and MMtoMS doesn't.


Truly it could be an option in the script but I don't see many people releasing it to the public if this is a massive economy killer.

Roflme

2012-09-03 21:30:20

From: CephaXz
The first TPA in the Array of TPA.


:duh:


INCOMING WALL OF TEXT

I apologize I tend to write a lot…




Anyways…

function StairImageColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.51, 3.87);

if not (FindColorsTolerance(arP, 601945, MMX1, MMY1, MMX2, MMY2, 2)) 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
Result := arC[i];
//Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;

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

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

Function Stairs(Option: String): Boolean;
var
S, MP: TPoint;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
FindMMColorsSpiralTolerance(TPA, StairImageColor, 15);
ATPA := TPAtoATPAEx(TPA, 10, 10);
if Length(ATPA) < 1 then
begin
Writeln('Failed to find Stair Image');
TerminateScript;
end else
begin
MP := MiddleTPA(ATPA[0])
S := MMtoMSEx(0, 10, Point(MP.x, MP.y));
MMouse(S.x, S.y, 1, 1);
if IsUpText('limb') then
begin
Result := true
ClickMouse2(false);
WaitOption(Option, 2000);
end;
end;
end;

Added that, and then was doing Stairs('limb-u') or Stairs('limb-do') but now I came across this…



Lol@MyLuck.

Seems to happen every so often. Was moving up and down the steps just fine until that happened. Thank you very much for the MMtoMS function though.

EDIT: Hmm…trying to think of a way to make use of the images if they cover the stair image on MM…was just going to do MMtoMS for the symbol but… the symbol varies and that could cause problems… Meh, I'll try to find a way around that :p


From: R4nd0m
Truly it could be an option in the script but I don't see many people releasing it to the public if this is a massive economy killer.


It wouldn't be MASSIVE, unless our definitions of massive are different. But I urge you to urge anyone entering a script to take that feature out if they are going to release it publicly :p. This is just something that can easily be botted by multiple accounts 24/7 = Could destroy method.





EDIT: Does a time mark in a repeat restart itself? :p Don't want to have any problems with this:

Procedure Loop;
var
Waiting: Integer;
begin
repeat
MarkTime(Waiting);
TakeApple;
TakeGrape;
Wait(100+random(80));
AntiBan;
until InvFull or (TimeFromMark(Waiting) > 10000);
end;

Would test myself but still working on one missing component to the loop :(

CephaXz

2012-09-03 21:41:28

Got no other option. Only thing I can think of is finding a unique color with higher CTS.

Footy

2012-09-03 22:55:48

From: Roflme
:duh:


INCOMING WALL OF TEXT

I apologize I tend to write a lot…




Anyways…

function StairImageColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.51, 3.87);

if not (FindColorsTolerance(arP, 601945, MMX1, MMY1, MMX2, MMY2, 2)) 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
Result := arC[i];
//Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;

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

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

Function Stairs(Option: String): Boolean;
var
S, MP: TPoint;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
FindMMColorsSpiralTolerance(TPA, StairImageColor, 15);
ATPA := TPAtoATPAEx(TPA, 10, 10);
if Length(ATPA) < 1 then
begin
Writeln('Failed to find Stair Image');
TerminateScript;
end else
begin
MP := MiddleTPA(ATPA[0])
S := MMtoMSEx(0, 10, Point(MP.x, MP.y));
MMouse(S.x, S.y, 1, 1);
if IsUpText('limb') then
begin
Result := true
ClickMouse2(false);
WaitOption(Option, 2000);
end;
end;
end;

Added that, and then was doing Stairs('limb-u') or Stairs('limb-do') but now I came across this…



Lol@MyLuck.

Seems to happen every so often. Was moving up and down the steps just fine until that happened. Thank you very much for the MMtoMS function though.

EDIT: Hmm…trying to think of a way to make use of the images if they cover the stair image on MM…was just going to do MMtoMS for the symbol but… the symbol varies and that could cause problems… Meh, I'll try to find a way around that :p




It wouldn't be MASSIVE, unless our definitions of massive are different. But I urge you to urge anyone entering a script to take that feature out if they are going to release it publicly :p. This is just something that can easily be botted by multiple accounts 24/7 = Could destroy method.





EDIT: Does a time mark in a repeat restart itself? :p Don't want to have any problems with this:

Procedure Loop;
var
Waiting: Integer;
begin
repeat
MarkTime(Waiting);
TakeApple;
TakeGrape;
Wait(100+random(80));
AntiBan;
until InvFull or (TimeFromMark(Waiting) > 10000);
end;

Would test myself but still working on one missing component to the loop :(


Put the marktime before the loop. And also, you probably don't want your script to continue normally if it times out, you would want to print an error line to debug and attempt to recover. To do that, do this

marktime(counter);
Repeat
Blahblahblaj
if timefrommark(counter) > 10000 then
begin
writeln('Error!');
Recoveryprocedure;
end;
until(invfull);

Roflme

2012-09-03 23:21:25

From: Footy
Put the marktime before the loop. And also, you probably don't want your script to continue normally if it times out, you would want to print an error line to debug and attempt to recover. To do that, do this

marktime(counter);
Repeat
Blahblahblaj
if timefrommark(counter) > 10000 then
begin
writeln('Error!');
Recoveryprocedure;
end;
until(invfull);


At the moment I've got it so after 10 seconds it's going to be moving up/down the stairs. Didn't add that portion into the code there.


program RoflmeCookGuild;


{$DEFINE SMART}
{$i SRL/SRL.simba}
{$i SPS/SPS.simba}
{$i SRL/SRL/Misc/Debug.simba}
{$I SRL/SRL/Misc/Online.simba}


var
x, y:Integer;


procedure DeclarePlayers; // Declares your player.
begin // Multi Players will be added
HowManyPlayers := 1; // later.
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
With Players[0] do
begin
Name := '';
Pass := '';
Pin := '';

Active := true;
end;
end;


procedure AntiBan; // Performs AntiBan..
begin
Case Random(800) of
1: RandomRClick;
2: RandomMovement;
3..10: BoredHuman;
11..20: PickUpMouse;
21..700: Wait(300);
end;
SetAngle(SRL_ANGLE_HIGH);
MakeCompass('N');
Wait(350+Random(200));
end;


Function WhichFloor: Integer; // If finds the right symbol(s)
var // then it knows what floor it's
TPA: TPointArray; // on. If it doesn't find symbols
begin // it'll know that it's on other floor
if FindSymbolsMulti(TPA, ['cook', 'churn']) then
begin
Result := 2;
Writeln('On floor 2');
Exit;
end else
Result := 3;
Writeln('On floor 3');
Exit;
end;

function StairImageColor: Integer; // Credits to ACA
var // (AutoColor Aid)
arP: TPointArray; // Gets stair color on Minimap (the image that looks like a ladder).
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.51, 3.87);

if not (FindColorsTolerance(arP, 601945, MMX1, MMY1, MMX2, MMY2, 2)) then
begin
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
Result := arC[i];
Break;
end;

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

if (i = arL + 1) then
end;

Function Stairs: Boolean; // Credits to CephaXz
var // for the main function (made a few
S, MP: TPoint; // edits for this script).
TPA: TPointArray; // Will take the StairImageColor found and use it to
ATPA: T2DPointArray; // find the stairs on the Main Screen.
begin
FindMMColorsSpiralTolerance(TPA, StairImageColor, 15);
ATPA := TPAtoATPAEx(TPA, 10, 10);
if Length(ATPA) < 1 then
begin
Writeln('Failed to find Stair Image');
TerminateScript;
end else
begin
MP := MiddleTPA(ATPA[0])
S := MMtoMSEx(5, 20, Point(MP.x, MP.y));
MMouse(S.x, S.y, 1, 1)
if IsUpText('limb') then
begin
Result := true
Writeln('Found Stairs');
ClickMouse2(mouse_right);
Writeln('Right clicked stairs');
end;
end;
end;

Function GoDownStairs: Boolean; // Will go downstairs until it confirms
begin // it's on the bottom floor. If "On floor"
AntiBan; // is bothering you just comment it out with two backslashes infront of it
if Stairs then // //WriteLn('On floor ' + IntToStr(WhichFloor));
repeat
WaitOption('limb-do', 4000);
Writeln('On floor ' + IntToStr(WhichFloor));
until FindSymbol(x, y, 'bank');
if FindSymbol(x, y, 'bank') then
begin
Result := true
Writeln('On bottom floor');
Exit;
end else
Result := false;
end;



function GrapeColor: Integer; // Credit to ACA again.
var // Finds the best color to use for Grape.
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.21, 0.99);

if not (FindColorsTolerance(arP, 7150462, MSX1, MSY1, MSX2, MSY2, 13)) 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
Result := arC[i];
//Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;

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

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


function AppleColor: Integer; // Same as above but for Apple this time.
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.25, 1.51);

if not (FindColorsTolerance(arP, 2867819, MSX1, MSY1, MSX2, MSY2, 8)) 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
Result := arC[i];
//Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;

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

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


Function FindApple: Boolean; // Uses the color result to confirm that object is apple.
var
CTS, I, H: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;

begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.23, 1.02);
For H := 0 to 1 do
FindColorsSpiralTolerance(MSCX, MSCY, TPA, AppleColor, MSX1, MSY1, MSX2, MSY2, 0);
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 5, 5);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y+1, 0, 0);
Wait(150+random(10));
If IsUpText('ake') then
begin
Result := True
Break;
end;
end;
end;


Function FindGrape: Boolean; // Same as above, with grape this time.
var
CTS, I: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;

begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.23, 1.02);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, GrapeColor, MSX1, MSY1, MSX2, MSY2, 0)
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 5, 5);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y+1, 0, 0);
Wait(150+random(10));
If IsUpText('ake') then
begin
Result := True
Break;
end;
end;
end;


Procedure TakeApple; // Actually takes the apple.
var
PlusOne: Integer;
begin
PlusOne := InvCount + 1
if FindApple then
repeat
Wait(70+random(20));
ClickMouse2(true);
AntiBan;
repeat
Wait(80+random(50));
until not IsMoving;
until (PlusOne=InvCount) or (FindApple=false);
end;

Procedure TakeGrape; // Actually takes the grape.
var
PlusOne: Integer;
begin
PlusOne := InvCount + 1
if FindGrape then
repeat
Wait(30+random(20));
ClickMouse2(true);
AntiBan;
repeat
Wait(600+random(50));
until not IsMoving;
until (PlusOne=InvCount) or (FindGrape=false);
end;


Procedure Loop; // The main loop...
var // This is what the script will actually do.
Waiting: Integer;
begin
MarkTime(Waiting);
repeat
TakeApple;
TakeGrape;
Wait(100+random(80));
AntiBan;
until InvFull or (TimeFromMark(Waiting) > 5000);
if TimeFromMark(Waiting) > 5000 then
if InvFull then
begin
GoDownstairs;
end else
if FindApple or FindGrape then
begin
Loop;
end else
begin
Writeln('Time to check other floors...');
if Stairs then
Case WhichFloor of
2:
begin
WaitOption('limb-u',5000);
end;
3:
begin
WaitOption('limb-do', 5000);
end;
end;
end;
if InvFull then
GoDownStairs;
end;


begin
Cleardebug;
DeclarePlayers;
SRL_SixHourFix := True;
Smart_FixSpeed := True;
SetupSRL;
SmartSetRefresh(70);
LoginPlayer;
SetAngle(SRL_ANGLE_HIGH);
MakeCompass('N');
Repeat
Loop;
until InvFull;
end.

The ONLY problem I'm having at the moment is using the stairs.

It will sometimes have to run through the loop twice (sometimes even more). But eventually it will get up and down the stairs.

EDIT: Now it's having problems finding the stair image on the second floor..[


Now my challenge is getting a function working for the door. Since the whole bottom floor has brown everywhere color isn't doing so well :p
Door has finally been conquered :p
 Function FindDoor: Boolean;
var
CTS, I, H, x, y: Integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
SetAngle(SRL_ANGLE_LOW);
MakeCompass('N');
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.23, 1.02);
For H := 0 to 1 do
FindColorsSpiralTolerance(MSCX, MSCY, TPA, DoorColor, MSX1, MSY1, MSX2, MSY2, 0);
ColorToleranceSpeed(CTS);

ATPA := TPAtoATPAEx(TPA, 10, 15);
SortATPASize(ATPA, true);

For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 0, 0);
Wait(150+random(10));
If IsUpText('oor') then
begin
Result := True
Break;
end;
end;
end;
From what I've tested this found the door :D from SRL_Angle_Low in one of the southern spots of inside cooking guild.


If anyone has suggestions on any methods for detecting stairs I'd appreciate it. I have a function that only works sometimes :(

Roflme

2012-09-05 15:17:53


I've been trying to get inside the black circle. I've only successfully walked to there once. The SPS walking is inaccurate every so often and will walk a few tiles away from the door, getting it out of range. This is throwing off my loop. What can I do to allow it to get CLOSE to the door so that my script can FindDoor and continue the loop?

Kasi

2012-09-05 15:25:55

From: Roflme

I've been trying to get inside the black circle. I've only successfully walked to there once. The SPS walking is inaccurate every so often and will walk a few tiles away from the door, getting it out of range. This is throwing off my loop. What can I do to allow it to get CLOSE to the door so that my script can FindDoor and continue the loop?


i could attempt to make you some mapwalk. are you walking from the bank?
edit : if so what bank slot?

Roflme

2012-09-05 21:59:06

From: pur3b100d
i could attempt to make you some mapwalk. are you walking from the bank?
edit : if so what bank slot?


Walking from the bank, yes.

Still perfecting it to go to a specific bank slot. Right now it (hopefully) goes to the middle of the bank and then finds a banker and banks with it. This is because, even though I have my TPAs ordered from closest to furthest it was still clicking on bankers further away, and if the character was in front of one banker and clicked on another, the character "cannot reach that".

Mapwalk? Vs. SPS Walkpath? What's the difference?

I was thinking about having it do radial walk towards the end with the color in front of the guild. That way the final walking spot will be right in front of the doors, causing the script to be close enough so the function successfully finds the door (The finding door function was very tricky, and I have it so the character is required to go to the lowest angle and turn the camera so the door is in the middle of the screen. Semi-bot like but at least it can find the door).

Kasi

2012-09-06 15:23:11

From: Roflme
Walking from the bank, yes.

Still perfecting it to go to a specific bank slot. Right now it (hopefully) goes to the middle of the bank and then finds a banker and banks with it. This is because, even though I have my TPAs ordered from closest to furthest it was still clicking on bankers further away, and if the character was in front of one banker and clicked on another, the character "cannot reach that".

Mapwalk? Vs. SPS Walkpath? What's the difference?

I was thinking about having it do radial walk towards the end with the color in front of the guild. That way the final walking spot will be right in front of the doors, causing the script to be close enough so the function successfully finds the door (The finding door function was very tricky, and I have it so the character is required to go to the lowest angle and turn the camera so the door is in the middle of the screen. Semi-bot like but at least it can find the door).


erm i had an attempt at walking from the bank to the door. the autocolor might be a little off but other then that it should be fine :P

Roflme

2012-09-06 15:33:13

From: pur3b100d
erm i had an attempt at walking from the bank to the door. the autocolor might be a little off but other then that it should be fine :P


I can always edit the AutoColor up. Thank you for this :D going to have to try this and see if I can understand what you did :p

Kasi

2012-09-06 15:35:06

From: Roflme
I can always edit the AutoColor up. Thank you for this :D going to have to try this and see if I can understand what you did :p


Yes try do ;) First time iv used DDTM's like that, its really accurate, the autocolor is for the dirt road, the one going to G.E etc. tell me if you have any problems :P

Roflme

2012-09-06 22:40:59

From: pur3b100d
Yes try do ;) First time iv used DDTM's like that, its really accurate, the autocolor is for the dirt road, the one going to G.E etc. tell me if you have any problems :P


DDTMs… hmm just found a tutorial on them… I'll have to look into them.

Tried the walking once. I believe I'll need to edit the road color. It was stuck the point before the cooking guild. Unfortunately I only tested it once. I've been trying to get on top of my homework because next year I can't be caught procrastinating in college :p so I haven't had time to test it again :( As soon as this week is over I'm going to test it again and hopefully release it. Just need to fix some last thing(s) after walking is done:

1) For some reason at the bottom floor (when going to the bank) it still tries to detect the stairs. But after a few seconds THEN it finally recognizes that it's at the bottom floor. I'll probably just have to add my FirstFloor check function in a few sections.

2) Stair detection is a little off. MOST LIKELY just have to play around with hue and saturation modifications. Or find a new function :( but I'm SO CLOSE to getting this finished. It's bothering me :p

3) Detecting when IN the cooking guild. Right now I just HOPE that the script detects the door…. he he he…. Not good :p. But I need to make sure that it can get in front of the door (better walking) and test a full loop to know that I can afford spending time fixing that over other things.


Any suggestions on how to approach any of those three topics would be highly appreciated. I want to get this done to work on another script idea that I've began :p

Kasi

2012-09-07 12:58:13

use ACA2 to get all the colors on cts2. it should work like a charm

Roflme

2012-09-07 15:46:16

From: pur3b100d
use ACA2 to get all the colors on cts2. it should work like a charm


Planned on it, I think a third of the code are ACA autocolor functions :p

Roflme

2012-09-09 11:26:15

From: Roflme
Planned on it, I think a third of the code are ACA autocolor functions :p


Merp, can't seem to get it to work. Walks to a few points but then it stops before it can get to the Cooks Guild door.

If I can't get it done in the next week I'll just release it and the banking procedures will be the anti-leech :p



Why is the walking so difficult :(

BigFate

2012-09-09 12:29:55

For the walking to the guild, you see the wheat field to the north of the guild
What I did was get a TPA of the wheat field, sort the TPA so that I had the point on the south east corner of the wheat field, I then used this point as a reference to click just in front of the cooking guild door.

If FindColorsSpiralTolerance(MMCX,MMCY, TPA, WheatColor, MMX1, MMY1, MMX2, MMY2, 3) then //finding the wheat color, I used Autocolor function that I named WheatColor but you don't really need that just use ACA to get best color and pop that in
begin
RemoveDistTPointArray(MMCX, MMCY, 74, TPA, True); //removing points not within the minimap
SortTPAFrom(TPA,Point(MMCX+41,MMCY+42)); //sorting from south east, a better way would be to sort the TPA vertically and then horizontally to get the corner or make an ATPA and get the middle but I couldn't be bothered
MMouse(TPA[0].x-1,TPA[0].y+53,0,0); // The corner of the wheat field is TPA[0].x , TPA[0].y and the guild door is -1,+53 away from it.
ClickMouse2(1);
wait(500);
repeat
wait(500);
until not (IsMoving);
end;


I'm not very good at explaining things but I hope you can kind of understand that. It's basic but works well. You can just use SPS or point clicking to get you in the general area of the cooking guild (you must be able to see the wheat field though) and then at the end use the above bit to get yourself in front of the door.

I also did the same kind of thing close to the bank where I use the red arrow symbol as my reference point because the arrow does not move and the colours on the arrow stay the same. Also the exclamation sign always appears underneath the arrow, and it is impossible for someone to walk on top of the arrow so it is never be blocked by anything.
The light blue circle shows the arrow I use, the green cross shows where I want it to click when I am going into the bank to deposit the grapes (at the end of the WalkToBank procedure from my Grape Grabber script), the purple cross shows where I want it to click when I am going out of the bank back to the guild (start of the WalkToGuild procedure from my Grape Grabber script).

Kasi

2012-09-09 12:55:35

From: Roflme
Merp, can't seem to get it to work. Walks to a few points but then it stops before it can get to the Cooks Guild door.

If I can't get it done in the next week I'll just release it and the banking procedures will be the anti-leech :p



Why is the walking so difficult :(


if its not working its got to be the autocolor, it works perfectly when the autocolor is correct.

Roflme

2012-09-09 15:55:25

From: BigFate
For the walking to the guild, you see the wheat field to the north of the guild
What I did was get a TPA of the wheat field, sort the TPA so that I had the point on the south east corner of the wheat field, I then used this point as a reference to click just in front of the cooking guild door.

If FindColorsSpiralTolerance(MMCX,MMCY, TPA, WheatColor, MMX1, MMY1, MMX2, MMY2, 3) then //finding the wheat color, I used Autocolor function that I named WheatColor but you don't really need that just use ACA to get best color and pop that in
begin
RemoveDistTPointArray(MMCX, MMCY, 74, TPA, True); //removing points not within the minimap
SortTPAFrom(TPA,Point(MMCX+41,MMCY+42)); //sorting from south east, a better way would be to sort the TPA vertically and then horizontally to get the corner or make an ATPA and get the middle but I couldn't be bothered
MMouse(TPA[0].x-1,TPA[0].y+53,0,0); // The corner of the wheat field is TPA[0].x , TPA[0].y and the guild door is -1,+53 away from it.
ClickMouse2(1);
wait(500);
repeat
wait(500);
until not (IsMoving);
end;


I'm not very good at explaining things but I hope you can kind of understand that. It's basic but works well. You can just use SPS or point clicking to get you in the general area of the cooking guild (you must be able to see the wheat field though) and then at the end use the above bit to get yourself in front of the door.

I also did the same kind of thing close to the bank where I use the red arrow symbol as my reference point because the arrow does not move and the colours on the arrow stay the same. Also the exclamation sign always appears underneath the arrow, and it is impossible for someone to walk on top of the arrow so it is never be blocked by anything.
The light blue circle shows the arrow I use, the green cross shows where I want it to click when I am going into the bank to deposit the grapes (at the end of the WalkToBank procedure from my Grape Grabber script), the purple cross shows where I want it to click when I am going out of the bank back to the guild (start of the WalkToGuild procedure from my Grape Grabber script).

I'll give both of those a shot. I'm getting sick of this script though :p I've other ideas in mind and this script is just time consuming to make sure everything is detected accurately. I understood what you explained and will give it an attempt. If I still can't get it working I'll just release it and say the anti leech is fixing the script to work :p

@pur3 I'll try getting autocolor again. The one going to GE? Not the one in front of cook guild? (They seemed to be ever so slightly different).

Kasi

2012-09-09 18:56:58

ah yer it will most likely be autocolor, i used what bigfate calls reference points in my code, i just call them offsets. it can't really fail i just tested it again, input the colors manually and it seems to still work fine, i think if anything it is the autocolor.

Roflme

2012-09-09 20:26:07

Alright, I'll try it once more sometime this week :p



And for something unrelated to previous discussion, does anyone know why this:
  If PlusOne=InvCount then
begin
Inc(amount)
Writeln(IntToStr(amount));
end;
Continues to print 1 in the debug? How come it doesn't print 1, 2, 3 etc. etc. :(

Hopefully it's a dumb mistake I discover in the next few minutes.


Yup… just moved it out of that procedure and now it's counting properly… :duh: