Page 1 of 1

monitoring istouching of any player

Posted: Mon Feb 28, 2005 2:58 pm
by wacko
mmm, maybe to much beer this weekend, but now I can't imagine how I could to this :roll:

I got a car going from point A to point B on a splinepath. Everythings fine, but now I want the car to be set back to point A after the ride. But this shall happen while no player is seeing the car.
I set a trigger_multiple $carview where the player would see the car in point A or B, and now I think, I must check whether any player is not touching the trigger and then the car can be moved back to point A.
Below is what I got so far, a second player though is neglected by now :cry:
Any ideas?

Code: Select all

main:
level waittill prespawn
	level.script = maps/test.scr
level waittill spawn
thread car_seen
end

car_seen:
while(1)
{
local.player = parm.other
while (local.player istouching $carview)
		{
		level.car_is_seen = 1
		wait 0.5
		}
level.car_is_seen = 0
		wait 0.5
}
end

carrun:
	level.startpos = $car.origin
	level.startangles = $car.angles
	local.player = parm.other
	$carseat bind $car
	$cartrigger nottriggerable
	local.player glue $carseat
	local.player forcelegsstate CROUCH_IDLE
	local.player physics_off
	$car followpath $carpath
	$car waitmove
	local.player physics_on
	local.player unglue
	level.carpos=1
	thread car_reset
end

car_reset:
while (level.carpos == 1)
	{
	iprintln_noloc level.car_is_seen " - " level.carpos
	if (level.car_is_seen == 0)
		{
		$car.origin = level.startpos
		$car.angles = level.startangles
		level.carpos=0
		}
	wait .5
	}
end

Re: monitoring istouching of any player

Posted: Mon Feb 28, 2005 3:23 pm
by Bjarne BZR
Uncompiled off the top of my head:

Code: Select all

car_seen:
	while(1)
	{
		local.car_is_seen = 0
		for( local.index = 1 ; local.index < $player.size ; local.index++ )
		{
			if ($player[ocal.index] istouching $carview)
			{
				local.car_is_seen = 1
				break
			}
			wait 0.1
		}
		level.car_is_seen = local.car_is_seen
		wait 0.5
	}
end

Posted: Mon Feb 28, 2005 3:54 pm
by Rookie One.pl
Why bother yourself using a trigger? You can use cansee instead. 8-)

Code: Select all

if ($player[local.i] cansee local.car <fov> <distance>)
blahblahblah

Posted: Mon Feb 28, 2005 4:11 pm
by Bjarne BZR
Yes, I think you can, but I think it is computationally expensive to use cansee... I do not know so, but it is my guess.

Re: monitoring istouching of any player

Posted: Mon Feb 28, 2005 6:00 pm
by wacko
@Bjarne BZR: Yes, thanks a lot, mate :D Almost perfect, just 2 typos:
for( local.index = 1 ; local.index <= $player.size ; local.index++ ) and if ($player[local.index] istouching
Now combining several triangular trigger_multiples under a single targetname seems to make them behave like one big rectangular one. So I probably will have to check all of them seperately :roll: Well, this I will manage by myself. Thanks again.

@ Rookie One: Could try this, but I think Bjarne is right, it'll take quite a lot resources :cry: But thanks for sharing ur idea, might come handy in another case :D