Jump to content
Sign in to follow this  
genterprise

To Get A Airplane to Spawn In Only if...

Recommended Posts

Hello,

I am creating a Hold and Defend Mission. There is an area on the Map as an objective to be captured and held. I would like to spawn in an Air Unit at the airport, when a side (opfor or blufor) has control of the objective.

I would like for the Aircraft to be of the nationality of the capturing side!

If you can point me in the right direction and/or explain to me how to do this, I will appreciate it.

I am totally new to scripting for ARMA, so please make it elementary for me.

Again I thank you in advance!

Share this post


Link to post
Share on other sites

The below script will call in two A10's, they will start 3000 meters away and they will fly to the player then search and destroy.

AirStrike.sqf

_BluforHQ = createCenter west;
_GroupCAS = CreateGroup West;

_veh1 = createVehicle ["A10_US_EP1", [(getpos player) select 0,(getpos player) select 1, 350], [], 3000, "FLY"];
_Pilot1 = _GroupCAS createUnit ["US_Pilot_Light_EP1", [0,0,1], [], 0, "CAN_COLLIDE"];
_pilot1 moveInDriver _veh1;
_veh1 FlyInHeight 350;

_veh2 = createVehicle ["A10_US_EP1", [(getpos _veh1) select 0,(getpos _veh1) select 1, 360], [], 50, "FLY"];
_Pilot2 = _GroupCAS createUnit ["US_Pilot_Light_EP1", [0,0,1], [], 0, "CAN_COLLIDE"];
_pilot2 moveInDriver _veh2;

{_x setSkill 1; _x setrank "CAPTAIN"} foreach units _GroupCAS;

_wp1 = _GroupCAS addwaypoint [position player, 0];
_wp1 setwaypointtype "SAD";
_wp1 setWaypointCompletionRadius 100;
_wp1 setWaypointSpeed "FULL";
_wp1 setWaypointBehaviour "COMBAT";

Edited by cobra4v320

Share this post


Link to post
Share on other sites

If one wanted to make an Opfor CAS mission using Su-34s, would something like this do? Or have I screwed it up?

_OpforHQ = createCenter east;
_GroupCASOpfor = CreateGroup East;

_veh1 = createVehicle ["Su34", [(getpos player) select 0,(getpos player) select 1, 0], [], 3000, "FLY"];
_Pilot1 = _GroupCASOpfor createUnit ["RU_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"];
_pilot1 moveInDriver _veh1;
_veh1 setpos [getPos _veh1 select 0, getPos _veh1 select 1, 250];
_veh1 FlyInHeight 250;

_veh2 = createVehicle ["Su34", [(getpos _veh1) select 0,(getpos _veh1) select 1, 0], [], 50, "FLY"];
_Pilot2 = _GroupCASOpfor createUnit ["RU_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"];
_pilot2 moveInDriver _veh2;
_veh2 setpos [getPos _veh2 select 0, getPos _veh2 select 1, 260];
_veh2 FlyInHeight 260;

{_x setSkill 1; _x setrank "CAPTAIN"} foreach units _GroupCAS;

_wp1 = _GroupCASOpfor addwaypoint [position player, 0];
_wp1 setwaypointtype "SAD";
_wp1 setWaypointCompletionRadius 100;
_wp1 setWaypointSpeed "FULL";
_wp1 setWaypointBehaviour "COMBAT";

And if I wanted to have them coming in just a little off from the player (enemy jets going directly over your head can be a little worrying), would I replace 'position player, 0' with '(getpos player) select 0,(getpos player) select 1, 300' on the addwaypoint line? Thanks for any help.

Share this post


Link to post
Share on other sites

I think he wants an chopper/plane to spawn on ground like in BF games.

Share this post


Link to post
Share on other sites

Yes Ziiiup - Absolutely correct, thank you for the clarification.

I thank you Cobra and Dynamic, even though that is not what I needed for this project, I may use those scripts in later creations.

Kylania - thanks for the link reference, I am checking it out now!

Share this post


Link to post
Share on other sites

A word of warning - my conversion of Cobra's code is a bit...rough - the Su-34s come in, but they seem to spawn very close to the player, then they fly off for a while (about a minute, normally), then return at a very low altitude which invariably causes them to fly into the nearest hill. Also they don't seem to want to shoot anything - though they did pop flares when I put some AA down. Needs work, basically, but Cobra's A-10s work fine.

Edited by Dynamic Echo

Share this post


Link to post
Share on other sites

This is really cool. Spawning in units and stuff on the fly could be used to greatly optimize fps greatly in missiond. :D:yay:

Share this post


Link to post
Share on other sites

This will spawn an empty A10 near the player:

_veh1 = createVehicle ["[color="Navy"]A10_US_EP1[/color]", [(getpos player) select 0,(getpos player) select 1, 0], [], 10, "NONE"];

This will spawn an empty A10 at a marker named "obj1":

_veh1 = createVehicle ["A10_US_EP1", [(getmarkerpos "obj1") select 0,(getmarkerpos "obj1") select 1, 0], [], 0, "NONE"];

Just change "A10_US_EP1" to the vehicle that you want. Vehicle classnames can be found here.

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Here ya go:

rewardaircraft.jpg

//////////////////////////////////////////////////////////////////
// Function file for ArmA 2: Operation Arrowhead
// Created by: kylania
//////////////////////////////////////////////////////////////////

// nul = ["WEST"] execVM "rewardAircraft.sqf";

// Array of available aircraft.  Simply add or remove classnames to adjust the available pool.
_westAircraft = ["A10_US_EP1","AH64D_EP1","AH6J_EP1","CH_47F_EP1","MH6J_EP1","UH60M_EP1","UH60M_MEV_EP1"];
_eastAircraft = ["L39_TK_EP1","Mi17_TK_EP1","Mi24_D_TK_EP1","Su25_TK_EP1","UH1H_TK_EP1"];

// Marker where aircraft will spawn.
_spawnPoint = "aircraftSpawn"; 

// Customize hint colors.
_westColor = "#3366FF";
_eastColor = "#B8002E";

// Grab winning side from argument.
_winningSide = _this select 0;

// Prepare variables.
private ["_name","_picture","_reward","_color"];

if (isServer) then {
// Spawn vehicle and choose hint color based on winning side.
switch (_winningSide) do {
	case "WEST": {
		_reward = _westAircraft select floor(random count _westAircraft) createVehicle getMarkerPos _spawnPoint;
		_color = _westColor;
	};
	case "EAST": {
		_reward = _eastAircraft select floor(random count _eastAircraft) createVehicle getMarkerPos _spawnPoint;
		_color = _eastColor;
	};
};

// Grab friendly name and image of vehicle.
_name = getText (configFile >> "cfgVehicles" >> typeOf _reward >> "displayName");	
_picture = getText (configFile >> "cfgVehicles" >> typeOf _reward >> "picture");

// Hint reward.
hint parseText format["
Congrats <t color='%4'>%1</t> Team!<br/>
You have been rewarded with an <t color='#FFCC33'>%2</t> for your efforts!<br/>
<t color='%4'><img size='4' image='%3'/></t>",
_winningSide, _name, _picture, _color
];

}; // end of If

Edited by kylania

Share this post


Link to post
Share on other sites
If one wanted to make an Opfor CAS mission using Su-34s, would something like this do? Or have I screwed it up?

Su-34 has two seats a driver and gunner! :rolleyes:

Try this instead:

_OpforHQ = createCenter east;
_GroupCASOpfor = CreateGroup East;

_veh1 = createVehicle ["Su34", [(getpos player) select 0,(getpos player) select 1, 350], [], 800, "FLY"];
_Pilot1 = _GroupCASOpfor createUnit ["RU_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"];
_pilot1 moveInDriver _veh1;
_Pilot1g = _GroupCASOpfor createUnit ["RU_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"];
_pilot1g moveInGunner _veh1;
_veh1 FlyInHeight 350;

_veh2 = createVehicle ["Su34", [(getpos _veh1) select 0,(getpos _veh1) select 1, 300], [], 50, "FLY"];
_Pilot2 = _GroupCASOpfor createUnit ["RU_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"];
_pilot2 moveInDriver _veh2;
_Pilot2g = _GroupCASOpfor createUnit ["RU_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"];
_pilot2g moveInGunner _veh2;

{_x setSkill 1; _x setrank "CAPTAIN"} foreach units _GroupCAS;

_wp1 = _GroupCASOpfor addwaypoint [position player, 0];
_wp1 setwaypointtype "SAD";
_wp1 setWaypointCompletionRadius 100;
_wp1 setWaypointSpeed "NORMAL";
_wp1 setWaypointBehaviour "COMBAT";

Edited by cobra4v320

Share this post


Link to post
Share on other sites

@kylania

For my script below it is not allowing me to randomly spawn in vehicles can you tell what is wrong witht the script? The line in the script that is not work is highlighted in red.

_westAircraft 	= ["AH64D_EP1","AH1Z","AH6J_EP1"];

_man		= player;
_pos		= getpos _man;
_spwndir	         = getdir _man;

_WestHQ 	         = createCenter West;
_Grp 		= CreateGroup West;
_PAPABEAR 	= [West,"HQ"];

[color="red"]_veh1 = _westAircraft floor (random count _westAircraft) createVehicle [_westAircraft, _pos, [], 200, "FLY"];[/color]
_Pilot1 = _Grp createUnit ["US_Soldier_Pilot_EP1", getpos _veh1, [], 0, "FORM"];
_pilot1 moveInDriver _veh1;
_Pilot1G = _Grp createUnit ["US_Soldier_Pilot_EP1", getpos _veh1, [], 0, "FORM"];
_pilot1G moveInGunner _veh1;
_veh1 setdir _spwndir;

{_x setSkill 1; _x setrank "CAPTAIN"} foreach units _Grp;

_wp1 = _Grp addwaypoint [_pos, 0];
_wp1 setwaypointtype "SAD";
_wp1 setWaypointSpeed "NORMAL";
_wp1 setWaypointBehaviour "COMBAT";
_wp1 setWaypointStatements  ["true",""];

_PAPABEAR SideChat "Knight close air support is inbound, over.";

while{true} do {
if(getPosATL _veh1 select 2 <= 1)then{_veh1 setdamage 1;};
if(getPosATL _veh2 select 2 <= 1)then{_veh2 setdamage 1;};
};

if(true)exitWith{};

Edited by cobra4v320

Share this post


Link to post
Share on other sites

The first argument of the createVehicle array is the type, and in that code you're passing it the array of types. Try this:

_veh1 =  createVehicle [_westAircraft select floor (random count _westAircraft), _pos, [], 200, "FLY"];

It's either "type" createVehicle position or createVehicle ["type", position, markers, placement, special].

Edited by kylania

Share this post


Link to post
Share on other sites

@Kylania

The script you posted still does not work, since it is a string shouldnt you use quotation "" marks in between like this?

_veh1 =  createVehicle ["_westAircraft floor (random count _westAircraft)", _pos, [], 200, "FLY"];

Ive tested and it does not give me any errors but also does not spawn any aircraft. :confused:

Share this post


Link to post
Share on other sites

Nope, that's not it, it's a missing select (in red) that's causing problems.

Since the contents of the _westAircraft array is strings, the result of _westAircraft select floor(random count _westAircraft) is a string so you don't need the "", only need those for a literal string like "cat".

_veh1 =  createVehicle [_westAircraft [b][color="Red"]select[/color][/b] floor (random count _westAircraft), _pos, [], 200, "FLY"];

Share this post


Link to post
Share on other sites

Wow - thanks to all and Kylania - ou went beyond what I expected so I thank you tremendously!

Share this post


Link to post
Share on other sites

Insted of this:

_BluforHQ = createCenter west;

_GroupCAS = CreateGroup West;

Pilot1 = _GroupCAS createUnit ["US_Pilot_Light_EP1", [0,0,1], [], 0, "CAN_COLLIDE"];

I tried this:

_BluforHQ = createCenter west;

_GroupCAS = CreateGroup West;

Pilot1 = _GroupCAS createUnit ["US_Pilot_Light_EP1", pospilot = getMarkerPos "marker1", [], 0, "CAN_COLLIDE"];

But it doesnt work. I wonder why?

Share this post


Link to post
Share on other sites

Why dont you try:

Pilot1 = _GroupCAS createUnit ["US_Pilot_Light_EP1", getMarkerPos "marker1", [], 0, "CAN_COLLIDE"]; 

Share this post


Link to post
Share on other sites

Yes, it works great! I wonder why BIKI got it wrong though.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×