Question to in_solid

Posted By: Toryno

Question to in_solid - 04/14/09 22:07

Hello everybody,

I want to place a building in a fps shooter. The building should be a few quants in front of the player and when its in a wall or in an other building, it should be red and otherwise it should be green (So that you can see if you can build it there or not).

My question: why doesn't it become red when its in a wall?
Here's the code ("ich" is the pointer to the player)


Code:
function Gebaeude_bauen() {
	my = ent_createlocal("Geschuetz.mdl",vector(ich.x + 100 * cos(ich.pan), ich.y + 100 * sin(ich.pan), ich.z), Geschuetz);

	wait(1);
	c_setminmax(my);
	
	set(my, TRANSLUCENT |LIGHT);
	
	my.alpha = 50;
	
	while (!Taste_bestaetigen) {
		
		my.x = ich.x + 100 * cos(ich.pan);
		my.y = ich.y + 100 * sin(ich.pan);
		
		if (my.floor_dist > 0)
			c_move(my, nullvector, vector(0, 0, -my.floor_dist), 0);
		if (my.floor_dist < 0)
			c_move(my, nullvector, vector(0, 0, my.floor_dist), 0);
		
		if(in_solid) {
			my.green = 0;
			my.red = 255;
		}
		else {
			my.green = 255;
			my.red = 0;
		}
		
		if (Taste_abbrechen) {
			ptr_remove(my);
			return;
		}
		wait(1);
	}
	
		my = ent_create("Geschuetz.mdl", my.x, Geschuetz);
}



Posted By: zwecklos

Re: Question to in_solid - 04/15/09 01:07

Hi there,
I dont know why in_solid in this case doesnt work for you.
But maybe you can use EVENT_TRIGGER / ENABLE_TRIGGER for an event based solution?

cheers
Posted By: Toryno

Re: Question to in_solid - 04/15/09 11:23

Now it seems to work. But only when the origin of the building is in a wall. When only a bit of it is in a wall, the building is green frown
Has anyone an idea how i can change this?
Here's the new code

Code:
function Gebaeude_bauen_event() {
	switch (event_type)
	{
	case EVENT_BLOCK:
		my.green = 0;
		my.red = 255;
		return;
	case EVENT_ENTITY: 
		my.green = 0;
		my.red = 255;
		return;
	}
	return;
}

function Gebaeude_bauen() {
	// local erstellen

	my = ent_createlocal("Geschuetz.mdl",vector(ich.x + 100 * cos(ich.pan), ich.y + 100 * sin(ich.pan), ich.z), Geschuetz);

	wait(1);
	c_setminmax(my);
	
	my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY); 
	my.event = Gebaeude_bauen_event;
	
	set(my, TRANSLUCENT |LIGHT);
	my.alpha = 50;
	
	
	// verschieben
	while (!Taste_bestaetigen || my.red == 255) {
		
		my.x = ich.x + 100 * cos(ich.pan);
		my.y = ich.y + 100 * sin(ich.pan);
		
		my.green = 255;
		my.red = 0;
		
		
		my.floor_dist = c_trace(my.x, vector(my.x, my.y, - 2000), IGNORE_ME | IGNORE_PASSABLE) + my.min_z;
		if (my.floor_dist > 0)
			c_move(my, nullvector, vector(0, 0, -my.floor_dist), 0);
		if (my.floor_dist < 0)
			c_move(my, nullvector, vector(0, 0, -my.floor_dist), 0);
		
		
		if (Taste_abbrechen) {
			ptr_remove(my);
			return;
		}
		wait(1);
	}
	
	// global erstellen
	if (Index == 1) {
		my = ent_create("Geschuetz.mdl", my.x, Geschuetz);
	}
}

Posted By: George

Re: Question to in_solid - 04/16/09 04:52

Change the origin of your building in Med.
Posted By: Toryno

Re: Question to in_solid - 05/03/09 15:49

I changed the origin but it's always the same problem. frown
Why is that so?
Posted By: FBL

Re: Question to in_solid - 05/03/09 16:13

Try evaluating min_x/y/z and max_x/y/z to see the bounding box. If it is too small, you should manually change the min/max_x/y/z values to fit to your needs.
Posted By: Toryno

Re: Question to in_solid - 05/03/09 16:21

In the code you can see that there is c_setminmax(my). Isn't it enough?
Posted By: Widi

Re: Question to in_solid - 05/03/09 18:20

Press F11 two times and you can see the Bounding Box
Posted By: Toryno

Re: Question to in_solid - 05/03/09 18:30

Yes, the bounding box is correct.

Edit: could it be the movement that makes this problem?
(it's still the same code)
Posted By: EvilSOB

Re: Question to in_solid - 05/04/09 02:30

what about the bounding box of what its hitting? is it correct too?

Posted By: Toryno

Re: Question to in_solid - 05/04/09 06:41

It collidates with a wall of the map.
When i pres f11 two times, the map becomes white so i can't see very good. How can i make that there are only these red stripes on the map?
© 2024 lite-C Forums