Ugly Bulletholes

Posted By: Rei_Ayanami

Ugly Bulletholes - 07/19/09 11:52

Hello Guys!
I finally got my 3rd erson gun but there are so many problems frown . Please don´t say that my View is ugly - I know, it is just for testing.

Here are the pics:

Ugly!

Wrong!
You can see that there are really ugly and wrong.

Code:
Code:
c_trace(temp2, temp, IGNORE_PASSABLE | IGNORE_ME | IGNORE_YOU | USE_POLYGON | ACTIVATE_SHOOT | GET_HITVERTEX);
ent_create("bullet_hole.tga",target,bullet_hole);


Calls the bullet hole and creates it at the target position.
Bullet Hole Code:
Code:
function bullet_hole()		//die Funktion die die Einschusslöcher erstellt
{
	vec_to_angle(my.pan, normal);		//setzt den Winkel auf nciht der Camera anpassen
	my.scale_x = 1;						//scaliert das Bild
	my.scale_y = 1;
	my.scale_z = 1;
	set(me, OVERLAY | TRANSLUCENT | PASSABLE);	//setzt das Bild auf PASSABLE, Durchsichtig und Schwar ausblenden
	my.alpha = 100;										//setzt die duchsichtig keit auf 0
	wait(-5);												//warte 5 sekunden
	while (my.alpha > 0)									//solange das bild weniger als 100 % durchsichtig ist
	{
		my.alpha -= 0.25*time_step;					//erhöhe die durchsichtigkeit
		wait(1);
	}
	ptr_remove(me);										//entferne das Bild
}


Hope you understand the code wink!

Nearly every reply is a good reply!
Posted By: Rei_Ayanami

Re: Ugly Bulletholes - 07/19/09 14:16

It got Worser frown !
Iamge:
why is that so?
Weapon Code:
Code:
function pistol_shoot()									//die Schuss Funktion, solange ich nciht wieß wieviele waffen es gibt bleibt es bei der Pistole
{
	VECTOR temp, temp2;									//2 lokale Vectoren
	var i;													//lokale hochzähl-variable
	temp.x = mouse_pos.x;								//setzt lokalen Vector 1 X auf die mouse x position
	temp.y = mouse_pos.y;								//setzt lokalen Vector 1 Y auf die mouse y position
	temp.z = camera.clip_far;							//setzt lokalen Vector 1 Z auf die Fern enfernung der Camera
 	vec_for_screen(temp, camera);						//konvertiert die durch den Vektor angegebenen XY-Bildschirmkoordinaten in eine Welt-Position
	you = player;											//du bist der Spieler
	vec_for_vertex(temp2, pistol, 797);				//setzt lokalen Vector 2 (Temp 2) auf die mündung 
	vec_sub(temp, temp2);								//berechnet den Winkel
	c_trace(temp2, temp, IGNORE_PASSABLE | IGNORE_ME | IGNORE_YOU | USE_POLYGON | ACTIVATE_SHOOT | GET_HITVERTEX);			//traced von vector 1 zu vector 2
	gun_flash();
	if(you!=NULL)											//wenn du Irgenwas bist auser die Level Wand
	{
		wait(1);												//noch nichts
	}
	else
	{
		ent_create("bullet_hole.tga",target,bullet_hole);	//sonst erstelle das Einschussloch an der stelle des hinschießens
		//		effect(funkenspezial,10,target,nullvector); 	// Funkeneffekt am Ziel
	}
	return;							//beendet
}


Posted By: Der_Kekser

Re: Ugly Bulletholes - 07/19/09 14:55

warum benutzt du keine Decals?

dann kann die function bullet_hole weg und in der function pistol_shoot ersetzt du
Code:
ent_create("bullet_hole.tga",target,bullet_hole);


mit:
Code:
ent_decal(NULL,"bullet_hole.tga",0,0);



und bei dem c_trace noch SCAN_TEXTURE als mode angeben.
Posted By: Scorpion

Re: Ugly Bulletholes - 07/19/09 15:12

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;
	}
}


Posted By: Rei_Ayanami

Re: Ugly Bulletholes - 07/19/09 15:25

Crash in Bullet hole frown
Bt thanks very much, i have never worked with voids or scan_texture or things like this smile.
Posted By: Rei_Ayanami

Re: Ugly Bulletholes - 07/19/09 15:29

Also ihr könnt auch in Deutsch schreiben, fällt mir grad auf wink
Posted By: sebbi91

Re: Ugly Bulletholes - 07/19/09 15:53

@Der_Kekser:
Ähh entschuldige mich wenn ich falsch liege aber ist die ent_decal function nicht eigendlich nur für A7 7.10 (Commercial,Professional) verfügbar?
Steht jedenfalls so im Manual !http://www.conitec.net/beta/ent_decal.htm

Dem anschein nach nutzt er allerdings Lite-C FREE!
Sorry falls ich falsch liege ^^
Posted By: Rei_Ayanami

Re: Ugly Bulletholes - 07/19/09 15:55

stimmt, ab A7 7.10 nur mit Com und Prof verfügbar frown
Posted By: VeT

Re: Ugly Bulletholes - 07/19/09 16:02

//instead use a trace from the cursor to a position way behind the cursor to get the position of the shot.

As a variant, you can try to trace from gun to your target coordinates in 3d, then find place, where your bullet will co,lline with obstacle and then place crosshair picture there.
Posted By: Der_Kekser

Re: Ugly Bulletholes - 07/19/09 16:10

Oh, hab ich nicht dran gedacht, dass ent_decal für Com und Pro ist, habe persönlich nähmlich Com, sry
Posted By: sebbi91

Re: Ugly Bulletholes - 07/19/09 16:16

gibt es vieleicht einen anderen Weg wie er decal simullieren kann?
mir würde blos noch das "uralt prinzip" einfallen(was er ja schon teilweise benutzt)!
Trace strahl-->schauen was er trifft-->vec_to angle
Posted By: Rei_Ayanami

Re: Ugly Bulletholes - 07/19/09 16:16

@VeT: Thanks! But when I use smaller bullet hole bmaps it will do the same job wink
@kekser: Egal, kann passieren smile !
Posted By: Rei_Ayanami

Re: Ugly Bulletholes - 07/19/09 16:17

Also wenn du mir das erklärst mit decal, denn ich mach das für sPIKe und der hat Com, würde das auch helfen smile
Posted By: Scorpion

Re: Ugly Bulletholes - 07/20/09 09:23

@vet der erste trace liefert die zielkoordinaten zurück, damit man dorthin tracen kann.

@Rei_Ayanami ich pack den code mal kurz in einen testlevel und such den typo^^ - vom prinzip her sollte es aber klappen. wenn du willst kann ich es auch noch ein wenig genauer erläutern.

Dann aber noch eine Frage: woher hast du den Level, wenn du nur lite-c hast? soweit ich weiß gibts wed doch nur mit gamestudio? naja, ich versuch mal das mit der alten decal methode.

edit: okay, ich hab ein kleines projekt gemacht, das sowohl mit decals als auch mit normalen sprites funktioniert (über einfaches #define umstellbar) hier ist der download link
Posted By: VeT

Re: Ugly Bulletholes - 07/20/09 10:38

//@VeT: Thanks! But when I use smaller bullet hole bmaps it will do the same job

Hmm... why do you think so? Crosshair would be placed on the position, where bullet will hit obstacle, i dont think that it depends on the size of bmaps.

//@vet der erste trace liefert die zielkoordinaten zurück, damit man dorthin tracen kann.

I dont understand smile
Posted By: Scorpion

Re: Ugly Bulletholes - 07/20/09 11:06

oh sorry..here are still not-german people around^^

The first trace is to get the coordinates you are targeting. The second trace is for the real shooting


Posted By: VeT

Re: Ugly Bulletholes - 07/20/09 13:53

Quote:

As a variant, you can try to trace from gun to your target coordinates in 3d, then find place, where your bullet will collide with obstacle and then place crosshair picture there.


I was told about another variant smile

[clickeable]
Posted By: Rei_Ayanami

Re: Ugly Bulletholes - 07/20/09 14:25

Thank you all soooo much smile!
@Scorpion Cool demo, but could you explain because I have never worked with this ifdef and things like that smile.

BTW: Cool pics you made :p!
Posted By: VeT

Re: Ugly Bulletholes - 07/20/09 14:50

I'm a progmammer, not 2d artist :P )))
Posted By: Scorpion

Re: Ugly Bulletholes - 07/20/09 23:02

@vet as far as i understood it, the player should shoot to the position of the crosshair (which is the mousecursor). you do a trace to a position somewhere behind that cursor and if it hits a wall it's not the same (in screenspace) position as the bullet hole = you would target another position than the one you're aiming with the cursor. that was the way how he did it before af far as i understood it.


okayy..., maybe it was a bit confusing to put the define in there^^

the hole stuff with defines works like this:
before the compiler does any code checking or validation, it first looks for the statement which start with #. #include, #define, #ifdef, etc.

i guess you know what #include does. it just puts the content of the file you name to the position in the code.

then there is another group: the defines and some handy controls for them
the #define statement - guess it - defines the name that comes after it. pretty similar to defining a variable (you can also put something behind the name and it gets replaced everytime it appears in the sourcecode, just look it up in the manual if you want to know more about it)

the other ones are similar to a normal if-else instruction.

Code:
#ifdef NAME - did the name got defined with #define before?
   CODECODECODE
#else - guess it
   OTHERCODECODECODE
#endif - like a closing bracket



so you can choose which lines of code get compiled and which do not. in my example you can comment the define of USE_DECALS out to not use decals. then the other function, other variables and another function call get compiled. the running program has no idea about the other lines of code, which were not chosen.


okay, the explanation got a bit longer, but i hope you got the idea.. and remember: the manual is your friend. it's a pretty good manual imo and you can nearly always get the answer, even when it's a little bit hidden sometimes.
If you've got another question about it just ask it and i try to answer..maybe a little bit shorter^^°
Posted By: Jaeger

Re: Ugly Bulletholes - 07/20/09 23:33

If you want some good looking bullet holes, you can download my free set on Turbosquid. You get 4 for regular surfaces, and 4 for glass. They're at a fairly hi-res, in case you need it, but you'll probably want to scale them down a bit.

http://www.turbosquid.com/FullPreview/Index.cfm/ID/473116



If you get them, please leave a review. smile
© 2024 lite-C Forums