SRL Archive - OSR Help

PixelShift Help?


Leyser

2012-05-26 11:27:29

Ok, so I have a Willow Chopper and I have pixel shift in it, but it doesent seem to stop when it is chopping?

Here is my script and where I put my things:.



program LeyserChopper;
{$DEFINE SMART}
{$i srl/srl.simba}

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

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
end;
function IsWoodcutting: Boolean;
var
PBox: TBox;
begin
PBox := IntToBox(245, 130, 285, 195);
Result := (AveragePixelShift(PBox, 250, 5000) > 680);
end;
procedure AntiBan;
begin
if(not(LoggedIn))then
Exit;
FindNormalRandoms;
case Random(8) of
0:
begin
HoverSkill('Woodcutting', false);
wait(500+Random(250));
end;
10:
begin
PickUpMouse;
Wait(1245+Random(400));
end;
20: begin
SetAngle(1);
Wait(1245+Random(400));
end;
30: begin
RandomRClick;
Wait(1245+Random(400));
end;
40: begin
ExitSquealOfFortune;
Wait(1245+Random(400));
end;
50: begin
FindSpinTicket;
Wait(1245+Random(400));
end;
60: begin
BoredHuman;
Wait(1245+Random(400));
end;
70: begin
WriteLn('Bored...');
Wait(1245+Random(400));
end;
80:
begin
MakeCompass('N');
wait(100+random(133));
MakeCompass('S');
wait(50+random(133));
FindNormalRandoms;
end;
end;
end;
procedure ChopTree;
var x, y: integer;
begin
repeat
FindNormalRandoms;
if FindObj(x, y, 'illow', 3030076, 35) then
if FindObj(x, y, 'illow', 3292993, 35) then
if FindObj(x, y, 'hop', 3425092, 35) then
if FindObj(x, y, 'hop', 3161918, 35) then
begin
Mouse(x, y, 5, 5, 1);
Wait(1234+random(1222));
end;
wait(400+random(250));
AntiBan;
Wait(402+random(110));
until(InvFull)
if (InvFull) then
begin
DropAllExcept([1]);
end;
end;

begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
repeat
ChopTree;
While IsWoodcutting Do Wait(200+Random(50)); //Where the Pixel Shift takes place
until(False)
end.


NKN

2012-05-26 12:02:30

On thing.

On ChopTree, the four FindObj are pretty weird.

It has to find the first one, if not, it won't click. If it does, it has to find the second one, if not, it won't click, see where I'm going with this? You should just add one that works.

As for PixelShift, I've never used it, can't help you there.

zmon

2012-05-26 13:05:25

yeah nkn is right about this part of code, i'll tell you how it is read and let's see if you meant something else:

    if FindObj(x, y, 'illow', 3030076, 35) then
if FindObj(x, y, 'illow', 3292993, 35) then
if FindObj(x, y, 'hop', 3425092, 35) then
if FindObj(x, y, 'hop', 3161918, 35) then
begin
Mouse(x, y, 5, 5, 1);
Wait(1234+random(1222));
end;

Basically it says this: spend precious CPU cycles to locate 'illow' somewhere on the screen and save the location into x, y… and then discard the information altogether and instead look for 'illow' with different color… and if you find that somewhere on the screen (not necessarily anywhere near the first one), then all is good and we can throw away everything we found so far and start with next line

you are saying - i need to match all of the first three, anywhere on the screen, and if i can, then and only then do i look for the actual target on line 4

perhaps you meant one or the second or the third or the fourth?

now i would tell you this but there is a problem with that code:

    if FindObj(x, y, 'illow', 3030076, 35) or
FindObj(x, y, 'illow', 3292993, 35) or
FindObj(x, y, 'hop', 3425092, 35) or
FindObj(x, y, 'hop', 3161918, 35) then
begin
Mouse(x, y, 5, 5, 1);
Wait(1234+random(1222));
end;

and the problem is called optimization. Sometimes the compiler will optimize statement and it *should* break on first positive find, but it may not, and since you are using value x and y later on, i wouldn't risk optimizer messing it up - wouldn't be the first time i'd see things evaluated right to left or evaluated after first positive

so i would actually suggest this:


var Found : Boolean;
begin
(....)
// try to find any of the four options, but test subsequent only if not yet found
Found := FindObj(x, y, 'illow', 3030076, 35);
if not Found then Found := FindObj(x, y, 'illow', 3292993, 35);
if not Found then Found := FindObj(x, y, 'hop', 3425092, 35);
if not Found then Found := FindObj(x, y, 'hop', 3161918, 35);
// now see if we found it
if Found then
begin
Mouse(x, y, 5, 5, 1);
Wait(1234+random(1222));
end;

bg5

2012-05-26 13:33:26

FindObj(x, y, 'illow', 3030076, 35) or
FindObj(x, y, 'illow', 3292993, 35) or
FindObj(x, y, 'hop', 3425092, 35) or
FindObj(x, y, 'hop', 3161918, 35) then

==

FindObjCustom(x,y,['illow','hop'],[3030076,3292993,3425092,3161918],35)

Leyser

2012-05-26 14:58:53

Ahhh, ok thanks for fixing that color thingy.
But I still need help with the Pixel Shift.

bg5

2012-05-26 15:07:00

Result := (AveragePixelShift(PBox, 250, 5000) > 680);

Maybe treshold is too low and it always returns TRUE?

Leyser

2012-05-27 09:36:29

BUMP

My Pixel Shift still isent working heres my code At The Moment:


program LeyserChopper;
{$DEFINE SMART}
{$i srl/srl.simba}

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

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
end;
function IsWoodcutting: Boolean;
var
PBox: TBox;
begin
PBox := IntToBox(245, 130, 285, 195);
Result := (AveragePixelShift(PBox, 250, 5000) > 965);
end;
procedure AntiBan;
begin
if(not(LoggedIn))then
Exit;
FindNormalRandoms;
case Random(8) of
0:
begin
HoverSkill('Woodcutting', false);
wait(500+Random(250));
end;
10:
begin
PickUpMouse;
Wait(500+Random(401));
end;
30: begin
RandomRClick;
Wait(500+Random(401));
end;
40: begin
ExitSquealOfFortune;
Wait(500+Random(401));
end;
50: begin
FindSpinTicket;
Wait(500+Random(401));
end;
60: begin
BoredHuman;
Wait(500+Random(401));
end;
70: begin
WriteLn('Bored...');
Wait(500+Random(401));
end;
80:
begin
MakeCompass('N');
wait(100+random(133));
MakeCompass('S');
wait(50+random(133));
FindNormalRandoms;
end;
end;
end;
procedure ChopTree;
var
x, y: integer;
begin
SetAngle(0);
repeat
FindNormalRandoms;
if FindObjCustom(x,y,['illow','hop'],[3030076,3292993,3425092,3161918],35) then
begin
Mouse(x, y, 5, 5, 1);
Wait(500+random(1222));
While IsWoodcutting Do Wait(20+Random(50));
end;
until(InvFull)
if (InvFull) then
begin
DropAllExcept([1]);
end;
end;

begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
repeat
ChopTree;
AntiBan;
until(False)
end.


zmon

2012-05-27 19:25:02

From: Leyser
BUMP

My Pixel Shift still isent working heres my code At The Moment:


function IsWoodcutting: Boolean;
var
PBox: TBox;
begin
PBox := IntToBox(245, 130, 285, 195);
Result := (AveragePixelShift(PBox, 250, 5000) > 965);
end;


I haven't been using pixel shift so i can't tell if 965 is by any chance too high?

try to print out the result from average pixel shift and then adjust accordingly

these were mine

Average pixel shift value: 1362
Average pixel shift value: 703
Average pixel shift value: 681
Average pixel shift value: 644
Average pixel shift value: 594
Average pixel shift value: 588
Average pixel shift value: 692
Average pixel shift value: 705
Average pixel shift value: 592

so seeing that they get as low as 592, you might want to lower your expectations

Abu

2012-05-28 00:39:18

Lower your average pixel shift to 400.

965 is way too high.

Flight

2012-05-28 00:52:07

Here's a suggestion when determine what count to use for pixelshift animation detection. Run my little debug script (that I provided on my Pixelshift Animation tutorial) and get a good, average shift count of your player standing still. Do this with your player facing north, south, east, and west. The numbers should be pretty similar, but take the highest of these numbers; this will be the highest shift count your player will make while standing still. Later on, we'll say any shift count above this number would indicate our player is animating some how.

Then, start chopping a tree, run the debug script again, and get a different shift count of your player while he's chopping. Like before, do this with your player facing all four directions. Take the lowest of these animating shift counts, and choose a number in between your highest 'standing still' shift count and your lowest 'animating' shift count; this number will be the indicator that our player is animating.


Does that make sense?

Leyser

2012-05-28 11:16:55

Thanks everyone SO much!

Theres just one little thing bugging me,

is there a way I can do a wait and/or do antiban at the same time?


Wait(500+random(1222));
ProgressReport;
While IsWoodcutting Do Wait(20+random(50)); //can i put antiban with this?
end;
until(InvFull)

bg5

2012-05-28 11:51:27

procedure antibanWait (time : integer);
var
t : integer;
begin
MarkTime(t);
repeat
antiban;
wait(20);
until TimeFromMark(t) > time
end;