euphemism

Lumbridge Bank Opener by kanah

Dec 9th, 2011
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 3.88 KB | None | 0 0
  1. function OpenLumbridgeBank: Boolean;
  2. //This finds the counter and the glass pair to open the bank
  3. // by: Kanah 12/8/11
  4. var
  5.   CounterInfo,GlassInfo: TExtendedArray;
  6.   CounterTPA,GlassTPA,probBank: TPointArray;
  7.   CounterATPA,TempATPA: T2DPointArray;
  8.   tmpCTS,i,q,len: Integer;
  9.   SearchBox: TBox;
  10. begin
  11.   CounterInfo := [6978442,4,0.08,0.18]; //[Color,Tol,HueMod,SatMod]
  12.   GlassInfo := [9278106,8,0.28,0.48];
  13.   tmpCTS := GetColorToleranceSpeed;
  14.   SetColorToleranceSpeed(2);
  15.   SetColorspeed2Modifiers(CounterInfo[2],CounterInfo[3]);
  16.  
  17.   //Find the counter colors
  18.   if (FindColorsToleranceOptimised(CounterTPA,Round(CounterInfo[0]),MSX1,MSY1,MSX2,MSY2,Round(CounterInfo[1]))) then
  19.   begin
  20.     //Now split it into groups, that are continuous color blocks
  21.     SplitTPAWrap(CounterTPA,1,CounterATPA);
  22.     len := length(CounterATPA);
  23.     SetLength(TempATPA,len);
  24.  
  25.     //DrawDotsMulti(true,CounterATPA);
  26.     //loop Through and check the lengths, get rid of short ones
  27.     for i := 0 to (len-1) do
  28.     begin
  29.       if length(CounterATPA[i]) > 180 then
  30.       begin
  31.         TempATPA[q] := CopyTPA(CounterATPA[i]);
  32.         Inc(q);
  33.       end;
  34.     end;
  35.  
  36.     len := q;
  37.     SetLength(TempATPA,len);
  38.     CounterATPA := CopyATPA(TempATPA);
  39.     SetLength(CounterATPA,len);
  40.     //DrawDotsMulti(true,CounterATPA);
  41.  
  42.     //Now lets find the 4 that are close to each other
  43.     MergeATPAWrap(CounterATPA,CounterTPA);
  44.  
  45.     //Split it again, this will make that group of 4 into 1
  46.     SplitTPAWrap(CounterTPA,50,CounterATPA);
  47.     len := length(CounterATPA);
  48.     //DrawDotsMulti(true,CounterATPA);
  49.  
  50.     //Grab the biggest one and that is the 4 counters
  51.     if not(len = 0) then
  52.     begin
  53.       SortATPASize(CounterATPA,true);
  54.       CounterTPA := CopyTPA(CounterATPA[0]);
  55.       SearchBox := GetTPABounds(CounterTPA);
  56.  
  57.       //Expand it a little in the y direction, in case we facing exactly north or south
  58.       IncEx(SearchBox.y1,-10);
  59.       IncEX(SearchBox.Y2,10);
  60.  
  61.       //Now I'm going to go ahead and seperate the counters back into individual counters; as
  62.       // a back in case the glass can't be found
  63.       SplitTPAWrap(CounterTPA,1,CounterATPA);
  64.       len := length(CounterATPA);
  65.       //SMART_DrawBoxEx(false,SearchBox,clRed);
  66.       SetLength(probBank,len);
  67.       for i := 0 to (len-1) do
  68.       begin
  69.         probBank[i] := MiddleTPA(CounterATPA[i]);
  70.       end;
  71.     end;
  72.     //Now begins the search for the glass
  73.     SetColorspeed2Modifiers(GlassInfo[2],GlassInfo[3]);
  74.  
  75.     if FindColorsToleranceOptimised(GlassTPA,Round(GlassInfo[0]),SearchBox.X1,SearchBox.Y1,SearchBox.X2,SearchBox.Y2,Round(GlassInfo[1])) then
  76.     begin
  77.       //Found some glass points
  78.       //SMART_DrawDotsEx(false,GlassTPA,clRed);
  79.       Inc(len);
  80.       SetLength(probBank,len);
  81.       probBank[len-1] := middleTPA(GlassTPA);
  82.     end else
  83.       writeln('Failed to find any glass points');
  84.  
  85.     //Now i need to mouse over each one and check the uptext
  86.     for i := (len-1) downto 0 do
  87.     begin
  88.       MMouse(probBank[i].x,probBank[i].y,0,0);
  89.       if (WaitUptext('ank bo',500)) then
  90.       begin
  91.         //here goes all the bank stuff
  92.         for q := 0 to 3 do
  93.         begin
  94.           Mouse(probBank[i].x,probBank[i].y,0,0,false);
  95.           wait(100);
  96.           ChooseOption('qui');
  97.           if (WaitFunc(@BankScreen,100,3000)or(PinScreen)) then
  98.           begin
  99.             if (PinScreen) then
  100.             begin
  101.               if not(InPin(Players[CurrentPlayer].Pin)) then
  102.                 CloseBank;
  103.             end;
  104.             //Force end the loops
  105.             i := -1;
  106.             q := 4;
  107.           end;
  108.         end;
  109.       end;
  110.     end;
  111.   end else
  112.     writeln('Failed to find counter colors');
  113.  
  114.   SetColorToleranceSpeed(tmpCTS);
  115.   SetColorSpeed2Modifiers(0.2, 0.2);
  116.   Result := BankScreen;
  117.  
  118.   if (Result) then
  119.   begin
  120.     writeln('opened bank');
  121.   end else
  122.     writeln('failed to open bank');
  123. end;
  124.  
Add Comment
Please, Sign In to add comment