Here is how I've edited that function for my old project:
Code:
// 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);
	}
}

I use it like this:
Code:
bullet_create(muzzle_pos.x, weapon.pan, 400);
// muzzle_pos is the vector where I create muzzle flash effect

Change accuracy of your weapons depending on the player's movement state to make it more realistic laugh


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung