Jump to content
Sign in to follow this  
Frenzi_

Forcing the AI to shoot while running

Recommended Posts

(Excuse me, as I'm sure this has been discussed many times already, but I can't seem to find a thread about it.)

So the question is simple:

Is there a way to force AI soldiers to fire their weapons (without looking up) while running?

As we know, the "fire" command makes the AI look up and shoot at the sky. Maybe someone has workaround for this...?

Share this post


Link to post
Share on other sites

IIRC there's no "run and shoot" animations in vanilla OFP. There is in the WW4 and WW4bis mods, though.

You can force AI units to shoot towards any direction you want by placing some invisible object in the desired direction and elevation (such as an invisible helo landing marker) and making them target it. With that said, they will revert to the "looking up" stance if they fire at that target or you delete it. This solution requires a lot of micro anyway, and might interfere with normal AI behaviour if not careful.

EDIT: In any case, here's a snippet for something similar:

_tgt = "HeliHEmpty" createVehicle [_x,_y,200];
~0.1
_unit reveal _tgt;
_mode = _flare;
_unit selectWeapon _muzzle;
~0.1
_unit doTarget _tgt;
~1
_unit fire [_muzzle, _mode, _flare];
deleteVehicle _tgt;
_unit doTarget objNull;

This would be better to be run only on the leader, and then loop through all the units of the group. You should also make sure to only make them fire if they are using their primary weapon, and use the proper muzzle, mode and ammo of the weapon used.

You might also replace the custom target with an enemy unit but, for that, you should first keep an array with all the alive enemy units, then check for the closest ones, then check for the ones in front of the leader. Quite a hassle.

Edited by kenoxite

Share this post


Link to post
Share on other sites

Thanks for posting.

I see what you're trying to show with the code, but the problem is that the AI would still stop before shooting (even if just for a second), instead of shooting while doing the running animation.

(Both the vanilla jogging and sprinting anims allow for shooting).

I've already tried dozens of combinations of playMove/reveal/doTarget/fire, but didn't manage to make them run and shoot at the same time, in any way (except for shooting at the clouds).

Edited by Ferenczi

Share this post


Link to post
Share on other sites
Because this is OFP.

Oh boy, I shouldn't just browse the "unread posts" section without checking the referenced sub-forums. :icon_ohmygod: My apologies, my response was indeed useless in this context.

Share this post


Link to post
Share on other sites
Oh boy, I shouldn't just browse the "unread posts" section without checking the referenced sub-forums. :icon_ohmygod: My apologies, my response was indeed useless in this context.

Yep, happens to me all the time.

Share this post


Link to post
Share on other sites
(except for shooting at the clouds).

OFP units do take the "spray & pray" motto to the letter.

It seems that little can be done with the animations then. But if the bullets are shot you could at least take control of them and move them forward, so pray happens but the spray would focus on the direction of your choosing.

Share this post


Link to post
Share on other sites

Of course my answer is too late, but if it still actual, i recommend to use addon of invisible targets. You need to write script that will create invisible targets in front of your movement, - use the tutorial about sin,cos,tg in OFP to make it.

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  

×