Jump to content
Purple Phantom

Smart Chasers

Recommended Posts

So, I have a game (commercial free) that involves a lot of things chasing the player character, one of which is a person. Now, with the normal chasers, I can survive with the "Approach" setting for the event. I can live with them getting stuck on walls. I mean, it makes sense for them. The human, however... He wouldn't get stuck on walls. I need a script that fixes it so the human chaser doesn't get stuck on walls. If there is one, already, please link me. :) Thank you in advance!

Share this post


Link to post
Share on other sites

If I understand what you want, I believe the solution for that will be having the chaser know what path he will follow before he starts moving. He would need to now the tiles where he can move and then find a path to the character. (I suppose the chasers you use just move towards the character without knowing what lies ahead and thats the reason for them getting stuck in walls)

 

So the solution lies in finding the shortest path (I supose you'll want the chasers to go directly to the character) from one point to another inside a graph. Unfortunately this is not an easy problem if you want to achieve this in a reasonable time like in this case. In fact, the easiest algorithm for this (wich is finding all possible paths and choose the shortest) can last even years before finding a solution in relative small chase areas. The most eficient algorithm I know of is called the "ant algorithm" (it's called like this because it simulates the behaviour of ant colonies when searching for food). This algorithm only gives an aproximate solution (close enough to the real one though) but on the other hand it's one of the fastest algorithms known.

 

Since the player is moving, the chaser will need to recalculate the path when the player changes position but I believe each new path can be obtained without much problem from the last one, and so the heavy algorithm will be only needed to run the first time the player enters the chase area.

 

I think I could implement the ant algorithm to this problem (or at least try to), however I'm afraid I don't know how much lag it will cause, but I'd bet/hope it won't be noticeable in small chase areas (let's say with less than 200 tiles, but I'm not sure).

 

Also I won't be able to code anything in a week, I'm afraid.

 

 

(It may be possible that I'm complicating the problem too much and there's an easier solution that I can't see at the moment)

Share this post


Link to post
Share on other sites

@Thaletos I was thinking more or less the same , you know you are askin for a pathfinding algorithm : a computer science problem that is still under study today ^^
But I remember a mouse script that implemented a basic pathfinding code that seem to work fine , it might be possible to copy it but I need to find wat script it was

Share this post


Link to post
Share on other sites

I tried to script this last year, but it was far from perfect.

It works on small map, but could be laggy in larger map

Also I don't really know how to integrate it with eventing so that it won't break anything

 

Video :

 

 

 

Script :

https://github.com/theoallen/RGSS3/blob/master/Pathfinding%20(ENG).rb

 

Any scripters who want to edit are welcomed

 

P.S: I thought it was A*, but then I guess it's more like hill-climbing algorhithm.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×