From: Flight
I have a quick question that's pretty far off topic, but it has to do with MSI so lend me a little slack please. :)
In MSI mining scripts, how do you detect if you're player is still mining? Through their animation I'm assuming? I recently completed my own reflection mining script and I stumbled upon a very nifty method "FindRSObjectSimple". I used this, after we clicked on the rock, to check if the rock was infact still there or did it change recently (perhaps someone else got the ore before us?). I worked this into my script to detect first, if the rock was infact still there, and second if we were either moving or animating, if so then we would wait until rock had changed and then give the go ahead to find another. It works very efficiently and I've not seen it in any other mining script which really surprises me.
So if MSI has this kind of mining detection already then super! If not, I'll be more than happen to share what I have. :)
That's almost exactly what MSI does, minus the animation check. We do, however, have color animations, but haven't felt the need to add it to mining as of yet. In case you're interested, here's exactly what MSI does:
- After clicking the rock, it will use MSI's tracking system to follow the rock's location while the player walks toward it.
- Once the player has stopped moving, it continually monitors the colors in the "tracking box" made by the tracking system.
- If the amount of colors found decreases enough, it moves to the next rock.
- Along with color checking, it checks inventory count and chat box text.
- Finally, it will break out of the loop after a maximum time specific to each rock as a final failsafe.
Here's MSI_WaitWhileMining if you're interested (it's 100% color if you were wondering). :)
Procedure MSI_WaitWhileMining(RockID: integer);
var
cts, OldInvCount, t, d, RockColorCount: Integer;
Arr, TPA: TPointArray;
SearchBox: TBox;
begin
if (not LoggedIn) then
Exit;
Flag;
Wait(RandomRange(285, 450));
if InvFull then
Exit;
MSI_AddHeader('MSI_WaitWhileMining');
cts := GetColorToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(MSI_Objects[RockID].Hue, MSI_Objects[RockID].Sat);
t := (GetSystemTime + MSI_Objects[RockID].MaxTime + Random(5000));
SearchBox := IntToBox(
MSI_Objects[RockID].X - Round(MSI_Objects[RockID].W * SIZE_MULTIPLIER),
MSI_Objects[RockID].Y - Round(MSI_Objects[RockID].H * SIZE_MULTIPLIER),
MSI_Objects[RockID].X + Round(MSI_Objects[RockID].W * SIZE_MULTIPLIER),
MSI_Objects[RockID].Y + Round(MSI_Objects[RockID].H * SIZE_MULTIPLIER));
if (MSI_SetupVars[SETUP_DEBUG_SMART]) then
SMART_DrawBoxEx(True, SearchBox, clBlue);
TPA := TPAFromBox(SearchBox);
sortTPAFrom(TPA, point(MSCX, MSCY));
if (length(TPA) > 0) then
begin
d := distance(TPA[0].x, TPA[0].y, MSCX, MSCY);
MSI_Debug('Distance from tracking box to player = '+intToStr(d));
if (d > ROCK_MAX_DIST) then
begin
MSI_Debug('Track box too far from player');
MSI_CloseHeader('MSI_WaitWhileMining: Finished');
exit;
end;
end;
OldInvCount := InvCount;
MSI_Debug('InvCount: ' + IntToStr(OldInvCount));
{preparing variables to detect when rock is gone through color}
FindColorsTolerance(Arr, MSI_Objects[RockID].Colors[0], SearchBox.x1,
SearchBox.y1, SearchBox.x2, SearchBox.y2, MSI_Objects[RockID].Tol);
RockColorCount := Length(Arr);
{done}
repeat
MSI_FindRandoms(False);
FindColorsTolerance(Arr, MSI_Objects[RockID].Colors[0], SearchBox.x1,
SearchBox.y1, SearchBox.x2, SearchBox.y2, MSI_Objects[RockID].Tol);
if (MSI_SetupVars[SETUP_DEBUG_SMART]) then
SMART_DrawDotsEx(False, Arr, clYellow);
if (Length(Arr) < MSI_Objects[RockID].Accuracy) then
begin
MSI_Debug('Colours found < Accuracy');
Break;
end;
if (Length(Arr) < Round(RockColorCount * 0.50)) then
begin
MSI_Debug('Rock Gone, not enough points');
Break;
end;
MSI_AntiBan(RandomRange(0, 3000), ANTI_BAN_CHANCE);
if (OldInvCount < InvCount) then
begin
MSI_Debug('OldInvCount < InvCount');
Break;
end;
if FindChatBoxText('manage to mine', 8, clMessage) then
begin
MSI_Debug('Found Text');
Break;
end;
Wait(RandomRange(100, 300));
if (t < GetSystemTime) then
begin
MSI_Debug('Took too long');
break;
end;
until((not LoggedIn));
MSI_CloseHeader('MSI_WaitWhileMining: Finished');
SetColorToleranceSpeed(cts);
SetColorSpeed2Modifiers(0.2, 0.2);
end;