cooked auto 7 Posted December 1 So I'm working on a cold war version of the Brecourt Manor assault, but I've run into an issue that's been giving me some grief. Namely; how do I make the MGs placed at the back keep up a constant stream of suppressive fire? I've tried a bunch of lines of code I've found from searching around on the forums, but none have really delivered in a satisfying way. Either the AI breaks off contact after a while, unless you peak your stand up in the trenches to reveal yourself. Or they're conflicted about targeting the player or the suppression point. The former feels self-defeating as I really want to encourage people to duck underneath a barrage of machine gun fire and have that be a constant thread to spice things up. While the latter looks a bit janky. While the AI suppressive fire module is great, and kind of what I'm looking for, but it's also exclusive to Zeus and I haven't found a way to recreate that functionality in Eden. Share this post Link to post Share on other sites
mikey74 186 Posted December 2 (edited) Im not sure what you're looking for but here is What I think you might be: This is tested and works. I set a unit on map named target1 and placed 2 mg's named mg1 and mg2 that had LOS to target1, and put this script in the init.sqf. useractions Spoiler // Define the position you want to suppress (in this case, the position of the target) _aposition_you_want_suppressed = getPos target1; // Create an array containing the machine gun units (MG1 and MG2) _MG_ARRAY = [mg1, mg2]; // Loop through each machine gun unit in the array { // Start a new spawn block for each machine gun unit [_x, _aposition_you_want_suppressed] spawn { // Define the parameters to be used in the spawn block params ["_mg", "_this_position"]; // Add an event handler for when the machine gun fires _mg addEventHandler ["Fired", { // The parameters for the Fired event handler params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; // Set vehicle ammo to 1 (this will prevent the unit from running out of ammo; can be modified if desired) _unit setVehicleAmmo 1; }]; // Command the machine gun to start watching the target position _mg doWatch _this_position; // Sleep for 1 second to allow the machine gun to start watching sleep 1; // Begin a while loop that runs while the machine gun is alive while {alive _mg} do { // Generate a random position around the target position to simulate a more dynamic suppression pattern _random_Positions = _this_position getPos [15, random 360]; // Command the machine gun to watch this random position (15 meter radius with random angle) _mg doWatch _random_Positions; // Command the machine gun to use its weapon, with the gunner's action // _mg is the machine gun unit, gunner _mg gets the unit's gunner, and 1 simulates continuous fire _mg action ["UseWeapon", _mg, gunner _mg, 1]; // Sleep for a random time between shots to simulate fire behavior (between 0 and 1 second) sleep Random 1; }; }; } forEach _MG_ARRAY; // Repeat the process for each machine gun unit in the array here is another slightly edited version of this script: Spoiler // Create an array containing the machine gun units (MG1 and MG2) _MG_ARRAY = [mg1, mg2]; // Loop through each machine gun unit in the array { // Define the position you want to suppress (in this case, the position of the target) _aposition_you_want_suppressed = target1 getPos [100,(_x getDir target1)]; // Start a new spawn block for each machine gun unit [_x, _aposition_you_want_suppressed] spawn { // Define the parameters to be used in the spawn block params ["_mg", "_this_position"]; // Add an event handler for when the machine gun fires _mg addEventHandler ["Fired", { // The parameters for the Fired event handler params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; // Set vehicle ammo to 1 (this will prevent the unit from running out of ammo; can be modified if desired) _unit setVehicleAmmo 1; }]; // Command the machine gun to start watching the target position _mg doWatch _this_position; // Sleep for 1 second to allow the machine gun to start watching sleep 1; // Begin a while loop that runs while the machine gun is alive while {alive _mg} do { // Generate a random position around the target position to simulate a more dynamic suppression pattern _random_Positions = _this_position getPos [100, random 360]; // Command the machine gun to watch this random position (15 meter radius with random angle) _mg doWatch _random_Positions; // Command the machine gun to use its weapon, with the gunner's action // _mg is the machine gun unit, gunner _mg gets the unit's gunner, and 1 simulates continuous fire [_mg] call { params ["_mg"]; for "_i" from 1 to (5 + (round (Random 23))) do { //(3 + (round (Random 7))) _mg action ["UseWeapon", _mg, gunner _mg, (round random 3)]; sleep random 0.1; }; //waitUntil { unitReady _mg }; }; sleep random 1;//(1.1 - random 1); }; }; } forEach _MG_ARRAY; // Repeat the process for each machine gun unit in the array Simulate AA fire same type script: Spoiler // Create an array containing the machine gun units (MG1 and MG2) _MG_ARRAY = [mg1, mg2]; // Loop through each machine gun unit in the array { // Define the position you want to suppress (in this case, the position of the target) _aposition_you_want_suppressed = target1 getPos [100,(_x getDir target1)]; // Start a new spawn block for each machine gun unit [_x, +_aposition_you_want_suppressed] spawn { // Define the parameters to be used in the spawn block params ["_mg", "_this_position"]; // Add an event handler for when the machine gun fires _mg addEventHandler ["Fired", { // The parameters for the Fired event handler params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; // Set vehicle ammo to 1 (this will prevent the unit from running out of ammo; can be modified if desired) _unit setVehicleAmmo 1; }]; //_this_position set [2,300]; // Command the machine gun to start watching the target position _mg doWatch _this_position; // Sleep for 1 second to allow the machine gun to start watching sleep 1; _stop = 0; // Begin a while loop that runs while the machine gun is alive while {alive _mg} do { // Generate a random position around the target position to simulate a more dynamic suppression pattern _random_Positions = +(_this_position getPos [100, random 360]); _random_Positions set [2,(200 + random 200)]; _mg doWatch _random_Positions; // Command the machine gun to use its weapon, with the gunner's action if (_stop >= 3) then { _mg doWatch _random_Positions; sleep 1; [_mg] call { params ["_mg"]; for "_i" from 1 to (14 + (round (Random 14))) do { _mg action ["UseWeapon", _mg, gunner _mg, (round random 3)]; sleep (0.05 + random 0.1); }; //waitUntil { unitReady _mg }; }; sleep (0.5 + random 1.5);//(1.1 - random 1); } else {_stop = _stop + 1;sleep 1.5}; }; }; } forEach _MG_ARRAY; // Repeat the process for each machine gun unit in the array Edited December 2 by mikey74 Got rid of non working script. Added comments to script explaining whats up. This works. Added link to useractions. Added another version for Threader to try out if this is what they are looking for. Added AA simulation too. 2 Share this post Link to post Share on other sites
pierremgi 4892 Posted December 2 Example: place in init field of the gunner (here a MK30 HMG). Make sure your player is prone at start! this spawn { while {true} do { sleep 2; _this doSuppressiveFire (getposASL player vectorAdd [0,0,1]); _this suppressFor 10; _this setVehicleAmmo 1; sleep 10; }; }; Feel free to trigger it as you need. doSuppressiveFire works in ASL position. The vectorAdd can set an altitude (z) above the player's feet.setVehicleAmmo is for turret. For heavy gunner, use setAmmo instead (the syntax is different) 3 Share this post Link to post Share on other sites
mikey74 186 Posted December 2 1 hour ago, pierremgi said: Example: place in init field of the gunner (here a MK30 HMG). Make sure your player is prone at start! this spawn { while {true} do { sleep 2; _this doSuppressiveFire (getposASL player vectorAdd [0,0,1]); _this suppressFor 10; _this setVehicleAmmo 1; sleep 10; }; }; Feel free to trigger it as you need. doSuppressiveFire works in ASL position. The vectorAdd can set an altitude (z) above the player's feet.setVehicleAmmo is for turret. For heavy gunner, use setAmmo instead (the syntax is different) I tested this and was getting slaughtered so I edited you script a bit. Still get nailed on 1st shot most times. Much simpler way than my code above. lol You follow my so called rules much better than me. Which is KISS: Keep it simple stupid. lol Thanks Pierremgi. 🙂 Spoiler [this] spawn { params ["_mg"]; while {true} do { sleep 2; _mg doSuppressiveFire (getposASL player vectorAdd [((1 + random 1) + (-1 + random -1)), ((1 + random 1) + (-1 + random -1)), (2 + random 2)]); _mg suppressFor 3; _mg setVehicleAmmo 1; sleep 3; }; }; 1 1 Share this post Link to post Share on other sites
pierremgi 4892 Posted December 2 _mg doSuppressiveFire (getposASL player vectorAdd [((1 + random 1) + (-1 + random -1)), ((1 + random 1) + (-1 + random -1)), (2 + random 2)]);..... or _mg doSuppressiveFire (getposASL player vectorAdd [-1 + random 2, -1 + random 2, (2 + random 2)]); (same 😋) 1+ 0...1 means 1...2 -1 + -1...0 means -2... -1 1...2 + -2... -1 means -1 ... 1, same as -1 + 0...2 1 Share this post Link to post Share on other sites
cooked auto 7 Posted December 2 Hm, interesting. Going to give these a try later. Much appreciated. And I do appreciate when the scripts are simple, less of a headache for me. 1 Share this post Link to post Share on other sites