Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
hoizen

JIP Helicopter insertion

Recommended Posts

Hello Arma 2 forum goers,

I'm fairly new to the syntax of Arma 2 scripting and would like to request the assistance of much more seasoned scripters on my JIP concept.

What I am looking to do is allow players to JIP but spawn into some sort of chopper which will spawn in air when a player connects and proceeds to transport the player to a designated LZ and then promptly take off and despawn. Any players that JIP when the chopper has already spawned for another player should also spawn into the same chopper. I am still in the process of piecing together the logic and pseudo code for such a script but I know that my scripting experience will be much more enjoyable by receiving ideas tips and suggestions from all of you gents.

Thanks for your precious and priceless time, oh wonderful arma scripting gods.

Share this post


Link to post
Share on other sites

Well, the spawning on JIP and getting the player into the heli is not a problem, you can use the init.sqf for spawning and stuff, but it will be quite hard to get other JIPed players into the helo - the timing has to be spot on.

This is an interesting task though so I'll try to fix some code in the next hours :D

Until then, here are my thoughts: On every player who joins your game, check if the helo has enough capacity to hold that additional player, check if the helo is under a specific distance to the landing point or if the helo already landed, disembarked and is on its way to disappear.

Place the player into the cargo of the helo if the checks succeed, else create a new helo, put two AI players into it (pilot and co-pilot), assign two Waypoints to them: "LAND" at the location where it should land and "MOVE" afterwards to get out of sight and disappear.

Once the helo has landed at the landing area, forcefully eject all players out of the helo and proceed to the "MOVE" waypoint. Once the helo reaches the MOVE-waypoint, delete the AI-players and the helo.

It wouldn't hurt to make the helo invincible, no one enjoys a game where you die just seconds after you get into the game :D

Okay, here you go, I made two example missions: http://ul.to/0i7hh4wj

The first one is the heli taxi one you wanted, the second one will just eject all playable units when over the landing zone.

I didn't (or rather couldn't) test if this is working in MP, just ask some friends of yours and try the hell out of it :D

Edited by XxAnimusxX

Share this post


Link to post
Share on other sites

Jumped into MP with one other. For myself, a chopper spawned and worked perfectly. However, the second player in the server was spawned with his own chopper which followed right behind. When my chopper was landing, the other player's chopper hovered in place until the player disconnected. JIPing resulted in spectator camera. Really good progress though you pumped these out really fast. Very impressive.

I'm in the process of moving so once I get setup in the new home I'll open up your script and see what I can do(Thank you for adding comments). I'll post my results when I can.

Share this post


Link to post
Share on other sites

Well the problem is the timing :S When you and your bud are logging in at the (almost) same time, it will result in this outcome.

There are no synchronisation commands like in usual programming languages (mutex, semaphor), so these things are bound to happen.

You could use a short sleep to give the other player the time to spawn the helos, something like this in your init.sqf:

if (!isDedicated) then
{
waitUntil {!isNil "bis_fnc_init"};

       if ({isPlayer _x} count playableUnits > 1) then
       {
          sleep 2;
       };
execVM "spawnOrMountHeli.sqf";
};

Okay, just to test this out and have meaningful result, try the following:

Start the server, login, then:

  1. Let your friend join after ~3-4 seconds (you should place the spawnHeliStart-Marker at quite a distance so you have time to test this).
  2. Let your friend login at the same time, trying to recreate the problem.
  3. Wait until you're less than 100m away to the landing area, let your friend join. He should get his own heli now.
  4. Wait until you disembarked from the heli and its flying off. Let your friend join now. He should again get his own heli.

And to test the extreme: Use a small heli with just 1~2 additional cargo places and fill it up with players.

When someone else joins he should get his own heli regardless of any conditions the former heli was bound to.

Share this post


Link to post
Share on other sites
Hello Arma 2 forum goers,

I'm fairly new to the syntax of Arma 2 scripting and would like to request the assistance of much more seasoned scripters on my JIP concept.

What I am looking to do is allow players to JIP but spawn into some sort of chopper which will spawn in air when a player connects and proceeds to transport the player to a designated LZ and then promptly take off and despawn. Any players that JIP when the chopper has already spawned for another player should also spawn into the same chopper. I am still in the process of piecing together the logic and pseudo code for such a script but I know that my scripting experience will be much more enjoyable by receiving ideas tips and suggestions from all of you gents.

Thanks for your precious and priceless time, oh wonderful arma scripting gods.

I have a chopper in 1 of my missions that does just that, but I use if for respawn option when available.

so in mine, only 1 player is ever in helo, but feel free to modify if want.

/*
                insertion chopper / player spawned option
chopper will insert and land in hot LZ with gunners shooting at enemy
===============================================
 call with: _nul = [this] execVM "insertion.sqf";

must make sure that "transporthelo2" is not already on map before calling another. if more then 1 is on map they will not delete.
then of course when another spawns in, it spawns on the other 2 at end waypoint and all blowup :)	
*/

waituntil {!isnil "bis_fnc_init"};

_unit = _this select 0; // who called it.
_chopperType = "UH60M_EP1";  // Type of transport.
_start = getMarkerPos "in1";  // location of start/spawn/delete location - all the same marker.
_end = getMarkerPos "out1";  // location of drop off unit.


// Spawn the helo, - ***Set correct starting direction manually (-320)***
_ch = [[_start select 0, _start select 1, 50], -320, _chopperType, WEST] call BIS_fnc_spawnVehicle;

// Name the helo globally so that waypoint orders will work.
transporthelo2 = _ch select 0;
_chGroup2 = _ch select 2; // group of helo so waypoints work.
_chGroup2 setBehaviour "CARELESS"; // Make sure they don't get distracted.
//transporthelo2 setCaptive true; // uncomment this to make your ride safe.

_ch select 0 setVehicleInit "transporthelo2 = this; this setVehicleVarName ""transporthelo2""";
processInitCommands;

// move in unit that called script.
_unit moveInCargo transporthelo2;

// and create landing spot for dropoff.
_lzDropOff = "HeliHEmpty" createVehicle _end;

wp0 = _chGroup2 addwaypoint [_end, 20];
wp0 setwaypointtype "TR UNLOAD";
wp0 setWaypointSpeed "NORMAL";
wp0 setWaypointStatements ["","transportHelo2 land ""GET OUT"""];

// Wait till the player's group is out of the helo.
waitUntil{{_x in transporthelo} count units group _unit == 0};

// Once they are out, set a waypoint back to the start and clean up by deleting the helo and landing pad.
wp1 = _chGroup2 addwaypoint [_start, 150];
wp1 setwaypointtype "MOVE";
wp1 setWaypointStatements ["true","{deleteVehicle _x} forEach crew transporthelo2; deletevehicle transporthelo2;"];
deleteVehicle _lzDropOff;


look at notes at top of script - make SURE that only 1 chopper is on map at a time. because it is named "transporthelo2", if more then 1 exists none will delete at spawn marker and then the next 1 that spawns in will blow them all up at spawn position.

Edited by Nimrod_Z

Share this post


Link to post
Share on other sites

Okay, just to test this out and have meaningful result, try the following:

Start the server, login, then:

  1. Let your friend join after ~3-4 seconds (you should place the spawnHeliStart-Marker at quite a distance so you have time to test this).
  2. Let your friend login at the same time, trying to recreate the problem.
  3. Wait until you're less than 100m away to the landing area, let your friend join. He should get his own heli now.
  4. Wait until you disembarked from the heli and its flying off. Let your friend join now. He should again get his own heli.

Alright I'm setup and back in action. Got a chance to run these tests as well.

1. a JIP player was able to join in and spawn in the helo. I had him do so repeatedly all the way to the LZ. He was able to continue spawning into the helo.

2. Attempting to enter the game at the same time resulted in what could be called the chinook centipede which then resulted in a glorious explosion once I realized why my chopper was shaking so violently.

3. Once close to the LZ, the JIPing player was spawned in his own helo at the spawn waypoint which made its way to the LZ. However, once at the LZ the helo did not land and instead hovered in place.

4. The JIPing player was spawned in his own helo when the first helo was on its way out. Same results as 3.

-When JIPing after the first helo has despawned, the player did not spawn a helo but rather ended up spawning on the ground (where the character was in the editor).

Nimrod, Many thanks for sharing your script. I'll post here tomorrow if I am able to modify it to work with multiple JIP players.(or I hit a wall :P)

Share this post


Link to post
Share on other sites
Sign in to follow this  

×