#include <amxmodx>
#include <fakemeta>
#include <xs>
#include <hamsandwich>
new const g_szRegEngitiesList[][] =
{
"worldspawn",
"func_wall",
"func_breakable"
};
public plugin_init()
{
for (new i; i < sizeof(g_szRegEngitiesList); i++)
{
RegisterHam(Ham_TraceAttack, g_szRegEngitiesList[i], "CBasePlayer_TraceAttack");
}
}
new const Float:MAX_EACH_DISTANCE = 8192.0;
public CBasePlayer_TraceAttack(victim, attacker, Float:damage, Float:vecDir[3], tracehandle, damagebits)
{
new Float:vecSrc[3], Float:vecEnd[3];
for (;;)
{
new Float:flFraction;
get_tr2(tracehandle, TR_flFraction, flFraction);
if (flFraction == 1.0)
{
return HAM_IGNORED;
}
new pHit = get_tr2(tracehandle, TR_pHit);
if (pHit > 0 && pHit <= MaxClients)
{
SetHamParamEntity(1, pHit);
return HAM_IGNORED;
}
get_tr2(tracehandle, TR_vecEndPos, vecSrc);
xs_vec_add_scaled(vecSrc, vecDir, 5.0, vecSrc);
xs_vec_add_scaled(vecSrc, vecDir, MAX_EACH_DISTANCE, vecEnd);
engfunc(EngFunc_TraceLine, vecSrc, vecEnd, DONT_IGNORE_MONSTERS, pHit, tracehandle);
}
return HAM_IGNORED;
}