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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Quad, M_D), 1,217 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
Page 2 of 2 1 2
Re: 2 paths interferring? [Re: ] #456236
11/15/15 20:26
11/15/15 20:26

M
Malice
Unregistered
Malice
Unregistered
M



LOL--- It's your c_scan -monster see the player and sets pathSetNum back to 1 then calls path_setter()

Re: 2 paths interferring? [Re: ] #456238
11/15/15 20:34
11/15/15 20:34

M
Malice
Unregistered
Malice
Unregistered
M



Also this path_Set() should not be there

Code:
if((my.z >= 47) && (my.z <= 49)) // once on bottom of 
         //    tower, monster faces and runs toward player
      {
         path_set(my,NULL);



My quote from days ago
Quote:

LOL are you detaching when you reach node 2 by calling path_set(my,NULL);
to many times?

Last edited by Malice; 11/15/15 20:37.
Re: 2 paths interferring? [Re: ] #456241
11/15/15 20:38
11/15/15 20:38

M
Malice
Unregistered
Malice
Unregistered
M



Anyways - I'm getting burned out on this topic. Once again it would have just been easier for my to rewrite the whole code on day of the post.

Mal

Re: 2 paths interferring? [Re: ] #456256
11/16/15 08:00
11/16/15 08:00
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Wow, the code is improving, but acting awfully strange.

So, when the game starts, the monster is standing 30 feet up in the air on the spiral staircase, and if the player walks toward the monster on the bottom ground of the tower to where the monster detects the player by c_scan(), the monster will run down path_001 to the bottom of the tower. The monster will then turn and face the player, and run toward the player. If the player dodges the monster and runs past it, and then runs up the stairs, the monster will run toward node 4 on the bottom of the spiral staircase, but then stop there while jittering between nodes 3 and 4.

At this time, the player has run up the spiral staircase a little ways, turns around, and is looking down at the monster on the tower floor, jittering like it does. While the player looks at the monster, the monster is not moving past node 4. However, when the player walks off the side of the spiral staircase and lands on the tower floor 30 feet below, the monster starts running up the spiral staircase on path_001 PERFECTLY with no jittering!

This is the code that is making this happen:

Code:
action path_setter()
{
   VECTOR vec_next_node;

   path_set(my,"path_001");
	
   if(pathSetNum == 1)
   {
      my.NODE_NEXT=path_nextnode(my,1,1); // SET THE NODE
   }

   if(pathSetNum == 2)
   {	
      my.NODE_NEXT=4; // SET THE NODE
   }

   while(1)
   {
      // PATH NODE DETECTION AND FACING //////////////////////////////////
		
      if(vec_dist(my.x,vec_next_node.x) < 80) 
      {    
         if(pathSetNum == 1) 
         {
            my.NODE_NEXT=path_nextnode(my,my.NODE_NEXT,1); // Grab Next node on 
         }
	 
         if(pathSetNum == 2) 
	 {
	    my.NODE_NEXT-=1; 
               
            if(my.NODE_NEXT < 1)
            {
               my.NODE_NEXT = 1;	
	    }
         }
      }
		
      path_getnode(my,my.NODE_NEXT,vec_next_node,NULL);  
         
      vec_to_angle(my.pan,vec_diff(NULL,vec_next_node,my.x));
         // face the new node

      DEBUG_VAR(my.NODE_NEXT,450);
      DEBUG_VAR(pathSetNum,500);
		
      wait(1);
   }
}

action monster_action() 
{
   ...

   pathSetNum = 1;

   ...
	
   while (1)
   { 
      ...
	   
      if(my.STATE == 1) 
      {	
         my.ANIMATION += 3*time_step;
			
         ent_animate(me,"idle",my.ANIMATION,ANM_CYCLE);	
		
         c_scan(my.x,my.pan,vector(360,0,750),SCAN_ENTS | SCAN_FLAG2 | 
            IGNORE_ME);
			
	 if (you) // player detected?
	 {  
	    path_setter(); // MONSTER RUNS DOWN path_001 SINCE pathSetNum = 1
					
	    ...

	    my.STATE = 2; 
	    
            ...
	 }				
      }
	
      // state 2: turn towards enemy, cast spells /////////////////// 
      if (my.STATE == 2) 
      {				
         if((hero.z > 50) && (hero.z > my.z)) // IF PLAYER IS HIGHER THAN 
                                              //    MONSTER ON STAIRS
	 {
	    pathSetNum = 2;
				
	    my.NODE_NEXT = 4;
	 }

         if((my.z >= 47) && (my.z <= 49))
	 {
	    vec_set(temp.x, player.x);
            vec_sub(temp.x, my.x);
            vec_to_angle(my.pan, temp); // rotate the enemy towards the player
	 }
			
         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);
   }
}



I tried taking this code out:

Code:
if((my.z >= 47) && (my.z <= 49))
{
   vec_set(temp.x, player.x);
   vec_sub(temp.x, my.x);
   vec_to_angle(my.pan, temp); // rotate the enemy towards the player
}



...thinking it might have been somehow interfering, but the same result happened even after commenting it out.

It is crazy trying to debug this, but fun at the same time. :-)

Re: 2 paths interferring? [Re: Ruben] #456257
11/16/15 08:35
11/16/15 08:35

M
Malice
Unregistered
Malice
Unregistered
M



only one part is left that is influenced by the player location
Code:
if((hero.z > 50) && (hero.z > my.z)) // IF PLAYER IS HIGHER THAN 
                                              //    MONSTER ON STAIRS
	 {
	    pathSetNum = 2;
				
	    my.NODE_NEXT = 4;
	 }


This rest to node 4 very time the player is ABOVE the mosnster... Can't believe I didn't see it before

Just do this
Code:
if((hero.z > 50) && (hero.z > my.z)) // IF PLAYER IS HIGHER THAN 
                                              //    MONSTER ON STAIRS
	 {
	    pathSetNum = 2;
				
	   // my.NODE_NEXT = 4;
	 }


and this ...

Code:
action path_setter()
{
proc_kill2(path_setter,my);
   VECTOR vec_next_node;

   path_set(my,"path_001");
	
   if(pathSetNum == 1)
   {
      my.NODE_NEXT=path_nextnode(my,1,1); // SET THE NODE
   }

   if(pathSetNum == 2)
   {	
      my.NODE_NEXT=4; // SET THE NODE
   }

   while(1)
   {
      // PATH NODE DETECTION AND FACING //////////////////////////////////
		
      if(vec_dist(my.x,vec_next_node.x) < 80) 
      {    
         if(pathSetNum == 1) 
         {
            my.NODE_NEXT=path_nextnode(my,my.NODE_NEXT,1); // Grab Next node on 
         }
	 
         if(pathSetNum == 2) 
	 {
	    my.NODE_NEXT-=1; 
               
            if(my.NODE_NEXT < 1)
            {
               my.NODE_NEXT = 1;	
	    }
         }
      }
		
      path_getnode(my,my.NODE_NEXT,vec_next_node,NULL);  
         
      vec_to_angle(my.pan,vec_diff(NULL,vec_next_node,my.x));
         // face the new node

      DEBUG_VAR(my.NODE_NEXT,450);
      DEBUG_VAR(pathSetNum,500);
		
      wait(1);
   }
}


EDIT --- REALY REALLY need sleep. Have fun man.
lol... I need sleep
Mal

Last edited by Malice; 11/16/15 08:45.
Re: 2 paths interferring? [Re: ] #456258
11/16/15 08:47
11/16/15 08:47
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Only problem with that, is that now the monster is skipping nodes 4 and/or 3, and running straight in the air towards node 2 again.

Re: 2 paths interferring? [Re: Ruben] #456260
11/16/15 09:13
11/16/15 09:13
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
So, for some reason, this code does not do what it is supposed to do as it is being executed:

Code:
if((hero.z > 50) && (hero.z > my.z)) // IF PLAYER IS HIGHER THAN 
                                              //    MONSTER ON STAIRs
{
   beep();

   pathSetNum = 2;
				
   my.NODE_NEXT = 4; // WITHOUT THIS HERE, THE MONSTER SKIPS NODES 4 AND/OR 3,
                     //    AND RUNS STRAIGHT TO NODE 2 THROUGH THE AIR.
}


When the player is above the monster on the z axis by being higher up on the spiral staircase, it is beeping like crazy. However, the monster does not move beyond node 4, and jitters between nodes 3 and 4. When the player walks off the side of the spiral staircase, the beeping stops, but then the monster starts walking up path_001 like its supposed to.

It is strange how the above code does not execute while it is happening, but executes after it happened.

Last edited by Ruben; 11/16/15 09:14.
Re: 2 paths interferring? [Re: Ruben] #456263
11/16/15 10:57
11/16/15 10:57

M
Malice
Unregistered
Malice
Unregistered
M



Every time you hear the beep you also RESET my.NODE_NEXT back to 4 even though the function ran past 4 and has set it to 3 ...

Will do a lock/check with a new var.

Code:
action monster_action() 
{
var set_once =0; // Attention <-NEW VAR
   ...

   pathSetNum = 1;

   ...
	
   while (1)
   { 
      ...
	   
      if(my.STATE == 1) 
      {	
         my.ANIMATION += 3*time_step;
			
         ent_animate(me,"idle",my.ANIMATION,ANM_CYCLE);	
		
         c_scan(my.x,my.pan,vector(360,0,750),SCAN_ENTS | SCAN_FLAG2 | 
            IGNORE_ME);
			
	 if (you) // player detected?
	 {  
	    path_setter(); // MONSTER RUNS DOWN path_001 SINCE pathSetNum = 1
					
	    ...

	    my.STATE = 2; 
	    
            ...
	 }				
      }
	
      // state 2: turn towards enemy, cast spells /////////////////// 
      if (my.STATE == 2) 
      {				
         if((hero.z > 50) && (hero.z > my.z)) // IF PLAYER IS HIGHER THAN 
                                              //    MONSTER ON STAIRS
	 {
	    pathSetNum = 2;
		if(!set_once)
           {		
	    my.NODE_NEXT = 4;
            set_once=1;
           }
	 }

         if((my.z >= 47) && (my.z <= 49))
	 {
	    vec_set(temp.x, player.x);
            vec_sub(temp.x, my.x);
            vec_to_angle(my.pan, temp); // rotate the enemy towards the player
	 }
			
         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);
   }
}


Re: 2 paths interferring? [Re: ] #456270
11/16/15 12:29
11/16/15 12:29
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Cool! That worked. Now I need to play with this system to make it behave in the artificially intelligent way that it needs to. Thank you so much Malice. This is big for me.

By the way, I sent you a PM. :-)

Page 2 of 2 1 2

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