Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function StairAutoColor(var TheColor: Integer): Boolean;
- var
- arP: TPointArray;
- arC: TIntegerArray;
- tmpCTS, i, arL: Integer;
- X, Y, Z: Extended;
- begin
- tmpCTS := GetColorToleranceSpeed;
- ColorToleranceSpeed(2);
- SetColorSpeed2Modifiers(0.18, 0.14);
- FindColorsSpiralTolerance(MMCX, MMCY, arP, 5332585, MMX1, MMY1, MMX2, MMY2, 4);
- if (Length(arP) = 0) then
- begin
- Result := False;
- ColorToleranceSpeed(tmpCTS);
- SetColorSpeed2Modifiers(0.2, 0.2);
- Exit;
- end;
- arC := GetColors(arP);
- ClearSameIntegers(arC);
- arL := High(arC);
- for i := 0 to arL do
- begin
- ColorToXYZ(arC[i], X, Y, Z);
- if (X >= 9.37) and (X <= 13.60) and (Y >= 9.62) and (Y <= 13.87) and (Z >= 7.82) and (Z <= 11.21) then
- begin
- TheColor := arC[i];
- Result := True;
- Break;
- end;
- end;
- ColorToleranceSpeed(tmpCTS);
- SetColorSpeed2Modifiers(0.2, 0.2);
- if (i = arL + 1) then
- Result := False;
- end;
- function ClimbStairs(GoingUp: Boolean): Boolean;
- var
- CTS, I, Len, StairColor, Tol, X, Y: Integer;
- Hue, Sat: Extended;
- StairOptions, UpTextOptions: TStringArray;
- StairCenters, StairTPA: TPointArray;
- StairATPA: T2DPointArray;
- begin
- Result := False;
- if not StairAutoColor(StairColor) then
- StairColor := 5332585;
- Hue := 0.18; Sat := 0.14; Tol := 4;
- UpTextOptions := ['limb', 'air', 'case', 'stair'];
- if GoingUp then
- StairOptions := ['Climb-up', 'up', 'b-u']
- else
- StairOptions := ['Climb-down', 'down', 'b-d', 'ow'];
- CTS := GetColorToleranceSpeed;
- SetColorToleranceSpeed(2);
- SetColorSpeed2Modifiers(Hue, Sat);
- while Tol < 30 do
- begin
- if not FindColorsTolerance(StairTPA, StairColor, MSX1, MSY1, MSX2, MSY2, Tol)
- then
- IncEx(Tol, 5)
- else
- Break;
- end;
- if Length(StairTPA) = 0 then
- Exit;
- SetColorSpeed2Modifiers(0.2, 0.2);
- SetColorToleranceSpeed(CTS);
- SplitTPAExWrap(StairTPA, 24, 24, StairATPA);
- SortATPASize(StairATPA, True);
- Len := Length(StairATPA);
- SetLength(StairCenters, Len);
- for I := 0 to (Len - 1) do
- StairCenters[i] := MiddleTPA(StairATPA[i]);
- for I := 0 to (Len - 1) do
- begin
- MouseBox(StairCenters[i].x - 8, StairCenters[i].y - 8,
- StairCenters[i].x + 10, StairCenters[i].y + 10, 3);
- if not WaitUpTextMulti(UpTextOptions, 500) then
- Continue;
- GetMousePos(X, Y);
- Mouse(X, Y, 0, 0, False);
- if WaitOptionMulti(StairOptions, 500) then
- begin
- SMART_DrawDotsEx(True, StairATPA[i], clWhite);
- Wait(800 + Random(300));
- ClearRSCanvas(SMART_Canvas.canvas);
- Result := True;
- Break;
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment