Page 4 of 7 FirstFirst ... 23456 ... LastLast
Results 76 to 100 of 152

Thread: [OSR] Walking & positioning system

  1. #76
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by honeyhoney View Post
    Cheers. Totally aware of that issue I just didn't put 2 and 2 together.

    Edit: I'm not actually sure that is the issue. Take a look:

    Simba Code:
    st := GetTimeRunning() + 60;
    if Assigned(@self.onMoveEvent) then
      self.onMoveEvent(@self, pos);
       
    Wait( Min(1, st-GetTimeRunning()));

    Scenario:
    GetTimeRunning() is 1000ms
    st is therefore set to 1060ms
    the onMoveEvent takes 200ms
    GetTimeRunning() is now 1200ms
    st - GetTimeRunning() is equal to -140
    The minimum value of 1 or -140 is -140
    The script then executes Wait(-140) which results in an indefinite wait.

    It looks to me, irrespective of any overfolow issues, if the onMoveEvent takes longer than 60ms you're always going to end up waiting for an indefinite (negative) amount of time.
    Indeed. It should call Max(), no idea how I ended up using Min you can change that manually for now, i'll fix it with the next commit I make, and then update Releases.
    Last edited by slacky; 05-30-2016 at 08:04 PM.
    !No priv. messages please

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

    Default

    Quote Originally Posted by slacky View Post
    Indeed. It should call Max(), no idea how I ended up writing Min you can change that manually for now, i'll fix it with the next commit I make, and then update the Releases.
    Or do the subtraction in the right order (current - cached).

  3. #78
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by tls View Post
    Or do the subtraction in the right order (current - cached).
    No, the order is correct. The idea is simply that it should never wait longer than 60ms, if the peroson who hooked onMoveEvent also added a wait, or did a lot of processing (going beyond 60ms) then we should not wait more than 1ms.
    Currently it's only waiting 1ms (at best) for the normal cases, which is a big oops, and in the case of negative numbers it waits for A LONG time, because using Min :P

    Simba Code:
    start := GetTimeRunning() + 60;        // time plus 60ms
    <user inserts whatever code>           // takes unknown amount of time
    Wait( Max(1, start-GetTimeRunning())); // wait at most 60ms from when timer started, and at min 1ms.

    If I just changed the order of subtraction it would go negative for all the cases when onMoveEvent doesn't take up 60ms or more. That would really go to hell.
    Last edited by slacky; 05-30-2016 at 08:33 PM.
    !No priv. messages please

  4. #79
    Join Date
    Oct 2015
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Hey Slacky,

    i've been lurking on this for a while and u seem very knowledgable about opencv..
    Im making my own rs bot to learn how to code, and have been learning opencv this week.
    Ive managed to succesfully detect my minimap pos using matchtemplate, but have alot of difficulties finding things on the mainscreen specifically sand crabs, as there is too much rotation etc involved.
    Do you think this is doable with opencv?or should i just scan for pixel colors and do some sort of clustering based on that.
    Would love some input!

    thx

  5. #80
    Join Date
    Apr 2015
    Location
    Pittsburgh
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by edgy View Post
    Hey Slacky,

    i've been lurking on this for a while and u seem very knowledgable about opencv..
    Im making my own rs bot to learn how to code, and have been learning opencv this week.
    Ive managed to succesfully detect my minimap pos using matchtemplate, but have alot of difficulties finding things on the mainscreen specifically sand crabs, as there is too much rotation etc involved.
    Do you think this is doable with opencv?or should i just scan for pixel colors and do some sort of clustering based on that.
    Would love some input!

    thx
    Obviously I'm not slacky, but you may be able to find the sand crabs based on color separation. I haven't actually went and looked at the sand crabs yet, but if they are like the rock crabs they probably have darker shading around the bottom (and possibly one side) for the rounding of the model. I'd guess that that coloring is probably relatively unique compared to the rest of the sand in the area, so you may be able to locate them based on that.

    Basically, the color at the bottom of the sand crab, once converted from RGB color to HSV, will have a lower V than the surrounding sand since it's shaded darker. If you can find a good threshold, I would think you could probably find the crab.

    It may be a little bit tricky though, because the shading sometimes isn't very apparent at every compass angle and you'd have to ensure the area of shading is big enough to not detect little rounded sandy pebbles that I'm sure they probably placed on the beach. In my head this idea sounds reasonable, although I'm not 100% confident it would work well enough to be practical, but like I said, I'm not slacky and I haven't used opencv for a little while, so my opinion very well might not carry any weight.

    If you did want to try to find them based on color separation, this link may be a good place to look at for reference:
    http://opencv-srf.blogspot.ro/2010/0...eperation.html

    And even if it doesn't work out, never hurts to learn new things!

    Also, maybe I'm wrong, but it may be best to create a new thread if you wanted to have a discussion on this just so this thread doesn't get caught up in a discussion that isn't entirely on the topic of the original post.
    Last edited by Polar Xpress; 06-01-2016 at 07:36 PM.

  6. #81
    Join Date
    Oct 2015
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Thanks alot for the answer. ill go try it out now!
    And yeah ur right i should probably create my own thread..initially i just wanted to pm slacky but i am not allowed to pm yet .

  7. #82
    Join Date
    Jun 2016
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    This is very cool, great you share the code! Much respect!

  8. #83
    Join Date
    Aug 2016
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    This is amazing!

    I just have one problem that I can't seem to fix or figure out why. I have two areas, a dark/underground area and a light green area in a custom map. When I run my script for 4h+, they'll be a point where .getMyPos will return a pos that is completely off and cause my bot to die. For example, if I am in the underground area, it will say I am in the above ground area.

    - The map is large and takes in account fort the non-walkable area.

    - I've also set minmatch to around 0.8 and logged for incorrect positions.

    I'm still unable to figure out what's wrong? Any idea? Thanks!

  9. #84
    Join Date
    Sep 2014
    Location
    C:\Simba\
    Posts
    565
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default

    Does your map include the underground area? it might cause some bad matches due to the border between normal level and underground
    Feel free to ask me any questions, I will do my best to answer them!

    Previously known as YouPee.

  10. #85
    Join Date
    Aug 2016
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Joopi View Post
    Does your map include the underground area? it might cause some bad matches due to the border between normal level and underground
    Yeah the custom map includes both areas. I put a large black space/border between the normal level and underground in the map. Still no luck.

  11. #86
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Hi all,

    I am trying to get this working on a script, but every time I run the script, I get this error:
    Simba Code:
    Error: Exception ('TRSPosFinder.UpdateAddr: Unable to locate bitmap') at line 231

    I have tried using the Walker include that is built into Aerolib and downloading the walker from this thread, both with the same result.

    Any ideas on what could be triggering it?

    Sample map below:

    Simba Code:
    program WalkerExample;
    {$DEFINE WALKER}
    {$i AeroLib/AeroLib.Simba}


    procedure w_ClickMouse(box:TBox; btn:Int32); override;
    begin
      MouseBox(box, btn); //call a click-mousefunction from the include you use
    end;

    var
      RSW:TRSWalker;
      path:TPointArray;

    begin
      initAL;
      RSW.Init('WorldMap');
      WriteLn('RSW is setup!');
      WriteLn(RSW._GetPos());
      RSW.Free();

    end.

    I also tried pasting the example script from the first post into Simba with the same result.

  12. #87
    Join Date
    Sep 2014
    Location
    C:\Simba\
    Posts
    565
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default

    Are you on linux, or any other OS than windows?
    I don't think memoryscanning will work on any of those, atleast not yet.

    Also try loading "YourMapName.png" instead of "YourMapName"
    Feel free to ask me any questions, I will do my best to answer them!

    Previously known as YouPee.

  13. #88
    Join Date
    Mar 2013
    Posts
    1,010
    Mentioned
    35 Post(s)
    Quoted
    620 Post(s)

    Default

    Stop using _GetPos and check what PID rswalker is targeting.
    Edit: and make sure you selected the client since you're not using SMART
    Last edited by Harrier; 12-21-2016 at 01:28 PM.
    #slack4admin2016
    <slacky> I will build a wall
    <slacky> I will ban reflection and OGL hooking until we know what the hell is going on

  14. #89
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Quote Originally Posted by Joopi View Post
    Are you on linux, or any other OS than windows?
    I don't think memoryscanning will work on any of those, atleast not yet.

    Also try loading "YourMapName.png" instead of "YourMapName"
    Tried WorldMap and WorldMap.png on both the Aerolib and stand alone include with the same result.

    I am running Windows 7 64bit.

    Quote Originally Posted by Harrier View Post
    Stop using _GetPos and check what PID rswalker is targeting.
    Edit: and make sure you selected the client since you're not using SMART
    I was actually using GetMyPos() with the same result. The script up there is the last attempt, and I thought I would try something else.

    I have also ensured the client is selected in all of my tests.

    Could external factors have something to do with this?
    I am running it from my office at work, but the network has network blocks to certain websites. Example: I can load up OSBuddy, but I cannot access any world menu (in login screen or ingame).

  15. #90
    Join Date
    Mar 2013
    Posts
    1,010
    Mentioned
    35 Post(s)
    Quoted
    620 Post(s)

    Default

    Quote Originally Posted by Dan the man View Post
    Tried WorldMap and WorldMap.png on both the Aerolib and stand alone include with the same result.

    I am running Windows 7 64bit.



    I was actually using GetMyPos() with the same result. The script up there is the last attempt, and I thought I would try something else.

    I have also ensured the client is selected in all of my tests.

    Could external factors have something to do with this?
    I am running it from my office at work, but the network has network blocks to certain websites. Example: I can load up OSBuddy, but I cannot access any world menu (in login screen or ingame).
    Stop using OSBuddy and use the official client, OSBuddy eats ram so it takes too long for rswalker to find the map bitmap (or disable memory reading).
    #slack4admin2016
    <slacky> I will build a wall
    <slacky> I will ban reflection and OGL hooking until we know what the hell is going on

  16. #91
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Quote Originally Posted by Harrier View Post
    Stop using OSBuddy and use the official client, OSBuddy eats ram so it takes too long for rswalker to find the map bitmap (or disable memory reading).
    Firewall at work blocks any pages on the Runescape domain; know of any alternative download links? I'll give it a try on official client.

    Cheers.

  17. #92
    Join Date
    Apr 2007
    Posts
    373
    Mentioned
    2 Post(s)
    Quoted
    24 Post(s)

    Default

    I get this error after a while:
    Error while reading stream: Unable to open file.

    Is this because i use the script twice at the same time?
    ~Fre

  18. #93
    Join Date
    Mar 2013
    Posts
    1,010
    Mentioned
    35 Post(s)
    Quoted
    620 Post(s)

    Default

    Quote Originally Posted by fre View Post
    I get this error after a while:
    Error while reading stream: Unable to open file.

    Is this because i use the script twice at the same time?
    Are you constantly loading and freeing RSWalker? Otherwise RSWalker should only load a file once when it starts.
    #slack4admin2016
    <slacky> I will build a wall
    <slacky> I will ban reflection and OGL hooking until we know what the hell is going on

  19. #94
    Join Date
    Apr 2007
    Posts
    373
    Mentioned
    2 Post(s)
    Quoted
    24 Post(s)

    Default

    Quote Originally Posted by Harrier View Post
    Are you constantly loading and freeing RSWalker? Otherwise RSWalker should only load a file once when it starts.
    Yes i am loading and freeing RSWalker. Because i use different regions and floors.

    This error popped up.

    Error: Exception ('TRSPosFinder.UpdateAddr: Unable to locate bitmap') at line 231
    refers to this line
    Simba Code:
    RaiseException(erException, 'TRSPosFinder.UpdateAddr: Unable to locate bitmap');
    ~Fre

  20. #95
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by fre View Post
    Yes i am loading and freeing RSWalker. Because i use different regions and floors.
    Just don't do that. Create several instances of RSW instead.
    I believe the issue comes from Simba trying to load the map in both your scripts at the exact same time.

    Just have two walkers (or more) in your script, create the walkers you need only once, and free them only once.
    !No priv. messages please

  21. #96
    Join Date
    Apr 2007
    Posts
    373
    Mentioned
    2 Post(s)
    Quoted
    24 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    Just don't do that. Create several instances of RSW instead.
    I believe the issue comes from Simba trying to load the map in both your scripts at the exact same time.

    Just have two walkers (or more) in your script, create the walkers you need only once, and free them only once.
    I use one procedure for map walking.
    So i should create multiple TRSWalker instances for each map/region i use AND each script?
    ~Fre

  22. #97
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by fre View Post
    I use one procedure for map walking.
    So i should create multiple TRSWalker instances for each map/region i use AND each script?
    First, I assume you have two or more maps, since you talk about "regions". So yeah, 1 RSW instance per map you load. Setup both walkers in the initialization part of your script, store the variables globally, so that you can use it anywhere in your script..

    A prototype example (written on the go):
    Simba Code:
    var
      WalkUG, Walk: TRSWalker;

    procedure OnTerminate();
    begin
      WriteLn('Script terminated');
      WalkUG.Free();
      Walk.Free();
    end;

    procedure DoStuffUnderground();
    begin
      ** do stuff **
      WalkUG.WalkPath([Point(123, 123), Point(111, 111)]);
    end;

    procedure DoStuffElsewhere();
    begin
      ** do stuff **
      Walk.WalkPath([Point(333, 333), Point(366, 366)]);
    end;

    procedure InitWalkers();
    begin
      Walk.Init('world.png');
      Walk.walkStyle := wsSPS;
      Walk.anyAngle  := True;

      WalkUG.Init('underground.png');
      WalkUG.walkStyle := wsSPS;
      WalkUG.anyAngle  := True;

      AddOnTerminate('OnTerminate');
    end;

    begin
      InitWalkers();
      repeat
        ** do stuff **
        DoStuffUnderground();
        DoStuffElsewhere();
      end;
    end.
    Last edited by slacky; 12-31-2016 at 01:29 AM.
    !No priv. messages please

  23. #98
    Join Date
    Apr 2007
    Posts
    373
    Mentioned
    2 Post(s)
    Quoted
    24 Post(s)

    Default

    So, i took your advice.
    I made multiple RSW instances and defined them globally.
    Works so far.
    Thx for the help.
    Last edited by fre; 01-01-2017 at 09:41 PM.
    ~Fre

  24. #99
    Join Date
    Apr 2007
    Posts
    373
    Mentioned
    2 Post(s)
    Quoted
    24 Post(s)

    Default

    So walking to paths works if the minimap is the same as the one i used to make my maps.
    I noticed jagex has 2 or 3 versions of the world map with few pixels difference.

    So when my player is walking a path and cannot get it's location i want to save the piece of the map.
    Then i can add this piece to my collection

    Simba Code:
    if not Result then
      begin
        Debug('Failed to walk path, setting compas north.');
        setCompass('n');
        Inc(Loop);

        //self.blindWalk(Path[0]);
        if Loop > 1 then
        begin
          //While 1 = 1 do
          Debug('Failed to walk path again, taking snap of memory map.');
          finder.Init(w_GetClientPID());
          finder.GetLocalPos();
          bmp := CreateBitmap(1,1);
          DrawMatrixBitmap(bmp, finder.localMap);
          CropBitmap(bmp, 52,52, 511-52,511-52);
          //ShowBitmap(bmp);
          Wait(100);
          //action := WaitKey([VK_RETURN,VK_BACK], 1500);
          //if (Action = VK_RETURN) then
          begin
            SaveBitmap(bmp,FILEPATH+PREFIX+ToStr(i)+'.png');
            WriteLn('Saved '+FILEPATH+PREFIX+ToStr(i)+'.png');
            inc(i);
          end;
          FreeBitmap(bmp);
          //WS_switchWorlds(randomWorld(Players[currentPlayer].Member));
        end;
        GoTo Start;
      end;

    i get this error

    Error: TMemScan.Init -> The parameter is incorrect.
    at line 159
    Last edited by fre; 01-16-2017 at 11:05 PM.
    ~Fre

  25. #100
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Hey Slacky I've got a question for you: have you compiled this with the newest version of Simba? If so, what have you changed? I'm having errors (Variable expected) particularly at this line in Base.pas:
    Simba Code:
    LibCV.MatchTemplate(large, sub, self.matchAlgo);
    Or any time referring to LibCV. I figure this is just an issue with Lape in the most recent Simba but I've tried everything I can think of to no avail. Do you have any suggestions to point me in the right direction?

    Edit:
    I've made progress and have it working now for the most part through a bit of sloppy modification. However I believe I have a memory leak somewhere as over time while the walker is in use Simba accumulates memory. And after X amount of times ran and stopped the map file cannot be loaded, as if it's still in use, AKA something is not being freed. I'll continue how I can but as I said before, my knowledge with Lape is quite limited.
    Last edited by Flight; 01-21-2017 at 05:33 PM.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


Page 4 of 7 FirstFirst ... 23456 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •