fatty86 10 Posted January 13, 2011 (edited) Wrote this short little script to add ambience to missions involving large artillery pieces like cannons, rocket artillery, mortars, etc. Presumably would work with just about anything - I can confirm it works with Shilkas, for instance. Basically, an object run with this script will fire at regular intervals at a target until the gunner is dead or runs out of ammo. Confirmed dedicated server safe. SQF File Demo Mission /* 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). Examples: nul = [big_gun, gun_target] execVM "faat.sqf"; nul = [rocket_artillery, house, 20, false, true] execVM "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; While {alive (gunner _gun)} do { sleep _delay; _gun fire (weapons _gun select 0); if (_autorearm) then { _gun setVehicleAmmo 1 }; }; Edited January 29, 2011 by fatty86 Share this post Link to post Share on other sites
ricnunes 0 Posted January 16, 2011 Thanks fatty! That's the kind of script what I'm wishing for a mission that I planned to make sometime in the near future. Share this post Link to post Share on other sites
ollem 4 Posted January 22, 2011 (edited) The script works great, but has one minor issue: the guns will try to shoot in a straight line to the target. Confirmed to work with mortars too and even fixed machine guns will fire shot every x seconds :) Would be nice if it could actually shoot at large distance using a parabolic flight path. UPDATE: It is actually possible: I thought the guns were aiming at the helipad. They do so, but I missed the option to set higher altitude in the helipad. If you increase the z-axis, the rounds will not drop at the helipad area, but somewhere right behind it. distance depends on the set height of course. Edited January 23, 2011 by Ollem Share this post Link to post Share on other sites
fatty86 10 Posted January 29, 2011 UPDATE: It is actually possible: I thought the guns were aiming at the helipad. They do so, but I missed the option to set higher altitude in the helipad. If you increase the z-axis, the rounds will not drop at the helipad area, but somewhere right behind it. distance depends on the set height of course. Yes, this is what I do in the demo mission: an invisible H setpos'd up in the air makes a good target. The challenge with this is that the live rounds going up will eventually come down somewhere. Would be nice to figure out a way to get the weapons to fire 'blanks.' Share this post Link to post Share on other sites
f2k sel 164 Posted January 29, 2011 You need to use the fired command which can then be used to delete the fired ammo, you can then spawn a shell above the target. Place this in the units init; when fired it will delete the shell. this addeventhandler["fired", {deletevehicle (nearestobject[_this select 0, _this select 4]); _this execVM "spawnscript,sqf"}] The following variables would be passed to the script. Script.sqf _shooter = _this Select 0; _weap = _this select 1; _ammotype = _this Select 4; _projectile = _this select 5; // The rest off the code would go here Share this post Link to post Share on other sites
demonized 20 Posted February 19, 2011 Would be nice to figure out a way to get the weapons to fire 'blanks.' the "ARTY_Sh_105_ILLUM" rounds fire duds in patch 1.57 no beta afaik. You can track the bullet all the way to the target area using a a fired EH but no impact, maybe its only duds when player shoot them, did not test with AI at the time. this is that magazine "ARTY_30Rnd_105mmILLUM_M119" Find more in: http://community.bistudio.com/wiki/ArmA_2:_Weapons#Artillery_Weapons_and_Special_Ammo Share this post Link to post Share on other sites
ollem 4 Posted February 19, 2011 (edited) Great idea this script. Took liberty to create modified v2 version (based on hint of F2k Sel. hope you don't mind.. ;-) ) faatv2.sqf Demo mission v2 /* fatty's ambient artillery tool (faat) version 2.0 by fatty, modified by Ollem Forces an AI 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 could be an invisible HeliPad, flagpole, house, enemy vehicle, etc Optional Parameters: Delay (number) - delay between shots in seconds (default is 10 seconds). Examples: Put the following parameters in the initialization string of the artillery piece(s) nul = [gun, target] execmVM "faatv2.sqf"; nul = [rocket_artillery, house, 20] execmVM "faatv2.sqf"; Changes v2.0: - No need to put parameters in the initialization string of target anymore - Target stays on actual position; a new hidden target is temporarily created at high altitude - Faked artillery shots by deleteing rounds after firing and re-creating rounds 30m above target (with some random spread) - Added some random time between shots */ private ["_gun","_target","_newTarget","_spawnDelay","_delay","_tposx","_tposy","_tposz","_dist","_posxGun","_posxTarget","_posyGun","_posyTarget","_poszGun","_poszTarget"]; //global variable faatAmmoType faatAmmoType = 0; _gun = _this select 0; _target = _this select 1; _delay = if (count _this > 2) then {_this select 2} else {10}; _delay = _delay + (random 6); // keep gun pointed at target _gun setCombatMode "BLUE"; _gun disableAI "move"; _gun disableAI "target"; _gun disableAI "autotarget"; _gun disableAI "anim"; _posxGun = ((getPosASL _gun) select 0); _posxTarget = ((getPosASL _target) select 0); _posyGun = ((getPosASL _gun) select 1); _posyTarget = ((getPosASL _target) select 1); _poszGun = ((getPosASL _gun) select 2); _poszTarget = ((getPosASL _target) select 2); _tposx = _posxTarget + ((_posxGun - _posxTarget)*(3/4)); _tposy = _posyTarget + ((_posyGun - _posyTarget)*(3/4)); _dist = _target Distance _gun; if ( _poszGun > _poszTarget ) then { _tposz = (getPosASL _target select 2) + (_dist/3); } else { _tposz = (getPosASL _gun select 2) + (_dist/5); }; // delay impact based on distance to target (no realistic timing) _spawnDelay = (round (_dist/666)); // create virtual target (empty hidden helipad in the air) _newTarget = "HeliHEmpty" createVehicle (getPos _target); _newTarget setPosASL [_tposx,_tposy,_tposz]; sleep 1; // gunner will look at hidden targets 'flying' in the air (gunner _gun) lookAt _newTarget; sleep 2; // create eventhandler to monitor if gun is fired. If so, delete the fired round and put type of ammo in global variable _gun addEventHandler ["fired",{faatAmmoType = _this select 4;deleteVehicle (nearestObject [_this select 0, _this select 4]);}]; While {alive (gunner _gun)} do { _gun fire (weapons _gun select 0); sleep _spawnDelay; //hint format["Fired ammo: %1",faatAmmoType]; // create new artillery round at actual target location at height of 30m faatAmmoType createVehicle [(_posxTarget + 30 - random 60),(_posyTarget + 30 - random 60),30]; _gun setVehicleAmmo 1; sleep _delay; }; // removing auto created hidden virtual target and eventhandler deleteVehicle _newTarget; _gun removeAllEventHandlers "fired"; Edited February 19, 2011 by Ollem Share this post Link to post Share on other sites
thedudeabides 40 Posted April 7, 2011 how is this script server side? Any one try it yet? Share this post Link to post Share on other sites
Nikoladis 12 Posted April 6, 2018 Anything has to be changed for this (v1 version) to run in Arma 3? When I do nul = [art, pad, 20, true, true] execVM "faat.sqf"; It also fired at my CUP Fishingboat where I am in, 2 Km away, even though it has no line of sight, and second last parameter is true. And should this line strings not be in capitals or does that not matter: {_gun disableAI "_x";} foreach [move,target,autotarget,anim]; I need to use v1 of this script, since v2 does not show the projectile flying, and the projectiles seems to be stuck above the target in v2 also. Share this post Link to post Share on other sites