Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (ozgur, Quad), 880 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
vec_dist #464128
01/24/17 11:33
01/24/17 11:33
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
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.
Re: vec_dist [Re: Ruben] #464135
01/24/17 16:59
01/24/17 16:59
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Hi,

Some parts of your code are confusing which is probably why you have some bugs in it. First of, what is 'my.status'? A defined skill? Something like my.STATE would be more clearer I think.
Also remove the 2nd while, and place the animation code in the first while. Because now only code in your 2nd while is running every frame. Now you mention that than the anim code is not running properly in the 1st while, my quess this is because either you have some 'break;' that breaks the while loop OR 'my.status' is not equal to 'scorpion_dead' and so the 1st while stops running.
So debug both my.status and scorpion_dead every frame and see what happens with them.
Also there is no wait(1); for the 1st loop.

Re: vec_dist [Re: Reconnoiter] #464146
01/25/17 06:41
01/25/17 06:41
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Sadly, I apologize. I did not quite accurately record the code the way my program was completely in my original post. There was actually a "wait(1)" in my first while loop. I ended up fixing it so that the scorpion initiates the "stand" animation by setting its health over 0 in the "main" file. Because I never set it over 0 in the main file, scrpn_health kept equaling 0, and never initiating the "while (my.status != scorpion_dead)" code, since my.status was equal to scorpion_dead.

Re: vec_dist [Re: Ruben] #464148
01/25/17 09:56
01/25/17 09:56
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
What I do in these circumstances is placing error("<fitting description>"); over the place and see which error(); triggers and which not. laugh


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1