SRL Archive - Test corner

Yay! More mining procedures....!


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.


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.

R0b0t1

2007-10-01 11:00:37

Well, I could mod it for you. Perhaps. Just get my five colors of clay :).

n3ss3s

2007-10-01 12:48:42

Good job Robot! You have made some advancement!

Uhh, now something I can pwn you again with…

a) FindPickHeadColor is already in SRL
b) Cnt := Cnt + 1 is faster than Inc(Cnt)
c)
I'm on FI'YAH!
No you're not :p

I also suggest having the DDTM loading in a separate function that returns the bitmap, so you adjust the areasize and tolerance in a loop until finds + failsafes etc..

nielsie95

2007-10-01 12:52:40

[OffTopic] Inc is faster [/OffTopic]

ShowerThoughts

2007-10-01 12:53:05

lol, n3ss3s show use some script ;)

n3ss3s

2007-10-01 13:10:46

[OffTopic] Inc is faster [/OffTopic]


Go check mastaraymonds tut about the "hidden" scar things, there he says x := x + 1 is faster :O :O :O !

1 h4f b33n sc4mm43d!!

Back on topic anyways ;)

R0b0t1

2007-10-01 13:11:30

I don't care if its already there, I'm gonna still make my own.

Boi'ch!

n3ss3s

2007-10-01 13:25:31

Okay, then another advice, to shorten your code of the pick color getting a shitload, I suggest making a normal DTM with the blackline of the pick + a mainpoint from middle of the head with 255 tol, so then you only need

1. line for DTMFromString
2. line for FindDTM
3. line for getcolor
4. line and so on for the case ;)

nielsie95

2007-10-01 13:33:46

[OffTopic]
c := c + 1: 4922
Inc©: 4906

c + 1 = 0,0016406661197779600740133086622304 ms per
inc = 0,0016353327882224039258653580448807 ms per
:p
[/OffTopic]

Sorry r0b0t. I will stay ontoppic from now on.

R0b0t1

2007-10-01 13:35:08

Lol?

n3ss3s, I made the color thingy so it would be more accurate… pl0x?

ShowerThoughts

2007-10-01 13:57:46

1p vs 1p (n3ss3s vs robot ;)) lets begin!

n3ss3s

2007-10-01 14:18:57

No, Im just kidding, the only reason of these "robot owning" posts of mine recently is that when r0b0t said his gonna make me eat my words, nothing serious ;) Now, back on topic plawkx.

SKy Scripter

2007-10-01 15:20:28

[off] nielsie95 i thought inc and dec were faster but i did some testing and it doesnt seem to be any faster at all…

[/off]


type
TRock = Array [0..8] of record
Name: String;
Color: Integer;
SubCo: TIntegerArray;
end;

Var
Rock: TRock;


:p

the scar noob

2007-10-01 15:31:11

From: n3ss3s
Okay, then another advice, to shorten your code of the pick color getting a shitload, I suggest making a normal DTM with the blackline of the pick + a mainpoint from middle of the head with 255 tol

…


Oh yea, wanne be pwned too?
That's called a BitMapMask:p
Also:
Someone can't be pwned until he has tried to defend him/herself


-Tsn.

R0b0t1

2007-10-01 19:15:40

What? People, slow down! I just woke up from a nap.


Sooo…. Sky, are you saying that I forgot to declare it as an array?

Santa_Clause

2007-10-01 20:30:53

From: the scar noob
Oh yea, wanne be pwned too?
That's called a BitMapMask:p
Also:


-Tsn.


It's a DTM…not bitmap mask.

The Claw

2007-10-01 22:30:16

From: R0b0t1
What? People, slow down! I just woke up from a nap.


Sooo…. Sky, are you saying that I forgot to declare it as an array?


Pretty sure he was. And why do you always make your own functions for finding picks and pickhead colors and stuff? I cant really see the point, lol

SKy Scripter

2007-10-01 22:36:45

From: R0b0t1
What? People, slow down! I just woke up from a nap.


Sooo…. Sky, are you saying that I forgot to declare it as an array?


i was just trying to show you can cut two types into one.. ;)


type
TVoxel = record
x, y, z : Extended;
end;

tvoxelarray = array of tvoxel

into


type
TVoxelArray = array of record
x, y, z : Extended;
end;

just thought i would point that out. even though you dont care ? :p

the scar noob

2007-10-02 03:07:44

From: Santa_Clause
It's a DTM…not bitmap mask.


With a DTM you don't have to take the black outline.. besides, you can't get the whole outline, that's what's a mask is, it's actually the 'picture' of a bitmapwithout the inside colors, just the 'outline'..

-Tsn.

n3ss3s

2007-10-02 09:31:01

Oh yea, wanne be pwned too?
That's called a BitMapMask


Wanna get raped up the ass? Read santas post lol.

Making a dtm with one main point and 4 subpoints takes just as much as time as a bitmapmask ;)

R0b0t1

2007-10-03 18:08:12

Now now people… No raping…

Santa_Clause

2007-10-05 10:01:06

From: the scar noob
With a DTM you don't have to take the black outline.. besides, you can't get the whole outline, that's what's a mask is, it's actually the 'picture' of a bitmapwithout the inside colors, just the 'outline'..

-Tsn.


Whoah?! A DTM is a main point with the black outline of an object…that's what n3ss3s was talking about…it is possible to get the whole black outline but no-one would do it ;)

program New;
{.Include SRL/SRL.scar}
type
Rock = array [0..8] of record
Name: String;
Color: Integer;
SubCo: TIntegerArray;
end;

Var
TinCol, CopperCol, IronCol, SilverCol, CoalCol: TIntegerArray;
GoldCol, MithrilCol, AdamantCol, RuniteCol: TIntegerArray;

procedure SetRockArrayColors;
begin
TinCol := [5855584, 6842479, 5921634, 7960963, 3890794, 4671566];
CopperCol := [4945799, 5143210, 4945314, 5011624, 3890818, 4879492];
IronCol := [10042, 1977158, 2569302, 1844541, 537162, 1646903];
SilverCol := [11316664, 11908799, 12632264, 12632264, 11513785, 11316664];
CoalCol := [1714730, 1715249, 2768960, 2636603, 1516323, 2043181];
GoldCol := [1883881, 1345703, 1547455, 1884396, 1147809, 1750751];
MithrilCol := [8016721, 5585209, 5782331, 5979709, 7491148, 4402477];
AdamantCol := [5861465, 6190428, 5202767, 6388321, 4017213, 6519906];
RuniteCol := [11643512, 8485975, 12103804, 12235388, 11577462, 11182706];
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: //Global rockcolor Var
If (TheRock = Rock[i].Name) Then
begin
OreValue:= Rock[i].Color;
Result:= True;
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
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;
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
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;
If not (Found) then
Exit;

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
Exit;
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;

It's a shortened version…;)

R0b0t1

2007-10-05 17:44:11

Yes, but the computer not knowing the array length actually uses more memory… I think.