Guest User

Untitled

a guest
May 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. Function RockCount(Debug, Clear:Boolean):Integer;
  2. var
  3. A,I,L,R,X,Y:Integer;
  4. OrePts,RockPts,TPA:TPointArray;
  5. RockPtsBox: T2DPointArray;
  6. SearchBox: TBox;
  7. Begin
  8.  
  9. If Not(LoggedIn) Then Exit;
  10.  
  11. If OreInLast Then Exit;
  12.  
  13. {Rock Points}
  14. ColorToleranceSpeed(2);
  15. SetColorSpeed2Modifiers(0.04, 1.27);
  16. FindColorsSpiralTolerance(MSCX, MSCY, RockPts, 1461093, MSX1, MSY1, MSX2, MSY2, 10);
  17. SetColorSpeed2Modifiers(0.2,0.2);
  18. ColorToleranceSpeed(1);
  19. {Rock Points}
  20.  
  21. {ATPA Rocks}
  22. RockPtsBox := TPAtoATPAEx(RockPts,36,36);
  23.  
  24. {ATPA Rocks}
  25.  
  26. L := High(RockPtsBox);
  27.  
  28. For I := 0 To L Do
  29. Begin
  30.  
  31. If (GetArrayLength(RockPtsBox[I]) > 30) Then
  32. Begin
  33.  
  34. SearchBox := GetTPABounds(RockPtsBox[I]);
  35.  
  36. with SearchBox do
  37. begin
  38. {Ore Color Within RockBox}
  39. ColorToleranceSpeed(2);
  40. SetColorSpeed2Modifiers(1.39,0.11);
  41. FindColorsSpiralTolerance(MSCX,MSCY,OrePts,2434854,SearchBox.x1,SearchBox.y1,SearchBox.x2,SearchBox.y2,10);
  42. SetColorSpeed2Modifiers(0.2,0.2);
  43. ColorToleranceSpeed(1);
  44. {Ore Color Within RockBox}
  45.  
  46. If Length(OrePts) > 1 Then
  47. Begin
  48.  
  49. Inc(R);
  50. SetArrayLength(TPA, (Length(TPA)+1));
  51. MiddleTPAEx(OrePts, X, Y);
  52. TPA[A] := Point(X, Y);
  53. Inc(A);
  54.  
  55. If Clear Then
  56. SMART_ClearCanvasArea( PointToBox( Point(MSX1-1, MSY1), Point(MSX2, MSY2+2) ) );
  57.  
  58. End;
  59.  
  60. end;
  61.  
  62. end;
  63.  
  64. end;
  65.  
  66. Result := R;
  67.  
  68. If Debug Then
  69.  
  70. Begin
  71. //'TPA' now contains the middle of each rock containing ore, so let's split these into an ATPA for debugging :)
  72. SMART_DrawDotsMulti(False, (TPAtoATPAEx(TPA, 36,36)));
  73. SMART_DrawText(MSX1+175, MSY1, CharsNPC, 'There are ~' + IntToStr(Result) + ' rocks with ore!', clWhite);
  74. //Or 'There are '+Length(TPA)+' rocks with ore!'
  75. End;
  76.  
  77.  
  78. end;
Add Comment
Please, Sign In to add comment