Forum Jump :

Author Message

Posts: 1513

Level: Member

Country: uk
In-game name:

#198387 Posted at 2017-11-26 15:58        
This isn't my script but I can't post a link as the forum is down so I'll post it here.

fatty's ambient artillery tool (faat) version 1.0
by fatty
Forces an AI gun (e.g. cannon or rocket artillery) to fire at regular intervals at a defined target. Gunners will persist until out of ammo or dead.

CAUTION: the guns fire live ammo, so be careful where you aim!

Required Parameters:
    Artillery Piece (object) - object to begin firing.
    Target (object) - target at which the artillery piece will fire. Suggested target is an invisible H setPos'd several hundred metres above the gun.
Optional Parameters:
    Delay (number) - delay between shots in seconds (default is 10 seconds).
    Disable aiming AI (boolean) - prevents AI gunners from engaging other targets (default is true).
    Enable auto-rearm (boolean) - enables automatic rearming of gun after every shot (default is false).

    nul = [big_gun, gun_target] execmVM "faat.sqf";
    nul = [rocket_artillery, house, 20, false, true] execmVM "faat.sqf";

private ["_gun","_target","_delay","_disableaim","_autorearm"];

_gun = _this select 0;
_target = _this select 1;
_delay = if (count _this > 2) then {_this select 2} else {10};
_disableaim = if (count _this > 3) then {_this select 3} else {true};
_autorearm = if (count _this > 4) then {_this select 4} else {false};

if (_disableaim) then {
    {_gun disableAI "_x";} foreach [move,target,autotarget,anim];
    _gun setCombatMode "BLUE";

(gunner _gun) lookAt _target;
(gunner _gun) dowatch _target;

While {alive (gunner _gun)} do
	(gunner _gun) dowatch _target;
	(gunner _gun) lookAt getpos _target;
    sleep _delay;
    (gunner _gun) dowatch _target;
	(gunner _gun) lookAt getpos _target;
    _gun fire (weapons _gun select 0);
    //_gun action ["useWeapon",_gun,_gun turretUnit [0],0];
    if (_autorearm) then {
        _gun setVehicleAmmo 1
save as faat.sqf

For a target just put this in a game logic init to give it some elevation
this setpos ( this modeltoworld [0,0,300])

then this in your trigger
nul = [big_gun, gun_target] execVM "faat.sqf";

big_gun is the name of the Arty
gun_traget is the name of the game logic