text
stringlengths 0
692
|
---|
for (new i = index + 1; i < maxents; ++i) { |
if (pev_valid(i) && (pev(i, pev_field) & flags) == flags) |
return i |
} |
return 0 |
} |
stock Float:fm_distance_to_box(const Float:point[3], const Float:mins[3], const Float:maxs[3]) { |
new Float:dist[3] |
for (new i = 0; i < 3; ++i) { |
if (point[i] > maxs[i]) |
dist[i] = point[i] - maxs[i] |
else if (mins[i] > point[i]) |
dist[i] = mins[i] - point[i] |
} |
return vector_length(dist) |
} |
stock Float:fm_boxes_distance(const Float:mins1[3], const Float:maxs1[3], const Float:mins2[3], const Float:maxs2[3]) { |
new Float:dist[3] |
for (new i = 0; i < 3; ++i) { |
if (mins1[i] > maxs2[i]) |
dist[i] = mins1[i] - maxs2[i] |
else if (mins2[i] > maxs1[i]) |
dist[i] = mins2[i] - maxs1[i] |
} |
return vector_length(dist) |
} |
stock Float:fm_distance_to_boxent(entity, boxent) { |
new Float:point[3] |
pev(entity, pev_origin, point) |
new Float:mins[3], Float:maxs[3] |
pev(boxent, pev_absmin, mins) |
pev(boxent, pev_absmax, maxs) |
return fm_distance_to_box(point, mins, maxs) |
} |
stock Float:fm_boxents_distance(boxent1, boxent2) { |
new Float:mins1[3], Float:maxs1[3] |
pev(boxent1, pev_absmin, mins1) |
pev(boxent1, pev_absmax, maxs1) |
new Float:mins2[3], Float:maxs2[3] |
pev(boxent2, pev_absmin, mins2) |
pev(boxent2, pev_absmax, maxs2) |
return fm_boxes_distance(mins1, maxs1, mins2, maxs2) |
} |
// projects a center of a player's feet base (originally by P34nut, improved) |
stock Float:fm_distance_to_floor(index, ignoremonsters = 1) { |
new Float:start[3], Float:dest[3], Float:end[3] |
pev(index, pev_origin, start) |
dest[0] = start[0] |
dest[1] = start[1] |
dest[2] = -8191.0 |
engfunc(EngFunc_TraceLine, start, dest, ignoremonsters, index, 0) |
get_tr2(0, TR_vecEndPos, end) |
pev(index, pev_absmin, start) |
new Float:ret = start[2] - end[2] |
return ret > 0 ? ret : 0.0 |
} |
// potential to crash (?) if used on weaponbox+weapon_* entity pair (use fm_remove_weaponbox instead) |
stock fm_kill_entity(index) { |
set_pev(index, pev_flags, pev(index, pev_flags) | FL_KILLME) |
return 1 |
} |
// if weapon index isn't passed then assuming that it's the current weapon |
stock fm_get_user_weapon_entity(id, wid = 0) { |
new weap = wid, clip, ammo |
if (!weap && !(weap = get_user_weapon(id, clip, ammo))) |
return 0 |
new class[32] |
get_weaponname(weap, class, sizeof class - 1) |
return fm_find_ent_by_owner(-1, class, id) |
} |
// only weapon index or its name can be passed, if neither is passed then the current gun will be stripped |
stock bool:fm_strip_user_gun(index, wid = 0, const wname[] = "") { |
new ent_class[32] |
if (!wid && wname[0]) |
copy(ent_class, sizeof ent_class - 1, wname) |
else { |
new weapon = wid, clip, ammo |
if (!weapon && !(weapon = get_user_weapon(index, clip, ammo))) |
return false |