SRL Archive - OSR Help

AveragePixelShift..?


Twinki

2013-04-28 00:26:27

So I figured out how I can detect Combat on a RSPS, but now I have a question.

How would I make it to where, if the AveragePixelShift was below 1000 then it'd go attack something, but if it wasn't then it would just wait for a certain amount of time?

I've already created a function for it, i'm just stuck at this part.

Function:
 Function DetermineCombat: Boolean;
Var
PBox: TBox;
begin
PBox := IntToBox(245, 110, 285, 175);
Result := (AveragePixelShift(PBox, 250, 500) > 400);
end;

Procedure i'm trying to add this too:
procedure KillAbbyDemon;
var
X, Y:Integer;
begin
if FindColorTolerance(X, Y, AbbyDemonColor, MSX1, MSY1, MSX2, MSY2, 5) then
begin
WriteLn('Found Abby Demon');
WriteLn('');
if (DetermineCombat) then //Where I'd like to add if the Pixels are less then 1000 then it continues on with the script
begin // Ignore everything below this, haven't changed yet
MMouse(x, y, 0, 0);
ClickMouse2(False);
wait(2000);
ChooseOption('Pickpocket Knight');
wait(250);
WriteLn('Picked Knight');
end;
inc(DemonsKilled);
end;
end;

t4q

2013-04-28 02:54:51

 Function DetermineCombat: Boolean;
Var
PBox: TBox;
begin
PBox := IntToBox(245, 110, 285, 175);
Result := (AveragePixelShift(PBox, 250, 500) > 1000); // 250 loop time, 500 max time > 1000 pixelshift
WriteLn('The average pixelshift is: ' + IntToStr(AveragePixelShift(Pbox, 250, 500))); // helps you see what is your PixelShift
end;

and this:


procedure KillAbbyDemon;
var
X, Y:Integer;
begin
while (DetermineCombat) do // waits 50 + random 50 while pixelshift is over 1000
wait(50+random(50));
if FindColorTolerance(X, Y, AbbyDemonColor, MSX1, MSY1, MSX2, MSY2, 5) then
begin
WriteLn('Found Abby Demon');
WriteLn('');
MMouse(x, y, 2, 2); // use some randomness if you are clicking one color
ClickMouse2(False);
waitoption('Pickpocket Knight', 500); // waits 500ms for option
fflag(0); // waits till red flag is gone from minimap (you are at your monster)
WriteLn('Picked Knight');
end;
inc(DemonsKilled);
end;

Twinki

2013-04-28 15:49:55

From: t4q
 Function DetermineCombat: Boolean;
Var
PBox: TBox;
begin
PBox := IntToBox(245, 110, 285, 175);
Result := (AveragePixelShift(PBox, 250, 500) > 1000); // 250 loop time, 500 max time > 1000 pixelshift
WriteLn('The average pixelshift is: ' + IntToStr(AveragePixelShift(Pbox, 250, 500))); // helps you see what is your PixelShift
end;

and this:


procedure KillAbbyDemon;
var
X, Y:Integer;
begin
while (DetermineCombat) do // waits 50 + random 50 while pixelshift is over 1000
wait(50+random(50));
if FindColorTolerance(X, Y, AbbyDemonColor, MSX1, MSY1, MSX2, MSY2, 5) then
begin
WriteLn('Found Abby Demon');
WriteLn('');
MMouse(x, y, 2, 2); // use some randomness if you are clicking one color
ClickMouse2(False);
waitoption('Pickpocket Knight', 500); // waits 500ms for option
fflag(0); // waits till red flag is gone from minimap (you are at your monster)
WriteLn('Picked Knight');
end;
inc(DemonsKilled);
end;


Thanks, working now :)

t4q

2013-04-28 16:17:43

From: Twinki
Thanks, working now :)

That's good!
If you have any other questions then ask :)

Twinki

2013-04-28 17:41:04

From: t4q
That's good!
If you have any other questions then ask :)


You know how to make it right click where the monster died and check for loot? Lol

Ian

2013-04-28 18:00:44

From: Twinki
You know how to make it right click where the monster died and check for loot? Lol


What does the monster always drop that you could see? For example cows always drop cowhides which are visible in the stack, so you look for the cowhide, collect it, and then you know you're standing on top of the rest of the loot.

Twinki

2013-04-28 18:15:35

From: BMWxi
What does the monster always drop that you could see? For example cows always drop cowhides which are visible in the stack, so you look for the cowhide, collect it, and then you know you're standing on top of the rest of the loot.



It's random on this RSPS, is there not a way I can make check if the item is there? If it isn't then it continues on to the next monster.

Sjoe

2013-04-28 18:32:26

From: Twinki
It's random on this RSPS, is there not a way I can make check if the item is there? If it isn't then it continues on to the next monster.


Just make an array of loot colors and make a function that searches thru that. with a for to do loop

Twinki

2013-04-28 18:55:57

What if it does always drop something? Like Dragon bones for example. How would I just make it right click where the monster died?


and i'll try Arrays.. Doubt i'll figure it out :P

westkevin12

2013-05-02 06:27:47

make it look for the colour of the dragon hide on the ground and right click it to check for bones maybe? only that way it would click the same pile unless you picked up hide too. or somehow made it only check one pile per kill the closest pile to you.. idk just throwing ideas lol.

edit:
i'm pretty sure loot always drops in like the sw corner of the monster so you could have it know where to check before it dies and look for the colour of the hide in that square after it dies. seems like it might work to me