OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: TC63 on 01 Jun 2006, 13:06:47

Title: Possibly another simple answer...
Post by: TC63 on 01 Jun 2006, 13:06:47
God i been waiting for this site to come back up, god job!

i have a script that runs in a loop to simulate a car chase

"?player distance pc1 < 200: PC1 domove getpos player"

this means that pc1 will try to catch up with the player, its in a 5 second loop but unfortunately it doesnt strictly work as pc1 will frequently just slow down or be left behind really easily

Is there a way that i could use x y z values to position where pc1 has to move about 50 meters infront of the player, this way making pc1 try to overtake and block the road?

Also would it be posible to detect when the player has stopped, so that i could tell everyone in pc1 to disembark, but if player starts to move again then they will jump back on and resume the chase?

Any help would be greatly appreciated!

Thanks
Title: Re: Possibly another simple answer...
Post by: bedges on 01 Jun 2006, 13:37:46
try

Code: [Select]
_x = getpos (vehicle player) select 0
_y = getpos (vehicle player) select 1
_dir = getdir (vehicle player)

? (((vehicle player) distance pc1) >= 200): pc1 domove [_x + (50*sin(_dir)), _y + (50*cos(_dir))]


the way the code was, pc1 would only try to catch up if he was less than 200 metres from the player... :P

the code above will place the domove point 50 metres in front of the player. as for the getting in and getting out, that's a bit more complicated.
Title: Re: Possibly another simple answer...
Post by: TC63 on 01 Jun 2006, 13:40:15
excellent, thanks you very much!

yes, it was supposed to be coded as such so that the player could 'lose' pc1, as there is also 6 more pcs, as they are police cars