Helicopter transport system

ArmA editing, missions, modeling, textures, terrains

Moderators: Lone Wolf, Snake Man

Post Reply
Snake Man
Commander-In-Chief
Posts: 9338
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC
Contact:

Helicopter transport system

Post by Snake Man » 2010-01-04 10:06:35

Helicopter transport system is what I call a ... well system that has pre-set helicopters and then they transport AI groups around the battlefield when there is "call" for transport.

What it means it is that earlier in my missions I created infantry squad and helicopter with crew which flew the inf squad into target location then returned to base where they were deleted again, but right now I have the helicopters pre-set for example in mission editor. No more "fake" artificial helos spawn out of thin air, now the helos get damaged, they need to be refueled, accidents happen (you know AI landing hehe) and you need to care about the airframes.

Maybe its bit difficult to explain or reason why I wanted this system, but please feel free to ask questions if I'm again confusing everyone.

Okay for editing this piece of junk. The scripts I'm about to show here are unfinished work in progress ones, they aren't much commented, don't have helo death checks and even have hard coded stuff still in, I just wanted to post this now as I got it finally working OK.

So I have simply two scripts to run. But first I was in mission editor and placed two helicopters, named "helo1" and "helo2", then four infantry squads on their init line "usinf1 = group this;" and that being usinf2, usinf3 and usinf4 for all of the names.

Then first script PMC_Helo_Transport.sqf which is run from init.sqf for example:

Code: Select all

private
[
	"_grp",
	"_Helo",
	"_lz",
	"_PMC_Check_Helo_List",
	"_tmp"
];

sleep 1;

// array list of helicopters
PMC_HeloList =
[
	helo1,
	helo2
];

// array list of infantry groups
PMC_Infantry =
[
	usinf1,
	usinf2,
	usinf3,
	usinf4
];

// check and return helo name
_PMC_Check_Helo_List =
{
	// clear the _Helo variable
	_Helo = objnull;

	// check if we have available helos.
	if (count PMC_HeloList > 0) then
	{
		// grab the first helo
		_Helo = (PMC_HeloList select 0);
		// remove it from the helolist
		PMC_HeloList = PMC_HeloList - [PMC_HeloList select 0];
		hint format["_PMC_HeloList after we took first guy out:\n%1\n\nAnd first guy: %2", PMC_HeloList, _Helo];
	};

	// return the helo name
	_Helo;
};

_PMC_Load_Troops =
{
	// troops are loaded into helo.
	{
		_x assignAsCargo _Helo;
		[_x] orderGetIn true;
		player sidechat format["_x: %1. _Helo: %2", _x, _Helo];
	} forEach units _grp;
};

/*

	main program ;)

*/

_lz = pmc_1;

while {true} do
{
	// until we have helo and infantry available.
	waitUntil
	{
		sleep 5;
		player sidechat format["PMC_HeloList: %1, PMC_Infantry: %2", (count PMC_HeloList), (count PMC_Infantry)];
		( (count PMC_HeloList > 0) && (count PMC_Infantry > 0) );
	};
	// first infantry group calls in for transport
	_grp = PMC_Infantry select 0;
	// remove the first group from the array.
	PMC_Infantry = PMC_Infantry - [PMC_Infantry select 0];

	_Helo = [] call _PMC_Check_Helo_List;
	player sidechat "_PMC_Check_Helo_List completed.";
	[] call _PMC_Load_Troops;
	player sidechat "_PMC_Load_Troops completed.";

	// make the helo fly.
	[_lz, _Helo, _grp, homebase] execVM "PMC_Helo_Transport_fly.sqf";
};

hint "_PMC_Infantry is empty, they are all on their way!";
player sidechat "_PMC_Infantry is empty, they are all on their way!";
As you see there is "pmc_1" and "homebase" hard coded game logics now in place, the pmc_1 is somewhere in the map and homebase is there the helicopters are located.

And this is the second script which is called from the first one, its name: PMC_Helo_Transport_fly.sqf

Code: Select all

private
[
	"_grp",
	"_Helo",
	"_homebase",
	"_PMC_Helo_Return_To_Base",
	"_PMC_Send_Helo_On_Way",
	"_PMC_Unload_Troops",
	"_lz",
	"_tmp"
];

_PMC_Send_Helo_On_Way =
{
	// helo send to destination.
	_Helo move _lz;

	waitUntil
	{
		sleep 2;
		_Helo distance _lz < 100;
	};
};

_PMC_Unload_Troops =
{
	// troops unloaded from the helo.
	{
		unAssignVehicle _x;
	} forEach units _grp;

	// this makes sure function runs "easy" and not return
	// while helo is still very much unloading troops. its not perfect though.
	waitUntil
	{
		sleep 2;
		((getPos _Helo select 2) < 3 );
	};
};

_PMC_Helo_Return_To_Base =
{
	// helo returns to base.
	_Helo move getPos _homebase;

	waitUntil
	{
		sleep 2;
		_Helo distance _homebase < 100;
	};

	// helo inserted back to _PMC_HeloList[].
	_Helo land "land";

	waitUntil
	{
		sleep 1;
		((getPos _Helo select 2) < 2 );
	};

	PMC_HeloList = PMC_HeloList + [_Helo];
};

/*

	main program :)

*/

_tmp = _this select 0;
_Helo = _this select 1;
_grp = _this select 2;
_homebase = _this select 3;
_lz = getPos _tmp;

[] call _PMC_Send_Helo_On_Way;
player sidechat "_PMC_Send_Helo_On_Way completed.";
[] call _PMC_Unload_Troops;
player sidechat "_PMC_Unload_Troops completed.";
[] call _PMC_Helo_Return_To_Base;
player sidechat "_PMC_Helo_Return_To_Base completed.";
Unless I missed something this script is build totally on top of the first without any hard coded stuff to change.

I'll try to update this topic when I refine this system bit more. Also this is not really usable for anyone's missions as is because even though this is the backbone for helo transport system... you totally need to build the "request transport" scripting design on top of this (unless you manage to use the current waituntil condition which is very very generic).

All feedback is welcome (which I know there will be none).
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Helicopter transport system

Post by T_Rex » 2010-01-04 16:50:48

hehe

Hard for me to pass up a request for feedback from you. ;)

I've spent some time looking at how the A2 SOM package runs. I think you can initiate the request for transport through a radio call, maybe even set up by a trigger. That's not all that hard.

The hard part - for me, when trying to figure out something similar - is finding a nearby landing place. There are config 'locations' that can be found, such as OpenArea or something like that. I *think* they would be appropriate for a landing zone, but in limited testing couldn't get a helo to land at one. I can find some code to generate the potential LZ, though, if you want.
Sic Semper tyrannosauro.

Snake Man
Commander-In-Chief
Posts: 9338
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC
Contact:

Re: Helicopter transport system

Post by Snake Man » 2010-01-04 17:00:43

Well yes the scripting for creating the request is dead easy, I mean the whole design, like the "AI brain" how it would do those requests. Maybe like reinforcement script would create infantry squad and place them in the PMC_Infantry array would be the easiest, then the looping script would pick them up and ... well ok the destination LZ of course is another thing. Well stuff like this is what I meant.

As for the landing areas, if you put helo land waypoint there it lands where it pleases to, you need to fix this by creating/placing a (invisible) helo pad object into that location.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Helicopter transport system

Post by T_Rex » 2010-01-04 21:14:38

Yeah, but you also have to place the invis pad in a place where the helo can fit. :D I think the findEmptyPosition command will prove useful for that. :)

I realize now that you mean to automate it?

To me, that means having an array of either groups or units, and if the count of that array falls below a threshhold, you decide whether to send the replacements. Or, you might try to calculate tactics. If the side in question is getting flanked (using bearing measurements somehow, or monitoring fsms?) then have the reinforcements transported. Ooooh - or even have them placed behind enemy lines? :D Risky, but could really pay off.

I guess part of the question is whether these troops would be spawned at the beginning of the mission, specifically to be transported, as if held in reserve by the commanding officer, or just troops who happened to be away from the battle and needed quick transport.

Might be worth looking at the DAC scriptology - I think Silola has some implementation similar to this. It also might be worth creating a flowchart of how you would ideally want it to work, then work on the elements. :)
Sic Semper tyrannosauro.

Snake Man
Commander-In-Chief
Posts: 9338
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC
Contact:

Re: Helicopter transport system

Post by Snake Man » 2010-01-05 04:38:04

I'm big fan of createVehicle missions where there is looping script which creates units as old ones get killed. So I find it very cool that the new units get created in the base and then flown into front lines (or behind the lines like you said) with helos, especially as now the helos are "real" and not magically always createVehicled too.

Of course such transport system has endless possibilities of use.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Helicopter transport system

Post by T_Rex » 2010-01-05 19:29:41

Hmmm... then you PMC_infantry array makes alot of sense. As groups are killed, you can delete them, then create new ones and add them to the list.

Oh, and I think I just realized this is in the ArmA area? Do you mean this for ArmA2? I think the same can be achieved in A1, but it'll just be a bit more complicated....
Sic Semper tyrannosauro.

Snake Man
Commander-In-Chief
Posts: 9338
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC
Contact:

Re: Helicopter transport system

Post by Snake Man » 2010-01-06 03:37:55

This is for ArmA, the technical level of my scripting makes no difference between ArmA or ArmA 2.

Did some more work on the script, nothing really worthwhile though, just one death check for helo as I noticed they get blown out of the sky quite easily when near enemies.

Also found another problem, when you create your infantry, their behavior & waypoints and put them into the array, they start to travel towards the first waypoint (which usually is far away, in my current testing terrain beyond ocean, so AI guys run to the coastline and stop there, its stupid). Especially if you have few helos (or even just one) and long distances to LZ, then the infantry waiting queue gets quite long. In my test scenario I had 12 groups waiting for transport at one point.

Its still quite trickery how to best use it.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Helicopter transport system

Post by T_Rex » 2010-01-06 03:51:25

Yeah, the long distance pathfinding was pretty bad in A1. From what I can tell, it is improved in A2.

I have a routine someplace that figures the direction they should go, then tries to find a road model in that area, so they follow the road. If there's no road, it'll at least avoid water.

I think the best thing would probably be to remove any infantry waypoints before/during the helo ride. Only give them the waypoints once they disembark.
Sic Semper tyrannosauro.

Post Reply

Who is online

Users browsing this forum: ahrefs.com [Robot] and 8 guests