SRL Archive - OSR Help

Quick question


Bionicle

2010-01-26 15:46:40

Well I'm working on a script, it has been a while since I've last scripted, and I just wanted to run something by you (you being anyone). I am trying to figure out a way to detect if the character is animating (chopping the tree). This is what I am using atm, it works pretty well, however sometimes it says that the character is not animating, and searches for a tree to chop again. It also has a failsafe that if it still is moving after a minute, it will break from the loop (i dont know how that could be a problem, but ya never know ;))
Repeat
//Stuff to find tree
//Stuff to click tree
Repeat
//Stuff to do while chopping
MarkTime(TreeTime);
//More stuff to do while chopping
Until((Not(Animating(IntToBox(MSCX-30, MSCY-100, MSCX+30, MSCY+100), 500, 440))) or (TimeFromMark(TreeTime) > 60000));
Until(InvFull Or Not LoggedIn);
Any suggestions for better tactics? Or do you think it is fine. The way my script searches for a tree is the one closest to your character, so if it does, it clicks the tree I'm chopping (usually), which some people do whilst woodcutting when they get bored/impatient, ergo it's not that big of a deal. But still, opinions?

Mr. Doctor

2010-01-26 16:05:59

From: bionicle1800
Well I'm working on a script, it has been a while since I've last scripted, and I just wanted to run something by you (you being anyone). I am trying to figure out a way to detect if the character is animating (chopping the tree). This is what I am using atm, it works pretty well, however sometimes it says that the character is not animating, and searches for a tree to chop again. It also has a failsafe that if it still is moving after a minute, it will break from the loop (i dont know how that could be a problem, but ya never know ;))
Repeat
//Stuff to find tree
//Stuff to click tree
Repeat
//Stuff to do while chopping
MarkTime(TreeTime);
//More stuff to do while chopping
Until((Not(Animating(IntToBox(MSCX-30, MSCY-100, MSCX+30, MSCY+100), 500, 440))) or (TimeFromMark(TreeTime) > 60000));
Until(InvFull Or Not LoggedIn);
Any suggestions for better tactics? Or do you think it is fine. The way my script searches for a tree is the one closest to your character, so if it does, it clicks the tree I'm chopping (usually), which some people do whilst woodcutting when they get bored/impatient, ergo it's not that big of a deal. But still, opinions?


It's fine. I use the same thing, and most of the time it works. If you use pixelshift, make sure the pixel count is large enough so when the tree is cut it will only pick up the tree and not other player's chopping animation. You should take a look at Animation.Scar, if you haven't.

Bionicle

2010-01-26 16:10:49

From: Junkj
It's fine. I use the same thing, and most of the time it works. If you use pixelshift, make sure the pixel count is large enough so when the tree is cut it will only pick up the tree and not other player's chopping animation. You should take a look at Animation.Scar, if you haven't.


…That is where i found the function I'm using…

If you notice it is MSCX-30, MSCY-100, MSCX+30, MSCY+100, that is a box surrounding the character, not the tree. The tree is not a box with the exact center of the box the exact center of the main screen. The function that I am using uses pixel shift, so if I had the box around the tree, if the tree is gone, or if it is there, there is no pixels moving either way. If I was using this for a tree, it would be worthless as it would return false each time no matter what. This looks at the character to see if the character is chopping.

Blumblebee

2010-01-26 16:21:29

I usually just make a 10 by 10 box around the pixel i clicked on the tree, get the color of the pixel and then continually search for it in the box, have a timeout if nothing is added to the inventory etc.

something such as this:

Function FollowPixelBox(Point: TPoint): Boolean;
var
i: LongInt;
col, tempCount: Integer;
x, y: Integer;
begin
Col := GetColor(Point.x, Point.y);
WriteLn('Tree Color = '+IntToStr(Col));
i := GetSystemTime;
tempCount := InvCount;
while FindColorTolerance(x, y, Col, Point.x-10, Point.y-10, Point.x+10, Point.y+10, 15) do
begin
FindNormalRandoms;
Wait(150+random(100));
if (GetSystemTime-i > RandomRange(25000, 50000)) then
Break;
if InvFull then Break;
if InvCount <> TempCount then
begin
i := Getsystemtime;
tempCount := InvCount;
end;
end;
Result := True;
end;

when the color is gone, the tree is gone :)

Bionicle

2010-01-26 16:29:41

From: Blumblebee
I usually just make a 10 by 10 box around the pixel i clicked on the tree, get the color of the pixel and then continually search for it in the box, have a timeout if nothing is added to the inventory etc.

something such as this:

Function FollowPixelBox(Point: TPoint): Boolean;
var
i: LongInt;
col, tempCount: Integer;
x, y: Integer;
begin
Col := GetColor(Point.x, Point.y);
WriteLn('Tree Color = '+IntToStr(Col));
i := GetSystemTime;
tempCount := InvCount;
while FindColorTolerance(x, y, Col, Point.x-10, Point.y-10, Point.x+10, Point.y+10, 15) do
begin
FindNormalRandoms;
Wait(150+random(100));
if (GetSystemTime-i > RandomRange(25000, 50000)) then
Break;
if InvFull then Break;
if InvCount <> TempCount then
begin
i := Getsystemtime;
tempCount := InvCount;
end;
end;
Result := True;
end;

when the color is gone, the tree is gone :)


Hmm, that looks pretty sweet, i could probably create something along the lines of that, and use it with my method too to make it extremely reliable.
Could I have your permission to use your method since you gave me the idea? (I wouldn't copy your function tho, id make my own) I would credit :p

Blumblebee

2010-01-26 16:36:16

be my guest. If your writing your own version of it I don't expect credits or anything, just glad it helps.

Bionicle

2010-01-26 16:37:58

From: Blumblebee
be my guest. If your writing your own version of it I don't expect credits or anything, just glad it helps.


Well I'll at least put a thanks :p I'm trying to stay away from using anyone else stuff, as it doesn't feel right to me for some reason.
Thanks :p