Results 1 to 6 of 6

Thread: DiscoverArea

  1. #1
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default DiscoverArea

    Since I want to make a large script I need a procedure that will work globally. This function is supposed to see if your character is around the walking path to the selected area. It also has a banking parameter to invert the path. The problem is that even after it checks the minimap it never actually completes what it's supposed to do.
    Simba Code:
    function LoadPath(Which: string): TPointArray;
    begin
      case (Which) of
      'lumby swamps','noob mine':
        begin
          SetLength(Result, 23);

          Result[0] := Point(3973, 2572);
          Result[1] := Point(3978, 2576);
          Result[2] := Point(3977, 2581);
          Result[3] := Point(3984, 2581);
          Result[4] := Point(3990, 2581);
          Result[5] := Point(3995, 2581);
          Result[6] := Point(3997, 2577);
          Result[7] := Point(3998, 2572);
          Result[8] := Point(3999, 2567);
          Result[9] := Point(4002, 2563);
          Result[10] := Point(4004, 2558);
          Result[11] := Point(4007, 2554);
          Result[12] := Point(4005, 2548);
          Result[13] := Point(4005, 2544);
          Result[14] := Point(4002, 2540);
          Result[15] := Point(4001, 2536);
          Result[16] := Point(3999, 2531);
          Result[17] := Point(3998, 2525);
          Result[18] := Point(3996, 2521);
          Result[19] := Point(3994, 2517);
          Result[20] := Point(3993, 2513);
          Result[21] := Point(3989, 2512);
          Result[22] := Point(3989, 2509);
        end;
      end;
    end;  
    procedure InvertTpPath(var Path: TPointArray);
    var
      Temp: TPointArray;
      i: integer;
    begin
      for i := High(Path) downto 0 do
      begin
        SetLength(Temp, Length(Temp)+1);
        Temp[High(Temp)] := Path[i];
      end;
      Path := Temp;
    end;    

    function DiscoverArea(Where: String; Bank: Boolean): Boolean;
    var
      i, Location: Integer;
      Path: TPointArray;
    begin
      Writeln('Testing..');
      Path := LoadPath(Where);
      if Length(Path) = 0 then
      begin
        Writeln('INVALID PATH!');
        TerminateScript;
      end;
      for i:= 0 to High(Path) do
      begin
        if (TileOnMM(Tile(Path[i].x, Path[i].y))) then
          Location := i;
        Writeln(IntToStr(i));
      end;
      if (Bank) then
        InvertTpPath(Path);
      for i:= (Location) to High(Path) do
      begin
        Result := WalkToTile(Tile(Path[i].x, Path[i].y), 5, 2+random(5));
        if (Result) then
          Writeln('Successfully Walked to tile [ '+ IntToStr(Path[i].x) + ', '
                  + IntToStr(Path[i].y) + ' ]');
      end;
    end;

    *Most of the begins are just to debug. *

    It goes through each tile but even though the player is on the path it does not do anything. Location is always 0.

    It returns this:
    Progress Report:
    Testing..
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    0//location variable

  2. #2
    Join Date
    May 2007
    Location
    Everywhere
    Posts
    1,428
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    These are my quick recommendations:

    Simba Code:
    procedure InvertTpPath(var Path: TPointArray);
    var
      Temp: TPointArray;
      i: integer;
    begin
      for i := High(Path) downto 0 do
      begin
        SetLength(Temp, Length(Temp)+1);
        Temp[High(Temp)] := Path[i];
      end;
      Path := Temp;
    end;

    For this function, WizzyPlugin has a faster function called InvertTPA (...) which you can use. Since it's a plugin, runs faster (nothing noticeable though, but good job at creating your own code).

    For walking, don't use WalkToTile, try WalkPath (TTileArrayHere);
    Plug int the TPA anyways, try this:

    Simba Code:
    Result := WalkPath (LoadPath);
    //or
    Result := WalkPath(InvertTPA(LoadPath));
    Havent tested them, but should work!
    I <3 WalkPath.

  3. #3
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by cstrike View Post
    These are my quick recommendations:

    Simba Code:
    procedure InvertTpPath(var Path: TPointArray);
    var
      Temp: TPointArray;
      i: integer;
    begin
      for i := High(Path) downto 0 do
      begin
        SetLength(Temp, Length(Temp)+1);
        Temp[High(Temp)] := Path[i];
      end;
      Path := Temp;
    end;

    For this function, WizzyPlugin has a faster function called InvertTPA (...) which you can use. Since it's a plugin, runs faster (nothing noticeable though, but good job at creating your own code).

    For walking, don't use WalkToTile, try WalkPath (TTileArrayHere);
    Plug int the TPA anyways, try this:

    Simba Code:
    Result := WalkPath (LoadPath);
    //or
    Result := WalkPath(InvertTPA(LoadPath));
    Havent tested them, but should work!
    I <3 WalkPath.
    But I need it to walk from a certain point. I don't want to tell the user to just go to the bank or mining area. I want them to have a wide array of locations.

    E: How would I remove the un-needed tiles, so that it just walks from its current spot?

  4. #4
    Join Date
    Jun 2007
    Location
    La Mirada, CA
    Posts
    2,484
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    I would do something like...

    Code:
    for (tiles in array)
      if (me within a certain distance to tile[i]) then
        Location = i
    
    for (location to end of path)
      if TileOnMM() then
        WalkToTile
    or something of the sort

    "Failure is the opportunity to begin again more intelligently" (Henry Ford)


  5. #5
    Join Date
    May 2007
    Location
    Everywhere
    Posts
    1,428
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by DeSnob View Post
    But I need it to walk from a certain point. I don't want to tell the user to just go to the bank or mining area. I want them to have a wide array of locations.

    E: How would I remove the un-needed tiles, so that it just walks from its current spot?
    If I have this right, lets say you're at Path # 5 of 12, WalkPath will start at 5 or 6 of 12 (if 6 is the most visible one) and walk that path. It won't start at the beginning for you.

  6. #6
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by cstrike View Post
    If I have this right, lets say you're at Path # 5 of 12, WalkPath will start at 5 or 6 of 12 (if 6 is the most visible one) and walk that path. It won't start at the beginning for you.

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
  •