OMG, I just decided to check out the AI for NPC, and I have never bothered to look it up before. It's just crazy, it literaly decides the direction by a random number when it has a target to follow. The random number then decides what direction the NPC should start checking. For example, lets say that Int(Rnd * 5) returns the value 1, then the NPC will move right first (if now the player is located to the right side of the enemy. If not, the check Left. If not left, then check right, and after that it checks up. So there is actually nothing that checks were the NPC should go right away with a simple function that returns the locations to move to. It just checks over and over again.
To see the AI, go here:
http://www.key2heaven.net/ms/downloads/ ... eneral.txt
And search for: i = Int(Rnd * 5)
I will for sure make changes here, doesn't have the time now since Im in school. But this is easy to upgrade, therefore it should be done.
For example, it could be done like this.
To use it:
Code:
= Function(y, x, Target)
Code:
Function(Map, Npc, Target)
'now we know what 'Map' the Npc is on, what 'Npc' number it has. And what it's target are.
End Function
And in that function there can be a equation to find it's best way to track down the player. The CanNpcMove sub is fine, it's just the way the enemy wants to move thats wrong. No random things should be used, because the NPC should know were he want to go.
This guide for the A Algorithm might be interesting to some, I havn't read it all, but it might be something usefull:
http://www.policyalmanac.org/games/aStarTutorial.htm