OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: barry_the_baldy on 04 Nov 2003, 04:26:41
-
I dont want anybody to write me a script, its not even for a mission, its just me experimenting and pushing the learning process along..
Ive scripted a helicopter to fly to players position and land.
All is well and good but the chopper doesnt land, its not my script because when i add a time of ~10 (the time it takes for the chopper to get o the player) it works fine. What i need is for the chopper to detect that it has arrived at the players position before it executes the "landing".
Heres a little example of what i mean
----------------------------------------------
chopper1 domove position man1
-Here is where i need the chopper to detect whether or not it is at "man1"s position
chopper1 land "land"
exit
------------------------------------------------
etc etc.
Anybody know how i can ask the chopper to detect whether or not it is hovering above man1s position before it lands?
Also is it possible to make the chopper land 10m or so away from the player?
Thanks.
-
you can try making a condition for a trigger using the distance command
Condition: heli distance man < x
On Activation: heli land "land"
-
Is there a way to incorporate that into the actual script?
Like I said, its just a learning process that helps me alot.
-
Ahhh got it, of course my script is a bit more complicated than this :) but using the other example
___________________________
chopper1 domove position man1
? chopper1 distance man1 < 20
chopper1 land "land"
exit
___________________________
I figure the "?" is the same as using the condition field on a trigger.
-
I figure the "?" is the same as using the condition field on a trigger.
No, the @ symbol does the same as the condition field. So, you'd have:
@(chopper1 distance man1 < 20)
The ? symbol is used in if-then statements:
?(chopper1 distance man1 < 20): goto "land"
Edit - The : symbol is the beginning of the then segment.
-
There's a handy little section inthe official command reference ... Scripting Topics I think. Well worth a read.
-
Just one thing i'd like to add here:
The distance from the chopper to the guy on the ground
also includes the height difference.
So if the chopper is flying in a height of 30 meters, the
distance 20 will never be reached.
Solution:
use an object (best use a gamelogic).
gamelogic setpos [(getpos man1 select 0),(getpos man1 select 1),(getpos chopper select 2)]
Now as the chopper will probably (or better say for sure) not
keep his flying height on a constant level, you need to do this
as a loop.
#loop
~1
gamelogic setpos [(getpos man1 select 0),(getpos man1 select 1),(getpos chopper select 2)]
?(chopper distance gamelogic > 20): goto "loop"
~S~ CD
-
Ah very nice.
Got it all in and working now, this will springboard me onto bigger things, it's already helped me create my own script to attatch a camera to a vehicle.
Thanks again guys.
Just 2 more questions (sorry guys), how do I set a timer up in my script?
Say for example you have a
_timer = _this select 0
then say
_timer < 100
how do I make it actually count down, so that when the timer is less than 100 it will move on?
And finally
Is there a way to make the chopper check if it has X amount of men in the cargo position before it takes off again?
Sorry for the bombardment of questions guys.
Thanks
-
#start
_timer = 192
#loop
_timer = _timer-1
? timer <= 100: exit
blah blah blah
goto "loop"
-
Ahhh of course, I cant belive I didnt think of that :P
Thanks a million