Jump to content
Sign in to follow this  
MadMantiz

How to make AI aircraft attack buildings or even soldiers?

Recommended Posts

Hi everybody, I have recently started editing and creating my first missions in ArmA 2 and it is great fun. I have run into a few questions which I have not been able to find a clear answer for by reading and searchig the forums. It is possible the answer is out there but I have been unable to find it.

My idea is to have a group of approaching enemy aircraft, like Su-25, trying to destroy a certain building which you have to defend (for testing purposes building 369000, ID369000 (on the southeast pier in Elektrozavodsk) . I have referred the building's ID with a game logic as I found in another thread. When the building is destroyed, the mission ends.

The problem is that I cannot get any aircraft to attack it. I have tried different waypoints, differents orders (guard, destroy, seek and destroy etc) I also cannot get the approaching aircraft to fire at the player or any other soldiers at all. The only way I can get it to shoot, is if I shoot at it first. Otherwise is just keeps circling around the waypoints.

Thanks for listening, cheers!

Share this post


Link to post
Share on other sites

maybe get a laser designator, thats only thing i can think of. or you need to somehow add a 'static laser designator' so then the aircraft blow it (pardon the pun)

other than that, not sure.

Share this post


Link to post
Share on other sites

Another idea would be to give your aircraft a destroy or sad waypoint and then attach the object in question to this waypoint with `waypointAttachObject` or `waypointAttachVehicle`. This should do the trick pretty reliable.

Share this post


Link to post
Share on other sites
Another idea would be to give your aircraft a destroy or sad waypoint and then attach the object in question to this waypoint with `waypointAttachObject` or `waypointAttachVehicle`. This should do the trick pretty reliable.

Have you tried that yourself?

I am pretty sure it won`t work, because buildings have no side.

The pilot AI won`t consider it an enemy.

Share this post


Link to post
Share on other sites

@MadMantiz:

If you still look for a way to make your AI fire at buildings, here is

an invisible targets addon that i have made:

http://rapidshare.com/files/283153691/CHN_InvTar.rar.html

There is many other like that out there too, from the Arma1 times, not sure if they are compatible with Arma2, that`s why i simply made my own ones.

Hope this helps.

Simply put them right next or on to the building to be destroyed and select the opposite side of the attacking aircraft.

Choose Armor to have the aircraft fire missilesand rockets at it or MAN to simulate infantry targets.

That makes them engage the house with machine guns.

Share this post


Link to post
Share on other sites

Hi @MadMantiz:

That link does not work anymore, can you supply another please?

Cheers

Arkon2

Share this post


Link to post
Share on other sites

btw the waypoint DESTROY now actually works on pre-set island buildings, so tank marking the waypoint as building will actually travel there and hit it with its cannon until it diminishes into rubble ;)

Share this post


Link to post
Share on other sites

@Charon Productions:

Do you still have a copy of the example mission that you can repost?

@IceBreakr:

I tried that but the units (man,car,armor,air) do indeed target the building but wont fire any rounds..

Share this post


Link to post
Share on other sites

Hi guys, I wanna the F-117 addon to destroy the bridge of Nogova as an objective. how to do that? I've tried "dotarget, dowatch, dofire" non works.. in OFP

Share this post


Link to post
Share on other sites

Wrong Forum. For OFP you should ask here.

Though I'm not sure if bridges in OFP are destroyable at all :eh:

Share this post


Link to post
Share on other sites

I'm having trouble with waypointAttachVehicle.

I've found no examples and Biki does not elaborate.

What I'm tring to do is find 1 of 3 commanders in an array who is a player and set him as a waypoint for enemy AI aircraft. The AI should then engage him

Not shown within this script AI aircraft are created and then script calls one of two waypoint functions dependent on a param selection.

My other function _AOwpfnc works fine but does not attach a waypoint to a vehicle or object.

Here is the waypoint function I have so far using waypointAttachVehicle.

I've tried referencing the player in jig_west_commanders many different ways, but

The return in RPT is always

AttachedWaypoint: <NULL-object>

_chase_commanders_wpfnc = {

jig_west_commanders = [runit1,bunit1,yunit1];//bluefor squad leaders/commanders grouped in editor

_player=player;
if (_player in(jig_west_commanders select 0)) then
{
	_valid_player_commander = [];
	_valid_player_commander = _valid_player_commander + [runit1];
	_new_player_commander = _valid_player_commander select _x;
}else{
	if (isPlayer (jig_west_commanders select 1)) then
	{
		_valid_player_commander = [];
		_valid_player_commander = _valid_player_commander + [bunit1];
		_new_player_commander = _valid_player_commander select _x;
	}else{
		if (isPlayer (jig_west_commanders select 2)) then
		{
			_valid_player_commander = [];
			_valid_player_commander = _valid_player_commander + [yunit1];
				_new_player_commander = _valid_player_commander select _x;
		}else{
			call _AOwpfnc;//if no commanders available run alternate guard AO waypoint function
		};
	};
};
//	_new_player_commander = _this select 0;

//Twirly
     switch (typeName _new_player_commander) do {
     case "ARRAY": {_pos = _new_player_commander};                   //position
     case "OBJECT": {_pos = getposATL _new_player_commander};        //object
     case "STRING": {_pos = getMarkerPos _new_player_commander};     //marker
};


_wphandle = [_pilot, 300, "spawnaire", "oamarker", 1000, "SAFE", 100, "FULL", "VEE", 4, 300, "cyclewpmrk"];

_pilot         = _wphandle select 0;
_spawnRadius   = _wphandle select 1;
_spawnMarker   = _wphandle select 2;
_patrolMarker  = _wphandle select 3;
_patrolRadius  = _wphandle select 4;
_pilotBehaviour = _wphandle select 5;
_existChance   = _wphandle select 6;
_pilotSpeed     = _wphandle select 7;
_pilotFormation = _wphandle select 8;
_pilotWaittime  = _wphandle select 9;
_flyInHeight   = _wphandle select 10;
_cyclemrkr   = _wphandle select 11;

_grp = group _pilot;

_airdest = getMarkerPos "oamarker";
_poscreate = getmarkerpos "spawnaire";

_chance = ceil(random 100);
if (_chance > _existChance) then { {deleteVehicle vehicle _x; deleteVehicle _x; sleep 0.1;} forEach units _grp; };

_wp = _grp addWaypoint [_pos, 25];
_wp setWaypointBehaviour "COMBAT";
_wp setWaypointSpeed "FULL";
_wp setWaypointFormation "VEE";
_wp setWaypointType "MOVE"; 
_wp setWaypointCombatMode "Yellow";
[_grp, 1] waypointAttachVehicle _pos;
[_grp, 1] setWaypointPosition [_pos, 300];
_attachedwp = waypointAttachedVehicle [_grp,1];
diag_log text format [""];		
diag_log text format ["AttachedWaypoint: %1", _attachedwp];
};

Any ideas on the problem or examples of other scripts using waypointAttachVehicle?

I can post the entire script if needed. It is very lengthy so I only posted the relevant bit.

Edited by Jigsor

Share this post


Link to post
Share on other sites

Try using Barrels, gas tanks and a flagpole next to the building with a SAD waypoint on each. I made a mission that I had gas tanks and barrles all around a building complex with three choppers attacking the area. The choppers would fly around the buildings destroying all the gas tanks and barrles when all the gas tanks and barrels were destroyed the choppers would then try to destroy the flagpoles around the buildings. Each chopper had its on end waypoint on a different flagpole. This was a hold and def missions that worked very well with this setup.

Share this post


Link to post
Share on other sites

AVIBIRD

That sounds like a great idea, but I'm not trying to get the AI to move to a building and target it, and or near static objects. I'm trying to attach a waypoint to a player. In this case the player will most likely be flying an aircraft so the waypoint will always be moving.

Is this not possible using waypointAttachVehicle? If if is, this should be very useful in getting AI to attack a player and I'm really surprised this has not been done yet as far as I can tell? I've tried changing the waypoint type to "Destroy" , got rid of if then filter for finding a player, put the editor named unit of a real player in waypointAttachVehicle command. I still get AttachedWaypoint: <NULL-object> in .rpt

Share this post


Link to post
Share on other sites

Hi friends,

Planes are indeed "reluctant" when it comes to fire at infantry, so here's a little script meant to solve this issue (nothing fancy I admit, but quite effective).

Somewhere on the editor create an enemy plane (plane1), flying at about 100m. You are the player and also the target (name it player1).

Paste this into a script and call it from a trigger or wherever you wish.

What it does: adds a waypoint with the properties below then selects bomb ordnance for the aircraft to fire at you, the moment it's got a clear shot at the target.

wp1 = (group plane1) addWaypoint [(getPos player1), 0];

wp1 setWaypointType "SAD";

wp1 setWaypointBehaviour "COMBAT";

wp1 setWaypointCombatMode "RED";

wp1 setWaypointStatements ["true",""];

wp1 setWaypointSpeed "NO CHANGE";

plane1 doTarget player1;

(driver plane1) forceWeaponFire ["Bomb_03_Plane_CAS_02_F", "Bomb_03_Plane_CAS_02_F"];

waitUntil {plane1 aimedAtTarget [player1] > 0}; plane1 fireAtTarget [player1];

It works, but the plane is going to "hesitate" a lot before releasing the bomb, unless it's aligned with the target.

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  

×