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
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (degenerate_762, AndrewAMD), 877 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
cTrace on specific section of model? #470113
12/25/17 04:14
12/25/17 04:14
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
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.
Re: cTrace on specific section of model? [Re: Ruben] #470116
12/25/17 17:16
12/25/17 17:16
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Try c_trace with SCAN_TEXTURE, then use hit.vertex as the vertex argument for ent_bonename.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: cTrace on specific section of model? [Re: Superku] #470130
12/28/17 05:02
12/28/17 05:02
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Thank you Superku! Your advice seems to be working. When I used ent_bonename along with hit.vertex and beep(), the c_trace is beeping when the player makes contact with the vertice areas controlled by a certain bone that I specify in the code. So, this should open the door for me to fulfill specific body part functionality, such as armor resistance at different body locations. Thank you again! :-D


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