diff --git a/dlls/engine/entity.cpp b/dlls/engine/entity.cpp index 030d51a8..f949a2e1 100755 --- a/dlls/engine/entity.cpp +++ b/dlls/engine/entity.cpp @@ -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} }; diff --git a/plugins/include/engine.inc b/plugins/include/engine.inc index 375b5a25..ae20be03 100755 --- a/plugins/include/engine.inc +++ b/plugins/include/engine.inc @@ -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