NCDS
2010-07-20 17:05:12
Current: (tweaked a couple thing's in WaitWhileMining to match up with the new one)
After fixing the suggestions:
We can't wrap MSI_MineInvFull and MSI_ChopInvFull at this point because of this line:
So, until we decide on a way around that were stuck with this.
I would appreciate it if you guy's would test the two different Mining.Simba's so we can decide which one work's best.
Thanks :)
I'm going to say as of right now that the new one is better. I'm quite sure that the WaitWhileMining functions much better this time. Still needs a little work possibly, but it's better.
{==============================================================================\
| MSI Group Scripting Include |
| Mining.scar |
|==============================================================================|
| For all mining routines. |
| |
| * function MSI_FindRock(); * by NCDS |
| * procedure MSI_WaitWhileMining(); * by NCDS |
| * function MSI_MineRock(); * by NCDS |
| * function MSI_MineInvFull(); * by NCDS & marpis |
\ _____________________________________________________________________________}
{******************************************************************************}
{ function MSI_FindRock(...): Boolean; }
{ By: NCDS }
{ Date: 11 July 2010 }
{ Description: Returns true if rock is found and the rocks in RockArray. }
{******************************************************************************}
function MSI_FindRock(var RockArray: T2DPointArray; SearchBox: TBox; RockInfo: TMSObjectArray): Boolean;
var
cts, i, ii: Integer;
Arr: TPointArray;
MDAr: T2DPointArray;
begin
for i := 0 to High(RockInfo) do
begin
cts := GetColorToleranceSpeed;
SetColorSpeed2Modifiers(RockInfo[i].Hue, RockInfo[i].Sat);
SetLength(MDAr, Length(RockInfo[i].Colors));
for ii := 0 to High(RockInfo[i].Colors) do
FindColorsSpiralTolerance(MSCx, MSCy, MDAr[ii], RockInfo[i].Colors[ii],
SearchBox.x1, SearchBox.y1, SearchBox.x2,
SearchBox.y2, RockInfo[i].Tol);
for ii := 0 to High(MDAr) do
begin
if Length(MDAr[ii]) <= 0 then
Continue
else if Length(MDAr[ii]) >= RockInfo[i].Accuracy then
Arr := CombineTPA(Arr, MDAr[ii]);
end;
RockArray := TPAToATPAEx(Arr, RockInfo[i].W, RockInfo[i].H);
SortATPAFrom(RockArray, Point(MSCx, MSCy));
Result := (Length(RockArray) > 0);
if Result then
Exit;
end;
SetColorToleranceSpeed(cts);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
{******************************************************************************}
{ Procedure MSI_WaitWhileMining(RockInfo: TMSObject); }
{ By: NCDS }
{ Date: 11 July 2010 }
{ Description: Wait's until an Ore has been mined. }
{******************************************************************************}
Procedure MSI_WaitWhileMining(RockInfo: TMSObject);
var
cts, OldInvCount, t, RockColorCount: Integer;
RockArray: TMSObjectArray;
MDAr, MDAr2: T2DPointArray;
SearchBox: TBox;
begin
Flag;
Wait(RandomRange(285, 450));
t := GetSystemTime + 60000;
SearchBox := IntToBox(
MSCx - Round(RockInfo.W * 1.75),
MSCy - Round(RockInfo.H * 1.75),
MSCx + Round(RockInfo.W * 1.75),
MSCy + Round(RockInfo.H * 1.75));
RockArray := [RockInfo];
if MSI_FindRock(MDAr, SearchBox, RockArray) then
begin
RockColorCount := Length(MDAr);
OldInvCount := InvCount;
repeat
if MSI_FindRock(MDAr2, SearchBox, RockArray) then
if (Length(MDAr2) < Round(RockColorCount * 0.40)) then
Exit;
MSI_AntiBan(RandomRange(0, 3000), ANTI_BAN_CHANCE);
MSI_FindRandoms;
if (OldInvCount < InvCount) then
Exit;
Wait(RandomRange(200, 500));
until((not(MSI_FindRock(MDAr2, SearchBox, RockArray))) or (t > GetSystemTime)
or (Length(MDAr2) < Round(RockColorCount * 0.40)));
end;
end;
{******************************************************************************}
{ function MSI_MineRock(Which: TIntegerArray): Boolean; }
{ By: NCDS }
{ Date: 11 July 2010 }
{ Description: Mines Rock }
{******************************************************************************}
function MSI_MineRock(Which: TIntegerArray): Boolean;
var
MDAr: T2DPointArray;
Rocks: TMSObjectArray;
SearchBox: TBox;
Click: Boolean;
tP: TPoint;
i, ii, x, y: Integer;
begin
Rocks := MSI_GetObjects(Which);
SearchBox := IntToBox(MSx1, MSy1, MSx2, MSy2);
for i := 0 to High(Rocks) do
begin
if MSI_FindRock(MDAr, SearchBox, Rocks) then
for ii := 0 to High(MDAr) do
begin
tP := MiddleTPA(MDAr[ii]);
MMouse(tP.x, tP.y, 2, 2);
if WaitUpText(Rocks[i].UpText, 1200) then
begin
GetMousePos(x, y);
Click := (Random(10) < 7);
Mouse(x, y, 0, 0, Click);
if (not Click) then
Result := WaitOption(Rocks[i].Option, 2000)
else
Result := True;
if Result then
MSI_WaitWhileMining(Rocks[i]);
Exit;
end;
end;
end;
end;
{******************************************************************************}
{ function MSI_MineInvFull(Which: TIntegerArray): Boolean; }
{ By: NCDS & mapris }
{ Date: 11 July 2010 }
{ Description: Mines Rock's until Inventory is full. }
{******************************************************************************}
function MSI_MineInvFull(Which: TIntegerArray): Boolean;
var
t: Integer;
begin
t := (GetSystemTime + (5 * 60000));
while (not(InvFull)) and LoggedIn and (GetSystemTime < t) do
begin
if MSI_MineRock(Which) then
t := (GetSystemTime + (5000 * 60000));
Wait(RandomRange(100, 300));
end;
Result := InvFull;
end;
After fixing the suggestions:
{==============================================================================\
| MSI Group Scripting Include |
| Mining.scar |
|==============================================================================|
| For all mining routines. |
| |
| * procedure MSI_WaitWhileMining(); * by NCDS |
| * function MSI_MineRock(); * by NCDS |
| * function MSI_MineInvFull(); * by NCDS & marpis |
\ _____________________________________________________________________________}
{******************************************************************************}
{ Procedure MSI_WaitWhileMining(RockInfo: TMSObject); }
{ By: NCDS }
{ Date: 11 July 2010 }
{ Description: Wait's until an Ore has been mined. }
{******************************************************************************}
Procedure MSI_WaitWhileMining(RockInfo: TMSObject);
var
cts, OldInvCount, t, i, RockColorCount: Integer;
MDAr: T2DPointArray;
Arr: array of TPoint;
SearchBox: TBox;
begin
Flag;
Wait(RandomRange(285, 450));
if InvFull then
Exit;
cts := GetColorToleranceSpeed;
SetToleranceSpeed2Modifiers(RockInfo.Hue, RockInfo.Sat);
t := (GetSystemTime + 60000);
SearchBox := IntToBox(
MSCx - Round(RockInfo.W * 1.75),
MSCy - Round(RockInfo.H * 1.75),
MSCx + Round(RockInfo.W * 1.75),
MSCy + Round(RockInfo.H * 1.75));
OldInvCount := InvCount;
repeat
FindColorsTolerance(Arr, RockInfo.Colors[0], SearchBox.x1,
SearchBox.y1, SearchBox.x2, SearchBox.y2, RockInfo.Tol);
if (Length(Arr) < RockInfo.Accuracy) then
Break;
RockColorCount := Length(Arr);
if (Length(Arr) < Round(RockColorCount * 0.50)) then
Break;
MSI_FindRandoms;
MSI_AntiBan(RandomRange(0, 3000), ANTI_BAN_CHANCE);
if (OldInvCount < InvCount) then
Break;
Wait(RandomRange(100, 300));
until((t > GetSystemTime) or (Length(Arr) < Round(RockColorCount * 0.50)))
SetColorToleranceSpeed(cts);
end;
{******************************************************************************}
{ function MSI_MineRock(Which: TIntegerArray): Boolean; }
{ By: NCDS }
{ Date: 11 July 2010 }
{ Description: Mines Rock }
{******************************************************************************}
function MSI_MineRock(Which: TIntegerArray): Boolean;
var
Rocks: TMSObjectArray;
SearchBox: TBox;
Index: Integer;
begin
Rocks := MSI_GetObjects(Which);
SearchBox := IntToBox(MSx1, MSy1, MSx2, MSy2);
if MSI_FindObjectsIn(Rocks, Index, SearchBox, ClickLeft) then
begin
Result := True;
MSI_WaitWhileMining(Rocks[Index]);
end;
end;
{******************************************************************************}
{ function MSI_MineInvFull(Which: TIntegerArray): Boolean; }
{ By: NCDS & marpis }
{ Date: 11 July 2010 }
{ Description: Mines Rock's until Inventory is full. }
{******************************************************************************}
function MSI_MineInvFull(Which: TIntegerArray): Boolean;
var
t: Integer;
Begin
t := (GetSystemTime + (5 * 60000));
while (not InvFull) and (LoggedIn) and (GetSystemTime < t) do
begin
if MSI_MineRock(Which) then
t := (GetSystemTime + (5 * 60000));
Wait(RandomRange(100, 300));
end;
Result := InvFull;
end;
We can't wrap MSI_MineInvFull and MSI_ChopInvFull at this point because of this line:
if MSI_MineRock(Which) then
Obviously, it is:
if MSI_ChopTree(Which) then
in Woodcutting.SimbaSo, until we decide on a way around that were stuck with this.
I would appreciate it if you guy's would test the two different Mining.Simba's so we can decide which one work's best.
Thanks :)
I'm going to say as of right now that the new one is better. I'm quite sure that the WaitWhileMining functions much better this time. Still needs a little work possibly, but it's better.