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

Title: Little Help, Stupid but it'll help me out alot.
Post 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.
Title: Re:Little Help, Stupid but it'll help me out alot.
Post by: Kaliyuga on 04 Nov 2003, 04:29:25
 you can try making a condition for a trigger using the distance command

Condition:  heli distance man < x

On Activation: heli land "land"



Title: Re:Little Help, Stupid but it'll help me out alot.
Post by: barry_the_baldy on 04 Nov 2003, 05:42:46
Is there a way to incorporate that into the actual script?

Like I said, its just a learning process that helps me alot.
Title: Re:Little Help, Stupid but it'll help me out alot.
Post by: barry_the_baldy on 04 Nov 2003, 06:09:41
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.
Title: Re:Little Help, Stupid but it'll help me out alot.
Post by: m21man on 04 Nov 2003, 14:14:11
Quote
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.
Title: Re:Little Help, Stupid but it'll help me out alot.
Post by: macguba on 04 Nov 2003, 14:47:26
There's a handy little section inthe official command reference ... Scripting Topics I think.   Well worth a read.
Title: Re:Little Help, Stupid but it'll help me out alot.
Post by: Chris Death on 04 Nov 2003, 15:09:42
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
Title: Re:Little Help, Stupid but it'll help me out alot.
Post by: barry_the_baldy on 06 Nov 2003, 23:04:43
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
Title: Re:Little Help, Stupid but it'll help me out alot.
Post by: macguba on 07 Nov 2003, 00:05:54
#start
_timer = 192

#loop
_timer = _timer-1
? timer <= 100: exit
blah blah blah
goto "loop"
Title: Re:Little Help, Stupid but it'll help me out alot.
Post by: barry_the_baldy on 07 Nov 2003, 00:19:44
Ahhh of course, I cant belive I didnt think of that :P

Thanks a million