R0b0t1
2007-09-30 21:20:53
Yep, just made some more. Feel free to test it, but I'm fairly sure they will work a majority of the time.
Oh yeah, you do need almost all of the script to be able to use any one procedure.
Oh yeah, you do need almost all of the script to be able to use any one procedure.
program New;
{.Include SRL/SRL.scar}
type
TRock = record
Name: String;
Color: Integer;
SubCo: TIntegerArray;
end;
Var
Rock: Array [0..8] of TRock;
TinCol, CopperCol, IronCol, SilverCol, CoalCol: Array [0..5] of Integer;
GoldCol, MithrilCol, AdamantCol, RuniteCol: Array [0..5] of Integer;
procedure SetRockArrayColors;
begin
TinCol[0]:= 5855584;
TinCol[1]:= 6842479;
TinCol[2]:= 5921634;
TinCol[3]:= 7960963;
TinCol[4]:= 3890794;
TinCol[5]:= 4671566;
CopperCol[0]:= 4945799;
CopperCol[1]:= 5143210;
CopperCol[2]:= 4945314;
CopperCol[3]:= 5011624;
CopperCol[4]:= 3890818;
CopperCol[5]:= 4879492;
IronCol[0]:= 10042;
IronCol[1]:= 1977158;
IronCol[2]:= 2569302;
IronCol[3]:= 1844541;
IronCol[4]:= 537162;
IronCol[5]:= 1646903;
SilverCol[0]:= 11316664;
SilverCol[1]:= 11908799;
SilverCol[2]:= 12632264;
SilverCol[3]:= 12632264;
SilverCol[4]:= 11513785;
SilverCol[5]:= 11316664;
CoalCol[0]:= 1714730;
CoalCol[1]:= 1715249;
CoalCol[2]:= 2768960;
CoalCol[3]:= 2636603;
CoalCol[4]:= 1516323;
CoalCol[5]:= 2043181;
GoldCol[0]:= 1883881;
GoldCol[1]:= 1345703;
GoldCol[2]:= 1547455;
GoldCol[3]:= 1884396;
GoldCol[4]:= 1147809;
GoldCol[5]:= 1750751;
MithrilCol[0]:= 8016721;
MithrilCol[1]:= 5585209;
MithrilCol[2]:= 5782331;
MithrilCol[3]:= 5979709;
MithrilCol[4]:= 7491148;
MithrilCol[5]:= 4402477;
AdamantCol[0]:= 5861465;
AdamantCol[1]:= 6190428;
AdamantCol[2]:= 5202767;
AdamantCol[3]:= 6388321;
AdamantCol[4]:= 4017213;
AdamantCol[5]:= 6519906;
RuniteCol[0]:= 11643512;
RuniteCol[1]:= 8485975;
RuniteCol[2]:= 12103804;
RuniteCol[3]:= 12235388;
RuniteCol[4]:= 11577462;
RuniteCol[5]:= 11182706;
end;
function BetterColor(Colors: TIntegerArray): Integer; //Wizzup?
var
I: Integer;
H, S, L: Array Of Extended;
bH, bS, bL: Extended;
begin;
SetArrayLength(H, Length(Colors));
SetArrayLength(S, Length(Colors));
SetArrayLength(L, Length(Colors));
For I := 0 To Length(Colors) - 1 Do
begin;
ColorToHSL(Colors[i], H[i], S[i], L[i]);
bH := bH + H[i];
bS := bS + S[i];
bL := bL + L[i];
End;
If Length(Colors) < 0 Then
Begin
bH := bH Div Length(Colors);
bS := bS Div Length(Colors);
bL := bL Div Length(Colors);
End;
Result := HSLToColor(bH, bS, bL);
End;
procedure SetRockColors;
begin;
Rock[0].Name:= 'tin';
Rock[0].Color:= BetterColor(TinCol);
Rock[0].SubCo:= TinCol;
Rock[1].Name:= 'copper';
Rock[1].Color:= BetterColor(CopperCol);
Rock[1].SubCo:= CopperCol;
Rock[2].Name:= 'iron';
Rock[2].Color:= BetterColor(IronCol);
Rock[2].SubCo:= IronCol;
Rock[3].Name:= 'silver';
Rock[3].Color:= BetterColor(SilverCol);
Rock[3].SubCo:= SilverCol;
Rock[4].Name:= 'coal';
Rock[4].Color:= BetterColor(CoalCol);
Rock[4].SubCo:= CoalCol;
Rock[5].Name:= 'gold';
Rock[5].Color:= BetterColor(GoldCol);
Rock[5].SubCo:= GoldCol;
Rock[6].Name:= 'mithril';
Rock[6].Color:= BetterColor(MithrilCol);
Rock[6].SubCo:= MithrilCol;
Rock[7].Name:= 'adamant';
Rock[7].Color:= BetterColor(AdamantCol);
Rock[7].SubCo:= AdamantCol;
Rock[8].Name:= 'runite';
Rock[8].Color:= BetterColor(RuniteCol);
Rock[8].SubCo:= RuniteCol;
end;
function SetPlayerRockColor(var OreValue: Integer; TheRock: String): Boolean;
var I, ScCo: Integer; //TheRock:
begin //EX: Players[I].Strings[I]
For ScCo:= 0 to GetArrayLength(Rock) do //OreValue:
begin //Global rockcolor Var
If (TheRock = Rock[I].Name) Then
begin
OreValue:= Rock[I].Color;
Result:= True;
end else
Result:= False;
end;
end;
function ExtendedSearch(var xt, yt: Integer; ColorT, x1, y1, x2, y2, TolT, Extense: Integer): Boolean;
var
SBox: TBox;
I, Cnt, InitXP, InitYP: Integer;
DidFind: Boolean;
begin;
GetClientDimensions(InitXP, InitYP);
SBox.x1:= x1
SBox.y1:= y1
SBox.x2:= x2
SBox.y2:= y2
For I:= 0 to Extense do
begin
DidFind:= FindColorTolerance(xt, yt, ColorT, SBox.x1, SBox.y1, SBox.x2, SBox.y2, TolT);
If not (DidFind) then
begin;
If (Cnt <= 0) then
Result:= False
else
begin
WriteLn('Did not find color to fullest extent - ExtendedSearch');
Result:= True;
xt:= xt;
yt:= yt;
Exit;
end;
end;
Inc(Cnt);
SBox.x1:= xt - Round(25/Cnt);
SBox.y1:= yt - Round(25/Cnt);
SBox.x2:= xt + Round(25/Cnt);
SBox.y2:= yt + Round(25/Cnt);
If (SBox.x1 < 0) then
SBox.x1:= 0;
If (SBox.y1 < 0) then
SBox.y1:= 0;
If (SBox.x2 > InitXP) then
SBox.x2:= InitXP;
If (SBox.y2 > InitYP) then
SBox.y2:= InitYP;
end;
Result:= True;
end;
function FindRock(var ClickBox: TBox; RockToFindL: String; T: Integer): Boolean;
var
I, B, Q, MPCol, xxx, yyy, Cnt, SPX, SPY, TRo: Integer;
Found: Boolean;
SkipA: Array [0..14] of TPoint;
SkipA2: Array [0..20] of TPoint;
begin
case LowerCase(RockToFindL) of
'tin' : MPCol:= Rock[0].Color;
'copper' : MPCol:= Rock[1].Color;
'iron' : MPCol:= Rock[2].Color;
'silver' : MPCol:= Rock[3].Color;
'coal' : MPCol:= Rock[4].Color;
'gold' : MPCol:= Rock[5].Color;
'mithril': MPCol:= Rock[6].Color;
'adamant': MPCol:= Rock[7].Color;
'runite' : MPCol:= Rock[8].Color;
end;
For I:= 0 to 8 do
If (MPCol = Rock[I].Color) then TRo:= I;
For I:= 0 to 14 do
begin
Found:= FindColorSkipcoordsTolerance(xxx, yyy, MPCol, MSX1, MSY1, MSX2, MSY2, T, SkipA)
If Found then
begin
Inc(Cnt);
SkipA[I].x:= xxx;
SkipA[I].y:= yyy;
If (Cnt >= 5) then
Break;
end;
If not Found then
begin
For B:= 0 to 5 do
begin
Found:= FindColorSkipCoordsTolerance(xxx, yyy, Rock[TRo].SubCo[I], MSX1, MSY1, MSX2, MSY2, T-10, SkipA);
If Found then
begin
Inc(Cnt);
SkipA[I].x:= xxx;
SkipA[I].y:= yyy;
If (Cnt >= 5) then
Break;
end;
end;
end;
end;
If not (Found) then
begin
Result:= False;
Exit;
end;
Cnt:= 0;
Q:= 0;
For I:= 0 to 5 do
begin
repeat
SPX:= SkipA[I].x;
SPX:= SkipA[I].y;
Found:= FindColorSkipCoordsTolerance(SPX, SPY, MPCol, SPX+13, SPY+13, SPX-13, SPY-25, T, SkipA2);
If not Found then
For B:= 0 to 5 do
begin
Found:= FindColorSkipCoordsTolerance(SPX, SPY, Rock[TRo].SubCo[B], SPX+13, SPY+13, SPX-13, SPY-13, T, SkipA2);
If Found then Break;
end;
If Found then
begin
Inc(Cnt);
SkipA2[Q].x:= SPX;
SkipA2[Q].y:= SPX;
end;
Inc(Q);
until(Cnt >= 5) or (Q = 20)
B:= I;
If (Cnt >= 5) and not (Q >= 20) then Break;
end;
If not (Cnt >= 5) then
begin
Result:= False;
Exit;
end;
ClickBox.x1:= SkipA[B].x + 13;
ClickBox.y1:= SkipA[B].y + 13;
ClickBox.x2:= SkipA[B].x - 13;
ClickBox.y2:= SkipA[B].y - 13;
Result:= True;
end;
function GetPickColor(var xx, yy, PickC: Integer; Picks: String): Boolean;
var
I: Integer;
Found: Boolean;
MPHDTMTol, PHDTMTol, MPHDTMColor, PHDTMColor, PHDTMSize: Integer;
PickHeadMP: TDTMPointDef;
PickHeadSP: Array [0..4] of TDTMPointDef;
PickHeadSkele: TDTM;
PickDTM: Integer;
begin
case LowerCase(Picks) of
'all' : MPHDTMColor:= 3680034;
'bronze' : MPHDTMColor:= 139054;
'iron' : MPHDTMColor:= 3814708;
'steel' : MPHDTMColor:= 5526357;
'mithril': MPHDTMColor:= 5060662;
'adamant': MPHDTMColor:= 3951421;
'rune' : MPHDTMColor:= 6181955;
end;
If (MPHDTMColor = 3680034) then
MPHDTMTol:= 255
else
MPHDTMTol:= 50;
//MPHDTMTol:= 255; //From original source, replaced by above if.
PHDTMTol:= 5;
//MPHDTMColor:= 3680034; //From original source, replaced by above case.
PHDTMColor:= 65536;
PHDTMSize:= 1;
//---------------------
PickHeadMP.x:= 29;
PickHeadMP.y:= 16;
PickHeadMP.AreaSize:= 1;
PickHeadMP.AreaShape:= 0;
PickHeadMP.Color:= MPHDTMColor;
PickHeadMP.Tolerance:= MPHDTMTol;
//---------------------
PickHeadSP[0].x:= 14;
PickHeadSP[0].y:= 19;
PickHeadSP[0].AreaSize:= PHDTMSize;
PickHeadSP[0].AreaShape:= 0;
PickHeadSP[0].Color:= PHDTMColor;
PickHeadSP[0].Tolerance:= PHDTMTol;
//---------------------
PickHeadSP[1].x:= 28;
PickHeadSP[1].y:= 14;
PickHeadSP[1].AreaSize:= PHDTMSize;
PickHeadSP[1].AreaShape:= 0;
PickHeadSP[1].Color:= PHDTMColor;
PickHeadSP[1].Tolerance:= PHDTMTol;
//---------------------
PickHeadSP[2].x:= 31;
PickHeadSP[2].y:= 14;
PickHeadSP[2].AreaSize:= PHDTMSize;
PickHeadSP[2].AreaShape:= 0;
PickHeadSP[2].Color:= PHDTMColor;
PickHeadSP[2].Tolerance:= PHDTMTol;
//---------------------
PickHeadSP[3].x:= 42;
PickHeadSP[3].y:= 25;
PickHeadSP[3].AreaSize:= PHDTMSize;
PickHeadSP[3].AreaShape:= 0;
PickHeadSP[3].Color:= PHDTMColor;
PickHeadSP[3].Tolerance:= PHDTMTol;
//---------------------
PickHeadSP[4].x:= 24;
PickHeadSP[4].y:= 20;
PickHeadSP[4].AreaSize:= PHDTMSize;
PickHeadSP[4].AreaShape:= 0;
PickHeadSP[4].Color:= PHDTMColor;
PickHeadSP[4].Tolerance:= PHDTMTol;
//---------------------
PickHeadSkele.MainPoint:= PickHeadMP;
PickHeadSkele.SubPoints:= PickHeadSP;
PickDTM:= AddDTM(PickHeadSkele);
//---------------------
If not (FindDTM(PickDTM, xx, yy, MIX1, MIY1, MIX2, MIY2)) then
begin
For I:= 0 to 5 do
begin
Inc(PHDTMSize);
If MPHDTMTol <> 255 then
IncEx(MPHDTMTol, 5);
Found:= FindDTM(PickDTM, xx, yy, MIX1, MIY1, MIX2, MIY2);
If Found then Break;
end;
MPHDTMTol:= 5;
PHDTMSize:= 1;
end else
begin
PickC:= GetColor(xx, yy);
Result:= True;
end;
If not Found then
begin
xx:= -1;
yy:= -1;
Result:= False;
end;
end;
begin
end.