Home   Help Search Login Register  

Author Topic: Script Question  (Read 2188 times)

0 Members and 1 Guest are viewing this topic.

Neal

  • Guest
Script Question
« on: 06 Mar 2004, 14:12:47 »
Can someone make me a script where a helicopter goes to one area. Land for 10 seconds. Then goes back to its main base and lands for another 10 seconds. Then goes back. Over and Over. And if possible do it with 2 helicopters.

If this is possible. If not I have another idea.

BibiPhoque

  • Guest
Re:Script Question
« Reply #1 on: 06 Mar 2004, 19:21:32 »
Code: [Select]
_heli = _this select 0
_wp = _this select 1
_waittime = 10

_nbwp = (count _wp) - 1
_i = 0

#Loop
_a = _wp select _i
_heli flyinheight 100
_heli DoMove (GetPos _a)
_hloc = "HeliHEmpty" createvehicle getpos _a
@_heli distance _a < 200
_heli Land "LAND"
_heli flyinheight 0
@getpos _heli select 2 < 2
~_waittime
_i = _i + 1
?_i > _nbwp: _i = 0
deletevehicle _hloc
Goto "Loop"

Where _heli is... an helicopter, _wp is an array of objects representing the desired landing locations. And _time is the time you want it to wait at each locations. Note that you can put more than two locations for _wp if you want. And doing it for two choppers is as easy as you may think =)
« Last Edit: 07 Mar 2004, 12:56:30 by BibiPhoque »

Neal

  • Guest
Re:Script Question
« Reply #2 on: 06 Mar 2004, 21:55:35 »
Hmm... I have no clue how or what to do with that. lol

**edit** alright i created heli.sqs and put it in there. In game-
[] exec "heli.sqs" is with the helicopter. But what do I do with WPs?
« Last Edit: 06 Mar 2004, 22:04:23 by Neal »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Script Question
« Reply #3 on: 06 Mar 2004, 22:12:36 »
You call the script something like this:-

[heli1, [GL1,GL2] ] exec "heli.sqs"

where heli1 is the name of the chopper you want to do all this and GL1 and GL2 are gamelogics placed at the places you want the chopper to go.   The chopper doesn't need waypoints - this script is doing the job of waypoints.   (You could of course use waypoints instead of a script.)

For the other chopper it would of course be

[heli2, [GL3,GL4] ] exec "heli.sqs"

and so on.  I haven't tested it so this answer is not guaranteed.


« Last Edit: 06 Mar 2004, 22:36:00 by macguba »
Plenty of reviewed ArmA missions for you to play

BibiPhoque

  • Guest
Re:Script Question
« Reply #4 on: 06 Mar 2004, 22:34:27 »
Oops sorry, I thought you'd know what to do after that  ;)
Thanks a lot macguba, I didn't expect someone here to care about my script, except Neal of course... That's very nice of you =)
By the way, I don't know why, the chopper won't move to a position too far away (for example, on nogova, he won't move from one airfield to the other with that script). So you have to put extra gamelogics to go from one airfield to another.

I changed the _time variable, which is already used by ofp.
« Last Edit: 07 Mar 2004, 00:07:14 by BibiPhoque »

Neal

  • Guest
Re:Script Question
« Reply #5 on: 07 Mar 2004, 01:26:10 »
Little problem :(



BibiPhoque

  • Guest
Re:Script Question
« Reply #6 on: 07 Mar 2004, 02:06:29 »
oops little mistake, corrected :D

Neal

  • Guest
Re:Script Question
« Reply #7 on: 07 Mar 2004, 02:56:41 »
Thx. Works excellent.

Neal

  • Guest
Re:Script Question
« Reply #8 on: 07 Mar 2004, 03:31:35 »
Ok... after a little bit they start to bug out. One just shut off its engine and waiting 1 minute then went. Another waited too long. Also when I loaded them up at GL2 it wouldnt take off.
« Last Edit: 07 Mar 2004, 03:33:17 by Neal »

BibiPhoque

  • Guest
Re:Script Question
« Reply #9 on: 07 Mar 2004, 12:48:01 »
Hmm.... Sounds strange, but I noticed that too... But as I said, is seems that if two consecutive GLs are too far away from eachother, the chopper won't take off. In fact, if they are too close, it does exactly the same... I think.
It goes beyond my skill to bypass this... Sorry...didn't try the DisableAI command though...
Edit: it's possible that the line :

@getpos _heli select 2 < 1

makes trouble, because the chopper's altitude must go below 1 before waiting _waittime. In some cases, if the ground isn't flat for example, altitude can be equal to 1 or even superior although the chopper has landed. I changed that line to :

@getpos _heli select 2 < 2
« Last Edit: 07 Mar 2004, 12:57:07 by BibiPhoque »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Script Question
« Reply #10 on: 07 Mar 2004, 14:13:08 »
doMove commands don't work for chopppers if the distance is too large.  You have to use intermediate GLs.
Plenty of reviewed ArmA missions for you to play

Neal

  • Guest
Re:Script Question
« Reply #11 on: 07 Mar 2004, 21:46:34 »
Is it possible to send another helicpter (or2) to GL3 then 4 instead of 1 then 2? So like 2 helicopters follow GL 1 and 2 and 2 other helis follow 3 and 4.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Script Question
« Reply #12 on: 07 Mar 2004, 22:26:50 »
Yes of course.   I get the impression that you're just starting to get to grips with scripting (which is fine) so if you haven't already read them I strongly recommend snYpir's Friendly Intro to Code Snippets and also Johan Gustafsson's Scripting Guide.

You can use this script for as many choppers as you want, each with any set of GLs that you want.  That is one of the reasons it was written the way it was written:  it is very flexible.   So you might have:-

[heli1, [GL1,GL2] ] exec "heli.sqs"

[heli2, [GL1,GL2] ] exec "heli.sqs"

[heli3, [GL3,GL4] ] exec "heli.sqs"

etc

Plenty of reviewed ArmA missions for you to play

Neal

  • Guest
Re:Script Question
« Reply #13 on: 09 Mar 2004, 01:04:08 »
New Question:

Trigger wise

About... 3 min after the mission started I want a msg to appear and a marker on the map appear as well. And a helicopter starts up and waits for a squad to board. Once aboard goes to a certain spot and lands. Gets everyone off and heads back.

Also:

When a group lets say a guy named "bob" walks in to a trigger zone and suddenly a msg appears and a helicopter comes in and picks them up. How?

And:

How would I make a guy not part of the squad get in to the helicopter that lands after the helicopter lands from the last question.
« Last Edit: 09 Mar 2004, 01:08:33 by Neal »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Script Question
« Reply #14 on: 09 Mar 2004, 01:38:42 »
Head over to the Ed Depot and read up on triggers, switch triggers in particular.

1)  Trigger, synchroed to waypoint(s) controlling the chopper crew and cargo groups:-

Countdown:  180    180   180
Condition:  true
Type:  Switch
On Activation:   hint "blah"; "marker1" setMarkerType "objective";


2)  Assuming bob is west... synchro with waypoints again

Activation box:  West present
condition:  bob in thislist
On activation:  whatever


3)  Clear your head:  the group getting into the chopper isn't "special", it isn't fundamentally related to the chopper.  You can have as many groups as you like getting in and out of a vehicle as many times as you like.    Also, make your question more specific:  is this loon in a group on his own?  Or is leaving the group?   Or is he stayingin the group but going in the chopper while the rest of the group stay behind?

Plenty of reviewed ArmA missions for you to play

Neal

  • Guest
Re:Script Question
« Reply #15 on: 09 Mar 2004, 01:47:16 »
Rescue mission. The one squad has to rescue the pilot. Once there a helicopter is activated with a text trigger and then the pilot goes to the chopper when it lands.

Neal

  • Guest
Re:Script Question
« Reply #16 on: 11 Mar 2004, 00:14:08 »
Alright nvm about the pilot rescue guy. Just have the heli come and pick them up. How? lol

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Script Question
« Reply #17 on: 11 Mar 2004, 00:18:12 »
It's all triggers:  you need to read a good general tutorial on triggers and also the one specifically on switch triggers.

In the Tutorial Mission (tutes - Getting started) there is a radio call for chopper CAS:  in that case it's trashing a tank rather than picking somebody up, but the principle is the same.

Getting choppers to do exactly what you want is tricky - they are just the awkward bastards of OFP.  Fortunately there are specific tutes on this too.

As an alternative, use snYpir's SP/MP support pack.    Can't remember if it does chopper extractions, it probably does.   In the Ed Depot under mods, on the left hand menu column.
Plenty of reviewed ArmA missions for you to play