try to add the normal to the position of the bullet hole
Code:
vec_add(my.x,normal);


or better: use decals for your bulletholes

About the wrong position of the bullet holes: you are defining a position FAAR behind that wall and if you draw a line from the gun to that position, it crosses the wall on a different part.
instead use a trace from the cursor to a position way behind the cursor to get the position of the shot.

for determine if you hit an enemy you need a second trace

this code should to the job. -did not tested it- enjoy!

edit: habs SCAN_TEXTURE vergessen..danke der kekser =]

Code:
void createBullethole(VECTOR* pos, VECTOR* n, int chunk){
	vec_set(hit.x, pos);
	vec_set(hit.nx, n);
	hit.chunk = chunk;
	hit.model = NULL;
	PARTICLE* p = ent_decal(NULL, "bullet_hole.tga", 8, random(360));

	//here you can set up everything for the bullet hole, like a event and a material
	p.lifespan = 160; //remove after 10 secs
}

void pistol_shoot(){
	VECTOR from, to;
	
	//mouse_spot to get the middle of the crosshair
	vec_set(from, vector(mouse_pos.x + mouse_spot.x, mouse_pos.y + mouse_spot.y ,0);
	vec_set(to, from);
	to.z = camera.clip_far;
	
	vec_for_screen(from, camera);
	vec_for_screen(to, camera);
	
	c_trace(from, to, IGNORE_PASSABLE | IGNORE_ME | IGNORE_YOU | USE_POLYGON | SCAN_TEXTURE);
	
	int holeChunk = hit.chunk;
	VECTOR holePos;
	vec_set(holePos, target);
	VECTOR holeN;
	vec_set(holeN, normal);
	
	vec_set(to, target);
	vec_for_vertex(from, pistol, 797);
	
	c_trace(from, to, IGNORE_PASSABLE | IGNORE_ME | USE_POLYGON | ACTIVATE_SHOOT | GET_HITVERTEX);
	
	if(you==NULL){//hit nothing
		createBullethole(holePos, holeN, holeChunk);
	}
	else{
		your.health -= PISTOL_DAMAGE;
	}
}



Last edited by Scorpion; 07/19/09 15:16.