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
__________________