public fw_touch(bullet, ent)
{
new class[20];
pev(bullet, pev_classname, class, 19);
if (!equali(class, "pbBullet"))
return FMRES_IGNORED;
new Float:origin[3], class2[20], owner = pev(bullet, pev_owner), is_ent_alive = is_user_alive(ent);
pev(ent, pev_classname, class2, 19);
pev(bullet, pev_origin, origin);
if (is_ent_alive)
{
if (owner == ent || pev(ent, pev_takedamage) == DAMAGE_NO)
return FMRES_IGNORED;
if (get_user_team(owner) == get_user_team(ent))
if (!get_pcvar_num(friendlyfire))
return FMRES_IGNORED;
ExecuteHam(Ham_TakeDamage, ent, owner, owner, float(get_pcvar_num(damge)), 4098);
}
if (!equali(class, class2))
{
set_pev(bullet, pev_velocity, Float:{0.0, 0.0, 0.0});
set_pev(bullet, pev_classname, "pbPaint");
set_pev(bullet, pev_solid, 0);
set_pev(bullet, pev_movetype, 0);
engfunc(EngFunc_SetModel, bullet, "sprites/paintball.spr");
new a, findpb = 0;
while (a++ < g_pbcount && !findpb)
if (g_paintballs[a] == bullet)
findpb = g_pbstatus[a] = 2;
remove_task(bullet);
remove_task(bullet+TASK_PB_RESET);
if (get_pcvar_num(sound))
{
static wav[20];
formatex(wav, 20, is_ent_alive ? "player/pl_pain%d.wav" : "misc/pb%d.wav", is_ent_alive ? random_num(4,7) : random_num(1,4));
emit_sound(bullet, CHAN_AUTO, wav, 1.0, ATTN_NORM, 0, PITCH_NORM);
}
new bool:valid_surface = (is_ent_alive || containi(class2, "door") != -1) ? false : true;
if (pev(ent, pev_health) && !is_ent_alive && pev(ent,pev_takedamage))
{
ExecuteHam(Ham_TakeDamage, ent, owner, owner, float(pev(ent, pev_health)), 0);
valid_surface = false;
}
if (valid_surface)
{
paint_splat(bullet);
set_task(float(get_pcvar_num(blife)), "paint_reset", bullet+TASK_PB_RESET);
}
else
paint_reset(bullet+TASK_PB_RESET);
return FMRES_HANDLED;
}
return FMRES_IGNORED;
}