Results 1 to 6 of 6

Thread: [oglib] Help determining if model has moved

  1. #1
    Join Date
    Jan 2007
    Location
    Not here
    Posts
    1,604
    Mentioned
    2 Post(s)
    Quoted
    19 Post(s)

    Default [oglib] Help determining if model has moved

    Sorry in advance for my horrible code, I haven't done anything like this for many years!

    I'm creating a basic Barbarian fishing spot script using oglib and am trying to detect when the fishing spot has moved. An easy way would be just have it click the nearest fishing spot every x seconds but that's boring.

    My problem is with the isVisible(); function and I think I'm using it incorrectly. When I load a model into a model array and output the index of the model array that I want (i.e. one fishing spot) then it outputs: {ID = 111111, TID = 222222, X = 123123, Y = 456456}. I assumed if I used isVisible() on this exact index of the model array it would return false if the model wasn't present at the above coordinates just outputted. It would appear I've got that wrong though, as it will return true as long as there is a model with the same ID in the area, is there a way to do this or another function to use?

    code so far:

    Simba Code:
    var
      fishingSpot: glModelArray;
      closestTemp : glModelArray;
      clientCenter := ogl.getClientMidPoint();

    begin
        fishingSpot := ogl.getModels(2252653705); //load all fishing spots in area to array
        closestTemp := clientCenter.closest(fishingSpot); //array to temporarily store the last closest fishing spot this stays out of the loop  

          repeat
            fishingSpot := ogl.getModels(2252653705); //reload fishing spots again in the loop to get current locations
            if closestTemp[0].isVisible() then //the line that's causing issues. I want it to give a false value if the spot has moved, this always continues to return true though. Wrong function?
            begin
              //this chunk works, clientCenter.closest updates when the closest spot changes. ClosestTemp[0] continues to return the old closest
              writeln(clientCenter.closest(fishingSpot)[0], 'closest spot output');
              writeln(closestTemp[0], 'closest temp output');
              wait(5000);
            end
            else
            begin
              writeln('Spot moved');
              writeln(clientCenter.closest(fishingSpot)[0], 'closest spot output');
              writeln(closestTemp[0], 'closest temp output');
              mouse.move(clientCenter.closest(fishingSpot)[0].randomizePointEllipse(16));
              exit;
              wait(20000);
            end
           until false;

    I hope I haven't explained that as horribly as I think I have, any help is much appreciated!
    Last edited by rkroxpunk; 11-17-2015 at 02:01 PM.
    Sleeping...

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    I dont use oglib, but if i have to determine if my current fishing spot is gone, there's 2 ways:
    1.
    wait till character stop moving/gained xp (i.e. coordinate of current fishing spot will no longer change), then store the (x,y) coordinate of the current spot.
    then keep grabbing the model at the area [x,y,x,y] and check if it's empty

    2.
    keep grabbing the models and storing the difference between player position and the coordinate of the nearest model (which should be the one u clicked).
    then once the new (x,y) is greater than the old (x,y) (can give the difference a bit of 'tolerance') you know the spot is gone.

    If you want to determine whether your player is still fishing or has stopped, that's another story (;
    Last edited by riwu; 11-17-2015 at 11:50 AM.

  3. #3
    Join Date
    Jan 2007
    Location
    Not here
    Posts
    1,604
    Mentioned
    2 Post(s)
    Quoted
    19 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    I dont use oglib, but if i have to determine if my current fishing spot is gone, there's 2 ways:
    1.
    wait till character stop moving/gained xp (i.e. coordinate of current fishing spot will no longer change), then store the (x,y) coordinate of the current spot.
    then keep grabbing the model at the area [x,y,x,y] and check if it's empty

    2.
    keep grabbing the models and storing the difference between player position and the coordinate of the nearest model (which should be the one u clicked).
    then once the new (x,y) is greater than the old (x,y) (can give the difference a bit of 'tolerance') you know the spot is gone.

    If you want to determine whether your player is still fishing or has stopped, that's another story (;
    Thanks for the response. Everything you've explained particularly in number two is exactly what I'm trying to do it's just a matter of not knowing the correct oglib function to do it with. I've stored the model and it's coordinates to an array and then I also have another array that updates with the new closest fishing spot co-ordinates straight away. I guess I could use an AND statement to determine if the x and y matches, I was hoping there would just be a function that can tell me if the model is not present at OldX and OldY though
    Sleeping...

  4. #4
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Default

    Why are you detecting when it has moved? Your character model changes when you're fishing, so just utilize that. It's what I do in all of my OGL scripts.

  5. #5
    Join Date
    Jun 2012
    Posts
    586
    Mentioned
    112 Post(s)
    Quoted
    296 Post(s)

    Default

    What Ross said.

    Get your player model standing still, not doing anything. Watch for that. If that ID exists, you've stopped.

    However, sometimes you stop for a split second before starting again. So, I'd watch for your player's model ID. If any are found, keep checking over another ~1-2 seconds. If it disappears, you're still fishing. If it still exists at the end of that 1-2 seconds, the spot has moved.

    Good luck! PM or message me on Skype if you need help or advice.




    Skype: obscuritySRL@outlook.com

  6. #6
    Join Date
    Jan 2007
    Location
    Not here
    Posts
    1,604
    Mentioned
    2 Post(s)
    Quoted
    19 Post(s)

    Default

    Oh wow I had no idea that makes it a lot easier. Cheers!
    Sleeping...

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
  •