Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
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
1 registered members (AndrewAMD), 559 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
getting bone name hit by c_trace with USE_BOX #470293
01/07/18 15:12
01/07/18 15:12
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Howdy,

I am trying to detect which limb gets hit on an attack (that uses c_trace with USE_BOX). The USE_BOX prevents that c_trace sets hit.vertex or hit.x, and so I cannot use ent_bonename since I am missing the vertex number and also the position of impact to get the vertex number (ent_nextvertex).

So what I a good alternative to get the closest vertex number on impact that is reasonable fast?
I have been thinking of either cycling through all the vertices of the entity that gets hit but that is a bit to slow I think (the entity is high poly) or perhaps use a 2nd c_trace without USE_BOX, which would be faster I guess(?). Or is there perhaps a better option?

Re: getting bone name hit by c_trace with USE_BOX [Re: Reconnoiter] #470298
01/07/18 17:09
01/07/18 17:09
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Set scan_texture flag in c_trace.

If u have old data in hit vertex u dont want to overwrite u could store hit.x in my.skill's for example

Also u could setup hit groups in med and check which group was hit bei c_trace. Superku once made an example of hit detection.

Last edited by rayp; 01/07/18 17:12.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: getting bone name hit by c_trace with USE_BOX [Re: rayp] #470300
01/07/18 17:58
01/07/18 17:58
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Hi, Scantexture does not work with usebox i think.

Re: getting bone name hit by c_trace with USE_BOX [Re: Reconnoiter] #470302
01/07/18 19:37
01/07/18 19:37
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Just tryed. With the following code i receive a bone handle...have to mention i did not check whats in the handle laugh

Code:
#define health skill100

void test_trace(){
   draw_text ("active", 10,10, vector(255,0,0));
   var sight = 300;                                                         // i can see this far
   VECTOR tpos;
   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);
   if (HIT_TARGET){
      if (you) if (ent_bonename (you, NULL, hit.vertex)) draw_text ("Bone handle returned", 10, 20, vector (255,0,0));
      draw_point3d (target.x,vector(50,50,255),100,3);
   }
}

action hero{
        my.health = 100;
        my.group  =   1;
	...
	..
	.
	while (my.health > 0){
		test_trace();
                ...
                ..
                .
		wait (1);
	}
	.
	..
	...
}


The traced model has POLYGON flag set.


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: getting bone name hit by c_trace with USE_BOX [Re: rayp] #470319
01/08/18 13:07
01/08/18 13:07
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Ty for fast reply. Well the problem is that it returns the same bone name when hitting different parts/bones (polygon hulls), the manual also states that usebox is mutually exclusive with scantexture. I really need usebox though, since the entities have some thin shapes etc otherwise attacking would be to annoying.

Edit- I noticed that hit.x is actually updated, but the vertex number not. And "var vertex_num = ent_nextvertex(you, hit.x);" works only for terrains it seems. So I just need to find an effective way of finding the closest vertex to the hit.x ...

Last edited by Reconnoiter; 01/08/18 14:27.
Re: getting bone name hit by c_trace with USE_BOX [Re: Reconnoiter] #470332
01/08/18 17:09
01/08/18 17:09
Joined: Jul 2014
Posts: 72
D
DriftWood Offline
Junior Member
DriftWood  Offline
Junior Member
D

Joined: Jul 2014
Posts: 72
The solution is like Superku first hitbox design. He attached many invisible boxes to the model. You can make the boxes thicker on your thin body parts. When shooting you ignore the bbox of the entity and use these hitboxes.
It can be found in an old AUM.
Furthermore, you can use the poly of the entity and only add these hitboxes for the thin parts of the entity body.

Re: getting bone name hit by c_trace with USE_BOX [Re: DriftWood] #470335
01/08/18 20:26
01/08/18 20:26
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Thanks for the recommendation but I advise against using that old multiple boxes approach.
You could use a very low poly character for collision only but with the same bones/ skeleton. When you call your hitscan weapon code copy the animation to the invisible low poly mesh, call c_updatehull (?) and c_trace without USE_BOX.
I once wrote the following anim copy function, could be optimized probably:

Code:
void ent_anim_copy(ENTITY* eTarget, ENTITY* eSource)
{
	int i,numBones,hparent;
	ANGLE angle,angle2,angle3,eSourcePanInv;

	numBones = ent_bones(eSource);
	ent_bonereset_all(eTarget);
	ang_diff(&eSourcePanInv,nullvector,&(eSource->pan));
	for(i = 0; i < numBones; i++)
	{
		ang_for_bone(&angle,eSource,i+1); // use bone handles/ indices instead of names
		ang_add(&angle,&eSourcePanInv);
		hparent = ent_boneparent(eSource,NULL,i+1);
		if(hparent > 0)
		{
			ang_for_bone(&angle2,eSource,hparent); // eTarget's bone is already rotated by parent bone's rotation => undo it!
			ang_add(&angle2,&eSourcePanInv);
			ang_diff(&angle3,nullvector,&angle2); // best way to do this? I doubt it.
			ang_add(&angle,&angle3);
		}
		ent_bonerotate(eTarget,i+1,&angle);
	}
}



"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: getting bone name hit by c_trace with USE_BOX [Re: Superku] #470374
01/10/18 17:37
01/10/18 17:37
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Its like always. Everytime you need a workaround or something isnt working like it should. The attempt with bonename sounded pretty good for me.

Edit
I once simply checked height of hit to decide if leg body or head was hit to use three different anims. Of course this weak system visually cant compare to hit detection with ragdoll but it was easy fast and looked pretty cool

Last edited by rayp; 01/10/18 17:41.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: getting bone name hit by c_trace with USE_BOX [Re: Reconnoiter] #470375
01/10/18 17:42
01/10/18 17:42
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Originally Posted By: Reconnoiter
Scantexture does not work with usebox i think.
Hey

It works for me pretty well!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: getting bone name hit by c_trace with USE_BOX [Re: Superku] #470392
01/11/18 13:05
01/11/18 13:05
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Thanks for you all replying.

Originally Posted By: Superku
Thanks for the recommendation but I advise against using that old multiple boxes approach.
You could use a very low poly character for collision only but with the same bones/ skeleton. When you call your hitscan weapon code copy the animation to the invisible low poly mesh, call c_updatehull (?) and c_trace without USE_BOX.
I once wrote the following anim copy function, could be optimized probably:

Code:
void ent_anim_copy(ENTITY* eTarget, ENTITY* eSource)
{
	int i,numBones,hparent;
	ANGLE angle,angle2,angle3,eSourcePanInv;

	numBones = ent_bones(eSource);
	ent_bonereset_all(eTarget);
	ang_diff(&eSourcePanInv,nullvector,&(eSource->pan));
	for(i = 0; i < numBones; i++)
	{
		ang_for_bone(&angle,eSource,i+1); // use bone handles/ indices instead of names
		ang_add(&angle,&eSourcePanInv);
		hparent = ent_boneparent(eSource,NULL,i+1);
		if(hparent > 0)
		{
			ang_for_bone(&angle2,eSource,hparent); // eTarget's bone is already rotated by parent bone's rotation => undo it!
			ang_add(&angle2,&eSourcePanInv);
			ang_diff(&angle3,nullvector,&angle2); // best way to do this? I doubt it.
			ang_add(&angle,&angle3);
		}
		ent_bonerotate(eTarget,i+1,&angle);
	}
}

, interesting idea, will have to think a bit about this one (in combination with painting gore / decals etc that I currently use on my current trace).

Originally Posted By: 3run
Originally Posted By: Reconnoiter
Scantexture does not work with usebox i think.
Hey

It works for me pretty well!

, for me it definitely doesn't work, it keeps returning the same bonename regardless of where the target entity is hit.

Originally Posted By: rayp
Edit
I once simply checked height of hit to decide if leg body or head was hit to use three different anims. Of course this weak system visually cant compare to hit detection with ragdoll but it was easy fast and looked pretty cool
, tnx I thought of something similar and I think it could work pretty decently as a lite limb detection system. :-)

Originally Posted By: DriftWood
The solution is like Superku first hitbox design. He attached many invisible boxes to the model. You can make the boxes thicker on your thin body parts. When shooting you ignore the bbox of the entity and use these hitboxes.
It can be found in an old AUM.
Furthermore, you can use the poly of the entity and only add these hitboxes for the thin parts of the entity body.
, tnx but this would become a bit complicated in my case since I have quite a bit of different models (and of various shapes). In the latter case of adding boxes to the models, I tried this earlier but it gives some problems with painting gore / decals etc on the target entities.

Page 1 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