Home   Help Search Login Register  

Author Topic: Units join me, hang out, then leave?  (Read 1163 times)

0 Members and 1 Guest are viewing this topic.

Offline eegore

  • Members
  • *
Units join me, hang out, then leave?
« on: 27 Nov 2008, 11:09:18 »

  Ok so in an attempt to pull about 80 triggers out of one of my missions I need to figure out a way to get everyone in my group to leave it when I enter a specific area. 

  The idea is that I fly around picking up soldiers and then drop them off at a staging area.   

  For pickups I named every soldier on the map and then gave every single one of them a trigger that says:   [soldiername] join group player 

  Perhaps there is a more efficient method to doing this.  Note: All of the soldiers are in 2 man groups.  I never managed to get a group join command to work so I had to ue a seperate trig for everybody. 



  As for dropping men off I have a trigger for each soldier that is a:   join grpnull    as they enter the staging area.  This of course means I must land outside the staging area tell them to disembark and run into the staging area so they leave my group. 

  This amounts to around 80 or so triggers total sitting around this staging area.  I tried to see if I could use a "repeatedly" radio command to Join grpnull my men but to no avail.

  So is there a way to possibly get the soldiers I pick up to be more autonomous?  Such as getting in the chopper when I fly to them, then disembarking when I fly into the staging area on thier own?  This would lighten the trigger load in my mission greatly. 

  Thanks for reading.

Walter_E_Kurtz

  • Guest
Re: Units join me, hang out, then leave?
« Reply #1 on: 27 Nov 2008, 23:00:42 »
The stuff in between square brackets are arrays, which is fancy programmer-talk for a list; and the thing about lists is that there can be more than one thing on them, so:

Code: [Select]
[soldiername1, soldiername2] join playerassumes the player is on his own or in command of his group - hence group player is unnecessary.



As for re-writing the whole thing, here's what I'd do:
1. name the player's helo, let's say chopper

2. triggers around the 2-man groups, give them names such as trig_grp_1. Make the triggers activated by the helo
(press F2 and then left-click-and-drag from the helo onto the trigger. When you edit the trigger, this list should read Vehicle, Group, Leader, Whole Group, etc. Select 'Vehicle')
once, present,
condition:
Code: [Select]
this && ((soldiername1 distance chopper) < 10)on activation:
Code: [Select]
soldiername1 assignAsCargo chopper; soldiername2 assignAsCargo chopper; [soldiername1, soldiername2] orderGetIn true; deleteVehicle trig_grp_1Make sure the soldiernames and trigger names are appropriate for each trigger.

3. place two triggers where the helo should land by the staging area, both triggered by the helicopter 'Vehicle' as above.
The first and slightly larger one should be: Vehicle, NOT Present, Repeatedly,
on activation
Code: [Select]
LZ_Active=true
4. the smaller, inner one should be Vehicle, Present, Repeatedly,
condition:
Code: [Select]
this && LZ_Activeon activation:
Code: [Select]
LZ_Active=false; [] exec "disembark.sqs"
5. create the disembark.sqs script in the mission folder:
Code: [Select]
#start
_wherechopper = getPos chopper
_height = _wherechopper select 2
? (_height > 5): goto "start"

unassignVehicle soldiername1
unassignVehicle soldiername2
...
list all the named soldiers that are to be transported
...
exit



The scheme is:
the helo gets to the 2-man groups, and within 10 metres of one of the men (ie. is landing)
the two men are told to get aboard
whilst outside the staging area, LZ_Active is true
as soon as the helo gets to the staging area, the disembark.sqs script is run and LZ_Active set to false (to prevent the script running twice)
on getting down to five metres above the ground, the men are told to get out

Offline eegore

  • Members
  • *
Re: Units join me, hang out, then leave?
« Reply #2 on: 28 Nov 2008, 08:29:12 »
  Thank you for looking this over. 

  I started a new mission and set things up as described above and everything works well.  Typing in 40 soldiers names into one script is better than typing out 40 triggers anyday. 

  Of course I had to play with the setup and had a question:   

If I place a trig grouped to the chopper right above Soldier1 that instructs him to enter the chopper when it is less than 10 meters away then it works fine because the chopper activated the trig by entering the trig perimiter and landing close to the soldier.  But if I place the trigger over the chopper's starting location and THEN fly to Soldier1 he wont get in.  I am assuming this is because simply crossing the trigger's perimiter isn't meeting the criteria of being present AND being within 10 meters of the soldier simultaneously. 

  Am I correct there?  I must be inside the trigger and near the soldier at the same time.   I thought maybe activating the trigger with the chopper's presence would tell the soldier to load-up whenever the chopper arrives. 

  Man I hope that makes sense.
« Last Edit: 28 Nov 2008, 08:32:24 by eegore »

Walter_E_Kurtz

  • Guest
Re: Units join me, hang out, then leave?
« Reply #3 on: 28 Nov 2008, 16:29:52 »
Correct. All conditions must be true for the trigger to trip. The reason for using more than one condition is so that the trigger isn't tripped by just flying through it - the men would end up running along the ground following the chopper, no matter how far away they were.

Demo of a seriously improved version appended: typing a long list of all the troops was a waste of effort, sorry (but haha, anyway)

Init.sqs
Code: [Select]
LZ_Active=true
[] exec "ChopperHeight.sqs"

exit

ChopperHeight.sqs
Code: [Select]
#Begin
ChopperAltitude = getPos chopper select 2
~0.5
goto "Begin"

exit

Disembark.sqs
Code: [Select]
CargoList = (Crew Chopper) - [Driver Chopper] - [Gunner Chopper]

"unassignVehicle _x" foreach CargoList

"_x DoMove getPos RallyPoint" forEach CargoList

exit


Change the condition for troops to get in to:
Code: [Select]
this && (ChopperAltitude < 5)
Change the condition at the LZ to:
Code: [Select]
this && LZ_Active && (ChopperAltitude < 5)
Create a marker or object (in the demo mission it's a flag) named 'RallyPoint'. Troops will move there after disembarking.



Update: conditions for triggers can be refined further (see HeloTaxi2.zip):

For pick-up points, the condition should be amended to:
Code: [Select]
(soldiername1 distance chopper) < 10then the vehicle activation part can be ignored, it's dimensions can be reduced to 0 and it doesn't matter where it's located.

For the LZ, name the trigger LZone, and amend the condition to
Code: [Select]
LZ_Active && ((LZone distance Chopper) < 5)likewise, since 'this' is no longer part of the Condition, the trigger setup is immaterial.

ChopperHeight.sqs and the reference to it in Init.sqs can be removed.
« Last Edit: 28 Nov 2008, 17:51:19 by Walter_E_Kurtz »

Offline eegore

  • Members
  • *
Re: Units join me, hang out, then leave?
« Reply #4 on: 29 Nov 2008, 14:17:47 »

"typing a long list of all the troops was a waste of effort, sorry (but haha, anyway)" 

  What?  So my list of soldiers:

Soldier1
Kraven Morhed
Mike Hunt
Soldier2
Holden Mgroin
Haywood Jablomee
etc.
etc...

 was just a waste of time?  Damn. 

  The mission samples really help.  I'm not much of a copy/paste kind of guy but nothing beats a mission to reference when an idea eludes you. 

  I'll play around with these and see what I can do.   Thanks.