Jump to content
nerexis

AI Jets crashing a lot

Recommended Posts

In my mission, I have some AI controlled jets set to patrol some area on given height. After they encounter enemy they attack them, but usualy they crash into terrain because they fly too low when they strike target. 
How to prevent such behavior or force them to fly and attack from given height or prevent them from descending during attack?

  • Like 1

Share this post


Link to post
Share on other sites

Hi nerexis.

 

Do you use Loiter waypoint with Loiter Altitude other than -1? If thats the case it might hold on to that and messes things up

Just a thought! :P

  • Like 1

Share this post


Link to post
Share on other sites

do they spawn with a  script or you have include the planes  with the editor?

 

 

  • Like 1

Share this post


Link to post
Share on other sites

if you are in the editor you can put this in the init of the air vehicle 

 this flyInHeight 200;

or else see this as example : ( you need to modify if you want to use )

/*
@filename: aoReinforcementJet.sqf
Author:

	Quiksilver
	
Last modified:

	26/10/2014 ArmA 1.32 by Quiksilver
	
Description:

	Spawn an enemy CAS jet
______________________________________________________*/

private ["_aoPos","_spawnPos","_jetSelect","_casArray","_jetLimit","_jetPilot","_jetActual","_new"];

_casArray = ["O_Plane_CAS_02_F","I_Plane_Fighter_03_AA_F"];

_jetLimit = 2;
	
_new = FALSE;
	
if ((count enemyCasArray) < _jetLimit) then {

	if ((count enemyCasArray) < 1) then {_new = TRUE;} else {_new = FALSE;};
	
	_spawnPos = [(random 30000),(random 30000),3000];
	_aoPos = getMarkerPos currentAO;
	if (isNull enemyCasGroup) then {enemyCasGroup = createGroup INDEPENDENT;};
	
	_jetPilot = enemyCasGroup createUnit ["I_C_Pilot_F",[0,0,(1000 + (random 1000))],[],0,"NONE"];
	_jetSelect = _casArray select (floor (random (count _casArray)));
	_jetActual = createVehicle [_jetSelect,_spawnPos,[],0,"NONE"];
	waitUntil {!isNull _jetActual};
	_jetActual engineOn TRUE;
	_jetActual allowCrewInImmobile TRUE;
	_jetActual flyInHeight 1000;
	_jetActual lock 2;
	_jetPilot assignAsDriver _jetActual;
	_jetPilot moveInDriver _jetActual;
	
	if (_new) then {_jetPilot setRank "COLONEL";} else {_jetPilot setRank "MAJOR";};
	enemyCasGroup setCombatMode "RED";
	enemyCasGroup setBehaviour "COMBAT";
	enemyCasGroup setSpeedMode "FULL";
	[(units enemyCasGroup)] call QS_fnc_setSkill4;
	[enemyCasGroup,_aoPos] call BIS_fnc_taskAttack;
	

	
	0 = enemyCasArray pushBack _jetActual;
	
	[_jetActual,_jetPilot] spawn {
		private ["_jetActual","_jetPos","_targetList"];
		_jetActual = _this select 0;
		_jetPilot = _this select 1;
		showNotification = ["EnemyJet","Enemy jet approaching!"]; publicVariable "showNotification";
		while {(alive _jetActual)} do {
			_jetActual setVehicleAmmo 1;
			_jetActual flyInHeight (300 + (random 850));
			_jetPos = getPosATL _jetActual;
			_targetList = _jetPos nearEntities [["Air"],7500];
			{enemyCasGroup reveal [_x,4];} count _targetList;
			sleep 60;
		};
		showNotification = ["EnemyJetDown","Enemy CAS is down. Well Done!"]; publicVariable "showNotification";
		enemyCasArray = enemyCasArray - [_jetActual];
		sleep 30;
		if (!isNull _jetActual) then {deleteVehicle _jetActual;};
		if (!isNull _jetPilot) then {deleteVehicle _jetPilot;};
	};
};

 

 

  • Like 1

Share this post


Link to post
Share on other sites

The waypoints are set as this:

_wp1 = _group addWaypoint [_aircraftInterior, 10];
_wp1 setWaypointType "MOVE";
_wp1 setWaypointSpeed "NORMAL";
_wp1 setWaypointCombatMode "RED";

_wp2 = _group addWaypoint [_aircraftInterior, 1];
_wp2 setWaypointType "GUARD";
_wp2 setWaypointSpeed "FULL";
_wp2 setWaypointCombatMode "RED";
//_wp2 setWaypointTimeout [1000,1500,2000];

_wp3 = _group addWaypoint [_aircraftHeliLandingSpot, 0];
_wp3 setWaypointType "CYCLE";

_group setCurrentWaypoint _wp1;


I spawn them in script in such way:
 

for [{_i=0}, {_i<3}, {_i=_i+1}] do
{
	_rPos = [ (_pos select 0) - 150 + random 300, (_pos select 1) - 150 + random 300, 150 ];
	_tmp = 
	[
		[
			_rPos
		],
		_group,
		"assault",
		_difficulty,
		_side,
		selectRandom _chopperTypes
		//"I_mas_MI24V"//"I_mas_MI24V"
	] call DMS_fnc_SpawnAIVehicle;
	_tmp setVehiclePosition [_rPos, [], 400, "FLY"];
	_tmp engineOn true;
	
	_tmp allowFleeing 0;
	_tmp doMove (getPosATL this);
	_tmp flyInHeight 300;
	
	
	
	_vel = velocity _tmp;
	_dir = direction _tmp;
	_speed = 150; //comment "Added speed";
	_tmp setVelocity [
		(_vel select 0) + (sin _dir * _speed), 
		(_vel select 1) + (cos _dir * _speed), 
		(_vel select 2)
	];


	{
	
		
		_x setskill ["aimingAccuracy",0.005];
		_x setskill ["aimingSpeed",0.005];
		_x setskill ["spotDistance",0.7];
		_x setskill ["spotTime",0.7];
	
	} forEach crew _tmp;	
	
	createVehicleCrew _tmp;
	(crew _tmp) joinSilent _group;
	
	_tmp setVariable["DisableFreezing",true,true];
	_tmp enableSimulation true;
	_tmp enableSimulationGlobal true;
	_tmp enableDynamicSimulation false;
	_attackChoppers pushBack _tmp;
};

(Chopper types variable contains jets too)

They only crash when striking target, because they fly too low to attack it. They usualy crash into mountain etc. They might try to engage using the minigun, maybe thats problem. How can I disable use of minigun weapon in jet by AI?
It's ok if they only use bombs.

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

×