monitoring istouching of any player

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

monitoring istouching of any player

Post 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
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Re: monitoring istouching of any player

Post 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
Admin .MAP Forums
Image
Head above heels.
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post 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
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post 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.
Admin .MAP Forums
Image
Head above heels.
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Re: monitoring istouching of any player

Post 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
Post Reply