Advertisement
WarPie90

Untitled

Jul 4th, 2023
1,222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.59 KB | None | 0 0
  1. type
  2.   TAlchemyValue = record
  3.     Name: string;
  4.     Points: Int32;
  5.     PatternId: Int32;
  6.   end;
  7.   TAlchemyValues = array of TAlchemyValue;  
  8.  
  9. const
  10.   pattern: TStringArray := [
  11.     'Leather boots', 'Adamant kiteshield', 'Adamant med helm', 'Emerald',
  12.     'Rune longsword','','',''
  13.   ];
  14.  
  15. function GetAlchValues(): TAlchemyValues;
  16. var
  17.   b: TBox;
  18.   TSA: TStringArray;
  19.   TPA: TPointArray;
  20.   ATPA: T2DPointArray;
  21.   i,j,z: Int32;
  22.  
  23.   function Compare(constref a,b: TAlchemyValue): Int32; static;
  24.   begin
  25.     Result := Sign(B.Points-A.Points);
  26.   end;
  27.  
  28. begin
  29.   try
  30.     b := Minimap.Bounds;
  31.     b := [b.x1-250, b.y1+80, b.x2-250, b.y2+50];
  32.  
  33.     SRL.FindColors(TPA, CTS2(45620, 6, 0.14, 0.01), b);
  34.     ATPA := TPA.Cluster(20, 2);
  35.     ATPA.SortByX(True);
  36.     ATPA.SortByY(True);
  37.  
  38.     RSClient.Image.DrawBox(b, 255);
  39.     for i:=0 to High(ATPA) do
  40.     begin
  41.       TSA += ocr.Recognize(ATPA[i].Bounds().Expand(2), TOCRColorFilter.Create([45620], [30]), RS_FONT_PLAIN_11);
  42.       z := TSA[High(TSA)].Pos('I');
  43.       if z > 1 then
  44.       begin
  45.         if LowerCase(TSA[High(TSA)][z-1]) = TSA[High(TSA)][z-1] then
  46.           TSA[High(TSA)][z] := 'l';
  47.       end;
  48.  
  49.       TSA[High(TSA)] := TSA[High(TSA)].Replace('Helm', 'med helm', [rfReplaceAll]);
  50.     end;
  51.  
  52.     for i:=0 to High(TSA) with 2 do
  53.       for j:=0 to High(pattern) do
  54.         if LowerCase(TSA[i]).Pos(LowerCase(pattern[j])) > 0 then
  55.         begin
  56.           Result += [pattern[j], StrToIntDef(TSA[i+1], 0), j];
  57.           break;
  58.         end;
  59.  
  60.     Sort(Result, @Compare);
  61.   except
  62.     SetLength(Result, 8); //hack!
  63.   end;
  64. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement