OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: The-Architect on 08 Jun 2007, 19:03:54

Title: Group in UH60
Post by: The-Architect on 08 Jun 2007, 19:03:54
Ok, I want some code which will check if my entire group is in a UH60.

I tried,
Code: [Select]
(mygrp in uh60)
but it didn't work. What syntax should I use?

Right now the check is done in a trigger but I can easily write a script if needs be.

P.S. my group is called mygrp and the blackhawk is called UH60.
Title: Re: Group in UH60
Post by: Mr.Peanut on 08 Jun 2007, 20:32:43
Code: [Select]
({_x in myHeli} count units myGrp) >= ({ alive _x} count units myGrp)
Title: Re: Group in UH60
Post by: DucusSumus on 08 Jun 2007, 21:51:09
You don't want to use crew.  That will return an array with only the driver and first gunner.  Other than that, Mr. Peanut's code should work.

Alternatively, you could just use this function: http://www.ofpec.com/ed_depot/the_files/OFPResources/functions/groupInVehicle.sqf
Title: Re: Group in UH60
Post by: Mr.Peanut on 08 Jun 2007, 23:58:09
Ack. Thanks for the catch ducus. Have fixed above and shame on me for not knowing about that function!
Title: Re: Group in UH60
Post by: The-Architect on 09 Jun 2007, 01:27:59
How do I call this and what bits do I need in my .sqf for just the specific vehicle part?
Title: Re: Group in UH60
Post by: Mr.Peanut on 09 Jun 2007, 02:03:03
My snippet should work....

If you want to use the function then in your init.sqf:
Code: [Select]
groupInVehicle = compile preprocessFile "groupInVehicle.sqf";
To call the function for a group and vehicle:
Code: [Select]
[myGroup, myVehicle] call groupInVehicle
If you do not specify a vehicle the function checks to see if all units are in any vehicles:
Code: [Select]
[myGroup] call groupInVehicle
The function returns true or false, so you can simply put that snippet in the Condition for a trigger.
Title: Re: Group in UH60
Post by: The-Architect on 09 Jun 2007, 02:39:09
Nope, I can't get my head around it.

Is it possible that you or somebody could do a small sample mission where a Helo picks up a group of guys?
Title: Re: Group in UH60
Post by: Mr.Peanut on 09 Jun 2007, 03:37:10
urp
Title: Re: Group in UH60
Post by: h- on 09 Jun 2007, 08:31:10
You don't want to use crew.  That will return an array with only the driver and first gunner.
Nope, not entirely true.
Crew will return everybody inside the vehicle, it returns them in order of [commander(if available),diriver,gunner(if available),cargo1,cargo2,...cargoN]..

If you think I'm wrong, test it ;)


@Archy, it's quite simple actually..

Put up a trigger, size 0/0
Condition: call {{_x in uh60} forEach (units mygrp)}

Just tested that myself and it works just fine..

No need for scripts nor functions (didn't check Mr.Peanut's sample)...
Title: Re: Group in UH60
Post by: DucusSumus on 09 Jun 2007, 09:51:00
I believe you, h-.  Biki must have had it wrong then.  Either way, in by itself will work. 
Title: Re: Group in UH60
Post by: h- on 09 Jun 2007, 09:59:53
There's a slight 'feature' in the crew command though, the 2nd 'door gunner' seems to be returned as cargo..

This is what the crew 'prints' with a ungrouped UH60
Quote
[uh60d,uh60g,WEST 1-1-A:3]
Title: Re: Group in UH60
Post by: The-Architect on 09 Jun 2007, 17:01:42
Ok, the small script line worked. The Helo jumped up and landed about 50m away after I ordered my guys to get in but I'll accept that. Much as it pains me.

I'm just glad they are almost doing as they're told now. Cheers fellas.

I'll lave this open in case someone figures out a way to stop the chopper taking off and landing again after the getin order.
Title: Re: Group in UH60
Post by: Mr.Peanut on 09 Jun 2007, 19:37:02
I tested crew last night, and it did not return the units in cargo. It may have in OFP, but not in ArmA. The units were in their own group. Someone is welcome to prove me wrong. Post your mission demo that does so.

I guess the second door gunner would also not be returned by the gunner command. Someone put in a request for a gunner2 command.
Title: Re: Group in UH60
Post by: h- on 09 Jun 2007, 20:05:15
Quote
it did not return the units in cargo
That's strange because when I tested this just before I made my post the hint output was mile long.
And still is.. Unless the chopper had 9 additional gunners that must be the cargo listed there.. ::)

Even the line unitName in (crew chopper) returns true after the group has boarded the chopper as cargo.

I have now tested this 80 times and it has worked each time so it must be your tests that were faulty.. :dunno:

Quote
The units were in their own group
So? ???


My test mission attached.
Radio 0-0-1: displays hint format ["%1",crew chopper],set to repeatedly
Radio 0-0-2: Teleports the group into the chopper (moveInCargo)
Radio 0-0-3: Makes the chopper pick up the group (with the amazing OFP/ArmA style)

And in each case every single soldier is returned in the hint output.
when the leader is in the crew (as cargo) of the vehicle a global chat is displayed.
Title: Re: Group in UH60
Post by: Mr.Peanut on 09 Jun 2007, 22:51:11
No problem. It's funny cause on BIS forums I placed code using crew and was told I was stewpid, so I did a quick test and thought I was. Now I know I was not stewpid then, just when I tried my test. Ahhhh. wait a sec.

I used unit inits to move into cargo i.e. in leader's field {_x moveInCargo myHeli} forEach units group this
and put the hint display in the player's init.  Maybe the hint processed first?

In any event, I much prefer being stewpid here than on BIS forums; I am happy to know some other dumb love there was wrong when calling me wrong when I was right. Right?
Title: Re: Group in UH60
Post by: h- on 09 Jun 2007, 23:54:34
Quote
Maybe the hint processed first?
That might be possible..

Quote
I am happy to know some other dumb love there was wrong when calling me wrong when I was right. Right?
Quaranteed satisfaction  :D

I was just a bit bafled about what you said because I just saw it working..
I already started to think whether the command was fixed in the fixed 1.07 beta version or something..  :P
Title: Re: Group in UH60
Post by: LCD on 10 Jun 2007, 01:42:55
Ok, the small script line worked. The Helo jumped up and landed about 50m away after I ordered my guys to get in but I'll accept that. Much as it pains me.

I'm just glad they are almost doing as they're told now. Cheers fellas.

I'll lave this open in case someone figures out a way to stop the chopper taking off and landing again after the getin order.

u cud remove da chopers fuel... nd add it after deyre in

LCD OUT
Title: Re: Group in UH60
Post by: The-Architect on 11 Jun 2007, 19:09:19
I'm having trouble again.
I got to the end of my mission and called for extraction and the helo took twice as long to arrive this time, and when it did, it landed 500m away and the crew jumped out. Then they got back in, flew to me and then just sat there doing nothing. Grr.

Title: Re: Group in UH60
Post by: Mr.Peanut on 12 Jun 2007, 18:18:54
Maybe you should have taken a bath
Title: Re: Group in UH60
Post by: h- on 12 Jun 2007, 19:52:53
Peanut, even if you're in the staff that doesn't mean you're allowed to spam  :cop:

@Architect
Does that happen every single time?
Does it happen with the latest version of the game (1.08)?
Title: Re: Group in UH60
Post by: The-Architect on 13 Jun 2007, 05:01:18
dunno about 1.08, will check on the morrow.
Title: Re: Group in UH60
Post by: The-Architect on 13 Jun 2007, 16:21:47
Nope, still being a pain. This time it went off to target bad guys even though it was set to careless.
Title: Re: Group in UH60
Post by: bedges on 13 Jun 2007, 17:46:01
archie, even if you're in the staff that doesn't mean you're allowed to double post  :cop:

tsk tsk...
Title: Re: Group in UH60
Post by: The-Architect on 13 Jun 2007, 18:08:57
Ah. I always thought a double post was when you somehow had two posts the same one after the other. Like you see now and again in forums. I didn't know, that  ::) was one too. Soz.

Anyway. I decided to forget trying trial and error and have been having a go at updating SnYpir's extraction scripts. Really all I've had to do so far is edit the mission.sqm so that ArmA recognises the demo mission. I'll post the updated demo mission later so others can use it for ArmA.