I am trying to have my game program tell me the vector distance between the player and a giant enemy scorpion model using this code:

Code:
DEBUG_VAR(scorpionPlyrDist, 100);
...
scorpionPlyrDist = vec_dist (hero.x, my.x);



I have it working for other enemy models, but strangely it is not working for the giant scorpion model.

Here is my code to try and make this happen:

Code:
action scorpion_action()
{
   my.eflags |= FAT | NARROW;

   ...

   demo_scorpion = me;
	
   my.push = 10;
	
   ...

   set(my, POLYGON);

   my.status = scorpion_unaware;

   while (my.status != scorpion_dead) 
   {
      DEBUG_VAR(scorpionPlyrDist, 100); // scorpionPlyrDist
         //    IS ALWAYS EQUALING 0, INSTEAD OF CHANGING AS 
         //    THE PLAYER MOVES CLOSER TO THE GIANT SCORPION.

      ...

      while(1) // I DO NOT KNOW WHY I NEED THIS EXTRA LOOP TO 
               //    MAKE THIS ANIMATION HAPPEN.  I DO NOT 
               //    NEED THIS EXTRA LOOP TO MAKE THIS 
               //    ANIMATION WORK FOR OTHER MODELS.
      {
         my.ANIMATION += 2*time_step;	  
         ent_animate(me,"stand",my.ANIMATION,ANM_CYCLE);
         
         wait(1);
      }

      if(scrpn_health <= 0)
      {
         my.status = scorpion_dead;
      }
	
      scorpionPlyrDist = vec_dist (hero.x, my.x); // FOR SOME
         //    REASON, scorpionPlyrDist IS ALWAYS EQUALING 0,
         //    ACCORDING TO THE DEBUG_VAR UP ABOVE, NO MATTER 
         //    HOW CLOSE THE PLAYER GETS TO THE GIANT SCORPION.
   	
      c_scan(my.x,my.pan,vector(360,0,750),SCAN_ENTS | 
         SCAN_FLAG2 | IGNORE_ME);

      if(you)
      {	
         // SCORPION DETECTING PLAYER CODE.
         ...
			
         wait (1);
      }
  
      my.tilt = 0;
	
      if(my.status == scorpion_dead)
      {
         // SCORPION DYING CODE
         ...	
      }
      
      set (my, PASSABLE); // allow the player to pass through 
                          //    the corpse now
}


I used this method for a goblin entity I have, and it is working for the goblin, but not for the scorpion, strangely.

(1) Anyone know why scorpionPlyrDist is always equaling 0, and not showing the vector distance in real time between the giant scorpion and the player? Even if I get rid the while(1) loop, I get the same result.

(2) Does anyone also know why I need the while(1) loop within the while(my.status != scorpion_dead) loop to make the "stand" animation for the scorpion work? I did not need the while(1) loop in a separate goblin code to make it work for the goblin.


Last edited by Ruben; 01/24/17 11:44.