Results 1 to 12 of 12

Thread: GameTab.scar TakeOff();

  1. #1
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default GameTab.scar TakeOff();

    To me boolean function should always be included when they can be. It just provides more options for failsafes.


    Previous procedure:
    SCAR Code:
    {*******************************************************************************
    procedure TakeOff(I: Integer);
    By: RsN
    Description: UnEquips Item specified in i.
    *******************************************************************************}


    procedure TakeOff(I: Integer);
    var
      TP: TPoint;
    begin
      TP := EquipmentCoords(I);
      if (WearingItem(I)) then
      begin
        Mouse(TP.x, TP.y, 5, 5, True);
        Wait(200 + Random(350));
      end;
    end;

    My version:
    SCAR Code:
    {*******************************************************************************
    function TakeOff(I: Integer): Boolean;
    By: RsN
    Description: UnEquips Item specified in i. Returns True if successful.
    *******************************************************************************}


    function TakeOff(I: Integer): Boolean;
    var
      TP: TPoint; x, y, ii: Integer;
    begin
      if not WearingItem(i) then Exit;
      TP := EquipmentCoords(I);
      for ii := 0 to 4 do
      begin
        Mouse(TP.x, TP.y, 5, 5, True);
        Wait(75 + Random(50));
        Result := WaitColorGone(srl_outline_black, Point(tp.x - 8, tp.y - 8), Point(tp.x + 8, tp.y + 8), 0, 3000);
        if Result then Exit;
      end;
    end;

    Anyone else find this to be a good idea?
    Last edited by NCDS; 02-11-2010 at 06:03 PM.

  2. #2
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    SCAR Code:
    procedure TakeOff(I: Integer): Boolean;

    wat

  3. #3
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    I like it.

  4. #4
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    SCAR Code:
    procedure TakeOff(I: Integer): Boolean;

    wat


    Fixed
    Thanks for pointing that out

  5. #5
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Quote Originally Posted by NCDS View Post


    Fixed
    Thanks for pointing that out
    No problem. Glad to give minuscule help towards someone who seems to have a bunch of fixes as far as I've noticed. ^^

  6. #6
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Yes, but make the wait smaller, and repeat X times and have an If FindColor(BlackOutline) then break.

    That way you can have a smaller wait overall :] get it? :/
    (SPEED!)

  7. #7
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    WaitColorGone

    GJ, you've been putting a lot of work in lately.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  8. #8
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Something like this you mean?:
    SCAR Code:
    function TakeOff(I: Integer): Boolean;
    var
      TP: TPoint; x, y, ii: Integer;
    begin
      if not WearingItem(i) then Exit;
      TP := EquipmentCoords(I);
      for ii := 0 to 4 do
      begin
        Mouse(TP.x, TP.y, 5, 5, True);
        Wait(75 + Random(50));
        Result := (not (FindColor(X, Y, srl_outline_black, TP.x - 8, TP.y - 8, TP.x + 8, TP.y + 8)));
        if Result then Exit;
      end;
    end;
    or this?
    SCAR Code:
    function TakeOff(I: Integer): Boolean;
    var
      TP: TPoint; x, y: Integer;
    begin
      if not WearingItem(i) then Exit;
      TP := EquipmentCoords(I);
      Mouse(TP.x, TP.y, 5, 5, True);
      Result := (not (FindColor(X, Y, srl_outline_black, TP.x - 8, TP.y - 8, TP.x + 8, TP.y + 8)));
      t := GetSystemTime + 5000;
      repeat
        if Result then Exit;
        Wait(50 + Random(50));
      until(GetSystemTime > t);
      srl_Warn('TakeOff', 'Failed to remove item'+IntToStr(i)+'.', warn_Warning);
    end;

    Is that what you meant or did I misunderstand you?

    Edit: and thank you RM

  9. #9
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Both work, WaitColorGone does too. :]

  10. #10
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    Both work, WaitColorGone does too. :]
    Hmm..I've never worked with WaitColorGone before, though it sounds pretty self explanatory :P

    I'll look into it and post the fastest/most efficient version I come up with.

  11. #11
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Timing.scar

    SCAR Code:
    {*******************************************************************************
    function WaitColorGone(Color, x, y, Tol, MaxTime: integer): Boolean;
    By: TRiLeZ
    Description: Waits until a colour is gone at (x, y) with tolerance and a timeout.
    Results true if the colour disappeared at (x, y) within the time cap.
    *******************************************************************************}

    function WaitColorGone(Color, x, y, Tol, MaxTime: integer): Boolean;
    var
      Time: Integer;
    begin
      Result := False;
      if Tol = 0 then Tol := 1;
      Time := GetSystemTime + MaxTime;
      while (Time > GetSystemTime) do
      begin
        if (not SimilarColors(GetColor(X, Y), Color, Tol)) then
        begin
          Result := True;
          Exit;
        end;
        Wait(10);
      end;
    end;

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  12. #12
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    Timing.scar

    SCAR Code:
    {*******************************************************************************
    function WaitColorGone(Color, x, y, Tol, MaxTime: integer): Boolean;
    By: TRiLeZ
    Description: Waits until a colour is gone at (x, y) with tolerance and a timeout.
    Results true if the colour disappeared at (x, y) within the time cap.
    *******************************************************************************}

    function WaitColorGone(Color, x, y, Tol, MaxTime: integer): Boolean;
    var
      Time: Integer;
    begin
      Result := False;
      if Tol = 0 then Tol := 1;
      Time := GetSystemTime + MaxTime;
      while (Time > GetSystemTime) do
      begin
        if (not SimilarColors(GetColor(X, Y), Color, Tol)) then
        begin
          Result := True;
          Exit;
        end;
        Wait(10);
      end;
    end;

    ~RM
    Thanks, and fixed.

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
  •