Home   Help Search Login Register  

Author Topic: Another chopper extraction thread / check if not in vehicle  (Read 4374 times)

0 Members and 1 Guest are viewing this topic.

Offline Undeceived

  • Members
  • *
    • My missions and campaigns
Hi, as a dedicated newbie in editing / scripting I always try it on my own first and then use the search function :) But even after repeated and extensive searches I could not find the right topic for this...

Just jump over the whole story, maybe it's not so important... goto "What I need". Just the red colored line is of importance, as far as I see the case.

What I have done so far:
I use the script land.sqs to make the chopper land. The script contains the simple line:

"helimission land "land";
exit"

And this works well, the chopper moves down on the invisible helipad. All right so far.
But now the problems begin.
The group to be extracted is 2 soldiers, the player and an AI.


Problem 1:

When I command the AI "2, get in that chopper!" while the chopper is still in the air the following will happen:
The chopper will touch the ground and lifts up again immediately to aprox. 20 m height, where it will stay, no matter what I do (excepting, I shot the pilot out ;) ).

To prevent this, I read in the forum that you can setfuel 0, when the helo touches the ground. Just to prevent the chopper to fly away without having loaded the troops.

Problem 2:

I set the fuel of the chopper = 0 when it has height < 2. But in this case, when the chopper hits the ground, the pilots will jump out the machine, which is pretty unrealistic... No pilot in an extraction mission will get out the chopper to see whats happening around :)

What I need:

I think, an easy way to solve this is to beam the pilots in the helo again, when they leave it. I just need the right syntax to check if a unit in not in a vehicle. And this one I could not find in the forums :) Only saw "check if the unit is in vehicle"... I tried it with the following script, but got an error message:


#LOOP
?!pilot1helimission in helimission : goto "CONTINUE"
goto "LOOP"

#CONTINUE
pilot1helimission moveindriver helimission;

exit

Can you show me the mistake?
Thank you!!
« Last Edit: 11 Feb 2008, 16:58:30 by Undeceived »
Current project: Black Lands (Arma 3)

Offline Loyalguard

  • Former Staff
  • ****
Re: Another chopper extraction thread / check if not in vehicle
« Reply #1 on: 11 Feb 2008, 17:57:17 »
Undeceived-

What you are looking for is the crew command.  So, try this (excuse my sqs as I am only an sqf guy):

Code: [Select]
#LOOP
?! pilot1helimission in crew helimission : goto "CONTINUE"
goto "LOOP"

#CONTINUE
pilot1helimission moveindriver helimission;

exit

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Another chopper extraction thread / check if not in vehicle
« Reply #2 on: 11 Feb 2008, 21:24:17 »
Actually, Loyalguard, you can use the in command with respect to an element in an array or an object in a vehicle, so either version of the script is equivalent.

As another "pure" SQFer, I might be wrong, but one problem is that there isn't a delay in the loop, so the game would freeze if it was run (until the pilot got out). The other issue would be that the script just pulls the pilot back into the helo once. However, since the pilot AI obviously wants to get out, even if the script ran without an error, the pilot would get out, get put back in, then get out again. I think you probably need to put him back in every time he is seen out of the helo. In effect, you are moving him back inside, not telling his AI that he actually wants to stay inside.

Code: (SQS) [Select]
#LOOP
?! pilot1helimission in helimission : goto "CONTINUE"
; Stop the loop from freezing the game by putting a small delay in, so other scripts can run at the same time.
~0.01;
goto "LOOP"

#CONTINUE
pilot1helimission moveindriver helimission;

; Loop back and wait until the pilot tries to get out again.
goto "LOOP"

Here is the same thing in SQF (because I think SQF it is considerably cleaner once you get past purely linear scripts, and it is never too late to move to SQF):
Code: (SQF) [Select]
while (true) do
{
    waitUntil { ! pilot1helimission in helimission };
    pilot1helimission moveindriver helimission;
};

Unfortunately, what I'm seeing are logic errors (which would make the script not work as you intend), not syntax errors that would raise errors. Not sure what is going wrong from the info I've been given...

(incidentally, if you get an error message when running code, it makes it considerably easier for us to work out what is wrong if we know what the error is, since the messages are invariably useful, if not always completely enlightening. Can help if you write it down manually or just copy and paste if from the ArmA RPT file, where errors are recorded).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Another chopper extraction thread / check if not in vehicle
« Reply #3 on: 13 Feb 2008, 03:26:12 »
I'm not sure if this works on drivers or pilots, but when chopper height is < 2, you might try this:

dostop pilot;
pilot disableAI "MOVE";

After passengers loaded, you then do this:

pilot domove destinationPos;
pilot enableAI "MOVE";

Exact syntax not guaranteed...  destinationPos would be a position you want pilot to move to after passengers loaded.
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Tajin

  • Members
  • *
Re: Another chopper extraction thread / check if not in vehicle
« Reply #4 on: 13 Feb 2008, 17:09:14 »
As far as I know this should also very much be possible using simple waypoints. Especially when you synchronize them.

Anyway disableAI should do the trick. Setfuel 0 will always make them jump out, no matter what (unless maybe if you lock the vehicle from outside xD). Well, who wants to stay in a chopper that has no fuel ?

Offline Undeceived

  • Members
  • *
    • My missions and campaigns
Re: Another chopper extraction thread / check if not in vehicle
« Reply #5 on: 13 Feb 2008, 17:25:22 »
Thanks to all, I will try it!

Thanks!  :yes:
Current project: Black Lands (Arma 3)

Offline Undeceived

  • Members
  • *
    • My missions and campaigns
Re: Another chopper extraction thread / check if not in vehicle
« Reply #6 on: 15 Feb 2008, 19:45:06 »
Hi guys.

Johnnyboy's idea actually did work, at least partly. The pilot really did stay in the chopper. But unfortunately the other one did not...
What I didn't mention: The second pilot actually isn't a pilot, but I put him as cargo in the cockpit of the Littlebird (for cutscene purposes). And he still jumps out after the chopper has got less than 2 meters height and then he stops (instead of running some meters without the pilot disableAI "move" command).

As it looks, I still will need a script that checks if a unit is not in a vehicle...

(incidentally, if you get an error message when running code, it makes it considerably easier for us to work out what is wrong if we know what the error is, since the messages are invariably useful, if not always completely enlightening. Can help if you write it down manually or just copy and paste if from the ArmA RPT file, where errors are recorded).

Hi Spooner.

Here I got the error that appears when the scripts from my first post runs. Unfortunately it also runs with the newer version, that Loyalguard wrote...

' |#| !pilot1helimission in helimission : goto "CONTINUE" '
Error !: type object, expected Bool                                  -----> I hope that this is the right translation of the error, as I'm running the german version of the game. But I assume you know all the errors :)


Well, who wants to stay in a chopper that has no fuel ?
Yes, you're right  :D
« Last Edit: 15 Feb 2008, 20:08:11 by Undeceived »
Current project: Black Lands (Arma 3)

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Another chopper extraction thread / check if not in vehicle
« Reply #7 on: 15 Feb 2008, 21:40:42 »
Glad I could help.  You're getting close!

Try this on the co-pilot:

copilot DisableAI "ANIM";

Hopefully this will keep his stuck in the sitting animation in the chopper.

When done, you can reenable him:

copilot enableAI "ANIM";


El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline lebson506th

  • Members
  • *
Re: Another chopper extraction thread / check if not in vehicle
« Reply #8 on: 16 Feb 2008, 14:19:18 »
Undeceived, try this

Code: [Select]
!(pilot1helimission in helimission) : goto "CONTINUE"
According to syntax you were saying "Not pilot1helimission" rather than "pilot1helimission not in helimission"

Hence expected boolean, got object.

Offline Undeceived

  • Members
  • *
    • My missions and campaigns
Re: Another chopper extraction thread / check if not in vehicle
« Reply #9 on: 20 Feb 2008, 15:39:09 »
Thanks guys, I'll try it and answer here then. (I'm pretty short in time these days...).  :)
Current project: Black Lands (Arma 3)

Offline Undeceived

  • Members
  • *
    • My missions and campaigns
Re: Another chopper extraction thread / check if not in vehicle
« Reply #10 on: 29 Feb 2008, 15:26:56 »
Hi all!

Well... I tried it and   :shhh: ...It didn't work  :(

I repared that I must use the setfuel 0 command when the chopper gets height < 2, because if I don't use it, it will fly up in the air right after my fellow AI boards it, leaving me on the ground... Just another bug (or feature)...

(Just for recapitulation -> By using "chopper setfuel 0" the pilots will jump out of it. But they should stay in the chopper and wait for my signal (radio call) to take off and fly to destination.)

The Code provided by lebson506th caused an error but this time at least it was an different error :)


'!(pilot1helimission in helimission) |#| : goto "CONTINUE"'
Error:: type Bool, expected Switch

(Recapitulation: I want to use this command to detect, when the pilot and the co-pilot are not in the vehicle. After this I would beam them in again, so that nobody notes it...  :whistle:)

Considering that I have to use the setfuel 0 command, the DisableAI commands "MOVE" or "ANIM" unfortunately also didn't work, they always jump out of this chopper.

Phew... I reached my wit's end here, don't know what to do.  :D
Isn't there any correction for the "check if pilot is not in chopper" - command? All points in the direction that I need this thingy.

Help would be very appreciated! Anyway, thanks for your ideas!!
« Last Edit: 29 Feb 2008, 15:33:38 by Undeceived »
Current project: Black Lands (Arma 3)

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Another chopper extraction thread / check if not in vehicle
« Reply #11 on: 29 Feb 2008, 20:26:52 »
Just a quick question is the squad going to be waypointed to load in the helo?  If so i managed to get the chopper to come in and land on the heli pad then wait till group is onboard before continuing.  Not sure if this is what your after (pob not) but hey here we go.

Obviously name the chopper and heli pad, for this i will use Helo and Pickup...

Start the chopper whereever, put a MOVE waypoint on the heli pad then in the init; Helo land "Pickup"; Helo flyInHeight 0;

This will get the chopper to land and stay on the ground (simple eh)

Next put a LOAD waypoint for the chopper very close to the move waypoint, in the init put; Helo flyInHeight 30;  then syncronise this with the group's GET IN waypoint.

Finally continue with the helo's waypoint's.

This probably isnt what your looking for, and it probably wont work in mp (not tested), but you never know.

Does anyone know if someone has converted Snypirs quick chopper landing script from OFP? Because that was very helpful.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Another chopper extraction thread / check if not in vehicle
« Reply #12 on: 29 Feb 2008, 20:49:48 »
Please review the Land command.


Planck
I know a little about a lot, and a lot about a little.

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Another chopper extraction thread / check if not in vehicle
« Reply #13 on: 29 Feb 2008, 21:41:06 »
Admittedly the chopper does try n stop its engines when it lands, but if your in quick enough its fine, also because of the flyinheight 0 it starts up straight away n remains on the deck.

Offline Undeceived

  • Members
  • *
    • My missions and campaigns
Re: Another chopper extraction thread / check if not in vehicle
« Reply #14 on: 04 Mar 2008, 21:33:30 »
Just a quick question is the squad going to be waypointed to load in the helo? 

No, unfortunately the squad is not waypointed in the editor... I could set a new waypoint in the scripts, but then it would be impossible to sync both waypoints (of the chopper and the sqad), as far as I know. Well, it would be perfect for the evac, but there are no waypoints at this part of the mission... :(

@ Planck:

I already tried the Land command earlier, unfortunately it didn't work either. See my first post, there I described the problem.
« Last Edit: 04 Mar 2008, 21:48:01 by Undeceived »
Current project: Black Lands (Arma 3)