Jump to content
Sign in to follow this  
comp_uter15776

AI Selective Fire?

Recommended Posts

Hello all,

Like so many on here, I'm making a sort of training camp with ambient life, and would like to know how to make the AI shoot once at a target. I couldn't for the life of me find any solutions so far on this forum or on any others, so this was my last resort.

Right now, I have this in my soldier's (gunman1) init:

_handle = this fireAtTarget [Target1,"BAF_L85A2_RIS_ACOG"];

"Target1" is an object in the form of a target (good guess eh). I've also tried the following:

Gunman1 doTarget Target1; Gunman1 doFire Target1;  this allowdamage false; this addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];

Not entirely sure what it was meant to do, however both of the above, the former to less of an extent, end up shooting the rifle like a bloody machinegun. When you have 5 guys on a range and they're all shooting automatically at one target... well... make sure you don't wear headphones.

Also, another thought popped into my mind: How would one go about making one guy (i.e. Gunman1) shoot multiple targets, one after another? So, in effect they could have say, 5 targets, shoot each one once, then stop.

Many thanks in advance,

Comp_uter15776

Share this post


Link to post
Share on other sites

I did try and make a script and it did work up to a point.

The problem is that the first ten or twelve shots were excellent but then they can't seem to see the targets and miss every time.

I've noticed that after a certain amount of time some sort of AI left right scan kicks in and this overrides the dotarget command or at least causes a conflict.

I've tried turning off AI's "target" and "autotarget" but it makes no difference.

But if you only need a few targets it may work well enough

https://www.dropbox.com/s/7ugk9jqksjjx3yx/single_shot.Chernarus.7z

Share this post


Link to post
Share on other sites

Thanks Mattar_Tharkari, but I'm a tad confused as to how one could go about actually implementing that as a directive for the AI to only use Single fire. From what that page shows (the latter of your links), it returns their current wepmode as a string, rather than being able to input that into the AI.

F2k Sel, I'll check that now :)

EDIT: Excellent stuff. Shoots at a semi-auto rate, right up until the targets end. I managed to also make both shoot (the left one wouldn't at all) by replacing it's init with what you put for the right one

effectively replacing "this doTarget targ1" with null=[this,targetlogic,[targ1,targ2,targ3,targ4,targ5,targ6]] execvm "pop_targ.sqf"

Edited by Comp_uter15776

Share this post


Link to post
Share on other sites

Let me remedy your confusion lol:

Put that in a trigger:

val = 0; player action ["SwitchWeapon", vehicle player, vehicle player, val]; hint format["%1",(currentWeaponMode player)];

val can be 0,1,2 - Single, Burst, FullAuto (will only work if the weapon has the mode, G36 has all 3 modes - values for M16 will be 0, Single - 1,Burst, others will be 0,Single - 1,FullAuto. As you need single shot it's easy - it's always 0)

currentWeaponMode helps you debug with the hint.

To set all units to single mode use this:

{_x addEventHandler ["Fired", {(_this select 0) action ["SwitchWeapon", vehicle (_this select 0), vehicle (_this select 0), 0]}]}forEach allUnits;

as soon as anyone fires, their weapon will be set to single shot only, no matter what they select. MG's do not have a single shot mode so it will not work for them.

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

Ah I see, thanks for a prompt and helpful response :) Will definitely incorporate where targets are not required, but single fire still is!

Share this post


Link to post
Share on other sites

I tested it and although they are using single shot AI still unload multiple rounds into the target when using dofire.

The unit on the left wasn't set up I was using it to observe the dotarget problem of it starting to sweep.

The best option for the second unit would be to place another set of targets and pass those targets to the script.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

You say about it starting to sweep, would not disabling the autotarget of AI stop that? :/ As in, what's the point in scanning if they're not targetting anything anyway...

Thanks again though, your script was just the thing for the kind of ambience I required :) The only time they don't shoot any more is when the targets are down.

Share this post


Link to post
Share on other sites

No I tried disabling AI's targeting but it makes no difference.

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
Sign in to follow this  

×