Results 1 to 6 of 6

Thread: Fixed GetAmount();

  1. #1
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Smile Fixed GetAmount();

    I have seen couple people that says the current one missed one digit.
    Example real amount 480;
    Script saw it as 80;


    Code:
    {*******************************************************************************
    function GetAmount(ItemX, ItemY: Integer): Integer;
    By: ZephyrsFury Edited By Home
    Description: Returns the amount of an item at coordinates (ItemX, ItemY).
      Returns approximate values for 'K' and 'M'.
    *******************************************************************************}
    
    function GetAmount(ItemX, ItemY: Integer): Integer;
    var
      S: string;
      Col, II: Integer;
      B: TBox;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      if (FindColorsTolerance(TPA, 65536, ItemX - 50, ItemY - 50, ItemX + 50, ItemY + 50, 0)) then
      begin
        SortTPAFrom(TPA, Point(ItemX, ItemY));
        ATPA := SplitTPAEx(TPA, 5, 5);
        B := GetTPABounds(ATPA[0]);
        if (Length(ATPA[0]) < 15) or (B.X2 - B.X1 < 5) or (B.Y2 - B.Y1 < 5) then Exit;
        Result := 1;
        for II := 2 downto 0 do
          if (FindColorsTolerance(TPA, 7575987 * II * II - 6796134 * II + 65535, B.X1 - 10, B.Y1 - 10, B.X2 + 10, B.Y2 + 10, 0)) then
            Break;
        if (II < 0) then Exit;
        SortTPAFrom(TPA, Point((B.X1 + B.X2) shr 1, (B.Y1 + B.Y2) shr 1));
        ATPA := SplitTPAEx(TPA, 5, 5);
        TPA := ATPA[0];
        Col := 7575987 * II * II - 6796134 * II + 65535;
        B := GetTPABounds(TPA);
        S := Trim(GetTextAtEx(B.X1 - 10, B.Y1 - 1, 0, StatChars, False, False, 0, 1, Col, 5, True, tr_AllChars));
        Result := StrToIntDef(GetNumbers(S), 1);
        if (Pos('M', S) > 0) then Result := Result * 1000000 else
        if (Pos('K', S) > 0) then Result := Result * 1000;
      end;
    end;
    I edited this:

    Code:
     S := Trim(GetTextAtEx(B.X1 , B.Y1 - 1, 0, StatChars, False, False, 0, 1, Col, 5, True, tr_AllChars));
    To:

    Code:
     S := Trim(GetTextAtEx(B.X1 - 10, B.Y1 - 1, 0, StatChars, False, False, 0, 1, Col, 5, True, tr_AllChars));
    I know a small fix, but still something

    ~Home

  2. #2
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    We love you home !
    NOT!
    ~Hermen

  3. #3
    Join Date
    Dec 2008
    Location
    In a galaxy far, far away...
    Posts
    584
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Funny i just fixed it yesterday, and added an extra thing -6 was good enough however.
    http://www.villavu.com/forum/showthread.php?p=608449



    ~NS

  4. #4
    Join Date
    Mar 2007
    Location
    <3
    Posts
    2,683
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice work Home!

    Good to see you contributing

  5. #5
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    Quote Originally Posted by Nadeem View Post
    Funny i just fixed it yesterday, and added an extra thing -6 was good enough however.
    http://www.villavu.com/forum/showthread.php?p=608449



    ~NS
    Heh, ohh well ANd thanks N1ke!

    ~Home

  6. #6
    Join Date
    Mar 2007
    Location
    <3
    Posts
    2,683
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ended up re-writing GetAmount.
    It now works, and I've uploaded the new one to the Dev-svn.

    Thanks again Home.
    Closed.

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
  •