Jump to content

Recommended Posts

Hey

How to get (AI) machinegunner to shoot 30 shots after noticing the player or possibly shoot Suppressive Fire if the player is over 300 m

It would be good if it is a function.

 

Define.sqf 

GunsType = 

["rhs_weap_pkm",

"rhs_weap_mg42"

];

 

Share this post


Link to post
Share on other sites

So, simple version, add the below to a script (let's go with  fire.sqf). Haven't tested it, but I've taken it out of a function I wrote that worked, and just changed it a little bit.

 

fire.sqf

params ["_unit","_rounds"];

_logic = createGroup west createUnit ["Logic", [0,0,0], [], 0, "NONE"];
_weapon = primaryWeapon _unit;

_endBurst = ((_unit ammo _weapon) - _rounds);

while {((_unit ammo _weapon) > _endBurst) && ((_unit ammo _weapon) != 0) && (alive _unit)} do {
	_firer action ["UseWeapon",vehicle _unit,_unit,0];
};

Run it with:

nul = [_unit,_rounds] execVM "fire.sqf";

- _unit - the unit to be firing.
- _rounds - the number of rounds to fire.

 

Alternatively, you could have a look at using the function I took it from:

It'll allow you to do things like this (video says WIP, but it's a complete system now):

Bit more complex than the above code, but you might find use for 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

×