A6 enemy attack issue, help please...

Posted By: Blink

A6 enemy attack issue, help please... - 09/04/09 23:25

ok, so i have an enemy that attacks. it comes in close to attack, but after it attacks, it "hops" backward a bit. any idea why? it does it everytime it attacks.

thanks in advance,Blink.

Code:
action abigail
{
     
        enemy_events();
        g3_handle_radar();
   	  var move_dist[3];	
   	  var distance;
   	  my.enable_entity = on;
   	  my.enable_impact = on; 
   	  my.albedo=0;
        my.ambient=100;
        my.unlit=on;
        my.bright=on;
   	  my.enable_scan = on;
   	  my.polygon = on;
   	  my.enable_block=on;
   	  my.transparent = on;   	  
   	  my.enable_shoot = on; 
   	  my.health = 10;     
   	  my.event = enemy_events;
   	  vec_set (temp, my.x);
        temp.z -= 1;

        my.skill11 = c_trace(my.x,temp,IGNORE_ME|IGNORE_PASSABLE); 
        my.z = my.skill11+0;
   	  
               	
   	  c_setminmax(my);	
   	  wait(1);	
   	  
   	  while(plBiped01_entity == null)	{ wait(1); }		
   	  
   	  while(my.health > 0)	
   	  {
   	     		 distance = vec_dist(my.x, plBiped01_entity.x);				
   	     		 
   	     		 if(distance < 1000)	// the player approaches the enemy		
   	     		 {	
   	     		 		   vec_set(temp, plBiped01_entity.x);			
   	     		 		   vec_sub(temp, my.x);			
   	     		 		   vec_to_angle(my.pan, temp);			
   	     		 		   my.tilt = 0;						
   	     		 		   
   	     		 		      	     		 		   
   	     		 		   move_dist.x = 5 * time_step;			
   	     		 		   move_dist.y = 0;			
   	     		 		   move_dist.z = 0;			
   	     		 		   c_move(my,move_dist,nullvector,IGNORE_ME|IGNORE_PASSABLE|IGNORE_MAPS);		 		   
   	     		 		   ent_animate(my, "walk", my.skill19, ANM_CYCLE);		// play run frames animation			
   	     		 		   my.skill19 = cycle(my.skill19+48*time_step,0,101);	// "run" animation speed + loop animation						
   	     		 		   ent_playsound (my, ghostwalk, 100);
   	     		         
   	     		 		   if(distance < 150)		// if the player comes closer than 50 quants attack him			
   	     		 		   {				
   	     		 		           my.skill23 = 0; // reset "attack" frames								
   	     		 		           
   	     		 		           while(my.skill23 < 100)				
   	     		 		           {					
   	     		 		                   c_trace (my.x,temp,IGNORE_ME|IGNORE_PASSABLE|IGNORE_MODELS|IGNORE_SPRITES|SCAN_TEXTURE); 
   	     		 		                  
   	     		                         
   	     		                            	     		                         									
   	     		                         create_explosions();
   	     		                         ent_animate(my,"attack",my.skill23,ANM_CYCLE);	// play attack frames animation					
   	     		                         my.skill23 += 20 * time_step;	// "attack" animation speed
   	     		                         you = plBiped01_entity;
   	     		                         you._armor__003 -= 1 * time_step;
   	     		                         
   	     		                         wave_handle = snd_play(wave, 100, 0);
   	     		                         snd_stop(wave); 
   	     		                         wait(1);
   	     		                         if(you._armor__003 < 0)
			                                        {
			                                      	 you._health__003 += you._armor__003;
				                                     you._armor__003 = 0;
				                                     PlBiped_Damage_Reaction();	// display damage panel
			                                         }			
   	     		                 }								
   	     		                 
   	     		                 wait(6);			
   	     		          }
   	     		        }		
   	     		        else	// the player is farther than 200 quants away		
   	     		        {			
   	     		               ent_animate(my,"stand",my.skill21,ANM_CYCLE);		// play stand frames animation			
   	     		               my.skill21 = cycle(my.skill21+2*time_step,0,101);	// "stand" animation speed + loop animation		
   	     		               
   	     		        }				
   	     		        
   	     		        wait(1);	
   	     		}		
   	     		
   	     		// enemy was killed:	
   	     		while(my.skill22 < 90)	
   	     		{
   	     		   	  ent_animate(me,"death", my.skill22, ANM_CYCLE); // play death frames animation		
   	     		   	  my.skill22 += 16 * time_step; // "death" animation speed				
   	     		   	  
   	     		   	  wait(1);
   	     		   	  
   	     		}		
   	     		
   	     		my.passable = on; // the corpse can't be hit by the sword from now on
   	     		
	while (my.alpha > 0)
	{
		my.alpha -= 0.3 * time_step;
		wait (1);
	}
	ent_playsound (my, die, 100);
	ent_remove (me);
	
}	
	
}


Posted By: Dillinger

Re: A6 enemy attack issue, help please... - 09/05/09 16:37

can't say why, but you could maybe fix it by setting a flag2 on the victim and then while in attack mode IGNORE_YOU | IGNORE_FLAG2
Posted By: Blink

Re: A6 enemy attack issue, help please... - 09/05/09 18:48

sorry, i dont quite get what you suggest.
Posted By: alibaba

Re: A6 enemy attack issue, help please... - 09/05/09 19:59

maybe in the create_explosions(); function are no passable entitys.
Posted By: Blink

Re: A6 enemy attack issue, help please... - 09/06/09 03:57

well, i moved the create_explosions(); out of the while and the enemy doesnt jump anymore, but now when the enemy attacks, it gets stuck on the player while attacking and i cant move. any suggestions?
Posted By: testDummy

Re: A6 enemy attack issue, help please... - 09/06/09 04:51

entanglement: Maybe, set my.polygon = OFF for moving actors?
Posted By: alibaba

Re: A6 enemy attack issue, help please... - 09/06/09 08:30

i think its because the enemy moves and attcks at the same time.
you the enemy moves into the players hull and gets stucked. because of this you have to set the attack code in a while loop or disable the walking while attacking.
Posted By: Blink

Re: A6 enemy attack issue, help please... - 09/06/09 19:28

i tried, my polygon=off and no change, but when i increase the distance when to attack, the enemy stops short and injures the player with an attack. i guess i will have to live with it, because i dont want the player to get stuck.
Posted By: Dillinger

Re: A6 enemy attack issue, help please... - 09/07/09 15:23

I was giving some more thought to your question.
Could it be that in your attack animation the attacker translates forward?
Because you're using collision detection and the engine takes care of that re: entity translation. However, if your attacker animation translates forward in addition to the engine's attempts to compensate it's translation coordinates, your attacker will step into the collision zone. Since two solid entities can't overlap, the engine bumps back the translation to compensate. You could redo the animation so the character's center always remains about the same and take care of any forward translation using code instead.
Press F11 twice to show the collision zones and play your animation in slow motion. If it's an unfixable problem, you simply disable collision temporarily during those wonky frames.
Posted By: Blink

Re: A6 enemy attack issue, help please... - 09/07/09 19:01

i am not sure what the solution can be. i have tried several different ways to get this to work, but no results. my problem is, i have a good enemy code that works, using swords, and fists, and other hand held weapons, but when i change the code to use a projectile type weapon, i get issues. this weapon in particular is not a normal projectile either. i anticipate problems, trying to merge two codes.
© 2024 lite-C Forums