I have a spiral staircase inside a circular tower. When I move the player close enough to an enemy standing guard on a section of the spiral staircase (with the player being lower on the z axis than the enemy) using c_scan(), the enemy runs downs a path called "path_001" that runs down a certain way down the spiral staircase. If the player runs past the enemy and ends up being above the enemy on the spiral staircase (where the player is higher on the z axis than the enemy), I have a second path called "path_002" that the enemy is supposed to run up in order to catch up to the player, or at least to the end of the path.

The enemy runs down "path_001" just fine along all its four nodes when the player gets close enough to it. However, when the player runs above the enemy on the spiral staircase, and the enemy chases the player by moving up along "path_002", the enemy will get as far as the second node (out of four), and not get past the second node.

Here is my code for this:

Code:
...

action path_setter_1()
{
   ...

   path_set(my,"path_001"); // Move down spiral staircase

   ...
}

action path_setter_2()
{
   ...

   path_set(my,"path_002"); // Move up spiral staircase

   ...
}

action monster_code()
{
   ...

   while(1)
   {
      c_scan(my.x,my.pan,vector(360,0,750),SCAN_ENTS | SCAN_FLAG2 | IGNORE_ME);

      if(you)
      {
         ...

         path_setter_1(); // If player gets close enough, 
            //   monster runs down spiral staircase to get to
            //   player.

         ...

         if((hero.z > 50) && (hero.z > my.z))
         {
            path_setter_2(); // If player runs past monster,
               //    and gets above monster on spiral 
               //    staircase, monster chases player up
               //    spiral staircase.
         }

         c_move(my, vector(8 * time_step, 0, 0), nullvector, GLIDE);
         
         ent_animate(my, "run", anim_percentage, ANM_CYCLE);
         anim_percentage += 8 * time_step;

         ...
      }

      ...

      wait(1);
   }
}



If I debug to where the enemy starts out at the beginning of "path_002", and the player gets close enough to the enemy causing the enemy to only move up "path_002" (leaving the "path_001" call out), the enemy moves up along "path_002" just fine along all four nodes.

Basically "path_001" and "path_002" run along the same area, except "path_001" goes down the spiral staircase, and "path_002" goes up the spiral staircase.

Are "path_001" and "path_002" somehow interfering with each other? Has anyone else had this problem?

Is there a way to only use one path, and have the enemy simply reverse direction as needed on the same path?

Last edited by Ruben; 11/10/15 18:30.