As SRL Members will know, I'm working on a new script. I've set myself the aim of being the best ever written script I have so far. This is in terms of look and functonality.
Yesterday, I started brainstorming. Today, I started writing.
It's a Guild Miner, and I'll be using a system that I have only ever seen 3 people use. For Color finding I'll be using an Artificial Intelligence (AI) system, which I learnt off / taught by Tarajunky, and that then I passed on to EvilChicken!, although we all made public threads about it. We then each developed it in different directions, although none of us ever got to finish a propper include to put in SRL.
Hopefully, this time around, 2 years later and with a lot more of experience, I'll be able to finish it and put it in SRL for everyone's use.
So anyway, here is the starts of my work:
This AI system analyses colors and will then search for them with 0 tol, making it extremely fast, and it'll organize the colors in an array so that the ones that return the most positive results are the first ones to be searched for. This part is not yet written.PHP Code:// RM
// Guild Miner
const
//Rock indexes
ROCK_COAL = 0;
ROCK_MITH = 1;
//SmartColors Specifics
UNIQUE_COLOR_MAX = 20;
HALF_BOX_SIZE = 25;
//Clicking Style
CLICK_STYLE = 3;
LEFT_CLICK = 1;
RIGHT_CLICK = 2;
RANDOM_RL_CLICK = 3;
RANDOM_RL_CHANCE = 30; // x / 100 for R click
//Timing
UPTEXT_TIME = 300; // ms
RANDOM_WAIT = 50; // ms
type
{ Type TMSObj
Description: To be used for finding on the MS. Stores all necessary
information. }
TMSObj = record
Name : string;
ID : integer;
UpTexts : TStringArray;
Options : TStringArray;
Color : integer;
Tol : integer;
Hue : extended;
Sat : extended;
SCArray : TIntegerArray;
end;
{*******************************************************************************
Function AnalyseColor(Color: integer): integer;
By: Rasta Magician
Description: Scans MS for Color, returning the number of times it was found
*******************************************************************************}
Function AnalyseColor(Color: integer): integer;
var
CTS, Length : integer;
TPA : TPointArray;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColors(TPA, Color, MSX1, MSY1, MSX2, MSY2)
Length := Length(TPA);
//this will avoid a useless color returning a false positive
if Length = 0 then Length := MAX_UNIQUE_COLOR + 10;
Result := Length;
ColorToleranceSpeed(CTS);
end;
{*******************************************************************************
Function OrganizeColors(Colors, Lengths: TIntegerArray): TIntegerArray;
By: Rasta Magician
Description: Organizes Colors, rarest first, returns organized TIntegerArray
*******************************************************************************}
Function OrganizeColors(Colors, Lengths: TIntegerArray): TIntegerArray;
var
Ic, HighColors: integer;
begin
HighColors := High(Colors)
while (Ic <= HighColors) do
for Ic := 0 to HighColors do
if (Lengths[Ic + 1] < Lengths[Ic]) then
begin
swap(Lengths[Ic + 1], Lengths[Ic]);
swap(Colors[Ic + 1], Colors[Ic]);
break;
end;
Result := Colors;
end;
{*******************************************************************************
Function GatherColors(var Rock: TMSObj): boolean;
By: Rasta Magician
Description: Gathers Colors from a box with double side length of
HALF_BOX_SIZE which match the Color and Tol from TMSObj
with the Hue and Sat modifiers and CTS 2
Sets TMSObj.SCArray to the gathered colors
*******************************************************************************}
Function GatherColors(var Rock: TMSObj): boolean;
var
x, y, i, CTS, RockColorIndex, L: integer;
TPA: TPointArray;
ColorArray, LengthArray: TIntegerArray;
begin
if not LoggedIn then exit;
if not IsUpTextMultiCustom(Rock.UpTexts) then exit;
GetMousePos(x, y);
CTS := GetColorToleranceSpeed;
//scanning colors around in a 50x50 box
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Rock.Hue, Rock.Sat);
if not FindColorsTolerance(
TPA, Rock.Color,
x - HALF_BOX_SIZE, y - HALF_BOX_SIZE,
x + HALF_BOX_SIZE, y + HALF_BOX_SIZE,
Rock.Tol
)
then
exit;
ColorArray := GetColors(TPA);
ClearSameIntegers(ColorArray);
//analysing colors for uniqueness
L := Length(TIA);
SetLength(Rock.Colors, L);
SetLength(LengthArray, L);
for i:= 0 to High(ColorArray) do
begin
L := AnalyzeColor(ColorArray[i]);
if L <= UNIQUE_COLOR_MAX then
begin
Rock.Colors[RockColorIndex] := ColorArray[i];
LengthArray[i] := L;
Inc(RockColorIndex);
end;
end;
SetLength(Rock.Colors, RockColorIndex + 1);
Rock.Colors := OrganizeColors(Rocks.Colors, LengthArray);
end;
{*******************************************************************************
Function CheckAndClick(Pos: TPoint, Rock: TMSObj): boolean;
By: Rasta Magician
Description: Checks Pos for matches with Rock.UpTexts. Return true if
found and click according to CLICK_STYLE
*******************************************************************************}
Function CheckAndClick(Pos: TPoint, Rock: TMSObj): boolean;
var
x, y, ClickType: integer;
begin
MMouse(Pos.x, Pos.y, 2, 2);
if WaitUpTexts(Rock.UpTexts, UPTEXT_TIME) then
begin
wait(Random(RANDOM_WAIT));
Result := true;
GetMousPos(x, y);
if CLICK_STYLE = RANDOM_RL_CLICK then
if random(100) <= RANDOM_RL_CHANCE then
ClickType := RIGHT_CLICK;
case ClickType of
LEFT_CLICK:
Mouse(x, y, 0, 0, True);
RIGHT_CLICK:
begin
Mouse(x, y, 0, 0, false);
ChooseOptions(Rock.Options);
end;
end;
end;
This is just the start of it, some of it will be rewritten. The use of constants is the same as it will be for SRL 5, so take a good notice of that ;)
~RM

