Jump to content
Sign in to follow this  
cobra4v320

Need assistance with Close Air Support Script

Recommended Posts

Here is my airborne infantry script, it calls a random cargo vehicle, and a random squad, and drops the squad off at the players location. The squad does a bis_fnc_taskpatrol, the cargo vehicle flys off and deletes after a certain distance. If anyone sees something that looks out of place or could be better please let me know. I would really like to make these scripts MP compatible and in an addaction menu.

For the "hint parseText format" Im using the picture from the bootcamp halo mission.

waituntil {!isnil "bis_fnc_init"};

if (infActive) exitWith {hint "Airborne Infantry Support is unavailable!"};

infActive = true;
publicVariable "infActive";

_unit		= player;
_pos 		= [(getmarkerpos "SpawnPoint" select 0), (getmarkerpos "SpawnPoint" select 1), 300];
_dir		= getdir _unit;
_westVehicle	= ["C130J_US_EP1","MV22","UH60M_EP1","CH_47F_EP1"];
_WestSquad	= ["US_DeltaForceTeam","US_WeaponsSquad","US_RifleSquad","US_Team"];

_airgrp 	= CreateGroup West;
_veh 		= [_pos, _dir, _westVehicle select (random count _westVehicle), _airgrp] call BIS_fnc_spawnVehicle;
_air_unit 	= units _airgrp;
_air_veh 	= _veh select 0;
_air_veh flyinheight 300;

sleep 1;

_infgrp		= CreateGroup West;
_infgrp 	= [(getmarkerpos "spawnpoint"), side _unit, (configFile >> "CfgGroups" >> "West" >> "BIS_US" >> "Infantry" >> _westSquad select (random count _westSquad))] call BIS_fnc_spawnGroup;
[_infgrp, (getpos _unit), 50] call BIS_fnc_taskPatrol;
_inf_unit = units _infgrp;
{_x moveincargo _air_veh} foreach _inf_unit;

_squadType 	= _westSquad select (random count _westSquad);

hint parseText format["<img size='5' image='img\airborne.paa'/><br/>
There is a %1 enroute to your location with an Airborne %2!",typeof _air_veh, _squadtype];

sleep 4;
hint "";

_wp1 = _airgrp addwaypoint [position _unit, 0];
_wp1 setwaypointtype "MOVE";
_wp1 setWaypointSpeed "NORMAL";
_wp1 setWaypointBehaviour "CARELESS";
_wp1 setWaypointCombatMode "BLUE";


waitUntil
{
_unit distance _air_veh < 450
};

{unassignVehicle (_x);(_x) action ["EJECT", vehicle _x];sleep 0.4} foreach _inf_unit;
{_x spawn {_this allowdamage false; waituntil {(getpos _this) select 2 < 3};_this allowdamage true}} foreach _inf_unit;

_wp2 = _airgrp addwaypoint [position _unit, 2000];
_wp2 setwaypointtype "MOVE";
_wp2 setWaypointSpeed "FULL";
_wp2 setWaypointBehaviour "CARELESS";
_wp2 setWaypointCombatMode "BLUE";

waituntil
{
_air_veh distance _unit > 800
};

sleep 10;

{deleteVehicle _x} forEach (_air_unit)+[_air_veh];


waitUntil
{
{alive _x} count _inf_unit == 0

};

hint format ["All the %1 units have been killed!",_squadtype];

sleep 4;
hint "";

sleep (60 + random 60);

{deletevehicle _x} foreach _inf_unit;


hint "Airborne Infantry support is available!";

sleep 4;
hint "";

infActive = false;

publicVariable "infActive";

Edited by cobra4v320

Share this post


Link to post
Share on other sites

I think your scripts are awesome... Thanks. Is the CAS the final product on page 2 of this thread? ummm also Im linking this with the US support script by the Lucilk. Also making it under high command rather then squad. If you'd like I'll send ya what I got when its working properly... or whats working right now. lol

Share this post


Link to post
Share on other sites

Hey Mikey

Here are better versions of my support scripts but Im still working on improving them and putting them into a support menu. I decided to go away from the bis_fnc_stuff because its driving me crazy.

Close Air Support currently calls either a Cobra or Apache, I may add two rather than just one.

Transport calls in a UH-60, picks you up and drops you off at your chosen locations.

Airborne Infantry calls in a random number of airborne units, but it calls in the wrong marines not desert.

Im working on fixed wing close air support and armor. I also need to change the marker names they interfere with each other since they are named the same when calling multiple supports. Im testing all of these using radio triggers. You just need to name them nul = [] execVM "scriptname.sqf"

You will also need the three picture save in a folder name img in your mission folder. I will work on uploading the photos.

If anyone has any ideas or improvements let me know.

Close air support:

if (!isServer) exitWith {};

waituntil {!isnil "bis_fnc_init"};

if (casActive) exitWith {hint "Close Air Support is unavailable!"};

casActive = true;
publicVariable "casActive";

_unit		= player;


_unit globalchat "Left click on the map where you want the close air support";
_drop = createMarkerLocal ["drop", [0,0,0]];
_drop setMarkerShapeLocal "ICON";
"drop" setMarkerTypeLocal "hd_destroy";
"drop" setMarkerColorLocal "ColorRed";
onMapSingleClick "'drop' setMarkerPosLocal _pos, dropclick = true";
waitUntil {dropclick};
onMapSingleClick "";
dropclick = false;

_drop 		= getMarkerPos "drop";
_spwn 		= getPosATL pad;
_spwndir	= getdir pad; 
_spwn1 		= [(_spwn select 0), (_spwn select 1) + 30, _spwn select 2];

_westAircraft 	= ["AH64D_EP1","AH1Z"];
_airgrp		= createGroup side _unit;

_veh 		= createVehicle [_westAircraft select floor (random count _westAircraft), _spwn1, [], 0, "FLY"];
_veh setdir _spwndir;
_veh setVelocity [sin(_spwndir)*80,cos(_spwndir)*80,0];

_pilotD		= _airgrp createUnit ["US_Soldier_Pilot_EP1", _spwn, [], 0, "NONE"];
_pilotD moveindriver _veh;
_pilotG		= _airgrp createUnit ["US_Soldier_Pilot_EP1", _spwn, [], 0, "NONE"];
_pilotG moveingunner _veh;

hint parseText format["<img size='5' image='img\closeair.paa'/><br/>
There is a %1 close air support enroute to your location!",typeof _veh];

sleep 5;
hint "";

_awp1 = _airgrp addwaypoint [_drop, 0];
_awp1 setwaypointtype "MOVE";
_awp1 setWaypointSpeed "FULL";
_awp1 setWaypointBehaviour "COMBAT";
_awp1 setWaypointCombatMode "RED";
_awp1 setWaypointStatements  ["true",""];

[_airgrp, _drop, 400] call BIS_fnc_taskPatrol;

_units = units _airgrp;


waitUntil
   { 	
_checkcas = FALSE;
if (!alive _veh) then {_checkcas = TRUE} else {_checkcas = FALSE};
if (getDammage _veh > 0.8) then {_checkcas = TRUE} else {_checkcas = FALSE};
if ((fuel _veh) < 0.2 ) then {_checkcas = TRUE} else {_checkcas = FALSE};
	if !(isengineon _veh) then {_checkcas = TRUE} else {_checkcas = FALSE};
_checkcas
   };


_unit globalchat format ["The %1 has been destroyed!", typeof _veh];

deleteMarkerLocal "drop";

sleep (60 + random 60);

waitUntil {_unit distance _veh > 200};

{deleteVehicle _x} forEach (_units)+[_veh]; deletegroup _airgrp;

hint "Close Air Support is available.";
sleep 4;
hint "";

casActive = false;

publicVariable "casActive";

Here is transport:

if (!isServer) exitWith {};

waituntil {!isnil "bis_fnc_init"};

if (transActive) exitWith {hint "Air transport is unavailable!"};

transActive = true;
publicVariable "transActive";

_unit		= player;


_unit globalchat "Left click on the map where you want to be picked up and where you want to be dropped off.";
_drop = createMarkerLocal ["drop", [0,0,0]];
_drop setMarkerShapeLocal "ICON";
"drop" setMarkerTypeLocal "hd_pickup";
"drop" setMarkerColorLocal "ColorGreen";
onMapSingleClick "'drop' setMarkerPosLocal _pos, dropclick = true";
waitUntil {dropclick};
onMapSingleClick "";
dropclick = false;

_drop2 = createMarkerLocal ["drop2", [0,0,0]];
_drop2 setMarkerShapeLocal "ICON";
_drop2 setMarkerColorLocal "ColorGreen";
"drop2" setMarkerTypeLocal "hd_end";
onMapSingleClick "'drop2' setMarkerPosLocal _pos, dropclick = true";
waitUntil {dropclick};
onMapSingleClick "";
dropclick = false;

_drop 		= getMarkerPos "drop";
_drop2 		= getMarkerPos "drop2";
_spwn 		= getPosATL pad;
_spwndir	= getdir pad; 
_spwn1 		= [(_spwn select 0), (_spwn select 1) + 30, _spwn select 2];

_airgrp		= createGroup side _unit;

_veh 		= createVehicle ["UH60M_EP1", _spwn1, [], 0, "FLY"];
_veh allowdamage false;
_veh setdir _spwndir;
_veh setVelocity [sin(_spwndir)*70,cos(_spwndir)*70,0];

_pilotD		= _airgrp createUnit ["US_Soldier_Pilot_EP1", _spwn, [], 0, "FORM"];
_pilotD moveindriver _veh;
_pilotC		= _airgrp createUnit ["US_Soldier_Pilot_EP1", _spwn, [], 0, "FORM"];
_pilotC moveincargo _veh;
_pilotG1	= _airgrp createUnit ["US_Soldier_Pilot_EP1", _spwn, [], 0, "FORM"];
_pilotG1 moveInTurret [_veh, [0]];
_pilotG2	= _airgrp createUnit ["US_Soldier_Pilot_EP1", _spwn, [], 0, "FORM"];
_pilotG2 moveInTurret [_veh, [1]];


_LZ1 = "HeliHEmpty" createVehicle _drop;
_LZ2 = "HeliHEmpty" createVehicle _drop2;
_smoke = "smokeshellred" createVehicle (getpos _LZ1);

hint parseText format["UH-60 Blackhawk is enroute for pickup.<img size='5' image='img\transport.paa'/>"];

sleep 5;
hint "";

land = false;

_awp1 = _airgrp addwaypoint [_drop, 0];
_awp1 setwaypointtype "LOAD";
_awp1 setWaypointSpeed "FULL";
_awp1 setWaypointBehaviour "CARELESS";
_awp1 setWaypointCombatMode "YELLOW";
[_airgrp, 1] setWaypointStatements ["true", "land = true"];

waituntil {(!transActive) or land};
_veh land "get in";
waituntil {(!transActive) or (!alive _unit) or (_unit in _Veh)};

land = false;

_awp2 = _airgrp addWaypoint [_drop2, 0];
_awp2 setWaypointType "MOVE";
_awp2 setWaypointSpeed "NORMAL";
_awp2 setWaypointBehaviour "CARELESS";
_awp2 setWaypointCombatMode "YELLOW";
[_airgrp, 2] setWaypointStatements ["true", "land = true"];
waituntil {(!transActive) or land};
_veh land "get out";
waituntil {(!transActive) or (0 >= count ((crew _veh)-[_pilotD,_pilotC,_pilotG1,_pilotG2]))};

land = false;

_awp3 = _airgrp addWaypoint [_spwn, 0];
_awp3 setWaypointType "MOVE";
_awp3 setWaypointSpeed "FULL";
_awp3 setWaypointBehaviour "AWARE";
_awp3 setWaypointStatements ["true", ""];

waituntil {_veh distance _spwn < 250};

{deleteVehicle _x} forEach (crew _veh)+[_veh]; deletegroup _airgrp;

deleteMarkerLocal "drop";
deleteMarkerLocal "drop2";
deleteVehicle _LZ1;
deleteVehicle _LZ2;


_unit globalchat "The UH-60 Blackhawk has returned to base.";

sleep (60 + random 60);


hint "Air Transport is available.";
sleep 4;
hint "";

transActive = false;

publicVariable "transActive";

Here is airborne units:

if (!isServer) exitWith {};

waituntil {!isnil "bis_fnc_init"};

if (infActive) exitWith {hint "Airborne Infantry Support is unavailable!"};

infActive = true;
publicVariable "infActive";

_unit		= player; 


_unit globalchat "Select the airborne LZ location on the map (left click)";
_drop = createMarkerLocal ["drop", [0,0,0]];
_drop setMarkerShapeLocal "ICON";
"drop" setMarkerTypeLocal "hd_destroy";
"drop" setMarkerColorLocal "ColorGreen";
onMapSingleClick "'drop' setMarkerPosLocal _pos, dropclick = true";
waitUntil {dropclick};
onMapSingleClick "";
dropclick = false;

_drop 		= getMarkerPos "drop";
_spwn 		= getPosATL pad; 
_spwndir 	= getDir pad;
_spwn1 		= [(_spwn select 0), (_spwn select 1) + 220, _spwn select 2];


_westVehicle	= ["C130J_US_EP1","MV22"];
_airgrp 	= CreateGroup side _unit;

_veh 		= createVehicle [_westVehicle select floor (random count _westVehicle), _spwn1, [], 0, "FLY"];
_veh allowdamage false;
_veh setdir _spwndir;
_veh setVelocity [sin(_spwndir)*90,cos(_spwndir)*90,0];

_pilot		= _airgrp createUnit ["US_Soldier_Pilot_EP1", _spwn, [], 0, "NONE"];
_pilot moveindriver _veh;
_veh flyinheight 220;

_awp1 = _airgrp addwaypoint [_drop, 0];
_awp1 setwaypointtype "MOVE";
_awp1 setWaypointSpeed "LIMITED";
_awp1 setWaypointBehaviour "AWARE";
_awp1 setWaypointCombatMode "BLUE";
_awp1 setWaypointStatements  ["true",""];


_WestSquad	= [5,6,7,8,9,10,11,12,13,14,15];
_infgrp		= CreateGroup side _unit;
_infgrp 	= [_spwn, side _unit, _westSquad select (random count _westSquad)] call BIS_fnc_spawnGroup;

{_x moveincargo _veh} foreach units _infgrp;

[_infgrp, getpos _unit, 150] call BIS_fnc_taskPatrol;

hint parseText "<img size='5' image='img\airborne.paa'/><br/>There is an Airborne Infantry Squad enroute to your location!";
sleep 5;
hint "";

waitUntil
{
_veh distance _drop < 250
};

{unassignVehicle (_x);(_x) action ["EJECT", vehicle _x];sleep 0.3} foreach units _infgrp;

{_x spawn {_this allowdamage false; waituntil {(getpos _this) select 2 < 3};_this allowdamage true}} foreach units _infgrp;

_awp2 = _airgrp addwaypoint [_spwn, 0];
_awp2 setwaypointtype "MOVE";
_awp2 setWaypointSpeed "FULL";
_awp2 setWaypointBehaviour "AWARE";
_awp2 setWaypointCombatMode "BLUE";
_awp2 setWaypointStatements  ["true",""];

waituntil
{
	_veh distance _spwn < 300
};

sleep 10;

deleteMarkerLocal "drop";
{deleteVehicle _x} forEach (crew _veh)+[_veh]; deletegroup _airgrp;

_units	= units _infgrp;

waitUntil {{alive _x} count _units == 0};

_unit globalchat "All the Airborne Infantry units have been killed!";

sleep 4;
hint "";

sleep (60 + random 60);

{deletevehicle _x} foreach _units; deletegroup _infgrp;

hint "Airborne Infantry support is available!";

sleep 4;
hint "";

infActive = false;

publicVariable "infActive";

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Hi,

Two suggestions:

  • Tag your Global Variables
  • Also, Player does not exist in a dedicated machine.

if (!isServer) exitWith {};
_unit = player;

So, it will work on SP and in a hosted game, but not in a dedicated server.

_neo_

Share this post


Link to post
Share on other sites
Hi,

Two suggestions:

  • Tag your Global Variables
  • Also, Player does not exist in a dedicated machine.

Hi neokika,

So I changed the _unit to

_PapaBear = [West, "HQ"]

for the radio chatter.

But if this is going to be for MP how would I define a player then? For example under the transport script where it says _unit in _veh towards the bottom? If I named a unit in the editor would that work? For example the team leader?

Also tagging global variables is that done by using private["","",""]?

Edited by cobra4v320

Share this post


Link to post
Share on other sites

thanks cobra... Im actually going to keep trying with the bis function stuff... I have a couple ideas. the biggest thing driving me crazy is I want to get 2 CAS (same units not 2 different ones) instead of one and I cant find a quick fix to it. lol my loops are not working.

As for player... Your just using _unit player as a reference point right? maybe change to map click or a marker? If you have the US support Script misson by Lucilk I'll send you the CAS file that works... but its spawns 2 different units. but works with US Support. ;)

Edited by Mikey74

Share this post


Link to post
Share on other sites

The other issue that Im having is setting the spawn height of the vehicles, this does not seem to be working for me:

(getpos pad select 0), (getpos pad select 1), 50

Never mind if I use below it works, but I also thought you could just use getpos to set vehicle height :confused:

_veh setpos [_spwn select 0,_spwn select 1,(_spwn select 2)+200];

---------- Post added at 06:14 PM ---------- Previous post was at 06:13 PM ----------

thanks cobra... Im actually going to keep trying with the bis function stuff... I have a couple ideas. the biggest thing driving me crazy is I want to get 2 CAS (same units not 2 different ones) instead of one and I cant find a quick fix to it. lol my loops are not working.

As for player... Your just using _unit player as a reference point right? maybe change to map click or a marker? If you have the US support Script misson by Lucilk I'll send you the CAS file that works... but its spawns 2 different units. but works with US Support. ;)

Mikey to spawn in two of the same units do this:

_grp = createGroup west;
for "_i" from 1 to 2 do {
   [(getpos troops1_1_7), random 360, "BMP3", _grp] call BIS_fnc_spawnVehicle;
};

This should spawn in two BMP's.

Edited by cobra4v320

Share this post


Link to post
Share on other sites
Also tagging global variables is that done by using private["","",""]?

No. Private command is only for local variables.

Sets a variable to the innermost scope. The variable has to be local.

For example:

[color="Blue"]_myName[/color] = andersson;

if (true) then
{
private ["_myName"];
_myName = john;
[color="Red"]_myName;[/color]
};

[color="Blue"]_myName;[/color]

_myName will be andersson

_myName will be john

So, what I meant by adding Tags to your Global Variables is:

For example BIS Tag is BIS_varName.

  • BIS_ = Tag
  • varName = Global Variable Name

So, for example I make a Addon which contain a Global Variable, lets call it myChopper. And you are using my addon to make your mission. And you in your mission use a Global Variable called myChopper also, it will cause problems. For example I say that myChopper is equal to true in my addon, and you in your mission say that myChopper is equal to false.

So the TAGS are really important in Global Variable so the community doesn't use the same names for Global Variable and cause issues.

**********************

Hi neokika,

So I changed the _unit to

_PapaBear = [West, "HQ"]

No, you will need to change alot more then that to make the scripts work in dedicated servers.

I see you do:

_unit = player;

And use the _unit position to the units waypoints.

The best option I see is to make use of the OnMapSingleClick "" comand so the player can choose the location where the units need to move.

_neo_

Share this post


Link to post
Share on other sites
Cobra : grp = createGroup west;

for "_i" from 1 to 2 do {

[(getpos troops1_1_7), random 360, "BMP3", _grp] call BIS_fnc_spawnVehicle;

};

I did this but was trying it with your CAS script. but Im stump on what to replace the (random count _west....) Couldnt get it right so Ive abandoned that for now.

As for the flying hieght... whats wrong with it seems fine?

Share this post


Link to post
Share on other sites

Mikey

The helicopters were starting on the ground and not in the air. Also if you use random it will randomly spawn in two ah64s or it could be one cobra and one ah64. So if you just want something specific you should just use one vehicle and not random. I will be trying to figure this out for the CAS where it will randomly spawn in two ah64s or two cobras.

neokika

Thank you for that information Im still trying to figure out this whole MP/JIP/dedicated server stuff, so like I said before all ideas and suggestions are appreciated.

---------- Post added at 07:38 PM ---------- Previous post was at 07:20 PM ----------

Here is an example mission with the support scripts. I believe the only Mod Im using is the GLT_Falcon and ACE 2.

http://www.mediafire.com/?1w82bwzauqzalt9

Edited by cobra4v320

Share this post


Link to post
Share on other sites
The helicopters were starting on the ground and not in the air.

I've got your Original script they dont start on the ground. I put them where they would spawn on my position and He was in the air. :386:

It looks like this:

_pos 		= [(getmarkerpos "SpawnPoint" select 0), (getmarkerpos "SpawnPoint" select 1), [u][i][b]50[/b][/i][/u]]; // <--- the 50 works it spawns about 50 meters in the air
_dir 		= random 360;
_westAircraft 	= ["AH64D_EP1","AH1Z","A10_US_EP1","AV8B2","F35B"];
_unit		= player;
_group		= createGroup West;


if (casActive) exitWith {hint "Close Air Support is unavailable!"};

casActive = true;


_veh = [_pos, _dir, _westAircraft select (random count _westAircraft), _group] call BIS_fnc_spawnVehicle;

_veh = _veh select 0;

_units = units _group;

Edited by Mikey74

Share this post


Link to post
Share on other sites

OK this i what I did. I combined some of yours, tiney bit of my ideas, and some of lulics.

http://www.mediafire.com/?czmjfbmw54kkm9s

It has your CAS, Para, modified INf inserted by a helo landing not paradrops, and 2 m1a2 tanks from OA.

Like I said tiny bit of me.lol I actually like the inf beter beeing flown in not dropped in. :ok:

Thanks for your script and help :)

ps enemies on the map forgot to delete them. just couple Russian inf squads on other side of the bridge.

sorry for the double post how does one delete a post?? If its you guys delete my prior post please. Again Im sorry for double post.

Edited by Mikey74
double post

Share this post


Link to post
Share on other sites

I dont think you can delete your previous post, Im on vacation until Friday so I can check them out when I get back.

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  

×