Hi Rommel.
I noticed 2 more UseWeapon firing bugs:
a) AT soldiers will fire bullets out of their rocket tubes.
b) Grenadiers often point their weapon at a severe up angle (like they were going to shoot a grenade), and then UseWeapon fires a bullet at that funny angle. Looks dumb.
Also, I may have solved the random shooting problem, and the AT soldier problem. Attached is a sample mission I was tinkering with (based from your sample mission). In it are 3 IA scripts:
- ROMMIA.sqf - your original script, unchanged
- ROMMIA3.sqf - modified to cure random shooting using Mando Angles
- ROMMIA2.sqf - modified to cure random shooting using Mando Angles plus a new game logic that shooters target as a proxy for the foe. This version also has code in it for excluding snipers, and removing/restoring all rockets from AT soldiers (which cures them of shooting bullets from their rocket tubes).
I tested the 3 different versions by modifying the init lines of the 3 west groups to call whichever script I wanted to test. In order to trigger the suppression scripts, you need to run to one of the cover objects and fire your MG at each of the 3 groups. Then hide. Then switch to the West officers to observe how the suppressors are shooting.
In the modified scripts I put in comments to clearly bracket the changes I made to make it easy for you to identify the new code. If you decide to use any of this code, feel free to rip out my comments.
I used Mando Angles to prevent the shooter from shooting unless he is pointing at original target +/- 30 degrees. So when he is tracking a phantom target too far away from original target, he will not shoot.
In the ROMMIA2 version, I also added a gamelogic for the shooter to target, rather than target the foe unit himself. I discovered that as time elapses, the knowsabout is less fresh, and the shooter will be more likely to target away from the foe location (especially if the foe was moving). The game logic is setposed to the foe's location, and it is deleted and recreated inside the main suppress loop. By recreating it, the knowsabout is fresh again, and the shooter re-targets close to the foe position.
I don't know if there is any performance consideration with deleting and recreating a gamelogic with every loop iteration...but it has worked fine in these limited tests.
Anyway, I had fun doing this, and I hope you find it useful. I know I plan to use this on the sequel to my mission Last Tango in Bagango.
Adios,
Johnnyboy.
Edit1: The same type of fix used for AT soldiers, also works for grenadiers, to prevent them from shooting up in the air. You simply remove and save their grenades at the top of the suppress function:
// Remove rifle grenades from shooter, so we don't see problem where soldier
// points weapon in air and useweapon makes him fire bullets up (which looks stupid)
if ((magazines _x) find "1Rnd_HE_GP25" > -1) then
{
_grenMag = "1Rnd_HE_GP25";
_grenCount = count(magazines _x - (magazines _x - [_grenMag]));
for "_y" from 1 to _grenCount do {_x removemagazine _grenMag};
player sidechat format ["removing %1 grenade mags",_grenCount];
};
if ((magazines _x) find "1Rnd_HE_M203" > -1) then
{
_grenMag = "1Rnd_HE_M203";
_grenCount = count(magazines _x - (magazines _x - [_grenMag]));
for "_y" from 1 to _grenCount do {_x removemagazine _grenMag};
player sidechat format ["removing %1 grenade mags",_grenCount];
};
And then add the grenades back before exiting suppress function:
for "_y" from 1 to _grenCount do {_x addmagazine _grenMag};
Edit2: In a copy of your script where I only use the suppress code, I had a problem where once suppressing units "needed ammo", they would go off course to get ammo, but the UseWeapon was still making them fire, so they fired in the wrong direction. So I placed some ammo boxes near the 3 suppressing teams into your demo mission, and the modified demo mission I made, and I removed all but 1 magazine from some of the suppressors. These missions passed the test (both your original, and the modified one). When they went for ammo, they did not fire in the wrong direction. So that's good! In my smaller test suppress version that I copied from your code I must be missing something that allowed the problem to occur...