// accuracy:
var wpn_aim_x = 1; // play with this value
var wpn_aim_y = 1; // play with this value
function bullet_create(VECTOR* vpos, VECTOR* vang, var speed){
var alive = 16;
VECTOR pos;
VECTOR temp;
VECTOR vel;
ANGLE accur;
vec_set(pos, vpos);
vec_set(vel, vector(speed, 0, -3));
vec_set(accur, vector(wpn_aim_x - random(wpn_aim_x * 2), wpn_aim_y - random(wpn_aim_y * 2), 0));
ang_add(accur, vang);
vec_rotate(vel, accur);
while(alive > 0){
// calculate new position
vec_set(temp, vel);
vec_scale(temp, time_step);
vec_add(temp, pos);
trace_mode = IGNORE_PASSABLE | USE_POLYGON | SCAN_TEXTURE;
c_trace(pos, temp, trace_mode);
if(trace_hit){
// check if hit the target:
if(vec_dist(target, nullvector) > 0){
// effect for blocks:
if(hit.entity == NULL){
}
else{
// entity was hit:
}
}
alive = 0;
}
// you may want to shorten vel on impact:
effect(bullet_effect, 1, pos,vel);
// move to new position:
vec_set(pos, temp);
alive -= time_step / 16;
wait(1);
}
}