Hi Chesso,

In terms of getting your enemies to follow a predefined path, then you need to come up with a way of defining the path... do you have a level editor?

If it really isn't any more complex than that and you have a tile based map, you could do something like this...

Code:
POSITION AT START OF PATH

WHILE ENEMYALIVE DO

  CASE ENEMYSTATE OF

    MOVINGNORTH :
      ENEMYY:=ENEMYY-1;
    END

    MOVINGSOUTH :
      ENEMYY:=ENEMYY+1;
    END

    MOVINGEAST :
      ENEMYX:=ENEMYX+1;
    END

    MOVINGWEST :
      ENEMYX:=ENEMYX-1;
    END
    
  ENDCASE

  STEPS:=STEPS-1;

  IF STEPS=0 THEN
    GETNEXTENEMYMOVE(ENEMYSTATE,STEPS);
  ENDIF

ENDWHILE
Thats a real simple idea... GETNEXTENEMYMOVE returns the new enemy state and the number of times it has to go through the state machine, but I'm sure you get the idea.

If you want to do something a little more complex then you would need to add states to the state machine and provide the necessary control mechanisms to read paths from your level data and switch states as necessary.

So... heres a zip file containing the code I put together for the first few stages of the 2006 PGD competition. Its not great and its probably nothing like what you want to achieve, but it may give you some ideas.

unitOREEnemyClasses.zip

For anyone else that may be about to comment on this code ;-) I don't want any comments about the quality or optimisation of it because I know its not particularly good :-P It was the first enemy AI for our competition entry and I've posted it only to give Chesso some ideas.

fState.pathfinder was a link to my A* path finding implementation. This was a seperate thread with three path finding job queues. Low, Medium and High. When an element of the engine wanted a path, it would submit a request to pathFinder along with a callback... pathfinder would get to work on a first come first served priority basis... when it was done, it would run the callback and provide a list of moves to the 'client' that requested the path.

The code is clunky, its not great and it certainly doesn't implement everything I wanted to do, but it did provide enemies that would wander around the map (going only where they could go without going through objects).... if they spotted you, they would pursue you until they lost you for a period and then they would just start roaming again.

To use it, I can't remember how it was setup... I think you created an instance of the object... positioned it and then called doMove to do all the processing for that enemy. As I say, it wasn't great, but it may help you get some ideas.