Nazeradom 0 Share Posted May 23, 2016 Hi I am quite new to scripting for Dreambot but I have a strong professional programming background. Something I noticed while creating a Motherload script was using getGameObjects().closest() could sometimes give you a game object which is technically closest but behind a wall or inaccessible. I noticed the pathfinding classses and was wondering if anyone had used them in conjunction with game objects to find the closest game object as far as pathfinding is concerned. I tried using the getGameObjects.all() function and looping through, performing pathfinding, but I found it clunky and slow and also all(<ID>) returns way too many of the object to be useful. TL;DRI need to find the closest game object as far as pathfinding is concerned and not just simply radius to the player. Thanks in advance for any help. Link to comment Share on other sites More sharing options...
Soldtodie 76 Share Posted May 23, 2016 Idk which method you used but you can use Map#canReach or you can wrote youre own method for that. Link to comment Share on other sites More sharing options...
Before 96 Share Posted May 23, 2016 Idk which method you used but you can use Map#canReach or you can wrote youre own method for that. I've heard other scripters talk about this but I've never found it. WHERE IS THIS METHOD HIDING!?? Link to comment Share on other sites More sharing options...
Nazeradom 0 Author Share Posted May 23, 2016 Idk which method you used but you can use Map#canReach or you can wrote youre own method for that. But if I can figure out which ones I can reach and which ones I can't, how do I then know which one is closest? Edit: I guess I could then loop through the reachable ones and find the closest one. But it could be reachable, have the shortest distance but still not be closest as far as time it takes the player to get to it. Link to comment Share on other sites More sharing options...
Soldtodie 76 Share Posted May 23, 2016 You can check how many obstacles are on the path and choose the one with the lowest amount. Or you could calculate it. 1 obstacle = 4 tiles for example Link to comment Share on other sites More sharing options...
Volta 183 Share Posted May 24, 2016 I've heard other scripters talk about this but I've never found it. WHERE IS THIS METHOD HIDING!?? Map# Map class. Link to comment Share on other sites More sharing options...
Cardozz 46 Share Posted May 24, 2016 closest just filters through a list of gameopbjects that are not null. So in your case as you describe it, i'd think it works like this: It gets all objects that are not null, then it filters the objects based on distance by using getLocalPlayer().distance(getGameObjects().closest()) something like that. It doesn't really take care of paths or if it is reachable. Correct me if i'm wrong, because i have no idea how the method was written. Link to comment Share on other sites More sharing options...
Pandemic 2798 Share Posted May 24, 2016 Our closest method uses the normal distance formula, the actual walking distance is not used (pathfinding on every object is very, very resource intensive). Link to comment Share on other sites More sharing options...
Nazeradom 0 Author Share Posted May 25, 2016 I think I am going to get the closest 5 objects and run pathfinding on them to figure out which one is actually closest, this seems to be the best way based on the feedback. If I am unlucky enough that all 5 are behind a wall then tough luck I guess. Thanks everyone. Link to comment Share on other sites More sharing options...
Cardozz 46 Share Posted May 25, 2016 I think I am going to get the closest 5 objects and run pathfinding on them to figure out which one is actually closest, this seems to be the best way based on the feedback. If I am unlucky enough that all 5 are behind a wall then tough luck I guess. Thanks everyone. You can also write it so that it will filter through the objects and only return the ones that actually have a walkpath that isn't null. Use the Filter class for this (basically what you want) Would you mind telling us what objects are blocked by the wall(s)? maybe we've got some better ideas Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.