Jump to content
Sign in to follow this  
-ami- mofo

Tweak this spawn aircraft script (help with height/speed/direction)

Recommended Posts

Hi I'm using this script which spawns the aircraft and makes it keep cycling through the markers.

I'd like to also set the height, speed and direction as it spawns as well (and keep up the height and speed flying through the markers).

I've looked around and all the other scripts 1st lines look different to this with getpos select blah blah so I'm not sure how to amend what I already have to achieve what I want to. If somebody could use their scripting skills to change what I have here that would be greatly appreciated.

ag1spawn = [getMarkerPos "ag1spawn", 0, "I_Plane_Fighter_03_CAS_F", INDEPENDENT] call bis_fnc_spawnvehicle;
ag1air = ag1spawn select 0;	//the aircraft
ag1crew = ag1spawn select 1;	//the units that make up the crew
ag1 = ag1spawn select 2;	//the group
{_x allowFleeing 0} forEach units ag1;

waypoint0 = ag1 addwaypoint[getmarkerpos"ag1move1",0];
waypoint0 setwaypointtype"Move"; 

waypoint1 = ag1 addwaypoint[getmarkerpos"ag1move2",0];
waypoint1 setwaypointtype"Move";

waypoint2 = ag1 addwaypoint[getmarkerpos"ag1move3",0];
waypoint2 setwaypointtype"Move";

waypoint0 = ag1 addwaypoint[getmarkerpos"ag1move1",0];
waypoint0 setwaypointtype"Move";

waypoint0 setwaypointtype "CYCLE"; 


[ag1, 1] setWaypointSpeed "FULL";
[ag1, 1] setWaypointCombatMode "RED";
[ag1, 1] setWaypointBehaviour "AWARE";

I also have one last small question... I see a lot of scripts have an underscore at the start of each line, like that _x allowfleeing 0 part. Is there an advantage to using that? This is a script to be used in a small MP mission so do I need to use _ at each line?

Thank you

Share this post


Link to post
Share on other sites

I've got a similar CAS patrol script that I don't want to share yet.

As you want to improve your own script how about this:

ag1spawn = [getMarkerPos "ag1spawn", 0, "I_Plane_Fighter_03_CAS_F", INDEPENDENT] call bis_fnc_spawnvehicle;
ag1air = ag1spawn select 0;	//the aircraft
ag1crew = ag1spawn select 1;	//the units that make up the crew
ag1 = ag1spawn select 2;	//the group
{_x allowFleeing 0} forEach units ag1;

ag1height = 250;
ag1air flyinheight ag1height;
ag1air setpos [getposATL ag1air select 0, getposATL ag1air select 1, ag1height];

reldir = [getmarkerpos "ag1spawn",getmarkerpos "ag1move1"] call BIS_fnc_dirTo;
ag1air setdir reldir;

waypoint0 = ag1 addwaypoint[getmarkerpos"ag1move1",0];
waypoint0 setwaypointtype"Move"; 

waypoint1 = ag1 addwaypoint[getmarkerpos"ag1move2",0];
waypoint1 setwaypointtype"Move";

waypoint2 = ag1 addwaypoint[getmarkerpos"ag1move3",0];
waypoint2 setwaypointtype"Move";

waypoint0 = ag1 addwaypoint[getmarkerpos"ag1move1",0];
waypoint0 setwaypointtype"Move";

waypoint0 setwaypointtype "CYCLE"; 


[ag1, 1] setWaypointSpeed "FULL";
[ag1, 1] setWaypointCombatMode "RED";
[ag1, 1] setWaypointBehaviour "AWARE";

The five lines above the waypoints are probably what you were looking for. ;)

I used the dirTo functions to make the jet look into the direction of the first marker after spawning.

The underscore makes variables local to the script only so only the script itself knows what _ag1air is, which is a huge advantage if you want to run a script multiple times within a mission.

Without underscores the variables are usable in the entire mission by other scripts, so ag1air would reference to your jet in any other script running in the same mission.

for your script it would practically make no difference, no idea about performance impact but it should be non existant.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks Grumpy the spawn height and direction work a treat. Only problem was the plane spawned with no forward momentum and unless the spawn height was at least 300m above ground it would crash.

I altered it to

ag1height = 700;
ag1air flyinheight 250;

So now it has time to gain speed as it falls and then continue at 250m so all good :)

I get what you said about the variable too so thanks for that as well. I'm going to start reading up about scripting over the Easter break so I don't have to ask as many questions and maybe start to know what I'm doing rather than just tinkering and testing with stuff I know very little about :o

Share this post


Link to post
Share on other sites

Well you can repace your spawn lines with these:

ag1spawn = createVehicle ["I_Plane_Fighter_03_CAS_F",getmarkerpos "ag1spawn", [], 0, "FLY"];
createvehiclecrew ag1spawn;

In general I'd change your script to look like this:

_ag1 = createVehicle ["I_Plane_Fighter_03_CAS_F",getmarkerpos "ag1spawn", [], 0, "FLY"];
createvehiclecrew _ag1;
_ag1 allowfleeing 0;

_ag1height = 250;
_ag1 flyinheight _ag1height;
_ag1 setpos [getposATL _ag1 select 0, getposATL _ag1 select 1, _ag1height];

_reldir = [getmarkerpos "ag1spawn",getmarkerpos "ag1move1"] call BIS_fnc_dirTo;
_ag1 setdir _reldir;

waypoint0 = _ag1 addwaypoint[getmarkerpos"ag1move1",0];
waypoint0 setwaypointtype"Move"; 

waypoint1 = _ag1 addwaypoint[getmarkerpos"ag1move2",0];
waypoint1 setwaypointtype"Move";

waypoint2 = _ag1 addwaypoint[getmarkerpos"ag1move3",0];
waypoint2 setwaypointtype"Move";

waypoint0 = _ag1 addwaypoint[getmarkerpos"ag1move1",0];
waypoint0 setwaypointtype"Move";

waypoint0 setwaypointtype "CYCLE"; 


[_ag1, 1] setWaypointSpeed "FULL";
[_ag1, 1] setWaypointCombatMode "RED";
[_ag1, 1] setWaypointBehaviour "AWARE";

Got no access to A3 right now but that should work.

This way you can run it multiple times.

You could further advance it to use a marker array instead of having to rewrite the script for everytime you want to use more or less waypoints.

Cheers

Share this post


Link to post
Share on other sites

Hi Grumpy I tried that one... still spawned with no forward momentum and didn't follow the waypoints either apart from the 1st one... but then just kept going in that direction.

The original one that you posted with my small alteration still works fine though.

Share this post


Link to post
Share on other sites

Thats a bug isn't it ?

bis_fnc_spawnvehicle spawns helicopters just fine put all planes go down instantly and crash into the ground !

    _AirPos = [(getmarkerpos _spawnPos select 0), (getmarkerpos _spawnPos select 1), 100];
   _vehicle = [_AirPos, random 360, "B_UAV_02_CAS_F", west] call bis_fnc_spawnvehicle;
   _veh = _vehicle select 0;
   _vehgrp = _vehicle select 2;
   CAS_plane1 = _veh;
   _veh setposATL [(getPosATL _veh) select 0, (getPosATL _veh) select 1, 100];
   _veh flyInHeight 100;

This does not work with a plane because it crashes, but with a heli everything works.

I need to set the hight to 300m otherwise crash...

Share this post


Link to post
Share on other sites

You'll need to specify a direction in bis_fnc_spawnvehicle and use setVelocity.

I use a function to make markers, move logics and spin the logics in the direction aircraft will be initially spawning and traveling.

This is how the function works.

Function Air_Dest_fnc makes spawn marker and An AO or destination marker.

Function then spins spawn marker in direction of AO marker

Function then moves a preplaced logic like invisible helipad named air_pat_east to spawn position marker and spins it in direction of AO marker.

For me its been more reliable to use preplaced logics then move them when you need by script or function. Logic names are air_pat_pos and air_pat_east

The choppers need to be handled slightly different from fixed wing.

This is working flawlessly.

Hopefully this will give you an idea.

Air_Dest_fnc =
{
//Air_Dest_fnc by Jigsor
private ["_posHpad","_posnewAO","_currentmarker","_wpcyclemark","_spwnaire","_spwnairepos","_spwnairedir","_spwnairw","_spwnairwpos","_spwnairwdir","_spwnairdire","_spwnairenewdir","_spwnairdirw","_spwnairwnewdir"];	
_posHpad = [ getPosATL air_pat_pos select 0, (getPosATL air_pat_pos select 1)];	
if (!isNil "oamarker") then
{
	_posnewAO = [ getMarkerPos "oamarker" select 0, (getMarkerPos "oamarker" select 1)];
	if (_posHpad distance _posnewAO == 0) exitwith {};
	if !(_posHpad distance _posnewAO == 0) then 	
	{
		//sleep 5;
		sleep 0.2;
		deleteMarker "oamarker";
		_currentmarker = createMarker ["oamarker", getposATL air_pat_pos];
		_currentmarker setMarkerShape "ELLIPSE";
		"oamarker" setMarkerSize [1, 1];
		"oamarker" setMarkerShape "ICON";
		"oamarker" setMarkerType "mil_dot";//set marker type to "mil_dot" for debug. Set "Empty" for invisible
		"oamarker" setMarkerColor "ColorRed";//ColorRedAlpha "ColorRed"
		"oamarker" setMarkerText "Enemy Occupied";
		"oamarker" setMarkerPos (getposATL air_pat_pos);
		publicVariable "oamarker";
		//publicVariable "air_pat_pos";			
		sleep 0.2;
		if (!isNil "cyclewpmrk") then {deleteMarker "cyclewpmrk";};
		_wpcyclemark = createMarker ["cyclewpmrk", getposATL air_pat_pos];
		_wpcyclemark setMarkerShape "ELLIPSE";
		"cyclewpmrk" setMarkerSize [1, 1];
		"cyclewpmrk" setMarkerShape "ICON";
		"cyclewpmrk" setMarkerType "Empty";//set marker type to "mil_dot" for debug. Set "Empty" for invisible
		"cyclewpmrk" setMarkerColor "ColorRed";
		"cyclewpmrk" setMarkerText "WPcycle";
		"cyclewpmrk" setMarkerPos [(getMarkerPos "oamarker" select 0) + (2800 * sin floor(random 360)), (getMarkerPos "oamarker" select 1) + (2800 * cos floor(random 360)), 0];//cycle waypoint distance is 2800 meters from AO marker			
		publicVariable "cyclewpmrk";						
		sleep 0.2;
		air_pat_cycle setPosATL getMarkerPos "cyclewpmrk";
		if (!isNil "spawnaire") then {deleteMarker "spawnaire";};
		_spwnaire = createMarker ["spawnaire", getposATL air_pat_pos];
		_spwnaire setMarkerShape "ELLIPSE";
		_spwnairepos = getMarkerPos "cyclewpmrk";
		_spwnairedir = [_spwnairepos, air_pat_pos] call BIS_fnc_dirTo;
		"spawnaire" setMarkerSize [1, 1];
		"spawnaire" setMarkerShape "ICON";
		"spawnaire" setMarkerType "Empty";//set marker type to "mil_dot" for debug. Set "Empty" for invisible
		"spawnaire" setMarkerColor "ColorRed";
		"spawnaire" setMarkerText "SpawnAirEst";
		"spawnaire" setMarkerPos [(getMarkerPos "oamarker" select 0) + (2800 * sin (_spwnairedir -300)), (getMarkerPos "oamarker" select 1) + (2800 * cos (_spwnairedir -300)), 0];//East Air spawn point distance is 2800 meters from AO marker
		_spwnairdire = getMarkerPos "spawnaire";
		_spwnairenewdir = [_spwnairdire, air_pat_pos] call BIS_fnc_dirTo;
		"spawnaire" setMarkerDir _spwnairenewdir;//point marker direction towards oamarker
		publicVariable "spawnaire";			
		sleep 0.2;
		//air_pat_east setPosATL _spwnairdire;
		air_pat_east setPosATL getMarkerPos "spawnaire";
		air_pat_east setDir _spwnairenewdir;
		if (!isNil "spawnairw") then {deleteMarker "spawnairw";};
		_spwnairw = createMarker ["spawnairw", getposATL air_pat_pos];
		_spwnairw setMarkerShape "ELLIPSE";
		"spawnairw" setMarkerSize [1, 1];
		"spawnairw" setMarkerShape "ICON";
		"spawnairw" setMarkerType "Empty";//set marker type to "mil_dot" for debug. Set "Empty" for invisible
		"spawnairw" setMarkerColor "ColorRed";
		"spawnairw" setMarkerText "Retreat";
		"spawnairw" setMarkerPos [(getMarkerPos "oamarker" select 0) + (2800 * sin (_spwnairedir -60)), (getMarkerPos "oamarker" select 1) + (2800 * cos (_spwnairedir -60)), 0];//East Air spawn point distance is 2800 meters from AO marker
		_spwnairdirw = getMarkerPos "spawnairw";
		_spwnairwnewdir = [_spwnairdirw, air_pat_pos] call BIS_fnc_dirTo;
		"spawnairw" setMarkerDir _spwnairwnewdir;//point marker direction towards oamarker	
		publicVariable "spawnairw";
		sleep 0.1;
		//air_pat_west setPosATL _spwnairdirw;
		air_pat_west setPosATL getMarkerPos "spawnairw";
		air_pat_west setDir _spwnairwnewdir;
		//markersready = true;
		//publicVariable "markersready";// required for airpate1.sqf					
	};
} else {
	if (isNil "oamarker") then
	{
		_currentmarker = createMarker ["oamarker", getposATL air_pat_pos];
		_currentmarker setMarkerShape "ELLIPSE";
		"oamarker" setMarkerSize [1, 1];
		"oamarker" setMarkerShape "ICON";
		"oamarker" setMarkerType "mil_dot";//set marker type to "mil_dot" for debug. Set "Empty" for invisible
		"oamarker" setMarkerColor "ColorRed";
		"oamarker" setMarkerText "Enemy Occupied";
		"oamarker" setMarkerPos (getposATL air_pat_pos);
		publicVariable "oamarker";
		//publicVariable "air_pat_pos";
		sleep 0.2;			
		_wpcyclemark = createMarker ["cyclewpmrk", getposATL air_pat_pos];
		_wpcyclemark setMarkerShape "ELLIPSE";
		"cyclewpmrk" setMarkerSize [1, 1];
		"cyclewpmrk" setMarkerShape "ICON";
		"cyclewpmrk" setMarkerType "Empty";//set marker type to "mil_dot" for debug. Set "Empty" for invisible
		"cyclewpmrk" setMarkerColor "ColorRed";
		"cyclewpmrk" setMarkerText "WPcycle";
		"cyclewpmrk" setMarkerPos [(getMarkerPos "oamarker" select 0) + (2800 * sin floor(random 360)), (getMarkerPos "oamarker" select 1) + (2800 * cos floor(random 360)), 0];//cycle waypoint distance is 2800 meters from AO marker			
		publicVariable "cyclewpmrk";
		sleep 0.2;
		air_pat_cycle setPosATL getMarkerPos "cyclewpmrk";
		_spwnaire = createMarker ["spawnaire", getposATL air_pat_pos];
		_spwnaire setMarkerShape "ELLIPSE";
		_spwnairepos = getMarkerPos "cyclewpmrk";
		_spwnairedir = [_spwnairepos, air_pat_pos] call BIS_fnc_dirTo;
		"spawnaire" setMarkerSize [1, 1];
		"spawnaire" setMarkerShape "ICON";
		"spawnaire" setMarkerType "Empty";//set marker type to "mil_dot" for debug. Set "Empty" for invisible
		"spawnaire" setMarkerColor "ColorRed";
		"spawnaire" setMarkerText "SpawnAirEst";
		"spawnaire" setMarkerPos [(getMarkerPos "oamarker" select 0) + (2800 * sin (_spwnairedir -300)), (getMarkerPos "oamarker" select 1) + (2800 * cos (_spwnairedir -300)), 0];//East Air spawn point distance is 2800 meters from AO marker
		_spwnairdire = getMarkerPos "spawnaire";
		_spwnairenewdir = [_spwnairdire, air_pat_pos] call BIS_fnc_dirTo;
		"spawnaire" setMarkerDir _spwnairenewdir;//point marker direction towards oamarker
		publicVariable "spawnaire";
		sleep 0.2;	
		//air_pat_east setPosATL _spwnairdire;
		air_pat_east setPosATL getMarkerPos "spawnaire";
		air_pat_east setDir _spwnairenewdir;
		_spwnairw = createMarker ["spawnairw", getposATL air_pat_pos];
		_spwnairw setMarkerShape "ELLIPSE";
		"spawnairw" setMarkerSize [1, 1];
		"spawnairw" setMarkerShape "ICON";
		"spawnairw" setMarkerType "Empty";//set marker type to "mil_dot" for debug. Set "Empty" for invisible
		"spawnairw" setMarkerColor "ColorRed";
		"spawnairw" setMarkerText "Retreat";
		"spawnairw" setMarkerPos [(getMarkerPos "oamarker" select 0) + (2800 * sin (_spwnairedir -60)), (getMarkerPos "oamarker" select 1) + (2800 * cos (_spwnairedir -60)), 0];//East Air spawn point distance is 2800 meters from AO marker
		_spwnairdirw = getMarkerPos "spawnairw";
		_spwnairwnewdir = [_spwnairdirw, air_pat_pos] call BIS_fnc_dirTo;
		"spawnairw" setMarkerDir _spwnairwnewdir;//point marker direction towards oamarker
		publicVariable "spawnairw";
		sleep 0.2;
		//air_pat_west setPosATL _spwnairdirw;
		air_pat_west setPosATL getMarkerPos "spawnairw";
		air_pat_west setDir _spwnairwnewdir;
		//markersready = true;
		//publicVariable "markersready";// required for airpate1.sqf					
	};
};
};

// AirPatrolEast.sqf by Jigsor
// runs from init_server.sqf
// nul = [] execVM "scripts\AirPatrolEast.sqf";
if (!isServer) exitWith {};

private ["_currentmarker","_newPosAELogic","_newPosAELogicMrk","_aire1","_aire2","_aire3"];

sleep 20;//wait for markers and logics

airhunterE1 = ObjNull;
airhunterE2 = ObjNull;
airhunterE3 = ObjNull;		

if (DebugEnabled > 0) then
{
if (!isNil "curAEspawnpos") then {deleteMarker "curAEspawnpos";};		
_currentmarker = createMarker ["curAEspawnpos", getMarkerPos "spawnaire"];
_currentmarker setMarkerShape "ELLIPSE";		
"curAEspawnpos" setMarkerSize [2, 2];
"curAEspawnpos" setMarkerShape "ICON";
"curAEspawnpos" setMarkerType "mil_dot";//"Empty"
"curAEspawnpos" setMarkerColor "ColorOrange";
"curAEspawnpos" setMarkerText "SpawnAirInitial";	
publicVariable "curAEspawnpos";
sleep 2;	
_newPosAELogic = getPos EastAirLogic;	
_newPosAELogicMrk = getMarkerPos "curAEspawnpos";
};

// Modded Jets
_aire1 = [] spawn
{	
airhunterE1 = ObjNull;
random_w_player1 = ObjNull;
"airhunterE1" addPublicVariableEventHandler {call compile format ["%1",_this select 1]};
"random_w_player1" addPublicVariableEventHandler {call compile format ["%1",_this select 1]};
for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{				
	if ((isNull airhunterE1) || (not(alive airhunterE1))) then
	{
		private ["_speed","_SAdir","_randomAltitudes","_maxalt","_height","_randomTypes","_maxtype","_type","_vehicle","_veh","_vehgrp","_vel","_VarHunterName","_wp0","_spwnairdir","_poscreate"];

		sleep AirRespawnDelay;						
		//call AirEast_move_logic_fnc;

		if (PatroleWPmode > 0) then
		{
			random_w_player1 = ObjNull;	
			publicVariable "random_w_player1";
			sleep 3;			
			call find_me3_fnc;
			sleep 3;
			//diag_log text format ["airhunterE1 West Human Target3: %1", random_w_player1];
		};

		_poscreate = getMarkerPos "spawnaire";
		_speed = 180;// starting speed			
		_SAdir = getDir air_pat_east;// Velocity Direction			
		_spwnairdir = [getPosATL air_pat_east, getPosATL air_pat_pos] call BIS_fnc_dirTo;// Spawn Direction
		_randomAltitudes = [275,375,475,575];// random altitudes	
		_maxalt = (count _randomAltitudes)-1;// count random altitudes			
		_height = _randomAltitudes select (round random _maxalt);// select random altitude
		_randomTypes = ["JS_JC_SU35","IVORY_MIG29K_1"];			
		//_randomTypes = ["M2000C_CAS_GBU","M2000C","M2000C_CAP"];// A3 HAFM Mod //can't lock on to
		_maxtype = (count _randomTypes)-1;// count random types
		_type = _randomTypes select (round random _maxtype);// select random type		

		_vehicle = [getPosATL air_pat_east, _SAdir, _type, EAST] call bis_fnc_spawnvehicle;
		sleep jig_tvt_globalsleep;	
		_veh = _vehicle select 0;

		_vel = velocity _veh;
		_veh setpos [(_poscreate select 0) + (sin (_spwnairdir -180)), (_poscreate select 1) + (cos (_spwnairdir -180)), _height];
		_veh setVelocity [(_vel select 0)+(sin _SAdir*_speed),(_vel select 1)+ (cos _SAdir*_speed),(_vel select 2)];

		_vehgrp = _vehicle select 2 ;// group of vehicle			
		if (BTC_p_skill == 1) then {[_vehgrp] call BTC_AI_init;};			
		_veh addEventHandler ["killed", {handle = [_this select 0] execVM "Scripts\bury.sqf"}];
		{_x addEventHandler ["killed", {handle = [_this select 0] execVM "Scripts\bury.sqf"}]} forEach (units _vehgrp);

		_VarHunterName = "airhunterE1";
		_veh setVehicleVarName _VarHunterName;
		_veh Call Compile Format ["%1=_This ; PublicVariable ""%1""",_VarHunterName];

		// Initial Waypoint
		_wp0 = _vehgrp addWaypoint [getPosATL air_pat_east, 200];   
		_wp0 setWaypointType "MOVE";
		_wp0 setWaypointBehaviour "AWARE";
		_wp0 setWaypointCombatMode "green";
		_wp0 setWaypointStatements ["true", ""];	

		if (!isNull random_w_player1) then
		{
			// Hunt Player
			nul = [airhunterE1,3000,random_w_player1] call find_west_target_fnc;
		}
		else
		{
			// Guard Towns				
			nul = [airhunterE1] call east_AO_guard_cycle_wp;
		};			

		waitUntil {sleep 1; (!alive _veh) || ((count crew _veh) < 1) || (!canmove _veh)};
		if (((count crew _veh) < 1) && (alive _veh)) then {_veh setDamage 1};			
		{
			if (alive _x) then {_x setDamage 1; sleep 0.1}
		} forEach (crew _veh);			
		if (!alive _veh) then
		{
			{
				if (alive _x) then {_x setDamage 1; sleep 0.1}
			} forEach (units _vehgrp);
		};
		if (alive _veh) then			
		{
			_veh setDamage 1;
			{
				if (alive _x) then {_x setDamage 1; sleep 0.1}
			} forEach (units _vehgrp);				
		};
	};
	sleep (random 600);
};
};
sleep (random 600);

// Stock A3 Choppers
_aire2 = [] spawn
{
airhunterE2 = ObjNull;
random_w_player2 = ObjNull;
"airhunterE2" addPublicVariableEventHandler {call compile format ["%1",_this select 1]};
"random_w_player2" addPublicVariableEventHandler {call compile format ["%1",_this select 1]};
for [{_loop=0}, {_loop<1}, {_loop=_loop}] do	{

	if ((isNull airhunterE2) || (not(alive airhunterE2))) then
	{
		private ["_speed","_SAdir","_randomAltitudes","_maxalt","_height","_randomTypes","_maxtype","_type","_vehicle","_veh","_vehgrp","_vel","_VarHunterName","_wp0","_spwnairdir","_poscreate"];

		sleep AirRespawnDelay;						
		//call AirEast_move_logic_fnc;

		if (PatroleWPmode > 0) then
		{
			random_w_player2 = ObjNull;	
			publicVariable "random_w_player2";
			sleep 3;			
			call find_me2_fnc;
			sleep 3;
			//diag_log text format ["AirhunterE2 West Human Target2: %1", random_w_player2];
		};

		_poscreate = getMarkerPos "spawnaire";			
		_speed = 70;// starting speed			
		_SAdir = getDir air_pat_east;// Velocity Direction			
		_spwnairdir = [getPosATL air_pat_east, getPosATL air_pat_pos] call BIS_fnc_dirTo;// Spawn Direction
		_randomAltitudes = [50,75,100];// random altitudes	
		_maxalt = (count _randomAltitudes)-1;// count random altitudes			
		_height = _randomAltitudes select (round random _maxalt);// select random altitude
		_randomTypes = ["O_Heli_Attack_02_black_F"];// stock A3 choppers. Only "O_Heli_Attack_02_black_F" will engage infantry
		_maxtype = (count _randomTypes)-1;// count random types
		_type = _randomTypes select (round random _maxtype);// select random type

		_vehicle = [getPosATL air_pat_east, _SAdir, _type, EAST] call bis_fnc_spawnvehicle;
		sleep jig_tvt_globalsleep;	
		_veh = _vehicle select 0;

		_vel = velocity _veh;
		_veh setpos [(_poscreate select 0) + (sin (_spwnairdir -180)), (_poscreate select 1) + (cos (_spwnairdir -180)), _height];	
		//_veh setpos (_veh modelToWorld [(_poscreate select 0) + (sin (_spwnairdir -180)), (_poscreate select 1) + (cos (_spwnairdir -180)), _height]);			
		_veh setVelocity [(_vel select 0)+(sin _SAdir*_speed),(_vel select 1)+ (cos _SAdir*_speed),(_vel select 2)];

		_vehgrp = _vehicle select 2 ;// group of vehicle					
		if (BTC_p_skill == 1) then {[_vehgrp] call BTC_AI_init;};
		_veh addEventHandler ["killed", {handle = [_this select 0] execVM "Scripts\bury.sqf"}];
		{_x addEventHandler ["killed", {handle = [_this select 0] execVM "Scripts\bury.sqf"}]} forEach (units _vehgrp);
		_veh addeventhandler ["HandleDamage", {if (((_this select 4) isKindOf "MissileCore") || ((_this select 4) isKindOf "rocketCore")) then { 1; } else { _this select 2; }; }];// Destroy Enemy Air Vehicles With 1 Missle or Rocket			

		_VarHunterName = "airhunterE2";
		_veh setVehicleVarName _VarHunterName;
		_veh Call Compile Format ["%1=_This ; PublicVariable ""%1""",_VarHunterName];

		// Initial Waypoint
		_wp0 = _vehgrp addWaypoint [getPosATL air_pat_east, 200];
		_wp0 setWaypointType "MOVE";
		_wp0 setWaypointBehaviour "AWARE";
		_wp0 setWaypointCombatMode "green";
		_wp0 setWaypointStatements ["true", ""];	

		if (!isNull random_w_player2) then
		{
			// Hunt Player
			nul = [airhunterE2,3100,random_w_player2] call find_west_target_fnc;
		}
		else
		{
			// Guard Towns				
			nul = [airhunterE2] call east_AO_guard_cycle_wp;	
		};

		waitUntil {sleep 1; (!alive _veh) || ((count crew _veh) < 1) || (!canmove _veh)};//count crew _veh == 0
		if (((count crew _veh) < 1) && (alive _veh)) then {_veh setDamage 1};			
		{
			if (alive _x) then {_x setDamage 1; sleep 0.1}
		} forEach (crew _veh);			
		if (!alive _veh) then
		{
			{
				if (alive _x) then {_x setDamage 1; sleep 0.1}
			} forEach (units _vehgrp);
		};
		if (alive _veh) then			
		{
			_veh setDamage 1;
			{
				if (alive _x) then {_x setDamage 1; sleep 0.1}
			} forEach (units _vehgrp);				
		};
	};
	sleep (random 600);
};
};
sleep (random 600);

// Stock A3 Jets
_aire3 = [] spawn
{	
airhunterE3 = ObjNull;
random_w_player3 = ObjNull;
"airhunterE3" addPublicVariableEventHandler {call compile format ["%1",_this select 1]};
"random_w_player3" addPublicVariableEventHandler {call compile format ["%1",_this select 1]};
for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{				
	if ((isNull airhunterE3) || (not(alive airhunterE3))) then
	{
		private ["_speed","_SAdir","_randomAltitudes","_maxalt","_height","_randomTypes","_maxtype","_type","_vehicle","_veh","_vehgrp","_vel","_VarHunterName","_wp0","_spwnairdir","_poscreate"];

		sleep AirRespawnDelay;						
		//call AirEast_move_logic_fnc;

		if (PatroleWPmode > 0) then
		{
			random_w_player3 = ObjNull;	
			publicVariable "random_w_player3";
			sleep 3;			
			call find_me3_fnc;
			sleep 3;
			//diag_log text format ["AirhunterE3 West Human Target3: %1", random_w_player3];
		};

		_poscreate = getMarkerPos "spawnaire";
		_speed = 180;// starting speed			
		_SAdir = getDir air_pat_east;// Velocity Direction			
		_spwnairdir = [getPosATL air_pat_east, getPosATL air_pat_pos] call BIS_fnc_dirTo;// Spawn Direction
		_randomAltitudes = [275,375,475,575];// random altitudes	
		_maxalt = (count _randomAltitudes)-1;// count random altitudes			
		_height = _randomAltitudes select (round random _maxalt);// select random altitude
		_randomTypes = ["I_Plane_Fighter_03_AA_F","I_Plane_Fighter_03_CAS_F","O_Plane_CAS_02_F"];
		_maxtype = (count _randomTypes)-1;// count random types
		_type = _randomTypes select (round random _maxtype);// select random type		

		_vehicle = [getPosATL air_pat_east, _SAdir, _type, EAST] call bis_fnc_spawnvehicle;
		sleep jig_tvt_globalsleep;	
		_veh = _vehicle select 0;

		_vel = velocity _veh;
		_veh setpos [(_poscreate select 0) + (sin (_spwnairdir -180)), (_poscreate select 1) + (cos (_spwnairdir -180)), _height];
		_veh setVelocity [(_vel select 0)+(sin _SAdir*_speed),(_vel select 1)+ (cos _SAdir*_speed),(_vel select 2)];

		_vehgrp = _vehicle select 2 ;// group of vehicle			
		if (BTC_p_skill == 1) then {[_vehgrp] call BTC_AI_init;};
		_veh addEventHandler ["killed", {handle = [_this select 0] execVM "Scripts\bury.sqf"}];
		{_x addEventHandler ["killed", {handle = [_this select 0] execVM "Scripts\bury.sqf"}]} forEach (units _vehgrp);

		_VarHunterName = "airhunterE3";
		_veh setVehicleVarName _VarHunterName;
		_veh Call Compile Format ["%1=_This ; PublicVariable ""%1""",_VarHunterName];

		// Initial Waypoint
		_wp0 = _vehgrp addWaypoint [getPosATL air_pat_east, 200];   
		_wp0 setWaypointType "MOVE";
		_wp0 setWaypointBehaviour "AWARE";
		_wp0 setWaypointCombatMode "green";
		_wp0 setWaypointStatements ["true", ""];	

		if (!isNull random_w_player3) then
		{
			// Hunt Player
			nul = [airhunterE3,3000,random_w_player3] call find_west_target_fnc;
		}
		else
		{
			// Guard Towns				
			nul = [airhunterE3] call east_AO_guard_cycle_wp;
		};

		waitUntil {sleep 1; (!alive _veh) || ((count crew _veh) < 1) || (!canmove _veh)};
		if (((count crew _veh) < 1) && (alive _veh)) then {_veh setDamage 1};			
		{
			if (alive _x) then {_x setDamage 1; sleep 0.1}
		} forEach (crew _veh);			
		if (!alive _veh) then
		{
			{
				if (alive _x) then {_x setDamage 1; sleep 0.1}
			} forEach (units _vehgrp);
		};
		if (alive _veh) then			
		{
			_veh setDamage 1;
			{
				if (alive _x) then {_x setDamage 1; sleep 0.1}
			} forEach (units _vehgrp);				
		};					
	};
	sleep (random 600);
};
};
/*	
_randomTypes = ["I_Plane_Fighter_03_AA_F","I_Plane_Fighter_03_CAS_F","O_Plane_CAS_02_F"];// stock A3 jets				
_randomTypes = ["M2000C_CAS_GBU","M2000C","M2000C_CAP"];// A3 HAFM Mod
_randomTypes = ["JS_JC_SU35","IVORY_MIG29K_1"];// Modded John Spartan and Saul / Ivory Aircraft
_randomTypes = ["I44_Plane_G_Bf109E4_WL","I44_Plane_G_Bf109F2_WL","I44_Plane_G_Bf109G6_WL"]; // A2 I44 mod
_randomTypes = ["O_Heli_Attack_02_F","O_Heli_Attack_02_black_F","I_Heli_light_03_F","I_Heli_light_03_unarmed_F"]; //stock A3 choppers
*/

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  

×