Jump to content
dpatt711

Force AI to spray machine gun?

Recommended Posts

So I'm trying to set up a D-Day-esque mission where AI heavy gunners are on top of the hill with LMGs. However the heavy gunners will only fire in slow controlled 2-4 round taps. I want the AI to fire several second long bursts and want bullets to be flying all around with a lower chance of getting hit. I've tried everything from a looping forceWeaponFire command, to setting unit recoil to 0, using new suppress commands, etc but I cannot get AI to do uncontrolled sprays. Any advice?

Share this post


Link to post
Share on other sites

hi

have you tried doFire with doTarget?

 

changing the target all the time to random enemy and then calling doFire might work.

 

edit: there's also fire command

Share this post


Link to post
Share on other sites

At the bottom of the FireAtTarget Wiki page is a table comparing all the different commands for forcing unit to fire.  Some combination of these, plus new suppress commands will likely work...I would methodically test each variation.  For most aggressive automatic fire doSuppressiveFire may be the best bet (coupled with doWatch position or doTarget object).  Also note that with forceWeaponFire mode,  "FullAuto" may not be the correct mode string for certain weapons.  So be sure you use the right mode string for the weapons in question.

 

Another technique is place invisible targets and have AI target those.  See if they go full-auto on these.

 switch (_side) do 
{ 	case east:{        _bulletMagnetUnitType = "O_TargetSoldier";}; 
    case west:{        _bulletMagnetUnitType = "B_TargetSoldier";}; 
    case independent:{ _bulletMagnetUnitType = "I_TargetSoldier";}; 
    case civilian:{    _bulletMagnetUnitType = "I_TargetSoldier";}; 
 };
_bulletMagnet = createVehicle [_bulletMagnetUnitType,  [0,0,1000], [], 0, "CAN_COLLIDE"];
_bulletMagnet allowDamage false;

I use the above for creating invisible targets that I attach to JBOY Dogs to get AI to fire on them. Then use crazy loops that reveal, dowatch, dotarget and forcefire and dofire.  At a distance they won't full-auto, but very close they may.  Your mileage may vary.  Good luck, and please post a solution if you find one.

  • Like 1

Share this post


Link to post
Share on other sites

I'm trying to find a way to do this as well without loads of disgusting loops. 

 

Don't want to hijack your thread but felt like we had the same issue. Getting AI to spray. I'm trying to make them spray with their kalashnikovs a lot more with low accuracy and long firing times. 

 

I'd make a few dummy targets at the beach around where the machinegunners would shoot. Then make them change target every 1-2 seconds between those and just loop fire/doFire. That way the machinegunner will spray left, right, up, down (Might stop between it but if at a distance you probably wouldn't notice). That might simulate a really nice d day style scenario without making the AI gun everyone down with 1 shot 1 kill MG's like snipers. 

  • Like 1

Share this post


Link to post
Share on other sites
On 11/11/2016 at 6:51 AM, Spatsiba said:

I'm trying to find a way to do this as well without loads of disgusting loops. 

 

Don't want to hijack your thread but felt like we had the same issue. Getting AI to spray. I'm trying to make them spray with their kalashnikovs a lot more with low accuracy and long firing times. 

 

I'd make a few dummy targets at the beach around where the machinegunners would shoot. Then make them change target every 1-2 seconds between those and just loop fire/doFire. That way the machinegunner will spray left, right, up, down (Might stop between it but if at a distance you probably wouldn't notice). That might simulate a really nice d day style scenario without making the AI gun everyone down with 1 shot 1 kill MG's like snipers. 

Could you explain this in more detail, if possible, put your script lines?

Share this post


Link to post
Share on other sites
params ["_unit"];

_auto_fire = "";
_current_weapon = currentWeapon _unit;

// get all fire modes of units weapon
_modes = getArray (configFile >> "CfgWeapons" >> _current_weapon >> "modes"));

//search for the fire mode which has the phrase "auto" in it
_index = _modes findIf {"auto" find (toLower _x) > -1};

//if phrase "auto" was found then use this mode
if (_index > -1) then
{
 _auto_fire = _modes select _index;
}
else
{
 //"auto" were not found. use last mode in array
_auto_fire = _modes select (count _modes - 1);
};

//fire weapon with selected fire mode
_unit forceWeaponFire [_current_weapon, _auto_fire];

this could be a start to get auto fireing work. nothing tested. just written.

  • Like 3

Share this post


Link to post
Share on other sites
5 minutes ago, sarogahtyp said:

this could be a start to get auto fireing work. nothing tested. just written. 

and where to prescribe it? in init unit? or create a file "script.cfg"

Share this post


Link to post
Share on other sites

I posted a force auto fire solution in this thread yesterday:  

 

  • Like 1

Share this post


Link to post
Share on other sites
3 minutes ago, johnnyboy said:

I posted a force auto fire solution in this thread yesterday:   

 

will it work for the enemy team? I just need all the units on the map (even those that have just appeared) to be able to shoot in bursts or full auto

Share this post


Link to post
Share on other sites
6 minutes ago, AlexMercerIV said:

will it work for the enemy team? I just need all the units on the map (even those that have just appeared) to be able to shoot in bursts or full auto

It would take a little work.  You could put that code into a fired event handler, and every time the ai chose to fire, they would fire bursts or auto.  So you run forEach allUnits loop to assign the EventHandler to every unit and you're done.  Should work.

 

You may also need to do this:  In the fired eventhandler you want to first delete this eventhandler for the shooter, then run my code to auto fire, then re-add same eventhandler to shooter.  We delete the EH because you don't want the EH executing every time the auto-fire loop makes him fire.

  • Like 1

Share this post


Link to post
Share on other sites
22 minutes ago, AlexMercerIV said:

and where to prescribe it? in init unit? or create a file "script.cfg"

 

10 minutes ago, AlexMercerIV said:

will it work for the enemy team? I just need all the units on the map (even those that have just appeared) to be able to shoot in bursts or full auto

 

I think what you want to do is more than your scripting skills allow. It's all possible but maybe it would be easier to use an AI mod on server to achieve your goal. I had good experiences with VCOM AI and ASR AI mods. But idk if it fits your need

  • Like 1

Share this post


Link to post
Share on other sites
7 minutes ago, sarogahtyp said:

 

 

I think what you want to do is more than your scripting skills allow. It's all possible but maybe it would be easier to use an AI mod on server to achieve your goal. I had good experiences with VCOM AI and ASR AI mods. But idk if it fits your need 

Yes, Vcom ai gives bots improved maneuvers and skill control, but they still shoot single after 150-200m. so vcom ai is not a solution to my problem ...

I was hoping that someone had already made a similar script or mod

Share this post


Link to post
Share on other sites
5 minutes ago, AlexMercerIV said:

Yes, Vcom ai gives bots improved maneuvers and skill control, but they still shoot single after 150-200m. so vcom ai is not a solution to my problem ...

I was hoping that someone had already made a similar script or mod

there are various AI mods out. just try em out. I think ASR AI mod was a bit more aggressive and engages better on long ranges but my tests were 2 years ago. could have changed a lot since then.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×