Merge pull request #70 from Arkshine/bug-6171

Add entity_intersects native (bug 6171)
This commit is contained in:
Vincent Herbet 2014-07-18 17:04:35 +02:00
commit a078064497
2 changed files with 35 additions and 0 deletions

View File

@ -1540,11 +1540,35 @@ static cell AMX_NATIVE_CALL set_ent_rendering(AMX *amx, cell *params) // set_use
return 1;
}
static cell AMX_NATIVE_CALL entity_intersects(AMX *amx, cell *params) // bool:entity_intersects(entity, other); = 2 arguments
{
// params[1] = entity
// params[2] = other
CHECK_ENTITY_SIMPLE(params[1]);
CHECK_ENTITY_SIMPLE(params[2]);
entvars_s *pevEntity = VARS(INDEXENT2(params[1]));
entvars_s *pevOther = VARS(INDEXENT2(params[2]));
if (pevOther->absmin.x > pevEntity->absmax.x ||
pevOther->absmin.y > pevEntity->absmax.y ||
pevOther->absmin.z > pevEntity->absmax.z ||
pevOther->absmax.x < pevEntity->absmin.x ||
pevOther->absmax.y < pevEntity->absmin.y ||
pevOther->absmax.z < pevEntity->absmin.z)
{
return 1;
}
return 0;
}
AMX_NATIVE_INFO ent_NewNatives[] =
{
{"DispatchKeyValue", DispatchKeyValue},
{"set_ent_rendering", set_ent_rendering},
{"entity_intersects", entity_intersects},
{NULL, NULL}
};

View File

@ -250,4 +250,15 @@ native trace_forward(const Float:start[3], const Float:angle[3], Float:give, ign
*/
native set_ent_rendering(index, fx = kRenderFxNone, r = 0, g = 0, b = 0, render = kRenderNormal, amount = 0);
/**
* Checks whether two entities intersect by comparing
* their absolute minimum and maximum coordinates.
*
* @param entity The first entity index to check.
* @param other The second entity index to check.
*
* @return true on success, false otherwise.
*/
native bool:entity_intersects(entity, other);
#include <engine_stocks>