SRL Archive - OSR Help

Problem with ACA


schnubbel15

2013-05-21 12:31:20

Hey guys,
I started to script with simba about a year ago but had to stop cuz of to less time.
So these week i started again and got a problem with ACA.

I just wounder if theres another similar method for getting the coords of an moving NPC? becouse the color of my NPC is too much like the surroundings

any idea will help
thanks :)

Kevin

2013-05-21 12:37:23

Could you post a picture of the npc and surrounding area? I'm sure we could still come up with a color solution ;)

schnubbel15

2013-05-21 12:49:18



edit:
i know there are fighting scripts but its just for learning;) and thanks for your time :P

Kevin

2013-05-21 12:51:47

Which animal seems to have a conflicting color with the surrounding area? The brown cow seems a little close to the surrounding fence, but I don't really see anything that should be very difficult with color here. Could you be more specific with which animal and perhaps the code you're trying to use?

schnubbel15

2013-05-21 12:54:48

the cows are the troublemakers… so it seems to be my stupidness that i cant use ACA right? everytime i try to get a good color the fence and building in background gets colored red too… heres my code:

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

function toCow:Boolean;
Var
cowPath : TPointArray;
begin
WriteLn('Waling to cows..');
SPS_Setup(RUNESCAPE_SURFACE, ['8_7']);

cowPath := [Point(3295, 2932), Point(3314, 2933), Point(3326, 2933), Point(3342, 2934), Point(3354, 2936), Point(3367, 2939), Point(3380, 2943), Point(3392, 2941), Point(3410, 2941), Point(3424, 2939), Point(3435, 2928), Point(3447, 2919), Point(3459, 2906), Point(3469, 2897), Point(3474, 2883), Point(3454, 2882)];
SPS_WalkPath(cowPath);
WriteLn('..at cows');
Result := True;
end;

function fightCow:Boolean;
Var
i, x, y: Integer;
begin
if (FindObj(x, y, 'ow', CowColor, 1))
or (FindObj(x, y, 'ow', CowColor, 1)) then
begin
Mouse(x, y, 2, 2, true);
wait(6000);
end;
end;

function CowColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.15, 2.94);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 11851240, MSX1, MSY1, MSX2, MSY2, 16);
if (Length(arP) = 0) 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
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 37.93) and (X <= 90.11) and (Y >= 40.15) and (Y <= 94.53) and (Z >= 38.98) and (Z <= 93.61) then
begin
Result := arC[i];
// Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

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



begin
SetupSRL;
// toCow;
repeat
fightCow;
until(InvCount = 28);
end.

EDIT: OLD VERSION! function cowcolor needs to be above fight cow sry :P

Kevin

2013-05-21 13:09:30

Ah, I wouldn't use FindObj at all (besides, it takes a color, not a function :p)
Since you're still using ACA to create a lot of your functions, I would make a couple of quick suggestions that should help out. Instead of adding all the brown colors of the cow, just add pixels one at a time (and check) and delete any that start to add in the fence and/or building. You don't need the entire cow to turn out a "red" match for it to work, you just need a good chunk of him. Also, there should be an option in one of the make functions to add an "uptext" check. At that point you can enter your 'ow' and the function it creates will not only find those groupings of brown, but it will also move the mouse over them until it matches that uptext so it knows the cow is the correct one. Then you could entirely remove your findobj and just have something more like:
if(CowColor)then
begin
ClickMouse2(mouse_right);
WaitOption('ttac', 600);
end;//and now it's attacking the cow!

schnubbel15

2013-05-21 13:11:46

Thanks for the quick answer Kevin. I will try it out now and will tell you if it worked :P thanks


EDIT:
cuz of your help i could get the script to kill the light brown cow.. still checks other items often but its a beginning. i cant find a colour from calf or dark brown cow which isnt used in another object. Changed my Code to
program Tests;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}

var
x, y: Integer;

function toCow:Boolean;
Var
cowPath : TPointArray;
begin
WriteLn('Waling to cows..');
SPS_Setup(RUNESCAPE_SURFACE, ['8_7']);

cowPath := [Point(3295, 2932), Point(3314, 2933), Point(3326, 2933), Point(3342, 2934), Point(3354, 2936), Point(3367, 2939), Point(3380, 2943), Point(3392, 2941), Point(3410, 2941), Point(3424, 2939), Point(3435, 2928), Point(3447, 2919), Point(3459, 2906), Point(3469, 2897), Point(3474, 2883), Point(3454, 2882)];
SPS_WalkPath(cowPath);
WriteLn('..at cows');
Result := True;
end;

function CowColor(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.05, 0.60);

if not(FindColorsTolerance(arP, 6057091, MSX1, MSY1, MSX2, MSY2, 18)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 5.84) and (X <= 32.09) and (Y >= 5.89) and (Y <= 32.89) and (Z >= 4.95) and (Z <= 30.65) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('ow')) then
begin;
Result := True;
Break;
end;
end;

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

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;


function fightCow:Boolean;
var
x, y : Integer;
begin
if(CowColor(x, y)) then
begin
ClickMouse2(mouse_right);
WaitOption('ttac',600);
end;
end;




begin
ClearDebug();
SetupSRL;
// toCow;
repeat
fightCow;
until(InvCount = 28);
end.

maybe you could help me one more time find an more effektive way? i think i understood the main thing but just cant figure out how to amke it flawless :/

t4q

2013-05-21 16:35:41

I think those cows have too different colors to set them all to one color and tolerance..
Maybe take one color for each cow (these are not right colors):

Hue := [0.01, 0.24, 0.56];
Sat := [1.16, 0.18, 0.65];
Col := [1027552, 11250867, 12425252];
Tol := [10, 7, 11];

Kevin

2013-05-21 16:42:06

Another option is to add a limit for pixel count (that way you only see items/monsters of a certain size).

for i := 0 to arL do
begin
if (Length(ararP[i]) < 50) then Continue;//10 is really small, almost a dot to the eye. 50 is a decent size, and if you stuck with all colors of a brown cow, perhaps 200 or more. play with this number a little to find a decent area.

schnubbel15

2013-05-21 17:27:40

i have improved my script a bit (kinda messy:D)
program Tests;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}

var
x, y, x2, y2: Integer;

function toCow:Boolean;
Var
cowPath : TPointArray;
begin
WriteLn('Waling to cows..');
SPS_Setup(RUNESCAPE_SURFACE, ['8_7']);

cowPath := [Point(3295, 2932), Point(3314, 2933), Point(3326, 2933), Point(3342, 2934), Point(3354, 2936), Point(3367, 2939), Point(3380, 2943), Point(3392, 2941), Point(3410, 2941), Point(3424, 2939), Point(3435, 2928), Point(3447, 2919), Point(3459, 2906), Point(3469, 2897), Point(3474, 2883), Point(3454, 2882)];
SPS_WalkPath(cowPath);
WriteLn('..at cows');
Result := True;
end;

function Cow1(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.04, 0.80);

if not(FindColorsTolerance(arP, 6912398, MSX1, MSY1, MSX2, MSY2, 10)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 13.27) and (X <= 29.27) and (Y >= 13.02) and (Y <= 30.07) and (Z >= 9.19) and (Z <= 27.94) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('ow')) then
begin;
Result := True;
Break;
end;
end;

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

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;

function Cow2(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.16, 2.63);

if not(FindColorsTolerance(arP, 3559506, MSX1, MSY1, MSX2, MSY2, 3)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 5.93) and (X <= 7.62) and (Y >= 6.50) and (Y <= 8.31) and (Z >= 3.39) and (Z <= 6.07) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('ow')) then
begin;
Result := True;
Break;
end;
end;

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

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;

function Cow3(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.03, 0.57);

if not(FindColorsTolerance(arP, 5800871, MSX1, MSY1, MSX2, MSY2, 5)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 20.87) and (X <= 30.08) and (Y >= 20.54) and (Y <= 29.62) and (Z >= 11.23) and (Z <= 15.95) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('ow')) then
begin;
Result := True;
Break;
end;
end;

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

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;

function Cow4(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.36, 0.43);

if not(FindColorsTolerance(arP, 4149075, MSX1, MSY1, MSX2, MSY2, 2)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 6.56) and (X <= 7.86) and (Y >= 7.01) and (Y <= 8.43) and (Z >= 5.40) and (Z <= 6.38) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('ow')) then
begin;
Result := True;
Break;
end;
end;

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

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;

function Cow5(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.16, 0.43);

if not(FindColorsTolerance(arP, 8490646, MSX1, MSY1, MSX2, MSY2, 3)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 23.75) and (X <= 28.47) and (Y >= 24.88) and (Y <= 29.68) and (Z >= 22.60) and (Z <= 26.79) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('ow')) then
begin;
Result := True;
Break;
end;
end;

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

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;

function Cow6(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.36, 0.31);

if not(FindColorsTolerance(arP, 3885132, MSX1, MSY1, MSX2, MSY2, 3)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 4.97) and (X <= 7.33) and (Y >= 5.28) and (Y <= 7.72) and (Z >= 4.11) and (Z <= 5.97) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('ow')) then
begin;
Result := True;
Break;
end;
end;

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

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;

function Cow7(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.06, 0.27);

if not(FindColorsTolerance(arP, 3755606, MSX1, MSY1, MSX2, MSY2, 3)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 6.16) and (X <= 8.47) and (Y >= 6.53) and (Y <= 8.98) and (Z >= 4.29) and (Z <= 5.86) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('ow')) then
begin;
Result := True;
Break;
end;
end;

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

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;

function fightCow:Boolean;
var
x, y : Integer;
begin
if(Cow1(x, y) or Cow2(x,y) or Cow3(x,y) or Cow4(x, y) or Cow5(x, y) or Cow6(x, y)) then
begin
ClickMouse2(mouse_right);
WaitOption('ttac',600);
Sleep(Random(2000));
end;
end;

function Hide(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
H, S, L: Extended;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(1);

if not(FindColorsTolerance(arP, 15198706, MSX1, MSY1, MSX2, MSY2, 19)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToHSL(arC[i], H, S, L);

if (H >= 0.00) and (H <= 7.60) and (S >= 16.65) and (S <= 73.35) and (L >= 88.22) and (L <= 97.08) then
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 72.18) and (X <= 88.30) and (Y >= 75.28) and (Y <= 90.82) and (Z >= 78.40) and (Z <= 96.88) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('Take')) then
begin;
Result := True;
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;

function FindTheHide:Boolean;
var
x, y : Integer;
begin
if(Hide(x, y)) then
begin
ClickMouse2(mouse_right);
WaitOption('owhide',600);
end;
end;


begin
ClearDebug();
SetupSRL;
// toCow;
repeat
// FindTheHide;
fightCow;
until(InvCount = 28);
end.
it "works" from time to time it buggs and i think i need to recreate the colours again (some points seems to be not on cows again..) could you explain how the limit for pixel count work? its doesnt make sense to me right now :o

Kevin

2013-05-21 17:33:37

A "limit" on the pixel count would be like saying "is this grouping of pixels I'm checking smaller than I think it should be? Then don't even bother looking at it."

So normally that for loop just loops through every grouping of pixels that match your color and tolerance, but by adding that little line you can add a limit and say "No, you're too small, I know you're wrong and I don't even want to look at you and instead I wanna check out the bigger groups!"

:P

schnubbel15

2013-05-21 18:02:46

that sounds good, but im still confused in how do i use it exactly?

nvm i think i found it but still having the problem with the tolerance for the colors.. cows keep changing their skin

Kevin

2013-05-21 18:40:00

From: schnubbel15
that sounds good, but im still confused in how do i use it exactly?

nvm i think i found it but still having the problem with the tolerance for the colors.. cows keep changing their skin


Raise the tolerance, but also raise the required minimum pixels?

schnubbel15

2013-05-22 04:43:43

EDIT: ok i got it to work pretty well :) thanks for your help guys if anyone is interested in the code:


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

var
x, y, x2, y2: Integer;

function toCow:Boolean;
Var
cowPath : TPointArray;
begin
WriteLn('Waling to cows..');
SPS_Setup(RUNESCAPE_SURFACE, ['8_7']);

cowPath := [Point(3295, 2932), Point(3314, 2933), Point(3326, 2933), Point(3342, 2934), Point(3354, 2936), Point(3367, 2939), Point(3380, 2943), Point(3392, 2941), Point(3410, 2941), Point(3424, 2939), Point(3435, 2928), Point(3447, 2919), Point(3459, 2906), Point(3469, 2897), Point(3474, 2883), Point(3454, 2882)];
SPS_WalkPath(cowPath);
WriteLn('..at cows');
Result := True;
end;

function cow1(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.38, 0.35);

if not(FindColorsTolerance(arP, 8226963, MSX1, MSY1, MSX2, MSY2, 6)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 19.19) and (X <= 30.56) and (Y >= 20.06) and (Y <= 31.41) and (Z >= 18.17) and (Z <= 29.27) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 100) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('ow')) then
begin;
Result := True;
Break;
end;
end;

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

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;

function cow2(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.45, 2.01);

if not(FindColorsTolerance(arP, 3624532, MSX1, MSY1, MSX2, MSY2, 4)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 5.04) and (X <= 8.95) and (Y >= 5.32) and (Y <= 9.83) and (Z >= 3.25) and (Z <= 5.97) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 100) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('ow')) then
begin;
Result := True;
Break;
end;
end;

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

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;

function fightCow:Boolean;
var
x, y : Integer;
begin
if(cow1(x, y) or cow2(x, y))then
begin
ClickMouse2(mouse_right);
WaitOption('ttac',600);
Sleep(4000);
end;
end;

begin
ClearDebug();
SetupSRL;
// toCow;
repeat
fightCow;
until(InvCount = 28);
end.