Raised This Month: $51 Target: $400
 12% 

Get origin of player's hitboxes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Day
Member
Join Date: Jan 2006
Location: Ukraine
Old 06-25-2009 , 03:48   Get origin of player's hitboxes
Reply With Quote #1

How to get origin of each hitbox of a player?

I can get the origin of player's vector using entity_get_vector(ent, EV_VEC_origin, entOrigin) function. Is there any way to get the origin of player's legs/hands for example?

Any suggestions are wellcome.
Thks in advance.
__________________
Sith Lord Darth Day
Day is offline
Send a message via ICQ to Day
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-25-2009 , 04:10   Re: Get origin of player's hitboxes
Reply With Quote #2

You can use EngFunc_GetBonePosition ( see fakemeta_cons.inc ) and to know the bone number just do "Dump Model Info" with Half-Life Model Viewer.
__________________
Arkshine is offline
Day
Member
Join Date: Jan 2006
Location: Ukraine
Old 06-25-2009 , 04:41   Re: Get origin of player's hitboxes
Reply With Quote #3

Thank you, will try and revert.
__________________
Sith Lord Darth Day
Day is offline
Send a message via ICQ to Day
Day
Member
Join Date: Jan 2006
Location: Ukraine
Old 06-25-2009 , 07:05   Re: Get origin of player's hitboxes
Reply With Quote #4

Tyvm, i works well, but is there any other way to do it? This func is a bit CPU consuming...
__________________
Sith Lord Darth Day
Day is offline
Send a message via ICQ to Day
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-25-2009 , 07:27   Re: Get origin of player's hitboxes
Reply With Quote #5

How is a bit CPU consuming ? It should be retrieve information already loaded into memory.
__________________
Arkshine is offline
Day
Member
Join Date: Jan 2006
Location: Ukraine
Old 06-25-2009 , 07:47   Re: Get origin of player's hitboxes
Reply With Quote #6

Well maybe it's other func using my CPU...

How to write trace_line(-1, userOrigin, entOrigin, hitOrigin) function using FakeMeta instead of Engine? and will it give me any advantage?
__________________
Sith Lord Darth Day
Day is offline
Send a message via ICQ to Day
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-25-2009 , 08:09   Re: Get origin of player's hitboxes
Reply With Quote #7

Here the code source for TraceLine ( engine ) :

Code:
static cell AMX_NATIVE_CALL trace_line(AMX *amx, cell *params) {     int iEnt = params[1];     cell *cStart = MF_GetAmxAddr(amx, params[2]);     cell *cEnd = MF_GetAmxAddr(amx, params[3]);     REAL fStartX = amx_ctof(cStart[0]);     REAL fStartY = amx_ctof(cStart[1]);     REAL fStartZ = amx_ctof(cStart[2]);     REAL fEndX = amx_ctof(cEnd[0]);     REAL fEndY = amx_ctof(cEnd[1]);     REAL fEndZ = amx_ctof(cEnd[2]);     cell *vRet = MF_GetAmxAddr(amx, params[4]);     Vector vStart = Vector(fStartX, fStartY, fStartZ);     Vector vEnd = Vector(fEndX, fEndY, fEndZ);     TraceResult tr;     if (iEnt == -1)         TRACE_LINE(vStart, vEnd, ignore_monsters, NULL, &tr);     else         TRACE_LINE(vStart, vEnd, dont_ignore_monsters, INDEXENT2(iEnt), &tr);     edict_t *pHit = tr.pHit;     vRet[0] = amx_ftoc(tr.vecEndPos.x);     vRet[1] = amx_ftoc(tr.vecEndPos.y);     vRet[2] = amx_ftoc(tr.vecEndPos.z);     if (FNullEnt(pHit))         return 0;     return ENTINDEX(pHit); }

Quote:
Hit = trace_line(-1, userOrigin, entOrigin, hitOrigin)
When -1, it means IgnoreEnt will be null. This native returns the entity index if it hits something (TR_pHit ) and it passes by reference the hit origin. ( TR_vecEndPos ).

In fakemeta it would be : engfunc( EngFunc_TraceLine, vStart, vEnd, IGNORE_MONSTERS, 0, tr);

But it doesn't return TR_pHit nor TR_vecEndPos, you have to do using get_tr2().

If you use an index for IgnoreEnt, in fakemeta it would be : engfunc( EngFunc_TraceLine, vStart, vEnd, DONT_IGNORE_MONSTERS, iEnt, tr);


Depending what you need, you have to use engine or fakemeta. For example if you want to use IGNORE_MONSTERS with a valid IgnoreEnt, you can't. If you don't need the end pos and hit, use fakemeta. If you want to use IGNORE_GLASS you can't etc. The engine version is more specific. The fakemeta version you have an access to all the params of TRACE_LINE() function. ( engine use TRACE_LINE() too ). EngFunc_TraceLine is a direct link to the HL1 engine function TRACE_LINE(), there are no addition like in the engine function. That's why you can do more things with EngFunc_TraceLine. If you reproduce the engine function to fakemeta, it will be more efficient to use engine. Not sure if I explain well. :p
__________________

Last edited by Arkshine; 06-25-2009 at 08:18.
Arkshine is offline
Day
Member
Join Date: Jan 2006
Location: Ukraine
Old 06-25-2009 , 08:18   Re: Get origin of player's hitboxes
Reply With Quote #8

Wow, thks for such detailed explanation! But how do you think which way will take less CPU engine (trace_line) or fakemata(engfunc+get_tr2)?
__________________
Sith Lord Darth Day
Day is offline
Send a message via ICQ to Day
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-25-2009 , 08:25   Re: Get origin of player's hitboxes
Reply With Quote #9

The less natives calls you have ( amxx plugin -> module ) = the less cpu consuming it will be.

eg: You want to retrieve the hit and the hit origin.

Using engine :

Code:
new Float:Start[3]; new Float:End[3]; new Float:EndPos[3]; new Hit; [...] Hit = trace_line( -1, Start, End, EndPos );

Using fakemeta :

Code:
new Float:Start[3]; new Float:End[3]; new Float:EndPos[3]; new Hit; [...] engfunc( EngFunc_TraceLine, Start, End, DONT_IGNORE_MONSTERS, Ent, 0 ); Hit = get_tr2( 0, TR_pHit ); get_tr2( 0, TR_vecEndPos, EndPos );

Engine, you need one call, Fakemeta 3.
It's possible to see the difference using the profiler by sawce. But here the difference would not be really significant.
__________________

Last edited by Arkshine; 06-25-2009 at 08:29.
Arkshine is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-25-2009 , 08:42   Re: Get origin of player's hitboxes
Reply With Quote #10

Just profiled :

Code:
type |  	name | calls | time / min / max
-------------------------------------------------------------------
   f | TraceEngine   | 10000 | 0.038086 / 0.000003 / 0.002073
   f | TraceFakemeta | 10000 | 0.082984 / 0.000006 / 0.005594
0 natives, 0 public callbacks, 2 function calls were not executed.
Like you see engine is ~x2 faster than fakemeta doing the same job.
__________________
Arkshine is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:37.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode