Code:
public CBaseWeapon_TraceAttack_Post( pEntity, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
{
new iDecal = GUNSHOT_DECALS[ random_num( 0 , sizeof( GUNSHOT_DECALS ) - 1 ) ];
new Float:vecEnd[3], Float:vecPlane[3]
get_tr2(ptr, TR_vecEndPos, vecEnd);
get_tr2(ptr, TR_vecPlaneNormal, vecPlane);
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_GUNSHOTDECAL)
write_coord_f(vecEnd[0])
write_coord_f(vecEnd[1])
write_coord_f(vecEnd[2])
write_short(pEntity)
write_byte(iDecal)
message_end()
pEntity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
xs_vec_mul_scalar(vecPlane, 60.0, vecPlane);
xs_vec_add(vecEnd, vecPlane, vecEnd);
entity_set_origin(pEntity, vecEnd)
entity_set_model(pEntity, WEAPON_TRACE_EFFECT)
entity_set_int(pEntity, EV_INT_solid, SOLID_NOT)
entity_set_int(pEntity, EV_INT_movetype, MOVETYPE_NOCLIP)
entity_set_float(pEntity, EV_FL_animtime, get_gametime())
entity_set_float(pEntity, EV_FL_framerate, 40.0)
set_pev(pEntity, pev_scale, 0.5)
set_pev(pEntity, pev_spawnflags, SF_SPRITE_ONCE)
// Set velocity
new Float:vecVelocity[3], Float:vecRight[3], Float:vecUp[3];
engfunc(EngFunc_VecToAngles, vecPlane, vecPlane );
vector_to_angle(vecPlane, vecPlane);
angle_vector(vecPlane,ANGLEVECTOR_RIGHT,vecRight)
angle_vector(vecPlane,ANGLEVECTOR_UP,vecUp)
vecVelocity[0] *= 32.0;
vecVelocity[1] *= 32.0;
vecVelocity[2] *= 32.0;
new Float:flRandomVec = random_float(0.0, 64.0) * random_float(-1.0, 1.0);
vecRight[0] *= flRandomVec;
vecRight[1] *= flRandomVec;
vecRight[2] *= flRandomVec;
flRandomVec = random_float(0.0, 64.0) * random_float(-1.0, 1.0);
vecUp[0] *= flRandomVec;
vecUp[1] *= flRandomVec;
vecUp[2] *= flRandomVec;
vecVelocity[0] += vecRight[0] + vecUp[0];
vecVelocity[1] += vecRight[1] + vecUp[1];
vecVelocity[2] += vecRight[2] + vecUp[2];
set_pev(pEntity, pev_velocity, vecVelocity);
DispatchSpawn(pEntity);
entity_set_int(pEntity, EV_INT_movetype, MOVETYPE_NOCLIP)
set_pev(pEntity, pev_rendermode, kRenderTransAdd)
set_pev(pEntity, pev_renderamt, 27.0)
entity_set_float(pEntity, EV_FL_animtime, get_gametime())
entity_set_float(pEntity, EV_FL_nextthink, get_gametime() + 0.025);
return HAM_IGNORED;
}