OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Riker13 on 18 Jan 2005, 13:33:37
-
From my previous post I have a Civillian able to fire at me but when I run off he just stays where he is, I need him to get on his bike and chase me as he is a cop.
How do I do that?
Many Regards
-
If you have it set so that the Civ hates the player (whichever side he is on) then he should chanse after you.
Getting on his bike is another thing altogether. He won't automatically get on his bike, so you'll have to scipt that bit.
Use something like (syntax not 100% acc.):
_civ = this select 0
_veh = this select 1
#Start
!(player distance _civ < 50) : goto "Mount"
goto "Start"
#Mount
_civ getInDriver _veh
#Chase
_pos = getPos player
[_civ, 0] setWPPos _pos
~0.001
goto "Chase"
exit
Then, in the mission editor make a trigger with the following:
x=0,y=0
Condition: this
OnActivation: ["NameOfCivillianUnit", "NameOfBike"] exec "ScriptName.sqs"
-
Many thanks for that. ;)
-
you could do it like that, in order to make it more ralistic:
_civ = this select 0
_veh = this select 1
#aLoop
!(player distance _civ < 50) : goto "run"
goto "aLoop"
#run
_civ doMove getpos _veh
#bLoop
!(_civ distance _veh < 2) : goto "Mount"
goto "bLoop"
#Mount
player action ["get in",_veh]
#Chase
_pos = getPos player
_civ doMove getPos player
?(_civ distance player) > 100 : goTo "abort"
~0.001
goto "Chase"
"Abort"
?(_civ distance player) < 50 : goTo "chase"
goTo "abort"
exit
the trigger is the same but this script will actually cause the civ to run to the vehicle, get in and follow you, if the distance between the civ and you gains a higher value than 100, the civ will stop moving. if player moves within 50m to civ, civ will restart the chase.
-
I think
#bLoop
!(_civ distance _veh < 2) : goto "Mount"
goto "bLoop"
Could be replaced by
@!(_civ distance _veh < 2)
Should:
player action ["get in",_veh]
not be:
_civ action ["get in",_veh]
and
"Abort"
be:
#abort
I would also suggest a longer delay than ~0.001 in the Chase loop
What is the civi supposed to do when he gets near the player?
-
I would also suggest a longer delay than ~0.001 in the Chase loop
Yeah, I think you're right if you're refering to redgun's version. The civ would constantly be stoping and turning to wards the player.
If you use the WP version then it would be much more continuous.
-
I haven't studied the script but I would have thought a delay of ~5 would be better.
~0.001 is I think the fastest loop you can have, which is very CPU intensive and completely unneccessary here. Also, if you issue too many orders too quickly, it can confuse the unit.
-
meh, I suppose that's true.
It is a fact that ~0.001 causes a lot of CTDs. :P
-
oh yeah, thanks a lot guys.
made some mistakes sorry for that.
maybe something like ~5 to ~10 should to the best job.
generally I try to avoid wp-commands in scripts, because with using Move or doMove you can still make the unit follow its wp, intepended from tghe script.
of course it can be done otherwise too, at least i think so.