Code:
public task_primary_attack(data[])
{
new attacker = data[0], inflictor = data[1]
new Float:angles[3], Float:start[3], Float:end[3], Float:dir[3], Float:fakeend[3]
new Float:flFraction, pHit
new tr = create_tr2()
get_entvar(attacker, var_angles, angles)
angle_vector(angles, ANGLEVECTOR_FORWARD, dir)
xs_vec_mul_scalar(dir, 80.0, fakeend)
get_entvar(attacker, var_origin, start)
get_entvar(attacker, var_view_ofs, end)
xs_vec_add(end, start, start)
xs_vec_add(start, fakeend, end)
engfunc(EngFunc_TraceLine, start, end, DONT_IGNORE_MONSTERS, attacker, tr)
get_tr2(tr, TR_flFraction, flFraction)
if (flFraction >= 1.0)
{
emit_sound(attacker, CHAN_WEAPON, sound_combistick_slash[random_num(0, sizeof sound_combistick_slash - 1)], VOL_NORM, ATTN_NORM, 0, PITCH_LOW)
}
else
{
pHit = get_tr2(tr, TR_pHit)
if (pHit == -1)
{
pHit = 0
set_tr2(tr, TR_pHit, pHit)
}
rg_multidmg_clear()
ExecuteHamB(Ham_TraceAttack, pHit, attacker, 35.0, dir, tr, DMG_NEVERGIB | DMG_BULLET)
rg_multidmg_apply(inflictor, attacker)
if (pHit && is_user_alive(pHit))
emit_sound(attacker, CHAN_WEAPON, sound_combistick_hit[random_num(0, sizeof sound_combistick_hit - 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
else
emit_sound(attacker, CHAN_WEAPON, sound_combistick_hit_wall, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
free_tr2(tr)
}
- when I attack the player, no matter what part of the body, it is always inflicted damage to the head rather than the affected area.
- when I attack a box (in the Cs_assault, a blue box, for example) or the floor, the sound "hit_wall" is not emitted, instead, the "slash" is being emitted.
- in some entities, the damage is only inflicted if I really pull it over, and if I'm crouching at the same time.