Results 1 to 10 of 10

Thread: SPS walk timeout?

  1. #1
    Join Date
    Oct 2011
    Posts
    422
    Mentioned
    15 Post(s)
    Quoted
    116 Post(s)

    Default SPS walk timeout?

    Please excuse me if this feature has already been included


    Is there a way to implement a walk timeout for SPS? So if the character is stuck, SPS_walkpath does not follow an infinite loop of trying to walk to the next flag

  2. #2
    Join Date
    Nov 2011
    Location
    MA
    Posts
    545
    Mentioned
    3 Post(s)
    Quoted
    10 Post(s)

    Default

    You mean like marking the time before and repeating until the time is greater than a certain number?

  3. #3
    Join Date
    Oct 2011
    Posts
    422
    Mentioned
    15 Post(s)
    Quoted
    116 Post(s)

    Default

    Quote Originally Posted by tehq View Post
    You mean like marking the time before and repeating until the time is greater than a certain number?
    I doubt encapsulating a timeout in the loop will work because once SPS_walkpath is called, it does not return until it finishes walking the path- very deadly situation especially if your character is stuck

  4. #4
    Join Date
    Jul 2009
    Location
    Australia
    Posts
    667
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by slushpuppy View Post
    I doubt encapsulating a timeout in the loop will work because once SPS_walkpath is called, it does not return until it finishes walking the path- very deadly situation especially if your character is stuck
    Have you tried pasting the actual sps_walkpath function into your script, then calling it from your script (not the SPS Include) and manually implementing a timeout? (This is the quickfix that I used in a couple of my scripts).

    ~Caotom

  5. #5
    Join Date
    Oct 2011
    Posts
    422
    Mentioned
    15 Post(s)
    Quoted
    116 Post(s)

    Default

    Quote Originally Posted by Caotom View Post
    Have you tried pasting the actual sps_walkpath function into your script, then calling it from your script (not the SPS Include) and manually implementing a timeout? (This is the quickfix that I used in a couple of my scripts).

    ~Caotom
    Thanks, I modified the SPS.simba directly, +1 for opensource . Would be nice if there was a SPS_setTimeOut() that would work for all SPS functions hehe

  6. #6
    Join Date
    Mar 2012
    Location
    Shenzhen China
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i think its better to add a stuck detection in SPS_WalkPath.
    so it return false stand for a stuck come.
    use timeout to failsafe is not a good idea in my opinion.

  7. #7
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Would be nice to see, Since something like a gate could close on you and the script would be clicking on the minimap for years :P

  8. #8
    Join Date
    Feb 2008
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    There is already a timeout built into SPS_WalkPath .. it has a 25 second timeout, I think when it goes back after clicking the minimap it should compare the position that it got to the old position and if it didnt change then exit.

    Code:
    // Walks the path "Path"; always walks to the furthest point possible
    function SPS_WalkPath(Path: TPointArray): boolean;
    var
      I, H, T, D: integer;
      P, MM,tempP: TPoint;
    begin
      tempP := Point(-1,-1);
      H := High(Path);
      T := GetSystemTime + 20000 + Random(5000);
    
      while (not Result) and (GetSystemTime < T) do
      begin
        RunEnergy(20);
    
        P := SPS_GetMyPos;
    
        If tempP.X <> -1 then  // check if player is stuck. 
          if InRange(tempP.X, (P.X - 10), (P.X + 10)) then
            If InRange(tempP.Y, (P.Y - 10), (P.Y + 10)) then
            Begin
              Result := false;
              Exit;
            end;
    
        tempP := P; 
    
        for I := H downto 0 do
        begin
          MM.X := MMCX + Path[I].X - P.X;
          MM.Y := MMCY + Path[I].Y - P.Y;
    
          D := Distance(MM.X, MM.Y, MMCX, MMCY);
    
          if (D < 10) then
            break
          else
            if (D < 70) then
            begin
              if (SPS_MultiMouse) then
                MultiMouse(MM.X, MM.Y, 25, 3, false)
              else
                Mouse(MM.X, MM.Y, 5, 5, mouse_Left);
    
              FFlag(Integer(I <> H) * 15);
    
              T := getSystemTime + 20000 + Random(1000);
     	        Break;
            end;
        end;
    
        Result := (I = H);
      end;
    end;
    Last edited by shadowrecon; 04-20-2012 at 09:20 PM.

  9. #9
    Join Date
    Oct 2011
    Posts
    422
    Mentioned
    15 Post(s)
    Quoted
    116 Post(s)

    Default

    Quote Originally Posted by shadowrecon View Post
    There is already a timeout built into SPS_WalkPath .. it has a 25 second timeout, I think when it goes back after clicking the minimap it should compare the position that it got to the old position and if it didnt change then exit.

    Code:
    // Walks the path "Path"; always walks to the furthest point possible
    function SPS_WalkPath(Path: TPointArray): boolean;
    var
      I, H, T, D: integer;
      P, MM,tempP: TPoint;
    begin
      tempP := Point(-1,-1);
      H := High(Path);
      T := GetSystemTime + 20000 + Random(5000);
    
      while (not Result) and (GetSystemTime < T) do
      begin
        RunEnergy(20);
    
        P := SPS_GetMyPos;
    
        If tempP.X <> -1 then  // check if player is stuck. 
          if InRange(tempP.X, (P.X - 10), (P.X + 10)) then
            If InRange(tempP.Y, (P.Y - 10), (P.Y + 10)) then
            Begin
              Result := false;
              Exit;
            end;
    
        tempP := P; 
    
        for I := H downto 0 do
        begin
          MM.X := MMCX + Path[I].X - P.X;
          MM.Y := MMCY + Path[I].Y - P.Y;
    
          D := Distance(MM.X, MM.Y, MMCX, MMCY);
    
          if (D < 10) then
            break
          else
            if (D < 70) then
            begin
              if (SPS_MultiMouse) then
                MultiMouse(MM.X, MM.Y, 25, 3, false)
              else
                Mouse(MM.X, MM.Y, 5, 5, mouse_Left);
    
              FFlag(Integer(I <> H) * 15);
    
              T := getSystemTime + 20000 + Random(1000);
     	        Break;
            end;
        end;
    
        Result := (I = H);
      end;
    end;
    SPS_getmyPos isn't remarkably accurate, you would get differences +-2 even shortest periods between function calls. I don't really understand how checking a range of +-10 would determine if you are stuck

  10. #10
    Join Date
    Feb 2008
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by slushpuppy View Post
    SPS_getmyPos isn't remarkably accurate, you would get differences +-2 even shortest periods between function calls. I don't really understand how checking a range of +-10 would determine if you are stuck
    It compares you current location to the location it previously had, and if its the same or withing a 10+- tolerance you would assume the character is stuck.

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
  •