bud_wis_er_420
2012-02-05 00:45:04
I'm trying to use ColorToleranceSpeed 2 with dtms to make them more accurate. I couldn't find any tuts on this and don't really know if anyone else has tried this. But I can't seem to get it working. My autocolor function works like a charm and I can make working TDTMs, but the minute I try adding the two, all hell breaks loose. Let me try to explain
If I use the below script, which uses my autocolor function and the findcolor function, it finds the correct color every time.
…but if I add a TDTM in there it gets a different color then the above script and cant find the dtm. I've tried many different DTM arrangements nothing works. As you can see I got AutoColors set up for 4 different bank colors. Been trying to get this working for 2 days. Even DTMs that shouldn't fail at all(have many false positives), fail every single time. Well here is the script I'm trying to get working. If any body has any idea of what I'm doing wrong I would greatly appreciate it.
If you try the ore finding one you will see it works fine. Only difference is I'm using FindDTM instead of FindDTMRotated to find the ore in the bank.
Uncomment out these lines:
TestDTM := GetOreDTM('iron'); <–change ore type to any ore, it all works
and
if(FindDTM(ItemDTM, ax, ay, 27, 82, 479, 290))then
Comment out these lines:
TestDTM := GetBankDTM;
and
if(FindDTMRotated(TestDTM, x, y, 27, 82, 479, 290, -Pi/4, Pi/4, Pi/60, Ang))then
If I use the below script, which uses my autocolor function and the findcolor function, it finds the correct color every time.
program New;
{$i srl/srl.Simba}
var
x, y, count, TestDTM: integer;
function AutoTheColor(StringType: string): Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL, Acolor, Atol: Integer;
Hue, Sat, Ang: Extended;
begin
case StringType of
'copper' : begin
Acolor := 3037597;
Atol := 12;
Hue := 0.02;
Sat := 0.16;
end;
'tin' : begin
Acolor := 5329236;
Atol := 10;
Hue := 0.42;
Sat := 0.10;
end;
'iron' : begin
Acolor := 1449524;
Atol := 3;
Hue := 0.14;
Sat := 0.58;
end;
'silver' : begin
Acolor := 7499117;
Atol := 14;
Hue := 0.24;
Sat := 0.08;
end;
'gold' : begin
Acolor := 1406871;
Atol := 10;
Hue := 0.02;
Sat := 0.07;
end;
'mithril' : begin
Acolor := 4139818;
Atol := 8;
Hue := 0.10;
Sat := 0.10;
end;
'adamant' : begin
Acolor := 3291442;
Atol := 7;
Hue := 0.24;
Sat := 0.19;
end;
'rune' : begin
Acolor := 4670007;
Atol := 8;
Hue := 0.10;
Sat := 0.13;
end;
'coal' : begin
Acolor := 1383453;
Atol := 4;
Hue := 0.53;
Sat := 0.93;
end;
'brown' : begin
Acolor := 2768205;
Atol := 10;
Hue := 0.05;
Sat := 0.13;
end;
'steel bar' : begin
Acolor := 5460823;
Atol := 19;
Hue := 0.00;
Sat := 0.02;
end;
'gold bar' : begin
Acolor := 1339791;
Atol := 18;
Hue := 0.01;
Sat := 0.04;
end;
//purple of bank NPC
'bankpurple' : begin
Acolor := 3941932;
Atol := 14;
Hue := 0.18;
Sat := 0.73;
end;
//The white bar on the bank booth, part of the gray bar
'bankwhite' : begin
Acolor := 8637652;
Atol := 26;
Hue := 0.03;
Sat := 1.59;
end;
//The gray bar on the bank booth, part of the white bar
'bankgray' : begin
Acolor := 8354422;
Atol := 21;
Hue := 0.11;
Sat := 0.09;
end;
//The grayish decorative trim on the bank booth
'banktrim' : begin
Acolor := 5005155;
Atol := 1;
Hue := 0.14;
Sat := 0.36;
end;
'furnace' : begin
Acolor := 2636996;
Atol := 15;
Hue := 0.07;
Sat := 1.00;
end;
end;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Hue, Sat);
FindColorsSpiralTolerance(MSCX, MSCY, arP, Acolor, MSX1, MSY1, MSX2, MSY2, Atol);
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
Result := arC[i];
Writeln('AutoColor found ' + StringType + ' = ' + 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;
Begin
SetupSRL();
if(FindColor(x, y, AutoTheColor('bankpurple'), 25, 25, 500, 325))then
begin
writeln('Spot found');
Mouse(x, y, 0, 0, false)
end else writeln('Spot not found');
End. …but if I add a TDTM in there it gets a different color then the above script and cant find the dtm. I've tried many different DTM arrangements nothing works. As you can see I got AutoColors set up for 4 different bank colors. Been trying to get this working for 2 days. Even DTMs that shouldn't fail at all(have many false positives), fail every single time. Well here is the script I'm trying to get working. If any body has any idea of what I'm doing wrong I would greatly appreciate it.
program SRLBasicTemplet;
//{$DEFINE SMART}
{$i srl/srl.Simba}
//{$i SRL/SRL/misc/paintsmart.Simba}
//{$i ObjectDTM\ObjDTMInclude.simba}
var
x, y, count, TestDTM: integer;
Ang: Extended;
function AutoTheColor(StringType: string): Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL, Acolor, Atol: Integer;
Hue, Sat, Ang: Extended;
begin
case StringType of
'copper' : begin
Acolor := 3037597;
Atol := 12;
Hue := 0.02;
Sat := 0.16;
end;
'tin' : begin
Acolor := 5329236;
Atol := 10;
Hue := 0.42;
Sat := 0.10;
end;
'iron' : begin
Acolor := 1449524;
Atol := 3;
Hue := 0.14;
Sat := 0.58;
end;
'silver' : begin
Acolor := 7499117;
Atol := 14;
Hue := 0.24;
Sat := 0.08;
end;
'gold' : begin
Acolor := 1406871;
Atol := 10;
Hue := 0.02;
Sat := 0.07;
end;
'mithril' : begin
Acolor := 4139818;
Atol := 8;
Hue := 0.10;
Sat := 0.10;
end;
'adamant' : begin
Acolor := 3291442;
Atol := 7;
Hue := 0.24;
Sat := 0.19;
end;
'rune' : begin
Acolor := 4670007;
Atol := 8;
Hue := 0.10;
Sat := 0.13;
end;
'coal' : begin
Acolor := 1383453;
Atol := 4;
Hue := 0.53;
Sat := 0.93;
end;
'brown' : begin
Acolor := 2768205;
Atol := 10;
Hue := 0.05;
Sat := 0.13;
end;
'steel bar' : begin
Acolor := 5460823;
Atol := 19;
Hue := 0.00;
Sat := 0.02;
end;
'gold bar' : begin
Acolor := 1339791;
Atol := 18;
Hue := 0.01;
Sat := 0.04;
end;
'bankpurple' : begin
Acolor := 3941932;
Atol := 14;
Hue := 0.18;
Sat := 0.73;
end;
'bankwhite' : begin
Acolor := 8637652;
Atol := 26;
Hue := 0.03;
Sat := 1.59;
end;
'bankgray' : begin
Acolor := 8354422;
Atol := 21;
Hue := 0.11;
Sat := 0.09;
end;
'banktrim' : begin
Acolor := 5005155;
Atol := 1;
Hue := 0.14;
Sat := 0.36;
end;
'furnace' : begin
Acolor := 2636996;
Atol := 15;
Hue := 0.07;
Sat := 1.00;
end;
end;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Hue, Sat);
FindColorsSpiralTolerance(MSCX, MSCY, arP, Acolor, MSX1, MSY1, MSX2, MSY2, Atol);
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
Result := arC[i];
Writeln(StringType + ' 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 GetBankDTM: integer;
var
MainPT: TDTMPointDef;
SubPT: array[0..2] of TDTMPointDef;
LoadDTM: TDTM;
begin
MainPT.x := 258;
MainPT.y := 190;
MainPT.areasize := 1;
MainPT.areashape := 0;
MainPT.color := AutoTheColor('bank');
MainPT.tolerance := 5;
SubPT[0].x := 237;
SubPT[0].y := 191;
SubPT[0].areasize := 4;
SubPT[0].areashape := 0;
SubPT[0].color := AutoTheColor('bankgray');
SubPT[0].tolerance := 5;
SubPT[1].x := 279;
SubPT[1].y := 191;
SubPT[1].areasize := 4;
SubPT[1].areashape := 0;
SubPT[1].color := AutoTheColor('bankgray');
SubPT[1].tolerance := 5;
SubPT[2].x := 257;
SubPT[2].y := 238;
SubPT[2].areasize := 10;
SubPT[2].areashape := 0;
SubPT[2].color := AutoTheColor('bankpurple');
SubPT[2].tolerance := 5;
LoadDTM.MainPoint := MainPT;
LoadDTM.SubPoints := SubPT;
Result := AddDTM(LoadDTM);
end;
function GetOreDTM(TheItem: string): integer;
var
AreaSize, AutoColorDTM: integer;
MainPT: TDTMPointDef;
SubPT: array[0..5] of TDTMPointDef;
LoadDTM: TDTM;
begin
AreaSize := 2;
MainPT.x := 52;
MainPT.y := 107;
MainPT.areasize := 1;
MainPT.areashape := 0;
MainPT.color := AutoTheColor(TheItem);
MainPT.tolerance := 5;
SubPT[0].x := 57;
SubPT[0].y := 108;
SubPT[0].areasize := AreaSize;
SubPT[0].areashape := 0;
SubPT[0].color := AutoTheColor(TheItem);
SubPT[0].tolerance := 5;
SubPT[1].x := 62;
SubPT[1].y := 113;
SubPT[1].areasize := AreaSize;
SubPT[1].areashape := 0;
SubPT[1].color := AutoTheColor(TheItem);
SubPT[1].tolerance := 5;
SubPT[2].x := 51;
SubPT[2].y := 117;
SubPT[2].areasize := AreaSize;
SubPT[2].areashape := 0;
SubPT[2].color := AutoTheColor('brown');
SubPT[2].tolerance := 5;
SubPT[3].x:=44;
SubPT[3].y:=111;
SubPT[3].areasize:=AreaSize;
SubPT[3].areashape:=0;
SubPT[3].color:=AutoTheColor('brown') ;
SubPT[3].tolerance:=5;
SubPT[4].x:=44;
SubPT[4].y:=105;
SubPT[4].areasize:=AreaSize;
SubPT[4].areashape:=0;
SubPT[4].color:=AutoTheColor('brown') ;
SubPT[4].tolerance:=5;
SubPT[5].x:=65;
SubPT[5].y:=103;
SubPT[5].areasize:=AreaSize;
SubPT[5].areashape:=0;
SubPT[5].color:=AutoTheColor('brown') ;
SubPT[5].tolerance:=5;
LoadDTM.MainPoint := MainPT;
LoadDTM.SubPoints := SubPT;
Result := AddDTM(LoadDTM);
end;
Begin
//ClearDebug();
//Smart_Server := 44;
SetupSRL();
count := 0;
TestDTM := GetBankDTM;
//TestDTM := GetOreDTM('iron');
//Finds bank npc color purple
if(FindColor(x, y, AutoTheColor('bankpurple'), 25, 25, 500, 325))then
begin
writeln('Spot found with FindColor');
Mouse(x, y, 0, 0, false)
end else writeln('Spot not found with FindColor');
MMouse(5, 5, 5, 5)
if(FindDTMRotated(TestDTM, x, y, 27, 82, 479, 290, -Pi/4, Pi/4, Pi/60, Ang))then
//if(FindDTM(ItemDTM, ax, ay, 27, 82, 479, 290))then
begin
writeln('Spot found with DTM');
Mouse(x, y,0,0,true)
end else writeln('Spot not found with DTM');
End.If you try the ore finding one you will see it works fine. Only difference is I'm using FindDTM instead of FindDTMRotated to find the ore in the bank.
Uncomment out these lines:
TestDTM := GetOreDTM('iron'); <–change ore type to any ore, it all works
and
if(FindDTM(ItemDTM, ax, ay, 27, 82, 479, 290))then
Comment out these lines:
TestDTM := GetBankDTM;
and
if(FindDTMRotated(TestDTM, x, y, 27, 82, 479, 290, -Pi/4, Pi/4, Pi/60, Ang))then