Results 1 to 4 of 4

Thread: LinearWalkEx

  1. #1
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default LinearWalkEx

    RWEx
    and i found the same problem in LinearWalkEx
    LinearWalkEx:
    SCAR Code:
    {*******************************************************************************
    function LinearWalkEx(var tpa: TPointArray; cx, cy, TheColor, tol: Integer; Direction: Integer; Radius: Integer): Boolean;
    By: Nielsie95
    Description: Finds TheColor from Radial (scanning outwards) for Radius Distance.
    Valid Arguments:
    tpa: Result points.
    Direction: Any number between 0-720. 0=N,90=E,180=S,270=W.
    Radius: Distance from the centre of minimap, i.e. how far away the mouse clicks. Use numbers 20-72
    *******************************************************************************}


    function LinearWalkEx(var tpa: TPointArray; cx, cy, TheColor, tol: Integer; Direction: Integer; Radius: Integer): Boolean;
    var
      i, SD, ED: Integer;
    begin
      Result := False;
      if (not LoggedIn) then Exit;
      if Radius > 70 then Radius := 70;
      i := GetSystemTime;
      Direction := Direction mod 360;
      if (Direction < 50) then
        SD := ((Direction + 360) - 50)
      else
        SD := (Direction - 50);
      ED := (Direction + 50);
      while (SD > 360) do
        SD := SD - 360;
      while (ED > 360) do
        ED := ED - 360;
      try
        FindColorsTolerance(tpa, TheColor, MMX1, MMY1, MMX2, MMY2, tol);
        FilterPointsPie(tpa, SD, ED, 10, Radius, cx, cy);
        LinearSort(tpa, cx, cy, Direction, False);
        Result := (Length(tpa) > 0);
      except srl_Warn('LinearWalkEx', 'LWex error!', warn_AllVersions); Exit; end;
    // Uncomment this for debug
    //  WriteLn('LWex time: '+IntToStr(GetSystemTime - i)+'ms. Found points: '+IntToStr(Length(tpa)));
    end;
    RadialWalkEx:
    SCAR Code:
    {*******************************************************************************
    function RadialWalkEx(var tpa: TPointArray; cx, cy, TheColor, tol: Integer; StartRadial, EndRadial: Integer; Radius: Integer): Boolean;
    By: Nielsie95
    Description: Finds TheColor from StartRadial to EndRadial for Radius Distance.
    Valid Arguments:
    tpa: Result points.
    StartRadial/EndRadial: Any number between 0-720. 0=N,90=E,180=S,270=W.
    Radius: Distance from the centre of minimap, i.e. how far away the mouse clicks. Use numbers 20-72
    *******************************************************************************}


    function RadialWalkEx(var tpa: TPointArray; cx, cy, TheColor, tol: Integer; StartRadial, EndRadial: Integer; Radius: Integer): Boolean;
    var
      i, SD, ED: Integer;
    begin
      Result := False;
      SD := StartRadial;
      ED := EndRadial;
      if Radius > 70 then Radius := 70;
      if (SD = ED) then
      begin
        WriteLn('Using LinearWalkEx, equal values.');
        Result := LinearWalkEx(tpa, cx, cy, TheColor, tol, StartRadial, Radius);
      end;
      if (SD > ED) then
        Swap(SD, ED);
      while (SD > 360) do
        SD := SD - 360;
      while (ED > 360) do
        ED := ED - 360;
      if (not LoggedIn) then Exit;
      i := GetSystemTime;
      try
        FindColorsTolerance(tpa, TheColor, MMX1, MMY1, MMX2, MMY2, tol);
        FilterPointsPie(tpa, SD, ED, 10, Radius, cx, cy);
        SortCircleWise(tpa, cx, cy, StartRadial, False, StartRadial > EndRadial);
        Result := (Length(tpa) > 0);
      except srl_Warn('RadialWalkEx', 'An exception has occured', warn_AllVersions); Exit; end;
    // Uncomment this for debug
    //  WriteLn('RWex time: '+IntToStr(GetSystemTime - i)+'ms. Found points: '+IntToStr(Length(tpa)));
    end;
    so if someone tries to make the radius too large or types in the radius wrong then it wont end up messing up the script
    therefore it will change the radius so it wont be too large and mess up the script

    ~shut

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

    Default

    Nice find;

    RWEx only calls LinerWalkEx if SD = ED;

    so it will still mess up in RWEx

    SCAR Code:
    try
        FindColorsTolerance(tpa, TheColor, MMX1, MMY1, MMX2, MMY2, tol);
        FilterPointsPie(tpa, SD, ED, 10, Radius, cx, cy);
        SortCircleWise(tpa, cx, cy, StartRadial, False, StartRadial > EndRadial);
        Result := (Length(tpa) > 0);
      except srl_Warn('RadialWalkEx', 'An exception has occured', warn_AllVersions); Exit; end;

    and all the scripter wil know is that there was an exception.

    maybe we would add
    if Radius > 70 then Radius := 70

    as it would be pointless to have it any bigger than that?

    ~RM

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

  3. #3
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  4. #4
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    RadialWalkEx and LinearWalkEx don't necessarily need to be used on the minimap (hence you must specify the centre of the circle you're searching in (cx, cy)).

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
  •