Roflme
2012-11-14 16:53:22
wall of text, I apologize if I left out any information or if I made any spelling errors.
Working on a mining script, and for a fail safe I was going to use WairColorGone for a failsafe to see if someone else stole the ore. When I was just using WaitColorGone, though, the color that was found would be blocked out by mining animation and it would come back as true, trying to click on the same/another ore. I wanted to know if someone could make suggestions to this function I wrote; will it even work? What can I do to improve it? etc.
(I've posted the other functions that go along with it).
And the goal of the function is that I want to use the furthest color point away from my player. That isn't blocked, but when I was putting WaitColorGone right in my function the colors were just gone. So with the following function, I'm trying to use the coords in MineOre, and set then to cx and cy. Find the colors spiraled around it but only in a small area (to make sure it doesn't include other ores in the TPA). Then, sort them so it'll start with the furthest away.
I believe those are all the functions…
I haven't tested it yet (Don't know what to put in for the Size), but in theory would that work? Are there any other functions that would do what I want (to find when the ore is gone) in some way?
Sorry for the long post :p
If you actually read that all I thank you very much :D!
Working on a mining script, and for a fail safe I was going to use WairColorGone for a failsafe to see if someone else stole the ore. When I was just using WaitColorGone, though, the color that was found would be blocked out by mining animation and it would come back as true, trying to click on the same/another ore. I wanted to know if someone could make suggestions to this function I wrote; will it even work? What can I do to improve it? etc.
(I've posted the other functions that go along with it).
And the goal of the function is that I want to use the furthest color point away from my player. That isn't blocked, but when I was putting WaitColorGone right in my function the colors were just gone. So with the following function, I'm trying to use the coords in MineOre, and set then to cx and cy. Find the colors spiraled around it but only in a small area (to make sure it doesn't include other ores in the TPA). Then, sort them so it'll start with the furthest away.
function CheckIfOreGone(Color, tol: Integer):Boolean;
var
C: Integer;
cTPA: TPointArray;
cATPA: T2DPointArray;
begin
if not FindColorsSpiralTolerance(cx, cy, cTPA, Color, cx-6, cy-6, cx+6, cy+6, tol) then // Probably will have to play with the area it's looking in (the integer cx is +/- by).
Exit;
cATPA := TPAtoATPAEx(cTPA, 1, 1);
SortATPAFromSize(cATPA, {Size??}, False); //What should fill in the size? I put a 1 and it compiled fine?
For C := 0 to High(cATPA) do
ox := MiddleTPA(cATPA[c]).x; //Would I change this to cATPA[0]? Because I ONLY want the furthest away coords, so there's no need for the other cATPAs?
oy := MiddleTPA(cATPA[c]).y;
Result := WaitColorGone(Color, ox, oy, tol, 30000);
end; function MineOre(Which: String; tol: Integer):Boolean;
var
PlusOne, Mining1, Mining2, Mining2Wait: Integer;
begin
if InvFull then
Exit;
MarkTime(Mining1);
case Lowercase(Which) of
'mith':
begin
Color := MithColor; //AutoColor Function
Hue := 0.09;
Sat := 0.61;
Text := ['ithril', 'ril or', 'mithril ore', 'Mine Mith', 'ine M'];
S := ['ine Mith', 'ril ore', 'Mine Mithril ore rocks'];
Mining2Wait := 25000;
end;
'addy':
begin
Color := AddyColor; //AutoColor Function
Hue := 0.11;
Sat := 0.72;
Text := ['amant', 'ine A', 'tite or'];
S := ['Mine Adamantite ore rocks', 'ine Ada', 'ite or', 'daman'];
Mining2Wait := 55000;
end;
end;
if not FindOre(Color, tol, Hue, Sat, Text) then
Exit;
begin
PlusOne := InvCount + 1;
ClickMouse2(false);
Result := WaitOptionMulti(S, 500);
if TimeFromMark(Mining1) > 10000 then
Exit;
if Result then
begin
MarkTime(Mining2);
Wait(RandomRange(300,400));
while IsMoving do
Wait(250);
cx := x;
cy := y;
// CheckIfOreGone would go here
repeat
Wait(RandomRange(100,120));
until WaitColorGone(Color, cx, cy, tol, 30000) or (InvCount = PlusOne) or (TimeFromMark(Mining2) > Mining2Wait);
end;
end;
end; function FindOre(Color, tol: Integer; Hue, Sat: Extended; Text: TStringArray):Boolean;
var
tCTS, I: Integer;
TPA: TPointArray;
ATPA: T2DPointArray;
myPoint: TPoint;
begin
myPoint := Point(MSCX, MSCY);
tCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(Hue, Sat);
if not FindColorsSpiralTolerance(MSCX, MSCY, TPA, Color, MSX1, MSY1, MSX2, MSY2, tol) then
begin
ColorToleranceSpeed(tCTS);
Exit;
end;
ATPA := TPAtoATPAEx(TPA, 10, 10);
SortATPAFrom(ATPA, myPoint);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 2, 2);
if IsUpTextMultiCustom(Text) then
Result := True;
end;
ColorToleranceSpeed(tCTS);
end; I believe those are all the functions…
I haven't tested it yet (Don't know what to put in for the Size), but in theory would that work? Are there any other functions that would do what I want (to find when the ore is gone) in some way?
Sorry for the long post :p
If you actually read that all I thank you very much :D!