I am trying to make it so that if the player hits a certain section of an NPC, like say the head, something will happen. Otherwise, nothing will happen. I know that cTrace can be used to detect whether the player hits the NPC model anywhere on its body. Is there a way to specify this for only one specific body part of the NPC, like say, the head, rather than the whole body?

For example, if I want to detect whether the player hits a sword on the model, this is what I have done so far:

Code:
action NPC_action()
{
   ...

   me = npcPerson;

   my.ENEMY_CODE = 7;

   ...

   while(1)
   {
      ...

      sword_ctrace();

      ...
  
      wait(1);
   }

   ...
}

void NPC_Create()
{
   npcPerson = ent_create("npcModel.mdl", vector(-64,146,-111),
      NPC_action );
   ...
}	

action sword_ctrace()
{
   var tip_sword;
   var hilt_sword;
	
   ...
	
   vec_for_vertex (tip_sword, sword, 54);
   vec_for_vertex (hilt_sword, sword, 50);
	
   ...
	
   if (c_trace (tip_sword, hilt_sword, IGNORE_ME | IGNORE_PASSABLE) >
       0)
   {
      ...

      if(you.ENEMY_CODE == 7) // Detects entire NPC model, but not 
                              //    specific body part like head.
      {
         NPC_health -= sword_damage * time_step;
      }
		
      ...	
}



Does anyone know how I can have the sword only detect the head of the NPC, or any other specific bodypart like the arm or leg, rather than the whole body?

Last edited by Ruben; 12/25/17 16:03.