EDIT: More refined and smarter script 2 posts down.
I looked high and low for a way to get Artillery to fire correctly but couldn't find it. Maybe this is somewhere else, but I don't know where.
I wanted a script that:
Allowed the artillery to fire on *any* enemy that strays into it's marked area of defense.
Made the artillery piece re-adjust it's aim before every shot for moving targets.
Was smart enough not to fire at aircraft.
I tried the approach most people use with mortars, but it wasn't working with artillery pieces and the MLRS. It took me hours of trial and error, but I finally figured out you have to hold the artillery piece's hand and tell it to reload and then wait for it to finish reloading.
When you run it, you'll see the piece fire, put it's cannon or MLRS launcher down while it's reloading (10 secs default), then put it back up again and fire - wash and repeat. The range has to be correct, if it's too far or too close it won't fire. You can cut the reload time down with the MLRS, but it seems to get a little buggy if you do. Actually, the MLRS just seems to be a little buggy period.
It takes a while for the rounds to reach their targets, so if you have something trucking through the target area the shells are going to lag pretty far behind it, but they will follow the target.
Here's the main script, I called it fireArty.sqf:
_arty = _this select 0;
_targetArray = _this select 1;
_target = _targetArray select 0;
_theAmmo = getArtilleryAmmo [_arty] select 0;
_idx = 0;
//10 seconds to reload is for the
//longest reloading artillery piece.
//MLRS can reload faster, but they get buggy.
_reloadTime = 10;
// The number of times you want the _arty to check for range
// and fire (if in range).
_shellCount = 10;
_arty addMagazineTurret [_theAmmo, [0]];
sleep _reloadTime;
// prevents firing at aircraft
if(isTouchingGround _target ) then {
while {(_idx < _shellCount)} do{
_tgtPos = position _target;
_isInRange = _tgtPos inRangeOfArtillery [[_arty], _theAmmo ];
if (_isInRange) then {
_arty doArtilleryFire [_tgtPos, _theAmmo, 1];
_arty addMagazineTurret [_theAmmo, [0]];
sleep _reloadTime;
} else {
//Try moving the target area marker
hint "Too close or far for artillery";
_idx = _shellCount;
};
_idx = _idx + 1;
};
};
You can change the values at the top for whatever piece you're using if you wanted to.
To set it up, make an artillery piece and name it whatever you want. In this example I used arty1.
Then make a trigger that goes off repeatedly any time an enemy enters and put this in the on act section:
script=[arty1, thislist] execVM "fireArty.sqf";
You can reuse this script with as many different artillery and MLRS pieces and as many different targets as you want, so:
script=[arty1, thislist] execVM "fireArty.sqf";
script=[arty2, thislist] execVM "fireArty.sqf";
script=[arty3, thislist] execVM "fireArty.sqf";
Would all be valid as actions for targets assuming you created artillery pieces with those names.
Enjoy! :)