Jump to content
Sign in to follow this  
avibird 1

CAS script for planes that engage targets in a limited AO!

Recommended Posts

I was trying to get a CAS script working for a group of planes on a dynamic mission/map a few weeks back. The major issue was that the planes have a very large target range and LOS. The planes would move to the players location and take out a few armor targets but then the squad would move all over my dynamic mission engaging any target within it's LOS. The CAS would never come back to support the player who called the script in): No air support on this mission = DEATH! Some suggestions were to look into the target commands and or LOS ect. I attempted but that was way over my head and paygrade for scripting.

I found a very simple fix with basic scripting to get a plane or a squad of planes to stay in a general location for CAS on a very dynamic mission. If this could help someone esle here it is. I looked and there are no other scripts that i could find to setup a plane for CAS support in a general AO without using a laser target. This script allows the AI plane to engage freely within general AO.

sqf called casjet

if (!((player getVariable "JsupportAvailable") == "JSupportAvailable")) exitWith {hint "Fighter Squadron not available for Support"};
player setVariable ["JsupportAvailable", "JsupportUNAvailable"]; 

jet = false;
publicVariable "jet";
[] exec "AISUPPORT\menu\close_menu.sqf";

player sideChat "We need Fighter support in our AO, Over";
sleep 5;
PAPABEAR=[West,"HQ"];

_pos = [(getPosATL Player select 0) + (1500 * sin(180)), (getPosATL Player select 1) + (1500 * cos(180)), 0];
GroupJET = CreateGroup West;

JetA = createVehicle ["A10",  _pos, [], 0, "FLY"];
JetA setPosATL [(getPosATL Player select 0) + (1500 * sin(180)), (getPosATL Player select 1) + (1500 * cos(180)), 1000];
JetAPilot1 = GroupJET createUnit ["USMC_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"];
JetAPilot1 moveInDriver JETA;
JetA FlyInHeight 600;


JetB = createVehicle ["AV8B2",  _pos, [], 0, "FLY"];
JetB setPosATL [(getPosATL Player select 0) + (1510 * sin(180)), (getPosATL Player select 1) + (1510 * cos(180)), 1000];
JetBPilot1 = GroupJET createUnit ["USMC_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"];
JetBPilot1 moveInDriver JETB;
JetB FlyInHeight 575;


JetC = createVehicle ["A10",  _pos, [], 0, "FLY"];
JetC setPosATL [(getPosATL Player select 0) + (1520 * sin(180)), (getPosATL Player select 1) + (1520 * cos(180)), 1000];
JetCPilot1 = GroupJET createUnit ["USMC_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"];
JetCPilot1 moveInDriver JETC;
JetC FlyInHeight 550;


JetD = createVehicle ["AV8B2",  _pos, [], 0, "FLY"];
JetD setPosATL [(getPosATL Player select 0) + (1530 * sin(180)), (getPosATL Player select 1) + (1530 * cos(180)), 1000];
JetDPilot1 = GroupJET createUnit ["USMC_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"];
JetDPilot1 moveInDriver JETD;
JetD FlyInHeight 525;

player sideChat "HQ Confirms: Squadron Eagle is airborne and moving towards our location over";
sleep 5;

//Call in waypoint
wp1 = GroupJET addwaypoint [position Player, 100]; 
//wp1 waypointAttachVehicle vehicle player;  
wp1 setwaypointtype "MOVE"; 
wp1 setWaypointCombatMode "Yellow"; 
wp1 setWaypointFormation "WEDGE"; 
wp1 setWaypointSpeed "FULL"; 
wp1 setWaypointBehaviour "AWARE"; 
//wp1 setWaypointCompletionRadius 10;
wp1 setWaypointStatements ["true", "hint 'END OF 1ST WAYPOINT MOVE';"];
wp1 setWaypointTimeout [15,15,15]; 

//Bravo waypoint
wp2 = GroupJET addwaypoint [position Player, 100]; 
wp2 waypointAttachVehicle vehicle player;  
wp2 setwaypointtype "MOVE"; 
wp2 setWaypointCombatMode "Yellow"; 
wp2 setWaypointFormation "WEDGE"; 
wp2 setWaypointSpeed "FULL"; 
wp2 setWaypointBehaviour "AWARE"; 
//wp2 setWaypointCompletionRadius 10;
wp2 setWaypointStatements ["true", "hint 'END OF 2ND WAYPOINT MOVE';"];
wp2 setWaypointTimeout [15,15,15]; 


//waypoint
wp3 = GroupJET addwaypoint [position Player, 100]; 
wp3 waypointAttachVehicle vehicle player;  
wp3 setwaypointtype "MOVE"; 
wp3 setWaypointCombatMode "Yellow"; 
wp3 setWaypointFormation "WEDGE"; 
wp3 setWaypointSpeed "FULL"; 
wp3 setWaypointBehaviour "AWARE"; 
//wp3 setWaypointCompletionRadius 10;
wp3 setWaypointStatements ["true", "hint 'END OF 3RD WAYPOINT MOVE';"];
wp3 setWaypointTimeout [15,15,15]; 


// waypoint
wp4 = GroupJET addwaypoint [position Player, 100]; 
wp4 waypointAttachVehicle vehicle player; 
wp4 setwaypointtype "MOVE"; 
wp4 setWaypointCombatMode "YELLOW"; 
wp4 setWaypointFormation "WEDGE"; 
wp4 setWaypointSpeed "FULL"; 
wp4 setWaypointBehaviour "AWARE"; 
//wp4 setWaypointCompletionRadius 10;
wp4 setWaypointStatements ["true", "hint 'START CYCLE WAYPOINT';"];
wp4 setWaypointTimeout [15,15,15]; 


//Cycle waypoint
wp5 = GroupJET addwaypoint [position Player, 100]; 
wp5 waypointAttachVehicle vehicle player; 
wp5 setwaypointtype "Cycle"; 
wp5 setWaypointCombatMode "YELLOW"; 
wp5 setWaypointFormation "WEDGE"; 
wp5 setWaypointSpeed "FULL"; 
wp5 setWaypointBehaviour "AWARE"; 
//wp5 setWaypointCompletionRadius 10;
wp5 setWaypointStatements ["true", "hint '';"];
wp5 setWaypointTimeout [60,60,60]; 


{_x setSkill 1} foreach units GroupJET;

jetcas = createTrigger ["EmptyDetector",getPos player]; 
jetcas setTriggerArea [500, 500, 0, false];
jetcas setTriggerActivation ["EAST", "NOT PRESENT", false];
jetcas setTriggerTimeout [270, 270, 270, false ];
jetcas setTriggerStatements ["this","player sideChat ""Eagle Squadron leader : Enemy Armor Targets have been Neutralized, OVER""; [] execVM ""AISUPPORT\support-req\movejet.sqf""" , ""];

jetcas2 = createTrigger ["EmptyDetector",getPos player]; 
jetcas2 setTriggerArea [10000, 10000, 0, false];
jetcas2 setTriggerActivation ["WEST", "PRESENT", false];
jetcas2 setTriggerTimeout [360, 360, 360, false ];
jetcas2 setTriggerStatements ["this", "player sideChat ""Squadron Eagle: Returning back to airfield to rearm and refuel, over""; [] execvm ""AISUPPORT\support-req\donejet.sqf""" , ""];

jetcas3 = createTrigger ["EmptyDetector", getPos player]; 
jetcas3 setTriggerArea [0, 0, 0, false];
jetcas3 setTriggerActivation ["NONE", "NOT PRESENT", false];
jetcas3 setTriggerStatements ["!(alive JetAPilot1) && !(alive JetBPilot1) && !(alive JetCPilot1) && !(alive JetDPilot1)", "PAPABEAR SideChat ""Fighter Squadron Eagle has been destroyed""; [] execvm ""AISUPPORT\support-req\donejet.sqf""" , ""];
sleep 420; 
player setVariable ["JsupportAvailable", "JsupportAvailable"];
hint "Fighter Squadron Falcon on Carrier deck and ready for support if needed!";

sqf called movejet

wpm2 = GroupJET addwaypoint [position player, 3000];
wpm2 setwaypointtype "MOVE";
wpm2 setWaypointSpeed "full";
wpm2 setWaypointCompletionRadius 0;
wpm2 setWaypointStatements ["true", "[] execvm ""AISUPPORT\support-req\donejet.sqf"""];
hint "THE MOVE waypoint working for jets 4 MIN HAVE PASSED,";

sqf called donejet

{deleteVehicle _x} forEach (units GroupJET);
deleteVehicle JetA;
deleteVehicle JetAPilot1;
deleteVehicle JetB;
deleteVehicle JetBPilot1;
deleteVehicle JetC;
deleteVehicle JetCPilot1;
deleteVehicle JetD;
deleteVehicle JetDPilot1;
deleteVehicle Jetcas;
deleteVehicle Jetcas2;
deleteVehicle Jetcas3;
hint " Fighter Squadron has been deleted!";

sleep 30;

jet = true;

publicVariable "jet";

Hope this can help someone esle AVIBIRD.

Edited by AVIBIRD 1

Share this post


Link to post
Share on other sites

Good job taking the time and trying to figure this out on your own AVIBIRD 1. Just a couple of quick pointers, to help eliminate/streamline the process:

using setVariable/getVariable, it is often times easier if you are just checking a boolean state to have the variable set to true/false. Then just check - if !(player getVariable "JsupportAvailable") instead of the == comparison

[] exec "AISUPPORT\menu\close_menu.sqf"; Does this line work??? should be execVM for .sqf

donejet could be simplified to just a couple of lines... {deleteVehicle vehicle _x; deleteVehicle _x} forEach units _grp; deleteGroup _grp; can be done by passing the group to this script

All the global variables are not necessary.

You could use BIS_fnc_spawnVehicle

I applaud for the time and effort put in. Most on these forums anymore just want an answer, and don't want to understand why it works...:D

Edited by panther42

Share this post


Link to post
Share on other sites

Thanks panther42 Yes the line [] exec "AISUPPORT\menu\close_menu.sqf"; Does work with and without the VM. I don't understand why But it works with it and without it.

I do know deleteVehicle vehicle _x; deleteVehicle _x} forEach units _grp; but got into a habit writing all the units in the group the long way!

The whole setVariable/getVariable thing is still very foreign to me and I am using the codelines that I know works in scripts!

the whole setVariable at the top of the script is to allow the user to have some options to set time factors to allow the script to be used again. I can't understand why a mission designer would make a script with no lmits on how many times or a time delay for the script to be called during the mission.

This is a small part of a complete combat/FOB support script and mission called DOMINATION company of heroes that I am working on. Hopefully I can complete it before ARMA3 comes out lol.

Edited by AVIBIRD 1

Share this post


Link to post
Share on other sites

I hate this game lol. After a long night of test playing my mission and combat support script that I am working on. The planes will still leave the current AO to target other enemy units on the map. The distance is a lot less NOW using the codelines above. The average range of an AO within the mission is the size of a town. (Bluefor needs to capture all the towns to win). I am using DAC in my mission which has 7 random FOB's as well as infantry and armor partols throughout the mission. With the code above the planes will target and stay around 3000-4000 meters (better then moving around the whole map) the average AO size is ~400<1000 meters. The issue now is if the FOB's get spawned within the 3000-4000 meters the planes will target the FOB's first and not the town to capture. The FOB's usually win because I added a lot more AA defense to the FOB's setup within the DAC. If multiple FOB'S are within the area my squad of planes have no chance): I guess the Bluefor needs to secure the area of FOB's before calling in Airsupport with planes. I have no issues with gunships using the code they stay at the AO. Any suggestions would be great if not. It's time to move on with other issues within the mission/script lol. AVIBIRD.

Edited by AVIBIRD 1

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  

×