Gamestudio Links
Zorro Links
Newest Posts
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, Aku_Aku, 1 invisible), 579 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
how to get the bonename from c_trace ? #474653
10/27/18 14:55
10/27/18 14:55
Joined: Oct 2018
Posts: 10
A
Anewbie Offline OP
Newbie
Anewbie  Offline OP
Newbie
A

Joined: Oct 2018
Posts: 10
I am trying to get the name of the limbs that are shot by the player in my game. I tried this by checking the old threads of this forum :

draw_text ("active", 10,10, vector(255,0,0));
var sight = 300;
VECTOR tpos;
STRING* bonename="empty";
vec_for_angle (tpos, vector (my.pan, my.tilt, my.roll));
vec_scale (tpos, sight);
vec_add (tpos, vector (my.x, my.y, my.z));
trace_mode = IGNORE_ME | IGNORE_PASSABLE | USE_BOX | SCAN_TEXTURE | IGNORE_SPRITES;
c_ignore (1, 0);
c_trace (vector (my.x, my.y, my.z), tpos, trace_mode);
draw_point3d (target.x,vector(50,50,255),100,3);
if(you && hit){

ent_bonename (you, bonename, hit.vertex);
draw_text (bonename, 10, 20, vector (255,0,0));

}


However it always shows the same bone name which is the left foot. I am using a non animated t-posing model for testing. I also would like to know how to check all the names of the bones of a model in MED.
Thanks!

Re: how to get the bonename from c_trace ? [Re: Anewbie] #474655
10/27/18 15:25
10/27/18 15:25
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Hi there!

a quote from the manual:
Quote:
For detecting which limb of an actor entity was hit, use the vertex number from the hit struct and retrieve the bone name with the ent_bonename function.

Take a look here:
c_trace
ent_bonename

Edit: gonna make an example, please wait


Edit2: please, take a look at this example (used guard model from my contribution):
Code:
#include <acknex.h>
#include <default.c>

#define PRAGMA_POINTER

void main(){
	
	warn_level = 6;
	fps_max = 60;
	
	level_load("");
	
	vec_set(&camera->x, vector(152, 0, 43));
	vec_set(&camera->pan, vector(180, -15, 0));
	
	def_move();
	
	ENTITY *guard_ent = ent_create("guard.mdl", nullvector, NULL);
	set(guard_ent, POLYGON);
	
	while(guard_ent){
		
		VECTOR temp;
		vec_set(&temp, vector(1024, 0, 0));
		vec_rotate(&temp, &camera->pan);
		vec_add(&temp, &camera->x);
		
		draw_point3d(&temp, COLOR_RED, 100, 4);
		
		c_trace(&camera->x, &temp, IGNORE_PASSABLE | SCAN_TEXTURE);
		
		if(trace_hit){
			
			draw_point3d(&hit->x, COLOR_RED, 100, 4);
			
			if(you){
				
				STRING *bone_name_str = "";
				ent_bonename(you, bone_name_str, hit->vertex);
				draw_text(bone_name_str, 10, 40, COLOR_WHITE);
				DEBUG_VAR(hit->vertex, 10);
				
			}
			
		}
		
		wait(1);
		
	}
	
}

It will display the bone, closest to the 'hit.x' position.


Edit3: if you want to check, which limb was hit (f.e. wanted to create hitboxes or such, to detect headshots etc), I would suggest you to use Superku's solution. You can find it in AUM 103, here. It's going to be faster.

Greets!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: how to get the bonename from c_trace ? [Re: 3run] #474656
10/27/18 15:46
10/27/18 15:46
Joined: Oct 2018
Posts: 10
A
Anewbie Offline OP
Newbie
Anewbie  Offline OP
Newbie
A

Joined: Oct 2018
Posts: 10
Originally Posted By: 3run
Hi there!

a quote from the manual:
Quote:
For detecting which limb of an actor entity was hit, use the vertex number from the hit struct and retrieve the bone name with the ent_bonename function.

Take a look here:
c_trace
ent_bonename

Edit: gonna make an example, please wait


Edit2: please, take a look at this example (used guard model from my contribution):
Code:
#include <acknex.h>
#include <default.c>

#define PRAGMA_POINTER

void main(){
	
	warn_level = 6;
	fps_max = 60;
	
	level_load("");
	
	vec_set(&camera->x, vector(152, 0, 43));
	vec_set(&camera->pan, vector(180, -15, 0));
	
	def_move();
	
	ENTITY *guard_ent = ent_create("guard.mdl", nullvector, NULL);
	set(guard_ent, POLYGON);
	
	while(guard_ent){
		
		VECTOR temp;
		vec_set(&temp, vector(1024, 0, 0));
		vec_rotate(&temp, &camera->pan);
		vec_add(&temp, &camera->x);
		
		draw_point3d(&temp, COLOR_RED, 100, 4);
		
		c_trace(&camera->x, &temp, IGNORE_PASSABLE | SCAN_TEXTURE);
		
		if(trace_hit){
			
			draw_point3d(&hit->x, COLOR_RED, 100, 4);
			
			if(you){
				
				STRING *bone_name_str = "";
				ent_bonename(you, bone_name_str, hit->vertex);
				draw_text(bone_name_str, 10, 40, COLOR_WHITE);
				DEBUG_VAR(hit->vertex, 10);
				
			}
			
		}
		
		wait(1);
		
	}
	
}

It will display the bone, closest to the 'hit.x' position.


Edit3: if you want to check, which limb was hit (f.e. wanted to create hitboxes or such, to detect headshots etc), I would suggest you to use Superku's solution. You can find it in AUM 103, here. It's going to be faster.

Greets!


Thanks a lot ! Turns out that i forgot to set the POLYGON flag. That is why it was always showing the same bone.

Re: how to get the bonename from c_trace ? [Re: Anewbie] #474657
10/27/18 16:00
10/27/18 16:00
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Glad to be helpful! laugh


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: how to get the bonename from c_trace ? [Re: 3run] #474660
10/28/18 10:42
10/28/18 10:42
Joined: Oct 2018
Posts: 10
A
Anewbie Offline OP
Newbie
Anewbie  Offline OP
Newbie
A

Joined: Oct 2018
Posts: 10
Hi again. So today I animated the entities and the animation seems to be working well. However it seems like the bones stay in the same place during the animation. For example when the target is running and I c_trace, it shows that the bones are still in the same place as if the target was still in T pose. So in order to hit the head, hand or something like that I have to aim for an invisible T - posing target rather than the animated one.
Any solutions for this ?

Re: how to get the bonename from c_trace ? [Re: Anewbie] #474663
10/28/18 14:44
10/28/18 14:44
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain

Re: how to get the bonename from c_trace ? [Re: txesmi] #474666
10/28/18 15:25
10/28/18 15:25
Joined: Oct 2018
Posts: 10
A
Anewbie Offline OP
Newbie
Anewbie  Offline OP
Newbie
A

Joined: Oct 2018
Posts: 10
Yes, it works ! Thank you so much .

Re: how to get the bonename from c_trace ? [Re: Anewbie] #474668
10/28/18 19:36
10/28/18 19:36
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Glad of been helpful


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