Jump to content

NPC pathfinding algorithm


Camaro

Recommended Posts

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!

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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)

  • Heart 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...