Camaro Posted June 26, 2019 Share Posted June 26, 2019 Hi all, I'm going to implement a method in my script to determine the closest position that would act as a safespot from a monster I am attacking. I don't want to simply define a few that would always work as there may be a closer, more optimal spot. Now before I spend hours attacking monsters from different angles, does anyone know/have the NPC pathfinding algorithm when it is trying to interact with a player? Thanks! Quote Link to comment Share on other sites More sharing options...
DylanSRT Posted June 26, 2019 Share Posted June 26, 2019 You could test out different approaches with two accounts by having one stand still and following it from different positions with the other. Things get way more complicated when both you and the NPC are moving at the same time though. I'm not sure what you mean by a more optimal spot, a safespot is a safespot at the end of the day. It's better to just predefine the spot which is most consistent and secure. Otherwise you'll constantly be moving around and it will just be less efficient overall. Quote Link to comment Share on other sites More sharing options...
Hybris Posted June 26, 2019 Share Posted June 26, 2019 What Dylan said, it's probably best to have a couple predefined safespots & then just move to the closest to your player. As for the "NPC pathfinding algorithm" (not sure what you mean by that), look at this: https://osbot.org/api/org/osbot/rs07/api/model/Character.html & NPC in the API Quote Link to comment Share on other sites More sharing options...
Imthabawse Posted June 26, 2019 Share Posted June 26, 2019 Make safe spot Area's and have your bot run to them after attacking the NPC. Quote Link to comment Share on other sites More sharing options...
Czar Posted June 26, 2019 Share Posted June 26, 2019 Using the Map, and Region API you can achieve this, however npc safespotting isn't fully covered by paths, sometimes you need to take into account gates/walls and objects that accept projectiles above them, unless you are in an area with none of that stuff Quote Link to comment Share on other sites More sharing options...
FrostBug Posted July 4, 2019 Share Posted July 4, 2019 Enemy NPCs don't "pathfind" per se. When in combat, they simply translate directly towards the target position. I assume that you only deal with melee enemies I find that the easiest way to do a reliable check, is to perform a simulation on what would happen if you attacked the enemy from the tested position. For such a simulation, each step would perform following checks: - Is the currently simulated position equal to the target (in this case the player's) position; if so, this is not a safespot - Is the player able to attack the currently simulated position? (Requires: Player range distance, region clipping graph & projectile masks); if so, this is a possible safespot - Is the next position towards the target blocked in both directions? (Requires: Region clipping graph, Checking positions of other NPCs) 1 Quote Link to comment Share on other sites More sharing options...