Sir R. M8gic1an
2008-02-23 06:17:51
well, to those who haven't heard about SmartColors tarajunky was the one who first made it. it'll look for you colors with absolutely no tol first, if it doesn't find them then it'll look with tol. the smart part is that when it finds what you're looking for it'll remember to color of where it found and look for that color in future times. it uses an array and the best colors will come first, and when a color gets a hit it'll move up the array.
Tarajunky's Thread
but some people found that principle and the code confusing and hard to understand. i studied the code, asked tara a few questions a came up with SmartColorsCustom.
It's as good as SmartColors, as fast as TPA's and as simple as FindObjCustom!
i was killing chickens with just this earlier, worked wonderfully. and here's a very practical example of how to use it:
Pick the colors just before you run and you'll be amazed. This SmartColors is just as good as the One Tara uses in his chicken killer. Have fun, Script, and be glad of how simple SmartColors Now Is.
note: if your looking for similar things like rocks it's betther to do:
['mithril','mine','rock'] than ['mine','rock','mithril']; or even just['mithril'] to make sure it doesn't mess up with other rocks.
Ps: you can use this for anything, like rocks and trees.
PPs: if you use this remember to credit tarajunky and me, and please only use SmartColorsCustom is members-only scripts. this is very powerful and simple to use, and we need more member only scripts.
~RM
Tarajunky's Thread
but some people found that principle and the code confusing and hard to understand. i studied the code, asked tara a few questions a came up with SmartColorsCustom.
It's as good as SmartColors, as fast as TPA's and as simple as FindObjCustom!
//by RM
Function CheckAndClick(var x, y:integer; text:TStringArray): boolean;
var
m:integer;
FoundIt:boolean;
begin
MMouse(x, y, 3, 3);
wait(100);
for m:=0 to high(text) do
begin
if IsUpText(text[m]) then
begin
writeln('text is up, '+text[m]);
FoundIt:=True;
break;
end;
end;
if FoundIt then
begin
GetMousePos(x, y);
Mouse(x, y, 3, 3, True);
Result := True;
end else
Result :=False;
end;
//Smart Colors By Tarajunky, Edited by Rasta Magician
Function SmartColorsCustom(name:string; UpText:TStringArray; colors:TIntegerArray):boolean;
var
j, k:integer;
b, Found:boolean;
var RMInt, RMx, RMy:integer;
var x,y,TestColor,a,l,m,i,red,green,blue, ClickColor:integer;
var p: array of Tpoint;
begin
for i:=0 to High(Find) do
begin
if lowercase(name) = Find[i].Name then
begin
b := True;
k := i;
end;
end;
if not b then //we have to add it.
begin
k:=GetArrayLength(Find);
SetArrayLength(Find, k+1);
Find[k].Name:= lowercase(name);
Find[k].UpText := UpText;
Find[k].Colors := colors;
end;
FFlag(0);
Wait(50);
Status('Finding '+name);
l:=GetArrayLength(Find[k].Colors); //Checks known colors first
if l>0 then
begin
for i:= 0 to l-1 do
begin
writeln('finding color: '+IntToStr(Find[k].Colors[i]));
FindColorsSpiralTolerance(MSCX,MSCY,p,Find[k].Colors[i],MSX1,MSY1,MSX2,MSY2,0);
m:=GetArrayLength(p);
if m>0 then
begin
if m > 30 then exit;
for a:= 0 to m-1 do
begin
if CheckAndClick(p[a].x,p[a].y, Find[k].UpText) then //Moves mouse to position, checks uptext and clicks if correct.
begin
result:=true;
if i>0 then //if the color is not in the first position of the array...
Swap(Find[k].Colors[i], Find[k].Colors[i-1]);
// Swap found color with the one ahead of it in the array
exit; // We found our color, so we exit the function completely.
end;
end;
end;
end;
end;
//We didn't find any known colors, so continue on to the tolerance search
for j:=0 to High(Find[k].Colors) do
begin
writeln('finding color '+IntToStr(Find[k].Colors[j])+' with tol: ');
FindColorsSpiralTolerance(MSCX, MSCY, p, Find[k].Colors[j],MSX1,MSY1,MSX2,MSY2,25);
l:=GetArrayLength(p);
if l>0 then
begin
if l > 30 then exit;
for i:= 0 to l-1 do
begin
TestColor:=GetColor(p[i].x,p[i].y); //Additional autocoloring to reduce wrong points. (Optional)
red:=(TestColor mod 256);
green:=((TestColor/256) mod 256);
blue:=((TestColor/256) / 256);
if ((green-blue)<=46) then if ((green-blue)>=24) then
if ((red-green)>=26) then if ((red-green)<=51) then
if ((red-blue)>55) then if ((red-blue)<=94) then
begin
Wait(20);
ClickColor:=GetColor(p[i].x,p[i].y);
for RMInt:=0 to High(Find[k].Colors) do
begin
if RMInt <> j then
if FindColorSpiralTolerance(RMx, RMy, Find[k].Colors[RMInt],x-5,y-5,x+5,y+5, 20) then
begin
Found:=True;
break;
end;
end;
If Found then
if CheckAndClick(p[a].x,p[a].y, Find[k].UpText) then //Move mouse, check uptext and click
begin
result:=true;
FindColorsSpiralTolerance(x,y,p,ClickColor,MSX1,MSY1,MSX2,MSY2,0);
if GetArrayLength(p)<20 then //Make sure that the color is somewhat rare, and doesn't take up half the screen
begin
a:=GetArrayLength(Find[k].Colors);
for i:= 0 to a-1 do
begin
if ClickColor=Find[k].Colors[i] then //If color is already in the array...
begin
if i>0 then
begin // Move it up one spot in the array search priority
Swap(Find[k].Colors[i], Find[k].Colors[i-1]);
end;
exit;
end;
end;
// if it's not in the array yet, then add it to the end of the array
SetArrayLength(Find[k].Colors,a+1);
Find[k].Colors[a]:=ClickColor;
Writeln(IntToStr(ClickColor)+' added to '+name+' array');
end;
exit;
end;
end;
end;
end;
end;
end;
that's the two functions you need. now there's also a Type Record that needs to be global:
type
Monster = record
Name: string;
UpText: TStringArray;
Colors: TIntegerArray;
end;
var
Find: Array of Monster;
i was killing chickens with just this earlier, worked wonderfully. and here's a very practical example of how to use it:
function FindMonster(name:string):boolean;
begin
case lowercase(name) of
'chicken':
Result := SmartColorsCustom('chicken', ['ttack', 'hicken', 'Chicken'], [2907004, 8036277, 3627894]);
'goblin':
Result := SmartColorsCustom('goblin', ['ttack','obl','goblin'], [000,000,000]);
'cow':
Result := SmartColorsCustom('cow', ['ttack','ow','Cow'], [000, 000, 000]);
end;
end;
begin
SetupSRL;
repeat
FindMonster('Chicken');
wait(4000);
until (IsFKeyDown(12))
end.
Pick the colors just before you run and you'll be amazed. This SmartColors is just as good as the One Tara uses in his chicken killer. Have fun, Script, and be glad of how simple SmartColors Now Is.
note: if your looking for similar things like rocks it's betther to do:
['mithril','mine','rock'] than ['mine','rock','mithril']; or even just['mithril'] to make sure it doesn't mess up with other rocks.
Ps: you can use this for anything, like rocks and trees.
PPs: if you use this remember to credit tarajunky and me, and please only use SmartColorsCustom is members-only scripts. this is very powerful and simple to use, and we need more member only scripts.
~RM
