Grumpy Old Man 3545 Posted April 24, 2017 GOM_fnc_ambientArtilleryFire V1.2 Purpose of this script: Gives mission makers access to simple ambient artillery units that fire just for decorative purposes into random directions. Features: Dedi and local MP compatible Takes pre placed vehicles and uses their main guns to engage artillery fire at simulated targets for the given salvo/rounds number. Works fine with with vanilla artillery assets and multiple third party vehicles. It's also possible to immediately stop the script and free up all units to fire on actual threats, so you can use the same units for the vanilla artillery support module/other arty scripts. How to use this script: At first copy the spoiler contents into a file inside your mission folder and name it accordingly. init.sqf: _initAmbientArty = [] execVM "scripts\GOM\ambient\GOM_fnc_ambientArtilleryFire.sqf"; scripts\GOM\ambient\GOM_fnc_ambientArtilleryFire.sqf: //How to add artillery gun to battery: //init field of gun: this setVariable ["GOM_fnc_ambientArtyBatteryID","Battery01",true]; //this will add the gun to "Battery01" GOM_fnc_abortAmbientArtilleryFire = { missionNamespace setVariable ["GOM_ambientArtilleryFiring",false,true]; }; GOM_fnc_ambientArtyFireGun = { params ["_gun","_dir","_alt","_rounds","_guns","_debug"]; _position = _gun getRelPos [250, _dir]; _position = ATLtoASL _position; _position = _position vectorAdd [random [1,3,5],random [1,3,5],_alt + random [1,3,5]]; if !(GOM_ambientArtilleryFiring) exitWith {false}; _leader = _guns select 0; _isLeader = _gun isEqualTo _leader; _gun setVariable ["GOM_fnc_ambientArtyReady",false]; _artyAmmo = getArtilleryAmmo [_gun] select 0; //select higher weapon charge so the projectile travels further _weaponmodes = getArray (configfile >> "CfgWeapons" >> currentweapon _gun >> "modes"); _weaponModeIndex = _weaponmodes findIf {getNumber (configfile >> "CfgWeapons" >> currentweapon _gun >> _x >> "artilleryCharge") >= 0.5}; if (_weaponModeIndex < 0) then {_weaponModeIndex = 0}; gunner _gun action ["SwitchWeapon", _gun, gunner _gun,_weaponModeIndex]; sleep random [0,1,2]; gunner _gun doWatch _position; sleep random [5,7,10]; _gun setVariable ["GOM_fnc_ambientArtyTurretReady",true,true]; waituntil {{_x getVariable ["GOM_fnc_ambientArtyTurretReady",false]} count _guns isEqualTo count _guns OR !GOM_ambientArtilleryFiring}; if !(GOM_ambientArtilleryFiring) exitWith {false}; sleep random [0,0.5,1]; for "_i" from 1 to _rounds do { if !(GOM_ambientArtilleryFiring) exitWith {false}; _gun setVehicleAmmoDef 1; _gun addEventHandler ["Fired",{ params ["_gun","","","","","","_projectile"]; _gun removeEventHandler ["Fired",_thiseventhandler]; _projectile setFeatureType 2;//makes it visible as far as terrainViewDistance goes _delete = _projectile spawn { //wait until projectile has negative Z velocity waitUntil {velocity _this # 2 <= 0 AND (getPosATL _this # 2) < 200 OR !alive _this}; if (alive _this) then {deleteVehicle _this}; }; }]; gunner _gun action ["SwitchWeapon", _gun, gunner _gun,_weaponModeIndex]; _gun action ["useWeapon", _gun, gunner _gun,0]; _getMuzzle = getarray (configfile >> "CfgVehicles" >> typeof _gun >> "Turrets" >> "MainTurret" >> "weapons"); _reloadtime = getnumber (configfile >> "CfgWeapons" >> (_getMuzzle select 0) >> "reloadTime"); if (_reloadTime <= 0.5) then {_reloadtime = 0.5}; sleep (_reloadtime + random [0.1,0.2,0.3]); }; _gun setVariable ["GOM_fnc_ambientArtyReady",true]; if !(GOM_ambientArtilleryFiring) exitWith {false}; }; GOM_fnc_ambientArtilleryFire = { params [["_batteryID",""],["_salvoes",4],["_rounds",4],["_debug",false]]; if (_batteryID isEqualTo "") exitWith {systemchat "Error GOM_fnc_ambientArtilleryFire - No battery ID given!"}; _guns = vehicles select {_x getVariable ["GOM_fnc_ambientArtyBatteryID",""] isEqualTo _batteryID}; if (_guns isEqualTo []) exitWith {systemchat "Error GOM_fnc_ambientArtilleryFire - No artillery guns found!"}; { _x setVariable ["GOM_fnc_ambientArtyReady",false,true]; _x setVariable ["GOM_fnc_ambientArtyTurretReady",false,true]; } foreach _guns; _dir = random 360; _alt = random [150,200,300]; for "_i" from 1 to _salvoes do { if !(GOM_ambientArtilleryFiring) exitWith {false}; if (_debug) then { _guns select 0 sidechat format ["Salvo %1 of %2.",_i,_salvoes]; _guns select 0 sidechat format ["%1 rounds.",_rounds] }; {[_x,_dir,_alt,_rounds,_guns,_debug] spawn GOM_fnc_ambientArtyFireGun} forEach _guns; waitUntil {{_x getVariable ["GOM_fnc_ambientArtyReady",false]} count _guns isEqualTo count _guns OR !GOM_ambientArtilleryFiring}; if !(GOM_ambientArtilleryFiring) exitWith {false}; if (_debug) then {_guns select 0 sidechat format ["Salvo %1 of %2 finished.",_i,_salvoes,_rounds];}; sleep random [10,15,20]; }; if (_debug) then {_guns select 0 sidechat "Firemission complete."}; { _x spawn { sleep random [3,5,7]; gunner _this dowatch objnull; _this setVehicleAmmoDef 1; }; } foreach _guns; }; missionNamespace setVariable ["GOM_ambientArtilleryFiring",true,true]; In the editor: Place few grouped or ungrouped artillery units put the following into their init fields: this setVariable ["GOM_fnc_ambientArtyBatteryID","Battery01",true]; _fire = ["Battery01",3,4] spawn GOM_fnc_ambientArtilleryFire This will make arty guns assigned to "Battery01" fire 3 salvoes with 4 rounds each. Parameters: _battery = "Battery01"; //battery ID assigned through objects init field _salvoes = 3; //(OPTIONAL) how many salvoes will be fired _rounds = 6; //(OPTIONAL) rounds per salvo _debug = false; //(OPTIONAL) displays debug messages _fire = [_battery,_salvoes,_rounds] spawn GOM_fnc_ambientArtilleryFire To abort the script simply call GOM_fnc_abortAmbientArtilleryFire wherever you like. _abort = [] call GOM_fnc_abortAmbientArtilleryFire; By executing the script again guns will fire as usual. For best effect place multiple groups executing the code simultaneously, this way you'll get multiple groups firing at multiple simulated targets. Known Issues: None so far. Changelog: V1.2: Made script local MP and dedi compatible Improved firing Arc Improved projectile deletion Guns are now assigned to batteries to allow multiple batteries for ambient artillery fire SP Demo Mission Enjoy! 1 2 Share this post Link to post Share on other sites
sarogahtyp 1108 Posted April 24, 2017 I love ambient scripts. I will test it and probably implement to my server. Thanks a lot for sharing. :-) 1 Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted April 24, 2017 Feel free to post suggestions / requests. Cheers Share this post Link to post Share on other sites
Coolie 0 Posted July 28, 2017 Do we have a SP Demo Mission for this script? Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted July 29, 2017 8 hours ago, Coolie said: Do we have a SP Demo Mission for this script? Added sp demo mission. Also changed how the scripts were executed, hence update to 1.1. Cheers 1 Share this post Link to post Share on other sites
Lucullus 71 Posted July 29, 2017 I like it! Nice would be a given direction as fourth parameter like [20,70]. Share this post Link to post Share on other sites
Coolie 0 Posted July 31, 2017 Oh how sweet the sound! Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted May 1, 2018 V1.2: Made script local MP and dedi compatible Improved firing Arc Improved projectile deletion Guns are now assigned to batteries to allow multiple batteries for ambient artillery fire 2 Share this post Link to post Share on other sites
avibird 1 36 Posted May 1, 2018 @Grumpy Old Man here I go with my suggestion. In your demo can you set up a simple task assigned to destroy the artillery battery units and a break in the battery firing for resupplying the units with more ammo like every 15 minutes or so. What a cool mission objective that mission designers can design defenses around the artillery battery. I can see a mission we're special forces need to sneak into a mountain range and destroy the artillery battery. Cheers Avibird ? 1 Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted May 1, 2018 37 minutes ago, avibird 1 said: @Grumpy Old Man here I go with my suggestion. In your demo can you set up a simple task assigned to destroy the artillery battery units and a break in the battery firing for resupplying the units with more ammo like every 15 minutes or so. What a cool mission objective that mission designers can design defenses around the artillery battery. I can see a mission we're special forces need to sneak into a mountain range and destroy the artillery battery. Cheers Avibird ? Well you can do any kind of mission you can think of. This is meant as a tool for mission makers to bring more life to their missions. It already fires a user defined amount of rounds and salvoes, up to the mission maker to add certain reammo breaks or whatnot. Cheers 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted May 1, 2018 5 hours ago, Grumpy Old Man said: V1.2: Thank you Grumpy Old Man for the update ! 1 Share this post Link to post Share on other sites
jandrews 116 Posted November 4, 2018 Hey I dug this up. Had a few questions. Will this work for AI and flares? Could you post a working file? Its for a flarefix script by Alais https://steamcommunity.com/sharedfiles/filedetails/?id=778433432 Share this post Link to post Share on other sites
gatordev 219 Posted September 4, 2021 @Grumpy Old Man I understand you may not be supporting this anymore, but I managed to get this working for canon artillery using your text from your post, but I can't seem to get it working for rocket artillery. I did initially have an error from trying to copy the text from the spoiler tag (the demo mission isn't avilable anymore), but I think I've eliminated any of those errors now. Guns attached to Battery01 work, but rockets attached to Battery02 don't. I do occassionally get an error about reload time (Line 74), and I believe that's related to the rockets, as the guns don't seem to have the issue. I know it shouldn't matter, but I've tried this with 3CB Soviet artillery (basically RHS-based stuff) and RHS rocket artillery. Both have the same issue. Any ideas? Otherwise, this is a great find and thanks for making it available. Share this post Link to post Share on other sites