func_IsAttackInBack(pVictim, pAttacker) {
static Float:vecSrc[3],
Float:vecAngles[3],
Float:vecForward[3],
Float:vecAttackDir[3];
func_GetCenter(pVictim, vecSrc);
func_GetCenter(pAttacker, vecAttackDir);
xs_vec_sub(vecAttackDir, vecSrc, vecAttackDir);
xs_vec_normalize(vecAttackDir, vecAttackDir);
get_entvar(pVictim, var_angles, vecAngles);
engfunc(EngFunc_MakeVectors, vecAngles);
global_get(glb_v_forward, vecForward);
xs_vec_mul_scalar(vecAttackDir, -1.0, vecAttackDir);
return (xs_vec_dot(vecForward, vecAttackDir) > 0.3) ? 1 : 0;
}
func_GetCenter(pPlayer, Float:vecSrc[3]) {
new Float:vecAbsMax[3], Float:vecAbsMin[3];
get_entvar(pPlayer, var_absmax, vecAbsMax);
get_entvar(pPlayer, var_absmin, vecAbsMin);
xs_vec_add(vecAbsMax, vecAbsMin, vecSrc);
xs_vec_mul_scalar(vecSrc, 0.5, vecSrc);
}