mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-24 13:55:36 +03:00
Added extra param to is_in_viewcone to switch between a 2D and 3D calculation
Neither is still as accurate as I want them to be though :\
This commit is contained in:
parent
90f11b52bc
commit
39d5ea94fb
@ -798,31 +798,42 @@ static cell AMX_NATIVE_CALL in_view_cone(AMX *amx, cell *params)
|
|||||||
|
|
||||||
CHECK_ENTITY(src);
|
CHECK_ENTITY(src);
|
||||||
|
|
||||||
Vector vecLOS;
|
edict_t *pEdictSrc = INDEXENT(src);
|
||||||
|
|
||||||
|
Vector vecLOS, vecForward;
|
||||||
float flDot;
|
float flDot;
|
||||||
|
|
||||||
edict_t *pEdictSrc = INDEXENT(src);
|
|
||||||
cell *addr = MF_GetAmxAddr(amx, params[2]);
|
cell *addr = MF_GetAmxAddr(amx, params[2]);
|
||||||
float vecOrigin[3];
|
Vector origin(amx_ctof(addr[0]), amx_ctof(addr[1]), amx_ctof(addr[2]));
|
||||||
|
|
||||||
vecOrigin[0] = amx_ctof(addr[0]);
|
bool use2D = (params[0] / sizeof(cell)) == 2 || params[3] == 0;
|
||||||
vecOrigin[1] = amx_ctof(addr[1]);
|
|
||||||
vecOrigin[2] = amx_ctof(addr[2]);
|
|
||||||
|
|
||||||
Vector origin(vecOrigin[0], vecOrigin[1], vecOrigin[2]);
|
if (use2D)
|
||||||
|
{
|
||||||
|
MAKE_VECTORS(pEdictSrc->v.angles);
|
||||||
|
vecForward = gpGlobals->v_forward;
|
||||||
|
|
||||||
MAKE_VECTORS(pEdictSrc->v.v_angle);
|
vecLOS = origin - pEdictSrc->v.origin;
|
||||||
|
|
||||||
|
vecForward.z = 0;
|
||||||
|
vecLOS.z = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MAKE_VECTORS(pEdictSrc->v.v_angle);
|
||||||
|
vecForward = gpGlobals->v_forward;
|
||||||
|
|
||||||
|
vecLOS = origin - (pEdictSrc->v.origin + pEdictSrc->v.view_ofs);
|
||||||
|
}
|
||||||
|
|
||||||
vecLOS = origin - (pEdictSrc->v.origin + pEdictSrc->v.view_ofs);
|
|
||||||
vecLOS = vecLOS.Normalize();
|
vecLOS = vecLOS.Normalize();
|
||||||
|
|
||||||
flDot = DotProduct(vecLOS, gpGlobals->v_forward);
|
flDot = DotProduct(vecLOS, vecForward);
|
||||||
|
|
||||||
if (flDot >= cos(pEdictSrc->v.fov * (M_PI / 360)))
|
if (flDot >= cos(pEdictSrc->v.fov * (M_PI / 360)))
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL traceresult(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL traceresult(AMX *amx, cell *params)
|
||||||
|
@ -226,8 +226,10 @@ forward pfn_spawn(entid);
|
|||||||
*/
|
*/
|
||||||
native find_sphere_class(aroundent, _lookforclassname[], Float:radius, entlist[], maxents, Float:origin[3] = {0.0, 0.0, 0.0});
|
native find_sphere_class(aroundent, _lookforclassname[], Float:radius, entlist[], maxents, Float:origin[3] = {0.0, 0.0, 0.0});
|
||||||
|
|
||||||
//SDK function - checks if an origin is in an entity's view cone
|
/* SDK function - checks if an origin is in an entity's view cone
|
||||||
native is_in_viewcone(entity, Float:origin[3]);
|
* Set use3d to 1 to do the calculation in 3D. Otherwise it will be in 2D.
|
||||||
|
*/
|
||||||
|
native is_in_viewcone(entity, Float:origin[3], use3d = 0);
|
||||||
|
|
||||||
//SDK function - checks if an entity is visible to an entity
|
//SDK function - checks if an entity is visible to an entity
|
||||||
native is_visible(entity, target);
|
native is_visible(entity, target);
|
||||||
|
Loading…
Reference in New Issue
Block a user