Results 1 to 6 of 6

Thread: WithdrawItem

  1. #1
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default WithdrawItem

    SCAR Code:
    {*******************************************************************************
    function WithdrawItem(Ident: integer; IdentType: string; var Index: integer; Amount: integer; UpText: TStringArray; Tol: TIntegerArray): boolean;
    By: Nava2
    Sections by: WT-Fakawi / Sumilion
    Description: Withdraws an item from the bank by using "Ident" with tol[0]
    as color tolerance, tol[1] as contour tolerance in case of bmp masks. Valid IdentTypes are :
    bmp, mask, color, dtm.
    Index: The Bank Index where the item is found, must be a variable. Speeds up future withdraws.
    Amount: Amount to withdraw from bank.
    UpText: The Uptext which the function checks for.
    *******************************************************************************}


    function WithdrawItem(Ident: integer; IdentType: string; var Index: integer; Amount: integer; UpText: TStringArray; Tol: TIntegerArray): boolean;

    var
      x1, y1, coltol, contol : integer;
      BPoint : TPoint;
      BankBox : TBox;
      F, Found : boolean;

    label
      Start;

    begin
      {Written by WT-Fakawi / Sumilion, from this line to {end}
      case LowerCase(IdentType) of
        'bmpmask', 'bitmapmask', 'bmp mask', 'bitmap mask', 'mask':
          try
            begin
              coltol := tol[0];
              contol := tol[1];
            end;
          except
            srl_Warn('WithdrawItem', 'Tol was incorrect', warn_AllVersions);
            Exit;
          end;
        'dtm': begin end;         //I guess this is a check to make sure its a valid identifier?
        'bmp', 'bitmap', 'color':
          try
            coltol := tol[0];
          except
            srl_Warn('WithdrawItem', 'Tol was incorrect', warn_AllVersions);
            Exit;
          end;
        else begin
          srl_Warn('WithdrawItem', 'Invalid identifier type: ' + IdentType, warn_AllVersions);
          Exit;
        end;
      end;
      {End}
      if (Index = 0) then
      begin
        Start:
        for Index := 1 to 50 do
        begin
          BankBox := BankIndexToMSBox(Index);
          case LowerCase(IdentType) of
            'bmp', 'bitmap': F := FindBitmapSpiralTolerance(Ident, x1, y1, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, coltol);
            'bmpmask', 'bitmapmask', 'bmp mask', 'bitmap mask', 'mask': F :=FindBitmapMaskTolerance(Ident, x1, y1, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, coltol, contol);
            'color': F := FindColorTolerance(x1, y1, Ident, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, coltol);
            'dtm': F := FindDtm(Ident, x1, y1, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2);
          end;
          if F then
          begin
            MMouse(x1, y1, 4, 4);
            Wait(100+random(50));
            if IsUpTextMultiCustom(UpText) then
            begin
              Writeln('Found Item at Bank Slot ' + IntToStr(Index) + '.');
              Found := true;
              break;
            end else
              Writeln('Found Incorrect Item, Moving to new Bank Spot.');
          end;
        end;
      end else
      begin
        BankBox := BankIndexToMSBox(Index);
        MouseBox(BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, 3);
        Wait(100+random(50));
        if IsUpTextMultiCustom(UpText) then
          Found := true
        else
        begin
          Writeln('Item Moved from Bank Slot ' + IntToStr(Index) + ', checking bank again.');
          GoTo Start;
        end;
      end;
      Wait(200+random(150));
      if Found then
      begin
        BPoint := MSTPointToBankPoint(Point(x1, y1));
        Withdraw(BPoint.x, BPoint.y, Amount);
        Result := true;
      end else
      begin
        Index := 0;
        Writeln('Could not Find ' + IdentType + ' in Bank.');
      end;
    end;

    {*******************************************************************************
    function WithdrawItemEx(Ident: integer; IdentType: string; Amount: integer; UpText: TStringArray; Tol: TIntegerArray): boolean;
    by: Nava2
    Description: Withdraws an item using WithdrawItem, but removes the Index check.
    *******************************************************************************}


    function WithdrawItemEx(Ident: integer; IdentType: string; Amount: integer; UpText: TStringArray; Tol: TIntegerArray): boolean;

    var
      I : integer;

    begin
      Result := WithdrawItem(Ident, IdentType, I, Amount, UpText, Tol);
    end;

    Read the descriptions to see how the functions work. The DTM and Bitmap withdrawing works flawlessly, I'm uncertain as to the mask and colors.

    The second function removes the index checking, which is a cool feature which allows scar to remember where the item is.

    Please post comments and suggestions.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  2. #2
    Join Date
    Mar 2008
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Looks amazing to me! will it withdraw something from the whole bank? even if it is down a little ways?

  3. #3
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    No, Only if its on the first page, at the top.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  4. #4
    Join Date
    Mar 2008
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Okay, still cool, but if we could make some awesome function that would find items in the whole thing lol, although it would be hard if not impossible to do with colors... But still good job, will it find it anywhere in the first window or just the 1st row of the 1st window as well?

  5. #5
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    First window, it searches the first 50 items.

    Maybe I will add in the search item thing..
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  6. #6
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Edited some things, improved code.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •