Jump to content
infiltrator_2k

Best AI Mortar Script?

Recommended Posts

I'm having problems trying to get an AI mortar script to work. I've followed the instructions in the below script but the AI mortar just won't fire. Is this the best mortar script currently available? Basically I just want the AI to target the Blufor when spotted.

Am I right in believing that this defaults to attack the west? Or have I missed something? "//// enter the side you want attacked on the following line ///////////////////////////

_sideToAttack = west; //blufor = WEST, opfor = EAST, independant = GUER, civilian = CIV

///////////////////////////////////////////////////////////////////////////////////////

http://www.tacticalgamer.com/script-bin/194107-arma-3-enemy-mortar-team-script.html

Share this post


Link to post
Share on other sites
It's possible an update broke the script if it's an older script. Have you tried simple mortar script by bangabob? Not sure if it works with Ai though.

Ahh... that makes sense. Not tried the simple mortar script, but I'll have a bash and report back :)

Share this post


Link to post
Share on other sites

Vanilla AI will make use of mortars just fine when spotting them.

Every Mortar script I came across basically spawned mortar rounds above the enemies instead of having "real" mortar fire.

Would be quite easy to make a small command line with a commandArtilleryFire

You could try this inside a trigger:

Mortarname commandArtilleryFire [getpos badguy, "8Rnd_82mm_Mo_shells", 3]

The last number indicates the number of rounds to be fired.

This would be the least "hacky" way to do this.

Let us know how that simple mortar script is working out for you.

Share this post


Link to post
Share on other sites

Trouble with that script from TacticalGamer is that it is only setup to spot playableunits (players or AI in a player slot).

Ive made a quick rewrite of the script , you can now pass it the Spotter and an array of artillery units. ( I was bored and seemed like something interesting to do for an hour)

Side to attack is automatically anyone that is unfriendly to the spotter.

Spotted units can be any unit not just players

Placed a few checks in the script to make sure spotter is a man and that artillery units are artillery units :/

Could be taken further allowing specifying number of rounds and firing/reload delays.

//////////////////////////////////
// _nul = [ UNIT, [mortar1, mortar2] ] exeVM "mortar_spotter.sqf;
//
// UNIT - a valid unit to serve as the artillery spotter
// [mortar1, .. ] - an array of artillary units
//////////////////
//Rewritten from original concept by Unkl on the TacticalGamer forum http://www.tacticalgamer.com/script-bin/194107-arma-3-enemy-mortar-team-script.html
/////

private ["_spotter","_mortars","_sideToAttack","_targets"];

_spotter = [_this, 0, objNull, [objNull] ] call BIS_fnc_param;
_mortars = [_this, 1, [], [[]] ] call BIS_fnc_param;

if ( isNull _spotter || { !((typeOf _spotter) isKindOf "MAN") } ) then { "You must supply a unit for the spotter" call BIS_fnc_error; };
if ( count _mortars < 1 ) then { "You must supply atleast one mortar" call BIS_fnc_error; };
{
if ( !( "Artillery" in (getArray (configfile >> "CfgVehicles" >> typeOf _x >> "availableForSupportTypes")) ) ) then {
	(format ["Mortar %1 is not a valid Artillary support unit",_forEachIndex]) call BIS_fnc_error;
};
}forEach _mortars;

_sideToAttack = [];
{
if (_x getFriend (side _spotter) < 0.6 ) then {
	_sideToAttack set [count _sideToAttack, _x];
};
}forEach [opfor,west,independent];

while { { alive _x; }count _mortars > 0 } do {

_targets = [];
{
	if (side _x in _sideToAttack && { alive _x && _spotter knowsAbout _x > 1 } ) then {
		_targets set [count _targets, _x];
	};
} forEach allUnits;


if (count _targets > 0) then {

	_chosenTarget = _targets select (floor (random (count _targets)));

	{
		if (alive _x) then {
			_x commandArtilleryFire [getPos _chosenTarget, (magazines _x) select 0, floor (random 6)+1];
			sleep 15;
		};
	}forEach _mortars;
	sleep ((floor random 30) + 45);

};

sleep 10;
};

Edited by Larrow
  • Like 1

Share this post


Link to post
Share on other sites
Trouble with that script from TacticalGamer is that it is only setup to spot playableunits (players or AI in a player slot).

Ive made a quick rewrite of the script , you can now pass it the Spotter and an array of artillery units. ( I was bored and seemed like something interesting to do for an hour)

Side to attack is automatically anyone that is unfriendly to the spotter.

Spotted units can be any unit not just players

Placed a few checks in the script to make sure spotter is a man and that artillery units are artillery units :/

Could be taken further allowing specifying number of rounds and firing/reload delays.

//////////////////////////////////
// _nul = [ UNIT, [mortar1, mortar2] ] exeVM "mortar_spotter.sqf;
//
// UNIT - a valid unit to serve as the artillery spotter
// [mortar1, .. ] - an array of artillary units
//////////////////
//Rewritten from original concept by Unkl on the TacticalGamer forum http://www.tacticalgamer.com/script-bin/194107-arma-3-enemy-mortar-team-script.html
/////

private ["_spotter","_mortars","_sideToAttack","_targets"];

_spotter = [_this, 0, objNull, [objNull] ] call BIS_fnc_param;
_mortars = [_this, 1, [], [[]] ] call BIS_fnc_param;

if ( isNull _spotter || { !((typeOf _spotter) isKindOf "MAN") } ) then { "You must supply a unit for the spotter" call BIS_fnc_error; };
if ( count _mortars < 1 ) then { "You must supply atleast one mortar" call BIS_fnc_error; };
{
if ( !( "Artillery" in (getArray (configfile >> "CfgVehicles" >> typeOf _x >> "availableForSupportTypes")) ) ) then {
	(format ["Mortar %1 is not a valid Artillary support unit",_forEachIndex]) call BIS_fnc_error;
};
}forEach _mortars;

_sideToAttack = [];
{
if (_x getFriend (side _spotter) < 0.6 ) then {
	_sideToAttack set [count _sideToAttack, _x];
};
}forEach [opfor,west,independent];

while { { alive _x; }count _mortars > 0 } do {

_targets = [];
{
	if (side _x in _sideToAttack && { alive _x && _spotter knowsAbout _x > 1 } ) then {
		_targets set [count _targets, _x];
	};
} forEach allUnits;


if (count _targets > 0) then {

	_chosenTarget = _targets select (floor (random (count _targets)));

	{
		if (alive _x) then {
			_x commandArtilleryFire [getPos _chosenTarget, (magazines _x) select 0, floor (random 6)+1];
			sleep 15;
		};
	}forEach _mortars;
	sleep ((floor random 30) + 45);

};

sleep 10;
};

Nice one ;) What parameters do I have to change/add to configure it to be used where Opfor target Blufor?

Share this post


Link to post
Share on other sites
Nice one What parameters do I have to change/add to configure it to be used where Opfor target Blufor?

None -

You pass it a unit that you want to be the spotter and an array or artillery units.

[ _mySpotterBloke, [ mortar1, mortar2] ] execVM "whatEverYouveCalledTheScript.sqf"

And the spotter will automatically call mortar strikes on anything unfriendly to himself when he knows about them.

Heres a quick example mission - spotter is the blufor unit out on the runway near the player, there are two mortar teams and a mlrs as artillery behind you further down the runway and 5 opfor rifle squads ahead of you at the other end of the runway.

EDIT: added two mortars for opfor and set one of the opfor group leaders up as a spotter aswell - to show script working both ways.

Edited by Larrow

Share this post


Link to post
Share on other sites
None -

You pass it a unit that you want to be the spotter and an array or artillery units.

[ _mySpotterBloke, [ mortar1, mortar2] ] execVM "whatEverYouveCalledTheScript.sqf"

And the spotter will automatically call mortar strikes on anything unfriendly to himself when he knows about them.

Heres a quick example mission - spotter is the blufor unit out on the runway near the player, there are two mortar teams and a mlrs as artillery behind you further down the runway and 5 opfor rifle squads ahead of you at the other end of the runway.

EDIT: added two mortars for opfor and set one of the opfor group leaders up as a spotter aswell - to show script working both ways.

Nice one ;) I'll let you know how I get on. Wish I could code :(

Share this post


Link to post
Share on other sites

010000010110110001101100001000000111100101101111011101010111001000100000011000100110000101110011011001010111001100100000011000100110010101101100011011110110111001100111001000000111010001101111001000000111010101110011 lol

Edited by Larrow

Share this post


Link to post
Share on other sites

Hes not human I am sure of this ! :p

And leave my bases alone !

Share this post


Link to post
Share on other sites

Hi Larrow and everybody, just a question.

ALL the AI Arty scripts I have seen, pick up targets in more or less the same method (random target from a count of total targets).

What they lack want is a clever use of the Arty, I mean, do not pick as target an isolated unit with no more targets in a 100 mts distance, and fire againste this lone soldier a whole battery charge.

Just the same use you would do: pick as targets the ones that have a whole bunch of units in his area. If not, do not waste ammo.

I'm guessing maybe placing a trigger on each target and make a cound could work, but that is over my scripting skills...

Share this post


Link to post
Share on other sites

I totally agree barbolani, and the above script is no different, all it does is pick a random target out of a group of known targets. This was actually something that crossed my mind whilst i was doing the quick rewrite above.

I may revisit this script in the near future and improve it further as i have other ideas, including as you mention making sure there are a number of units within the chosen target area to make it worth while calling in an artillery strike along with making sure there are no friendlies danger close or maybe some means to alert friendlies of incoming barrage maybe a notification or radio message?.

Share this post


Link to post
Share on other sites

Sorry to dig up this topic  but I tried to use this script and I get an error saying that i miss a ";" . I might do something wrong, I placed the " _nul = [ spotter2, [mortar1, mortar2] ] exeVM "mortar_spotter.sqf"; " in the init of the spotter unit. 

Share this post


Link to post
Share on other sites
15 minutes ago, Zarele said:

Sorry to dig up this topic  but I tried to use this script and I get an error saying that i miss a ";" . I might do something wrong, I placed the " _nul = [ spotter2, [mortar1, mortar2] ] exeVM "mortar_spotter.sqf"; " in the init of the spotter unit. 

 

Double check your code.

Your execVM command has a typo.

 

It should read:

_nul = [ spotter2, [mortar1, mortar2] ] execVM "mortar_spotter.sqf";

Share this post


Link to post
Share on other sites

My mistake. I put the name "spotter2" in the composition variable instead of the unit variable

 

Strange if i put it in a testmission everyting works out, if I put it in my actual mission i get an error about : etarray (configfille >> "cfgvehicles" >> |#| typeof _x "availableforsupport error typeof, type group expected objects

 

I have no idea what this means or how to fix this

Edited by Zarele

Share this post


Link to post
Share on other sites
On 08/12/2013 at 7:04 PM, Larrow said:

Trouble with that script from TacticalGamer is that it is only setup to spot playableunits (players or AI in a player slot).

Ive made a quick rewrite of the script , you can now pass it the Spotter and an array of artillery units. ( I was bored and seemed like something interesting to do for an hour)

Side to attack is automatically anyone that is unfriendly to the spotter.

Spotted units can be any unit not just players

Placed a few checks in the script to make sure spotter is a man and that artillery units are artillery units :/

Could be taken further allowing specifying number of rounds and firing/reload delays.

 


//////////////////////////////////
// _nul = [ UNIT, [mortar1, mortar2] ] exeVM "mortar_spotter.sqf;
//
// UNIT - a valid unit to serve as the artillery spotter
// [mortar1, .. ] - an array of artillary units
//////////////////
//Rewritten from original concept by Unkl on the TacticalGamer forum http://www.tacticalgamer.com/script-bin/194107-arma-3-enemy-mortar-team-script.html
/////

private ["_spotter","_mortars","_sideToAttack","_targets"];

_spotter = [_this, 0, objNull, [objNull] ] call BIS_fnc_param;
_mortars = [_this, 1, [], [[]] ] call BIS_fnc_param;

if ( isNull _spotter || { !((typeOf _spotter) isKindOf "MAN") } ) then { "You must supply a unit for the spotter" call BIS_fnc_error; };
if ( count _mortars < 1 ) then { "You must supply atleast one mortar" call BIS_fnc_error; };
{
if ( !( "Artillery" in (getArray (configfile >> "CfgVehicles" >> typeOf _x >> "availableForSupportTypes")) ) ) then {
	(format ["Mortar %1 is not a valid Artillary support unit",_forEachIndex]) call BIS_fnc_error;
};
}forEach _mortars;

_sideToAttack = [];
{
if (_x getFriend (side _spotter) < 0.6 ) then {
	_sideToAttack set [count _sideToAttack, _x];
};
}forEach [opfor,west,independent];

while { { alive _x; }count _mortars > 0 } do {

_targets = [];
{
	if (side _x in _sideToAttack && { alive _x && _spotter knowsAbout _x > 1 } ) then {
		_targets set [count _targets, _x];
	};
} forEach allUnits;


if (count _targets > 0) then {

	_chosenTarget = _targets select (floor (random (count _targets)));

	{
		if (alive _x) then {
			_x commandArtilleryFire [getPos _chosenTarget, (magazines _x) select 0, floor (random 6)+1];
			sleep 15;
		};
	}forEach _mortars;
	sleep ((floor random 30) + 45);

};

sleep 10;
};
 

 

How would this be adapted for multiple spotters sharing the same array of artillery pieces? Could I simply group units to the spotter and they would share info? Or put the execVM in multiple units?

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

×