SRL Archive - Test corner

From the one and only r0b0t1 - his own mining procedures!


R0b0t1

2007-09-07 22:59:02

Yes… Yes… Feel free to look at them.

Feel free to compliment :p.


program New;
{.Include SRL/SRL.scar}

Type TRock = record
Name: String;
Color: Integer;
end;

Var
Rock: Array [0..8] of TRock;
TinCol, CopperCol, IronCol, SilverCol, CoalCol: Array [0..5] of Integer;
MithrilCol, AdamantCol, RuniteCol: Array [0..5] of Integer;
TheBox: TBox;

Function BetterColor(Colors: TIntegerArray): Integer; //Wizzup?
Var
I: Integer;
H, S, L: Array Of Extended;
bH, bS, bL: Extended;
begin;
SetLength(H, Length(Colors);
SetLength(S, Length(Colors);
SetLength(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 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;

Procedure SetRockColors;
begin;
Rock[0].Name:= 'tin';
Rock[0].Color:= BetterColor(TinCol);
Rock[1].Name:= 'copper';
Rock[1].Color:= BetterColor(CopperCol);
Rock[2].Name:= 'iron';
Rock[2].Color:= BetterColor(IronCol);
Rock[3].Name:= 'silver';
Rock[3].Color:= BetterColor(SilverCol);
Rock[4].Name:= 'coal';
Rock[4].Color:= BetterColor(CoalCol);
Rock[5].Name:= 'gold';
Rock[5].Color:= BetterColor(GoldCol);
Rock[6].Name:= 'mithril';
Rock[6].Color:= BetterColor(MithrilCol);
Rock[7].Name:= 'adamant';
Rock[7].Color:= BetterColor(AdamantCol);
Rock[8].Name:= 'runite';
Rock[8].Color:= BetterColor(RuniteCol);
end;

Procedure SetPlayerRockColor; //Call after switching players.
Var I:Integer;
begin;
RockColor:= 0;
For I:=0 to GetArrayLength(Rock) - 1 do
begin;
If (Players[CurrentPlayer].Strings[0] = Rock[i].Name) Then
RockColor:= Rock[i].Color;
end;
If (RockColor = 0) Then
RaiseException(erCustomError, 'Value stored in ''cmbRock.Text'' is in valid.');
end;

{_____________________________________________________________________________}
{---------------------------MINING PROCEDURES---------------------------------}
Function MineDropRock: Boolean;
Var I, B, C, D, x1, x2, y1, y2, OX, OY, r0bOre, OreCount, InvCount: Integer;
Var OX2, OY2, SlotX1, SlotX2, SlotY1, SlotY2: Integer;
Var BreakLoop, RockFound: Boolean;
begin;
If (InvCount < 1) Then
InvCount:= 1;
r0bOre := DTMFromString('78DA6314666460886340012D95D50CFF81345' +
'086E13F1030F20359010C188019AA0604183980AC704C35ACC86A' +
'9881AC34026A0481AC6C026A6481AC14026A1481AC48026A2481A' +
'C204C359C486A00B8F10A2B');
For B:=0 to 6 do
begin;
Case B of //Case by WT-Fakawi. I changed the letter :p
1: begin x1:= MSx1; y1 := MSy1 + 20; x2 := MSCx; y2:= MSCy; end;
2: begin x1:= MSCx; y1 := MSy1 + 20; x2 := MSx2; y2:= MSCy; end;
3: begin x1:= MSx1; y1 := MSCy; x2 := MSCx; y2:= MSy2; end;
4: begin x1:= MSCx; y1 := MSCy; x2 := MSx2; y2:= MSy2; end;
5: begin x1:= MSCx - 50; y1 := MSCy - 50; x2 := MSCx + 50; y2:= MSCy + 50; end;
6: begin x1:= MSx1; y1 := MSy1 + 20; x2 := MSx2; y2:= MSy2; end;
end;
For C:=0 to 15 do
begin;
BreakLoop:=FindColorSpiralTolerance(OX, OY, RockColor, x1, y1, x2, y2, C);
If (BreakLoop) Then
Break;
end;
If not (BreakLoop) Then
Continue;
If (BreakLoop) Then
begin;
Mouse(OX, OY, 2, 2, False);
If (ChooseOption(x, y, 'ine')) Then
begin;
RockFound:= True;
end else
begin;
WriteLn('Trouble finding rock')
RockFound:= False;
end;
end;
If not (RockFound) Then
begin;
For D:=0 to 5 do
begin;
Case lowercase(Players[CurrentPlayer].Strings[0]) of
'tin': RockColor:= TinCol[D];
'copper': RockColor:= CopperCol[D];
'iron': RockColor:= IronCol[D];
'silver': RockColor:= SilverCol[D];
'coal': RockColor:= CoalCol[D];
'gold': RockColor:= GoldCol[D];
'mithril': RockColor:= MithrilCol[D];
'adamant': RockColor:= AdamantCol[D];
'runite': RockColor:= RuniteCol[D];
end;
For C:= 0 to 15 do
begin;
BreakLoop:=FindColorSpiralTolerance(OX, OY, RockColor, x1, y1, x2, y2, E)
If (BreakLoop) Then
Break;
end;
If (BreakLoop) Then
begin;
Mouse(OX, OY, 2, 2, False);
If (ChooseOption(x, y, 'ine')) Then
begin;
RockFound:= True;
end else
begin;
WriteLn('Trouble finding rock')
RockFound:= False;
end;
end;
If not (RockFound) Then
begin;
WriteLn('Could not find rock')
Result:= False;
Exit;
end;
If (RockFound) Then
Break;
end;
If (RockFound) Then
Break;
end;
If (RockFound) Then
Break;
end;
If (Players[CurrentPlayer].Booleans[0]) And (InvCount < 1) Then //first slot
inc(InvCount);
Case InvCount of
1: TheBox:= InvBox(InvCount);
2: TheBox:= InvBox(InvCount);
3: TheBox:= InvBox(InvCount);
4: TheBox:= InvBox(InvCount);
5: TheBox:= InvBox(InvCount);
6: TheBox:= InvBox(InvCount);
7: TheBox:= InvBox(InvCount);
8: TheBox:= InvBox(InvCount);
9: TheBox:= InvBox(InvCount);
10: TheBox:= InvBox(InvCount);
11: TheBox:= InvBox(InvCount);
12: TheBox:= InvBox(InvCount);
13: TheBox:= InvBox(InvCount);
14: TheBox:= InvBox(InvCount);
15: TheBox:= InvBox(InvCount);
16: TheBox:= InvBox(InvCount);
17: TheBox:= InvBox(InvCount);
18: TheBox:= InvBox(InvCount);
19: TheBox:= InvBox(InvCount);
20: TheBox:= InvBox(InvCount);
21: TheBox:= InvBox(InvCount);
22: TheBox:= InvBox(InvCount);
23: TheBox:= InvBox(InvCount);
24: TheBox:= InvBox(InvCount);
25: TheBox:= InvBox(InvCount);
26: TheBox:= InvBox(InvCount);
27: TheBox:= InvBox(InvCount);
28: TheBox:= InvBox(InvCount);
end;
If (FindDTM(r0bOre, OX2, OY2, TheBox.x1, TheBox.y1, TheBox.x2, TheBox.y2)) Then
inc(InvCount);
If (InvCount = 28) Then
begin;
If not (Players[CurrentPlayer].Booleans[0]) Then //Banking, if false
begin;
If (Players[CurrentPlayer].Booleans[1]) Then //Wielded pick?
DropTo(2, 28);
else
DropTo(1, 28);
end;
end;
end;

begin;
end.

EDIT: Added the type: TRock.
EDIT: Changed to work with TBoxes and InvBox().

elementalelf

2007-09-07 23:29:02

thats a sweet script, very complex, especially for a scar based pascal script.

+rep(if the rep system is working)

R0b0t1

2007-09-07 23:36:36

Nahs, nos reps.

its onlys parts ofs as scripts. :)s

Bobarkinator

2007-09-08 00:35:27

Very nice work!!

n3ss3s

2007-09-08 03:23:30

Good work, but your "Slot" thing might be unnecassary, SRL has now "InvBox(Slot: Integer)" :)

The Claw

2007-09-08 04:44:28

Not bad, not bad :p Should I post my mining procs?

nielsie95

2007-09-08 10:01:17

Wouldn't the GetBetterColor return the same everytime? So you could set the rock colors without arrays? And instead of SlotX1, SlotY1, SLotX2, SlotY2 why not use a TBox and use GetInvBox? ;)

Other then that, nice work.

n3ss3s

2007-09-08 11:19:56

GetInvBox


Its InvBox Mr.Dev :D

nielsie95

2007-09-08 11:24:57

You get the idea ;)

R0b0t1

2007-09-08 17:29:05

Oh, thank you :p didn't know about it.


Did you look at the logic though? Or did you scroll through and say, "Holy Shit!"?


If you would read through it, it checks for the better color first, and then searches through the arrays of integers that are the colors. :). This is a fine example for "For" loops.


EDIT: Changed stuff.

nielsie95

2007-09-09 04:12:12

Ok, I admit I was more scrolling ;)
Looked a bit more at it now :) Looks pretty nice, but why the case for
TheBox:= InvBox(InvCount)?

R0b0t1

2007-09-09 11:23:04

To count j00 ores.

Every repetition, it looks at that inventory slot that should be occupied by an ore… If its there, aye oh kay.


I think I may have left out some functions it relies on…